patch_realtek.c 401 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123
  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_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_BENQ_T31,
  93. ALC262_AUTO,
  94. ALC262_MODEL_LAST /* last tag */
  95. };
  96. /* ALC268 models */
  97. enum {
  98. ALC268_3ST,
  99. ALC268_TOSHIBA,
  100. ALC268_ACER,
  101. ALC268_AUTO,
  102. ALC268_MODEL_LAST /* last tag */
  103. };
  104. /* ALC861 models */
  105. enum {
  106. ALC861_3ST,
  107. ALC660_3ST,
  108. ALC861_3ST_DIG,
  109. ALC861_6ST_DIG,
  110. ALC861_UNIWILL_M31,
  111. ALC861_TOSHIBA,
  112. ALC861_ASUS,
  113. ALC861_ASUS_LAPTOP,
  114. ALC861_AUTO,
  115. ALC861_MODEL_LAST,
  116. };
  117. /* ALC861-VD models */
  118. enum {
  119. ALC660VD_3ST,
  120. ALC660VD_3ST_DIG,
  121. ALC861VD_3ST,
  122. ALC861VD_3ST_DIG,
  123. ALC861VD_6ST_DIG,
  124. ALC861VD_LENOVO,
  125. ALC861VD_DALLAS,
  126. ALC861VD_HP,
  127. ALC861VD_AUTO,
  128. ALC861VD_MODEL_LAST,
  129. };
  130. /* ALC662 models */
  131. enum {
  132. ALC662_3ST_2ch_DIG,
  133. ALC662_3ST_6ch_DIG,
  134. ALC662_3ST_6ch,
  135. ALC662_5ST_DIG,
  136. ALC662_LENOVO_101E,
  137. ALC662_AUTO,
  138. ALC662_MODEL_LAST,
  139. };
  140. /* ALC882 models */
  141. enum {
  142. ALC882_3ST_DIG,
  143. ALC882_6ST_DIG,
  144. ALC882_ARIMA,
  145. ALC882_W2JC,
  146. ALC882_TARGA,
  147. ALC882_ASUS_A7J,
  148. ALC885_MACPRO,
  149. ALC885_MBP3,
  150. ALC885_IMAC24,
  151. ALC882_AUTO,
  152. ALC882_MODEL_LAST,
  153. };
  154. /* ALC883 models */
  155. enum {
  156. ALC883_3ST_2ch_DIG,
  157. ALC883_3ST_6ch_DIG,
  158. ALC883_3ST_6ch,
  159. ALC883_6ST_DIG,
  160. ALC883_TARGA_DIG,
  161. ALC883_TARGA_2ch_DIG,
  162. ALC883_ACER,
  163. ALC883_ACER_ASPIRE,
  164. ALC883_MEDION,
  165. ALC883_MEDION_MD2,
  166. ALC883_LAPTOP_EAPD,
  167. ALC883_LENOVO_101E_2ch,
  168. ALC883_LENOVO_NB0763,
  169. ALC888_LENOVO_MS7195_DIG,
  170. ALC883_HAIER_W66,
  171. ALC888_6ST_HP,
  172. ALC888_3ST_HP,
  173. ALC883_AUTO,
  174. ALC883_MODEL_LAST,
  175. };
  176. /* for GPIO Poll */
  177. #define GPIO_MASK 0x03
  178. struct alc_spec {
  179. /* codec parameterization */
  180. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  181. unsigned int num_mixers;
  182. const struct hda_verb *init_verbs[5]; /* initialization verbs
  183. * don't forget NULL
  184. * termination!
  185. */
  186. unsigned int num_init_verbs;
  187. char *stream_name_analog; /* analog PCM stream */
  188. struct hda_pcm_stream *stream_analog_playback;
  189. struct hda_pcm_stream *stream_analog_capture;
  190. char *stream_name_digital; /* digital PCM stream */
  191. struct hda_pcm_stream *stream_digital_playback;
  192. struct hda_pcm_stream *stream_digital_capture;
  193. /* playback */
  194. struct hda_multi_out multiout; /* playback set-up
  195. * max_channels, dacs must be set
  196. * dig_out_nid and hp_nid are optional
  197. */
  198. /* capture */
  199. unsigned int num_adc_nids;
  200. hda_nid_t *adc_nids;
  201. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  202. /* capture source */
  203. unsigned int num_mux_defs;
  204. const struct hda_input_mux *input_mux;
  205. unsigned int cur_mux[3];
  206. /* channel model */
  207. const struct hda_channel_mode *channel_mode;
  208. int num_channel_mode;
  209. int need_dac_fix;
  210. /* PCM information */
  211. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  212. /* dynamic controls, init_verbs and input_mux */
  213. struct auto_pin_cfg autocfg;
  214. unsigned int num_kctl_alloc, num_kctl_used;
  215. struct snd_kcontrol_new *kctl_alloc;
  216. struct hda_input_mux private_imux;
  217. hda_nid_t private_dac_nids[5];
  218. /* hooks */
  219. void (*init_hook)(struct hda_codec *codec);
  220. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  221. /* for pin sensing */
  222. unsigned int sense_updated: 1;
  223. unsigned int jack_present: 1;
  224. #ifdef CONFIG_SND_HDA_POWER_SAVE
  225. struct hda_loopback_check loopback;
  226. #endif
  227. };
  228. /*
  229. * configuration template - to be copied to the spec instance
  230. */
  231. struct alc_config_preset {
  232. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  233. * with spec
  234. */
  235. const struct hda_verb *init_verbs[5];
  236. unsigned int num_dacs;
  237. hda_nid_t *dac_nids;
  238. hda_nid_t dig_out_nid; /* optional */
  239. hda_nid_t hp_nid; /* optional */
  240. unsigned int num_adc_nids;
  241. hda_nid_t *adc_nids;
  242. hda_nid_t dig_in_nid;
  243. unsigned int num_channel_mode;
  244. const struct hda_channel_mode *channel_mode;
  245. int need_dac_fix;
  246. unsigned int num_mux_defs;
  247. const struct hda_input_mux *input_mux;
  248. void (*unsol_event)(struct hda_codec *, unsigned int);
  249. void (*init_hook)(struct hda_codec *);
  250. #ifdef CONFIG_SND_HDA_POWER_SAVE
  251. struct hda_amp_list *loopbacks;
  252. #endif
  253. };
  254. /*
  255. * input MUX handling
  256. */
  257. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  258. struct snd_ctl_elem_info *uinfo)
  259. {
  260. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  261. struct alc_spec *spec = codec->spec;
  262. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  263. if (mux_idx >= spec->num_mux_defs)
  264. mux_idx = 0;
  265. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  266. }
  267. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  268. struct snd_ctl_elem_value *ucontrol)
  269. {
  270. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  271. struct alc_spec *spec = codec->spec;
  272. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  273. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  274. return 0;
  275. }
  276. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  277. struct snd_ctl_elem_value *ucontrol)
  278. {
  279. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  280. struct alc_spec *spec = codec->spec;
  281. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  282. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  283. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  284. spec->adc_nids[adc_idx],
  285. &spec->cur_mux[adc_idx]);
  286. }
  287. /*
  288. * channel mode setting
  289. */
  290. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  291. struct snd_ctl_elem_info *uinfo)
  292. {
  293. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  294. struct alc_spec *spec = codec->spec;
  295. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  296. spec->num_channel_mode);
  297. }
  298. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  299. struct snd_ctl_elem_value *ucontrol)
  300. {
  301. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  302. struct alc_spec *spec = codec->spec;
  303. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  304. spec->num_channel_mode,
  305. spec->multiout.max_channels);
  306. }
  307. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  308. struct snd_ctl_elem_value *ucontrol)
  309. {
  310. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  311. struct alc_spec *spec = codec->spec;
  312. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  313. spec->num_channel_mode,
  314. &spec->multiout.max_channels);
  315. if (err >= 0 && spec->need_dac_fix)
  316. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  317. return err;
  318. }
  319. /*
  320. * Control the mode of pin widget settings via the mixer. "pc" is used
  321. * instead of "%" to avoid consequences of accidently treating the % as
  322. * being part of a format specifier. Maximum allowed length of a value is
  323. * 63 characters plus NULL terminator.
  324. *
  325. * Note: some retasking pin complexes seem to ignore requests for input
  326. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  327. * are requested. Therefore order this list so that this behaviour will not
  328. * cause problems when mixer clients move through the enum sequentially.
  329. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  330. * March 2006.
  331. */
  332. static char *alc_pin_mode_names[] = {
  333. "Mic 50pc bias", "Mic 80pc bias",
  334. "Line in", "Line out", "Headphone out",
  335. };
  336. static unsigned char alc_pin_mode_values[] = {
  337. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  338. };
  339. /* The control can present all 5 options, or it can limit the options based
  340. * in the pin being assumed to be exclusively an input or an output pin. In
  341. * addition, "input" pins may or may not process the mic bias option
  342. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  343. * accept requests for bias as of chip versions up to March 2006) and/or
  344. * wiring in the computer.
  345. */
  346. #define ALC_PIN_DIR_IN 0x00
  347. #define ALC_PIN_DIR_OUT 0x01
  348. #define ALC_PIN_DIR_INOUT 0x02
  349. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  350. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  351. /* Info about the pin modes supported by the different pin direction modes.
  352. * For each direction the minimum and maximum values are given.
  353. */
  354. static signed char alc_pin_mode_dir_info[5][2] = {
  355. { 0, 2 }, /* ALC_PIN_DIR_IN */
  356. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  357. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  358. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  359. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  360. };
  361. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  362. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  363. #define alc_pin_mode_n_items(_dir) \
  364. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  365. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  366. struct snd_ctl_elem_info *uinfo)
  367. {
  368. unsigned int item_num = uinfo->value.enumerated.item;
  369. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  370. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  371. uinfo->count = 1;
  372. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  373. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  374. item_num = alc_pin_mode_min(dir);
  375. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  376. return 0;
  377. }
  378. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  379. struct snd_ctl_elem_value *ucontrol)
  380. {
  381. unsigned int i;
  382. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  383. hda_nid_t nid = kcontrol->private_value & 0xffff;
  384. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  385. long *valp = ucontrol->value.integer.value;
  386. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  387. AC_VERB_GET_PIN_WIDGET_CONTROL,
  388. 0x00);
  389. /* Find enumerated value for current pinctl setting */
  390. i = alc_pin_mode_min(dir);
  391. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  392. i++;
  393. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  394. return 0;
  395. }
  396. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  397. struct snd_ctl_elem_value *ucontrol)
  398. {
  399. signed int change;
  400. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  401. hda_nid_t nid = kcontrol->private_value & 0xffff;
  402. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  403. long val = *ucontrol->value.integer.value;
  404. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  405. AC_VERB_GET_PIN_WIDGET_CONTROL,
  406. 0x00);
  407. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  408. val = alc_pin_mode_min(dir);
  409. change = pinctl != alc_pin_mode_values[val];
  410. if (change) {
  411. /* Set pin mode to that requested */
  412. snd_hda_codec_write_cache(codec, nid, 0,
  413. AC_VERB_SET_PIN_WIDGET_CONTROL,
  414. alc_pin_mode_values[val]);
  415. /* Also enable the retasking pin's input/output as required
  416. * for the requested pin mode. Enum values of 2 or less are
  417. * input modes.
  418. *
  419. * Dynamically switching the input/output buffers probably
  420. * reduces noise slightly (particularly on input) so we'll
  421. * do it. However, having both input and output buffers
  422. * enabled simultaneously doesn't seem to be problematic if
  423. * this turns out to be necessary in the future.
  424. */
  425. if (val <= 2) {
  426. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  427. HDA_AMP_MUTE, HDA_AMP_MUTE);
  428. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  429. HDA_AMP_MUTE, 0);
  430. } else {
  431. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  432. HDA_AMP_MUTE, HDA_AMP_MUTE);
  433. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  434. HDA_AMP_MUTE, 0);
  435. }
  436. }
  437. return change;
  438. }
  439. #define ALC_PIN_MODE(xname, nid, dir) \
  440. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  441. .info = alc_pin_mode_info, \
  442. .get = alc_pin_mode_get, \
  443. .put = alc_pin_mode_put, \
  444. .private_value = nid | (dir<<16) }
  445. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  446. * together using a mask with more than one bit set. This control is
  447. * currently used only by the ALC260 test model. At this stage they are not
  448. * needed for any "production" models.
  449. */
  450. #ifdef CONFIG_SND_DEBUG
  451. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  452. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  453. struct snd_ctl_elem_value *ucontrol)
  454. {
  455. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  456. hda_nid_t nid = kcontrol->private_value & 0xffff;
  457. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  458. long *valp = ucontrol->value.integer.value;
  459. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  460. AC_VERB_GET_GPIO_DATA, 0x00);
  461. *valp = (val & mask) != 0;
  462. return 0;
  463. }
  464. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  465. struct snd_ctl_elem_value *ucontrol)
  466. {
  467. signed int change;
  468. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  469. hda_nid_t nid = kcontrol->private_value & 0xffff;
  470. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  471. long val = *ucontrol->value.integer.value;
  472. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  473. AC_VERB_GET_GPIO_DATA,
  474. 0x00);
  475. /* Set/unset the masked GPIO bit(s) as needed */
  476. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  477. if (val == 0)
  478. gpio_data &= ~mask;
  479. else
  480. gpio_data |= mask;
  481. snd_hda_codec_write_cache(codec, nid, 0,
  482. AC_VERB_SET_GPIO_DATA, gpio_data);
  483. return change;
  484. }
  485. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  486. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  487. .info = alc_gpio_data_info, \
  488. .get = alc_gpio_data_get, \
  489. .put = alc_gpio_data_put, \
  490. .private_value = nid | (mask<<16) }
  491. #endif /* CONFIG_SND_DEBUG */
  492. /* A switch control to allow the enabling of the digital IO pins on the
  493. * ALC260. This is incredibly simplistic; the intention of this control is
  494. * to provide something in the test model allowing digital outputs to be
  495. * identified if present. If models are found which can utilise these
  496. * outputs a more complete mixer control can be devised for those models if
  497. * necessary.
  498. */
  499. #ifdef CONFIG_SND_DEBUG
  500. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  501. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  502. struct snd_ctl_elem_value *ucontrol)
  503. {
  504. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  505. hda_nid_t nid = kcontrol->private_value & 0xffff;
  506. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  507. long *valp = ucontrol->value.integer.value;
  508. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  509. AC_VERB_GET_DIGI_CONVERT, 0x00);
  510. *valp = (val & mask) != 0;
  511. return 0;
  512. }
  513. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  514. struct snd_ctl_elem_value *ucontrol)
  515. {
  516. signed int change;
  517. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  518. hda_nid_t nid = kcontrol->private_value & 0xffff;
  519. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  520. long val = *ucontrol->value.integer.value;
  521. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  522. AC_VERB_GET_DIGI_CONVERT,
  523. 0x00);
  524. /* Set/unset the masked control bit(s) as needed */
  525. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  526. if (val==0)
  527. ctrl_data &= ~mask;
  528. else
  529. ctrl_data |= mask;
  530. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  531. ctrl_data);
  532. return change;
  533. }
  534. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  535. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  536. .info = alc_spdif_ctrl_info, \
  537. .get = alc_spdif_ctrl_get, \
  538. .put = alc_spdif_ctrl_put, \
  539. .private_value = nid | (mask<<16) }
  540. #endif /* CONFIG_SND_DEBUG */
  541. /*
  542. * set up from the preset table
  543. */
  544. static void setup_preset(struct alc_spec *spec,
  545. const struct alc_config_preset *preset)
  546. {
  547. int i;
  548. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  549. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  550. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  551. i++)
  552. spec->init_verbs[spec->num_init_verbs++] =
  553. preset->init_verbs[i];
  554. spec->channel_mode = preset->channel_mode;
  555. spec->num_channel_mode = preset->num_channel_mode;
  556. spec->need_dac_fix = preset->need_dac_fix;
  557. spec->multiout.max_channels = spec->channel_mode[0].channels;
  558. spec->multiout.num_dacs = preset->num_dacs;
  559. spec->multiout.dac_nids = preset->dac_nids;
  560. spec->multiout.dig_out_nid = preset->dig_out_nid;
  561. spec->multiout.hp_nid = preset->hp_nid;
  562. spec->num_mux_defs = preset->num_mux_defs;
  563. if (!spec->num_mux_defs)
  564. spec->num_mux_defs = 1;
  565. spec->input_mux = preset->input_mux;
  566. spec->num_adc_nids = preset->num_adc_nids;
  567. spec->adc_nids = preset->adc_nids;
  568. spec->dig_in_nid = preset->dig_in_nid;
  569. spec->unsol_event = preset->unsol_event;
  570. spec->init_hook = preset->init_hook;
  571. #ifdef CONFIG_SND_HDA_POWER_SAVE
  572. spec->loopback.amplist = preset->loopbacks;
  573. #endif
  574. }
  575. /* Enable GPIO mask and set output */
  576. static struct hda_verb alc_gpio1_init_verbs[] = {
  577. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  578. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  579. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  580. { }
  581. };
  582. static struct hda_verb alc_gpio2_init_verbs[] = {
  583. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  584. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  585. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  586. { }
  587. };
  588. static struct hda_verb alc_gpio3_init_verbs[] = {
  589. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  590. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  591. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  592. { }
  593. };
  594. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  595. * 31 ~ 16 : Manufacture ID
  596. * 15 ~ 8 : SKU ID
  597. * 7 ~ 0 : Assembly ID
  598. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  599. */
  600. static void alc_subsystem_id(struct hda_codec *codec,
  601. unsigned int porta, unsigned int porte,
  602. unsigned int portd)
  603. {
  604. unsigned int ass, tmp;
  605. ass = codec->subsystem_id;
  606. if (!(ass & 1))
  607. return;
  608. /* Override */
  609. tmp = (ass & 0x38) >> 3; /* external Amp control */
  610. switch (tmp) {
  611. case 1:
  612. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  613. break;
  614. case 3:
  615. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  616. break;
  617. case 7:
  618. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  619. break;
  620. case 5:
  621. switch (codec->vendor_id) {
  622. case 0x10ec0862:
  623. case 0x10ec0660:
  624. case 0x10ec0662:
  625. case 0x10ec0267:
  626. case 0x10ec0268:
  627. snd_hda_codec_write(codec, 0x14, 0,
  628. AC_VERB_SET_EAPD_BTLENABLE, 2);
  629. snd_hda_codec_write(codec, 0x15, 0,
  630. AC_VERB_SET_EAPD_BTLENABLE, 2);
  631. return;
  632. }
  633. case 6:
  634. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  635. hda_nid_t port = 0;
  636. tmp = (ass & 0x1800) >> 11;
  637. switch (tmp) {
  638. case 0: port = porta; break;
  639. case 1: port = porte; break;
  640. case 2: port = portd; break;
  641. }
  642. if (port)
  643. snd_hda_codec_write(codec, port, 0,
  644. AC_VERB_SET_EAPD_BTLENABLE,
  645. 2);
  646. }
  647. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  648. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  649. (tmp == 5 ? 0x3040 : 0x3050));
  650. break;
  651. }
  652. }
  653. /*
  654. * Fix-up pin default configurations
  655. */
  656. struct alc_pincfg {
  657. hda_nid_t nid;
  658. u32 val;
  659. };
  660. static void alc_fix_pincfg(struct hda_codec *codec,
  661. const struct snd_pci_quirk *quirk,
  662. const struct alc_pincfg **pinfix)
  663. {
  664. const struct alc_pincfg *cfg;
  665. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  666. if (!quirk)
  667. return;
  668. cfg = pinfix[quirk->value];
  669. for (; cfg->nid; cfg++) {
  670. int i;
  671. u32 val = cfg->val;
  672. for (i = 0; i < 4; i++) {
  673. snd_hda_codec_write(codec, cfg->nid, 0,
  674. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  675. val & 0xff);
  676. val >>= 8;
  677. }
  678. }
  679. }
  680. /*
  681. * ALC880 3-stack model
  682. *
  683. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  684. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  685. * F-Mic = 0x1b, HP = 0x19
  686. */
  687. static hda_nid_t alc880_dac_nids[4] = {
  688. /* front, rear, clfe, rear_surr */
  689. 0x02, 0x05, 0x04, 0x03
  690. };
  691. static hda_nid_t alc880_adc_nids[3] = {
  692. /* ADC0-2 */
  693. 0x07, 0x08, 0x09,
  694. };
  695. /* The datasheet says the node 0x07 is connected from inputs,
  696. * but it shows zero connection in the real implementation on some devices.
  697. * Note: this is a 915GAV bug, fixed on 915GLV
  698. */
  699. static hda_nid_t alc880_adc_nids_alt[2] = {
  700. /* ADC1-2 */
  701. 0x08, 0x09,
  702. };
  703. #define ALC880_DIGOUT_NID 0x06
  704. #define ALC880_DIGIN_NID 0x0a
  705. static struct hda_input_mux alc880_capture_source = {
  706. .num_items = 4,
  707. .items = {
  708. { "Mic", 0x0 },
  709. { "Front Mic", 0x3 },
  710. { "Line", 0x2 },
  711. { "CD", 0x4 },
  712. },
  713. };
  714. /* channel source setting (2/6 channel selection for 3-stack) */
  715. /* 2ch mode */
  716. static struct hda_verb alc880_threestack_ch2_init[] = {
  717. /* set line-in to input, mute it */
  718. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  719. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  720. /* set mic-in to input vref 80%, mute it */
  721. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  722. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  723. { } /* end */
  724. };
  725. /* 6ch mode */
  726. static struct hda_verb alc880_threestack_ch6_init[] = {
  727. /* set line-in to output, unmute it */
  728. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  729. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  730. /* set mic-in to output, unmute it */
  731. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  732. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  733. { } /* end */
  734. };
  735. static struct hda_channel_mode alc880_threestack_modes[2] = {
  736. { 2, alc880_threestack_ch2_init },
  737. { 6, alc880_threestack_ch6_init },
  738. };
  739. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  740. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  741. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  742. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  743. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  744. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  745. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  746. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  747. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  748. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  749. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  750. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  751. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  752. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  753. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  754. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  755. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  756. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  757. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  758. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  759. {
  760. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  761. .name = "Channel Mode",
  762. .info = alc_ch_mode_info,
  763. .get = alc_ch_mode_get,
  764. .put = alc_ch_mode_put,
  765. },
  766. { } /* end */
  767. };
  768. /* capture mixer elements */
  769. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  770. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  771. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  772. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  773. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  774. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  775. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  776. {
  777. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  778. /* The multiple "Capture Source" controls confuse alsamixer
  779. * So call somewhat different..
  780. * FIXME: the controls appear in the "playback" view!
  781. */
  782. /* .name = "Capture Source", */
  783. .name = "Input Source",
  784. .count = 3,
  785. .info = alc_mux_enum_info,
  786. .get = alc_mux_enum_get,
  787. .put = alc_mux_enum_put,
  788. },
  789. { } /* end */
  790. };
  791. /* capture mixer elements (in case NID 0x07 not available) */
  792. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  793. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  794. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  795. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  796. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  797. {
  798. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  799. /* The multiple "Capture Source" controls confuse alsamixer
  800. * So call somewhat different..
  801. * FIXME: the controls appear in the "playback" view!
  802. */
  803. /* .name = "Capture Source", */
  804. .name = "Input Source",
  805. .count = 2,
  806. .info = alc_mux_enum_info,
  807. .get = alc_mux_enum_get,
  808. .put = alc_mux_enum_put,
  809. },
  810. { } /* end */
  811. };
  812. /*
  813. * ALC880 5-stack model
  814. *
  815. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  816. * Side = 0x02 (0xd)
  817. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  818. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  819. */
  820. /* additional mixers to alc880_three_stack_mixer */
  821. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  822. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  823. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  824. { } /* end */
  825. };
  826. /* channel source setting (6/8 channel selection for 5-stack) */
  827. /* 6ch mode */
  828. static struct hda_verb alc880_fivestack_ch6_init[] = {
  829. /* set line-in to input, mute it */
  830. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  831. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  832. { } /* end */
  833. };
  834. /* 8ch mode */
  835. static struct hda_verb alc880_fivestack_ch8_init[] = {
  836. /* set line-in to output, unmute it */
  837. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  838. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  839. { } /* end */
  840. };
  841. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  842. { 6, alc880_fivestack_ch6_init },
  843. { 8, alc880_fivestack_ch8_init },
  844. };
  845. /*
  846. * ALC880 6-stack model
  847. *
  848. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  849. * Side = 0x05 (0x0f)
  850. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  851. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  852. */
  853. static hda_nid_t alc880_6st_dac_nids[4] = {
  854. /* front, rear, clfe, rear_surr */
  855. 0x02, 0x03, 0x04, 0x05
  856. };
  857. static struct hda_input_mux alc880_6stack_capture_source = {
  858. .num_items = 4,
  859. .items = {
  860. { "Mic", 0x0 },
  861. { "Front Mic", 0x1 },
  862. { "Line", 0x2 },
  863. { "CD", 0x4 },
  864. },
  865. };
  866. /* fixed 8-channels */
  867. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  868. { 8, NULL },
  869. };
  870. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  871. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  872. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  873. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  874. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  875. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  876. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  877. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  878. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  879. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  880. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  881. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  882. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  883. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  884. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  885. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  886. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  887. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  888. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  889. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  890. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  891. {
  892. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  893. .name = "Channel Mode",
  894. .info = alc_ch_mode_info,
  895. .get = alc_ch_mode_get,
  896. .put = alc_ch_mode_put,
  897. },
  898. { } /* end */
  899. };
  900. /*
  901. * ALC880 W810 model
  902. *
  903. * W810 has rear IO for:
  904. * Front (DAC 02)
  905. * Surround (DAC 03)
  906. * Center/LFE (DAC 04)
  907. * Digital out (06)
  908. *
  909. * The system also has a pair of internal speakers, and a headphone jack.
  910. * These are both connected to Line2 on the codec, hence to DAC 02.
  911. *
  912. * There is a variable resistor to control the speaker or headphone
  913. * volume. This is a hardware-only device without a software API.
  914. *
  915. * Plugging headphones in will disable the internal speakers. This is
  916. * implemented in hardware, not via the driver using jack sense. In
  917. * a similar fashion, plugging into the rear socket marked "front" will
  918. * disable both the speakers and headphones.
  919. *
  920. * For input, there's a microphone jack, and an "audio in" jack.
  921. * These may not do anything useful with this driver yet, because I
  922. * haven't setup any initialization verbs for these yet...
  923. */
  924. static hda_nid_t alc880_w810_dac_nids[3] = {
  925. /* front, rear/surround, clfe */
  926. 0x02, 0x03, 0x04
  927. };
  928. /* fixed 6 channels */
  929. static struct hda_channel_mode alc880_w810_modes[1] = {
  930. { 6, NULL }
  931. };
  932. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  933. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  934. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  935. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  936. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  937. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  938. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  939. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  940. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  941. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  942. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  943. { } /* end */
  944. };
  945. /*
  946. * Z710V model
  947. *
  948. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  949. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  950. * Line = 0x1a
  951. */
  952. static hda_nid_t alc880_z71v_dac_nids[1] = {
  953. 0x02
  954. };
  955. #define ALC880_Z71V_HP_DAC 0x03
  956. /* fixed 2 channels */
  957. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  958. { 2, NULL }
  959. };
  960. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  961. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  962. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  963. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  964. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  965. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  966. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  967. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  968. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  969. { } /* end */
  970. };
  971. /* FIXME! */
  972. /*
  973. * ALC880 F1734 model
  974. *
  975. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  976. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  977. */
  978. static hda_nid_t alc880_f1734_dac_nids[1] = {
  979. 0x03
  980. };
  981. #define ALC880_F1734_HP_DAC 0x02
  982. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  983. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  984. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  985. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  986. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  987. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  988. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  989. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  990. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  991. { } /* end */
  992. };
  993. /* FIXME! */
  994. /*
  995. * ALC880 ASUS model
  996. *
  997. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  998. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  999. * Mic = 0x18, Line = 0x1a
  1000. */
  1001. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1002. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1003. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1004. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1005. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1006. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1007. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1008. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1009. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1010. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1011. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1012. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1013. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1014. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1015. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1016. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1017. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1018. {
  1019. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1020. .name = "Channel Mode",
  1021. .info = alc_ch_mode_info,
  1022. .get = alc_ch_mode_get,
  1023. .put = alc_ch_mode_put,
  1024. },
  1025. { } /* end */
  1026. };
  1027. /* FIXME! */
  1028. /*
  1029. * ALC880 ASUS W1V model
  1030. *
  1031. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1032. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1033. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1034. */
  1035. /* additional mixers to alc880_asus_mixer */
  1036. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1037. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1038. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1039. { } /* end */
  1040. };
  1041. /* additional mixers to alc880_asus_mixer */
  1042. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1043. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1044. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1045. { } /* end */
  1046. };
  1047. /* TCL S700 */
  1048. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1049. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1050. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1051. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1052. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1053. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1054. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1055. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1056. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1057. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1058. {
  1059. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1060. /* The multiple "Capture Source" controls confuse alsamixer
  1061. * So call somewhat different..
  1062. * FIXME: the controls appear in the "playback" view!
  1063. */
  1064. /* .name = "Capture Source", */
  1065. .name = "Input Source",
  1066. .count = 1,
  1067. .info = alc_mux_enum_info,
  1068. .get = alc_mux_enum_get,
  1069. .put = alc_mux_enum_put,
  1070. },
  1071. { } /* end */
  1072. };
  1073. /* Uniwill */
  1074. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1075. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1076. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1077. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1078. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1079. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1080. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1081. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1082. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1083. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1084. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1085. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1086. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1087. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1088. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1089. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1090. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1091. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1092. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1093. {
  1094. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1095. .name = "Channel Mode",
  1096. .info = alc_ch_mode_info,
  1097. .get = alc_ch_mode_get,
  1098. .put = alc_ch_mode_put,
  1099. },
  1100. { } /* end */
  1101. };
  1102. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1103. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1104. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1105. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1106. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1107. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1108. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1109. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1110. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1111. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1112. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1113. { } /* end */
  1114. };
  1115. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1116. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1117. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1118. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1119. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1120. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1121. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1122. { } /* end */
  1123. };
  1124. /*
  1125. * build control elements
  1126. */
  1127. static int alc_build_controls(struct hda_codec *codec)
  1128. {
  1129. struct alc_spec *spec = codec->spec;
  1130. int err;
  1131. int i;
  1132. for (i = 0; i < spec->num_mixers; i++) {
  1133. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1134. if (err < 0)
  1135. return err;
  1136. }
  1137. if (spec->multiout.dig_out_nid) {
  1138. err = snd_hda_create_spdif_out_ctls(codec,
  1139. spec->multiout.dig_out_nid);
  1140. if (err < 0)
  1141. return err;
  1142. }
  1143. if (spec->dig_in_nid) {
  1144. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1145. if (err < 0)
  1146. return err;
  1147. }
  1148. return 0;
  1149. }
  1150. /*
  1151. * initialize the codec volumes, etc
  1152. */
  1153. /*
  1154. * generic initialization of ADC, input mixers and output mixers
  1155. */
  1156. static struct hda_verb alc880_volume_init_verbs[] = {
  1157. /*
  1158. * Unmute ADC0-2 and set the default input to mic-in
  1159. */
  1160. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1161. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1162. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1163. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1164. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1165. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1166. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1167. * mixer widget
  1168. * Note: PASD motherboards uses the Line In 2 as the input for front
  1169. * panel mic (mic 2)
  1170. */
  1171. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1172. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1173. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1174. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1175. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1179. /*
  1180. * Set up output mixers (0x0c - 0x0f)
  1181. */
  1182. /* set vol=0 to output mixers */
  1183. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1184. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1185. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1186. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1187. /* set up input amps for analog loopback */
  1188. /* Amp Indices: DAC = 0, mixer = 1 */
  1189. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1191. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1193. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1195. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1197. { }
  1198. };
  1199. /*
  1200. * 3-stack pin configuration:
  1201. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1202. */
  1203. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1204. /*
  1205. * preset connection lists of input pins
  1206. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1207. */
  1208. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1209. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1210. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1211. /*
  1212. * Set pin mode and muting
  1213. */
  1214. /* set front pin widgets 0x14 for output */
  1215. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1216. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1217. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1218. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1219. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1220. /* Mic2 (as headphone out) for HP output */
  1221. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1222. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1223. /* Line In pin widget for input */
  1224. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1225. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1226. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1227. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1228. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1229. /* CD pin widget for input */
  1230. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1231. { }
  1232. };
  1233. /*
  1234. * 5-stack pin configuration:
  1235. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1236. * line-in/side = 0x1a, f-mic = 0x1b
  1237. */
  1238. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1239. /*
  1240. * preset connection lists of input pins
  1241. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1242. */
  1243. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1244. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1245. /*
  1246. * Set pin mode and muting
  1247. */
  1248. /* set pin widgets 0x14-0x17 for output */
  1249. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1250. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1251. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1253. /* unmute pins for output (no gain on this amp) */
  1254. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1255. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1258. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1259. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1260. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1261. /* Mic2 (as headphone out) for HP output */
  1262. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1263. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1264. /* Line In pin widget for input */
  1265. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1266. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1267. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1268. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1269. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1270. /* CD pin widget for input */
  1271. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1272. { }
  1273. };
  1274. /*
  1275. * W810 pin configuration:
  1276. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1277. */
  1278. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1279. /* hphone/speaker input selector: front DAC */
  1280. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1281. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1282. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1283. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1284. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1285. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1286. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1287. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1288. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1289. { }
  1290. };
  1291. /*
  1292. * Z71V pin configuration:
  1293. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1294. */
  1295. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1296. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1297. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1298. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1299. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1300. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1301. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1302. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1303. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1304. { }
  1305. };
  1306. /*
  1307. * 6-stack pin configuration:
  1308. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1309. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1310. */
  1311. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1312. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1313. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1314. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1315. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1316. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1318. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1319. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1320. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1321. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1322. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1323. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1324. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1325. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1326. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1327. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1328. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1329. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1330. { }
  1331. };
  1332. /*
  1333. * Uniwill pin configuration:
  1334. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1335. * line = 0x1a
  1336. */
  1337. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1338. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1339. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1340. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1341. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1342. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1343. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1344. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1345. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1346. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1347. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1349. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1351. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1353. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1354. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1355. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1356. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1357. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1358. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1359. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1360. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1361. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1362. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1363. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1364. { }
  1365. };
  1366. /*
  1367. * Uniwill P53
  1368. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1369. */
  1370. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1371. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1372. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1373. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1374. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1375. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1376. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1377. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1378. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1379. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1380. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1381. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1382. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1383. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1384. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1385. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1386. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1387. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1388. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1389. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1390. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1391. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1392. { }
  1393. };
  1394. static struct hda_verb alc880_beep_init_verbs[] = {
  1395. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1396. { }
  1397. };
  1398. /* toggle speaker-output according to the hp-jack state */
  1399. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1400. {
  1401. unsigned int present;
  1402. unsigned char bits;
  1403. present = snd_hda_codec_read(codec, 0x14, 0,
  1404. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1405. bits = present ? HDA_AMP_MUTE : 0;
  1406. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1407. HDA_AMP_MUTE, bits);
  1408. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1409. HDA_AMP_MUTE, bits);
  1410. }
  1411. /* auto-toggle front mic */
  1412. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1413. {
  1414. unsigned int present;
  1415. unsigned char bits;
  1416. present = snd_hda_codec_read(codec, 0x18, 0,
  1417. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1418. bits = present ? HDA_AMP_MUTE : 0;
  1419. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1420. }
  1421. static void alc880_uniwill_automute(struct hda_codec *codec)
  1422. {
  1423. alc880_uniwill_hp_automute(codec);
  1424. alc880_uniwill_mic_automute(codec);
  1425. }
  1426. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1427. unsigned int res)
  1428. {
  1429. /* Looks like the unsol event is incompatible with the standard
  1430. * definition. 4bit tag is placed at 28 bit!
  1431. */
  1432. switch (res >> 28) {
  1433. case ALC880_HP_EVENT:
  1434. alc880_uniwill_hp_automute(codec);
  1435. break;
  1436. case ALC880_MIC_EVENT:
  1437. alc880_uniwill_mic_automute(codec);
  1438. break;
  1439. }
  1440. }
  1441. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1442. {
  1443. unsigned int present;
  1444. unsigned char bits;
  1445. present = snd_hda_codec_read(codec, 0x14, 0,
  1446. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1447. bits = present ? HDA_AMP_MUTE : 0;
  1448. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1449. }
  1450. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1451. {
  1452. unsigned int present;
  1453. present = snd_hda_codec_read(codec, 0x21, 0,
  1454. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1455. present &= HDA_AMP_VOLMASK;
  1456. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1457. HDA_AMP_VOLMASK, present);
  1458. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1459. HDA_AMP_VOLMASK, present);
  1460. }
  1461. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1462. unsigned int res)
  1463. {
  1464. /* Looks like the unsol event is incompatible with the standard
  1465. * definition. 4bit tag is placed at 28 bit!
  1466. */
  1467. if ((res >> 28) == ALC880_HP_EVENT)
  1468. alc880_uniwill_p53_hp_automute(codec);
  1469. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1470. alc880_uniwill_p53_dcvol_automute(codec);
  1471. }
  1472. /* FIXME! */
  1473. /*
  1474. * F1734 pin configuration:
  1475. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1476. */
  1477. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1478. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1479. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1480. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1481. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1482. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1483. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1484. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1485. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1486. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1487. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1488. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1489. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1490. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1491. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1492. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1493. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1494. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1495. { }
  1496. };
  1497. /* FIXME! */
  1498. /*
  1499. * ASUS pin configuration:
  1500. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1501. */
  1502. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1503. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1504. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1505. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1506. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1507. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1508. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1509. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1510. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1511. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1512. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1513. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1514. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1515. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1516. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1517. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1518. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1519. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1520. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1521. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1522. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1523. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1524. { }
  1525. };
  1526. /* Enable GPIO mask and set output */
  1527. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1528. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1529. /* Clevo m520g init */
  1530. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1531. /* headphone output */
  1532. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1533. /* line-out */
  1534. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1535. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1536. /* Line-in */
  1537. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1538. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1539. /* CD */
  1540. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1541. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1542. /* Mic1 (rear panel) */
  1543. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1544. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1545. /* Mic2 (front panel) */
  1546. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1547. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1548. /* headphone */
  1549. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1550. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1551. /* change to EAPD mode */
  1552. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1553. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1554. { }
  1555. };
  1556. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1557. /* change to EAPD mode */
  1558. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1559. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1560. /* Headphone output */
  1561. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1562. /* Front output*/
  1563. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1564. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1565. /* Line In pin widget for input */
  1566. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1567. /* CD pin widget for input */
  1568. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1569. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1570. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1571. /* change to EAPD mode */
  1572. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1573. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1574. { }
  1575. };
  1576. /*
  1577. * LG m1 express dual
  1578. *
  1579. * Pin assignment:
  1580. * Rear Line-In/Out (blue): 0x14
  1581. * Build-in Mic-In: 0x15
  1582. * Speaker-out: 0x17
  1583. * HP-Out (green): 0x1b
  1584. * Mic-In/Out (red): 0x19
  1585. * SPDIF-Out: 0x1e
  1586. */
  1587. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1588. static hda_nid_t alc880_lg_dac_nids[3] = {
  1589. 0x05, 0x02, 0x03
  1590. };
  1591. /* seems analog CD is not working */
  1592. static struct hda_input_mux alc880_lg_capture_source = {
  1593. .num_items = 3,
  1594. .items = {
  1595. { "Mic", 0x1 },
  1596. { "Line", 0x5 },
  1597. { "Internal Mic", 0x6 },
  1598. },
  1599. };
  1600. /* 2,4,6 channel modes */
  1601. static struct hda_verb alc880_lg_ch2_init[] = {
  1602. /* set line-in and mic-in to input */
  1603. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1604. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1605. { }
  1606. };
  1607. static struct hda_verb alc880_lg_ch4_init[] = {
  1608. /* set line-in to out and mic-in to input */
  1609. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1610. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1611. { }
  1612. };
  1613. static struct hda_verb alc880_lg_ch6_init[] = {
  1614. /* set line-in and mic-in to output */
  1615. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1616. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1617. { }
  1618. };
  1619. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1620. { 2, alc880_lg_ch2_init },
  1621. { 4, alc880_lg_ch4_init },
  1622. { 6, alc880_lg_ch6_init },
  1623. };
  1624. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1625. /* FIXME: it's not really "master" but front channels */
  1626. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1627. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1628. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1629. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1630. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1631. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1632. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1633. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1634. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1635. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1636. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1637. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1638. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1639. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1640. {
  1641. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1642. .name = "Channel Mode",
  1643. .info = alc_ch_mode_info,
  1644. .get = alc_ch_mode_get,
  1645. .put = alc_ch_mode_put,
  1646. },
  1647. { } /* end */
  1648. };
  1649. static struct hda_verb alc880_lg_init_verbs[] = {
  1650. /* set capture source to mic-in */
  1651. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1652. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1653. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1654. /* mute all amp mixer inputs */
  1655. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1656. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1657. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1658. /* line-in to input */
  1659. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1660. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1661. /* built-in mic */
  1662. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1663. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1664. /* speaker-out */
  1665. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1666. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1667. /* mic-in to input */
  1668. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1669. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1670. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1671. /* HP-out */
  1672. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1673. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1674. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1675. /* jack sense */
  1676. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1677. { }
  1678. };
  1679. /* toggle speaker-output according to the hp-jack state */
  1680. static void alc880_lg_automute(struct hda_codec *codec)
  1681. {
  1682. unsigned int present;
  1683. unsigned char bits;
  1684. present = snd_hda_codec_read(codec, 0x1b, 0,
  1685. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1686. bits = present ? HDA_AMP_MUTE : 0;
  1687. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1688. HDA_AMP_MUTE, bits);
  1689. }
  1690. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1691. {
  1692. /* Looks like the unsol event is incompatible with the standard
  1693. * definition. 4bit tag is placed at 28 bit!
  1694. */
  1695. if ((res >> 28) == 0x01)
  1696. alc880_lg_automute(codec);
  1697. }
  1698. /*
  1699. * LG LW20
  1700. *
  1701. * Pin assignment:
  1702. * Speaker-out: 0x14
  1703. * Mic-In: 0x18
  1704. * Built-in Mic-In: 0x19
  1705. * Line-In: 0x1b
  1706. * HP-Out: 0x1a
  1707. * SPDIF-Out: 0x1e
  1708. */
  1709. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1710. .num_items = 3,
  1711. .items = {
  1712. { "Mic", 0x0 },
  1713. { "Internal Mic", 0x1 },
  1714. { "Line In", 0x2 },
  1715. },
  1716. };
  1717. #define alc880_lg_lw_modes alc880_threestack_modes
  1718. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1719. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1720. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1721. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1722. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1723. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1724. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1725. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1726. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1727. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1728. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1729. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1730. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1731. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1732. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1733. {
  1734. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1735. .name = "Channel Mode",
  1736. .info = alc_ch_mode_info,
  1737. .get = alc_ch_mode_get,
  1738. .put = alc_ch_mode_put,
  1739. },
  1740. { } /* end */
  1741. };
  1742. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1743. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1744. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1745. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1746. /* set capture source to mic-in */
  1747. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1748. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1749. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1750. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1751. /* speaker-out */
  1752. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1753. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1754. /* HP-out */
  1755. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1756. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1757. /* mic-in to input */
  1758. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1759. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1760. /* built-in mic */
  1761. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1762. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1763. /* jack sense */
  1764. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1765. { }
  1766. };
  1767. /* toggle speaker-output according to the hp-jack state */
  1768. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1769. {
  1770. unsigned int present;
  1771. unsigned char bits;
  1772. present = snd_hda_codec_read(codec, 0x1b, 0,
  1773. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1774. bits = present ? HDA_AMP_MUTE : 0;
  1775. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1776. HDA_AMP_MUTE, bits);
  1777. }
  1778. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1779. {
  1780. /* Looks like the unsol event is incompatible with the standard
  1781. * definition. 4bit tag is placed at 28 bit!
  1782. */
  1783. if ((res >> 28) == 0x01)
  1784. alc880_lg_lw_automute(codec);
  1785. }
  1786. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1787. static struct hda_amp_list alc880_loopbacks[] = {
  1788. { 0x0b, HDA_INPUT, 0 },
  1789. { 0x0b, HDA_INPUT, 1 },
  1790. { 0x0b, HDA_INPUT, 2 },
  1791. { 0x0b, HDA_INPUT, 3 },
  1792. { 0x0b, HDA_INPUT, 4 },
  1793. { } /* end */
  1794. };
  1795. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1796. { 0x0b, HDA_INPUT, 1 },
  1797. { 0x0b, HDA_INPUT, 6 },
  1798. { 0x0b, HDA_INPUT, 7 },
  1799. { } /* end */
  1800. };
  1801. #endif
  1802. /*
  1803. * Common callbacks
  1804. */
  1805. static int alc_init(struct hda_codec *codec)
  1806. {
  1807. struct alc_spec *spec = codec->spec;
  1808. unsigned int i;
  1809. for (i = 0; i < spec->num_init_verbs; i++)
  1810. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1811. if (spec->init_hook)
  1812. spec->init_hook(codec);
  1813. return 0;
  1814. }
  1815. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1816. {
  1817. struct alc_spec *spec = codec->spec;
  1818. if (spec->unsol_event)
  1819. spec->unsol_event(codec, res);
  1820. }
  1821. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1822. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1823. {
  1824. struct alc_spec *spec = codec->spec;
  1825. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1826. }
  1827. #endif
  1828. /*
  1829. * Analog playback callbacks
  1830. */
  1831. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1832. struct hda_codec *codec,
  1833. struct snd_pcm_substream *substream)
  1834. {
  1835. struct alc_spec *spec = codec->spec;
  1836. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1837. }
  1838. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1839. struct hda_codec *codec,
  1840. unsigned int stream_tag,
  1841. unsigned int format,
  1842. struct snd_pcm_substream *substream)
  1843. {
  1844. struct alc_spec *spec = codec->spec;
  1845. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1846. stream_tag, format, substream);
  1847. }
  1848. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1849. struct hda_codec *codec,
  1850. struct snd_pcm_substream *substream)
  1851. {
  1852. struct alc_spec *spec = codec->spec;
  1853. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1854. }
  1855. /*
  1856. * Digital out
  1857. */
  1858. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1859. struct hda_codec *codec,
  1860. struct snd_pcm_substream *substream)
  1861. {
  1862. struct alc_spec *spec = codec->spec;
  1863. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1864. }
  1865. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1866. struct hda_codec *codec,
  1867. unsigned int stream_tag,
  1868. unsigned int format,
  1869. struct snd_pcm_substream *substream)
  1870. {
  1871. struct alc_spec *spec = codec->spec;
  1872. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1873. stream_tag, format, substream);
  1874. }
  1875. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1876. struct hda_codec *codec,
  1877. struct snd_pcm_substream *substream)
  1878. {
  1879. struct alc_spec *spec = codec->spec;
  1880. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1881. }
  1882. /*
  1883. * Analog capture
  1884. */
  1885. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1886. struct hda_codec *codec,
  1887. unsigned int stream_tag,
  1888. unsigned int format,
  1889. struct snd_pcm_substream *substream)
  1890. {
  1891. struct alc_spec *spec = codec->spec;
  1892. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1893. stream_tag, 0, format);
  1894. return 0;
  1895. }
  1896. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1897. struct hda_codec *codec,
  1898. struct snd_pcm_substream *substream)
  1899. {
  1900. struct alc_spec *spec = codec->spec;
  1901. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1902. 0, 0, 0);
  1903. return 0;
  1904. }
  1905. /*
  1906. */
  1907. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1908. .substreams = 1,
  1909. .channels_min = 2,
  1910. .channels_max = 8,
  1911. /* NID is set in alc_build_pcms */
  1912. .ops = {
  1913. .open = alc880_playback_pcm_open,
  1914. .prepare = alc880_playback_pcm_prepare,
  1915. .cleanup = alc880_playback_pcm_cleanup
  1916. },
  1917. };
  1918. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1919. .substreams = 2,
  1920. .channels_min = 2,
  1921. .channels_max = 2,
  1922. /* NID is set in alc_build_pcms */
  1923. .ops = {
  1924. .prepare = alc880_capture_pcm_prepare,
  1925. .cleanup = alc880_capture_pcm_cleanup
  1926. },
  1927. };
  1928. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1929. .substreams = 1,
  1930. .channels_min = 2,
  1931. .channels_max = 2,
  1932. /* NID is set in alc_build_pcms */
  1933. .ops = {
  1934. .open = alc880_dig_playback_pcm_open,
  1935. .close = alc880_dig_playback_pcm_close,
  1936. .prepare = alc880_dig_playback_pcm_prepare
  1937. },
  1938. };
  1939. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1940. .substreams = 1,
  1941. .channels_min = 2,
  1942. .channels_max = 2,
  1943. /* NID is set in alc_build_pcms */
  1944. };
  1945. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1946. static struct hda_pcm_stream alc_pcm_null_playback = {
  1947. .substreams = 0,
  1948. .channels_min = 0,
  1949. .channels_max = 0,
  1950. };
  1951. static int alc_build_pcms(struct hda_codec *codec)
  1952. {
  1953. struct alc_spec *spec = codec->spec;
  1954. struct hda_pcm *info = spec->pcm_rec;
  1955. int i;
  1956. codec->num_pcms = 1;
  1957. codec->pcm_info = info;
  1958. info->name = spec->stream_name_analog;
  1959. if (spec->stream_analog_playback) {
  1960. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1961. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1962. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1963. }
  1964. if (spec->stream_analog_capture) {
  1965. snd_assert(spec->adc_nids, return -EINVAL);
  1966. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1967. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1968. }
  1969. if (spec->channel_mode) {
  1970. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1971. for (i = 0; i < spec->num_channel_mode; i++) {
  1972. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1973. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1974. }
  1975. }
  1976. }
  1977. /* SPDIF for stream index #1 */
  1978. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1979. codec->num_pcms = 2;
  1980. info = spec->pcm_rec + 1;
  1981. info->name = spec->stream_name_digital;
  1982. if (spec->multiout.dig_out_nid &&
  1983. spec->stream_digital_playback) {
  1984. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1985. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1986. }
  1987. if (spec->dig_in_nid &&
  1988. spec->stream_digital_capture) {
  1989. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1990. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1991. }
  1992. }
  1993. /* If the use of more than one ADC is requested for the current
  1994. * model, configure a second analog capture-only PCM.
  1995. */
  1996. /* Additional Analaog capture for index #2 */
  1997. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1998. spec->adc_nids) {
  1999. codec->num_pcms = 3;
  2000. info = spec->pcm_rec + 2;
  2001. info->name = spec->stream_name_analog;
  2002. /* No playback stream for second PCM */
  2003. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2004. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2005. if (spec->stream_analog_capture) {
  2006. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2007. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2008. }
  2009. }
  2010. return 0;
  2011. }
  2012. static void alc_free(struct hda_codec *codec)
  2013. {
  2014. struct alc_spec *spec = codec->spec;
  2015. unsigned int i;
  2016. if (!spec)
  2017. return;
  2018. if (spec->kctl_alloc) {
  2019. for (i = 0; i < spec->num_kctl_used; i++)
  2020. kfree(spec->kctl_alloc[i].name);
  2021. kfree(spec->kctl_alloc);
  2022. }
  2023. kfree(spec);
  2024. }
  2025. /*
  2026. */
  2027. static struct hda_codec_ops alc_patch_ops = {
  2028. .build_controls = alc_build_controls,
  2029. .build_pcms = alc_build_pcms,
  2030. .init = alc_init,
  2031. .free = alc_free,
  2032. .unsol_event = alc_unsol_event,
  2033. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2034. .check_power_status = alc_check_power_status,
  2035. #endif
  2036. };
  2037. /*
  2038. * Test configuration for debugging
  2039. *
  2040. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2041. * enum controls.
  2042. */
  2043. #ifdef CONFIG_SND_DEBUG
  2044. static hda_nid_t alc880_test_dac_nids[4] = {
  2045. 0x02, 0x03, 0x04, 0x05
  2046. };
  2047. static struct hda_input_mux alc880_test_capture_source = {
  2048. .num_items = 7,
  2049. .items = {
  2050. { "In-1", 0x0 },
  2051. { "In-2", 0x1 },
  2052. { "In-3", 0x2 },
  2053. { "In-4", 0x3 },
  2054. { "CD", 0x4 },
  2055. { "Front", 0x5 },
  2056. { "Surround", 0x6 },
  2057. },
  2058. };
  2059. static struct hda_channel_mode alc880_test_modes[4] = {
  2060. { 2, NULL },
  2061. { 4, NULL },
  2062. { 6, NULL },
  2063. { 8, NULL },
  2064. };
  2065. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2066. struct snd_ctl_elem_info *uinfo)
  2067. {
  2068. static char *texts[] = {
  2069. "N/A", "Line Out", "HP Out",
  2070. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2071. };
  2072. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2073. uinfo->count = 1;
  2074. uinfo->value.enumerated.items = 8;
  2075. if (uinfo->value.enumerated.item >= 8)
  2076. uinfo->value.enumerated.item = 7;
  2077. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2078. return 0;
  2079. }
  2080. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2081. struct snd_ctl_elem_value *ucontrol)
  2082. {
  2083. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2084. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2085. unsigned int pin_ctl, item = 0;
  2086. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2087. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2088. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2089. if (pin_ctl & AC_PINCTL_HP_EN)
  2090. item = 2;
  2091. else
  2092. item = 1;
  2093. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2094. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2095. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2096. case AC_PINCTL_VREF_50: item = 4; break;
  2097. case AC_PINCTL_VREF_GRD: item = 5; break;
  2098. case AC_PINCTL_VREF_80: item = 6; break;
  2099. case AC_PINCTL_VREF_100: item = 7; break;
  2100. }
  2101. }
  2102. ucontrol->value.enumerated.item[0] = item;
  2103. return 0;
  2104. }
  2105. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2106. struct snd_ctl_elem_value *ucontrol)
  2107. {
  2108. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2109. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2110. static unsigned int ctls[] = {
  2111. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2112. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2113. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2114. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2115. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2116. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2117. };
  2118. unsigned int old_ctl, new_ctl;
  2119. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2120. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2121. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2122. if (old_ctl != new_ctl) {
  2123. int val;
  2124. snd_hda_codec_write_cache(codec, nid, 0,
  2125. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2126. new_ctl);
  2127. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2128. HDA_AMP_MUTE : 0;
  2129. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2130. HDA_AMP_MUTE, val);
  2131. return 1;
  2132. }
  2133. return 0;
  2134. }
  2135. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2136. struct snd_ctl_elem_info *uinfo)
  2137. {
  2138. static char *texts[] = {
  2139. "Front", "Surround", "CLFE", "Side"
  2140. };
  2141. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2142. uinfo->count = 1;
  2143. uinfo->value.enumerated.items = 4;
  2144. if (uinfo->value.enumerated.item >= 4)
  2145. uinfo->value.enumerated.item = 3;
  2146. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2147. return 0;
  2148. }
  2149. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2150. struct snd_ctl_elem_value *ucontrol)
  2151. {
  2152. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2153. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2154. unsigned int sel;
  2155. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2156. ucontrol->value.enumerated.item[0] = sel & 3;
  2157. return 0;
  2158. }
  2159. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2160. struct snd_ctl_elem_value *ucontrol)
  2161. {
  2162. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2163. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2164. unsigned int sel;
  2165. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2166. if (ucontrol->value.enumerated.item[0] != sel) {
  2167. sel = ucontrol->value.enumerated.item[0] & 3;
  2168. snd_hda_codec_write_cache(codec, nid, 0,
  2169. AC_VERB_SET_CONNECT_SEL, sel);
  2170. return 1;
  2171. }
  2172. return 0;
  2173. }
  2174. #define PIN_CTL_TEST(xname,nid) { \
  2175. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2176. .name = xname, \
  2177. .info = alc_test_pin_ctl_info, \
  2178. .get = alc_test_pin_ctl_get, \
  2179. .put = alc_test_pin_ctl_put, \
  2180. .private_value = nid \
  2181. }
  2182. #define PIN_SRC_TEST(xname,nid) { \
  2183. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2184. .name = xname, \
  2185. .info = alc_test_pin_src_info, \
  2186. .get = alc_test_pin_src_get, \
  2187. .put = alc_test_pin_src_put, \
  2188. .private_value = nid \
  2189. }
  2190. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2191. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2192. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2193. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2194. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2195. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2196. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2197. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2198. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2199. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2200. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2201. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2202. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2203. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2204. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2205. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2206. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2207. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2208. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2209. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2210. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2211. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2212. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2213. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2214. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2215. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2216. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2217. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2218. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2219. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2220. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2221. {
  2222. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2223. .name = "Channel Mode",
  2224. .info = alc_ch_mode_info,
  2225. .get = alc_ch_mode_get,
  2226. .put = alc_ch_mode_put,
  2227. },
  2228. { } /* end */
  2229. };
  2230. static struct hda_verb alc880_test_init_verbs[] = {
  2231. /* Unmute inputs of 0x0c - 0x0f */
  2232. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2233. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2234. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2235. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2236. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2237. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2238. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2239. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2240. /* Vol output for 0x0c-0x0f */
  2241. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2242. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2243. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2244. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2245. /* Set output pins 0x14-0x17 */
  2246. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2247. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2248. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2249. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2250. /* Unmute output pins 0x14-0x17 */
  2251. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2252. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2253. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2254. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2255. /* Set input pins 0x18-0x1c */
  2256. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2257. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2258. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2259. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2260. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2261. /* Mute input pins 0x18-0x1b */
  2262. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2263. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2264. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2265. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2266. /* ADC set up */
  2267. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2268. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2269. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2270. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2271. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2272. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2273. /* Analog input/passthru */
  2274. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2275. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2276. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2277. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2278. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2279. { }
  2280. };
  2281. #endif
  2282. /*
  2283. */
  2284. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2285. [ALC880_3ST] = "3stack",
  2286. [ALC880_TCL_S700] = "tcl",
  2287. [ALC880_3ST_DIG] = "3stack-digout",
  2288. [ALC880_CLEVO] = "clevo",
  2289. [ALC880_5ST] = "5stack",
  2290. [ALC880_5ST_DIG] = "5stack-digout",
  2291. [ALC880_W810] = "w810",
  2292. [ALC880_Z71V] = "z71v",
  2293. [ALC880_6ST] = "6stack",
  2294. [ALC880_6ST_DIG] = "6stack-digout",
  2295. [ALC880_ASUS] = "asus",
  2296. [ALC880_ASUS_W1V] = "asus-w1v",
  2297. [ALC880_ASUS_DIG] = "asus-dig",
  2298. [ALC880_ASUS_DIG2] = "asus-dig2",
  2299. [ALC880_UNIWILL_DIG] = "uniwill",
  2300. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2301. [ALC880_FUJITSU] = "fujitsu",
  2302. [ALC880_F1734] = "F1734",
  2303. [ALC880_LG] = "lg",
  2304. [ALC880_LG_LW] = "lg-lw",
  2305. #ifdef CONFIG_SND_DEBUG
  2306. [ALC880_TEST] = "test",
  2307. #endif
  2308. [ALC880_AUTO] = "auto",
  2309. };
  2310. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2311. /* Broken BIOS configuration */
  2312. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2313. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2314. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2315. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2316. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2317. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2318. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2319. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2320. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2321. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2322. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2323. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2324. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2325. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2326. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2327. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2328. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2329. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2330. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2331. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2332. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2333. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2334. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2335. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2336. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2337. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2338. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2339. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2340. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2341. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2342. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2343. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2344. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2345. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2346. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2347. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2348. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2349. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2350. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2351. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2352. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2353. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2354. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2355. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2356. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2357. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2358. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2359. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2360. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2361. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2362. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2363. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2364. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2365. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2366. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2367. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2368. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2369. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2370. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2371. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2372. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2373. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2374. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2375. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2376. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2377. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2378. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2379. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2380. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2381. {}
  2382. };
  2383. /*
  2384. * ALC880 codec presets
  2385. */
  2386. static struct alc_config_preset alc880_presets[] = {
  2387. [ALC880_3ST] = {
  2388. .mixers = { alc880_three_stack_mixer },
  2389. .init_verbs = { alc880_volume_init_verbs,
  2390. alc880_pin_3stack_init_verbs },
  2391. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2392. .dac_nids = alc880_dac_nids,
  2393. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2394. .channel_mode = alc880_threestack_modes,
  2395. .need_dac_fix = 1,
  2396. .input_mux = &alc880_capture_source,
  2397. },
  2398. [ALC880_3ST_DIG] = {
  2399. .mixers = { alc880_three_stack_mixer },
  2400. .init_verbs = { alc880_volume_init_verbs,
  2401. alc880_pin_3stack_init_verbs },
  2402. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2403. .dac_nids = alc880_dac_nids,
  2404. .dig_out_nid = ALC880_DIGOUT_NID,
  2405. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2406. .channel_mode = alc880_threestack_modes,
  2407. .need_dac_fix = 1,
  2408. .input_mux = &alc880_capture_source,
  2409. },
  2410. [ALC880_TCL_S700] = {
  2411. .mixers = { alc880_tcl_s700_mixer },
  2412. .init_verbs = { alc880_volume_init_verbs,
  2413. alc880_pin_tcl_S700_init_verbs,
  2414. alc880_gpio2_init_verbs },
  2415. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2416. .dac_nids = alc880_dac_nids,
  2417. .hp_nid = 0x03,
  2418. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2419. .channel_mode = alc880_2_jack_modes,
  2420. .input_mux = &alc880_capture_source,
  2421. },
  2422. [ALC880_5ST] = {
  2423. .mixers = { alc880_three_stack_mixer,
  2424. alc880_five_stack_mixer},
  2425. .init_verbs = { alc880_volume_init_verbs,
  2426. alc880_pin_5stack_init_verbs },
  2427. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2428. .dac_nids = alc880_dac_nids,
  2429. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2430. .channel_mode = alc880_fivestack_modes,
  2431. .input_mux = &alc880_capture_source,
  2432. },
  2433. [ALC880_5ST_DIG] = {
  2434. .mixers = { alc880_three_stack_mixer,
  2435. alc880_five_stack_mixer },
  2436. .init_verbs = { alc880_volume_init_verbs,
  2437. alc880_pin_5stack_init_verbs },
  2438. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2439. .dac_nids = alc880_dac_nids,
  2440. .dig_out_nid = ALC880_DIGOUT_NID,
  2441. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2442. .channel_mode = alc880_fivestack_modes,
  2443. .input_mux = &alc880_capture_source,
  2444. },
  2445. [ALC880_6ST] = {
  2446. .mixers = { alc880_six_stack_mixer },
  2447. .init_verbs = { alc880_volume_init_verbs,
  2448. alc880_pin_6stack_init_verbs },
  2449. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2450. .dac_nids = alc880_6st_dac_nids,
  2451. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2452. .channel_mode = alc880_sixstack_modes,
  2453. .input_mux = &alc880_6stack_capture_source,
  2454. },
  2455. [ALC880_6ST_DIG] = {
  2456. .mixers = { alc880_six_stack_mixer },
  2457. .init_verbs = { alc880_volume_init_verbs,
  2458. alc880_pin_6stack_init_verbs },
  2459. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2460. .dac_nids = alc880_6st_dac_nids,
  2461. .dig_out_nid = ALC880_DIGOUT_NID,
  2462. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2463. .channel_mode = alc880_sixstack_modes,
  2464. .input_mux = &alc880_6stack_capture_source,
  2465. },
  2466. [ALC880_W810] = {
  2467. .mixers = { alc880_w810_base_mixer },
  2468. .init_verbs = { alc880_volume_init_verbs,
  2469. alc880_pin_w810_init_verbs,
  2470. alc880_gpio2_init_verbs },
  2471. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2472. .dac_nids = alc880_w810_dac_nids,
  2473. .dig_out_nid = ALC880_DIGOUT_NID,
  2474. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2475. .channel_mode = alc880_w810_modes,
  2476. .input_mux = &alc880_capture_source,
  2477. },
  2478. [ALC880_Z71V] = {
  2479. .mixers = { alc880_z71v_mixer },
  2480. .init_verbs = { alc880_volume_init_verbs,
  2481. alc880_pin_z71v_init_verbs },
  2482. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2483. .dac_nids = alc880_z71v_dac_nids,
  2484. .dig_out_nid = ALC880_DIGOUT_NID,
  2485. .hp_nid = 0x03,
  2486. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2487. .channel_mode = alc880_2_jack_modes,
  2488. .input_mux = &alc880_capture_source,
  2489. },
  2490. [ALC880_F1734] = {
  2491. .mixers = { alc880_f1734_mixer },
  2492. .init_verbs = { alc880_volume_init_verbs,
  2493. alc880_pin_f1734_init_verbs },
  2494. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2495. .dac_nids = alc880_f1734_dac_nids,
  2496. .hp_nid = 0x02,
  2497. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2498. .channel_mode = alc880_2_jack_modes,
  2499. .input_mux = &alc880_capture_source,
  2500. },
  2501. [ALC880_ASUS] = {
  2502. .mixers = { alc880_asus_mixer },
  2503. .init_verbs = { alc880_volume_init_verbs,
  2504. alc880_pin_asus_init_verbs,
  2505. alc880_gpio1_init_verbs },
  2506. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2507. .dac_nids = alc880_asus_dac_nids,
  2508. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2509. .channel_mode = alc880_asus_modes,
  2510. .need_dac_fix = 1,
  2511. .input_mux = &alc880_capture_source,
  2512. },
  2513. [ALC880_ASUS_DIG] = {
  2514. .mixers = { alc880_asus_mixer },
  2515. .init_verbs = { alc880_volume_init_verbs,
  2516. alc880_pin_asus_init_verbs,
  2517. alc880_gpio1_init_verbs },
  2518. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2519. .dac_nids = alc880_asus_dac_nids,
  2520. .dig_out_nid = ALC880_DIGOUT_NID,
  2521. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2522. .channel_mode = alc880_asus_modes,
  2523. .need_dac_fix = 1,
  2524. .input_mux = &alc880_capture_source,
  2525. },
  2526. [ALC880_ASUS_DIG2] = {
  2527. .mixers = { alc880_asus_mixer },
  2528. .init_verbs = { alc880_volume_init_verbs,
  2529. alc880_pin_asus_init_verbs,
  2530. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2531. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2532. .dac_nids = alc880_asus_dac_nids,
  2533. .dig_out_nid = ALC880_DIGOUT_NID,
  2534. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2535. .channel_mode = alc880_asus_modes,
  2536. .need_dac_fix = 1,
  2537. .input_mux = &alc880_capture_source,
  2538. },
  2539. [ALC880_ASUS_W1V] = {
  2540. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2541. .init_verbs = { alc880_volume_init_verbs,
  2542. alc880_pin_asus_init_verbs,
  2543. alc880_gpio1_init_verbs },
  2544. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2545. .dac_nids = alc880_asus_dac_nids,
  2546. .dig_out_nid = ALC880_DIGOUT_NID,
  2547. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2548. .channel_mode = alc880_asus_modes,
  2549. .need_dac_fix = 1,
  2550. .input_mux = &alc880_capture_source,
  2551. },
  2552. [ALC880_UNIWILL_DIG] = {
  2553. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2554. .init_verbs = { alc880_volume_init_verbs,
  2555. alc880_pin_asus_init_verbs },
  2556. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2557. .dac_nids = alc880_asus_dac_nids,
  2558. .dig_out_nid = ALC880_DIGOUT_NID,
  2559. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2560. .channel_mode = alc880_asus_modes,
  2561. .need_dac_fix = 1,
  2562. .input_mux = &alc880_capture_source,
  2563. },
  2564. [ALC880_UNIWILL] = {
  2565. .mixers = { alc880_uniwill_mixer },
  2566. .init_verbs = { alc880_volume_init_verbs,
  2567. alc880_uniwill_init_verbs },
  2568. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2569. .dac_nids = alc880_asus_dac_nids,
  2570. .dig_out_nid = ALC880_DIGOUT_NID,
  2571. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2572. .channel_mode = alc880_threestack_modes,
  2573. .need_dac_fix = 1,
  2574. .input_mux = &alc880_capture_source,
  2575. .unsol_event = alc880_uniwill_unsol_event,
  2576. .init_hook = alc880_uniwill_automute,
  2577. },
  2578. [ALC880_UNIWILL_P53] = {
  2579. .mixers = { alc880_uniwill_p53_mixer },
  2580. .init_verbs = { alc880_volume_init_verbs,
  2581. alc880_uniwill_p53_init_verbs },
  2582. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2583. .dac_nids = alc880_asus_dac_nids,
  2584. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2585. .channel_mode = alc880_threestack_modes,
  2586. .input_mux = &alc880_capture_source,
  2587. .unsol_event = alc880_uniwill_p53_unsol_event,
  2588. .init_hook = alc880_uniwill_p53_hp_automute,
  2589. },
  2590. [ALC880_FUJITSU] = {
  2591. .mixers = { alc880_fujitsu_mixer,
  2592. alc880_pcbeep_mixer, },
  2593. .init_verbs = { alc880_volume_init_verbs,
  2594. alc880_uniwill_p53_init_verbs,
  2595. alc880_beep_init_verbs },
  2596. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2597. .dac_nids = alc880_dac_nids,
  2598. .dig_out_nid = ALC880_DIGOUT_NID,
  2599. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2600. .channel_mode = alc880_2_jack_modes,
  2601. .input_mux = &alc880_capture_source,
  2602. .unsol_event = alc880_uniwill_p53_unsol_event,
  2603. .init_hook = alc880_uniwill_p53_hp_automute,
  2604. },
  2605. [ALC880_CLEVO] = {
  2606. .mixers = { alc880_three_stack_mixer },
  2607. .init_verbs = { alc880_volume_init_verbs,
  2608. alc880_pin_clevo_init_verbs },
  2609. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2610. .dac_nids = alc880_dac_nids,
  2611. .hp_nid = 0x03,
  2612. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2613. .channel_mode = alc880_threestack_modes,
  2614. .need_dac_fix = 1,
  2615. .input_mux = &alc880_capture_source,
  2616. },
  2617. [ALC880_LG] = {
  2618. .mixers = { alc880_lg_mixer },
  2619. .init_verbs = { alc880_volume_init_verbs,
  2620. alc880_lg_init_verbs },
  2621. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2622. .dac_nids = alc880_lg_dac_nids,
  2623. .dig_out_nid = ALC880_DIGOUT_NID,
  2624. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2625. .channel_mode = alc880_lg_ch_modes,
  2626. .need_dac_fix = 1,
  2627. .input_mux = &alc880_lg_capture_source,
  2628. .unsol_event = alc880_lg_unsol_event,
  2629. .init_hook = alc880_lg_automute,
  2630. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2631. .loopbacks = alc880_lg_loopbacks,
  2632. #endif
  2633. },
  2634. [ALC880_LG_LW] = {
  2635. .mixers = { alc880_lg_lw_mixer },
  2636. .init_verbs = { alc880_volume_init_verbs,
  2637. alc880_lg_lw_init_verbs },
  2638. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2639. .dac_nids = alc880_dac_nids,
  2640. .dig_out_nid = ALC880_DIGOUT_NID,
  2641. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2642. .channel_mode = alc880_lg_lw_modes,
  2643. .input_mux = &alc880_lg_lw_capture_source,
  2644. .unsol_event = alc880_lg_lw_unsol_event,
  2645. .init_hook = alc880_lg_lw_automute,
  2646. },
  2647. #ifdef CONFIG_SND_DEBUG
  2648. [ALC880_TEST] = {
  2649. .mixers = { alc880_test_mixer },
  2650. .init_verbs = { alc880_test_init_verbs },
  2651. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2652. .dac_nids = alc880_test_dac_nids,
  2653. .dig_out_nid = ALC880_DIGOUT_NID,
  2654. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2655. .channel_mode = alc880_test_modes,
  2656. .input_mux = &alc880_test_capture_source,
  2657. },
  2658. #endif
  2659. };
  2660. /*
  2661. * Automatic parse of I/O pins from the BIOS configuration
  2662. */
  2663. #define NUM_CONTROL_ALLOC 32
  2664. #define NUM_VERB_ALLOC 32
  2665. enum {
  2666. ALC_CTL_WIDGET_VOL,
  2667. ALC_CTL_WIDGET_MUTE,
  2668. ALC_CTL_BIND_MUTE,
  2669. };
  2670. static struct snd_kcontrol_new alc880_control_templates[] = {
  2671. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2672. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2673. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2674. };
  2675. /* add dynamic controls */
  2676. static int add_control(struct alc_spec *spec, int type, const char *name,
  2677. unsigned long val)
  2678. {
  2679. struct snd_kcontrol_new *knew;
  2680. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2681. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2682. /* array + terminator */
  2683. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2684. if (!knew)
  2685. return -ENOMEM;
  2686. if (spec->kctl_alloc) {
  2687. memcpy(knew, spec->kctl_alloc,
  2688. sizeof(*knew) * spec->num_kctl_alloc);
  2689. kfree(spec->kctl_alloc);
  2690. }
  2691. spec->kctl_alloc = knew;
  2692. spec->num_kctl_alloc = num;
  2693. }
  2694. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2695. *knew = alc880_control_templates[type];
  2696. knew->name = kstrdup(name, GFP_KERNEL);
  2697. if (!knew->name)
  2698. return -ENOMEM;
  2699. knew->private_value = val;
  2700. spec->num_kctl_used++;
  2701. return 0;
  2702. }
  2703. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2704. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2705. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2706. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2707. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2708. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2709. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2710. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2711. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2712. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2713. #define ALC880_PIN_CD_NID 0x1c
  2714. /* fill in the dac_nids table from the parsed pin configuration */
  2715. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2716. const struct auto_pin_cfg *cfg)
  2717. {
  2718. hda_nid_t nid;
  2719. int assigned[4];
  2720. int i, j;
  2721. memset(assigned, 0, sizeof(assigned));
  2722. spec->multiout.dac_nids = spec->private_dac_nids;
  2723. /* check the pins hardwired to audio widget */
  2724. for (i = 0; i < cfg->line_outs; i++) {
  2725. nid = cfg->line_out_pins[i];
  2726. if (alc880_is_fixed_pin(nid)) {
  2727. int idx = alc880_fixed_pin_idx(nid);
  2728. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2729. assigned[idx] = 1;
  2730. }
  2731. }
  2732. /* left pins can be connect to any audio widget */
  2733. for (i = 0; i < cfg->line_outs; i++) {
  2734. nid = cfg->line_out_pins[i];
  2735. if (alc880_is_fixed_pin(nid))
  2736. continue;
  2737. /* search for an empty channel */
  2738. for (j = 0; j < cfg->line_outs; j++) {
  2739. if (!assigned[j]) {
  2740. spec->multiout.dac_nids[i] =
  2741. alc880_idx_to_dac(j);
  2742. assigned[j] = 1;
  2743. break;
  2744. }
  2745. }
  2746. }
  2747. spec->multiout.num_dacs = cfg->line_outs;
  2748. return 0;
  2749. }
  2750. /* add playback controls from the parsed DAC table */
  2751. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2752. const struct auto_pin_cfg *cfg)
  2753. {
  2754. char name[32];
  2755. static const char *chname[4] = {
  2756. "Front", "Surround", NULL /*CLFE*/, "Side"
  2757. };
  2758. hda_nid_t nid;
  2759. int i, err;
  2760. for (i = 0; i < cfg->line_outs; i++) {
  2761. if (!spec->multiout.dac_nids[i])
  2762. continue;
  2763. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2764. if (i == 2) {
  2765. /* Center/LFE */
  2766. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2767. "Center Playback Volume",
  2768. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2769. HDA_OUTPUT));
  2770. if (err < 0)
  2771. return err;
  2772. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2773. "LFE Playback Volume",
  2774. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2775. HDA_OUTPUT));
  2776. if (err < 0)
  2777. return err;
  2778. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2779. "Center Playback Switch",
  2780. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2781. HDA_INPUT));
  2782. if (err < 0)
  2783. return err;
  2784. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2785. "LFE Playback Switch",
  2786. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2787. HDA_INPUT));
  2788. if (err < 0)
  2789. return err;
  2790. } else {
  2791. sprintf(name, "%s Playback Volume", chname[i]);
  2792. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2793. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2794. HDA_OUTPUT));
  2795. if (err < 0)
  2796. return err;
  2797. sprintf(name, "%s Playback Switch", chname[i]);
  2798. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2799. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2800. HDA_INPUT));
  2801. if (err < 0)
  2802. return err;
  2803. }
  2804. }
  2805. return 0;
  2806. }
  2807. /* add playback controls for speaker and HP outputs */
  2808. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2809. const char *pfx)
  2810. {
  2811. hda_nid_t nid;
  2812. int err;
  2813. char name[32];
  2814. if (!pin)
  2815. return 0;
  2816. if (alc880_is_fixed_pin(pin)) {
  2817. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2818. /* specify the DAC as the extra output */
  2819. if (!spec->multiout.hp_nid)
  2820. spec->multiout.hp_nid = nid;
  2821. else
  2822. spec->multiout.extra_out_nid[0] = nid;
  2823. /* control HP volume/switch on the output mixer amp */
  2824. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2825. sprintf(name, "%s Playback Volume", pfx);
  2826. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2827. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2828. if (err < 0)
  2829. return err;
  2830. sprintf(name, "%s Playback Switch", pfx);
  2831. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2832. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2833. if (err < 0)
  2834. return err;
  2835. } else if (alc880_is_multi_pin(pin)) {
  2836. /* set manual connection */
  2837. /* we have only a switch on HP-out PIN */
  2838. sprintf(name, "%s Playback Switch", pfx);
  2839. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2840. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2841. if (err < 0)
  2842. return err;
  2843. }
  2844. return 0;
  2845. }
  2846. /* create input playback/capture controls for the given pin */
  2847. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2848. const char *ctlname,
  2849. int idx, hda_nid_t mix_nid)
  2850. {
  2851. char name[32];
  2852. int err;
  2853. sprintf(name, "%s Playback Volume", ctlname);
  2854. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2855. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2856. if (err < 0)
  2857. return err;
  2858. sprintf(name, "%s Playback Switch", ctlname);
  2859. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2860. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2861. if (err < 0)
  2862. return err;
  2863. return 0;
  2864. }
  2865. /* create playback/capture controls for input pins */
  2866. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2867. const struct auto_pin_cfg *cfg)
  2868. {
  2869. struct hda_input_mux *imux = &spec->private_imux;
  2870. int i, err, idx;
  2871. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2872. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2873. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2874. err = new_analog_input(spec, cfg->input_pins[i],
  2875. auto_pin_cfg_labels[i],
  2876. idx, 0x0b);
  2877. if (err < 0)
  2878. return err;
  2879. imux->items[imux->num_items].label =
  2880. auto_pin_cfg_labels[i];
  2881. imux->items[imux->num_items].index =
  2882. alc880_input_pin_idx(cfg->input_pins[i]);
  2883. imux->num_items++;
  2884. }
  2885. }
  2886. return 0;
  2887. }
  2888. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2889. hda_nid_t nid, int pin_type,
  2890. int dac_idx)
  2891. {
  2892. /* set as output */
  2893. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2894. pin_type);
  2895. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2896. AMP_OUT_UNMUTE);
  2897. /* need the manual connection? */
  2898. if (alc880_is_multi_pin(nid)) {
  2899. struct alc_spec *spec = codec->spec;
  2900. int idx = alc880_multi_pin_idx(nid);
  2901. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2902. AC_VERB_SET_CONNECT_SEL,
  2903. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2904. }
  2905. }
  2906. static int get_pin_type(int line_out_type)
  2907. {
  2908. if (line_out_type == AUTO_PIN_HP_OUT)
  2909. return PIN_HP;
  2910. else
  2911. return PIN_OUT;
  2912. }
  2913. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2914. {
  2915. struct alc_spec *spec = codec->spec;
  2916. int i;
  2917. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2918. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2919. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2920. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2921. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2922. }
  2923. }
  2924. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2925. {
  2926. struct alc_spec *spec = codec->spec;
  2927. hda_nid_t pin;
  2928. pin = spec->autocfg.speaker_pins[0];
  2929. if (pin) /* connect to front */
  2930. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2931. pin = spec->autocfg.hp_pins[0];
  2932. if (pin) /* connect to front */
  2933. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2934. }
  2935. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2936. {
  2937. struct alc_spec *spec = codec->spec;
  2938. int i;
  2939. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2940. hda_nid_t nid = spec->autocfg.input_pins[i];
  2941. if (alc880_is_input_pin(nid)) {
  2942. snd_hda_codec_write(codec, nid, 0,
  2943. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2944. i <= AUTO_PIN_FRONT_MIC ?
  2945. PIN_VREF80 : PIN_IN);
  2946. if (nid != ALC880_PIN_CD_NID)
  2947. snd_hda_codec_write(codec, nid, 0,
  2948. AC_VERB_SET_AMP_GAIN_MUTE,
  2949. AMP_OUT_MUTE);
  2950. }
  2951. }
  2952. }
  2953. /* parse the BIOS configuration and set up the alc_spec */
  2954. /* return 1 if successful, 0 if the proper config is not found,
  2955. * or a negative error code
  2956. */
  2957. static int alc880_parse_auto_config(struct hda_codec *codec)
  2958. {
  2959. struct alc_spec *spec = codec->spec;
  2960. int err;
  2961. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2962. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2963. alc880_ignore);
  2964. if (err < 0)
  2965. return err;
  2966. if (!spec->autocfg.line_outs)
  2967. return 0; /* can't find valid BIOS pin config */
  2968. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2969. if (err < 0)
  2970. return err;
  2971. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2972. if (err < 0)
  2973. return err;
  2974. err = alc880_auto_create_extra_out(spec,
  2975. spec->autocfg.speaker_pins[0],
  2976. "Speaker");
  2977. if (err < 0)
  2978. return err;
  2979. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2980. "Headphone");
  2981. if (err < 0)
  2982. return err;
  2983. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2984. if (err < 0)
  2985. return err;
  2986. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2987. if (spec->autocfg.dig_out_pin)
  2988. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2989. if (spec->autocfg.dig_in_pin)
  2990. spec->dig_in_nid = ALC880_DIGIN_NID;
  2991. if (spec->kctl_alloc)
  2992. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2993. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2994. spec->num_mux_defs = 1;
  2995. spec->input_mux = &spec->private_imux;
  2996. return 1;
  2997. }
  2998. /* additional initialization for auto-configuration model */
  2999. static void alc880_auto_init(struct hda_codec *codec)
  3000. {
  3001. alc880_auto_init_multi_out(codec);
  3002. alc880_auto_init_extra_out(codec);
  3003. alc880_auto_init_analog_input(codec);
  3004. }
  3005. /*
  3006. * OK, here we have finally the patch for ALC880
  3007. */
  3008. static int patch_alc880(struct hda_codec *codec)
  3009. {
  3010. struct alc_spec *spec;
  3011. int board_config;
  3012. int err;
  3013. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3014. if (spec == NULL)
  3015. return -ENOMEM;
  3016. codec->spec = spec;
  3017. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3018. alc880_models,
  3019. alc880_cfg_tbl);
  3020. if (board_config < 0) {
  3021. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3022. "trying auto-probe from BIOS...\n");
  3023. board_config = ALC880_AUTO;
  3024. }
  3025. if (board_config == ALC880_AUTO) {
  3026. /* automatic parse from the BIOS config */
  3027. err = alc880_parse_auto_config(codec);
  3028. if (err < 0) {
  3029. alc_free(codec);
  3030. return err;
  3031. } else if (!err) {
  3032. printk(KERN_INFO
  3033. "hda_codec: Cannot set up configuration "
  3034. "from BIOS. Using 3-stack mode...\n");
  3035. board_config = ALC880_3ST;
  3036. }
  3037. }
  3038. if (board_config != ALC880_AUTO)
  3039. setup_preset(spec, &alc880_presets[board_config]);
  3040. spec->stream_name_analog = "ALC880 Analog";
  3041. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3042. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3043. spec->stream_name_digital = "ALC880 Digital";
  3044. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3045. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3046. if (!spec->adc_nids && spec->input_mux) {
  3047. /* check whether NID 0x07 is valid */
  3048. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3049. /* get type */
  3050. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3051. if (wcap != AC_WID_AUD_IN) {
  3052. spec->adc_nids = alc880_adc_nids_alt;
  3053. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3054. spec->mixers[spec->num_mixers] =
  3055. alc880_capture_alt_mixer;
  3056. spec->num_mixers++;
  3057. } else {
  3058. spec->adc_nids = alc880_adc_nids;
  3059. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3060. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3061. spec->num_mixers++;
  3062. }
  3063. }
  3064. codec->patch_ops = alc_patch_ops;
  3065. if (board_config == ALC880_AUTO)
  3066. spec->init_hook = alc880_auto_init;
  3067. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3068. if (!spec->loopback.amplist)
  3069. spec->loopback.amplist = alc880_loopbacks;
  3070. #endif
  3071. return 0;
  3072. }
  3073. /*
  3074. * ALC260 support
  3075. */
  3076. static hda_nid_t alc260_dac_nids[1] = {
  3077. /* front */
  3078. 0x02,
  3079. };
  3080. static hda_nid_t alc260_adc_nids[1] = {
  3081. /* ADC0 */
  3082. 0x04,
  3083. };
  3084. static hda_nid_t alc260_adc_nids_alt[1] = {
  3085. /* ADC1 */
  3086. 0x05,
  3087. };
  3088. static hda_nid_t alc260_hp_adc_nids[2] = {
  3089. /* ADC1, 0 */
  3090. 0x05, 0x04
  3091. };
  3092. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3093. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3094. */
  3095. static hda_nid_t alc260_dual_adc_nids[2] = {
  3096. /* ADC0, ADC1 */
  3097. 0x04, 0x05
  3098. };
  3099. #define ALC260_DIGOUT_NID 0x03
  3100. #define ALC260_DIGIN_NID 0x06
  3101. static struct hda_input_mux alc260_capture_source = {
  3102. .num_items = 4,
  3103. .items = {
  3104. { "Mic", 0x0 },
  3105. { "Front Mic", 0x1 },
  3106. { "Line", 0x2 },
  3107. { "CD", 0x4 },
  3108. },
  3109. };
  3110. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3111. * headphone jack and the internal CD lines since these are the only pins at
  3112. * which audio can appear. For flexibility, also allow the option of
  3113. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3114. * connection to the mixer output).
  3115. */
  3116. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3117. {
  3118. .num_items = 3,
  3119. .items = {
  3120. { "Mic/Line", 0x0 },
  3121. { "CD", 0x4 },
  3122. { "Headphone", 0x2 },
  3123. },
  3124. },
  3125. {
  3126. .num_items = 4,
  3127. .items = {
  3128. { "Mic/Line", 0x0 },
  3129. { "CD", 0x4 },
  3130. { "Headphone", 0x2 },
  3131. { "Mixer", 0x5 },
  3132. },
  3133. },
  3134. };
  3135. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3136. * the Fujitsu S702x, but jacks are marked differently.
  3137. */
  3138. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3139. {
  3140. .num_items = 4,
  3141. .items = {
  3142. { "Mic", 0x0 },
  3143. { "Line", 0x2 },
  3144. { "CD", 0x4 },
  3145. { "Headphone", 0x5 },
  3146. },
  3147. },
  3148. {
  3149. .num_items = 5,
  3150. .items = {
  3151. { "Mic", 0x0 },
  3152. { "Line", 0x2 },
  3153. { "CD", 0x4 },
  3154. { "Headphone", 0x6 },
  3155. { "Mixer", 0x5 },
  3156. },
  3157. },
  3158. };
  3159. /*
  3160. * This is just place-holder, so there's something for alc_build_pcms to look
  3161. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3162. * element which allows changing the channel mode, so the verb list is
  3163. * never used.
  3164. */
  3165. static struct hda_channel_mode alc260_modes[1] = {
  3166. { 2, NULL },
  3167. };
  3168. /* Mixer combinations
  3169. *
  3170. * basic: base_output + input + pc_beep + capture
  3171. * HP: base_output + input + capture_alt
  3172. * HP_3013: hp_3013 + input + capture
  3173. * fujitsu: fujitsu + capture
  3174. * acer: acer + capture
  3175. */
  3176. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3177. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3178. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3179. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3180. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3181. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3182. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3183. { } /* end */
  3184. };
  3185. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3186. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3187. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3188. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3189. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3190. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3191. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3192. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3193. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3194. { } /* end */
  3195. };
  3196. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3197. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3198. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3199. { } /* end */
  3200. };
  3201. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3202. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3203. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3204. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3205. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3206. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3207. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3208. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3209. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3210. { } /* end */
  3211. };
  3212. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3213. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3214. */
  3215. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3216. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3217. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3218. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3219. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3220. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3221. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3222. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3223. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3224. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3225. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3226. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3227. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3228. { } /* end */
  3229. };
  3230. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3231. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3232. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3233. * datasheet doesn't mention this restriction. At this stage it's not clear
  3234. * whether this behaviour is intentional or is a hardware bug in chip
  3235. * revisions available in early 2006. Therefore for now allow the
  3236. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3237. * that the lack of mic bias for this NID is intentional we could change the
  3238. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3239. *
  3240. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3241. * don't appear to make the mic bias available from the "line" jack, even
  3242. * though the NID used for this jack (0x14) can supply it. The theory is
  3243. * that perhaps Acer have included blocking capacitors between the ALC260
  3244. * and the output jack. If this turns out to be the case for all such
  3245. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3246. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3247. *
  3248. * The C20x Tablet series have a mono internal speaker which is controlled
  3249. * via the chip's Mono sum widget and pin complex, so include the necessary
  3250. * controls for such models. On models without a "mono speaker" the control
  3251. * won't do anything.
  3252. */
  3253. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3254. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3255. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3256. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3257. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3258. HDA_OUTPUT),
  3259. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3260. HDA_INPUT),
  3261. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3262. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3263. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3264. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3265. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3266. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3267. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3268. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3269. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3270. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3271. { } /* end */
  3272. };
  3273. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3274. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3275. */
  3276. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3277. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3278. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3279. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3280. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3281. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3282. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3283. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3284. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3285. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3286. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3287. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3288. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3289. { } /* end */
  3290. };
  3291. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3292. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3293. */
  3294. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3295. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3296. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3297. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3298. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3299. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3300. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3301. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3302. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3303. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3304. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3305. { } /* end */
  3306. };
  3307. /* capture mixer elements */
  3308. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3309. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3310. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3311. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3312. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3313. {
  3314. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3315. /* The multiple "Capture Source" controls confuse alsamixer
  3316. * So call somewhat different..
  3317. * FIXME: the controls appear in the "playback" view!
  3318. */
  3319. /* .name = "Capture Source", */
  3320. .name = "Input Source",
  3321. .count = 2,
  3322. .info = alc_mux_enum_info,
  3323. .get = alc_mux_enum_get,
  3324. .put = alc_mux_enum_put,
  3325. },
  3326. { } /* end */
  3327. };
  3328. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3329. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3330. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3331. {
  3332. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3333. /* The multiple "Capture Source" controls confuse alsamixer
  3334. * So call somewhat different..
  3335. * FIXME: the controls appear in the "playback" view!
  3336. */
  3337. /* .name = "Capture Source", */
  3338. .name = "Input Source",
  3339. .count = 1,
  3340. .info = alc_mux_enum_info,
  3341. .get = alc_mux_enum_get,
  3342. .put = alc_mux_enum_put,
  3343. },
  3344. { } /* end */
  3345. };
  3346. /*
  3347. * initialization verbs
  3348. */
  3349. static struct hda_verb alc260_init_verbs[] = {
  3350. /* Line In pin widget for input */
  3351. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3352. /* CD pin widget for input */
  3353. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3354. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3355. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3356. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3357. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3358. /* LINE-2 is used for line-out in rear */
  3359. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3360. /* select line-out */
  3361. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3362. /* LINE-OUT pin */
  3363. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3364. /* enable HP */
  3365. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3366. /* enable Mono */
  3367. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3368. /* mute capture amp left and right */
  3369. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3370. /* set connection select to line in (default select for this ADC) */
  3371. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3372. /* mute capture amp left and right */
  3373. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3374. /* set connection select to line in (default select for this ADC) */
  3375. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3376. /* set vol=0 Line-Out mixer amp left and right */
  3377. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3378. /* unmute pin widget amp left and right (no gain on this amp) */
  3379. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3380. /* set vol=0 HP mixer amp left and right */
  3381. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3382. /* unmute pin widget amp left and right (no gain on this amp) */
  3383. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3384. /* set vol=0 Mono mixer amp left and right */
  3385. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3386. /* unmute pin widget amp left and right (no gain on this amp) */
  3387. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3388. /* unmute LINE-2 out pin */
  3389. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3390. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3391. * Line In 2 = 0x03
  3392. */
  3393. /* mute analog inputs */
  3394. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3395. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3397. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3398. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3399. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3400. /* mute Front out path */
  3401. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3402. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3403. /* mute Headphone out path */
  3404. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3405. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3406. /* mute Mono out path */
  3407. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3408. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3409. { }
  3410. };
  3411. #if 0 /* should be identical with alc260_init_verbs? */
  3412. static struct hda_verb alc260_hp_init_verbs[] = {
  3413. /* Headphone and output */
  3414. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3415. /* mono output */
  3416. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3417. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3418. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3419. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3420. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3421. /* Line In pin widget for input */
  3422. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3423. /* Line-2 pin widget for output */
  3424. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3425. /* CD pin widget for input */
  3426. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3427. /* unmute amp left and right */
  3428. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3429. /* set connection select to line in (default select for this ADC) */
  3430. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3431. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3432. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3433. /* mute pin widget amp left and right (no gain on this amp) */
  3434. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3435. /* unmute HP mixer amp left and right (volume = 0) */
  3436. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3437. /* mute pin widget amp left and right (no gain on this amp) */
  3438. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3439. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3440. * Line In 2 = 0x03
  3441. */
  3442. /* mute analog inputs */
  3443. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3444. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3445. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3446. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3447. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3448. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3449. /* Unmute Front out path */
  3450. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3451. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3452. /* Unmute Headphone out path */
  3453. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3454. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3455. /* Unmute Mono out path */
  3456. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3457. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3458. { }
  3459. };
  3460. #endif
  3461. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3462. /* Line out and output */
  3463. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3464. /* mono output */
  3465. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3466. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3467. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3468. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3469. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3470. /* Line In pin widget for input */
  3471. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3472. /* Headphone pin widget for output */
  3473. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3474. /* CD pin widget for input */
  3475. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3476. /* unmute amp left and right */
  3477. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3478. /* set connection select to line in (default select for this ADC) */
  3479. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3480. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3481. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3482. /* mute pin widget amp left and right (no gain on this amp) */
  3483. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3484. /* unmute HP mixer amp left and right (volume = 0) */
  3485. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3486. /* mute pin widget amp left and right (no gain on this amp) */
  3487. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3488. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3489. * Line In 2 = 0x03
  3490. */
  3491. /* mute analog inputs */
  3492. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3493. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3494. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3495. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3496. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3497. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3498. /* Unmute Front out path */
  3499. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3500. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3501. /* Unmute Headphone out path */
  3502. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3503. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3504. /* Unmute Mono out path */
  3505. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3506. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3507. { }
  3508. };
  3509. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3510. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3511. * audio = 0x16, internal speaker = 0x10.
  3512. */
  3513. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3514. /* Disable all GPIOs */
  3515. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3516. /* Internal speaker is connected to headphone pin */
  3517. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3518. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3519. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3520. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3521. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3522. /* Ensure all other unused pins are disabled and muted. */
  3523. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3524. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3525. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3526. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3527. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3528. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3529. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3530. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3531. /* Disable digital (SPDIF) pins */
  3532. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3533. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3534. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3535. * when acting as an output.
  3536. */
  3537. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3538. /* Start with output sum widgets muted and their output gains at min */
  3539. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3540. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3541. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3542. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3543. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3544. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3545. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3546. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3547. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3548. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3549. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3550. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3551. * If the pin mode is changed by the user the pin mode control will
  3552. * take care of enabling the pin's input/output buffers as needed.
  3553. * Therefore there's no need to enable the input buffer at this
  3554. * stage.
  3555. */
  3556. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3557. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3558. * mixer ctrl)
  3559. */
  3560. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3561. /* Mute capture amp left and right */
  3562. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3563. /* Set ADC connection select to match default mixer setting - line
  3564. * in (on mic1 pin)
  3565. */
  3566. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3567. /* Do the same for the second ADC: mute capture input amp and
  3568. * set ADC connection to line in (on mic1 pin)
  3569. */
  3570. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3571. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3572. /* Mute all inputs to mixer widget (even unconnected ones) */
  3573. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3575. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3576. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3578. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3579. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3580. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3581. { }
  3582. };
  3583. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3584. * similar laptops (adapted from Fujitsu init verbs).
  3585. */
  3586. static struct hda_verb alc260_acer_init_verbs[] = {
  3587. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3588. * the headphone jack. Turn this on and rely on the standard mute
  3589. * methods whenever the user wants to turn these outputs off.
  3590. */
  3591. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3592. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3593. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3594. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3595. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3596. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3597. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3598. /* Line In jack is connected to Line1 pin */
  3599. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3600. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3601. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3602. /* Ensure all other unused pins are disabled and muted. */
  3603. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3604. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3605. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3606. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3607. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3608. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3609. /* Disable digital (SPDIF) pins */
  3610. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3611. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3612. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3613. * bus when acting as outputs.
  3614. */
  3615. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3616. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3617. /* Start with output sum widgets muted and their output gains at min */
  3618. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3619. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3620. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3621. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3622. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3623. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3624. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3625. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3626. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3627. /* Unmute Line-out pin widget amp left and right
  3628. * (no equiv mixer ctrl)
  3629. */
  3630. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3631. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3632. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3633. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3634. * inputs. If the pin mode is changed by the user the pin mode control
  3635. * will take care of enabling the pin's input/output buffers as needed.
  3636. * Therefore there's no need to enable the input buffer at this
  3637. * stage.
  3638. */
  3639. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3640. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3641. /* Mute capture amp left and right */
  3642. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3643. /* Set ADC connection select to match default mixer setting - mic
  3644. * (on mic1 pin)
  3645. */
  3646. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3647. /* Do similar with the second ADC: mute capture input amp and
  3648. * set ADC connection to mic to match ALSA's default state.
  3649. */
  3650. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3651. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3652. /* Mute all inputs to mixer widget (even unconnected ones) */
  3653. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3658. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3659. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3660. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3661. { }
  3662. };
  3663. static struct hda_verb alc260_will_verbs[] = {
  3664. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3665. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3666. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3667. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3668. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3669. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3670. {}
  3671. };
  3672. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3673. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3674. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3675. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3676. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3677. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3678. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3679. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3680. {}
  3681. };
  3682. /* toggle speaker-output according to the hp-jack state */
  3683. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3684. {
  3685. unsigned int present;
  3686. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3687. present = snd_hda_codec_read(codec, 0x0f, 0,
  3688. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3689. if (present) {
  3690. snd_hda_codec_write_cache(codec, 0x01, 0,
  3691. AC_VERB_SET_GPIO_DATA, 1);
  3692. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3693. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3694. PIN_HP);
  3695. } else {
  3696. snd_hda_codec_write_cache(codec, 0x01, 0,
  3697. AC_VERB_SET_GPIO_DATA, 0);
  3698. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3699. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3700. PIN_OUT);
  3701. }
  3702. }
  3703. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3704. unsigned int res)
  3705. {
  3706. if ((res >> 26) == ALC880_HP_EVENT)
  3707. alc260_replacer_672v_automute(codec);
  3708. }
  3709. /* Test configuration for debugging, modelled after the ALC880 test
  3710. * configuration.
  3711. */
  3712. #ifdef CONFIG_SND_DEBUG
  3713. static hda_nid_t alc260_test_dac_nids[1] = {
  3714. 0x02,
  3715. };
  3716. static hda_nid_t alc260_test_adc_nids[2] = {
  3717. 0x04, 0x05,
  3718. };
  3719. /* For testing the ALC260, each input MUX needs its own definition since
  3720. * the signal assignments are different. This assumes that the first ADC
  3721. * is NID 0x04.
  3722. */
  3723. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3724. {
  3725. .num_items = 7,
  3726. .items = {
  3727. { "MIC1 pin", 0x0 },
  3728. { "MIC2 pin", 0x1 },
  3729. { "LINE1 pin", 0x2 },
  3730. { "LINE2 pin", 0x3 },
  3731. { "CD pin", 0x4 },
  3732. { "LINE-OUT pin", 0x5 },
  3733. { "HP-OUT pin", 0x6 },
  3734. },
  3735. },
  3736. {
  3737. .num_items = 8,
  3738. .items = {
  3739. { "MIC1 pin", 0x0 },
  3740. { "MIC2 pin", 0x1 },
  3741. { "LINE1 pin", 0x2 },
  3742. { "LINE2 pin", 0x3 },
  3743. { "CD pin", 0x4 },
  3744. { "Mixer", 0x5 },
  3745. { "LINE-OUT pin", 0x6 },
  3746. { "HP-OUT pin", 0x7 },
  3747. },
  3748. },
  3749. };
  3750. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3751. /* Output driver widgets */
  3752. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3753. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3754. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3755. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3756. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3757. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3758. /* Modes for retasking pin widgets
  3759. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3760. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3761. * mention this restriction. At this stage it's not clear whether
  3762. * this behaviour is intentional or is a hardware bug in chip
  3763. * revisions available at least up until early 2006. Therefore for
  3764. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3765. * choices, but if it turns out that the lack of mic bias for these
  3766. * NIDs is intentional we could change their modes from
  3767. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3768. */
  3769. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3770. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3771. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3772. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3773. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3774. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3775. /* Loopback mixer controls */
  3776. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3777. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3778. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3779. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3780. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3781. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3782. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3783. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3784. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3785. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3786. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3787. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3788. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3789. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3790. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3791. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3792. /* Controls for GPIO pins, assuming they are configured as outputs */
  3793. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3794. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3795. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3796. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3797. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3798. * is ambigious as to which NID is which; testing on laptops which
  3799. * make this output available should provide clarification.
  3800. */
  3801. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3802. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3803. { } /* end */
  3804. };
  3805. static struct hda_verb alc260_test_init_verbs[] = {
  3806. /* Enable all GPIOs as outputs with an initial value of 0 */
  3807. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3808. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3809. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3810. /* Enable retasking pins as output, initially without power amp */
  3811. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3812. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3813. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3814. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3815. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3816. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3817. /* Disable digital (SPDIF) pins initially, but users can enable
  3818. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3819. * payload also sets the generation to 0, output to be in "consumer"
  3820. * PCM format, copyright asserted, no pre-emphasis and no validity
  3821. * control.
  3822. */
  3823. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3824. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3825. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3826. * OUT1 sum bus when acting as an output.
  3827. */
  3828. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3829. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3830. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3831. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3832. /* Start with output sum widgets muted and their output gains at min */
  3833. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3834. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3835. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3836. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3837. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3838. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3839. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3840. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3841. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3842. /* Unmute retasking pin widget output buffers since the default
  3843. * state appears to be output. As the pin mode is changed by the
  3844. * user the pin mode control will take care of enabling the pin's
  3845. * input/output buffers as needed.
  3846. */
  3847. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3848. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3849. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3850. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3851. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3852. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3853. /* Also unmute the mono-out pin widget */
  3854. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3855. /* Mute capture amp left and right */
  3856. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3857. /* Set ADC connection select to match default mixer setting (mic1
  3858. * pin)
  3859. */
  3860. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3861. /* Do the same for the second ADC: mute capture input amp and
  3862. * set ADC connection to mic1 pin
  3863. */
  3864. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3865. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3866. /* Mute all inputs to mixer widget (even unconnected ones) */
  3867. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3871. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3872. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3873. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3874. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3875. { }
  3876. };
  3877. #endif
  3878. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3879. .substreams = 1,
  3880. .channels_min = 2,
  3881. .channels_max = 2,
  3882. };
  3883. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3884. .substreams = 1,
  3885. .channels_min = 2,
  3886. .channels_max = 2,
  3887. };
  3888. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3889. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3890. /*
  3891. * for BIOS auto-configuration
  3892. */
  3893. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3894. const char *pfx)
  3895. {
  3896. hda_nid_t nid_vol;
  3897. unsigned long vol_val, sw_val;
  3898. char name[32];
  3899. int err;
  3900. if (nid >= 0x0f && nid < 0x11) {
  3901. nid_vol = nid - 0x7;
  3902. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3903. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3904. } else if (nid == 0x11) {
  3905. nid_vol = nid - 0x7;
  3906. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3907. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3908. } else if (nid >= 0x12 && nid <= 0x15) {
  3909. nid_vol = 0x08;
  3910. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3911. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3912. } else
  3913. return 0; /* N/A */
  3914. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3915. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3916. if (err < 0)
  3917. return err;
  3918. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3919. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3920. if (err < 0)
  3921. return err;
  3922. return 1;
  3923. }
  3924. /* add playback controls from the parsed DAC table */
  3925. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3926. const struct auto_pin_cfg *cfg)
  3927. {
  3928. hda_nid_t nid;
  3929. int err;
  3930. spec->multiout.num_dacs = 1;
  3931. spec->multiout.dac_nids = spec->private_dac_nids;
  3932. spec->multiout.dac_nids[0] = 0x02;
  3933. nid = cfg->line_out_pins[0];
  3934. if (nid) {
  3935. err = alc260_add_playback_controls(spec, nid, "Front");
  3936. if (err < 0)
  3937. return err;
  3938. }
  3939. nid = cfg->speaker_pins[0];
  3940. if (nid) {
  3941. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3942. if (err < 0)
  3943. return err;
  3944. }
  3945. nid = cfg->hp_pins[0];
  3946. if (nid) {
  3947. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3948. if (err < 0)
  3949. return err;
  3950. }
  3951. return 0;
  3952. }
  3953. /* create playback/capture controls for input pins */
  3954. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3955. const struct auto_pin_cfg *cfg)
  3956. {
  3957. struct hda_input_mux *imux = &spec->private_imux;
  3958. int i, err, idx;
  3959. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3960. if (cfg->input_pins[i] >= 0x12) {
  3961. idx = cfg->input_pins[i] - 0x12;
  3962. err = new_analog_input(spec, cfg->input_pins[i],
  3963. auto_pin_cfg_labels[i], idx,
  3964. 0x07);
  3965. if (err < 0)
  3966. return err;
  3967. imux->items[imux->num_items].label =
  3968. auto_pin_cfg_labels[i];
  3969. imux->items[imux->num_items].index = idx;
  3970. imux->num_items++;
  3971. }
  3972. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3973. idx = cfg->input_pins[i] - 0x09;
  3974. err = new_analog_input(spec, cfg->input_pins[i],
  3975. auto_pin_cfg_labels[i], idx,
  3976. 0x07);
  3977. if (err < 0)
  3978. return err;
  3979. imux->items[imux->num_items].label =
  3980. auto_pin_cfg_labels[i];
  3981. imux->items[imux->num_items].index = idx;
  3982. imux->num_items++;
  3983. }
  3984. }
  3985. return 0;
  3986. }
  3987. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3988. hda_nid_t nid, int pin_type,
  3989. int sel_idx)
  3990. {
  3991. /* set as output */
  3992. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3993. pin_type);
  3994. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3995. AMP_OUT_UNMUTE);
  3996. /* need the manual connection? */
  3997. if (nid >= 0x12) {
  3998. int idx = nid - 0x12;
  3999. snd_hda_codec_write(codec, idx + 0x0b, 0,
  4000. AC_VERB_SET_CONNECT_SEL, sel_idx);
  4001. }
  4002. }
  4003. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4004. {
  4005. struct alc_spec *spec = codec->spec;
  4006. hda_nid_t nid;
  4007. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4008. nid = spec->autocfg.line_out_pins[0];
  4009. if (nid) {
  4010. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4011. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4012. }
  4013. nid = spec->autocfg.speaker_pins[0];
  4014. if (nid)
  4015. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4016. nid = spec->autocfg.hp_pins[0];
  4017. if (nid)
  4018. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4019. }
  4020. #define ALC260_PIN_CD_NID 0x16
  4021. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4022. {
  4023. struct alc_spec *spec = codec->spec;
  4024. int i;
  4025. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4026. hda_nid_t nid = spec->autocfg.input_pins[i];
  4027. if (nid >= 0x12) {
  4028. snd_hda_codec_write(codec, nid, 0,
  4029. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4030. i <= AUTO_PIN_FRONT_MIC ?
  4031. PIN_VREF80 : PIN_IN);
  4032. if (nid != ALC260_PIN_CD_NID)
  4033. snd_hda_codec_write(codec, nid, 0,
  4034. AC_VERB_SET_AMP_GAIN_MUTE,
  4035. AMP_OUT_MUTE);
  4036. }
  4037. }
  4038. }
  4039. /*
  4040. * generic initialization of ADC, input mixers and output mixers
  4041. */
  4042. static struct hda_verb alc260_volume_init_verbs[] = {
  4043. /*
  4044. * Unmute ADC0-1 and set the default input to mic-in
  4045. */
  4046. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4047. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4048. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4049. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4050. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4051. * mixer widget
  4052. * Note: PASD motherboards uses the Line In 2 as the input for
  4053. * front panel mic (mic 2)
  4054. */
  4055. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4056. /* mute analog inputs */
  4057. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4059. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4062. /*
  4063. * Set up output mixers (0x08 - 0x0a)
  4064. */
  4065. /* set vol=0 to output mixers */
  4066. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4067. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4068. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4069. /* set up input amps for analog loopback */
  4070. /* Amp Indices: DAC = 0, mixer = 1 */
  4071. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4072. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4073. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4074. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4075. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4076. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4077. { }
  4078. };
  4079. static int alc260_parse_auto_config(struct hda_codec *codec)
  4080. {
  4081. struct alc_spec *spec = codec->spec;
  4082. unsigned int wcap;
  4083. int err;
  4084. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4085. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4086. alc260_ignore);
  4087. if (err < 0)
  4088. return err;
  4089. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4090. if (err < 0)
  4091. return err;
  4092. if (!spec->kctl_alloc)
  4093. return 0; /* can't find valid BIOS pin config */
  4094. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4095. if (err < 0)
  4096. return err;
  4097. spec->multiout.max_channels = 2;
  4098. if (spec->autocfg.dig_out_pin)
  4099. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4100. if (spec->kctl_alloc)
  4101. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4102. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4103. spec->num_mux_defs = 1;
  4104. spec->input_mux = &spec->private_imux;
  4105. /* check whether NID 0x04 is valid */
  4106. wcap = get_wcaps(codec, 0x04);
  4107. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4108. if (wcap != AC_WID_AUD_IN) {
  4109. spec->adc_nids = alc260_adc_nids_alt;
  4110. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4111. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4112. } else {
  4113. spec->adc_nids = alc260_adc_nids;
  4114. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4115. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4116. }
  4117. spec->num_mixers++;
  4118. return 1;
  4119. }
  4120. /* additional initialization for auto-configuration model */
  4121. static void alc260_auto_init(struct hda_codec *codec)
  4122. {
  4123. alc260_auto_init_multi_out(codec);
  4124. alc260_auto_init_analog_input(codec);
  4125. }
  4126. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4127. static struct hda_amp_list alc260_loopbacks[] = {
  4128. { 0x07, HDA_INPUT, 0 },
  4129. { 0x07, HDA_INPUT, 1 },
  4130. { 0x07, HDA_INPUT, 2 },
  4131. { 0x07, HDA_INPUT, 3 },
  4132. { 0x07, HDA_INPUT, 4 },
  4133. { } /* end */
  4134. };
  4135. #endif
  4136. /*
  4137. * ALC260 configurations
  4138. */
  4139. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4140. [ALC260_BASIC] = "basic",
  4141. [ALC260_HP] = "hp",
  4142. [ALC260_HP_3013] = "hp-3013",
  4143. [ALC260_FUJITSU_S702X] = "fujitsu",
  4144. [ALC260_ACER] = "acer",
  4145. [ALC260_WILL] = "will",
  4146. [ALC260_REPLACER_672V] = "replacer",
  4147. #ifdef CONFIG_SND_DEBUG
  4148. [ALC260_TEST] = "test",
  4149. #endif
  4150. [ALC260_AUTO] = "auto",
  4151. };
  4152. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4153. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4154. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4155. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4156. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4157. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4158. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4159. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4160. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4161. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4162. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4163. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4164. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4165. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4166. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4167. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4168. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4169. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4170. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4171. {}
  4172. };
  4173. static struct alc_config_preset alc260_presets[] = {
  4174. [ALC260_BASIC] = {
  4175. .mixers = { alc260_base_output_mixer,
  4176. alc260_input_mixer,
  4177. alc260_pc_beep_mixer,
  4178. alc260_capture_mixer },
  4179. .init_verbs = { alc260_init_verbs },
  4180. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4181. .dac_nids = alc260_dac_nids,
  4182. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4183. .adc_nids = alc260_adc_nids,
  4184. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4185. .channel_mode = alc260_modes,
  4186. .input_mux = &alc260_capture_source,
  4187. },
  4188. [ALC260_HP] = {
  4189. .mixers = { alc260_base_output_mixer,
  4190. alc260_input_mixer,
  4191. alc260_capture_alt_mixer },
  4192. .init_verbs = { alc260_init_verbs },
  4193. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4194. .dac_nids = alc260_dac_nids,
  4195. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4196. .adc_nids = alc260_hp_adc_nids,
  4197. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4198. .channel_mode = alc260_modes,
  4199. .input_mux = &alc260_capture_source,
  4200. },
  4201. [ALC260_HP_3013] = {
  4202. .mixers = { alc260_hp_3013_mixer,
  4203. alc260_input_mixer,
  4204. alc260_capture_alt_mixer },
  4205. .init_verbs = { alc260_hp_3013_init_verbs },
  4206. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4207. .dac_nids = alc260_dac_nids,
  4208. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4209. .adc_nids = alc260_hp_adc_nids,
  4210. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4211. .channel_mode = alc260_modes,
  4212. .input_mux = &alc260_capture_source,
  4213. },
  4214. [ALC260_FUJITSU_S702X] = {
  4215. .mixers = { alc260_fujitsu_mixer,
  4216. alc260_capture_mixer },
  4217. .init_verbs = { alc260_fujitsu_init_verbs },
  4218. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4219. .dac_nids = alc260_dac_nids,
  4220. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4221. .adc_nids = alc260_dual_adc_nids,
  4222. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4223. .channel_mode = alc260_modes,
  4224. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4225. .input_mux = alc260_fujitsu_capture_sources,
  4226. },
  4227. [ALC260_ACER] = {
  4228. .mixers = { alc260_acer_mixer,
  4229. alc260_capture_mixer },
  4230. .init_verbs = { alc260_acer_init_verbs },
  4231. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4232. .dac_nids = alc260_dac_nids,
  4233. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4234. .adc_nids = alc260_dual_adc_nids,
  4235. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4236. .channel_mode = alc260_modes,
  4237. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4238. .input_mux = alc260_acer_capture_sources,
  4239. },
  4240. [ALC260_WILL] = {
  4241. .mixers = { alc260_will_mixer,
  4242. alc260_capture_mixer },
  4243. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4244. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4245. .dac_nids = alc260_dac_nids,
  4246. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4247. .adc_nids = alc260_adc_nids,
  4248. .dig_out_nid = ALC260_DIGOUT_NID,
  4249. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4250. .channel_mode = alc260_modes,
  4251. .input_mux = &alc260_capture_source,
  4252. },
  4253. [ALC260_REPLACER_672V] = {
  4254. .mixers = { alc260_replacer_672v_mixer,
  4255. alc260_capture_mixer },
  4256. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4257. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4258. .dac_nids = alc260_dac_nids,
  4259. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4260. .adc_nids = alc260_adc_nids,
  4261. .dig_out_nid = ALC260_DIGOUT_NID,
  4262. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4263. .channel_mode = alc260_modes,
  4264. .input_mux = &alc260_capture_source,
  4265. .unsol_event = alc260_replacer_672v_unsol_event,
  4266. .init_hook = alc260_replacer_672v_automute,
  4267. },
  4268. #ifdef CONFIG_SND_DEBUG
  4269. [ALC260_TEST] = {
  4270. .mixers = { alc260_test_mixer,
  4271. alc260_capture_mixer },
  4272. .init_verbs = { alc260_test_init_verbs },
  4273. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4274. .dac_nids = alc260_test_dac_nids,
  4275. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4276. .adc_nids = alc260_test_adc_nids,
  4277. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4278. .channel_mode = alc260_modes,
  4279. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4280. .input_mux = alc260_test_capture_sources,
  4281. },
  4282. #endif
  4283. };
  4284. static int patch_alc260(struct hda_codec *codec)
  4285. {
  4286. struct alc_spec *spec;
  4287. int err, board_config;
  4288. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4289. if (spec == NULL)
  4290. return -ENOMEM;
  4291. codec->spec = spec;
  4292. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4293. alc260_models,
  4294. alc260_cfg_tbl);
  4295. if (board_config < 0) {
  4296. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4297. "trying auto-probe from BIOS...\n");
  4298. board_config = ALC260_AUTO;
  4299. }
  4300. if (board_config == ALC260_AUTO) {
  4301. /* automatic parse from the BIOS config */
  4302. err = alc260_parse_auto_config(codec);
  4303. if (err < 0) {
  4304. alc_free(codec);
  4305. return err;
  4306. } else if (!err) {
  4307. printk(KERN_INFO
  4308. "hda_codec: Cannot set up configuration "
  4309. "from BIOS. Using base mode...\n");
  4310. board_config = ALC260_BASIC;
  4311. }
  4312. }
  4313. if (board_config != ALC260_AUTO)
  4314. setup_preset(spec, &alc260_presets[board_config]);
  4315. spec->stream_name_analog = "ALC260 Analog";
  4316. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4317. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4318. spec->stream_name_digital = "ALC260 Digital";
  4319. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4320. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4321. codec->patch_ops = alc_patch_ops;
  4322. if (board_config == ALC260_AUTO)
  4323. spec->init_hook = alc260_auto_init;
  4324. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4325. if (!spec->loopback.amplist)
  4326. spec->loopback.amplist = alc260_loopbacks;
  4327. #endif
  4328. return 0;
  4329. }
  4330. /*
  4331. * ALC882 support
  4332. *
  4333. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4334. * configuration. Each pin widget can choose any input DACs and a mixer.
  4335. * Each ADC is connected from a mixer of all inputs. This makes possible
  4336. * 6-channel independent captures.
  4337. *
  4338. * In addition, an independent DAC for the multi-playback (not used in this
  4339. * driver yet).
  4340. */
  4341. #define ALC882_DIGOUT_NID 0x06
  4342. #define ALC882_DIGIN_NID 0x0a
  4343. static struct hda_channel_mode alc882_ch_modes[1] = {
  4344. { 8, NULL }
  4345. };
  4346. static hda_nid_t alc882_dac_nids[4] = {
  4347. /* front, rear, clfe, rear_surr */
  4348. 0x02, 0x03, 0x04, 0x05
  4349. };
  4350. /* identical with ALC880 */
  4351. #define alc882_adc_nids alc880_adc_nids
  4352. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4353. /* input MUX */
  4354. /* FIXME: should be a matrix-type input source selection */
  4355. static struct hda_input_mux alc882_capture_source = {
  4356. .num_items = 4,
  4357. .items = {
  4358. { "Mic", 0x0 },
  4359. { "Front Mic", 0x1 },
  4360. { "Line", 0x2 },
  4361. { "CD", 0x4 },
  4362. },
  4363. };
  4364. #define alc882_mux_enum_info alc_mux_enum_info
  4365. #define alc882_mux_enum_get alc_mux_enum_get
  4366. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4367. struct snd_ctl_elem_value *ucontrol)
  4368. {
  4369. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4370. struct alc_spec *spec = codec->spec;
  4371. const struct hda_input_mux *imux = spec->input_mux;
  4372. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4373. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4374. hda_nid_t nid = capture_mixers[adc_idx];
  4375. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4376. unsigned int i, idx;
  4377. idx = ucontrol->value.enumerated.item[0];
  4378. if (idx >= imux->num_items)
  4379. idx = imux->num_items - 1;
  4380. if (*cur_val == idx)
  4381. return 0;
  4382. for (i = 0; i < imux->num_items; i++) {
  4383. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4384. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4385. imux->items[i].index,
  4386. HDA_AMP_MUTE, v);
  4387. }
  4388. *cur_val = idx;
  4389. return 1;
  4390. }
  4391. /*
  4392. * 2ch mode
  4393. */
  4394. static struct hda_verb alc882_3ST_ch2_init[] = {
  4395. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4396. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4397. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4398. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4399. { } /* end */
  4400. };
  4401. /*
  4402. * 6ch mode
  4403. */
  4404. static struct hda_verb alc882_3ST_ch6_init[] = {
  4405. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4406. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4407. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4408. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4409. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4410. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4411. { } /* end */
  4412. };
  4413. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4414. { 2, alc882_3ST_ch2_init },
  4415. { 6, alc882_3ST_ch6_init },
  4416. };
  4417. /*
  4418. * 6ch mode
  4419. */
  4420. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4421. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4422. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4423. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4424. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4425. { } /* end */
  4426. };
  4427. /*
  4428. * 8ch mode
  4429. */
  4430. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4431. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4432. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4433. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4434. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4435. { } /* end */
  4436. };
  4437. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4438. { 6, alc882_sixstack_ch6_init },
  4439. { 8, alc882_sixstack_ch8_init },
  4440. };
  4441. /*
  4442. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4443. */
  4444. /*
  4445. * 2ch mode
  4446. */
  4447. static struct hda_verb alc885_mbp_ch2_init[] = {
  4448. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4449. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4450. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4451. { } /* end */
  4452. };
  4453. /*
  4454. * 6ch mode
  4455. */
  4456. static struct hda_verb alc885_mbp_ch6_init[] = {
  4457. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4458. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4459. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4460. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4461. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4462. { } /* end */
  4463. };
  4464. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4465. { 2, alc885_mbp_ch2_init },
  4466. { 6, alc885_mbp_ch6_init },
  4467. };
  4468. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4469. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4470. */
  4471. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4472. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4473. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4474. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4475. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4476. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4477. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4478. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4479. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4480. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4481. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4482. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4483. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4484. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4485. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4486. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4487. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4488. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4489. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4490. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4491. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4492. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4493. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4494. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4495. { } /* end */
  4496. };
  4497. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4498. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4499. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4500. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4501. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4502. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4503. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4504. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4505. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4506. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4507. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4508. { } /* end */
  4509. };
  4510. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4511. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4512. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4513. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4514. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4515. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4516. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4517. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4518. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4519. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4520. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4521. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4522. { } /* end */
  4523. };
  4524. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4525. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4526. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4527. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4528. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4529. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4530. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4531. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4532. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4533. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4534. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4535. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4536. { } /* end */
  4537. };
  4538. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4539. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4540. */
  4541. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4542. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4543. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4544. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4545. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4546. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4547. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4548. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4549. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4550. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4551. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4552. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4553. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4554. { } /* end */
  4555. };
  4556. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4557. {
  4558. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4559. .name = "Channel Mode",
  4560. .info = alc_ch_mode_info,
  4561. .get = alc_ch_mode_get,
  4562. .put = alc_ch_mode_put,
  4563. },
  4564. { } /* end */
  4565. };
  4566. static struct hda_verb alc882_init_verbs[] = {
  4567. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4568. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4569. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4570. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4571. /* Rear mixer */
  4572. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4573. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4574. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4575. /* CLFE mixer */
  4576. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4577. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4578. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4579. /* Side mixer */
  4580. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4581. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4582. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4583. /* Front Pin: output 0 (0x0c) */
  4584. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4585. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4586. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4587. /* Rear Pin: output 1 (0x0d) */
  4588. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4589. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4590. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4591. /* CLFE Pin: output 2 (0x0e) */
  4592. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4593. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4594. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4595. /* Side Pin: output 3 (0x0f) */
  4596. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4597. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4598. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4599. /* Mic (rear) pin: input vref at 80% */
  4600. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4601. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4602. /* Front Mic pin: input vref at 80% */
  4603. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4604. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4605. /* Line In pin: input */
  4606. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4607. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4608. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4609. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4610. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4611. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4612. /* CD pin widget for input */
  4613. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4614. /* FIXME: use matrix-type input source selection */
  4615. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4616. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4617. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4618. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4619. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4620. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4621. /* Input mixer2 */
  4622. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4623. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4624. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4625. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4626. /* Input mixer3 */
  4627. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4628. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4629. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4630. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4631. /* ADC1: mute amp left and right */
  4632. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4633. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4634. /* ADC2: mute amp left and right */
  4635. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4636. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4637. /* ADC3: mute amp left and right */
  4638. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4639. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4640. { }
  4641. };
  4642. static struct hda_verb alc882_eapd_verbs[] = {
  4643. /* change to EAPD mode */
  4644. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4645. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4646. { }
  4647. };
  4648. /* Mac Pro test */
  4649. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4650. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4651. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4652. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4653. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4654. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4655. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4656. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4657. { } /* end */
  4658. };
  4659. static struct hda_verb alc882_macpro_init_verbs[] = {
  4660. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4661. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4662. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4663. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4664. /* Front Pin: output 0 (0x0c) */
  4665. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4666. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4667. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4668. /* Front Mic pin: input vref at 80% */
  4669. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4670. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4671. /* Speaker: output */
  4672. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4673. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4674. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4675. /* Headphone output (output 0 - 0x0c) */
  4676. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4677. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4678. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4679. /* FIXME: use matrix-type input source selection */
  4680. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4681. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4682. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4683. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4684. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4685. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4686. /* Input mixer2 */
  4687. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4688. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4689. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4690. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4691. /* Input mixer3 */
  4692. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4693. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4694. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4695. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4696. /* ADC1: mute amp left and right */
  4697. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4698. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4699. /* ADC2: mute amp left and right */
  4700. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4701. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4702. /* ADC3: mute amp left and right */
  4703. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4704. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4705. { }
  4706. };
  4707. /* Macbook Pro rev3 */
  4708. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4709. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4710. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4711. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4712. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4713. /* Rear mixer */
  4714. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4715. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4716. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4717. /* Front Pin: output 0 (0x0c) */
  4718. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4719. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4720. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4721. /* HP Pin: output 0 (0x0d) */
  4722. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4723. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4724. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4725. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4726. /* Mic (rear) pin: input vref at 80% */
  4727. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4728. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4729. /* Front Mic pin: input vref at 80% */
  4730. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4731. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4732. /* Line In pin: use output 1 when in LineOut mode */
  4733. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4734. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4735. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4736. /* FIXME: use matrix-type input source selection */
  4737. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4738. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4739. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4740. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4741. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4742. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4743. /* Input mixer2 */
  4744. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4745. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4746. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4747. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4748. /* Input mixer3 */
  4749. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4750. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4751. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4752. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4753. /* ADC1: mute amp left and right */
  4754. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4755. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4756. /* ADC2: mute amp left and right */
  4757. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4758. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4759. /* ADC3: mute amp left and right */
  4760. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4761. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4762. { }
  4763. };
  4764. /* iMac 24 mixer. */
  4765. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4766. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4767. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4768. { } /* end */
  4769. };
  4770. /* iMac 24 init verbs. */
  4771. static struct hda_verb alc885_imac24_init_verbs[] = {
  4772. /* Internal speakers: output 0 (0x0c) */
  4773. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4774. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4775. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4776. /* Internal speakers: output 0 (0x0c) */
  4777. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4778. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4779. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4780. /* Headphone: output 0 (0x0c) */
  4781. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4782. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4783. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4784. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4785. /* Front Mic: input vref at 80% */
  4786. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4787. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4788. { }
  4789. };
  4790. /* Toggle speaker-output according to the hp-jack state */
  4791. static void alc885_imac24_automute(struct hda_codec *codec)
  4792. {
  4793. unsigned int present;
  4794. present = snd_hda_codec_read(codec, 0x14, 0,
  4795. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4796. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4797. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4798. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4799. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4800. }
  4801. /* Processes unsolicited events. */
  4802. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4803. unsigned int res)
  4804. {
  4805. /* Headphone insertion or removal. */
  4806. if ((res >> 26) == ALC880_HP_EVENT)
  4807. alc885_imac24_automute(codec);
  4808. }
  4809. static void alc885_mbp3_automute(struct hda_codec *codec)
  4810. {
  4811. unsigned int present;
  4812. present = snd_hda_codec_read(codec, 0x15, 0,
  4813. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4814. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  4815. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4816. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  4817. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  4818. }
  4819. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  4820. unsigned int res)
  4821. {
  4822. /* Headphone insertion or removal. */
  4823. if ((res >> 26) == ALC880_HP_EVENT)
  4824. alc885_mbp3_automute(codec);
  4825. }
  4826. static struct hda_verb alc882_targa_verbs[] = {
  4827. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4828. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4829. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4830. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4831. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4832. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4833. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4834. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4835. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4836. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4837. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4838. { } /* end */
  4839. };
  4840. /* toggle speaker-output according to the hp-jack state */
  4841. static void alc882_targa_automute(struct hda_codec *codec)
  4842. {
  4843. unsigned int present;
  4844. present = snd_hda_codec_read(codec, 0x14, 0,
  4845. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4846. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  4847. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4848. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  4849. present ? 1 : 3);
  4850. }
  4851. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4852. {
  4853. /* Looks like the unsol event is incompatible with the standard
  4854. * definition. 4bit tag is placed at 26 bit!
  4855. */
  4856. if (((res >> 26) == ALC880_HP_EVENT)) {
  4857. alc882_targa_automute(codec);
  4858. }
  4859. }
  4860. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4861. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4862. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4863. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4864. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4865. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4866. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4867. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4868. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4869. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4870. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4871. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4872. { } /* end */
  4873. };
  4874. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4875. {
  4876. unsigned int gpiostate, gpiomask, gpiodir;
  4877. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4878. AC_VERB_GET_GPIO_DATA, 0);
  4879. if (!muted)
  4880. gpiostate |= (1 << pin);
  4881. else
  4882. gpiostate &= ~(1 << pin);
  4883. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4884. AC_VERB_GET_GPIO_MASK, 0);
  4885. gpiomask |= (1 << pin);
  4886. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4887. AC_VERB_GET_GPIO_DIRECTION, 0);
  4888. gpiodir |= (1 << pin);
  4889. snd_hda_codec_write(codec, codec->afg, 0,
  4890. AC_VERB_SET_GPIO_MASK, gpiomask);
  4891. snd_hda_codec_write(codec, codec->afg, 0,
  4892. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4893. msleep(1);
  4894. snd_hda_codec_write(codec, codec->afg, 0,
  4895. AC_VERB_SET_GPIO_DATA, gpiostate);
  4896. }
  4897. /* set up GPIO at initialization */
  4898. static void alc885_macpro_init_hook(struct hda_codec *codec)
  4899. {
  4900. alc882_gpio_mute(codec, 0, 0);
  4901. alc882_gpio_mute(codec, 1, 0);
  4902. }
  4903. /* set up GPIO and update auto-muting at initialization */
  4904. static void alc885_imac24_init_hook(struct hda_codec *codec)
  4905. {
  4906. alc885_macpro_init_hook(codec);
  4907. alc885_imac24_automute(codec);
  4908. }
  4909. /*
  4910. * generic initialization of ADC, input mixers and output mixers
  4911. */
  4912. static struct hda_verb alc882_auto_init_verbs[] = {
  4913. /*
  4914. * Unmute ADC0-2 and set the default input to mic-in
  4915. */
  4916. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4917. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4918. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4919. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4920. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4921. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4922. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4923. * mixer widget
  4924. * Note: PASD motherboards uses the Line In 2 as the input for
  4925. * front panel mic (mic 2)
  4926. */
  4927. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4928. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4929. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4930. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4931. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4932. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4933. /*
  4934. * Set up output mixers (0x0c - 0x0f)
  4935. */
  4936. /* set vol=0 to output mixers */
  4937. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4938. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4939. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4940. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4941. /* set up input amps for analog loopback */
  4942. /* Amp Indices: DAC = 0, mixer = 1 */
  4943. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4944. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4945. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4946. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4947. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4948. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4949. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4950. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4951. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4952. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4953. /* FIXME: use matrix-type input source selection */
  4954. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4955. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4956. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4957. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4958. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4959. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4960. /* Input mixer2 */
  4961. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4962. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4963. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4964. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4965. /* Input mixer3 */
  4966. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4967. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4968. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4969. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4970. { }
  4971. };
  4972. /* capture mixer elements */
  4973. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4974. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4975. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4976. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4977. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4978. {
  4979. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4980. /* The multiple "Capture Source" controls confuse alsamixer
  4981. * So call somewhat different..
  4982. * FIXME: the controls appear in the "playback" view!
  4983. */
  4984. /* .name = "Capture Source", */
  4985. .name = "Input Source",
  4986. .count = 2,
  4987. .info = alc882_mux_enum_info,
  4988. .get = alc882_mux_enum_get,
  4989. .put = alc882_mux_enum_put,
  4990. },
  4991. { } /* end */
  4992. };
  4993. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4994. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4995. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4996. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4997. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4998. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4999. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  5000. {
  5001. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5002. /* The multiple "Capture Source" controls confuse alsamixer
  5003. * So call somewhat different..
  5004. * FIXME: the controls appear in the "playback" view!
  5005. */
  5006. /* .name = "Capture Source", */
  5007. .name = "Input Source",
  5008. .count = 3,
  5009. .info = alc882_mux_enum_info,
  5010. .get = alc882_mux_enum_get,
  5011. .put = alc882_mux_enum_put,
  5012. },
  5013. { } /* end */
  5014. };
  5015. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5016. #define alc882_loopbacks alc880_loopbacks
  5017. #endif
  5018. /* pcm configuration: identiacal with ALC880 */
  5019. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5020. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5021. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5022. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5023. /*
  5024. * configuration and preset
  5025. */
  5026. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5027. [ALC882_3ST_DIG] = "3stack-dig",
  5028. [ALC882_6ST_DIG] = "6stack-dig",
  5029. [ALC882_ARIMA] = "arima",
  5030. [ALC882_W2JC] = "w2jc",
  5031. [ALC885_MACPRO] = "macpro",
  5032. [ALC885_MBP3] = "mbp3",
  5033. [ALC885_IMAC24] = "imac24",
  5034. [ALC882_AUTO] = "auto",
  5035. };
  5036. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5037. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5038. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5039. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5040. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5041. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5042. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5043. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5044. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5045. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5046. {}
  5047. };
  5048. static struct alc_config_preset alc882_presets[] = {
  5049. [ALC882_3ST_DIG] = {
  5050. .mixers = { alc882_base_mixer },
  5051. .init_verbs = { alc882_init_verbs },
  5052. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5053. .dac_nids = alc882_dac_nids,
  5054. .dig_out_nid = ALC882_DIGOUT_NID,
  5055. .dig_in_nid = ALC882_DIGIN_NID,
  5056. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5057. .channel_mode = alc882_ch_modes,
  5058. .need_dac_fix = 1,
  5059. .input_mux = &alc882_capture_source,
  5060. },
  5061. [ALC882_6ST_DIG] = {
  5062. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5063. .init_verbs = { alc882_init_verbs },
  5064. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5065. .dac_nids = alc882_dac_nids,
  5066. .dig_out_nid = ALC882_DIGOUT_NID,
  5067. .dig_in_nid = ALC882_DIGIN_NID,
  5068. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5069. .channel_mode = alc882_sixstack_modes,
  5070. .input_mux = &alc882_capture_source,
  5071. },
  5072. [ALC882_ARIMA] = {
  5073. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5074. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5075. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5076. .dac_nids = alc882_dac_nids,
  5077. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5078. .channel_mode = alc882_sixstack_modes,
  5079. .input_mux = &alc882_capture_source,
  5080. },
  5081. [ALC882_W2JC] = {
  5082. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5083. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5084. alc880_gpio1_init_verbs },
  5085. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5086. .dac_nids = alc882_dac_nids,
  5087. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5088. .channel_mode = alc880_threestack_modes,
  5089. .need_dac_fix = 1,
  5090. .input_mux = &alc882_capture_source,
  5091. .dig_out_nid = ALC882_DIGOUT_NID,
  5092. },
  5093. [ALC885_MBP3] = {
  5094. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5095. .init_verbs = { alc885_mbp3_init_verbs,
  5096. alc880_gpio1_init_verbs },
  5097. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5098. .dac_nids = alc882_dac_nids,
  5099. .channel_mode = alc885_mbp_6ch_modes,
  5100. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5101. .input_mux = &alc882_capture_source,
  5102. .dig_out_nid = ALC882_DIGOUT_NID,
  5103. .dig_in_nid = ALC882_DIGIN_NID,
  5104. .unsol_event = alc885_mbp3_unsol_event,
  5105. .init_hook = alc885_mbp3_automute,
  5106. },
  5107. [ALC885_MACPRO] = {
  5108. .mixers = { alc882_macpro_mixer },
  5109. .init_verbs = { alc882_macpro_init_verbs },
  5110. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5111. .dac_nids = alc882_dac_nids,
  5112. .dig_out_nid = ALC882_DIGOUT_NID,
  5113. .dig_in_nid = ALC882_DIGIN_NID,
  5114. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5115. .channel_mode = alc882_ch_modes,
  5116. .input_mux = &alc882_capture_source,
  5117. .init_hook = alc885_macpro_init_hook,
  5118. },
  5119. [ALC885_IMAC24] = {
  5120. .mixers = { alc885_imac24_mixer },
  5121. .init_verbs = { alc885_imac24_init_verbs },
  5122. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5123. .dac_nids = alc882_dac_nids,
  5124. .dig_out_nid = ALC882_DIGOUT_NID,
  5125. .dig_in_nid = ALC882_DIGIN_NID,
  5126. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5127. .channel_mode = alc882_ch_modes,
  5128. .input_mux = &alc882_capture_source,
  5129. .unsol_event = alc885_imac24_unsol_event,
  5130. .init_hook = alc885_imac24_init_hook,
  5131. },
  5132. [ALC882_TARGA] = {
  5133. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5134. alc882_capture_mixer },
  5135. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5136. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5137. .dac_nids = alc882_dac_nids,
  5138. .dig_out_nid = ALC882_DIGOUT_NID,
  5139. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5140. .adc_nids = alc882_adc_nids,
  5141. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5142. .channel_mode = alc882_3ST_6ch_modes,
  5143. .need_dac_fix = 1,
  5144. .input_mux = &alc882_capture_source,
  5145. .unsol_event = alc882_targa_unsol_event,
  5146. .init_hook = alc882_targa_automute,
  5147. },
  5148. [ALC882_ASUS_A7J] = {
  5149. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5150. alc882_capture_mixer },
  5151. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5152. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5153. .dac_nids = alc882_dac_nids,
  5154. .dig_out_nid = ALC882_DIGOUT_NID,
  5155. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5156. .adc_nids = alc882_adc_nids,
  5157. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5158. .channel_mode = alc882_3ST_6ch_modes,
  5159. .need_dac_fix = 1,
  5160. .input_mux = &alc882_capture_source,
  5161. },
  5162. };
  5163. /*
  5164. * Pin config fixes
  5165. */
  5166. enum {
  5167. PINFIX_ABIT_AW9D_MAX
  5168. };
  5169. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5170. { 0x15, 0x01080104 }, /* side */
  5171. { 0x16, 0x01011012 }, /* rear */
  5172. { 0x17, 0x01016011 }, /* clfe */
  5173. { }
  5174. };
  5175. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5176. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5177. };
  5178. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5179. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5180. {}
  5181. };
  5182. /*
  5183. * BIOS auto configuration
  5184. */
  5185. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5186. hda_nid_t nid, int pin_type,
  5187. int dac_idx)
  5188. {
  5189. /* set as output */
  5190. struct alc_spec *spec = codec->spec;
  5191. int idx;
  5192. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5193. idx = 4;
  5194. else
  5195. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5196. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5197. pin_type);
  5198. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5199. AMP_OUT_UNMUTE);
  5200. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5201. }
  5202. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5203. {
  5204. struct alc_spec *spec = codec->spec;
  5205. int i;
  5206. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5207. for (i = 0; i <= HDA_SIDE; i++) {
  5208. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5209. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5210. if (nid)
  5211. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5212. i);
  5213. }
  5214. }
  5215. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5216. {
  5217. struct alc_spec *spec = codec->spec;
  5218. hda_nid_t pin;
  5219. pin = spec->autocfg.hp_pins[0];
  5220. if (pin) /* connect to front */
  5221. /* use dac 0 */
  5222. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5223. }
  5224. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5225. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5226. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5227. {
  5228. struct alc_spec *spec = codec->spec;
  5229. int i;
  5230. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5231. hda_nid_t nid = spec->autocfg.input_pins[i];
  5232. if (alc882_is_input_pin(nid)) {
  5233. snd_hda_codec_write(codec, nid, 0,
  5234. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5235. i <= AUTO_PIN_FRONT_MIC ?
  5236. PIN_VREF80 : PIN_IN);
  5237. if (nid != ALC882_PIN_CD_NID)
  5238. snd_hda_codec_write(codec, nid, 0,
  5239. AC_VERB_SET_AMP_GAIN_MUTE,
  5240. AMP_OUT_MUTE);
  5241. }
  5242. }
  5243. }
  5244. /* almost identical with ALC880 parser... */
  5245. static int alc882_parse_auto_config(struct hda_codec *codec)
  5246. {
  5247. struct alc_spec *spec = codec->spec;
  5248. int err = alc880_parse_auto_config(codec);
  5249. if (err < 0)
  5250. return err;
  5251. else if (err > 0)
  5252. /* hack - override the init verbs */
  5253. spec->init_verbs[0] = alc882_auto_init_verbs;
  5254. return err;
  5255. }
  5256. /* additional initialization for auto-configuration model */
  5257. static void alc882_auto_init(struct hda_codec *codec)
  5258. {
  5259. alc882_auto_init_multi_out(codec);
  5260. alc882_auto_init_hp_out(codec);
  5261. alc882_auto_init_analog_input(codec);
  5262. }
  5263. static int patch_alc882(struct hda_codec *codec)
  5264. {
  5265. struct alc_spec *spec;
  5266. int err, board_config;
  5267. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5268. if (spec == NULL)
  5269. return -ENOMEM;
  5270. codec->spec = spec;
  5271. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5272. alc882_models,
  5273. alc882_cfg_tbl);
  5274. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5275. /* Pick up systems that don't supply PCI SSID */
  5276. switch (codec->subsystem_id) {
  5277. case 0x106b0c00: /* Mac Pro */
  5278. board_config = ALC885_MACPRO;
  5279. break;
  5280. case 0x106b1000: /* iMac 24 */
  5281. board_config = ALC885_IMAC24;
  5282. break;
  5283. case 0x106b2c00: /* Macbook Pro rev3 */
  5284. board_config = ALC885_MBP3;
  5285. break;
  5286. default:
  5287. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5288. "trying auto-probe from BIOS...\n");
  5289. board_config = ALC882_AUTO;
  5290. }
  5291. }
  5292. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5293. if (board_config == ALC882_AUTO) {
  5294. /* automatic parse from the BIOS config */
  5295. err = alc882_parse_auto_config(codec);
  5296. if (err < 0) {
  5297. alc_free(codec);
  5298. return err;
  5299. } else if (!err) {
  5300. printk(KERN_INFO
  5301. "hda_codec: Cannot set up configuration "
  5302. "from BIOS. Using base mode...\n");
  5303. board_config = ALC882_3ST_DIG;
  5304. }
  5305. }
  5306. if (board_config != ALC882_AUTO)
  5307. setup_preset(spec, &alc882_presets[board_config]);
  5308. spec->stream_name_analog = "ALC882 Analog";
  5309. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5310. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5311. spec->stream_name_digital = "ALC882 Digital";
  5312. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5313. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5314. if (!spec->adc_nids && spec->input_mux) {
  5315. /* check whether NID 0x07 is valid */
  5316. unsigned int wcap = get_wcaps(codec, 0x07);
  5317. /* get type */
  5318. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5319. if (wcap != AC_WID_AUD_IN) {
  5320. spec->adc_nids = alc882_adc_nids_alt;
  5321. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5322. spec->mixers[spec->num_mixers] =
  5323. alc882_capture_alt_mixer;
  5324. spec->num_mixers++;
  5325. } else {
  5326. spec->adc_nids = alc882_adc_nids;
  5327. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5328. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5329. spec->num_mixers++;
  5330. }
  5331. }
  5332. codec->patch_ops = alc_patch_ops;
  5333. if (board_config == ALC882_AUTO)
  5334. spec->init_hook = alc882_auto_init;
  5335. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5336. if (!spec->loopback.amplist)
  5337. spec->loopback.amplist = alc882_loopbacks;
  5338. #endif
  5339. return 0;
  5340. }
  5341. /*
  5342. * ALC883 support
  5343. *
  5344. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5345. * configuration. Each pin widget can choose any input DACs and a mixer.
  5346. * Each ADC is connected from a mixer of all inputs. This makes possible
  5347. * 6-channel independent captures.
  5348. *
  5349. * In addition, an independent DAC for the multi-playback (not used in this
  5350. * driver yet).
  5351. */
  5352. #define ALC883_DIGOUT_NID 0x06
  5353. #define ALC883_DIGIN_NID 0x0a
  5354. static hda_nid_t alc883_dac_nids[4] = {
  5355. /* front, rear, clfe, rear_surr */
  5356. 0x02, 0x04, 0x03, 0x05
  5357. };
  5358. static hda_nid_t alc883_adc_nids[2] = {
  5359. /* ADC1-2 */
  5360. 0x08, 0x09,
  5361. };
  5362. /* input MUX */
  5363. /* FIXME: should be a matrix-type input source selection */
  5364. static struct hda_input_mux alc883_capture_source = {
  5365. .num_items = 4,
  5366. .items = {
  5367. { "Mic", 0x0 },
  5368. { "Front Mic", 0x1 },
  5369. { "Line", 0x2 },
  5370. { "CD", 0x4 },
  5371. },
  5372. };
  5373. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5374. .num_items = 2,
  5375. .items = {
  5376. { "Mic", 0x1 },
  5377. { "Line", 0x2 },
  5378. },
  5379. };
  5380. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5381. .num_items = 4,
  5382. .items = {
  5383. { "Mic", 0x0 },
  5384. { "iMic", 0x1 },
  5385. { "Line", 0x2 },
  5386. { "CD", 0x4 },
  5387. },
  5388. };
  5389. #define alc883_mux_enum_info alc_mux_enum_info
  5390. #define alc883_mux_enum_get alc_mux_enum_get
  5391. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5392. struct snd_ctl_elem_value *ucontrol)
  5393. {
  5394. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5395. struct alc_spec *spec = codec->spec;
  5396. const struct hda_input_mux *imux = spec->input_mux;
  5397. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5398. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5399. hda_nid_t nid = capture_mixers[adc_idx];
  5400. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5401. unsigned int i, idx;
  5402. idx = ucontrol->value.enumerated.item[0];
  5403. if (idx >= imux->num_items)
  5404. idx = imux->num_items - 1;
  5405. if (*cur_val == idx)
  5406. return 0;
  5407. for (i = 0; i < imux->num_items; i++) {
  5408. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5409. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5410. imux->items[i].index,
  5411. HDA_AMP_MUTE, v);
  5412. }
  5413. *cur_val = idx;
  5414. return 1;
  5415. }
  5416. /*
  5417. * 2ch mode
  5418. */
  5419. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5420. { 2, NULL }
  5421. };
  5422. /*
  5423. * 2ch mode
  5424. */
  5425. static struct hda_verb alc883_3ST_ch2_init[] = {
  5426. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5427. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5428. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5429. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5430. { } /* end */
  5431. };
  5432. /*
  5433. * 6ch mode
  5434. */
  5435. static struct hda_verb alc883_3ST_ch6_init[] = {
  5436. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5437. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5438. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5439. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5440. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5441. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5442. { } /* end */
  5443. };
  5444. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5445. { 2, alc883_3ST_ch2_init },
  5446. { 6, alc883_3ST_ch6_init },
  5447. };
  5448. /*
  5449. * 6ch mode
  5450. */
  5451. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5452. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5453. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5454. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5455. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5456. { } /* end */
  5457. };
  5458. /*
  5459. * 8ch mode
  5460. */
  5461. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5462. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5463. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5464. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5465. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5466. { } /* end */
  5467. };
  5468. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5469. { 6, alc883_sixstack_ch6_init },
  5470. { 8, alc883_sixstack_ch8_init },
  5471. };
  5472. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5473. /* eanable EAPD on medion laptop */
  5474. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5475. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5476. { }
  5477. };
  5478. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5479. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5480. */
  5481. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5482. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5483. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5484. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5485. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5486. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5487. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5488. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5489. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5490. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5491. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5492. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5493. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5494. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5495. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5496. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5497. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5498. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5499. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5500. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5501. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5502. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5503. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5504. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5505. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5506. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5507. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5508. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5509. {
  5510. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5511. /* .name = "Capture Source", */
  5512. .name = "Input Source",
  5513. .count = 2,
  5514. .info = alc883_mux_enum_info,
  5515. .get = alc883_mux_enum_get,
  5516. .put = alc883_mux_enum_put,
  5517. },
  5518. { } /* end */
  5519. };
  5520. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5521. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5522. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5523. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5524. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5525. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5526. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5527. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5528. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5529. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5530. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5531. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5532. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5533. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5534. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5535. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5536. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5537. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5538. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5539. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5540. {
  5541. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5542. /* .name = "Capture Source", */
  5543. .name = "Input Source",
  5544. .count = 2,
  5545. .info = alc883_mux_enum_info,
  5546. .get = alc883_mux_enum_get,
  5547. .put = alc883_mux_enum_put,
  5548. },
  5549. { } /* end */
  5550. };
  5551. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5552. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5553. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5554. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5555. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5556. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5557. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5558. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5559. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5560. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5561. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5562. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5563. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5564. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5565. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5566. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5567. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5568. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5569. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5570. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5571. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5572. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5573. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5574. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5575. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5576. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5577. {
  5578. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5579. /* .name = "Capture Source", */
  5580. .name = "Input Source",
  5581. .count = 2,
  5582. .info = alc883_mux_enum_info,
  5583. .get = alc883_mux_enum_get,
  5584. .put = alc883_mux_enum_put,
  5585. },
  5586. { } /* end */
  5587. };
  5588. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5589. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5590. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5591. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5592. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5593. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5594. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5595. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5596. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5597. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5598. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5599. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5600. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5601. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5602. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5603. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5604. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5605. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5606. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5607. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5608. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5609. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5610. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5611. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5612. {
  5613. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5614. /* .name = "Capture Source", */
  5615. .name = "Input Source",
  5616. .count = 1,
  5617. .info = alc883_mux_enum_info,
  5618. .get = alc883_mux_enum_get,
  5619. .put = alc883_mux_enum_put,
  5620. },
  5621. { } /* end */
  5622. };
  5623. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5624. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5625. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5626. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5627. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5628. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5629. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5630. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5631. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5632. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5633. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5634. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5635. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5636. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5637. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5638. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5639. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5640. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5641. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5642. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5643. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5644. {
  5645. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5646. /* .name = "Capture Source", */
  5647. .name = "Input Source",
  5648. .count = 2,
  5649. .info = alc883_mux_enum_info,
  5650. .get = alc883_mux_enum_get,
  5651. .put = alc883_mux_enum_put,
  5652. },
  5653. { } /* end */
  5654. };
  5655. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5656. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5657. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5658. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5659. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5660. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5661. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5662. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5663. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5664. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5665. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5666. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5667. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5668. {
  5669. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5670. /* .name = "Capture Source", */
  5671. .name = "Input Source",
  5672. .count = 2,
  5673. .info = alc883_mux_enum_info,
  5674. .get = alc883_mux_enum_get,
  5675. .put = alc883_mux_enum_put,
  5676. },
  5677. { } /* end */
  5678. };
  5679. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5680. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5681. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5682. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5683. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5684. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5685. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5686. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5687. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5688. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5689. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5690. {
  5691. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5692. /* .name = "Capture Source", */
  5693. .name = "Input Source",
  5694. .count = 1,
  5695. .info = alc883_mux_enum_info,
  5696. .get = alc883_mux_enum_get,
  5697. .put = alc883_mux_enum_put,
  5698. },
  5699. { } /* end */
  5700. };
  5701. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5702. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5703. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5704. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5705. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5706. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5707. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5708. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5709. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5710. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5711. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5712. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5713. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5714. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5715. {
  5716. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5717. /* .name = "Capture Source", */
  5718. .name = "Input Source",
  5719. .count = 2,
  5720. .info = alc883_mux_enum_info,
  5721. .get = alc883_mux_enum_get,
  5722. .put = alc883_mux_enum_put,
  5723. },
  5724. { } /* end */
  5725. };
  5726. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5727. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5728. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5729. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5730. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5731. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5732. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5733. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5734. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5735. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5736. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5737. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5738. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5739. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5740. {
  5741. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5742. /* .name = "Capture Source", */
  5743. .name = "Input Source",
  5744. .count = 2,
  5745. .info = alc883_mux_enum_info,
  5746. .get = alc883_mux_enum_get,
  5747. .put = alc883_mux_enum_put,
  5748. },
  5749. { } /* end */
  5750. };
  5751. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5752. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5753. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5754. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5755. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5756. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5757. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5758. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5759. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5760. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5761. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5762. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5763. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5764. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5765. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5766. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5767. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5768. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5769. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5770. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5771. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5772. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5773. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5774. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5775. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5776. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5777. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5778. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5779. {
  5780. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5781. /* .name = "Capture Source", */
  5782. .name = "Input Source",
  5783. .count = 2,
  5784. .info = alc883_mux_enum_info,
  5785. .get = alc883_mux_enum_get,
  5786. .put = alc883_mux_enum_put,
  5787. },
  5788. { } /* end */
  5789. };
  5790. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  5791. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5792. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5793. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5794. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5795. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5796. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5797. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5798. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5799. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5800. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5801. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5802. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5803. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5804. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5805. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5806. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5807. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5808. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5809. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5810. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5811. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5812. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5813. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5814. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5815. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5816. {
  5817. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5818. /* .name = "Capture Source", */
  5819. .name = "Input Source",
  5820. .count = 2,
  5821. .info = alc883_mux_enum_info,
  5822. .get = alc883_mux_enum_get,
  5823. .put = alc883_mux_enum_put,
  5824. },
  5825. { } /* end */
  5826. };
  5827. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  5828. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5829. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5830. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5831. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5832. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5833. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5834. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5835. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5836. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5837. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5838. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5839. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5840. {
  5841. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5842. /* .name = "Capture Source", */
  5843. .name = "Input Source",
  5844. .count = 2,
  5845. .info = alc883_mux_enum_info,
  5846. .get = alc883_mux_enum_get,
  5847. .put = alc883_mux_enum_put,
  5848. },
  5849. { } /* end */
  5850. };
  5851. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5852. {
  5853. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5854. .name = "Channel Mode",
  5855. .info = alc_ch_mode_info,
  5856. .get = alc_ch_mode_get,
  5857. .put = alc_ch_mode_put,
  5858. },
  5859. { } /* end */
  5860. };
  5861. static struct hda_verb alc883_init_verbs[] = {
  5862. /* ADC1: mute amp left and right */
  5863. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5864. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5865. /* ADC2: mute amp left and right */
  5866. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5867. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5868. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5869. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5870. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5871. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5872. /* Rear mixer */
  5873. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5874. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5875. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5876. /* CLFE mixer */
  5877. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5878. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5879. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5880. /* Side mixer */
  5881. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5882. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5883. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5884. /* mute analog input loopbacks */
  5885. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5886. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5887. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5888. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5889. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5890. /* Front Pin: output 0 (0x0c) */
  5891. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5892. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5893. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5894. /* Rear Pin: output 1 (0x0d) */
  5895. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5896. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5897. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5898. /* CLFE Pin: output 2 (0x0e) */
  5899. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5900. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5901. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5902. /* Side Pin: output 3 (0x0f) */
  5903. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5904. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5905. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5906. /* Mic (rear) pin: input vref at 80% */
  5907. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5908. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5909. /* Front Mic pin: input vref at 80% */
  5910. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5911. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5912. /* Line In pin: input */
  5913. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5914. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5915. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5916. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5917. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5918. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5919. /* CD pin widget for input */
  5920. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5921. /* FIXME: use matrix-type input source selection */
  5922. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5923. /* Input mixer2 */
  5924. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5925. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5926. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5927. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5928. /* Input mixer3 */
  5929. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5930. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5931. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5932. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5933. { }
  5934. };
  5935. static struct hda_verb alc883_tagra_verbs[] = {
  5936. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5937. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5938. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5939. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5940. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5941. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5942. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5943. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5944. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5945. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5946. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5947. { } /* end */
  5948. };
  5949. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5950. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5951. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5952. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5953. { } /* end */
  5954. };
  5955. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5956. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5957. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5958. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5959. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5960. { } /* end */
  5961. };
  5962. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5963. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5964. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5965. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5966. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5967. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5968. { } /* end */
  5969. };
  5970. static struct hda_verb alc883_haier_w66_verbs[] = {
  5971. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5972. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5973. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5974. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5975. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5976. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5977. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5978. { } /* end */
  5979. };
  5980. static struct hda_verb alc888_6st_hp_verbs[] = {
  5981. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5982. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  5983. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  5984. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  5985. { }
  5986. };
  5987. static struct hda_verb alc888_3st_hp_verbs[] = {
  5988. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5989. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  5990. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  5991. { }
  5992. };
  5993. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  5994. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5995. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5996. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5997. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5998. { }
  5999. };
  6000. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  6001. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6002. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6003. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6004. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6005. { }
  6006. };
  6007. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  6008. { 2, alc888_3st_hp_2ch_init },
  6009. { 6, alc888_3st_hp_6ch_init },
  6010. };
  6011. /* toggle front-jack and RCA according to the hp-jack state */
  6012. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6013. {
  6014. unsigned int present;
  6015. present = snd_hda_codec_read(codec, 0x1b, 0,
  6016. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6017. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6018. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6019. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6020. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6021. }
  6022. /* toggle RCA according to the front-jack state */
  6023. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6024. {
  6025. unsigned int present;
  6026. present = snd_hda_codec_read(codec, 0x14, 0,
  6027. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6028. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6029. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6030. }
  6031. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6032. unsigned int res)
  6033. {
  6034. if ((res >> 26) == ALC880_HP_EVENT)
  6035. alc888_lenovo_ms7195_front_automute(codec);
  6036. if ((res >> 26) == ALC880_FRONT_EVENT)
  6037. alc888_lenovo_ms7195_rca_automute(codec);
  6038. }
  6039. static struct hda_verb alc883_medion_md2_verbs[] = {
  6040. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6041. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6042. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6043. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6044. { } /* end */
  6045. };
  6046. /* toggle speaker-output according to the hp-jack state */
  6047. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6048. {
  6049. unsigned int present;
  6050. present = snd_hda_codec_read(codec, 0x14, 0,
  6051. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6052. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6053. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6054. }
  6055. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6056. unsigned int res)
  6057. {
  6058. if ((res >> 26) == ALC880_HP_EVENT)
  6059. alc883_medion_md2_automute(codec);
  6060. }
  6061. /* toggle speaker-output according to the hp-jack state */
  6062. static void alc883_tagra_automute(struct hda_codec *codec)
  6063. {
  6064. unsigned int present;
  6065. unsigned char bits;
  6066. present = snd_hda_codec_read(codec, 0x14, 0,
  6067. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6068. bits = present ? HDA_AMP_MUTE : 0;
  6069. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6070. HDA_AMP_MUTE, bits);
  6071. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6072. present ? 1 : 3);
  6073. }
  6074. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6075. {
  6076. if ((res >> 26) == ALC880_HP_EVENT)
  6077. alc883_tagra_automute(codec);
  6078. }
  6079. static void alc883_haier_w66_automute(struct hda_codec *codec)
  6080. {
  6081. unsigned int present;
  6082. unsigned char bits;
  6083. present = snd_hda_codec_read(codec, 0x1b, 0,
  6084. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6085. bits = present ? 0x80 : 0;
  6086. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6087. 0x80, bits);
  6088. }
  6089. static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
  6090. unsigned int res)
  6091. {
  6092. if ((res >> 26) == ALC880_HP_EVENT)
  6093. alc883_haier_w66_automute(codec);
  6094. }
  6095. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6096. {
  6097. unsigned int present;
  6098. unsigned char bits;
  6099. present = snd_hda_codec_read(codec, 0x14, 0,
  6100. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6101. bits = present ? HDA_AMP_MUTE : 0;
  6102. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6103. HDA_AMP_MUTE, bits);
  6104. }
  6105. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6106. {
  6107. unsigned int present;
  6108. unsigned char bits;
  6109. present = snd_hda_codec_read(codec, 0x1b, 0,
  6110. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6111. bits = present ? HDA_AMP_MUTE : 0;
  6112. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6113. HDA_AMP_MUTE, bits);
  6114. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6115. HDA_AMP_MUTE, bits);
  6116. }
  6117. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6118. unsigned int res)
  6119. {
  6120. if ((res >> 26) == ALC880_HP_EVENT)
  6121. alc883_lenovo_101e_all_automute(codec);
  6122. if ((res >> 26) == ALC880_FRONT_EVENT)
  6123. alc883_lenovo_101e_ispeaker_automute(codec);
  6124. }
  6125. /* toggle speaker-output according to the hp-jack state */
  6126. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6127. {
  6128. unsigned int present;
  6129. present = snd_hda_codec_read(codec, 0x14, 0,
  6130. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6131. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6132. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6133. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6134. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6135. }
  6136. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6137. unsigned int res)
  6138. {
  6139. if ((res >> 26) == ALC880_HP_EVENT)
  6140. alc883_acer_aspire_automute(codec);
  6141. }
  6142. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6143. /* HP Pin: output 0 (0x0c) */
  6144. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6145. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6146. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6147. /* Front Pin: output 0 (0x0c) */
  6148. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6149. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6150. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6151. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6152. /* eanable EAPD on medion laptop */
  6153. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6154. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6155. /* enable unsolicited event */
  6156. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6157. { }
  6158. };
  6159. /*
  6160. * generic initialization of ADC, input mixers and output mixers
  6161. */
  6162. static struct hda_verb alc883_auto_init_verbs[] = {
  6163. /*
  6164. * Unmute ADC0-2 and set the default input to mic-in
  6165. */
  6166. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6167. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6168. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6169. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6170. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6171. * mixer widget
  6172. * Note: PASD motherboards uses the Line In 2 as the input for
  6173. * front panel mic (mic 2)
  6174. */
  6175. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6179. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6180. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6181. /*
  6182. * Set up output mixers (0x0c - 0x0f)
  6183. */
  6184. /* set vol=0 to output mixers */
  6185. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6186. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6187. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6188. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6189. /* set up input amps for analog loopback */
  6190. /* Amp Indices: DAC = 0, mixer = 1 */
  6191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6192. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6194. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6196. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6197. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6198. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6199. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6200. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6201. /* FIXME: use matrix-type input source selection */
  6202. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6203. /* Input mixer1 */
  6204. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6205. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6206. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6207. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6208. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6209. /* Input mixer2 */
  6210. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6211. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6212. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6213. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6214. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6215. { }
  6216. };
  6217. /* capture mixer elements */
  6218. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6219. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6220. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6221. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6222. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6223. {
  6224. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6225. /* The multiple "Capture Source" controls confuse alsamixer
  6226. * So call somewhat different..
  6227. * FIXME: the controls appear in the "playback" view!
  6228. */
  6229. /* .name = "Capture Source", */
  6230. .name = "Input Source",
  6231. .count = 2,
  6232. .info = alc882_mux_enum_info,
  6233. .get = alc882_mux_enum_get,
  6234. .put = alc882_mux_enum_put,
  6235. },
  6236. { } /* end */
  6237. };
  6238. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6239. #define alc883_loopbacks alc880_loopbacks
  6240. #endif
  6241. /* pcm configuration: identiacal with ALC880 */
  6242. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6243. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6244. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6245. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6246. /*
  6247. * configuration and preset
  6248. */
  6249. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6250. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6251. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6252. [ALC883_3ST_6ch] = "3stack-6ch",
  6253. [ALC883_6ST_DIG] = "6stack-dig",
  6254. [ALC883_TARGA_DIG] = "targa-dig",
  6255. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6256. [ALC883_ACER] = "acer",
  6257. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6258. [ALC883_MEDION] = "medion",
  6259. [ALC883_MEDION_MD2] = "medion-md2",
  6260. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6261. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6262. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6263. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6264. [ALC883_HAIER_W66] = "haier-w66",
  6265. [ALC888_6ST_HP] = "6stack-hp",
  6266. [ALC888_3ST_HP] = "3stack-hp",
  6267. [ALC883_AUTO] = "auto",
  6268. };
  6269. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6270. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6271. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6272. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6273. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6274. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6275. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6276. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6277. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6278. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6279. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6280. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6281. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6282. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6283. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6284. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6285. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6286. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6287. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6288. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6289. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6290. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6291. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6292. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6293. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6294. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6295. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6296. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6297. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6298. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6299. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6300. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6301. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6302. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6303. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6304. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6305. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6306. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6307. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6308. SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
  6309. SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6310. {}
  6311. };
  6312. static struct alc_config_preset alc883_presets[] = {
  6313. [ALC883_3ST_2ch_DIG] = {
  6314. .mixers = { alc883_3ST_2ch_mixer },
  6315. .init_verbs = { alc883_init_verbs },
  6316. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6317. .dac_nids = alc883_dac_nids,
  6318. .dig_out_nid = ALC883_DIGOUT_NID,
  6319. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6320. .adc_nids = alc883_adc_nids,
  6321. .dig_in_nid = ALC883_DIGIN_NID,
  6322. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6323. .channel_mode = alc883_3ST_2ch_modes,
  6324. .input_mux = &alc883_capture_source,
  6325. },
  6326. [ALC883_3ST_6ch_DIG] = {
  6327. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6328. .init_verbs = { alc883_init_verbs },
  6329. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6330. .dac_nids = alc883_dac_nids,
  6331. .dig_out_nid = ALC883_DIGOUT_NID,
  6332. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6333. .adc_nids = alc883_adc_nids,
  6334. .dig_in_nid = ALC883_DIGIN_NID,
  6335. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6336. .channel_mode = alc883_3ST_6ch_modes,
  6337. .need_dac_fix = 1,
  6338. .input_mux = &alc883_capture_source,
  6339. },
  6340. [ALC883_3ST_6ch] = {
  6341. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6342. .init_verbs = { alc883_init_verbs },
  6343. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6344. .dac_nids = alc883_dac_nids,
  6345. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6346. .adc_nids = alc883_adc_nids,
  6347. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6348. .channel_mode = alc883_3ST_6ch_modes,
  6349. .need_dac_fix = 1,
  6350. .input_mux = &alc883_capture_source,
  6351. },
  6352. [ALC883_6ST_DIG] = {
  6353. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6354. .init_verbs = { alc883_init_verbs },
  6355. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6356. .dac_nids = alc883_dac_nids,
  6357. .dig_out_nid = ALC883_DIGOUT_NID,
  6358. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6359. .adc_nids = alc883_adc_nids,
  6360. .dig_in_nid = ALC883_DIGIN_NID,
  6361. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6362. .channel_mode = alc883_sixstack_modes,
  6363. .input_mux = &alc883_capture_source,
  6364. },
  6365. [ALC883_TARGA_DIG] = {
  6366. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6367. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6368. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6369. .dac_nids = alc883_dac_nids,
  6370. .dig_out_nid = ALC883_DIGOUT_NID,
  6371. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6372. .adc_nids = alc883_adc_nids,
  6373. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6374. .channel_mode = alc883_3ST_6ch_modes,
  6375. .need_dac_fix = 1,
  6376. .input_mux = &alc883_capture_source,
  6377. .unsol_event = alc883_tagra_unsol_event,
  6378. .init_hook = alc883_tagra_automute,
  6379. },
  6380. [ALC883_TARGA_2ch_DIG] = {
  6381. .mixers = { alc883_tagra_2ch_mixer},
  6382. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6383. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6384. .dac_nids = alc883_dac_nids,
  6385. .dig_out_nid = ALC883_DIGOUT_NID,
  6386. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6387. .adc_nids = alc883_adc_nids,
  6388. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6389. .channel_mode = alc883_3ST_2ch_modes,
  6390. .input_mux = &alc883_capture_source,
  6391. .unsol_event = alc883_tagra_unsol_event,
  6392. .init_hook = alc883_tagra_automute,
  6393. },
  6394. [ALC883_ACER] = {
  6395. .mixers = { alc883_base_mixer },
  6396. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6397. * and the headphone jack. Turn this on and rely on the
  6398. * standard mute methods whenever the user wants to turn
  6399. * these outputs off.
  6400. */
  6401. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6402. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6403. .dac_nids = alc883_dac_nids,
  6404. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6405. .adc_nids = alc883_adc_nids,
  6406. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6407. .channel_mode = alc883_3ST_2ch_modes,
  6408. .input_mux = &alc883_capture_source,
  6409. },
  6410. [ALC883_ACER_ASPIRE] = {
  6411. .mixers = { alc883_acer_aspire_mixer },
  6412. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6413. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6414. .dac_nids = alc883_dac_nids,
  6415. .dig_out_nid = ALC883_DIGOUT_NID,
  6416. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6417. .adc_nids = alc883_adc_nids,
  6418. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6419. .channel_mode = alc883_3ST_2ch_modes,
  6420. .input_mux = &alc883_capture_source,
  6421. .unsol_event = alc883_acer_aspire_unsol_event,
  6422. .init_hook = alc883_acer_aspire_automute,
  6423. },
  6424. [ALC883_MEDION] = {
  6425. .mixers = { alc883_fivestack_mixer,
  6426. alc883_chmode_mixer },
  6427. .init_verbs = { alc883_init_verbs,
  6428. alc883_medion_eapd_verbs },
  6429. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6430. .dac_nids = alc883_dac_nids,
  6431. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6432. .adc_nids = alc883_adc_nids,
  6433. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6434. .channel_mode = alc883_sixstack_modes,
  6435. .input_mux = &alc883_capture_source,
  6436. },
  6437. [ALC883_MEDION_MD2] = {
  6438. .mixers = { alc883_medion_md2_mixer},
  6439. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6440. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6441. .dac_nids = alc883_dac_nids,
  6442. .dig_out_nid = ALC883_DIGOUT_NID,
  6443. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6444. .adc_nids = alc883_adc_nids,
  6445. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6446. .channel_mode = alc883_3ST_2ch_modes,
  6447. .input_mux = &alc883_capture_source,
  6448. .unsol_event = alc883_medion_md2_unsol_event,
  6449. .init_hook = alc883_medion_md2_automute,
  6450. },
  6451. [ALC883_LAPTOP_EAPD] = {
  6452. .mixers = { alc883_base_mixer },
  6453. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6454. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6455. .dac_nids = alc883_dac_nids,
  6456. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6457. .adc_nids = alc883_adc_nids,
  6458. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6459. .channel_mode = alc883_3ST_2ch_modes,
  6460. .input_mux = &alc883_capture_source,
  6461. },
  6462. [ALC883_LENOVO_101E_2ch] = {
  6463. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6464. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6465. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6466. .dac_nids = alc883_dac_nids,
  6467. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6468. .adc_nids = alc883_adc_nids,
  6469. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6470. .channel_mode = alc883_3ST_2ch_modes,
  6471. .input_mux = &alc883_lenovo_101e_capture_source,
  6472. .unsol_event = alc883_lenovo_101e_unsol_event,
  6473. .init_hook = alc883_lenovo_101e_all_automute,
  6474. },
  6475. [ALC883_LENOVO_NB0763] = {
  6476. .mixers = { alc883_lenovo_nb0763_mixer },
  6477. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6478. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6479. .dac_nids = alc883_dac_nids,
  6480. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6481. .adc_nids = alc883_adc_nids,
  6482. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6483. .channel_mode = alc883_3ST_2ch_modes,
  6484. .need_dac_fix = 1,
  6485. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6486. .unsol_event = alc883_medion_md2_unsol_event,
  6487. .init_hook = alc883_medion_md2_automute,
  6488. },
  6489. [ALC888_LENOVO_MS7195_DIG] = {
  6490. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6491. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6492. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6493. .dac_nids = alc883_dac_nids,
  6494. .dig_out_nid = ALC883_DIGOUT_NID,
  6495. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6496. .adc_nids = alc883_adc_nids,
  6497. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6498. .channel_mode = alc883_3ST_6ch_modes,
  6499. .need_dac_fix = 1,
  6500. .input_mux = &alc883_capture_source,
  6501. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6502. .init_hook = alc888_lenovo_ms7195_front_automute,
  6503. },
  6504. [ALC883_HAIER_W66] = {
  6505. .mixers = { alc883_tagra_2ch_mixer},
  6506. .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
  6507. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6508. .dac_nids = alc883_dac_nids,
  6509. .dig_out_nid = ALC883_DIGOUT_NID,
  6510. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6511. .adc_nids = alc883_adc_nids,
  6512. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6513. .channel_mode = alc883_3ST_2ch_modes,
  6514. .input_mux = &alc883_capture_source,
  6515. .unsol_event = alc883_haier_w66_unsol_event,
  6516. .init_hook = alc883_haier_w66_automute,
  6517. },
  6518. [ALC888_6ST_HP] = {
  6519. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6520. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6521. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6522. .dac_nids = alc883_dac_nids,
  6523. .dig_out_nid = ALC883_DIGOUT_NID,
  6524. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6525. .adc_nids = alc883_adc_nids,
  6526. .dig_in_nid = ALC883_DIGIN_NID,
  6527. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6528. .channel_mode = alc883_sixstack_modes,
  6529. .input_mux = &alc883_capture_source,
  6530. },
  6531. [ALC888_3ST_HP] = {
  6532. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6533. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6534. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6535. .dac_nids = alc883_dac_nids,
  6536. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6537. .adc_nids = alc883_adc_nids,
  6538. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6539. .channel_mode = alc888_3st_hp_modes,
  6540. .need_dac_fix = 1,
  6541. .input_mux = &alc883_capture_source,
  6542. },
  6543. };
  6544. /*
  6545. * BIOS auto configuration
  6546. */
  6547. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6548. hda_nid_t nid, int pin_type,
  6549. int dac_idx)
  6550. {
  6551. /* set as output */
  6552. struct alc_spec *spec = codec->spec;
  6553. int idx;
  6554. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6555. idx = 4;
  6556. else
  6557. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6558. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6559. pin_type);
  6560. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6561. AMP_OUT_UNMUTE);
  6562. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6563. }
  6564. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6565. {
  6566. struct alc_spec *spec = codec->spec;
  6567. int i;
  6568. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6569. for (i = 0; i <= HDA_SIDE; i++) {
  6570. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6571. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6572. if (nid)
  6573. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6574. i);
  6575. }
  6576. }
  6577. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6578. {
  6579. struct alc_spec *spec = codec->spec;
  6580. hda_nid_t pin;
  6581. pin = spec->autocfg.hp_pins[0];
  6582. if (pin) /* connect to front */
  6583. /* use dac 0 */
  6584. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6585. }
  6586. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6587. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6588. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6589. {
  6590. struct alc_spec *spec = codec->spec;
  6591. int i;
  6592. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6593. hda_nid_t nid = spec->autocfg.input_pins[i];
  6594. if (alc883_is_input_pin(nid)) {
  6595. snd_hda_codec_write(codec, nid, 0,
  6596. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6597. (i <= AUTO_PIN_FRONT_MIC ?
  6598. PIN_VREF80 : PIN_IN));
  6599. if (nid != ALC883_PIN_CD_NID)
  6600. snd_hda_codec_write(codec, nid, 0,
  6601. AC_VERB_SET_AMP_GAIN_MUTE,
  6602. AMP_OUT_MUTE);
  6603. }
  6604. }
  6605. }
  6606. /* almost identical with ALC880 parser... */
  6607. static int alc883_parse_auto_config(struct hda_codec *codec)
  6608. {
  6609. struct alc_spec *spec = codec->spec;
  6610. int err = alc880_parse_auto_config(codec);
  6611. if (err < 0)
  6612. return err;
  6613. else if (err > 0)
  6614. /* hack - override the init verbs */
  6615. spec->init_verbs[0] = alc883_auto_init_verbs;
  6616. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6617. spec->num_mixers++;
  6618. return err;
  6619. }
  6620. /* additional initialization for auto-configuration model */
  6621. static void alc883_auto_init(struct hda_codec *codec)
  6622. {
  6623. alc883_auto_init_multi_out(codec);
  6624. alc883_auto_init_hp_out(codec);
  6625. alc883_auto_init_analog_input(codec);
  6626. }
  6627. static int patch_alc883(struct hda_codec *codec)
  6628. {
  6629. struct alc_spec *spec;
  6630. int err, board_config;
  6631. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6632. if (spec == NULL)
  6633. return -ENOMEM;
  6634. codec->spec = spec;
  6635. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6636. alc883_models,
  6637. alc883_cfg_tbl);
  6638. if (board_config < 0) {
  6639. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6640. "trying auto-probe from BIOS...\n");
  6641. board_config = ALC883_AUTO;
  6642. }
  6643. if (board_config == ALC883_AUTO) {
  6644. /* automatic parse from the BIOS config */
  6645. err = alc883_parse_auto_config(codec);
  6646. if (err < 0) {
  6647. alc_free(codec);
  6648. return err;
  6649. } else if (!err) {
  6650. printk(KERN_INFO
  6651. "hda_codec: Cannot set up configuration "
  6652. "from BIOS. Using base mode...\n");
  6653. board_config = ALC883_3ST_2ch_DIG;
  6654. }
  6655. }
  6656. if (board_config != ALC883_AUTO)
  6657. setup_preset(spec, &alc883_presets[board_config]);
  6658. spec->stream_name_analog = "ALC883 Analog";
  6659. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6660. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6661. spec->stream_name_digital = "ALC883 Digital";
  6662. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6663. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6664. if (!spec->adc_nids && spec->input_mux) {
  6665. spec->adc_nids = alc883_adc_nids;
  6666. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6667. }
  6668. codec->patch_ops = alc_patch_ops;
  6669. if (board_config == ALC883_AUTO)
  6670. spec->init_hook = alc883_auto_init;
  6671. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6672. if (!spec->loopback.amplist)
  6673. spec->loopback.amplist = alc883_loopbacks;
  6674. #endif
  6675. return 0;
  6676. }
  6677. /*
  6678. * ALC262 support
  6679. */
  6680. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6681. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6682. #define alc262_dac_nids alc260_dac_nids
  6683. #define alc262_adc_nids alc882_adc_nids
  6684. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6685. #define alc262_modes alc260_modes
  6686. #define alc262_capture_source alc882_capture_source
  6687. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6688. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6689. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6690. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6691. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6692. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6693. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6694. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6695. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6696. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6697. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6698. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6699. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6700. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6701. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6702. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6703. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6704. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6705. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6706. { } /* end */
  6707. };
  6708. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6709. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6710. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6711. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6712. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6713. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6714. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6715. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6716. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6717. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6718. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6719. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6720. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6721. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6722. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6723. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6724. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6725. { } /* end */
  6726. };
  6727. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6728. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6729. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6730. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6731. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6732. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6733. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6734. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6735. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6736. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6737. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6738. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6739. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6740. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6741. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6742. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6743. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6744. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6745. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6746. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6747. { } /* end */
  6748. };
  6749. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6750. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6751. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6752. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6753. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6754. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6755. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6756. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6757. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6758. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6759. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6760. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6761. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6762. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6763. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6764. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6765. { } /* end */
  6766. };
  6767. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6768. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6769. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6770. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6771. { } /* end */
  6772. };
  6773. /* bind hp and internal speaker mute (with plug check) */
  6774. static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
  6775. struct snd_ctl_elem_value *ucontrol)
  6776. {
  6777. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6778. long *valp = ucontrol->value.integer.value;
  6779. int change;
  6780. /* change hp mute */
  6781. change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6782. HDA_AMP_MUTE,
  6783. valp[0] ? 0 : HDA_AMP_MUTE);
  6784. change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6785. HDA_AMP_MUTE,
  6786. valp[1] ? 0 : HDA_AMP_MUTE);
  6787. if (change) {
  6788. /* change speaker according to HP jack state */
  6789. struct alc_spec *spec = codec->spec;
  6790. unsigned int mute;
  6791. if (spec->jack_present)
  6792. mute = HDA_AMP_MUTE;
  6793. else
  6794. mute = snd_hda_codec_amp_read(codec, 0x15, 0,
  6795. HDA_OUTPUT, 0);
  6796. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6797. HDA_AMP_MUTE, mute);
  6798. }
  6799. return change;
  6800. }
  6801. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6802. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6803. {
  6804. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6805. .name = "Master Playback Switch",
  6806. .info = snd_hda_mixer_amp_switch_info,
  6807. .get = snd_hda_mixer_amp_switch_get,
  6808. .put = alc262_sony_master_sw_put,
  6809. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  6810. },
  6811. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6812. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6813. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6814. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6815. { } /* end */
  6816. };
  6817. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6818. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6819. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6820. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6821. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6822. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6823. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6824. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6825. { } /* end */
  6826. };
  6827. #define alc262_capture_mixer alc882_capture_mixer
  6828. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6829. /*
  6830. * generic initialization of ADC, input mixers and output mixers
  6831. */
  6832. static struct hda_verb alc262_init_verbs[] = {
  6833. /*
  6834. * Unmute ADC0-2 and set the default input to mic-in
  6835. */
  6836. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6837. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6838. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6839. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6840. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6841. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6842. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6843. * mixer widget
  6844. * Note: PASD motherboards uses the Line In 2 as the input for
  6845. * front panel mic (mic 2)
  6846. */
  6847. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6848. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6849. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6850. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6851. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6852. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6853. /*
  6854. * Set up output mixers (0x0c - 0x0e)
  6855. */
  6856. /* set vol=0 to output mixers */
  6857. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6858. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6859. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6860. /* set up input amps for analog loopback */
  6861. /* Amp Indices: DAC = 0, mixer = 1 */
  6862. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6863. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6864. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6865. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6866. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6867. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6868. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6869. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6870. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6871. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6872. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6873. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6874. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6875. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6876. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6877. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6878. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6879. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6880. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6881. /* FIXME: use matrix-type input source selection */
  6882. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6883. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6884. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6885. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6886. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6887. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6888. /* Input mixer2 */
  6889. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6890. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6891. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6892. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6893. /* Input mixer3 */
  6894. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6895. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6896. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6897. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6898. { }
  6899. };
  6900. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6901. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6902. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6903. {}
  6904. };
  6905. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6906. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6907. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6908. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6909. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6910. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6911. {}
  6912. };
  6913. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6914. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6915. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6916. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6917. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6918. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6919. };
  6920. /* mute/unmute internal speaker according to the hp jack and mute state */
  6921. static void alc262_hippo_automute(struct hda_codec *codec)
  6922. {
  6923. struct alc_spec *spec = codec->spec;
  6924. unsigned int mute;
  6925. unsigned int present;
  6926. /* need to execute and sync at first */
  6927. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6928. present = snd_hda_codec_read(codec, 0x15, 0,
  6929. AC_VERB_GET_PIN_SENSE, 0);
  6930. spec->jack_present = (present & 0x80000000) != 0;
  6931. if (spec->jack_present) {
  6932. /* mute internal speaker */
  6933. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6934. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6935. } else {
  6936. /* unmute internal speaker if necessary */
  6937. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6938. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6939. HDA_AMP_MUTE, mute);
  6940. }
  6941. }
  6942. /* unsolicited event for HP jack sensing */
  6943. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6944. unsigned int res)
  6945. {
  6946. if ((res >> 26) != ALC880_HP_EVENT)
  6947. return;
  6948. alc262_hippo_automute(codec);
  6949. }
  6950. static void alc262_hippo1_automute(struct hda_codec *codec)
  6951. {
  6952. unsigned int mute;
  6953. unsigned int present;
  6954. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6955. present = snd_hda_codec_read(codec, 0x1b, 0,
  6956. AC_VERB_GET_PIN_SENSE, 0);
  6957. present = (present & 0x80000000) != 0;
  6958. if (present) {
  6959. /* mute internal speaker */
  6960. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6961. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6962. } else {
  6963. /* unmute internal speaker if necessary */
  6964. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6965. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6966. HDA_AMP_MUTE, mute);
  6967. }
  6968. }
  6969. /* unsolicited event for HP jack sensing */
  6970. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6971. unsigned int res)
  6972. {
  6973. if ((res >> 26) != ALC880_HP_EVENT)
  6974. return;
  6975. alc262_hippo1_automute(codec);
  6976. }
  6977. /*
  6978. * fujitsu model
  6979. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6980. */
  6981. #define ALC_HP_EVENT 0x37
  6982. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6983. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6984. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6985. {}
  6986. };
  6987. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6988. .num_items = 2,
  6989. .items = {
  6990. { "Mic", 0x0 },
  6991. { "CD", 0x4 },
  6992. },
  6993. };
  6994. static struct hda_input_mux alc262_HP_capture_source = {
  6995. .num_items = 5,
  6996. .items = {
  6997. { "Mic", 0x0 },
  6998. { "Front Mic", 0x3 },
  6999. { "Line", 0x2 },
  7000. { "CD", 0x4 },
  7001. { "AUX IN", 0x6 },
  7002. },
  7003. };
  7004. /* mute/unmute internal speaker according to the hp jack and mute state */
  7005. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  7006. {
  7007. struct alc_spec *spec = codec->spec;
  7008. unsigned int mute;
  7009. if (force || !spec->sense_updated) {
  7010. unsigned int present;
  7011. /* need to execute and sync at first */
  7012. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  7013. present = snd_hda_codec_read(codec, 0x14, 0,
  7014. AC_VERB_GET_PIN_SENSE, 0);
  7015. spec->jack_present = (present & 0x80000000) != 0;
  7016. spec->sense_updated = 1;
  7017. }
  7018. if (spec->jack_present) {
  7019. /* mute internal speaker */
  7020. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7021. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7022. } else {
  7023. /* unmute internal speaker if necessary */
  7024. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7025. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7026. HDA_AMP_MUTE, mute);
  7027. }
  7028. }
  7029. /* unsolicited event for HP jack sensing */
  7030. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  7031. unsigned int res)
  7032. {
  7033. if ((res >> 26) != ALC_HP_EVENT)
  7034. return;
  7035. alc262_fujitsu_automute(codec, 1);
  7036. }
  7037. /* bind volumes of both NID 0x0c and 0x0d */
  7038. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  7039. .ops = &snd_hda_bind_vol,
  7040. .values = {
  7041. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7042. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7043. 0
  7044. },
  7045. };
  7046. /* bind hp and internal speaker mute (with plug check) */
  7047. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  7048. struct snd_ctl_elem_value *ucontrol)
  7049. {
  7050. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7051. long *valp = ucontrol->value.integer.value;
  7052. int change;
  7053. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7054. HDA_AMP_MUTE,
  7055. valp[0] ? 0 : HDA_AMP_MUTE);
  7056. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7057. HDA_AMP_MUTE,
  7058. valp[1] ? 0 : HDA_AMP_MUTE);
  7059. if (change)
  7060. alc262_fujitsu_automute(codec, 0);
  7061. return change;
  7062. }
  7063. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  7064. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  7065. {
  7066. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7067. .name = "Master Playback Switch",
  7068. .info = snd_hda_mixer_amp_switch_info,
  7069. .get = snd_hda_mixer_amp_switch_get,
  7070. .put = alc262_fujitsu_master_sw_put,
  7071. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7072. },
  7073. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7074. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7075. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7076. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7077. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7078. { } /* end */
  7079. };
  7080. /* additional init verbs for Benq laptops */
  7081. static struct hda_verb alc262_EAPD_verbs[] = {
  7082. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7083. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7084. {}
  7085. };
  7086. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7087. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7088. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7089. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7090. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7091. {}
  7092. };
  7093. /* add playback controls from the parsed DAC table */
  7094. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7095. const struct auto_pin_cfg *cfg)
  7096. {
  7097. hda_nid_t nid;
  7098. int err;
  7099. spec->multiout.num_dacs = 1; /* only use one dac */
  7100. spec->multiout.dac_nids = spec->private_dac_nids;
  7101. spec->multiout.dac_nids[0] = 2;
  7102. nid = cfg->line_out_pins[0];
  7103. if (nid) {
  7104. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7105. "Front Playback Volume",
  7106. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7107. if (err < 0)
  7108. return err;
  7109. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7110. "Front Playback Switch",
  7111. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7112. if (err < 0)
  7113. return err;
  7114. }
  7115. nid = cfg->speaker_pins[0];
  7116. if (nid) {
  7117. if (nid == 0x16) {
  7118. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7119. "Speaker Playback Volume",
  7120. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7121. HDA_OUTPUT));
  7122. if (err < 0)
  7123. return err;
  7124. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7125. "Speaker Playback Switch",
  7126. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7127. HDA_OUTPUT));
  7128. if (err < 0)
  7129. return err;
  7130. } else {
  7131. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7132. "Speaker Playback Switch",
  7133. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7134. HDA_OUTPUT));
  7135. if (err < 0)
  7136. return err;
  7137. }
  7138. }
  7139. nid = cfg->hp_pins[0];
  7140. if (nid) {
  7141. /* spec->multiout.hp_nid = 2; */
  7142. if (nid == 0x16) {
  7143. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7144. "Headphone Playback Volume",
  7145. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7146. HDA_OUTPUT));
  7147. if (err < 0)
  7148. return err;
  7149. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7150. "Headphone Playback Switch",
  7151. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7152. HDA_OUTPUT));
  7153. if (err < 0)
  7154. return err;
  7155. } else {
  7156. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7157. "Headphone Playback Switch",
  7158. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7159. HDA_OUTPUT));
  7160. if (err < 0)
  7161. return err;
  7162. }
  7163. }
  7164. return 0;
  7165. }
  7166. /* identical with ALC880 */
  7167. #define alc262_auto_create_analog_input_ctls \
  7168. alc880_auto_create_analog_input_ctls
  7169. /*
  7170. * generic initialization of ADC, input mixers and output mixers
  7171. */
  7172. static struct hda_verb alc262_volume_init_verbs[] = {
  7173. /*
  7174. * Unmute ADC0-2 and set the default input to mic-in
  7175. */
  7176. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7177. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7178. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7179. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7180. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7181. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7182. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7183. * mixer widget
  7184. * Note: PASD motherboards uses the Line In 2 as the input for
  7185. * front panel mic (mic 2)
  7186. */
  7187. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7188. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7189. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7190. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7191. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7192. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7193. /*
  7194. * Set up output mixers (0x0c - 0x0f)
  7195. */
  7196. /* set vol=0 to output mixers */
  7197. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7198. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7199. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7200. /* set up input amps for analog loopback */
  7201. /* Amp Indices: DAC = 0, mixer = 1 */
  7202. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7203. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7204. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7205. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7206. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7207. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7208. /* FIXME: use matrix-type input source selection */
  7209. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7210. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7211. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7212. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7213. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7214. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7215. /* Input mixer2 */
  7216. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7217. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7218. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7219. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7220. /* Input mixer3 */
  7221. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7222. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7223. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7224. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7225. { }
  7226. };
  7227. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7228. /*
  7229. * Unmute ADC0-2 and set the default input to mic-in
  7230. */
  7231. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7232. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7233. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7234. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7235. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7236. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7237. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7238. * mixer widget
  7239. * Note: PASD motherboards uses the Line In 2 as the input for
  7240. * front panel mic (mic 2)
  7241. */
  7242. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7243. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7244. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7245. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7246. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7247. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7248. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7249. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7250. /*
  7251. * Set up output mixers (0x0c - 0x0e)
  7252. */
  7253. /* set vol=0 to output mixers */
  7254. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7255. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7256. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7257. /* set up input amps for analog loopback */
  7258. /* Amp Indices: DAC = 0, mixer = 1 */
  7259. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7260. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7261. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7262. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7263. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7264. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7265. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7266. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7267. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7268. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7269. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7270. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7271. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7272. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7273. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7274. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7275. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7276. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7277. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7278. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7279. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7280. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7281. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7282. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7283. /* FIXME: use matrix-type input source selection */
  7284. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7285. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7286. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7287. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7288. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7289. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7290. /* Input mixer2 */
  7291. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7292. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7293. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7294. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7295. /* Input mixer3 */
  7296. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7297. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7298. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7299. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7300. { }
  7301. };
  7302. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7303. /*
  7304. * Unmute ADC0-2 and set the default input to mic-in
  7305. */
  7306. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7307. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7308. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7309. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7310. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7311. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7312. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7313. * mixer widget
  7314. * Note: PASD motherboards uses the Line In 2 as the input for front
  7315. * panel mic (mic 2)
  7316. */
  7317. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7318. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7319. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7320. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7321. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7322. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7323. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7324. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7325. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7326. /*
  7327. * Set up output mixers (0x0c - 0x0e)
  7328. */
  7329. /* set vol=0 to output mixers */
  7330. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7331. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7332. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7333. /* set up input amps for analog loopback */
  7334. /* Amp Indices: DAC = 0, mixer = 1 */
  7335. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7336. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7337. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7338. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7339. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7340. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7341. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7342. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7343. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7344. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7345. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7346. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7347. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7348. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7349. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7350. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7351. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7352. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7353. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7354. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7355. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7356. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7357. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7358. /* FIXME: use matrix-type input source selection */
  7359. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7360. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7361. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7362. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7363. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7364. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7365. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7366. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7367. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7368. /* Input mixer2 */
  7369. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7370. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7371. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7372. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7373. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7374. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7375. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7376. /* Input mixer3 */
  7377. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7378. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7379. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7380. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7381. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7382. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7383. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7384. { }
  7385. };
  7386. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7387. #define alc262_loopbacks alc880_loopbacks
  7388. #endif
  7389. /* pcm configuration: identiacal with ALC880 */
  7390. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7391. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7392. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7393. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7394. /*
  7395. * BIOS auto configuration
  7396. */
  7397. static int alc262_parse_auto_config(struct hda_codec *codec)
  7398. {
  7399. struct alc_spec *spec = codec->spec;
  7400. int err;
  7401. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7402. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7403. alc262_ignore);
  7404. if (err < 0)
  7405. return err;
  7406. if (!spec->autocfg.line_outs)
  7407. return 0; /* can't find valid BIOS pin config */
  7408. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7409. if (err < 0)
  7410. return err;
  7411. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7412. if (err < 0)
  7413. return err;
  7414. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7415. if (spec->autocfg.dig_out_pin)
  7416. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7417. if (spec->autocfg.dig_in_pin)
  7418. spec->dig_in_nid = ALC262_DIGIN_NID;
  7419. if (spec->kctl_alloc)
  7420. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7421. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7422. spec->num_mux_defs = 1;
  7423. spec->input_mux = &spec->private_imux;
  7424. return 1;
  7425. }
  7426. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7427. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7428. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7429. /* init callback for auto-configuration model -- overriding the default init */
  7430. static void alc262_auto_init(struct hda_codec *codec)
  7431. {
  7432. alc262_auto_init_multi_out(codec);
  7433. alc262_auto_init_hp_out(codec);
  7434. alc262_auto_init_analog_input(codec);
  7435. }
  7436. /*
  7437. * configuration and preset
  7438. */
  7439. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7440. [ALC262_BASIC] = "basic",
  7441. [ALC262_HIPPO] = "hippo",
  7442. [ALC262_HIPPO_1] = "hippo_1",
  7443. [ALC262_FUJITSU] = "fujitsu",
  7444. [ALC262_HP_BPC] = "hp-bpc",
  7445. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7446. [ALC262_BENQ_ED8] = "benq",
  7447. [ALC262_BENQ_T31] = "benq-t31",
  7448. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7449. [ALC262_AUTO] = "auto",
  7450. };
  7451. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7452. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7453. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7454. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7455. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7456. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7457. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7458. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7459. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7460. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7461. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7462. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7463. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7464. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7465. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7466. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7467. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7468. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7469. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7470. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7471. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7472. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7473. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7474. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7475. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7476. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7477. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7478. {}
  7479. };
  7480. static struct alc_config_preset alc262_presets[] = {
  7481. [ALC262_BASIC] = {
  7482. .mixers = { alc262_base_mixer },
  7483. .init_verbs = { alc262_init_verbs },
  7484. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7485. .dac_nids = alc262_dac_nids,
  7486. .hp_nid = 0x03,
  7487. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7488. .channel_mode = alc262_modes,
  7489. .input_mux = &alc262_capture_source,
  7490. },
  7491. [ALC262_HIPPO] = {
  7492. .mixers = { alc262_base_mixer },
  7493. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7494. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7495. .dac_nids = alc262_dac_nids,
  7496. .hp_nid = 0x03,
  7497. .dig_out_nid = ALC262_DIGOUT_NID,
  7498. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7499. .channel_mode = alc262_modes,
  7500. .input_mux = &alc262_capture_source,
  7501. .unsol_event = alc262_hippo_unsol_event,
  7502. .init_hook = alc262_hippo_automute,
  7503. },
  7504. [ALC262_HIPPO_1] = {
  7505. .mixers = { alc262_hippo1_mixer },
  7506. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7507. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7508. .dac_nids = alc262_dac_nids,
  7509. .hp_nid = 0x02,
  7510. .dig_out_nid = ALC262_DIGOUT_NID,
  7511. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7512. .channel_mode = alc262_modes,
  7513. .input_mux = &alc262_capture_source,
  7514. .unsol_event = alc262_hippo1_unsol_event,
  7515. .init_hook = alc262_hippo1_automute,
  7516. },
  7517. [ALC262_FUJITSU] = {
  7518. .mixers = { alc262_fujitsu_mixer },
  7519. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7520. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7521. .dac_nids = alc262_dac_nids,
  7522. .hp_nid = 0x03,
  7523. .dig_out_nid = ALC262_DIGOUT_NID,
  7524. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7525. .channel_mode = alc262_modes,
  7526. .input_mux = &alc262_fujitsu_capture_source,
  7527. .unsol_event = alc262_fujitsu_unsol_event,
  7528. },
  7529. [ALC262_HP_BPC] = {
  7530. .mixers = { alc262_HP_BPC_mixer },
  7531. .init_verbs = { alc262_HP_BPC_init_verbs },
  7532. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7533. .dac_nids = alc262_dac_nids,
  7534. .hp_nid = 0x03,
  7535. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7536. .channel_mode = alc262_modes,
  7537. .input_mux = &alc262_HP_capture_source,
  7538. },
  7539. [ALC262_HP_BPC_D7000_WF] = {
  7540. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7541. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7542. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7543. .dac_nids = alc262_dac_nids,
  7544. .hp_nid = 0x03,
  7545. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7546. .channel_mode = alc262_modes,
  7547. .input_mux = &alc262_HP_capture_source,
  7548. },
  7549. [ALC262_HP_BPC_D7000_WL] = {
  7550. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7551. alc262_HP_BPC_WildWest_option_mixer },
  7552. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7553. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7554. .dac_nids = alc262_dac_nids,
  7555. .hp_nid = 0x03,
  7556. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7557. .channel_mode = alc262_modes,
  7558. .input_mux = &alc262_HP_capture_source,
  7559. },
  7560. [ALC262_BENQ_ED8] = {
  7561. .mixers = { alc262_base_mixer },
  7562. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7563. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7564. .dac_nids = alc262_dac_nids,
  7565. .hp_nid = 0x03,
  7566. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7567. .channel_mode = alc262_modes,
  7568. .input_mux = &alc262_capture_source,
  7569. },
  7570. [ALC262_SONY_ASSAMD] = {
  7571. .mixers = { alc262_sony_mixer },
  7572. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7573. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7574. .dac_nids = alc262_dac_nids,
  7575. .hp_nid = 0x02,
  7576. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7577. .channel_mode = alc262_modes,
  7578. .input_mux = &alc262_capture_source,
  7579. .unsol_event = alc262_hippo_unsol_event,
  7580. .init_hook = alc262_hippo_automute,
  7581. },
  7582. [ALC262_BENQ_T31] = {
  7583. .mixers = { alc262_benq_t31_mixer },
  7584. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7585. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7586. .dac_nids = alc262_dac_nids,
  7587. .hp_nid = 0x03,
  7588. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7589. .channel_mode = alc262_modes,
  7590. .input_mux = &alc262_capture_source,
  7591. .unsol_event = alc262_hippo_unsol_event,
  7592. .init_hook = alc262_hippo_automute,
  7593. },
  7594. };
  7595. static int patch_alc262(struct hda_codec *codec)
  7596. {
  7597. struct alc_spec *spec;
  7598. int board_config;
  7599. int err;
  7600. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7601. if (spec == NULL)
  7602. return -ENOMEM;
  7603. codec->spec = spec;
  7604. #if 0
  7605. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7606. * under-run
  7607. */
  7608. {
  7609. int tmp;
  7610. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7611. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7612. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7613. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7614. }
  7615. #endif
  7616. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7617. alc262_models,
  7618. alc262_cfg_tbl);
  7619. if (board_config < 0) {
  7620. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7621. "trying auto-probe from BIOS...\n");
  7622. board_config = ALC262_AUTO;
  7623. }
  7624. if (board_config == ALC262_AUTO) {
  7625. /* automatic parse from the BIOS config */
  7626. err = alc262_parse_auto_config(codec);
  7627. if (err < 0) {
  7628. alc_free(codec);
  7629. return err;
  7630. } else if (!err) {
  7631. printk(KERN_INFO
  7632. "hda_codec: Cannot set up configuration "
  7633. "from BIOS. Using base mode...\n");
  7634. board_config = ALC262_BASIC;
  7635. }
  7636. }
  7637. if (board_config != ALC262_AUTO)
  7638. setup_preset(spec, &alc262_presets[board_config]);
  7639. spec->stream_name_analog = "ALC262 Analog";
  7640. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7641. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7642. spec->stream_name_digital = "ALC262 Digital";
  7643. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7644. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7645. if (!spec->adc_nids && spec->input_mux) {
  7646. /* check whether NID 0x07 is valid */
  7647. unsigned int wcap = get_wcaps(codec, 0x07);
  7648. /* get type */
  7649. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7650. if (wcap != AC_WID_AUD_IN) {
  7651. spec->adc_nids = alc262_adc_nids_alt;
  7652. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7653. spec->mixers[spec->num_mixers] =
  7654. alc262_capture_alt_mixer;
  7655. spec->num_mixers++;
  7656. } else {
  7657. spec->adc_nids = alc262_adc_nids;
  7658. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7659. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7660. spec->num_mixers++;
  7661. }
  7662. }
  7663. codec->patch_ops = alc_patch_ops;
  7664. if (board_config == ALC262_AUTO)
  7665. spec->init_hook = alc262_auto_init;
  7666. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7667. if (!spec->loopback.amplist)
  7668. spec->loopback.amplist = alc262_loopbacks;
  7669. #endif
  7670. return 0;
  7671. }
  7672. /*
  7673. * ALC268 channel source setting (2 channel)
  7674. */
  7675. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7676. #define alc268_modes alc260_modes
  7677. static hda_nid_t alc268_dac_nids[2] = {
  7678. /* front, hp */
  7679. 0x02, 0x03
  7680. };
  7681. static hda_nid_t alc268_adc_nids[2] = {
  7682. /* ADC0-1 */
  7683. 0x08, 0x07
  7684. };
  7685. static hda_nid_t alc268_adc_nids_alt[1] = {
  7686. /* ADC0 */
  7687. 0x08
  7688. };
  7689. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7690. /* output mixer control */
  7691. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7692. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7693. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7694. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7695. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7696. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7697. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7698. { }
  7699. };
  7700. static struct hda_verb alc268_eapd_verbs[] = {
  7701. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7702. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7703. { }
  7704. };
  7705. /* Toshiba specific */
  7706. #define alc268_toshiba_automute alc262_hippo_automute
  7707. static struct hda_verb alc268_toshiba_verbs[] = {
  7708. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7709. { } /* end */
  7710. };
  7711. /* Acer specific */
  7712. /* bind volumes of both NID 0x02 and 0x03 */
  7713. static struct hda_bind_ctls alc268_acer_bind_master_vol = {
  7714. .ops = &snd_hda_bind_vol,
  7715. .values = {
  7716. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  7717. HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
  7718. 0
  7719. },
  7720. };
  7721. /* mute/unmute internal speaker according to the hp jack and mute state */
  7722. static void alc268_acer_automute(struct hda_codec *codec, int force)
  7723. {
  7724. struct alc_spec *spec = codec->spec;
  7725. unsigned int mute;
  7726. if (force || !spec->sense_updated) {
  7727. unsigned int present;
  7728. present = snd_hda_codec_read(codec, 0x14, 0,
  7729. AC_VERB_GET_PIN_SENSE, 0);
  7730. spec->jack_present = (present & 0x80000000) != 0;
  7731. spec->sense_updated = 1;
  7732. }
  7733. if (spec->jack_present)
  7734. mute = HDA_AMP_MUTE; /* mute internal speaker */
  7735. else /* unmute internal speaker if necessary */
  7736. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7737. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7738. HDA_AMP_MUTE, mute);
  7739. }
  7740. /* bind hp and internal speaker mute (with plug check) */
  7741. static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
  7742. struct snd_ctl_elem_value *ucontrol)
  7743. {
  7744. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7745. long *valp = ucontrol->value.integer.value;
  7746. int change;
  7747. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7748. HDA_AMP_MUTE,
  7749. valp[0] ? 0 : HDA_AMP_MUTE);
  7750. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7751. HDA_AMP_MUTE,
  7752. valp[1] ? 0 : HDA_AMP_MUTE);
  7753. if (change)
  7754. alc268_acer_automute(codec, 0);
  7755. return change;
  7756. }
  7757. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  7758. /* output mixer control */
  7759. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  7760. {
  7761. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7762. .name = "Master Playback Switch",
  7763. .info = snd_hda_mixer_amp_switch_info,
  7764. .get = snd_hda_mixer_amp_switch_get,
  7765. .put = alc268_acer_master_sw_put,
  7766. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7767. },
  7768. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7769. HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
  7770. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7771. { }
  7772. };
  7773. static struct hda_verb alc268_acer_verbs[] = {
  7774. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7775. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7776. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7777. { }
  7778. };
  7779. /* unsolicited event for HP jack sensing */
  7780. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  7781. unsigned int res)
  7782. {
  7783. if ((res >> 26) != ALC880_HP_EVENT)
  7784. return;
  7785. alc268_toshiba_automute(codec);
  7786. }
  7787. static void alc268_acer_unsol_event(struct hda_codec *codec,
  7788. unsigned int res)
  7789. {
  7790. if ((res >> 26) != ALC880_HP_EVENT)
  7791. return;
  7792. alc268_acer_automute(codec, 1);
  7793. }
  7794. static void alc268_acer_init_hook(struct hda_codec *codec)
  7795. {
  7796. alc268_acer_automute(codec, 1);
  7797. }
  7798. /*
  7799. * generic initialization of ADC, input mixers and output mixers
  7800. */
  7801. static struct hda_verb alc268_base_init_verbs[] = {
  7802. /* Unmute DAC0-1 and set vol = 0 */
  7803. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7804. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7805. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7806. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7807. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7808. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7809. /*
  7810. * Set up output mixers (0x0c - 0x0e)
  7811. */
  7812. /* set vol=0 to output mixers */
  7813. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7814. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7815. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7816. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7817. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7818. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7819. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7820. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7821. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7822. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7823. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7824. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7825. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7826. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7827. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7828. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7829. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7830. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7831. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7832. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7833. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7834. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7835. /* FIXME: use matrix-type input source selection */
  7836. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7837. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7838. /* Input mixer2 */
  7839. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7840. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7841. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7842. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7843. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7844. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7845. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7846. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7847. { }
  7848. };
  7849. /*
  7850. * generic initialization of ADC, input mixers and output mixers
  7851. */
  7852. static struct hda_verb alc268_volume_init_verbs[] = {
  7853. /* set output DAC */
  7854. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7855. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7856. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7857. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7858. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7859. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7860. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7861. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7862. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7863. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7864. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7865. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7866. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7867. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7868. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7869. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7870. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7871. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7872. /* set PCBEEP vol = 0 */
  7873. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7874. { }
  7875. };
  7876. #define alc268_mux_enum_info alc_mux_enum_info
  7877. #define alc268_mux_enum_get alc_mux_enum_get
  7878. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7879. struct snd_ctl_elem_value *ucontrol)
  7880. {
  7881. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7882. struct alc_spec *spec = codec->spec;
  7883. const struct hda_input_mux *imux = spec->input_mux;
  7884. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7885. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7886. hda_nid_t nid = capture_mixers[adc_idx];
  7887. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7888. unsigned int i, idx;
  7889. idx = ucontrol->value.enumerated.item[0];
  7890. if (idx >= imux->num_items)
  7891. idx = imux->num_items - 1;
  7892. if (*cur_val == idx)
  7893. return 0;
  7894. for (i = 0; i < imux->num_items; i++) {
  7895. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  7896. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  7897. imux->items[i].index,
  7898. HDA_AMP_MUTE, v);
  7899. snd_hda_codec_write_cache(codec, nid, 0,
  7900. AC_VERB_SET_CONNECT_SEL,
  7901. idx );
  7902. }
  7903. *cur_val = idx;
  7904. return 1;
  7905. }
  7906. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7907. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7908. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7909. {
  7910. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7911. /* The multiple "Capture Source" controls confuse alsamixer
  7912. * So call somewhat different..
  7913. * FIXME: the controls appear in the "playback" view!
  7914. */
  7915. /* .name = "Capture Source", */
  7916. .name = "Input Source",
  7917. .count = 1,
  7918. .info = alc268_mux_enum_info,
  7919. .get = alc268_mux_enum_get,
  7920. .put = alc268_mux_enum_put,
  7921. },
  7922. { } /* end */
  7923. };
  7924. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7925. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7926. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7927. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7928. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7929. {
  7930. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7931. /* The multiple "Capture Source" controls confuse alsamixer
  7932. * So call somewhat different..
  7933. * FIXME: the controls appear in the "playback" view!
  7934. */
  7935. /* .name = "Capture Source", */
  7936. .name = "Input Source",
  7937. .count = 2,
  7938. .info = alc268_mux_enum_info,
  7939. .get = alc268_mux_enum_get,
  7940. .put = alc268_mux_enum_put,
  7941. },
  7942. { } /* end */
  7943. };
  7944. static struct hda_input_mux alc268_capture_source = {
  7945. .num_items = 4,
  7946. .items = {
  7947. { "Mic", 0x0 },
  7948. { "Front Mic", 0x1 },
  7949. { "Line", 0x2 },
  7950. { "CD", 0x3 },
  7951. },
  7952. };
  7953. /* create input playback/capture controls for the given pin */
  7954. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7955. const char *ctlname, int idx)
  7956. {
  7957. char name[32];
  7958. int err;
  7959. sprintf(name, "%s Playback Volume", ctlname);
  7960. if (nid == 0x14) {
  7961. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7962. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7963. HDA_OUTPUT));
  7964. if (err < 0)
  7965. return err;
  7966. } else if (nid == 0x15) {
  7967. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7968. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7969. HDA_OUTPUT));
  7970. if (err < 0)
  7971. return err;
  7972. } else
  7973. return -1;
  7974. sprintf(name, "%s Playback Switch", ctlname);
  7975. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7976. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7977. if (err < 0)
  7978. return err;
  7979. return 0;
  7980. }
  7981. /* add playback controls from the parsed DAC table */
  7982. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7983. const struct auto_pin_cfg *cfg)
  7984. {
  7985. hda_nid_t nid;
  7986. int err;
  7987. spec->multiout.num_dacs = 2; /* only use one dac */
  7988. spec->multiout.dac_nids = spec->private_dac_nids;
  7989. spec->multiout.dac_nids[0] = 2;
  7990. spec->multiout.dac_nids[1] = 3;
  7991. nid = cfg->line_out_pins[0];
  7992. if (nid)
  7993. alc268_new_analog_output(spec, nid, "Front", 0);
  7994. nid = cfg->speaker_pins[0];
  7995. if (nid == 0x1d) {
  7996. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7997. "Speaker Playback Volume",
  7998. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7999. if (err < 0)
  8000. return err;
  8001. }
  8002. nid = cfg->hp_pins[0];
  8003. if (nid)
  8004. alc268_new_analog_output(spec, nid, "Headphone", 0);
  8005. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  8006. if (nid == 0x16) {
  8007. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8008. "Mono Playback Switch",
  8009. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  8010. if (err < 0)
  8011. return err;
  8012. }
  8013. return 0;
  8014. }
  8015. /* create playback/capture controls for input pins */
  8016. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  8017. const struct auto_pin_cfg *cfg)
  8018. {
  8019. struct hda_input_mux *imux = &spec->private_imux;
  8020. int i, idx1;
  8021. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8022. switch(cfg->input_pins[i]) {
  8023. case 0x18:
  8024. idx1 = 0; /* Mic 1 */
  8025. break;
  8026. case 0x19:
  8027. idx1 = 1; /* Mic 2 */
  8028. break;
  8029. case 0x1a:
  8030. idx1 = 2; /* Line In */
  8031. break;
  8032. case 0x1c:
  8033. idx1 = 3; /* CD */
  8034. break;
  8035. default:
  8036. continue;
  8037. }
  8038. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8039. imux->items[imux->num_items].index = idx1;
  8040. imux->num_items++;
  8041. }
  8042. return 0;
  8043. }
  8044. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  8045. {
  8046. struct alc_spec *spec = codec->spec;
  8047. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  8048. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  8049. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  8050. unsigned int dac_vol1, dac_vol2;
  8051. if (speaker_nid) {
  8052. snd_hda_codec_write(codec, speaker_nid, 0,
  8053. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  8054. snd_hda_codec_write(codec, 0x0f, 0,
  8055. AC_VERB_SET_AMP_GAIN_MUTE,
  8056. AMP_IN_UNMUTE(1));
  8057. snd_hda_codec_write(codec, 0x10, 0,
  8058. AC_VERB_SET_AMP_GAIN_MUTE,
  8059. AMP_IN_UNMUTE(1));
  8060. } else {
  8061. snd_hda_codec_write(codec, 0x0f, 0,
  8062. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8063. snd_hda_codec_write(codec, 0x10, 0,
  8064. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8065. }
  8066. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  8067. if (line_nid == 0x14)
  8068. dac_vol2 = AMP_OUT_ZERO;
  8069. else if (line_nid == 0x15)
  8070. dac_vol1 = AMP_OUT_ZERO;
  8071. if (hp_nid == 0x14)
  8072. dac_vol2 = AMP_OUT_ZERO;
  8073. else if (hp_nid == 0x15)
  8074. dac_vol1 = AMP_OUT_ZERO;
  8075. if (line_nid != 0x16 || hp_nid != 0x16 ||
  8076. spec->autocfg.line_out_pins[1] != 0x16 ||
  8077. spec->autocfg.line_out_pins[2] != 0x16)
  8078. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  8079. snd_hda_codec_write(codec, 0x02, 0,
  8080. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  8081. snd_hda_codec_write(codec, 0x03, 0,
  8082. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  8083. }
  8084. /* pcm configuration: identiacal with ALC880 */
  8085. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  8086. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  8087. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  8088. /*
  8089. * BIOS auto configuration
  8090. */
  8091. static int alc268_parse_auto_config(struct hda_codec *codec)
  8092. {
  8093. struct alc_spec *spec = codec->spec;
  8094. int err;
  8095. static hda_nid_t alc268_ignore[] = { 0 };
  8096. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8097. alc268_ignore);
  8098. if (err < 0)
  8099. return err;
  8100. if (!spec->autocfg.line_outs)
  8101. return 0; /* can't find valid BIOS pin config */
  8102. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8103. if (err < 0)
  8104. return err;
  8105. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8106. if (err < 0)
  8107. return err;
  8108. spec->multiout.max_channels = 2;
  8109. /* digital only support output */
  8110. if (spec->autocfg.dig_out_pin)
  8111. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  8112. if (spec->kctl_alloc)
  8113. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8114. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  8115. spec->num_mux_defs = 1;
  8116. spec->input_mux = &spec->private_imux;
  8117. return 1;
  8118. }
  8119. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  8120. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  8121. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  8122. /* init callback for auto-configuration model -- overriding the default init */
  8123. static void alc268_auto_init(struct hda_codec *codec)
  8124. {
  8125. alc268_auto_init_multi_out(codec);
  8126. alc268_auto_init_hp_out(codec);
  8127. alc268_auto_init_mono_speaker_out(codec);
  8128. alc268_auto_init_analog_input(codec);
  8129. }
  8130. /*
  8131. * configuration and preset
  8132. */
  8133. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8134. [ALC268_3ST] = "3stack",
  8135. [ALC268_TOSHIBA] = "toshiba",
  8136. [ALC268_ACER] = "acer",
  8137. [ALC268_AUTO] = "auto",
  8138. };
  8139. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8140. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8141. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8142. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8143. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8144. SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
  8145. {}
  8146. };
  8147. static struct alc_config_preset alc268_presets[] = {
  8148. [ALC268_3ST] = {
  8149. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8150. .init_verbs = { alc268_base_init_verbs },
  8151. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8152. .dac_nids = alc268_dac_nids,
  8153. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8154. .adc_nids = alc268_adc_nids_alt,
  8155. .hp_nid = 0x03,
  8156. .dig_out_nid = ALC268_DIGOUT_NID,
  8157. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8158. .channel_mode = alc268_modes,
  8159. .input_mux = &alc268_capture_source,
  8160. },
  8161. [ALC268_TOSHIBA] = {
  8162. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8163. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8164. alc268_toshiba_verbs },
  8165. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8166. .dac_nids = alc268_dac_nids,
  8167. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8168. .adc_nids = alc268_adc_nids_alt,
  8169. .hp_nid = 0x03,
  8170. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8171. .channel_mode = alc268_modes,
  8172. .input_mux = &alc268_capture_source,
  8173. .input_mux = &alc268_capture_source,
  8174. .unsol_event = alc268_toshiba_unsol_event,
  8175. .init_hook = alc268_toshiba_automute,
  8176. },
  8177. [ALC268_ACER] = {
  8178. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8179. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8180. alc268_acer_verbs },
  8181. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8182. .dac_nids = alc268_dac_nids,
  8183. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8184. .adc_nids = alc268_adc_nids_alt,
  8185. .hp_nid = 0x02,
  8186. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8187. .channel_mode = alc268_modes,
  8188. .input_mux = &alc268_capture_source,
  8189. .unsol_event = alc268_acer_unsol_event,
  8190. .init_hook = alc268_acer_init_hook,
  8191. },
  8192. };
  8193. static int patch_alc268(struct hda_codec *codec)
  8194. {
  8195. struct alc_spec *spec;
  8196. int board_config;
  8197. int err;
  8198. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8199. if (spec == NULL)
  8200. return -ENOMEM;
  8201. codec->spec = spec;
  8202. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8203. alc268_models,
  8204. alc268_cfg_tbl);
  8205. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8206. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8207. "trying auto-probe from BIOS...\n");
  8208. board_config = ALC268_AUTO;
  8209. }
  8210. if (board_config == ALC268_AUTO) {
  8211. /* automatic parse from the BIOS config */
  8212. err = alc268_parse_auto_config(codec);
  8213. if (err < 0) {
  8214. alc_free(codec);
  8215. return err;
  8216. } else if (!err) {
  8217. printk(KERN_INFO
  8218. "hda_codec: Cannot set up configuration "
  8219. "from BIOS. Using base mode...\n");
  8220. board_config = ALC268_3ST;
  8221. }
  8222. }
  8223. if (board_config != ALC268_AUTO)
  8224. setup_preset(spec, &alc268_presets[board_config]);
  8225. spec->stream_name_analog = "ALC268 Analog";
  8226. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8227. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8228. spec->stream_name_digital = "ALC268 Digital";
  8229. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8230. if (board_config == ALC268_AUTO) {
  8231. if (!spec->adc_nids && spec->input_mux) {
  8232. /* check whether NID 0x07 is valid */
  8233. unsigned int wcap = get_wcaps(codec, 0x07);
  8234. /* get type */
  8235. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8236. if (wcap != AC_WID_AUD_IN) {
  8237. spec->adc_nids = alc268_adc_nids_alt;
  8238. spec->num_adc_nids =
  8239. ARRAY_SIZE(alc268_adc_nids_alt);
  8240. spec->mixers[spec->num_mixers] =
  8241. alc268_capture_alt_mixer;
  8242. spec->num_mixers++;
  8243. } else {
  8244. spec->adc_nids = alc268_adc_nids;
  8245. spec->num_adc_nids =
  8246. ARRAY_SIZE(alc268_adc_nids);
  8247. spec->mixers[spec->num_mixers] =
  8248. alc268_capture_mixer;
  8249. spec->num_mixers++;
  8250. }
  8251. }
  8252. }
  8253. codec->patch_ops = alc_patch_ops;
  8254. if (board_config == ALC268_AUTO)
  8255. spec->init_hook = alc268_auto_init;
  8256. return 0;
  8257. }
  8258. /*
  8259. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8260. */
  8261. /*
  8262. * set the path ways for 2 channel output
  8263. * need to set the codec line out and mic 1 pin widgets to inputs
  8264. */
  8265. static struct hda_verb alc861_threestack_ch2_init[] = {
  8266. /* set pin widget 1Ah (line in) for input */
  8267. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8268. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8269. * the vref
  8270. */
  8271. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8272. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8273. #if 0
  8274. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8275. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8276. #endif
  8277. { } /* end */
  8278. };
  8279. /*
  8280. * 6ch mode
  8281. * need to set the codec line out and mic 1 pin widgets to outputs
  8282. */
  8283. static struct hda_verb alc861_threestack_ch6_init[] = {
  8284. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8285. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8286. /* set pin widget 18h (mic1) for output (CLFE)*/
  8287. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8288. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8289. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8290. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8291. #if 0
  8292. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8293. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8294. #endif
  8295. { } /* end */
  8296. };
  8297. static struct hda_channel_mode alc861_threestack_modes[2] = {
  8298. { 2, alc861_threestack_ch2_init },
  8299. { 6, alc861_threestack_ch6_init },
  8300. };
  8301. /* Set mic1 as input and unmute the mixer */
  8302. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  8303. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8304. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8305. { } /* end */
  8306. };
  8307. /* Set mic1 as output and mute mixer */
  8308. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  8309. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8310. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8311. { } /* end */
  8312. };
  8313. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  8314. { 2, alc861_uniwill_m31_ch2_init },
  8315. { 4, alc861_uniwill_m31_ch4_init },
  8316. };
  8317. /* Set mic1 and line-in as input and unmute the mixer */
  8318. static struct hda_verb alc861_asus_ch2_init[] = {
  8319. /* set pin widget 1Ah (line in) for input */
  8320. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8321. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8322. * the vref
  8323. */
  8324. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8325. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8326. #if 0
  8327. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8328. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8329. #endif
  8330. { } /* end */
  8331. };
  8332. /* Set mic1 nad line-in as output and mute mixer */
  8333. static struct hda_verb alc861_asus_ch6_init[] = {
  8334. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8335. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8336. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8337. /* set pin widget 18h (mic1) for output (CLFE)*/
  8338. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8339. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8340. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8341. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8342. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8343. #if 0
  8344. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8345. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8346. #endif
  8347. { } /* end */
  8348. };
  8349. static struct hda_channel_mode alc861_asus_modes[2] = {
  8350. { 2, alc861_asus_ch2_init },
  8351. { 6, alc861_asus_ch6_init },
  8352. };
  8353. /* patch-ALC861 */
  8354. static struct snd_kcontrol_new alc861_base_mixer[] = {
  8355. /* output mixer control */
  8356. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8357. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8358. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8359. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8360. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8361. /*Input mixer control */
  8362. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8363. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8364. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8365. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8366. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8367. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8368. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8369. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8370. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8371. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8372. /* Capture mixer control */
  8373. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8374. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8375. {
  8376. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8377. .name = "Capture Source",
  8378. .count = 1,
  8379. .info = alc_mux_enum_info,
  8380. .get = alc_mux_enum_get,
  8381. .put = alc_mux_enum_put,
  8382. },
  8383. { } /* end */
  8384. };
  8385. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8386. /* output mixer control */
  8387. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8388. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8389. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8390. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8391. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8392. /* Input mixer control */
  8393. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8394. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8395. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8396. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8397. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8398. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8399. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8400. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8401. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8402. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8403. /* Capture mixer control */
  8404. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8405. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8406. {
  8407. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8408. .name = "Capture Source",
  8409. .count = 1,
  8410. .info = alc_mux_enum_info,
  8411. .get = alc_mux_enum_get,
  8412. .put = alc_mux_enum_put,
  8413. },
  8414. {
  8415. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8416. .name = "Channel Mode",
  8417. .info = alc_ch_mode_info,
  8418. .get = alc_ch_mode_get,
  8419. .put = alc_ch_mode_put,
  8420. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8421. },
  8422. { } /* end */
  8423. };
  8424. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8425. /* output mixer control */
  8426. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8427. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8428. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8429. /*Capture mixer control */
  8430. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8431. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8432. {
  8433. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8434. .name = "Capture Source",
  8435. .count = 1,
  8436. .info = alc_mux_enum_info,
  8437. .get = alc_mux_enum_get,
  8438. .put = alc_mux_enum_put,
  8439. },
  8440. { } /* end */
  8441. };
  8442. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8443. /* output mixer control */
  8444. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8445. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8446. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8447. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8448. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8449. /* Input mixer control */
  8450. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8451. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8452. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8453. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8454. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8455. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8456. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8457. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8458. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8459. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8460. /* Capture mixer control */
  8461. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8462. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8463. {
  8464. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8465. .name = "Capture Source",
  8466. .count = 1,
  8467. .info = alc_mux_enum_info,
  8468. .get = alc_mux_enum_get,
  8469. .put = alc_mux_enum_put,
  8470. },
  8471. {
  8472. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8473. .name = "Channel Mode",
  8474. .info = alc_ch_mode_info,
  8475. .get = alc_ch_mode_get,
  8476. .put = alc_ch_mode_put,
  8477. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8478. },
  8479. { } /* end */
  8480. };
  8481. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8482. /* output mixer control */
  8483. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8484. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8485. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8486. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8487. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8488. /* Input mixer control */
  8489. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8490. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8491. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8492. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8493. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8494. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8495. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8496. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8497. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8498. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8499. /* Capture mixer control */
  8500. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8501. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8502. {
  8503. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8504. .name = "Capture Source",
  8505. .count = 1,
  8506. .info = alc_mux_enum_info,
  8507. .get = alc_mux_enum_get,
  8508. .put = alc_mux_enum_put,
  8509. },
  8510. {
  8511. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8512. .name = "Channel Mode",
  8513. .info = alc_ch_mode_info,
  8514. .get = alc_ch_mode_get,
  8515. .put = alc_ch_mode_put,
  8516. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8517. },
  8518. { }
  8519. };
  8520. /* additional mixer */
  8521. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8522. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8523. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8524. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8525. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8526. { }
  8527. };
  8528. /*
  8529. * generic initialization of ADC, input mixers and output mixers
  8530. */
  8531. static struct hda_verb alc861_base_init_verbs[] = {
  8532. /*
  8533. * Unmute ADC0 and set the default input to mic-in
  8534. */
  8535. /* port-A for surround (rear panel) */
  8536. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8537. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8538. /* port-B for mic-in (rear panel) with vref */
  8539. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8540. /* port-C for line-in (rear panel) */
  8541. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8542. /* port-D for Front */
  8543. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8544. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8545. /* port-E for HP out (front panel) */
  8546. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8547. /* route front PCM to HP */
  8548. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8549. /* port-F for mic-in (front panel) with vref */
  8550. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8551. /* port-G for CLFE (rear panel) */
  8552. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8553. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8554. /* port-H for side (rear panel) */
  8555. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8556. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8557. /* CD-in */
  8558. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8559. /* route front mic to ADC1*/
  8560. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8561. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8562. /* Unmute DAC0~3 & spdif out*/
  8563. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8564. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8565. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8566. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8567. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8568. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8569. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8570. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8571. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8572. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8573. /* Unmute Stereo Mixer 15 */
  8574. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8575. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8576. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8577. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8578. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8579. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8580. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8581. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8582. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8583. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8584. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8585. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8586. /* hp used DAC 3 (Front) */
  8587. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8588. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8589. { }
  8590. };
  8591. static struct hda_verb alc861_threestack_init_verbs[] = {
  8592. /*
  8593. * Unmute ADC0 and set the default input to mic-in
  8594. */
  8595. /* port-A for surround (rear panel) */
  8596. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8597. /* port-B for mic-in (rear panel) with vref */
  8598. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8599. /* port-C for line-in (rear panel) */
  8600. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8601. /* port-D for Front */
  8602. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8603. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8604. /* port-E for HP out (front panel) */
  8605. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8606. /* route front PCM to HP */
  8607. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8608. /* port-F for mic-in (front panel) with vref */
  8609. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8610. /* port-G for CLFE (rear panel) */
  8611. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8612. /* port-H for side (rear panel) */
  8613. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8614. /* CD-in */
  8615. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8616. /* route front mic to ADC1*/
  8617. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8618. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8619. /* Unmute DAC0~3 & spdif out*/
  8620. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8621. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8622. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8623. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8624. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8625. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8626. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8627. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8628. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8629. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8630. /* Unmute Stereo Mixer 15 */
  8631. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8632. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8633. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8634. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8635. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8636. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8637. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8638. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8639. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8640. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8641. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8642. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8643. /* hp used DAC 3 (Front) */
  8644. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8645. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8646. { }
  8647. };
  8648. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8649. /*
  8650. * Unmute ADC0 and set the default input to mic-in
  8651. */
  8652. /* port-A for surround (rear panel) */
  8653. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8654. /* port-B for mic-in (rear panel) with vref */
  8655. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8656. /* port-C for line-in (rear panel) */
  8657. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8658. /* port-D for Front */
  8659. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8660. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8661. /* port-E for HP out (front panel) */
  8662. /* this has to be set to VREF80 */
  8663. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8664. /* route front PCM to HP */
  8665. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8666. /* port-F for mic-in (front panel) with vref */
  8667. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8668. /* port-G for CLFE (rear panel) */
  8669. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8670. /* port-H for side (rear panel) */
  8671. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8672. /* CD-in */
  8673. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8674. /* route front mic to ADC1*/
  8675. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8676. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8677. /* Unmute DAC0~3 & spdif out*/
  8678. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8679. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8680. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8681. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8682. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8683. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8684. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8685. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8686. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8687. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8688. /* Unmute Stereo Mixer 15 */
  8689. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8690. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8691. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8692. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8693. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8694. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8695. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8696. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8697. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8698. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8699. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8700. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8701. /* hp used DAC 3 (Front) */
  8702. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8703. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8704. { }
  8705. };
  8706. static struct hda_verb alc861_asus_init_verbs[] = {
  8707. /*
  8708. * Unmute ADC0 and set the default input to mic-in
  8709. */
  8710. /* port-A for surround (rear panel)
  8711. * according to codec#0 this is the HP jack
  8712. */
  8713. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8714. /* route front PCM to HP */
  8715. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8716. /* port-B for mic-in (rear panel) with vref */
  8717. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8718. /* port-C for line-in (rear panel) */
  8719. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8720. /* port-D for Front */
  8721. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8722. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8723. /* port-E for HP out (front panel) */
  8724. /* this has to be set to VREF80 */
  8725. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8726. /* route front PCM to HP */
  8727. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8728. /* port-F for mic-in (front panel) with vref */
  8729. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8730. /* port-G for CLFE (rear panel) */
  8731. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8732. /* port-H for side (rear panel) */
  8733. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8734. /* CD-in */
  8735. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8736. /* route front mic to ADC1*/
  8737. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8738. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8739. /* Unmute DAC0~3 & spdif out*/
  8740. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8741. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8742. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8743. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8744. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8745. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8746. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8747. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8748. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8749. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8750. /* Unmute Stereo Mixer 15 */
  8751. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8752. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8753. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8754. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8755. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8756. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8757. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8758. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8759. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8760. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8761. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8762. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8763. /* hp used DAC 3 (Front) */
  8764. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8765. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8766. { }
  8767. };
  8768. /* additional init verbs for ASUS laptops */
  8769. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8770. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8771. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8772. { }
  8773. };
  8774. /*
  8775. * generic initialization of ADC, input mixers and output mixers
  8776. */
  8777. static struct hda_verb alc861_auto_init_verbs[] = {
  8778. /*
  8779. * Unmute ADC0 and set the default input to mic-in
  8780. */
  8781. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8782. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8783. /* Unmute DAC0~3 & spdif out*/
  8784. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8785. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8786. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8787. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8788. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8789. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8790. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8791. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8792. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8793. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8794. /* Unmute Stereo Mixer 15 */
  8795. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8796. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8797. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8798. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8799. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8800. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8801. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8802. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8803. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8804. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8805. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8806. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8807. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8808. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8809. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8810. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8811. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8812. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8813. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8814. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8815. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8816. { }
  8817. };
  8818. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8819. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8820. { }
  8821. };
  8822. /* toggle speaker-output according to the hp-jack state */
  8823. static void alc861_toshiba_automute(struct hda_codec *codec)
  8824. {
  8825. unsigned int present;
  8826. present = snd_hda_codec_read(codec, 0x0f, 0,
  8827. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8828. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  8829. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  8830. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  8831. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  8832. }
  8833. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8834. unsigned int res)
  8835. {
  8836. if ((res >> 26) == ALC880_HP_EVENT)
  8837. alc861_toshiba_automute(codec);
  8838. }
  8839. /* pcm configuration: identiacal with ALC880 */
  8840. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8841. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8842. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8843. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8844. #define ALC861_DIGOUT_NID 0x07
  8845. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8846. { 8, NULL }
  8847. };
  8848. static hda_nid_t alc861_dac_nids[4] = {
  8849. /* front, surround, clfe, side */
  8850. 0x03, 0x06, 0x05, 0x04
  8851. };
  8852. static hda_nid_t alc660_dac_nids[3] = {
  8853. /* front, clfe, surround */
  8854. 0x03, 0x05, 0x06
  8855. };
  8856. static hda_nid_t alc861_adc_nids[1] = {
  8857. /* ADC0-2 */
  8858. 0x08,
  8859. };
  8860. static struct hda_input_mux alc861_capture_source = {
  8861. .num_items = 5,
  8862. .items = {
  8863. { "Mic", 0x0 },
  8864. { "Front Mic", 0x3 },
  8865. { "Line", 0x1 },
  8866. { "CD", 0x4 },
  8867. { "Mixer", 0x5 },
  8868. },
  8869. };
  8870. /* fill in the dac_nids table from the parsed pin configuration */
  8871. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8872. const struct auto_pin_cfg *cfg)
  8873. {
  8874. int i;
  8875. hda_nid_t nid;
  8876. spec->multiout.dac_nids = spec->private_dac_nids;
  8877. for (i = 0; i < cfg->line_outs; i++) {
  8878. nid = cfg->line_out_pins[i];
  8879. if (nid) {
  8880. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8881. continue;
  8882. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8883. }
  8884. }
  8885. spec->multiout.num_dacs = cfg->line_outs;
  8886. return 0;
  8887. }
  8888. /* add playback controls from the parsed DAC table */
  8889. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8890. const struct auto_pin_cfg *cfg)
  8891. {
  8892. char name[32];
  8893. static const char *chname[4] = {
  8894. "Front", "Surround", NULL /*CLFE*/, "Side"
  8895. };
  8896. hda_nid_t nid;
  8897. int i, idx, err;
  8898. for (i = 0; i < cfg->line_outs; i++) {
  8899. nid = spec->multiout.dac_nids[i];
  8900. if (!nid)
  8901. continue;
  8902. if (nid == 0x05) {
  8903. /* Center/LFE */
  8904. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8905. "Center Playback Switch",
  8906. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8907. HDA_OUTPUT));
  8908. if (err < 0)
  8909. return err;
  8910. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8911. "LFE Playback Switch",
  8912. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8913. HDA_OUTPUT));
  8914. if (err < 0)
  8915. return err;
  8916. } else {
  8917. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8918. idx++)
  8919. if (nid == alc861_dac_nids[idx])
  8920. break;
  8921. sprintf(name, "%s Playback Switch", chname[idx]);
  8922. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8923. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8924. HDA_OUTPUT));
  8925. if (err < 0)
  8926. return err;
  8927. }
  8928. }
  8929. return 0;
  8930. }
  8931. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8932. {
  8933. int err;
  8934. hda_nid_t nid;
  8935. if (!pin)
  8936. return 0;
  8937. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8938. nid = 0x03;
  8939. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8940. "Headphone Playback Switch",
  8941. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8942. if (err < 0)
  8943. return err;
  8944. spec->multiout.hp_nid = nid;
  8945. }
  8946. return 0;
  8947. }
  8948. /* create playback/capture controls for input pins */
  8949. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8950. const struct auto_pin_cfg *cfg)
  8951. {
  8952. struct hda_input_mux *imux = &spec->private_imux;
  8953. int i, err, idx, idx1;
  8954. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8955. switch (cfg->input_pins[i]) {
  8956. case 0x0c:
  8957. idx1 = 1;
  8958. idx = 2; /* Line In */
  8959. break;
  8960. case 0x0f:
  8961. idx1 = 2;
  8962. idx = 2; /* Line In */
  8963. break;
  8964. case 0x0d:
  8965. idx1 = 0;
  8966. idx = 1; /* Mic In */
  8967. break;
  8968. case 0x10:
  8969. idx1 = 3;
  8970. idx = 1; /* Mic In */
  8971. break;
  8972. case 0x11:
  8973. idx1 = 4;
  8974. idx = 0; /* CD */
  8975. break;
  8976. default:
  8977. continue;
  8978. }
  8979. err = new_analog_input(spec, cfg->input_pins[i],
  8980. auto_pin_cfg_labels[i], idx, 0x15);
  8981. if (err < 0)
  8982. return err;
  8983. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8984. imux->items[imux->num_items].index = idx1;
  8985. imux->num_items++;
  8986. }
  8987. return 0;
  8988. }
  8989. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8990. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8991. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8992. {
  8993. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8994. /* The multiple "Capture Source" controls confuse alsamixer
  8995. * So call somewhat different..
  8996. *FIXME: the controls appear in the "playback" view!
  8997. */
  8998. /* .name = "Capture Source", */
  8999. .name = "Input Source",
  9000. .count = 1,
  9001. .info = alc_mux_enum_info,
  9002. .get = alc_mux_enum_get,
  9003. .put = alc_mux_enum_put,
  9004. },
  9005. { } /* end */
  9006. };
  9007. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  9008. hda_nid_t nid,
  9009. int pin_type, int dac_idx)
  9010. {
  9011. /* set as output */
  9012. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  9013. pin_type);
  9014. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9015. AMP_OUT_UNMUTE);
  9016. }
  9017. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  9018. {
  9019. struct alc_spec *spec = codec->spec;
  9020. int i;
  9021. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  9022. for (i = 0; i < spec->autocfg.line_outs; i++) {
  9023. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9024. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9025. if (nid)
  9026. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  9027. spec->multiout.dac_nids[i]);
  9028. }
  9029. }
  9030. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  9031. {
  9032. struct alc_spec *spec = codec->spec;
  9033. hda_nid_t pin;
  9034. pin = spec->autocfg.hp_pins[0];
  9035. if (pin) /* connect to front */
  9036. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  9037. spec->multiout.dac_nids[0]);
  9038. }
  9039. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  9040. {
  9041. struct alc_spec *spec = codec->spec;
  9042. int i;
  9043. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9044. hda_nid_t nid = spec->autocfg.input_pins[i];
  9045. if (nid >= 0x0c && nid <= 0x11) {
  9046. snd_hda_codec_write(codec, nid, 0,
  9047. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9048. i <= AUTO_PIN_FRONT_MIC ?
  9049. PIN_VREF80 : PIN_IN);
  9050. }
  9051. }
  9052. }
  9053. /* parse the BIOS configuration and set up the alc_spec */
  9054. /* return 1 if successful, 0 if the proper config is not found,
  9055. * or a negative error code
  9056. */
  9057. static int alc861_parse_auto_config(struct hda_codec *codec)
  9058. {
  9059. struct alc_spec *spec = codec->spec;
  9060. int err;
  9061. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  9062. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9063. alc861_ignore);
  9064. if (err < 0)
  9065. return err;
  9066. if (!spec->autocfg.line_outs)
  9067. return 0; /* can't find valid BIOS pin config */
  9068. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  9069. if (err < 0)
  9070. return err;
  9071. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9072. if (err < 0)
  9073. return err;
  9074. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  9075. if (err < 0)
  9076. return err;
  9077. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9078. if (err < 0)
  9079. return err;
  9080. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9081. if (spec->autocfg.dig_out_pin)
  9082. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  9083. if (spec->kctl_alloc)
  9084. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9085. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  9086. spec->num_mux_defs = 1;
  9087. spec->input_mux = &spec->private_imux;
  9088. spec->adc_nids = alc861_adc_nids;
  9089. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  9090. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  9091. spec->num_mixers++;
  9092. return 1;
  9093. }
  9094. /* additional initialization for auto-configuration model */
  9095. static void alc861_auto_init(struct hda_codec *codec)
  9096. {
  9097. alc861_auto_init_multi_out(codec);
  9098. alc861_auto_init_hp_out(codec);
  9099. alc861_auto_init_analog_input(codec);
  9100. }
  9101. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9102. static struct hda_amp_list alc861_loopbacks[] = {
  9103. { 0x15, HDA_INPUT, 0 },
  9104. { 0x15, HDA_INPUT, 1 },
  9105. { 0x15, HDA_INPUT, 2 },
  9106. { 0x15, HDA_INPUT, 3 },
  9107. { } /* end */
  9108. };
  9109. #endif
  9110. /*
  9111. * configuration and preset
  9112. */
  9113. static const char *alc861_models[ALC861_MODEL_LAST] = {
  9114. [ALC861_3ST] = "3stack",
  9115. [ALC660_3ST] = "3stack-660",
  9116. [ALC861_3ST_DIG] = "3stack-dig",
  9117. [ALC861_6ST_DIG] = "6stack-dig",
  9118. [ALC861_UNIWILL_M31] = "uniwill-m31",
  9119. [ALC861_TOSHIBA] = "toshiba",
  9120. [ALC861_ASUS] = "asus",
  9121. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  9122. [ALC861_AUTO] = "auto",
  9123. };
  9124. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  9125. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9126. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9127. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9128. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9129. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9130. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9131. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9132. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9133. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9134. * Any other models that need this preset?
  9135. */
  9136. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9137. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9138. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  9139. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9140. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9141. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9142. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9143. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9144. {}
  9145. };
  9146. static struct alc_config_preset alc861_presets[] = {
  9147. [ALC861_3ST] = {
  9148. .mixers = { alc861_3ST_mixer },
  9149. .init_verbs = { alc861_threestack_init_verbs },
  9150. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9151. .dac_nids = alc861_dac_nids,
  9152. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9153. .channel_mode = alc861_threestack_modes,
  9154. .need_dac_fix = 1,
  9155. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9156. .adc_nids = alc861_adc_nids,
  9157. .input_mux = &alc861_capture_source,
  9158. },
  9159. [ALC861_3ST_DIG] = {
  9160. .mixers = { alc861_base_mixer },
  9161. .init_verbs = { alc861_threestack_init_verbs },
  9162. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9163. .dac_nids = alc861_dac_nids,
  9164. .dig_out_nid = ALC861_DIGOUT_NID,
  9165. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9166. .channel_mode = alc861_threestack_modes,
  9167. .need_dac_fix = 1,
  9168. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9169. .adc_nids = alc861_adc_nids,
  9170. .input_mux = &alc861_capture_source,
  9171. },
  9172. [ALC861_6ST_DIG] = {
  9173. .mixers = { alc861_base_mixer },
  9174. .init_verbs = { alc861_base_init_verbs },
  9175. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9176. .dac_nids = alc861_dac_nids,
  9177. .dig_out_nid = ALC861_DIGOUT_NID,
  9178. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  9179. .channel_mode = alc861_8ch_modes,
  9180. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9181. .adc_nids = alc861_adc_nids,
  9182. .input_mux = &alc861_capture_source,
  9183. },
  9184. [ALC660_3ST] = {
  9185. .mixers = { alc861_3ST_mixer },
  9186. .init_verbs = { alc861_threestack_init_verbs },
  9187. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  9188. .dac_nids = alc660_dac_nids,
  9189. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9190. .channel_mode = alc861_threestack_modes,
  9191. .need_dac_fix = 1,
  9192. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9193. .adc_nids = alc861_adc_nids,
  9194. .input_mux = &alc861_capture_source,
  9195. },
  9196. [ALC861_UNIWILL_M31] = {
  9197. .mixers = { alc861_uniwill_m31_mixer },
  9198. .init_verbs = { alc861_uniwill_m31_init_verbs },
  9199. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9200. .dac_nids = alc861_dac_nids,
  9201. .dig_out_nid = ALC861_DIGOUT_NID,
  9202. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9203. .channel_mode = alc861_uniwill_m31_modes,
  9204. .need_dac_fix = 1,
  9205. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9206. .adc_nids = alc861_adc_nids,
  9207. .input_mux = &alc861_capture_source,
  9208. },
  9209. [ALC861_TOSHIBA] = {
  9210. .mixers = { alc861_toshiba_mixer },
  9211. .init_verbs = { alc861_base_init_verbs,
  9212. alc861_toshiba_init_verbs },
  9213. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9214. .dac_nids = alc861_dac_nids,
  9215. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9216. .channel_mode = alc883_3ST_2ch_modes,
  9217. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9218. .adc_nids = alc861_adc_nids,
  9219. .input_mux = &alc861_capture_source,
  9220. .unsol_event = alc861_toshiba_unsol_event,
  9221. .init_hook = alc861_toshiba_automute,
  9222. },
  9223. [ALC861_ASUS] = {
  9224. .mixers = { alc861_asus_mixer },
  9225. .init_verbs = { alc861_asus_init_verbs },
  9226. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9227. .dac_nids = alc861_dac_nids,
  9228. .dig_out_nid = ALC861_DIGOUT_NID,
  9229. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  9230. .channel_mode = alc861_asus_modes,
  9231. .need_dac_fix = 1,
  9232. .hp_nid = 0x06,
  9233. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9234. .adc_nids = alc861_adc_nids,
  9235. .input_mux = &alc861_capture_source,
  9236. },
  9237. [ALC861_ASUS_LAPTOP] = {
  9238. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  9239. .init_verbs = { alc861_asus_init_verbs,
  9240. alc861_asus_laptop_init_verbs },
  9241. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9242. .dac_nids = alc861_dac_nids,
  9243. .dig_out_nid = ALC861_DIGOUT_NID,
  9244. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9245. .channel_mode = alc883_3ST_2ch_modes,
  9246. .need_dac_fix = 1,
  9247. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9248. .adc_nids = alc861_adc_nids,
  9249. .input_mux = &alc861_capture_source,
  9250. },
  9251. };
  9252. static int patch_alc861(struct hda_codec *codec)
  9253. {
  9254. struct alc_spec *spec;
  9255. int board_config;
  9256. int err;
  9257. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9258. if (spec == NULL)
  9259. return -ENOMEM;
  9260. codec->spec = spec;
  9261. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9262. alc861_models,
  9263. alc861_cfg_tbl);
  9264. if (board_config < 0) {
  9265. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9266. "trying auto-probe from BIOS...\n");
  9267. board_config = ALC861_AUTO;
  9268. }
  9269. if (board_config == ALC861_AUTO) {
  9270. /* automatic parse from the BIOS config */
  9271. err = alc861_parse_auto_config(codec);
  9272. if (err < 0) {
  9273. alc_free(codec);
  9274. return err;
  9275. } else if (!err) {
  9276. printk(KERN_INFO
  9277. "hda_codec: Cannot set up configuration "
  9278. "from BIOS. Using base mode...\n");
  9279. board_config = ALC861_3ST_DIG;
  9280. }
  9281. }
  9282. if (board_config != ALC861_AUTO)
  9283. setup_preset(spec, &alc861_presets[board_config]);
  9284. spec->stream_name_analog = "ALC861 Analog";
  9285. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  9286. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  9287. spec->stream_name_digital = "ALC861 Digital";
  9288. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  9289. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  9290. codec->patch_ops = alc_patch_ops;
  9291. if (board_config == ALC861_AUTO)
  9292. spec->init_hook = alc861_auto_init;
  9293. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9294. if (!spec->loopback.amplist)
  9295. spec->loopback.amplist = alc861_loopbacks;
  9296. #endif
  9297. return 0;
  9298. }
  9299. /*
  9300. * ALC861-VD support
  9301. *
  9302. * Based on ALC882
  9303. *
  9304. * In addition, an independent DAC
  9305. */
  9306. #define ALC861VD_DIGOUT_NID 0x06
  9307. static hda_nid_t alc861vd_dac_nids[4] = {
  9308. /* front, surr, clfe, side surr */
  9309. 0x02, 0x03, 0x04, 0x05
  9310. };
  9311. /* dac_nids for ALC660vd are in a different order - according to
  9312. * Realtek's driver.
  9313. * This should probably tesult in a different mixer for 6stack models
  9314. * of ALC660vd codecs, but for now there is only 3stack mixer
  9315. * - and it is the same as in 861vd.
  9316. * adc_nids in ALC660vd are (is) the same as in 861vd
  9317. */
  9318. static hda_nid_t alc660vd_dac_nids[3] = {
  9319. /* front, rear, clfe, rear_surr */
  9320. 0x02, 0x04, 0x03
  9321. };
  9322. static hda_nid_t alc861vd_adc_nids[1] = {
  9323. /* ADC0 */
  9324. 0x09,
  9325. };
  9326. /* input MUX */
  9327. /* FIXME: should be a matrix-type input source selection */
  9328. static struct hda_input_mux alc861vd_capture_source = {
  9329. .num_items = 4,
  9330. .items = {
  9331. { "Mic", 0x0 },
  9332. { "Front Mic", 0x1 },
  9333. { "Line", 0x2 },
  9334. { "CD", 0x4 },
  9335. },
  9336. };
  9337. static struct hda_input_mux alc861vd_dallas_capture_source = {
  9338. .num_items = 3,
  9339. .items = {
  9340. { "Front Mic", 0x0 },
  9341. { "ATAPI Mic", 0x1 },
  9342. { "Line In", 0x5 },
  9343. },
  9344. };
  9345. static struct hda_input_mux alc861vd_hp_capture_source = {
  9346. .num_items = 2,
  9347. .items = {
  9348. { "Front Mic", 0x0 },
  9349. { "ATAPI Mic", 0x1 },
  9350. },
  9351. };
  9352. #define alc861vd_mux_enum_info alc_mux_enum_info
  9353. #define alc861vd_mux_enum_get alc_mux_enum_get
  9354. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  9355. struct snd_ctl_elem_value *ucontrol)
  9356. {
  9357. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9358. struct alc_spec *spec = codec->spec;
  9359. const struct hda_input_mux *imux = spec->input_mux;
  9360. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9361. static hda_nid_t capture_mixers[1] = { 0x22 };
  9362. hda_nid_t nid = capture_mixers[adc_idx];
  9363. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9364. unsigned int i, idx;
  9365. idx = ucontrol->value.enumerated.item[0];
  9366. if (idx >= imux->num_items)
  9367. idx = imux->num_items - 1;
  9368. if (*cur_val == idx)
  9369. return 0;
  9370. for (i = 0; i < imux->num_items; i++) {
  9371. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9372. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9373. imux->items[i].index,
  9374. HDA_AMP_MUTE, v);
  9375. }
  9376. *cur_val = idx;
  9377. return 1;
  9378. }
  9379. /*
  9380. * 2ch mode
  9381. */
  9382. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9383. { 2, NULL }
  9384. };
  9385. /*
  9386. * 6ch mode
  9387. */
  9388. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9389. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9390. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9391. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9392. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9393. { } /* end */
  9394. };
  9395. /*
  9396. * 8ch mode
  9397. */
  9398. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9399. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9400. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9401. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9402. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9403. { } /* end */
  9404. };
  9405. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9406. { 6, alc861vd_6stack_ch6_init },
  9407. { 8, alc861vd_6stack_ch8_init },
  9408. };
  9409. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9410. {
  9411. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9412. .name = "Channel Mode",
  9413. .info = alc_ch_mode_info,
  9414. .get = alc_ch_mode_get,
  9415. .put = alc_ch_mode_put,
  9416. },
  9417. { } /* end */
  9418. };
  9419. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9420. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9421. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9422. {
  9423. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9424. /* The multiple "Capture Source" controls confuse alsamixer
  9425. * So call somewhat different..
  9426. *FIXME: the controls appear in the "playback" view!
  9427. */
  9428. /* .name = "Capture Source", */
  9429. .name = "Input Source",
  9430. .count = 1,
  9431. .info = alc861vd_mux_enum_info,
  9432. .get = alc861vd_mux_enum_get,
  9433. .put = alc861vd_mux_enum_put,
  9434. },
  9435. { } /* end */
  9436. };
  9437. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9438. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9439. */
  9440. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9441. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9442. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9443. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9444. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9445. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9446. HDA_OUTPUT),
  9447. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9448. HDA_OUTPUT),
  9449. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9450. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9451. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9452. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9453. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9454. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9455. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9456. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9457. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9458. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9459. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9460. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9461. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9462. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9463. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9464. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9465. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9466. { } /* end */
  9467. };
  9468. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9469. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9470. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9471. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9472. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9473. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9474. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9475. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9476. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9477. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9478. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9479. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9480. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9481. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9482. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9483. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9484. { } /* end */
  9485. };
  9486. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9487. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9488. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9489. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9490. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9491. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9492. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9493. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9494. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9495. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9496. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9497. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9498. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9499. { } /* end */
  9500. };
  9501. /* Pin assignment: Front=0x14, HP = 0x15,
  9502. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9503. */
  9504. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9505. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9506. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9507. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9508. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9509. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9510. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9511. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9512. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9513. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9514. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9515. { } /* end */
  9516. };
  9517. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  9518. * Front Mic=0x18, ATAPI Mic = 0x19,
  9519. */
  9520. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  9521. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9522. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9523. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9524. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9525. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9526. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9527. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9528. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9529. { } /* end */
  9530. };
  9531. /*
  9532. * generic initialization of ADC, input mixers and output mixers
  9533. */
  9534. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9535. /*
  9536. * Unmute ADC0 and set the default input to mic-in
  9537. */
  9538. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9539. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9540. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9541. * the analog-loopback mixer widget
  9542. */
  9543. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9544. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9545. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9546. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9547. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9548. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9549. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9550. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9551. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9552. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9553. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9554. /*
  9555. * Set up output mixers (0x02 - 0x05)
  9556. */
  9557. /* set vol=0 to output mixers */
  9558. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9559. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9560. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9561. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9562. /* set up input amps for analog loopback */
  9563. /* Amp Indices: DAC = 0, mixer = 1 */
  9564. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9565. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9566. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9567. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9568. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9569. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9570. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9571. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9572. { }
  9573. };
  9574. /*
  9575. * 3-stack pin configuration:
  9576. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9577. */
  9578. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9579. /*
  9580. * Set pin mode and muting
  9581. */
  9582. /* set front pin widgets 0x14 for output */
  9583. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9584. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9585. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9586. /* Mic (rear) pin: input vref at 80% */
  9587. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9588. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9589. /* Front Mic pin: input vref at 80% */
  9590. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9591. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9592. /* Line In pin: input */
  9593. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9594. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9595. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9596. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9597. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9598. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9599. /* CD pin widget for input */
  9600. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9601. { }
  9602. };
  9603. /*
  9604. * 6-stack pin configuration:
  9605. */
  9606. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9607. /*
  9608. * Set pin mode and muting
  9609. */
  9610. /* set front pin widgets 0x14 for output */
  9611. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9612. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9613. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9614. /* Rear Pin: output 1 (0x0d) */
  9615. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9616. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9617. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9618. /* CLFE Pin: output 2 (0x0e) */
  9619. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9620. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9621. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9622. /* Side Pin: output 3 (0x0f) */
  9623. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9624. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9625. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9626. /* Mic (rear) pin: input vref at 80% */
  9627. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9628. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9629. /* Front Mic pin: input vref at 80% */
  9630. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9631. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9632. /* Line In pin: input */
  9633. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9634. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9635. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9636. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9637. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9638. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9639. /* CD pin widget for input */
  9640. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9641. { }
  9642. };
  9643. static struct hda_verb alc861vd_eapd_verbs[] = {
  9644. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9645. { }
  9646. };
  9647. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9648. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9649. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9650. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9651. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9652. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9653. {}
  9654. };
  9655. /* toggle speaker-output according to the hp-jack state */
  9656. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9657. {
  9658. unsigned int present;
  9659. unsigned char bits;
  9660. present = snd_hda_codec_read(codec, 0x1b, 0,
  9661. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9662. bits = present ? HDA_AMP_MUTE : 0;
  9663. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9664. HDA_AMP_MUTE, bits);
  9665. }
  9666. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9667. {
  9668. unsigned int present;
  9669. unsigned char bits;
  9670. present = snd_hda_codec_read(codec, 0x18, 0,
  9671. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9672. bits = present ? HDA_AMP_MUTE : 0;
  9673. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  9674. HDA_AMP_MUTE, bits);
  9675. }
  9676. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9677. {
  9678. alc861vd_lenovo_hp_automute(codec);
  9679. alc861vd_lenovo_mic_automute(codec);
  9680. }
  9681. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9682. unsigned int res)
  9683. {
  9684. switch (res >> 26) {
  9685. case ALC880_HP_EVENT:
  9686. alc861vd_lenovo_hp_automute(codec);
  9687. break;
  9688. case ALC880_MIC_EVENT:
  9689. alc861vd_lenovo_mic_automute(codec);
  9690. break;
  9691. }
  9692. }
  9693. static struct hda_verb alc861vd_dallas_verbs[] = {
  9694. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9695. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9696. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9697. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9698. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9699. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9700. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9701. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9702. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9703. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9704. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9705. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9706. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9707. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9708. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9709. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9710. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9711. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9712. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9713. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9714. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9715. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9716. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9717. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9718. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9719. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9720. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9721. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9722. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9723. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9724. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9725. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9726. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9727. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9728. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9729. { } /* end */
  9730. };
  9731. /* toggle speaker-output according to the hp-jack state */
  9732. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9733. {
  9734. unsigned int present;
  9735. present = snd_hda_codec_read(codec, 0x15, 0,
  9736. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9737. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9738. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9739. }
  9740. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9741. {
  9742. if ((res >> 26) == ALC880_HP_EVENT)
  9743. alc861vd_dallas_automute(codec);
  9744. }
  9745. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9746. #define alc861vd_loopbacks alc880_loopbacks
  9747. #endif
  9748. /* pcm configuration: identiacal with ALC880 */
  9749. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9750. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9751. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9752. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9753. /*
  9754. * configuration and preset
  9755. */
  9756. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9757. [ALC660VD_3ST] = "3stack-660",
  9758. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  9759. [ALC861VD_3ST] = "3stack",
  9760. [ALC861VD_3ST_DIG] = "3stack-digout",
  9761. [ALC861VD_6ST_DIG] = "6stack-digout",
  9762. [ALC861VD_LENOVO] = "lenovo",
  9763. [ALC861VD_DALLAS] = "dallas",
  9764. [ALC861VD_HP] = "hp",
  9765. [ALC861VD_AUTO] = "auto",
  9766. };
  9767. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9768. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9769. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9770. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9771. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9772. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9773. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  9774. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9775. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9776. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9777. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9778. SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
  9779. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  9780. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  9781. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  9782. {}
  9783. };
  9784. static struct alc_config_preset alc861vd_presets[] = {
  9785. [ALC660VD_3ST] = {
  9786. .mixers = { alc861vd_3st_mixer },
  9787. .init_verbs = { alc861vd_volume_init_verbs,
  9788. alc861vd_3stack_init_verbs },
  9789. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9790. .dac_nids = alc660vd_dac_nids,
  9791. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9792. .adc_nids = alc861vd_adc_nids,
  9793. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9794. .channel_mode = alc861vd_3stack_2ch_modes,
  9795. .input_mux = &alc861vd_capture_source,
  9796. },
  9797. [ALC660VD_3ST_DIG] = {
  9798. .mixers = { alc861vd_3st_mixer },
  9799. .init_verbs = { alc861vd_volume_init_verbs,
  9800. alc861vd_3stack_init_verbs },
  9801. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9802. .dac_nids = alc660vd_dac_nids,
  9803. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9804. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9805. .adc_nids = alc861vd_adc_nids,
  9806. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9807. .channel_mode = alc861vd_3stack_2ch_modes,
  9808. .input_mux = &alc861vd_capture_source,
  9809. },
  9810. [ALC861VD_3ST] = {
  9811. .mixers = { alc861vd_3st_mixer },
  9812. .init_verbs = { alc861vd_volume_init_verbs,
  9813. alc861vd_3stack_init_verbs },
  9814. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9815. .dac_nids = alc861vd_dac_nids,
  9816. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9817. .channel_mode = alc861vd_3stack_2ch_modes,
  9818. .input_mux = &alc861vd_capture_source,
  9819. },
  9820. [ALC861VD_3ST_DIG] = {
  9821. .mixers = { alc861vd_3st_mixer },
  9822. .init_verbs = { alc861vd_volume_init_verbs,
  9823. alc861vd_3stack_init_verbs },
  9824. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9825. .dac_nids = alc861vd_dac_nids,
  9826. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9827. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9828. .channel_mode = alc861vd_3stack_2ch_modes,
  9829. .input_mux = &alc861vd_capture_source,
  9830. },
  9831. [ALC861VD_6ST_DIG] = {
  9832. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9833. .init_verbs = { alc861vd_volume_init_verbs,
  9834. alc861vd_6stack_init_verbs },
  9835. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9836. .dac_nids = alc861vd_dac_nids,
  9837. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9838. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9839. .channel_mode = alc861vd_6stack_modes,
  9840. .input_mux = &alc861vd_capture_source,
  9841. },
  9842. [ALC861VD_LENOVO] = {
  9843. .mixers = { alc861vd_lenovo_mixer },
  9844. .init_verbs = { alc861vd_volume_init_verbs,
  9845. alc861vd_3stack_init_verbs,
  9846. alc861vd_eapd_verbs,
  9847. alc861vd_lenovo_unsol_verbs },
  9848. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9849. .dac_nids = alc660vd_dac_nids,
  9850. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9851. .adc_nids = alc861vd_adc_nids,
  9852. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9853. .channel_mode = alc861vd_3stack_2ch_modes,
  9854. .input_mux = &alc861vd_capture_source,
  9855. .unsol_event = alc861vd_lenovo_unsol_event,
  9856. .init_hook = alc861vd_lenovo_automute,
  9857. },
  9858. [ALC861VD_DALLAS] = {
  9859. .mixers = { alc861vd_dallas_mixer },
  9860. .init_verbs = { alc861vd_dallas_verbs },
  9861. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9862. .dac_nids = alc861vd_dac_nids,
  9863. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9864. .adc_nids = alc861vd_adc_nids,
  9865. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9866. .channel_mode = alc861vd_3stack_2ch_modes,
  9867. .input_mux = &alc861vd_dallas_capture_source,
  9868. .unsol_event = alc861vd_dallas_unsol_event,
  9869. .init_hook = alc861vd_dallas_automute,
  9870. },
  9871. [ALC861VD_HP] = {
  9872. .mixers = { alc861vd_hp_mixer },
  9873. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  9874. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9875. .dac_nids = alc861vd_dac_nids,
  9876. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9877. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9878. .adc_nids = alc861vd_adc_nids,
  9879. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9880. .channel_mode = alc861vd_3stack_2ch_modes,
  9881. .input_mux = &alc861vd_hp_capture_source,
  9882. .unsol_event = alc861vd_dallas_unsol_event,
  9883. .init_hook = alc861vd_dallas_automute,
  9884. },
  9885. };
  9886. /*
  9887. * BIOS auto configuration
  9888. */
  9889. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9890. hda_nid_t nid, int pin_type, int dac_idx)
  9891. {
  9892. /* set as output */
  9893. snd_hda_codec_write(codec, nid, 0,
  9894. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9895. snd_hda_codec_write(codec, nid, 0,
  9896. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9897. }
  9898. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9899. {
  9900. struct alc_spec *spec = codec->spec;
  9901. int i;
  9902. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9903. for (i = 0; i <= HDA_SIDE; i++) {
  9904. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9905. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9906. if (nid)
  9907. alc861vd_auto_set_output_and_unmute(codec, nid,
  9908. pin_type, i);
  9909. }
  9910. }
  9911. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9912. {
  9913. struct alc_spec *spec = codec->spec;
  9914. hda_nid_t pin;
  9915. pin = spec->autocfg.hp_pins[0];
  9916. if (pin) /* connect to front and use dac 0 */
  9917. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9918. }
  9919. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9920. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9921. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9922. {
  9923. struct alc_spec *spec = codec->spec;
  9924. int i;
  9925. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9926. hda_nid_t nid = spec->autocfg.input_pins[i];
  9927. if (alc861vd_is_input_pin(nid)) {
  9928. snd_hda_codec_write(codec, nid, 0,
  9929. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9930. i <= AUTO_PIN_FRONT_MIC ?
  9931. PIN_VREF80 : PIN_IN);
  9932. if (nid != ALC861VD_PIN_CD_NID)
  9933. snd_hda_codec_write(codec, nid, 0,
  9934. AC_VERB_SET_AMP_GAIN_MUTE,
  9935. AMP_OUT_MUTE);
  9936. }
  9937. }
  9938. }
  9939. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9940. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9941. /* add playback controls from the parsed DAC table */
  9942. /* Based on ALC880 version. But ALC861VD has separate,
  9943. * different NIDs for mute/unmute switch and volume control */
  9944. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9945. const struct auto_pin_cfg *cfg)
  9946. {
  9947. char name[32];
  9948. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9949. hda_nid_t nid_v, nid_s;
  9950. int i, err;
  9951. for (i = 0; i < cfg->line_outs; i++) {
  9952. if (!spec->multiout.dac_nids[i])
  9953. continue;
  9954. nid_v = alc861vd_idx_to_mixer_vol(
  9955. alc880_dac_to_idx(
  9956. spec->multiout.dac_nids[i]));
  9957. nid_s = alc861vd_idx_to_mixer_switch(
  9958. alc880_dac_to_idx(
  9959. spec->multiout.dac_nids[i]));
  9960. if (i == 2) {
  9961. /* Center/LFE */
  9962. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9963. "Center Playback Volume",
  9964. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9965. HDA_OUTPUT));
  9966. if (err < 0)
  9967. return err;
  9968. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9969. "LFE Playback Volume",
  9970. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9971. HDA_OUTPUT));
  9972. if (err < 0)
  9973. return err;
  9974. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9975. "Center Playback Switch",
  9976. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9977. HDA_INPUT));
  9978. if (err < 0)
  9979. return err;
  9980. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9981. "LFE Playback Switch",
  9982. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9983. HDA_INPUT));
  9984. if (err < 0)
  9985. return err;
  9986. } else {
  9987. sprintf(name, "%s Playback Volume", chname[i]);
  9988. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9989. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9990. HDA_OUTPUT));
  9991. if (err < 0)
  9992. return err;
  9993. sprintf(name, "%s Playback Switch", chname[i]);
  9994. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9995. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9996. HDA_INPUT));
  9997. if (err < 0)
  9998. return err;
  9999. }
  10000. }
  10001. return 0;
  10002. }
  10003. /* add playback controls for speaker and HP outputs */
  10004. /* Based on ALC880 version. But ALC861VD has separate,
  10005. * different NIDs for mute/unmute switch and volume control */
  10006. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  10007. hda_nid_t pin, const char *pfx)
  10008. {
  10009. hda_nid_t nid_v, nid_s;
  10010. int err;
  10011. char name[32];
  10012. if (!pin)
  10013. return 0;
  10014. if (alc880_is_fixed_pin(pin)) {
  10015. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10016. /* specify the DAC as the extra output */
  10017. if (!spec->multiout.hp_nid)
  10018. spec->multiout.hp_nid = nid_v;
  10019. else
  10020. spec->multiout.extra_out_nid[0] = nid_v;
  10021. /* control HP volume/switch on the output mixer amp */
  10022. nid_v = alc861vd_idx_to_mixer_vol(
  10023. alc880_fixed_pin_idx(pin));
  10024. nid_s = alc861vd_idx_to_mixer_switch(
  10025. alc880_fixed_pin_idx(pin));
  10026. sprintf(name, "%s Playback Volume", pfx);
  10027. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10028. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  10029. if (err < 0)
  10030. return err;
  10031. sprintf(name, "%s Playback Switch", pfx);
  10032. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10033. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  10034. if (err < 0)
  10035. return err;
  10036. } else if (alc880_is_multi_pin(pin)) {
  10037. /* set manual connection */
  10038. /* we have only a switch on HP-out PIN */
  10039. sprintf(name, "%s Playback Switch", pfx);
  10040. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10041. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10042. if (err < 0)
  10043. return err;
  10044. }
  10045. return 0;
  10046. }
  10047. /* parse the BIOS configuration and set up the alc_spec
  10048. * return 1 if successful, 0 if the proper config is not found,
  10049. * or a negative error code
  10050. * Based on ALC880 version - had to change it to override
  10051. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  10052. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  10053. {
  10054. struct alc_spec *spec = codec->spec;
  10055. int err;
  10056. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  10057. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10058. alc861vd_ignore);
  10059. if (err < 0)
  10060. return err;
  10061. if (!spec->autocfg.line_outs)
  10062. return 0; /* can't find valid BIOS pin config */
  10063. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10064. if (err < 0)
  10065. return err;
  10066. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10067. if (err < 0)
  10068. return err;
  10069. err = alc861vd_auto_create_extra_out(spec,
  10070. spec->autocfg.speaker_pins[0],
  10071. "Speaker");
  10072. if (err < 0)
  10073. return err;
  10074. err = alc861vd_auto_create_extra_out(spec,
  10075. spec->autocfg.hp_pins[0],
  10076. "Headphone");
  10077. if (err < 0)
  10078. return err;
  10079. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10080. if (err < 0)
  10081. return err;
  10082. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10083. if (spec->autocfg.dig_out_pin)
  10084. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  10085. if (spec->kctl_alloc)
  10086. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10087. spec->init_verbs[spec->num_init_verbs++]
  10088. = alc861vd_volume_init_verbs;
  10089. spec->num_mux_defs = 1;
  10090. spec->input_mux = &spec->private_imux;
  10091. return 1;
  10092. }
  10093. /* additional initialization for auto-configuration model */
  10094. static void alc861vd_auto_init(struct hda_codec *codec)
  10095. {
  10096. alc861vd_auto_init_multi_out(codec);
  10097. alc861vd_auto_init_hp_out(codec);
  10098. alc861vd_auto_init_analog_input(codec);
  10099. }
  10100. static int patch_alc861vd(struct hda_codec *codec)
  10101. {
  10102. struct alc_spec *spec;
  10103. int err, board_config;
  10104. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10105. if (spec == NULL)
  10106. return -ENOMEM;
  10107. codec->spec = spec;
  10108. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  10109. alc861vd_models,
  10110. alc861vd_cfg_tbl);
  10111. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  10112. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  10113. "ALC861VD, trying auto-probe from BIOS...\n");
  10114. board_config = ALC861VD_AUTO;
  10115. }
  10116. if (board_config == ALC861VD_AUTO) {
  10117. /* automatic parse from the BIOS config */
  10118. err = alc861vd_parse_auto_config(codec);
  10119. if (err < 0) {
  10120. alc_free(codec);
  10121. return err;
  10122. } else if (!err) {
  10123. printk(KERN_INFO
  10124. "hda_codec: Cannot set up configuration "
  10125. "from BIOS. Using base mode...\n");
  10126. board_config = ALC861VD_3ST;
  10127. }
  10128. }
  10129. if (board_config != ALC861VD_AUTO)
  10130. setup_preset(spec, &alc861vd_presets[board_config]);
  10131. spec->stream_name_analog = "ALC861VD Analog";
  10132. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10133. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10134. spec->stream_name_digital = "ALC861VD Digital";
  10135. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10136. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10137. spec->adc_nids = alc861vd_adc_nids;
  10138. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10139. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10140. spec->num_mixers++;
  10141. codec->patch_ops = alc_patch_ops;
  10142. if (board_config == ALC861VD_AUTO)
  10143. spec->init_hook = alc861vd_auto_init;
  10144. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10145. if (!spec->loopback.amplist)
  10146. spec->loopback.amplist = alc861vd_loopbacks;
  10147. #endif
  10148. return 0;
  10149. }
  10150. /*
  10151. * ALC662 support
  10152. *
  10153. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  10154. * configuration. Each pin widget can choose any input DACs and a mixer.
  10155. * Each ADC is connected from a mixer of all inputs. This makes possible
  10156. * 6-channel independent captures.
  10157. *
  10158. * In addition, an independent DAC for the multi-playback (not used in this
  10159. * driver yet).
  10160. */
  10161. #define ALC662_DIGOUT_NID 0x06
  10162. #define ALC662_DIGIN_NID 0x0a
  10163. static hda_nid_t alc662_dac_nids[4] = {
  10164. /* front, rear, clfe, rear_surr */
  10165. 0x02, 0x03, 0x04
  10166. };
  10167. static hda_nid_t alc662_adc_nids[1] = {
  10168. /* ADC1-2 */
  10169. 0x09,
  10170. };
  10171. /* input MUX */
  10172. /* FIXME: should be a matrix-type input source selection */
  10173. static struct hda_input_mux alc662_capture_source = {
  10174. .num_items = 4,
  10175. .items = {
  10176. { "Mic", 0x0 },
  10177. { "Front Mic", 0x1 },
  10178. { "Line", 0x2 },
  10179. { "CD", 0x4 },
  10180. },
  10181. };
  10182. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  10183. .num_items = 2,
  10184. .items = {
  10185. { "Mic", 0x1 },
  10186. { "Line", 0x2 },
  10187. },
  10188. };
  10189. #define alc662_mux_enum_info alc_mux_enum_info
  10190. #define alc662_mux_enum_get alc_mux_enum_get
  10191. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  10192. struct snd_ctl_elem_value *ucontrol)
  10193. {
  10194. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10195. struct alc_spec *spec = codec->spec;
  10196. const struct hda_input_mux *imux = spec->input_mux;
  10197. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10198. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  10199. hda_nid_t nid = capture_mixers[adc_idx];
  10200. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10201. unsigned int i, idx;
  10202. idx = ucontrol->value.enumerated.item[0];
  10203. if (idx >= imux->num_items)
  10204. idx = imux->num_items - 1;
  10205. if (*cur_val == idx)
  10206. return 0;
  10207. for (i = 0; i < imux->num_items; i++) {
  10208. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10209. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10210. imux->items[i].index,
  10211. HDA_AMP_MUTE, v);
  10212. }
  10213. *cur_val = idx;
  10214. return 1;
  10215. }
  10216. /*
  10217. * 2ch mode
  10218. */
  10219. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  10220. { 2, NULL }
  10221. };
  10222. /*
  10223. * 2ch mode
  10224. */
  10225. static struct hda_verb alc662_3ST_ch2_init[] = {
  10226. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  10227. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10228. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  10229. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10230. { } /* end */
  10231. };
  10232. /*
  10233. * 6ch mode
  10234. */
  10235. static struct hda_verb alc662_3ST_ch6_init[] = {
  10236. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10237. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10238. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  10239. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10240. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10241. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  10242. { } /* end */
  10243. };
  10244. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  10245. { 2, alc662_3ST_ch2_init },
  10246. { 6, alc662_3ST_ch6_init },
  10247. };
  10248. /*
  10249. * 2ch mode
  10250. */
  10251. static struct hda_verb alc662_sixstack_ch6_init[] = {
  10252. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10253. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10254. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10255. { } /* end */
  10256. };
  10257. /*
  10258. * 6ch mode
  10259. */
  10260. static struct hda_verb alc662_sixstack_ch8_init[] = {
  10261. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10262. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10263. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10264. { } /* end */
  10265. };
  10266. static struct hda_channel_mode alc662_5stack_modes[2] = {
  10267. { 2, alc662_sixstack_ch6_init },
  10268. { 6, alc662_sixstack_ch8_init },
  10269. };
  10270. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10271. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10272. */
  10273. static struct snd_kcontrol_new alc662_base_mixer[] = {
  10274. /* output mixer control */
  10275. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  10276. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  10277. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  10278. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  10279. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10280. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10281. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10282. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10283. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10284. /*Input mixer control */
  10285. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  10286. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  10287. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  10288. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  10289. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  10290. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  10291. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  10292. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  10293. /* Capture mixer control */
  10294. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10295. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10296. {
  10297. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10298. .name = "Capture Source",
  10299. .count = 1,
  10300. .info = alc_mux_enum_info,
  10301. .get = alc_mux_enum_get,
  10302. .put = alc_mux_enum_put,
  10303. },
  10304. { } /* end */
  10305. };
  10306. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  10307. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10308. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10309. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10310. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10311. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10312. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10313. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10314. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10315. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10316. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10317. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10318. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10319. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10320. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10321. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10322. {
  10323. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10324. /* .name = "Capture Source", */
  10325. .name = "Input Source",
  10326. .count = 1,
  10327. .info = alc662_mux_enum_info,
  10328. .get = alc662_mux_enum_get,
  10329. .put = alc662_mux_enum_put,
  10330. },
  10331. { } /* end */
  10332. };
  10333. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  10334. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10335. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10336. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10337. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  10338. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10339. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10340. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10341. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10342. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10343. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10344. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10345. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10346. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10347. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10348. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10349. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10350. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10351. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10352. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10353. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10354. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10355. {
  10356. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10357. /* .name = "Capture Source", */
  10358. .name = "Input Source",
  10359. .count = 1,
  10360. .info = alc662_mux_enum_info,
  10361. .get = alc662_mux_enum_get,
  10362. .put = alc662_mux_enum_put,
  10363. },
  10364. { } /* end */
  10365. };
  10366. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  10367. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10368. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10369. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10370. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  10371. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10372. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10373. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10374. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10375. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10376. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10377. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10378. {
  10379. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10380. /* .name = "Capture Source", */
  10381. .name = "Input Source",
  10382. .count = 1,
  10383. .info = alc662_mux_enum_info,
  10384. .get = alc662_mux_enum_get,
  10385. .put = alc662_mux_enum_put,
  10386. },
  10387. { } /* end */
  10388. };
  10389. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  10390. {
  10391. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10392. .name = "Channel Mode",
  10393. .info = alc_ch_mode_info,
  10394. .get = alc_ch_mode_get,
  10395. .put = alc_ch_mode_put,
  10396. },
  10397. { } /* end */
  10398. };
  10399. static struct hda_verb alc662_init_verbs[] = {
  10400. /* ADC: mute amp left and right */
  10401. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10402. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10403. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10404. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10405. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10406. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10407. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10408. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10409. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10410. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10411. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10412. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10413. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10414. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10415. /* Front Pin: output 0 (0x0c) */
  10416. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10417. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10418. /* Rear Pin: output 1 (0x0d) */
  10419. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10420. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10421. /* CLFE Pin: output 2 (0x0e) */
  10422. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10423. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10424. /* Mic (rear) pin: input vref at 80% */
  10425. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10426. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10427. /* Front Mic pin: input vref at 80% */
  10428. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10429. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10430. /* Line In pin: input */
  10431. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10432. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10433. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10434. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10435. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10436. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10437. /* CD pin widget for input */
  10438. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10439. /* FIXME: use matrix-type input source selection */
  10440. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10441. /* Input mixer */
  10442. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10443. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10444. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10445. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10446. { }
  10447. };
  10448. static struct hda_verb alc662_sue_init_verbs[] = {
  10449. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10450. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10451. {}
  10452. };
  10453. /*
  10454. * generic initialization of ADC, input mixers and output mixers
  10455. */
  10456. static struct hda_verb alc662_auto_init_verbs[] = {
  10457. /*
  10458. * Unmute ADC and set the default input to mic-in
  10459. */
  10460. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10461. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10462. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10463. * mixer widget
  10464. * Note: PASD motherboards uses the Line In 2 as the input for front
  10465. * panel mic (mic 2)
  10466. */
  10467. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10468. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10469. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10470. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10471. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10472. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10473. /*
  10474. * Set up output mixers (0x0c - 0x0f)
  10475. */
  10476. /* set vol=0 to output mixers */
  10477. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10478. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10479. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10480. /* set up input amps for analog loopback */
  10481. /* Amp Indices: DAC = 0, mixer = 1 */
  10482. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10483. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10484. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10485. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10486. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10487. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10488. /* FIXME: use matrix-type input source selection */
  10489. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10490. /* Input mixer */
  10491. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10492. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10493. { }
  10494. };
  10495. /* capture mixer elements */
  10496. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10497. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10498. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10499. {
  10500. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10501. /* The multiple "Capture Source" controls confuse alsamixer
  10502. * So call somewhat different..
  10503. * FIXME: the controls appear in the "playback" view!
  10504. */
  10505. /* .name = "Capture Source", */
  10506. .name = "Input Source",
  10507. .count = 1,
  10508. .info = alc882_mux_enum_info,
  10509. .get = alc882_mux_enum_get,
  10510. .put = alc882_mux_enum_put,
  10511. },
  10512. { } /* end */
  10513. };
  10514. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10515. {
  10516. unsigned int present;
  10517. unsigned char bits;
  10518. present = snd_hda_codec_read(codec, 0x14, 0,
  10519. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10520. bits = present ? HDA_AMP_MUTE : 0;
  10521. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10522. HDA_AMP_MUTE, bits);
  10523. }
  10524. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10525. {
  10526. unsigned int present;
  10527. unsigned char bits;
  10528. present = snd_hda_codec_read(codec, 0x1b, 0,
  10529. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10530. bits = present ? HDA_AMP_MUTE : 0;
  10531. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10532. HDA_AMP_MUTE, bits);
  10533. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10534. HDA_AMP_MUTE, bits);
  10535. }
  10536. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10537. unsigned int res)
  10538. {
  10539. if ((res >> 26) == ALC880_HP_EVENT)
  10540. alc662_lenovo_101e_all_automute(codec);
  10541. if ((res >> 26) == ALC880_FRONT_EVENT)
  10542. alc662_lenovo_101e_ispeaker_automute(codec);
  10543. }
  10544. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10545. #define alc662_loopbacks alc880_loopbacks
  10546. #endif
  10547. /* pcm configuration: identiacal with ALC880 */
  10548. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10549. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10550. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10551. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10552. /*
  10553. * configuration and preset
  10554. */
  10555. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10556. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10557. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10558. [ALC662_3ST_6ch] = "3stack-6ch",
  10559. [ALC662_5ST_DIG] = "6stack-dig",
  10560. [ALC662_LENOVO_101E] = "lenovo-101e",
  10561. [ALC662_AUTO] = "auto",
  10562. };
  10563. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10564. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10565. {}
  10566. };
  10567. static struct alc_config_preset alc662_presets[] = {
  10568. [ALC662_3ST_2ch_DIG] = {
  10569. .mixers = { alc662_3ST_2ch_mixer },
  10570. .init_verbs = { alc662_init_verbs },
  10571. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10572. .dac_nids = alc662_dac_nids,
  10573. .dig_out_nid = ALC662_DIGOUT_NID,
  10574. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10575. .adc_nids = alc662_adc_nids,
  10576. .dig_in_nid = ALC662_DIGIN_NID,
  10577. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10578. .channel_mode = alc662_3ST_2ch_modes,
  10579. .input_mux = &alc662_capture_source,
  10580. },
  10581. [ALC662_3ST_6ch_DIG] = {
  10582. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10583. .init_verbs = { alc662_init_verbs },
  10584. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10585. .dac_nids = alc662_dac_nids,
  10586. .dig_out_nid = ALC662_DIGOUT_NID,
  10587. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10588. .adc_nids = alc662_adc_nids,
  10589. .dig_in_nid = ALC662_DIGIN_NID,
  10590. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10591. .channel_mode = alc662_3ST_6ch_modes,
  10592. .need_dac_fix = 1,
  10593. .input_mux = &alc662_capture_source,
  10594. },
  10595. [ALC662_3ST_6ch] = {
  10596. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10597. .init_verbs = { alc662_init_verbs },
  10598. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10599. .dac_nids = alc662_dac_nids,
  10600. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10601. .adc_nids = alc662_adc_nids,
  10602. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10603. .channel_mode = alc662_3ST_6ch_modes,
  10604. .need_dac_fix = 1,
  10605. .input_mux = &alc662_capture_source,
  10606. },
  10607. [ALC662_5ST_DIG] = {
  10608. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10609. .init_verbs = { alc662_init_verbs },
  10610. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10611. .dac_nids = alc662_dac_nids,
  10612. .dig_out_nid = ALC662_DIGOUT_NID,
  10613. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10614. .adc_nids = alc662_adc_nids,
  10615. .dig_in_nid = ALC662_DIGIN_NID,
  10616. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10617. .channel_mode = alc662_5stack_modes,
  10618. .input_mux = &alc662_capture_source,
  10619. },
  10620. [ALC662_LENOVO_101E] = {
  10621. .mixers = { alc662_lenovo_101e_mixer },
  10622. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10623. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10624. .dac_nids = alc662_dac_nids,
  10625. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10626. .adc_nids = alc662_adc_nids,
  10627. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10628. .channel_mode = alc662_3ST_2ch_modes,
  10629. .input_mux = &alc662_lenovo_101e_capture_source,
  10630. .unsol_event = alc662_lenovo_101e_unsol_event,
  10631. .init_hook = alc662_lenovo_101e_all_automute,
  10632. },
  10633. };
  10634. /*
  10635. * BIOS auto configuration
  10636. */
  10637. /* add playback controls from the parsed DAC table */
  10638. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10639. const struct auto_pin_cfg *cfg)
  10640. {
  10641. char name[32];
  10642. static const char *chname[4] = {
  10643. "Front", "Surround", NULL /*CLFE*/, "Side"
  10644. };
  10645. hda_nid_t nid;
  10646. int i, err;
  10647. for (i = 0; i < cfg->line_outs; i++) {
  10648. if (!spec->multiout.dac_nids[i])
  10649. continue;
  10650. nid = alc880_idx_to_mixer(i);
  10651. if (i == 2) {
  10652. /* Center/LFE */
  10653. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10654. "Center Playback Volume",
  10655. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10656. HDA_OUTPUT));
  10657. if (err < 0)
  10658. return err;
  10659. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10660. "LFE Playback Volume",
  10661. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10662. HDA_OUTPUT));
  10663. if (err < 0)
  10664. return err;
  10665. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10666. "Center Playback Switch",
  10667. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10668. HDA_INPUT));
  10669. if (err < 0)
  10670. return err;
  10671. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10672. "LFE Playback Switch",
  10673. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10674. HDA_INPUT));
  10675. if (err < 0)
  10676. return err;
  10677. } else {
  10678. sprintf(name, "%s Playback Volume", chname[i]);
  10679. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10680. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10681. HDA_OUTPUT));
  10682. if (err < 0)
  10683. return err;
  10684. sprintf(name, "%s Playback Switch", chname[i]);
  10685. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10686. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10687. HDA_INPUT));
  10688. if (err < 0)
  10689. return err;
  10690. }
  10691. }
  10692. return 0;
  10693. }
  10694. /* add playback controls for speaker and HP outputs */
  10695. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10696. const char *pfx)
  10697. {
  10698. hda_nid_t nid;
  10699. int err;
  10700. char name[32];
  10701. if (!pin)
  10702. return 0;
  10703. if (alc880_is_fixed_pin(pin)) {
  10704. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10705. /* printk("DAC nid=%x\n",nid); */
  10706. /* specify the DAC as the extra output */
  10707. if (!spec->multiout.hp_nid)
  10708. spec->multiout.hp_nid = nid;
  10709. else
  10710. spec->multiout.extra_out_nid[0] = nid;
  10711. /* control HP volume/switch on the output mixer amp */
  10712. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10713. sprintf(name, "%s Playback Volume", pfx);
  10714. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10715. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10716. if (err < 0)
  10717. return err;
  10718. sprintf(name, "%s Playback Switch", pfx);
  10719. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10720. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10721. if (err < 0)
  10722. return err;
  10723. } else if (alc880_is_multi_pin(pin)) {
  10724. /* set manual connection */
  10725. /* we have only a switch on HP-out PIN */
  10726. sprintf(name, "%s Playback Switch", pfx);
  10727. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10728. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10729. if (err < 0)
  10730. return err;
  10731. }
  10732. return 0;
  10733. }
  10734. /* create playback/capture controls for input pins */
  10735. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10736. const struct auto_pin_cfg *cfg)
  10737. {
  10738. struct hda_input_mux *imux = &spec->private_imux;
  10739. int i, err, idx;
  10740. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10741. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10742. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10743. err = new_analog_input(spec, cfg->input_pins[i],
  10744. auto_pin_cfg_labels[i],
  10745. idx, 0x0b);
  10746. if (err < 0)
  10747. return err;
  10748. imux->items[imux->num_items].label =
  10749. auto_pin_cfg_labels[i];
  10750. imux->items[imux->num_items].index =
  10751. alc880_input_pin_idx(cfg->input_pins[i]);
  10752. imux->num_items++;
  10753. }
  10754. }
  10755. return 0;
  10756. }
  10757. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10758. hda_nid_t nid, int pin_type,
  10759. int dac_idx)
  10760. {
  10761. /* set as output */
  10762. snd_hda_codec_write(codec, nid, 0,
  10763. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10764. snd_hda_codec_write(codec, nid, 0,
  10765. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10766. /* need the manual connection? */
  10767. if (alc880_is_multi_pin(nid)) {
  10768. struct alc_spec *spec = codec->spec;
  10769. int idx = alc880_multi_pin_idx(nid);
  10770. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10771. AC_VERB_SET_CONNECT_SEL,
  10772. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10773. }
  10774. }
  10775. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10776. {
  10777. struct alc_spec *spec = codec->spec;
  10778. int i;
  10779. for (i = 0; i <= HDA_SIDE; i++) {
  10780. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10781. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10782. if (nid)
  10783. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10784. i);
  10785. }
  10786. }
  10787. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10788. {
  10789. struct alc_spec *spec = codec->spec;
  10790. hda_nid_t pin;
  10791. pin = spec->autocfg.hp_pins[0];
  10792. if (pin) /* connect to front */
  10793. /* use dac 0 */
  10794. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10795. }
  10796. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10797. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10798. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10799. {
  10800. struct alc_spec *spec = codec->spec;
  10801. int i;
  10802. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10803. hda_nid_t nid = spec->autocfg.input_pins[i];
  10804. if (alc662_is_input_pin(nid)) {
  10805. snd_hda_codec_write(codec, nid, 0,
  10806. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10807. (i <= AUTO_PIN_FRONT_MIC ?
  10808. PIN_VREF80 : PIN_IN));
  10809. if (nid != ALC662_PIN_CD_NID)
  10810. snd_hda_codec_write(codec, nid, 0,
  10811. AC_VERB_SET_AMP_GAIN_MUTE,
  10812. AMP_OUT_MUTE);
  10813. }
  10814. }
  10815. }
  10816. static int alc662_parse_auto_config(struct hda_codec *codec)
  10817. {
  10818. struct alc_spec *spec = codec->spec;
  10819. int err;
  10820. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10821. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10822. alc662_ignore);
  10823. if (err < 0)
  10824. return err;
  10825. if (!spec->autocfg.line_outs)
  10826. return 0; /* can't find valid BIOS pin config */
  10827. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10828. if (err < 0)
  10829. return err;
  10830. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10831. if (err < 0)
  10832. return err;
  10833. err = alc662_auto_create_extra_out(spec,
  10834. spec->autocfg.speaker_pins[0],
  10835. "Speaker");
  10836. if (err < 0)
  10837. return err;
  10838. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10839. "Headphone");
  10840. if (err < 0)
  10841. return err;
  10842. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10843. if (err < 0)
  10844. return err;
  10845. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10846. if (spec->autocfg.dig_out_pin)
  10847. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10848. if (spec->kctl_alloc)
  10849. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10850. spec->num_mux_defs = 1;
  10851. spec->input_mux = &spec->private_imux;
  10852. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10853. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10854. spec->num_mixers++;
  10855. return 1;
  10856. }
  10857. /* additional initialization for auto-configuration model */
  10858. static void alc662_auto_init(struct hda_codec *codec)
  10859. {
  10860. alc662_auto_init_multi_out(codec);
  10861. alc662_auto_init_hp_out(codec);
  10862. alc662_auto_init_analog_input(codec);
  10863. }
  10864. static int patch_alc662(struct hda_codec *codec)
  10865. {
  10866. struct alc_spec *spec;
  10867. int err, board_config;
  10868. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10869. if (!spec)
  10870. return -ENOMEM;
  10871. codec->spec = spec;
  10872. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10873. alc662_models,
  10874. alc662_cfg_tbl);
  10875. if (board_config < 0) {
  10876. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10877. "trying auto-probe from BIOS...\n");
  10878. board_config = ALC662_AUTO;
  10879. }
  10880. if (board_config == ALC662_AUTO) {
  10881. /* automatic parse from the BIOS config */
  10882. err = alc662_parse_auto_config(codec);
  10883. if (err < 0) {
  10884. alc_free(codec);
  10885. return err;
  10886. } else if (!err) {
  10887. printk(KERN_INFO
  10888. "hda_codec: Cannot set up configuration "
  10889. "from BIOS. Using base mode...\n");
  10890. board_config = ALC662_3ST_2ch_DIG;
  10891. }
  10892. }
  10893. if (board_config != ALC662_AUTO)
  10894. setup_preset(spec, &alc662_presets[board_config]);
  10895. spec->stream_name_analog = "ALC662 Analog";
  10896. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10897. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10898. spec->stream_name_digital = "ALC662 Digital";
  10899. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10900. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10901. if (!spec->adc_nids && spec->input_mux) {
  10902. spec->adc_nids = alc662_adc_nids;
  10903. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10904. }
  10905. codec->patch_ops = alc_patch_ops;
  10906. if (board_config == ALC662_AUTO)
  10907. spec->init_hook = alc662_auto_init;
  10908. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10909. if (!spec->loopback.amplist)
  10910. spec->loopback.amplist = alc662_loopbacks;
  10911. #endif
  10912. return 0;
  10913. }
  10914. /*
  10915. * patch entries
  10916. */
  10917. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10918. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10919. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10920. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10921. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10922. .patch = patch_alc861 },
  10923. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10924. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10925. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10926. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10927. .patch = patch_alc883 },
  10928. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10929. .patch = patch_alc662 },
  10930. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10931. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10932. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10933. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10934. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10935. {} /* terminator */
  10936. };