patch_realtek.c 412 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495
  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_ASUS_EEEPC_P701,
  138. ALC662_AUTO,
  139. ALC662_MODEL_LAST,
  140. };
  141. /* ALC882 models */
  142. enum {
  143. ALC882_3ST_DIG,
  144. ALC882_6ST_DIG,
  145. ALC882_ARIMA,
  146. ALC882_W2JC,
  147. ALC882_TARGA,
  148. ALC882_ASUS_A7J,
  149. ALC882_ASUS_A7M,
  150. ALC885_MACPRO,
  151. ALC885_MBP3,
  152. ALC885_IMAC24,
  153. ALC882_AUTO,
  154. ALC882_MODEL_LAST,
  155. };
  156. /* ALC883 models */
  157. enum {
  158. ALC883_3ST_2ch_DIG,
  159. ALC883_3ST_6ch_DIG,
  160. ALC883_3ST_6ch,
  161. ALC883_6ST_DIG,
  162. ALC883_TARGA_DIG,
  163. ALC883_TARGA_2ch_DIG,
  164. ALC883_ACER,
  165. ALC883_ACER_ASPIRE,
  166. ALC883_MEDION,
  167. ALC883_MEDION_MD2,
  168. ALC883_LAPTOP_EAPD,
  169. ALC883_LENOVO_101E_2ch,
  170. ALC883_LENOVO_NB0763,
  171. ALC888_LENOVO_MS7195_DIG,
  172. ALC883_HAIER_W66,
  173. ALC888_6ST_HP,
  174. ALC888_3ST_HP,
  175. ALC883_AUTO,
  176. ALC883_MODEL_LAST,
  177. };
  178. /* for GPIO Poll */
  179. #define GPIO_MASK 0x03
  180. struct alc_spec {
  181. /* codec parameterization */
  182. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  183. unsigned int num_mixers;
  184. const struct hda_verb *init_verbs[5]; /* initialization verbs
  185. * don't forget NULL
  186. * termination!
  187. */
  188. unsigned int num_init_verbs;
  189. char *stream_name_analog; /* analog PCM stream */
  190. struct hda_pcm_stream *stream_analog_playback;
  191. struct hda_pcm_stream *stream_analog_capture;
  192. char *stream_name_digital; /* digital PCM stream */
  193. struct hda_pcm_stream *stream_digital_playback;
  194. struct hda_pcm_stream *stream_digital_capture;
  195. /* playback */
  196. struct hda_multi_out multiout; /* playback set-up
  197. * max_channels, dacs must be set
  198. * dig_out_nid and hp_nid are optional
  199. */
  200. /* capture */
  201. unsigned int num_adc_nids;
  202. hda_nid_t *adc_nids;
  203. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  204. /* capture source */
  205. unsigned int num_mux_defs;
  206. const struct hda_input_mux *input_mux;
  207. unsigned int cur_mux[3];
  208. /* channel model */
  209. const struct hda_channel_mode *channel_mode;
  210. int num_channel_mode;
  211. int need_dac_fix;
  212. /* PCM information */
  213. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  214. /* dynamic controls, init_verbs and input_mux */
  215. struct auto_pin_cfg autocfg;
  216. unsigned int num_kctl_alloc, num_kctl_used;
  217. struct snd_kcontrol_new *kctl_alloc;
  218. struct hda_input_mux private_imux;
  219. hda_nid_t private_dac_nids[5];
  220. /* hooks */
  221. void (*init_hook)(struct hda_codec *codec);
  222. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  223. /* for pin sensing */
  224. unsigned int sense_updated: 1;
  225. unsigned int jack_present: 1;
  226. #ifdef CONFIG_SND_HDA_POWER_SAVE
  227. struct hda_loopback_check loopback;
  228. #endif
  229. };
  230. /*
  231. * configuration template - to be copied to the spec instance
  232. */
  233. struct alc_config_preset {
  234. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  235. * with spec
  236. */
  237. const struct hda_verb *init_verbs[5];
  238. unsigned int num_dacs;
  239. hda_nid_t *dac_nids;
  240. hda_nid_t dig_out_nid; /* optional */
  241. hda_nid_t hp_nid; /* optional */
  242. unsigned int num_adc_nids;
  243. hda_nid_t *adc_nids;
  244. hda_nid_t dig_in_nid;
  245. unsigned int num_channel_mode;
  246. const struct hda_channel_mode *channel_mode;
  247. int need_dac_fix;
  248. unsigned int num_mux_defs;
  249. const struct hda_input_mux *input_mux;
  250. void (*unsol_event)(struct hda_codec *, unsigned int);
  251. void (*init_hook)(struct hda_codec *);
  252. #ifdef CONFIG_SND_HDA_POWER_SAVE
  253. struct hda_amp_list *loopbacks;
  254. #endif
  255. };
  256. /*
  257. * input MUX handling
  258. */
  259. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  260. struct snd_ctl_elem_info *uinfo)
  261. {
  262. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  263. struct alc_spec *spec = codec->spec;
  264. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  265. if (mux_idx >= spec->num_mux_defs)
  266. mux_idx = 0;
  267. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  268. }
  269. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  270. struct snd_ctl_elem_value *ucontrol)
  271. {
  272. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  273. struct alc_spec *spec = codec->spec;
  274. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  275. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  276. return 0;
  277. }
  278. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  279. struct snd_ctl_elem_value *ucontrol)
  280. {
  281. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  282. struct alc_spec *spec = codec->spec;
  283. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  284. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  285. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  286. spec->adc_nids[adc_idx],
  287. &spec->cur_mux[adc_idx]);
  288. }
  289. /*
  290. * channel mode setting
  291. */
  292. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  293. struct snd_ctl_elem_info *uinfo)
  294. {
  295. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  296. struct alc_spec *spec = codec->spec;
  297. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  298. spec->num_channel_mode);
  299. }
  300. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  301. struct snd_ctl_elem_value *ucontrol)
  302. {
  303. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  304. struct alc_spec *spec = codec->spec;
  305. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  306. spec->num_channel_mode,
  307. spec->multiout.max_channels);
  308. }
  309. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  310. struct snd_ctl_elem_value *ucontrol)
  311. {
  312. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  313. struct alc_spec *spec = codec->spec;
  314. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  315. spec->num_channel_mode,
  316. &spec->multiout.max_channels);
  317. if (err >= 0 && spec->need_dac_fix)
  318. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  319. return err;
  320. }
  321. /*
  322. * Control the mode of pin widget settings via the mixer. "pc" is used
  323. * instead of "%" to avoid consequences of accidently treating the % as
  324. * being part of a format specifier. Maximum allowed length of a value is
  325. * 63 characters plus NULL terminator.
  326. *
  327. * Note: some retasking pin complexes seem to ignore requests for input
  328. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  329. * are requested. Therefore order this list so that this behaviour will not
  330. * cause problems when mixer clients move through the enum sequentially.
  331. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  332. * March 2006.
  333. */
  334. static char *alc_pin_mode_names[] = {
  335. "Mic 50pc bias", "Mic 80pc bias",
  336. "Line in", "Line out", "Headphone out",
  337. };
  338. static unsigned char alc_pin_mode_values[] = {
  339. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  340. };
  341. /* The control can present all 5 options, or it can limit the options based
  342. * in the pin being assumed to be exclusively an input or an output pin. In
  343. * addition, "input" pins may or may not process the mic bias option
  344. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  345. * accept requests for bias as of chip versions up to March 2006) and/or
  346. * wiring in the computer.
  347. */
  348. #define ALC_PIN_DIR_IN 0x00
  349. #define ALC_PIN_DIR_OUT 0x01
  350. #define ALC_PIN_DIR_INOUT 0x02
  351. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  352. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  353. /* Info about the pin modes supported by the different pin direction modes.
  354. * For each direction the minimum and maximum values are given.
  355. */
  356. static signed char alc_pin_mode_dir_info[5][2] = {
  357. { 0, 2 }, /* ALC_PIN_DIR_IN */
  358. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  359. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  360. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  361. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  362. };
  363. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  364. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  365. #define alc_pin_mode_n_items(_dir) \
  366. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  367. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  368. struct snd_ctl_elem_info *uinfo)
  369. {
  370. unsigned int item_num = uinfo->value.enumerated.item;
  371. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  372. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  373. uinfo->count = 1;
  374. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  375. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  376. item_num = alc_pin_mode_min(dir);
  377. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  378. return 0;
  379. }
  380. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  381. struct snd_ctl_elem_value *ucontrol)
  382. {
  383. unsigned int i;
  384. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  385. hda_nid_t nid = kcontrol->private_value & 0xffff;
  386. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  387. long *valp = ucontrol->value.integer.value;
  388. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  389. AC_VERB_GET_PIN_WIDGET_CONTROL,
  390. 0x00);
  391. /* Find enumerated value for current pinctl setting */
  392. i = alc_pin_mode_min(dir);
  393. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  394. i++;
  395. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  396. return 0;
  397. }
  398. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  399. struct snd_ctl_elem_value *ucontrol)
  400. {
  401. signed int change;
  402. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  403. hda_nid_t nid = kcontrol->private_value & 0xffff;
  404. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  405. long val = *ucontrol->value.integer.value;
  406. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  407. AC_VERB_GET_PIN_WIDGET_CONTROL,
  408. 0x00);
  409. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  410. val = alc_pin_mode_min(dir);
  411. change = pinctl != alc_pin_mode_values[val];
  412. if (change) {
  413. /* Set pin mode to that requested */
  414. snd_hda_codec_write_cache(codec, nid, 0,
  415. AC_VERB_SET_PIN_WIDGET_CONTROL,
  416. alc_pin_mode_values[val]);
  417. /* Also enable the retasking pin's input/output as required
  418. * for the requested pin mode. Enum values of 2 or less are
  419. * input modes.
  420. *
  421. * Dynamically switching the input/output buffers probably
  422. * reduces noise slightly (particularly on input) so we'll
  423. * do it. However, having both input and output buffers
  424. * enabled simultaneously doesn't seem to be problematic if
  425. * this turns out to be necessary in the future.
  426. */
  427. if (val <= 2) {
  428. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  429. HDA_AMP_MUTE, HDA_AMP_MUTE);
  430. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  431. HDA_AMP_MUTE, 0);
  432. } else {
  433. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  434. HDA_AMP_MUTE, HDA_AMP_MUTE);
  435. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  436. HDA_AMP_MUTE, 0);
  437. }
  438. }
  439. return change;
  440. }
  441. #define ALC_PIN_MODE(xname, nid, dir) \
  442. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  443. .info = alc_pin_mode_info, \
  444. .get = alc_pin_mode_get, \
  445. .put = alc_pin_mode_put, \
  446. .private_value = nid | (dir<<16) }
  447. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  448. * together using a mask with more than one bit set. This control is
  449. * currently used only by the ALC260 test model. At this stage they are not
  450. * needed for any "production" models.
  451. */
  452. #ifdef CONFIG_SND_DEBUG
  453. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  454. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  455. struct snd_ctl_elem_value *ucontrol)
  456. {
  457. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  458. hda_nid_t nid = kcontrol->private_value & 0xffff;
  459. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  460. long *valp = ucontrol->value.integer.value;
  461. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  462. AC_VERB_GET_GPIO_DATA, 0x00);
  463. *valp = (val & mask) != 0;
  464. return 0;
  465. }
  466. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  467. struct snd_ctl_elem_value *ucontrol)
  468. {
  469. signed int change;
  470. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  471. hda_nid_t nid = kcontrol->private_value & 0xffff;
  472. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  473. long val = *ucontrol->value.integer.value;
  474. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  475. AC_VERB_GET_GPIO_DATA,
  476. 0x00);
  477. /* Set/unset the masked GPIO bit(s) as needed */
  478. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  479. if (val == 0)
  480. gpio_data &= ~mask;
  481. else
  482. gpio_data |= mask;
  483. snd_hda_codec_write_cache(codec, nid, 0,
  484. AC_VERB_SET_GPIO_DATA, gpio_data);
  485. return change;
  486. }
  487. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  488. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  489. .info = alc_gpio_data_info, \
  490. .get = alc_gpio_data_get, \
  491. .put = alc_gpio_data_put, \
  492. .private_value = nid | (mask<<16) }
  493. #endif /* CONFIG_SND_DEBUG */
  494. /* A switch control to allow the enabling of the digital IO pins on the
  495. * ALC260. This is incredibly simplistic; the intention of this control is
  496. * to provide something in the test model allowing digital outputs to be
  497. * identified if present. If models are found which can utilise these
  498. * outputs a more complete mixer control can be devised for those models if
  499. * necessary.
  500. */
  501. #ifdef CONFIG_SND_DEBUG
  502. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  503. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  504. struct snd_ctl_elem_value *ucontrol)
  505. {
  506. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  507. hda_nid_t nid = kcontrol->private_value & 0xffff;
  508. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  509. long *valp = ucontrol->value.integer.value;
  510. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  511. AC_VERB_GET_DIGI_CONVERT, 0x00);
  512. *valp = (val & mask) != 0;
  513. return 0;
  514. }
  515. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  516. struct snd_ctl_elem_value *ucontrol)
  517. {
  518. signed int change;
  519. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  520. hda_nid_t nid = kcontrol->private_value & 0xffff;
  521. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  522. long val = *ucontrol->value.integer.value;
  523. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  524. AC_VERB_GET_DIGI_CONVERT,
  525. 0x00);
  526. /* Set/unset the masked control bit(s) as needed */
  527. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  528. if (val==0)
  529. ctrl_data &= ~mask;
  530. else
  531. ctrl_data |= mask;
  532. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  533. ctrl_data);
  534. return change;
  535. }
  536. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  537. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  538. .info = alc_spdif_ctrl_info, \
  539. .get = alc_spdif_ctrl_get, \
  540. .put = alc_spdif_ctrl_put, \
  541. .private_value = nid | (mask<<16) }
  542. #endif /* CONFIG_SND_DEBUG */
  543. /*
  544. * set up from the preset table
  545. */
  546. static void setup_preset(struct alc_spec *spec,
  547. const struct alc_config_preset *preset)
  548. {
  549. int i;
  550. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  551. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  552. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  553. i++)
  554. spec->init_verbs[spec->num_init_verbs++] =
  555. preset->init_verbs[i];
  556. spec->channel_mode = preset->channel_mode;
  557. spec->num_channel_mode = preset->num_channel_mode;
  558. spec->need_dac_fix = preset->need_dac_fix;
  559. spec->multiout.max_channels = spec->channel_mode[0].channels;
  560. spec->multiout.num_dacs = preset->num_dacs;
  561. spec->multiout.dac_nids = preset->dac_nids;
  562. spec->multiout.dig_out_nid = preset->dig_out_nid;
  563. spec->multiout.hp_nid = preset->hp_nid;
  564. spec->num_mux_defs = preset->num_mux_defs;
  565. if (!spec->num_mux_defs)
  566. spec->num_mux_defs = 1;
  567. spec->input_mux = preset->input_mux;
  568. spec->num_adc_nids = preset->num_adc_nids;
  569. spec->adc_nids = preset->adc_nids;
  570. spec->dig_in_nid = preset->dig_in_nid;
  571. spec->unsol_event = preset->unsol_event;
  572. spec->init_hook = preset->init_hook;
  573. #ifdef CONFIG_SND_HDA_POWER_SAVE
  574. spec->loopback.amplist = preset->loopbacks;
  575. #endif
  576. }
  577. /* Enable GPIO mask and set output */
  578. static struct hda_verb alc_gpio1_init_verbs[] = {
  579. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  580. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  581. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  582. { }
  583. };
  584. static struct hda_verb alc_gpio2_init_verbs[] = {
  585. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  586. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  587. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  588. { }
  589. };
  590. static struct hda_verb alc_gpio3_init_verbs[] = {
  591. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  592. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  593. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  594. { }
  595. };
  596. static void alc_sku_automute(struct hda_codec *codec)
  597. {
  598. struct alc_spec *spec = codec->spec;
  599. unsigned int mute;
  600. unsigned int present;
  601. unsigned int hp_nid = spec->autocfg.hp_pins[0];
  602. unsigned int sp_nid = spec->autocfg.speaker_pins[0];
  603. /* need to execute and sync at first */
  604. snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
  605. present = snd_hda_codec_read(codec, hp_nid, 0,
  606. AC_VERB_GET_PIN_SENSE, 0);
  607. spec->jack_present = (present & 0x80000000) != 0;
  608. if (spec->jack_present) {
  609. /* mute internal speaker */
  610. snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
  611. HDA_AMP_MUTE, HDA_AMP_MUTE);
  612. } else {
  613. /* unmute internal speaker if necessary */
  614. mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
  615. snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
  616. HDA_AMP_MUTE, mute);
  617. }
  618. }
  619. /* unsolicited event for HP jack sensing */
  620. static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
  621. {
  622. if (codec->vendor_id == 0x10ec0880)
  623. res >>= 28;
  624. else
  625. res >>= 26;
  626. if (res != ALC880_HP_EVENT)
  627. return;
  628. alc_sku_automute(codec);
  629. }
  630. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  631. * 31 ~ 16 : Manufacture ID
  632. * 15 ~ 8 : SKU ID
  633. * 7 ~ 0 : Assembly ID
  634. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  635. */
  636. static void alc_subsystem_id(struct hda_codec *codec,
  637. unsigned int porta, unsigned int porte,
  638. unsigned int portd)
  639. {
  640. unsigned int ass, tmp, i;
  641. unsigned nid;
  642. struct alc_spec *spec = codec->spec;
  643. ass = codec->subsystem_id & 0xffff;
  644. if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
  645. goto do_sku;
  646. /*
  647. * 31~30 : port conetcivity
  648. * 29~21 : reserve
  649. * 20 : PCBEEP input
  650. * 19~16 : Check sum (15:1)
  651. * 15~1 : Custom
  652. * 0 : override
  653. */
  654. nid = 0x1d;
  655. if (codec->vendor_id == 0x10ec0260)
  656. nid = 0x17;
  657. ass = snd_hda_codec_read(codec, nid, 0,
  658. AC_VERB_GET_CONFIG_DEFAULT, 0);
  659. if (!(ass & 1) && !(ass & 0x100000))
  660. return;
  661. if ((ass >> 30) != 1) /* no physical connection */
  662. return;
  663. /* check sum */
  664. tmp = 0;
  665. for (i = 1; i < 16; i++) {
  666. if ((ass >> i) && 1)
  667. tmp++;
  668. }
  669. if (((ass >> 16) & 0xf) != tmp)
  670. return;
  671. do_sku:
  672. /*
  673. * 0 : override
  674. * 1 : Swap Jack
  675. * 2 : 0 --> Desktop, 1 --> Laptop
  676. * 3~5 : External Amplifier control
  677. * 7~6 : Reserved
  678. */
  679. tmp = (ass & 0x38) >> 3; /* external Amp control */
  680. switch (tmp) {
  681. case 1:
  682. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  683. break;
  684. case 3:
  685. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  686. break;
  687. case 7:
  688. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  689. break;
  690. case 5: /* set EAPD output high */
  691. switch (codec->vendor_id) {
  692. case 0x10ec0260:
  693. snd_hda_codec_write(codec, 0x0f, 0,
  694. AC_VERB_SET_EAPD_BTLENABLE, 2);
  695. snd_hda_codec_write(codec, 0x10, 0,
  696. AC_VERB_SET_EAPD_BTLENABLE, 2);
  697. break;
  698. case 0x10ec0262:
  699. case 0x10ec0267:
  700. case 0x10ec0268:
  701. case 0x10ec0269:
  702. case 0x10ec0862:
  703. case 0x10ec0662:
  704. snd_hda_codec_write(codec, 0x14, 0,
  705. AC_VERB_SET_EAPD_BTLENABLE, 2);
  706. snd_hda_codec_write(codec, 0x15, 0,
  707. AC_VERB_SET_EAPD_BTLENABLE, 2);
  708. break;
  709. }
  710. switch (codec->vendor_id) {
  711. case 0x10ec0260:
  712. snd_hda_codec_write(codec, 0x1a, 0,
  713. AC_VERB_SET_COEF_INDEX, 7);
  714. tmp = snd_hda_codec_read(codec, 0x1a, 0,
  715. AC_VERB_GET_PROC_COEF, 0);
  716. snd_hda_codec_write(codec, 0x1a, 0,
  717. AC_VERB_SET_COEF_INDEX, 7);
  718. snd_hda_codec_write(codec, 0x1a, 0,
  719. AC_VERB_SET_PROC_COEF,
  720. tmp | 0x2010);
  721. break;
  722. case 0x10ec0262:
  723. case 0x10ec0880:
  724. case 0x10ec0882:
  725. case 0x10ec0883:
  726. case 0x10ec0885:
  727. case 0x10ec0888:
  728. snd_hda_codec_write(codec, 0x20, 0,
  729. AC_VERB_SET_COEF_INDEX, 7);
  730. tmp = snd_hda_codec_read(codec, 0x20, 0,
  731. AC_VERB_GET_PROC_COEF, 0);
  732. snd_hda_codec_write(codec, 0x20, 0,
  733. AC_VERB_SET_COEF_INDEX, 7);
  734. snd_hda_codec_write(codec, 0x20, 0,
  735. AC_VERB_SET_PROC_COEF,
  736. tmp | 0x2010);
  737. break;
  738. case 0x10ec0267:
  739. case 0x10ec0268:
  740. snd_hda_codec_write(codec, 0x20, 0,
  741. AC_VERB_SET_COEF_INDEX, 7);
  742. tmp = snd_hda_codec_read(codec, 0x20, 0,
  743. AC_VERB_GET_PROC_COEF, 0);
  744. snd_hda_codec_write(codec, 0x20, 0,
  745. AC_VERB_SET_COEF_INDEX, 7);
  746. snd_hda_codec_write(codec, 0x20, 0,
  747. AC_VERB_SET_PROC_COEF,
  748. tmp | 0x3000);
  749. break;
  750. }
  751. default:
  752. break;
  753. }
  754. /* is laptop and enable the function "Mute internal speaker
  755. * when the external headphone out jack is plugged"
  756. */
  757. if (!(ass & 0x4) || !(ass & 0x8000))
  758. return;
  759. /*
  760. * 10~8 : Jack location
  761. * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
  762. * 14~13: Resvered
  763. * 15 : 1 --> enable the function "Mute internal speaker
  764. * when the external headphone out jack is plugged"
  765. */
  766. if (!spec->autocfg.speaker_pins[0]) {
  767. if (spec->multiout.dac_nids[0])
  768. spec->autocfg.speaker_pins[0] =
  769. spec->multiout.dac_nids[0];
  770. else
  771. return;
  772. }
  773. if (!spec->autocfg.hp_pins[0]) {
  774. tmp = (ass >> 11) & 0x3; /* HP to chassis */
  775. if (tmp == 0)
  776. spec->autocfg.hp_pins[0] = porta;
  777. else if (tmp == 1)
  778. spec->autocfg.hp_pins[0] = porte;
  779. else if (tmp == 2)
  780. spec->autocfg.hp_pins[0] = portd;
  781. else
  782. return;
  783. }
  784. snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
  785. AC_VERB_SET_UNSOLICITED_ENABLE,
  786. AC_USRSP_EN | ALC880_HP_EVENT);
  787. spec->unsol_event = alc_sku_unsol_event;
  788. spec->init_hook = alc_sku_automute;
  789. }
  790. /*
  791. * Fix-up pin default configurations
  792. */
  793. struct alc_pincfg {
  794. hda_nid_t nid;
  795. u32 val;
  796. };
  797. static void alc_fix_pincfg(struct hda_codec *codec,
  798. const struct snd_pci_quirk *quirk,
  799. const struct alc_pincfg **pinfix)
  800. {
  801. const struct alc_pincfg *cfg;
  802. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  803. if (!quirk)
  804. return;
  805. cfg = pinfix[quirk->value];
  806. for (; cfg->nid; cfg++) {
  807. int i;
  808. u32 val = cfg->val;
  809. for (i = 0; i < 4; i++) {
  810. snd_hda_codec_write(codec, cfg->nid, 0,
  811. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  812. val & 0xff);
  813. val >>= 8;
  814. }
  815. }
  816. }
  817. /*
  818. * ALC880 3-stack model
  819. *
  820. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  821. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  822. * F-Mic = 0x1b, HP = 0x19
  823. */
  824. static hda_nid_t alc880_dac_nids[4] = {
  825. /* front, rear, clfe, rear_surr */
  826. 0x02, 0x05, 0x04, 0x03
  827. };
  828. static hda_nid_t alc880_adc_nids[3] = {
  829. /* ADC0-2 */
  830. 0x07, 0x08, 0x09,
  831. };
  832. /* The datasheet says the node 0x07 is connected from inputs,
  833. * but it shows zero connection in the real implementation on some devices.
  834. * Note: this is a 915GAV bug, fixed on 915GLV
  835. */
  836. static hda_nid_t alc880_adc_nids_alt[2] = {
  837. /* ADC1-2 */
  838. 0x08, 0x09,
  839. };
  840. #define ALC880_DIGOUT_NID 0x06
  841. #define ALC880_DIGIN_NID 0x0a
  842. static struct hda_input_mux alc880_capture_source = {
  843. .num_items = 4,
  844. .items = {
  845. { "Mic", 0x0 },
  846. { "Front Mic", 0x3 },
  847. { "Line", 0x2 },
  848. { "CD", 0x4 },
  849. },
  850. };
  851. /* channel source setting (2/6 channel selection for 3-stack) */
  852. /* 2ch mode */
  853. static struct hda_verb alc880_threestack_ch2_init[] = {
  854. /* set line-in to input, mute it */
  855. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  856. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  857. /* set mic-in to input vref 80%, mute it */
  858. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  859. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  860. { } /* end */
  861. };
  862. /* 6ch mode */
  863. static struct hda_verb alc880_threestack_ch6_init[] = {
  864. /* set line-in to output, unmute it */
  865. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  866. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  867. /* set mic-in to output, unmute it */
  868. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  869. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  870. { } /* end */
  871. };
  872. static struct hda_channel_mode alc880_threestack_modes[2] = {
  873. { 2, alc880_threestack_ch2_init },
  874. { 6, alc880_threestack_ch6_init },
  875. };
  876. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  877. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  878. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  879. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  880. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  881. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  882. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  883. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  884. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  885. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  886. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  887. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  888. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  889. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  890. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  891. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  892. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  893. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  894. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  895. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  896. {
  897. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  898. .name = "Channel Mode",
  899. .info = alc_ch_mode_info,
  900. .get = alc_ch_mode_get,
  901. .put = alc_ch_mode_put,
  902. },
  903. { } /* end */
  904. };
  905. /* capture mixer elements */
  906. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  907. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  908. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  909. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  910. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  911. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  912. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  913. {
  914. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  915. /* The multiple "Capture Source" controls confuse alsamixer
  916. * So call somewhat different..
  917. * FIXME: the controls appear in the "playback" view!
  918. */
  919. /* .name = "Capture Source", */
  920. .name = "Input Source",
  921. .count = 3,
  922. .info = alc_mux_enum_info,
  923. .get = alc_mux_enum_get,
  924. .put = alc_mux_enum_put,
  925. },
  926. { } /* end */
  927. };
  928. /* capture mixer elements (in case NID 0x07 not available) */
  929. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  930. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  931. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  932. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  933. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  934. {
  935. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  936. /* The multiple "Capture Source" controls confuse alsamixer
  937. * So call somewhat different..
  938. * FIXME: the controls appear in the "playback" view!
  939. */
  940. /* .name = "Capture Source", */
  941. .name = "Input Source",
  942. .count = 2,
  943. .info = alc_mux_enum_info,
  944. .get = alc_mux_enum_get,
  945. .put = alc_mux_enum_put,
  946. },
  947. { } /* end */
  948. };
  949. /*
  950. * ALC880 5-stack model
  951. *
  952. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  953. * Side = 0x02 (0xd)
  954. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  955. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  956. */
  957. /* additional mixers to alc880_three_stack_mixer */
  958. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  959. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  960. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  961. { } /* end */
  962. };
  963. /* channel source setting (6/8 channel selection for 5-stack) */
  964. /* 6ch mode */
  965. static struct hda_verb alc880_fivestack_ch6_init[] = {
  966. /* set line-in to input, mute it */
  967. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  968. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  969. { } /* end */
  970. };
  971. /* 8ch mode */
  972. static struct hda_verb alc880_fivestack_ch8_init[] = {
  973. /* set line-in to output, unmute it */
  974. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  975. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  976. { } /* end */
  977. };
  978. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  979. { 6, alc880_fivestack_ch6_init },
  980. { 8, alc880_fivestack_ch8_init },
  981. };
  982. /*
  983. * ALC880 6-stack model
  984. *
  985. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  986. * Side = 0x05 (0x0f)
  987. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  988. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  989. */
  990. static hda_nid_t alc880_6st_dac_nids[4] = {
  991. /* front, rear, clfe, rear_surr */
  992. 0x02, 0x03, 0x04, 0x05
  993. };
  994. static struct hda_input_mux alc880_6stack_capture_source = {
  995. .num_items = 4,
  996. .items = {
  997. { "Mic", 0x0 },
  998. { "Front Mic", 0x1 },
  999. { "Line", 0x2 },
  1000. { "CD", 0x4 },
  1001. },
  1002. };
  1003. /* fixed 8-channels */
  1004. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  1005. { 8, NULL },
  1006. };
  1007. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  1008. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1009. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1010. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1011. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1012. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1013. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1014. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1015. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1016. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1017. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1018. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1019. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1020. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1021. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1022. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1023. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1024. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1025. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1026. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1027. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1028. {
  1029. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1030. .name = "Channel Mode",
  1031. .info = alc_ch_mode_info,
  1032. .get = alc_ch_mode_get,
  1033. .put = alc_ch_mode_put,
  1034. },
  1035. { } /* end */
  1036. };
  1037. /*
  1038. * ALC880 W810 model
  1039. *
  1040. * W810 has rear IO for:
  1041. * Front (DAC 02)
  1042. * Surround (DAC 03)
  1043. * Center/LFE (DAC 04)
  1044. * Digital out (06)
  1045. *
  1046. * The system also has a pair of internal speakers, and a headphone jack.
  1047. * These are both connected to Line2 on the codec, hence to DAC 02.
  1048. *
  1049. * There is a variable resistor to control the speaker or headphone
  1050. * volume. This is a hardware-only device without a software API.
  1051. *
  1052. * Plugging headphones in will disable the internal speakers. This is
  1053. * implemented in hardware, not via the driver using jack sense. In
  1054. * a similar fashion, plugging into the rear socket marked "front" will
  1055. * disable both the speakers and headphones.
  1056. *
  1057. * For input, there's a microphone jack, and an "audio in" jack.
  1058. * These may not do anything useful with this driver yet, because I
  1059. * haven't setup any initialization verbs for these yet...
  1060. */
  1061. static hda_nid_t alc880_w810_dac_nids[3] = {
  1062. /* front, rear/surround, clfe */
  1063. 0x02, 0x03, 0x04
  1064. };
  1065. /* fixed 6 channels */
  1066. static struct hda_channel_mode alc880_w810_modes[1] = {
  1067. { 6, NULL }
  1068. };
  1069. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  1070. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  1071. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1072. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1073. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1074. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1075. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1076. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1077. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1078. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1079. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1080. { } /* end */
  1081. };
  1082. /*
  1083. * Z710V model
  1084. *
  1085. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  1086. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  1087. * Line = 0x1a
  1088. */
  1089. static hda_nid_t alc880_z71v_dac_nids[1] = {
  1090. 0x02
  1091. };
  1092. #define ALC880_Z71V_HP_DAC 0x03
  1093. /* fixed 2 channels */
  1094. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  1095. { 2, NULL }
  1096. };
  1097. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  1098. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1099. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1100. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1101. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  1102. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1103. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1104. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1105. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1106. { } /* end */
  1107. };
  1108. /* FIXME! */
  1109. /*
  1110. * ALC880 F1734 model
  1111. *
  1112. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  1113. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  1114. */
  1115. static hda_nid_t alc880_f1734_dac_nids[1] = {
  1116. 0x03
  1117. };
  1118. #define ALC880_F1734_HP_DAC 0x02
  1119. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  1120. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1121. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1122. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1123. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1124. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1125. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1126. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1127. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1128. { } /* end */
  1129. };
  1130. /* FIXME! */
  1131. /*
  1132. * ALC880 ASUS model
  1133. *
  1134. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1135. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1136. * Mic = 0x18, Line = 0x1a
  1137. */
  1138. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1139. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1140. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1141. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1142. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1143. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1144. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1145. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1146. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1147. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1148. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1149. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1150. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1151. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1152. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1153. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1154. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1155. {
  1156. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1157. .name = "Channel Mode",
  1158. .info = alc_ch_mode_info,
  1159. .get = alc_ch_mode_get,
  1160. .put = alc_ch_mode_put,
  1161. },
  1162. { } /* end */
  1163. };
  1164. /* FIXME! */
  1165. /*
  1166. * ALC880 ASUS W1V model
  1167. *
  1168. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1169. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1170. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1171. */
  1172. /* additional mixers to alc880_asus_mixer */
  1173. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1174. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1175. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1176. { } /* end */
  1177. };
  1178. /* additional mixers to alc880_asus_mixer */
  1179. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1180. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1181. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1182. { } /* end */
  1183. };
  1184. /* TCL S700 */
  1185. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1186. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1187. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1188. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1189. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1190. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1191. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1192. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1193. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1194. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1195. {
  1196. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1197. /* The multiple "Capture Source" controls confuse alsamixer
  1198. * So call somewhat different..
  1199. * FIXME: the controls appear in the "playback" view!
  1200. */
  1201. /* .name = "Capture Source", */
  1202. .name = "Input Source",
  1203. .count = 1,
  1204. .info = alc_mux_enum_info,
  1205. .get = alc_mux_enum_get,
  1206. .put = alc_mux_enum_put,
  1207. },
  1208. { } /* end */
  1209. };
  1210. /* Uniwill */
  1211. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1212. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1213. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1214. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1215. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1216. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1217. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1218. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1219. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1220. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1221. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1222. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1223. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1224. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1225. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1226. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1227. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1228. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1229. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1230. {
  1231. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1232. .name = "Channel Mode",
  1233. .info = alc_ch_mode_info,
  1234. .get = alc_ch_mode_get,
  1235. .put = alc_ch_mode_put,
  1236. },
  1237. { } /* end */
  1238. };
  1239. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1240. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1241. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1242. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1243. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1244. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1245. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1246. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1247. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1248. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1249. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1250. { } /* end */
  1251. };
  1252. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1253. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1254. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1255. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1256. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1257. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1258. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1259. { } /* end */
  1260. };
  1261. /*
  1262. * build control elements
  1263. */
  1264. static int alc_build_controls(struct hda_codec *codec)
  1265. {
  1266. struct alc_spec *spec = codec->spec;
  1267. int err;
  1268. int i;
  1269. for (i = 0; i < spec->num_mixers; i++) {
  1270. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1271. if (err < 0)
  1272. return err;
  1273. }
  1274. if (spec->multiout.dig_out_nid) {
  1275. err = snd_hda_create_spdif_out_ctls(codec,
  1276. spec->multiout.dig_out_nid);
  1277. if (err < 0)
  1278. return err;
  1279. }
  1280. if (spec->dig_in_nid) {
  1281. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1282. if (err < 0)
  1283. return err;
  1284. }
  1285. return 0;
  1286. }
  1287. /*
  1288. * initialize the codec volumes, etc
  1289. */
  1290. /*
  1291. * generic initialization of ADC, input mixers and output mixers
  1292. */
  1293. static struct hda_verb alc880_volume_init_verbs[] = {
  1294. /*
  1295. * Unmute ADC0-2 and set the default input to mic-in
  1296. */
  1297. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1298. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1299. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1300. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1301. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1302. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1303. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1304. * mixer widget
  1305. * Note: PASD motherboards uses the Line In 2 as the input for front
  1306. * panel mic (mic 2)
  1307. */
  1308. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1309. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1310. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1311. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1312. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1313. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1314. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1315. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1316. /*
  1317. * Set up output mixers (0x0c - 0x0f)
  1318. */
  1319. /* set vol=0 to output mixers */
  1320. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1321. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1322. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1323. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1324. /* set up input amps for analog loopback */
  1325. /* Amp Indices: DAC = 0, mixer = 1 */
  1326. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1327. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1328. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1329. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1330. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1331. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1332. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1333. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1334. { }
  1335. };
  1336. /*
  1337. * 3-stack pin configuration:
  1338. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1339. */
  1340. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1341. /*
  1342. * preset connection lists of input pins
  1343. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1344. */
  1345. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1346. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1347. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1348. /*
  1349. * Set pin mode and muting
  1350. */
  1351. /* set front pin widgets 0x14 for output */
  1352. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1353. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1354. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1355. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1356. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1357. /* Mic2 (as headphone out) for HP output */
  1358. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1359. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1360. /* Line In pin widget for input */
  1361. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1362. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1363. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1364. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1365. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1366. /* CD pin widget for input */
  1367. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1368. { }
  1369. };
  1370. /*
  1371. * 5-stack pin configuration:
  1372. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1373. * line-in/side = 0x1a, f-mic = 0x1b
  1374. */
  1375. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1376. /*
  1377. * preset connection lists of input pins
  1378. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1379. */
  1380. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1381. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1382. /*
  1383. * Set pin mode and muting
  1384. */
  1385. /* set pin widgets 0x14-0x17 for output */
  1386. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1387. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1388. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1389. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1390. /* unmute pins for output (no gain on this amp) */
  1391. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1392. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1393. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1394. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1395. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1396. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1397. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1398. /* Mic2 (as headphone out) for HP output */
  1399. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1400. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1401. /* Line In pin widget for input */
  1402. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1403. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1404. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1405. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1406. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1407. /* CD pin widget for input */
  1408. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1409. { }
  1410. };
  1411. /*
  1412. * W810 pin configuration:
  1413. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1414. */
  1415. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1416. /* hphone/speaker input selector: front DAC */
  1417. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1418. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1419. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1420. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1421. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1422. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1423. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1424. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1425. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1426. { }
  1427. };
  1428. /*
  1429. * Z71V pin configuration:
  1430. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1431. */
  1432. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1433. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1434. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1435. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1436. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1437. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1438. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1439. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1440. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1441. { }
  1442. };
  1443. /*
  1444. * 6-stack pin configuration:
  1445. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1446. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1447. */
  1448. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1449. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1450. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1451. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1452. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1453. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1454. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1455. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1456. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1457. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1458. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1459. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1460. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1461. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1462. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1463. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1464. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1465. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1466. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1467. { }
  1468. };
  1469. /*
  1470. * Uniwill pin configuration:
  1471. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1472. * line = 0x1a
  1473. */
  1474. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1475. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1476. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1477. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1478. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1479. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1480. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1481. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1482. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1483. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1484. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1485. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1486. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1487. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1488. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1489. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1490. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1491. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1492. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1493. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1494. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1495. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1496. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1497. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1498. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1499. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1500. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1501. { }
  1502. };
  1503. /*
  1504. * Uniwill P53
  1505. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1506. */
  1507. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1508. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1509. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1510. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1511. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1512. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1513. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1514. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1515. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1516. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1517. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1518. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1519. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1520. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1521. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1522. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1523. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1524. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1525. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1526. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1527. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1528. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1529. { }
  1530. };
  1531. static struct hda_verb alc880_beep_init_verbs[] = {
  1532. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1533. { }
  1534. };
  1535. /* toggle speaker-output according to the hp-jack state */
  1536. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1537. {
  1538. unsigned int present;
  1539. unsigned char bits;
  1540. present = snd_hda_codec_read(codec, 0x14, 0,
  1541. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1542. bits = present ? HDA_AMP_MUTE : 0;
  1543. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1544. HDA_AMP_MUTE, bits);
  1545. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1546. HDA_AMP_MUTE, bits);
  1547. }
  1548. /* auto-toggle front mic */
  1549. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1550. {
  1551. unsigned int present;
  1552. unsigned char bits;
  1553. present = snd_hda_codec_read(codec, 0x18, 0,
  1554. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1555. bits = present ? HDA_AMP_MUTE : 0;
  1556. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1557. }
  1558. static void alc880_uniwill_automute(struct hda_codec *codec)
  1559. {
  1560. alc880_uniwill_hp_automute(codec);
  1561. alc880_uniwill_mic_automute(codec);
  1562. }
  1563. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1564. unsigned int res)
  1565. {
  1566. /* Looks like the unsol event is incompatible with the standard
  1567. * definition. 4bit tag is placed at 28 bit!
  1568. */
  1569. switch (res >> 28) {
  1570. case ALC880_HP_EVENT:
  1571. alc880_uniwill_hp_automute(codec);
  1572. break;
  1573. case ALC880_MIC_EVENT:
  1574. alc880_uniwill_mic_automute(codec);
  1575. break;
  1576. }
  1577. }
  1578. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1579. {
  1580. unsigned int present;
  1581. unsigned char bits;
  1582. present = snd_hda_codec_read(codec, 0x14, 0,
  1583. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1584. bits = present ? HDA_AMP_MUTE : 0;
  1585. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1586. }
  1587. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1588. {
  1589. unsigned int present;
  1590. present = snd_hda_codec_read(codec, 0x21, 0,
  1591. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1592. present &= HDA_AMP_VOLMASK;
  1593. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1594. HDA_AMP_VOLMASK, present);
  1595. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1596. HDA_AMP_VOLMASK, present);
  1597. }
  1598. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1599. unsigned int res)
  1600. {
  1601. /* Looks like the unsol event is incompatible with the standard
  1602. * definition. 4bit tag is placed at 28 bit!
  1603. */
  1604. if ((res >> 28) == ALC880_HP_EVENT)
  1605. alc880_uniwill_p53_hp_automute(codec);
  1606. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1607. alc880_uniwill_p53_dcvol_automute(codec);
  1608. }
  1609. /* FIXME! */
  1610. /*
  1611. * F1734 pin configuration:
  1612. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1613. */
  1614. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1615. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1616. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1617. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1618. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1619. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1620. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1621. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1622. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1623. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1624. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1625. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1626. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1627. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1628. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1629. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1630. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1631. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1632. { }
  1633. };
  1634. /* FIXME! */
  1635. /*
  1636. * ASUS pin configuration:
  1637. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1638. */
  1639. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1640. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1641. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1642. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1643. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1644. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1645. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1646. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1647. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1648. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1649. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1650. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1651. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1652. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1653. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1654. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1655. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1656. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1657. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1658. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1659. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1660. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1661. { }
  1662. };
  1663. /* Enable GPIO mask and set output */
  1664. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1665. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1666. /* Clevo m520g init */
  1667. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1668. /* headphone output */
  1669. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1670. /* line-out */
  1671. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1672. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1673. /* Line-in */
  1674. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1675. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1676. /* CD */
  1677. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1678. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1679. /* Mic1 (rear panel) */
  1680. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1681. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1682. /* Mic2 (front panel) */
  1683. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1684. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1685. /* headphone */
  1686. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1687. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1688. /* change to EAPD mode */
  1689. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1690. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1691. { }
  1692. };
  1693. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1694. /* change to EAPD mode */
  1695. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1696. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1697. /* Headphone output */
  1698. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1699. /* Front output*/
  1700. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1701. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1702. /* Line In pin widget for input */
  1703. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1704. /* CD pin widget for input */
  1705. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1706. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1707. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1708. /* change to EAPD mode */
  1709. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1710. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1711. { }
  1712. };
  1713. /*
  1714. * LG m1 express dual
  1715. *
  1716. * Pin assignment:
  1717. * Rear Line-In/Out (blue): 0x14
  1718. * Build-in Mic-In: 0x15
  1719. * Speaker-out: 0x17
  1720. * HP-Out (green): 0x1b
  1721. * Mic-In/Out (red): 0x19
  1722. * SPDIF-Out: 0x1e
  1723. */
  1724. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1725. static hda_nid_t alc880_lg_dac_nids[3] = {
  1726. 0x05, 0x02, 0x03
  1727. };
  1728. /* seems analog CD is not working */
  1729. static struct hda_input_mux alc880_lg_capture_source = {
  1730. .num_items = 3,
  1731. .items = {
  1732. { "Mic", 0x1 },
  1733. { "Line", 0x5 },
  1734. { "Internal Mic", 0x6 },
  1735. },
  1736. };
  1737. /* 2,4,6 channel modes */
  1738. static struct hda_verb alc880_lg_ch2_init[] = {
  1739. /* set line-in and mic-in to input */
  1740. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1741. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1742. { }
  1743. };
  1744. static struct hda_verb alc880_lg_ch4_init[] = {
  1745. /* set line-in to out and mic-in to input */
  1746. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1747. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1748. { }
  1749. };
  1750. static struct hda_verb alc880_lg_ch6_init[] = {
  1751. /* set line-in and mic-in to output */
  1752. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1753. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1754. { }
  1755. };
  1756. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1757. { 2, alc880_lg_ch2_init },
  1758. { 4, alc880_lg_ch4_init },
  1759. { 6, alc880_lg_ch6_init },
  1760. };
  1761. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1762. /* FIXME: it's not really "master" but front channels */
  1763. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1764. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1765. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1766. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1767. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1768. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1769. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1770. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1771. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1772. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1773. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1774. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1775. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1776. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1777. {
  1778. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1779. .name = "Channel Mode",
  1780. .info = alc_ch_mode_info,
  1781. .get = alc_ch_mode_get,
  1782. .put = alc_ch_mode_put,
  1783. },
  1784. { } /* end */
  1785. };
  1786. static struct hda_verb alc880_lg_init_verbs[] = {
  1787. /* set capture source to mic-in */
  1788. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1789. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1790. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1791. /* mute all amp mixer inputs */
  1792. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1793. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1794. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1795. /* line-in to input */
  1796. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1797. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1798. /* built-in mic */
  1799. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1800. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1801. /* speaker-out */
  1802. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1803. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1804. /* mic-in to input */
  1805. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1806. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1807. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1808. /* HP-out */
  1809. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1810. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1811. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1812. /* jack sense */
  1813. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1814. { }
  1815. };
  1816. /* toggle speaker-output according to the hp-jack state */
  1817. static void alc880_lg_automute(struct hda_codec *codec)
  1818. {
  1819. unsigned int present;
  1820. unsigned char bits;
  1821. present = snd_hda_codec_read(codec, 0x1b, 0,
  1822. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1823. bits = present ? HDA_AMP_MUTE : 0;
  1824. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1825. HDA_AMP_MUTE, bits);
  1826. }
  1827. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1828. {
  1829. /* Looks like the unsol event is incompatible with the standard
  1830. * definition. 4bit tag is placed at 28 bit!
  1831. */
  1832. if ((res >> 28) == 0x01)
  1833. alc880_lg_automute(codec);
  1834. }
  1835. /*
  1836. * LG LW20
  1837. *
  1838. * Pin assignment:
  1839. * Speaker-out: 0x14
  1840. * Mic-In: 0x18
  1841. * Built-in Mic-In: 0x19
  1842. * Line-In: 0x1b
  1843. * HP-Out: 0x1a
  1844. * SPDIF-Out: 0x1e
  1845. */
  1846. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1847. .num_items = 3,
  1848. .items = {
  1849. { "Mic", 0x0 },
  1850. { "Internal Mic", 0x1 },
  1851. { "Line In", 0x2 },
  1852. },
  1853. };
  1854. #define alc880_lg_lw_modes alc880_threestack_modes
  1855. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1856. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1857. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1858. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1859. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1860. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1861. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1862. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1863. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1864. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1865. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1866. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1867. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1868. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1869. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1870. {
  1871. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1872. .name = "Channel Mode",
  1873. .info = alc_ch_mode_info,
  1874. .get = alc_ch_mode_get,
  1875. .put = alc_ch_mode_put,
  1876. },
  1877. { } /* end */
  1878. };
  1879. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1880. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1881. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1882. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1883. /* set capture source to mic-in */
  1884. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1885. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1886. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1887. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1888. /* speaker-out */
  1889. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1890. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1891. /* HP-out */
  1892. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1893. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1894. /* mic-in to input */
  1895. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1896. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1897. /* built-in mic */
  1898. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1899. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1900. /* jack sense */
  1901. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1902. { }
  1903. };
  1904. /* toggle speaker-output according to the hp-jack state */
  1905. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1906. {
  1907. unsigned int present;
  1908. unsigned char bits;
  1909. present = snd_hda_codec_read(codec, 0x1b, 0,
  1910. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1911. bits = present ? HDA_AMP_MUTE : 0;
  1912. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1913. HDA_AMP_MUTE, bits);
  1914. }
  1915. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1916. {
  1917. /* Looks like the unsol event is incompatible with the standard
  1918. * definition. 4bit tag is placed at 28 bit!
  1919. */
  1920. if ((res >> 28) == 0x01)
  1921. alc880_lg_lw_automute(codec);
  1922. }
  1923. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1924. static struct hda_amp_list alc880_loopbacks[] = {
  1925. { 0x0b, HDA_INPUT, 0 },
  1926. { 0x0b, HDA_INPUT, 1 },
  1927. { 0x0b, HDA_INPUT, 2 },
  1928. { 0x0b, HDA_INPUT, 3 },
  1929. { 0x0b, HDA_INPUT, 4 },
  1930. { } /* end */
  1931. };
  1932. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1933. { 0x0b, HDA_INPUT, 1 },
  1934. { 0x0b, HDA_INPUT, 6 },
  1935. { 0x0b, HDA_INPUT, 7 },
  1936. { } /* end */
  1937. };
  1938. #endif
  1939. /*
  1940. * Common callbacks
  1941. */
  1942. static int alc_init(struct hda_codec *codec)
  1943. {
  1944. struct alc_spec *spec = codec->spec;
  1945. unsigned int i;
  1946. for (i = 0; i < spec->num_init_verbs; i++)
  1947. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1948. if (spec->init_hook)
  1949. spec->init_hook(codec);
  1950. return 0;
  1951. }
  1952. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1953. {
  1954. struct alc_spec *spec = codec->spec;
  1955. if (spec->unsol_event)
  1956. spec->unsol_event(codec, res);
  1957. }
  1958. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1959. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1960. {
  1961. struct alc_spec *spec = codec->spec;
  1962. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1963. }
  1964. #endif
  1965. /*
  1966. * Analog playback callbacks
  1967. */
  1968. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1969. struct hda_codec *codec,
  1970. struct snd_pcm_substream *substream)
  1971. {
  1972. struct alc_spec *spec = codec->spec;
  1973. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1974. }
  1975. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1976. struct hda_codec *codec,
  1977. unsigned int stream_tag,
  1978. unsigned int format,
  1979. struct snd_pcm_substream *substream)
  1980. {
  1981. struct alc_spec *spec = codec->spec;
  1982. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1983. stream_tag, format, substream);
  1984. }
  1985. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1986. struct hda_codec *codec,
  1987. struct snd_pcm_substream *substream)
  1988. {
  1989. struct alc_spec *spec = codec->spec;
  1990. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1991. }
  1992. /*
  1993. * Digital out
  1994. */
  1995. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1996. struct hda_codec *codec,
  1997. struct snd_pcm_substream *substream)
  1998. {
  1999. struct alc_spec *spec = codec->spec;
  2000. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  2001. }
  2002. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  2003. struct hda_codec *codec,
  2004. unsigned int stream_tag,
  2005. unsigned int format,
  2006. struct snd_pcm_substream *substream)
  2007. {
  2008. struct alc_spec *spec = codec->spec;
  2009. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  2010. stream_tag, format, substream);
  2011. }
  2012. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  2013. struct hda_codec *codec,
  2014. struct snd_pcm_substream *substream)
  2015. {
  2016. struct alc_spec *spec = codec->spec;
  2017. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  2018. }
  2019. /*
  2020. * Analog capture
  2021. */
  2022. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  2023. struct hda_codec *codec,
  2024. unsigned int stream_tag,
  2025. unsigned int format,
  2026. struct snd_pcm_substream *substream)
  2027. {
  2028. struct alc_spec *spec = codec->spec;
  2029. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  2030. stream_tag, 0, format);
  2031. return 0;
  2032. }
  2033. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2034. struct hda_codec *codec,
  2035. struct snd_pcm_substream *substream)
  2036. {
  2037. struct alc_spec *spec = codec->spec;
  2038. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  2039. 0, 0, 0);
  2040. return 0;
  2041. }
  2042. /*
  2043. */
  2044. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  2045. .substreams = 1,
  2046. .channels_min = 2,
  2047. .channels_max = 8,
  2048. /* NID is set in alc_build_pcms */
  2049. .ops = {
  2050. .open = alc880_playback_pcm_open,
  2051. .prepare = alc880_playback_pcm_prepare,
  2052. .cleanup = alc880_playback_pcm_cleanup
  2053. },
  2054. };
  2055. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  2056. .substreams = 2,
  2057. .channels_min = 2,
  2058. .channels_max = 2,
  2059. /* NID is set in alc_build_pcms */
  2060. .ops = {
  2061. .prepare = alc880_capture_pcm_prepare,
  2062. .cleanup = alc880_capture_pcm_cleanup
  2063. },
  2064. };
  2065. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  2066. .substreams = 1,
  2067. .channels_min = 2,
  2068. .channels_max = 2,
  2069. /* NID is set in alc_build_pcms */
  2070. .ops = {
  2071. .open = alc880_dig_playback_pcm_open,
  2072. .close = alc880_dig_playback_pcm_close,
  2073. .prepare = alc880_dig_playback_pcm_prepare
  2074. },
  2075. };
  2076. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  2077. .substreams = 1,
  2078. .channels_min = 2,
  2079. .channels_max = 2,
  2080. /* NID is set in alc_build_pcms */
  2081. };
  2082. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  2083. static struct hda_pcm_stream alc_pcm_null_playback = {
  2084. .substreams = 0,
  2085. .channels_min = 0,
  2086. .channels_max = 0,
  2087. };
  2088. static int alc_build_pcms(struct hda_codec *codec)
  2089. {
  2090. struct alc_spec *spec = codec->spec;
  2091. struct hda_pcm *info = spec->pcm_rec;
  2092. int i;
  2093. codec->num_pcms = 1;
  2094. codec->pcm_info = info;
  2095. info->name = spec->stream_name_analog;
  2096. if (spec->stream_analog_playback) {
  2097. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  2098. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  2099. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  2100. }
  2101. if (spec->stream_analog_capture) {
  2102. snd_assert(spec->adc_nids, return -EINVAL);
  2103. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2104. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  2105. }
  2106. if (spec->channel_mode) {
  2107. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  2108. for (i = 0; i < spec->num_channel_mode; i++) {
  2109. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  2110. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  2111. }
  2112. }
  2113. }
  2114. /* SPDIF for stream index #1 */
  2115. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  2116. codec->num_pcms = 2;
  2117. info = spec->pcm_rec + 1;
  2118. info->name = spec->stream_name_digital;
  2119. if (spec->multiout.dig_out_nid &&
  2120. spec->stream_digital_playback) {
  2121. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  2122. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  2123. }
  2124. if (spec->dig_in_nid &&
  2125. spec->stream_digital_capture) {
  2126. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  2127. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  2128. }
  2129. }
  2130. /* If the use of more than one ADC is requested for the current
  2131. * model, configure a second analog capture-only PCM.
  2132. */
  2133. /* Additional Analaog capture for index #2 */
  2134. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  2135. spec->adc_nids) {
  2136. codec->num_pcms = 3;
  2137. info = spec->pcm_rec + 2;
  2138. info->name = spec->stream_name_analog;
  2139. /* No playback stream for second PCM */
  2140. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2141. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2142. if (spec->stream_analog_capture) {
  2143. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2144. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2145. }
  2146. }
  2147. return 0;
  2148. }
  2149. static void alc_free(struct hda_codec *codec)
  2150. {
  2151. struct alc_spec *spec = codec->spec;
  2152. unsigned int i;
  2153. if (!spec)
  2154. return;
  2155. if (spec->kctl_alloc) {
  2156. for (i = 0; i < spec->num_kctl_used; i++)
  2157. kfree(spec->kctl_alloc[i].name);
  2158. kfree(spec->kctl_alloc);
  2159. }
  2160. kfree(spec);
  2161. }
  2162. /*
  2163. */
  2164. static struct hda_codec_ops alc_patch_ops = {
  2165. .build_controls = alc_build_controls,
  2166. .build_pcms = alc_build_pcms,
  2167. .init = alc_init,
  2168. .free = alc_free,
  2169. .unsol_event = alc_unsol_event,
  2170. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2171. .check_power_status = alc_check_power_status,
  2172. #endif
  2173. };
  2174. /*
  2175. * Test configuration for debugging
  2176. *
  2177. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2178. * enum controls.
  2179. */
  2180. #ifdef CONFIG_SND_DEBUG
  2181. static hda_nid_t alc880_test_dac_nids[4] = {
  2182. 0x02, 0x03, 0x04, 0x05
  2183. };
  2184. static struct hda_input_mux alc880_test_capture_source = {
  2185. .num_items = 7,
  2186. .items = {
  2187. { "In-1", 0x0 },
  2188. { "In-2", 0x1 },
  2189. { "In-3", 0x2 },
  2190. { "In-4", 0x3 },
  2191. { "CD", 0x4 },
  2192. { "Front", 0x5 },
  2193. { "Surround", 0x6 },
  2194. },
  2195. };
  2196. static struct hda_channel_mode alc880_test_modes[4] = {
  2197. { 2, NULL },
  2198. { 4, NULL },
  2199. { 6, NULL },
  2200. { 8, NULL },
  2201. };
  2202. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2203. struct snd_ctl_elem_info *uinfo)
  2204. {
  2205. static char *texts[] = {
  2206. "N/A", "Line Out", "HP Out",
  2207. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2208. };
  2209. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2210. uinfo->count = 1;
  2211. uinfo->value.enumerated.items = 8;
  2212. if (uinfo->value.enumerated.item >= 8)
  2213. uinfo->value.enumerated.item = 7;
  2214. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2215. return 0;
  2216. }
  2217. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2218. struct snd_ctl_elem_value *ucontrol)
  2219. {
  2220. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2221. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2222. unsigned int pin_ctl, item = 0;
  2223. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2224. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2225. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2226. if (pin_ctl & AC_PINCTL_HP_EN)
  2227. item = 2;
  2228. else
  2229. item = 1;
  2230. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2231. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2232. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2233. case AC_PINCTL_VREF_50: item = 4; break;
  2234. case AC_PINCTL_VREF_GRD: item = 5; break;
  2235. case AC_PINCTL_VREF_80: item = 6; break;
  2236. case AC_PINCTL_VREF_100: item = 7; break;
  2237. }
  2238. }
  2239. ucontrol->value.enumerated.item[0] = item;
  2240. return 0;
  2241. }
  2242. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2243. struct snd_ctl_elem_value *ucontrol)
  2244. {
  2245. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2246. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2247. static unsigned int ctls[] = {
  2248. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2249. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2250. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2251. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2252. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2253. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2254. };
  2255. unsigned int old_ctl, new_ctl;
  2256. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2257. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2258. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2259. if (old_ctl != new_ctl) {
  2260. int val;
  2261. snd_hda_codec_write_cache(codec, nid, 0,
  2262. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2263. new_ctl);
  2264. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2265. HDA_AMP_MUTE : 0;
  2266. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2267. HDA_AMP_MUTE, val);
  2268. return 1;
  2269. }
  2270. return 0;
  2271. }
  2272. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2273. struct snd_ctl_elem_info *uinfo)
  2274. {
  2275. static char *texts[] = {
  2276. "Front", "Surround", "CLFE", "Side"
  2277. };
  2278. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2279. uinfo->count = 1;
  2280. uinfo->value.enumerated.items = 4;
  2281. if (uinfo->value.enumerated.item >= 4)
  2282. uinfo->value.enumerated.item = 3;
  2283. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2284. return 0;
  2285. }
  2286. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2287. struct snd_ctl_elem_value *ucontrol)
  2288. {
  2289. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2290. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2291. unsigned int sel;
  2292. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2293. ucontrol->value.enumerated.item[0] = sel & 3;
  2294. return 0;
  2295. }
  2296. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2297. struct snd_ctl_elem_value *ucontrol)
  2298. {
  2299. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2300. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2301. unsigned int sel;
  2302. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2303. if (ucontrol->value.enumerated.item[0] != sel) {
  2304. sel = ucontrol->value.enumerated.item[0] & 3;
  2305. snd_hda_codec_write_cache(codec, nid, 0,
  2306. AC_VERB_SET_CONNECT_SEL, sel);
  2307. return 1;
  2308. }
  2309. return 0;
  2310. }
  2311. #define PIN_CTL_TEST(xname,nid) { \
  2312. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2313. .name = xname, \
  2314. .info = alc_test_pin_ctl_info, \
  2315. .get = alc_test_pin_ctl_get, \
  2316. .put = alc_test_pin_ctl_put, \
  2317. .private_value = nid \
  2318. }
  2319. #define PIN_SRC_TEST(xname,nid) { \
  2320. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2321. .name = xname, \
  2322. .info = alc_test_pin_src_info, \
  2323. .get = alc_test_pin_src_get, \
  2324. .put = alc_test_pin_src_put, \
  2325. .private_value = nid \
  2326. }
  2327. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2328. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2329. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2330. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2331. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2332. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2333. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2334. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2335. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2336. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2337. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2338. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2339. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2340. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2341. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2342. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2343. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2344. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2345. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2346. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2347. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2348. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2349. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2350. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2351. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2352. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2353. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2354. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2355. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2356. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2357. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2358. {
  2359. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2360. .name = "Channel Mode",
  2361. .info = alc_ch_mode_info,
  2362. .get = alc_ch_mode_get,
  2363. .put = alc_ch_mode_put,
  2364. },
  2365. { } /* end */
  2366. };
  2367. static struct hda_verb alc880_test_init_verbs[] = {
  2368. /* Unmute inputs of 0x0c - 0x0f */
  2369. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2370. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2371. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2372. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2373. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2374. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2375. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2376. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2377. /* Vol output for 0x0c-0x0f */
  2378. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2379. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2380. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2381. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2382. /* Set output pins 0x14-0x17 */
  2383. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2384. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2385. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2386. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2387. /* Unmute output pins 0x14-0x17 */
  2388. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2389. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2390. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2391. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2392. /* Set input pins 0x18-0x1c */
  2393. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2394. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2395. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2396. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2397. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2398. /* Mute input pins 0x18-0x1b */
  2399. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2400. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2401. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2402. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2403. /* ADC set up */
  2404. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2405. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2406. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2407. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2408. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2409. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2410. /* Analog input/passthru */
  2411. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2412. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2413. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2414. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2415. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2416. { }
  2417. };
  2418. #endif
  2419. /*
  2420. */
  2421. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2422. [ALC880_3ST] = "3stack",
  2423. [ALC880_TCL_S700] = "tcl",
  2424. [ALC880_3ST_DIG] = "3stack-digout",
  2425. [ALC880_CLEVO] = "clevo",
  2426. [ALC880_5ST] = "5stack",
  2427. [ALC880_5ST_DIG] = "5stack-digout",
  2428. [ALC880_W810] = "w810",
  2429. [ALC880_Z71V] = "z71v",
  2430. [ALC880_6ST] = "6stack",
  2431. [ALC880_6ST_DIG] = "6stack-digout",
  2432. [ALC880_ASUS] = "asus",
  2433. [ALC880_ASUS_W1V] = "asus-w1v",
  2434. [ALC880_ASUS_DIG] = "asus-dig",
  2435. [ALC880_ASUS_DIG2] = "asus-dig2",
  2436. [ALC880_UNIWILL_DIG] = "uniwill",
  2437. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2438. [ALC880_FUJITSU] = "fujitsu",
  2439. [ALC880_F1734] = "F1734",
  2440. [ALC880_LG] = "lg",
  2441. [ALC880_LG_LW] = "lg-lw",
  2442. #ifdef CONFIG_SND_DEBUG
  2443. [ALC880_TEST] = "test",
  2444. #endif
  2445. [ALC880_AUTO] = "auto",
  2446. };
  2447. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2448. /* Broken BIOS configuration */
  2449. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2450. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2451. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2452. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2453. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2454. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2455. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2456. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2457. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2458. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2459. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2460. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2461. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2462. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2463. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2464. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2465. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2466. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2467. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2468. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2469. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2470. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2471. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2472. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2473. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2474. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2475. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2476. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2477. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2478. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2479. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2480. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2481. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2482. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2483. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2484. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2485. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2486. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2487. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2488. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2489. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2490. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2491. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2492. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2493. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2494. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2495. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2496. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2497. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2498. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2499. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2500. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2501. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2502. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2503. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2504. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2505. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2506. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2507. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2508. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2509. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2510. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2511. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2512. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2513. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2514. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2515. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2516. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2517. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2518. {}
  2519. };
  2520. /*
  2521. * ALC880 codec presets
  2522. */
  2523. static struct alc_config_preset alc880_presets[] = {
  2524. [ALC880_3ST] = {
  2525. .mixers = { alc880_three_stack_mixer },
  2526. .init_verbs = { alc880_volume_init_verbs,
  2527. alc880_pin_3stack_init_verbs },
  2528. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2529. .dac_nids = alc880_dac_nids,
  2530. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2531. .channel_mode = alc880_threestack_modes,
  2532. .need_dac_fix = 1,
  2533. .input_mux = &alc880_capture_source,
  2534. },
  2535. [ALC880_3ST_DIG] = {
  2536. .mixers = { alc880_three_stack_mixer },
  2537. .init_verbs = { alc880_volume_init_verbs,
  2538. alc880_pin_3stack_init_verbs },
  2539. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2540. .dac_nids = alc880_dac_nids,
  2541. .dig_out_nid = ALC880_DIGOUT_NID,
  2542. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2543. .channel_mode = alc880_threestack_modes,
  2544. .need_dac_fix = 1,
  2545. .input_mux = &alc880_capture_source,
  2546. },
  2547. [ALC880_TCL_S700] = {
  2548. .mixers = { alc880_tcl_s700_mixer },
  2549. .init_verbs = { alc880_volume_init_verbs,
  2550. alc880_pin_tcl_S700_init_verbs,
  2551. alc880_gpio2_init_verbs },
  2552. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2553. .dac_nids = alc880_dac_nids,
  2554. .hp_nid = 0x03,
  2555. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2556. .channel_mode = alc880_2_jack_modes,
  2557. .input_mux = &alc880_capture_source,
  2558. },
  2559. [ALC880_5ST] = {
  2560. .mixers = { alc880_three_stack_mixer,
  2561. alc880_five_stack_mixer},
  2562. .init_verbs = { alc880_volume_init_verbs,
  2563. alc880_pin_5stack_init_verbs },
  2564. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2565. .dac_nids = alc880_dac_nids,
  2566. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2567. .channel_mode = alc880_fivestack_modes,
  2568. .input_mux = &alc880_capture_source,
  2569. },
  2570. [ALC880_5ST_DIG] = {
  2571. .mixers = { alc880_three_stack_mixer,
  2572. alc880_five_stack_mixer },
  2573. .init_verbs = { alc880_volume_init_verbs,
  2574. alc880_pin_5stack_init_verbs },
  2575. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2576. .dac_nids = alc880_dac_nids,
  2577. .dig_out_nid = ALC880_DIGOUT_NID,
  2578. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2579. .channel_mode = alc880_fivestack_modes,
  2580. .input_mux = &alc880_capture_source,
  2581. },
  2582. [ALC880_6ST] = {
  2583. .mixers = { alc880_six_stack_mixer },
  2584. .init_verbs = { alc880_volume_init_verbs,
  2585. alc880_pin_6stack_init_verbs },
  2586. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2587. .dac_nids = alc880_6st_dac_nids,
  2588. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2589. .channel_mode = alc880_sixstack_modes,
  2590. .input_mux = &alc880_6stack_capture_source,
  2591. },
  2592. [ALC880_6ST_DIG] = {
  2593. .mixers = { alc880_six_stack_mixer },
  2594. .init_verbs = { alc880_volume_init_verbs,
  2595. alc880_pin_6stack_init_verbs },
  2596. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2597. .dac_nids = alc880_6st_dac_nids,
  2598. .dig_out_nid = ALC880_DIGOUT_NID,
  2599. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2600. .channel_mode = alc880_sixstack_modes,
  2601. .input_mux = &alc880_6stack_capture_source,
  2602. },
  2603. [ALC880_W810] = {
  2604. .mixers = { alc880_w810_base_mixer },
  2605. .init_verbs = { alc880_volume_init_verbs,
  2606. alc880_pin_w810_init_verbs,
  2607. alc880_gpio2_init_verbs },
  2608. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2609. .dac_nids = alc880_w810_dac_nids,
  2610. .dig_out_nid = ALC880_DIGOUT_NID,
  2611. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2612. .channel_mode = alc880_w810_modes,
  2613. .input_mux = &alc880_capture_source,
  2614. },
  2615. [ALC880_Z71V] = {
  2616. .mixers = { alc880_z71v_mixer },
  2617. .init_verbs = { alc880_volume_init_verbs,
  2618. alc880_pin_z71v_init_verbs },
  2619. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2620. .dac_nids = alc880_z71v_dac_nids,
  2621. .dig_out_nid = ALC880_DIGOUT_NID,
  2622. .hp_nid = 0x03,
  2623. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2624. .channel_mode = alc880_2_jack_modes,
  2625. .input_mux = &alc880_capture_source,
  2626. },
  2627. [ALC880_F1734] = {
  2628. .mixers = { alc880_f1734_mixer },
  2629. .init_verbs = { alc880_volume_init_verbs,
  2630. alc880_pin_f1734_init_verbs },
  2631. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2632. .dac_nids = alc880_f1734_dac_nids,
  2633. .hp_nid = 0x02,
  2634. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2635. .channel_mode = alc880_2_jack_modes,
  2636. .input_mux = &alc880_capture_source,
  2637. },
  2638. [ALC880_ASUS] = {
  2639. .mixers = { alc880_asus_mixer },
  2640. .init_verbs = { alc880_volume_init_verbs,
  2641. alc880_pin_asus_init_verbs,
  2642. alc880_gpio1_init_verbs },
  2643. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2644. .dac_nids = alc880_asus_dac_nids,
  2645. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2646. .channel_mode = alc880_asus_modes,
  2647. .need_dac_fix = 1,
  2648. .input_mux = &alc880_capture_source,
  2649. },
  2650. [ALC880_ASUS_DIG] = {
  2651. .mixers = { alc880_asus_mixer },
  2652. .init_verbs = { alc880_volume_init_verbs,
  2653. alc880_pin_asus_init_verbs,
  2654. alc880_gpio1_init_verbs },
  2655. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2656. .dac_nids = alc880_asus_dac_nids,
  2657. .dig_out_nid = ALC880_DIGOUT_NID,
  2658. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2659. .channel_mode = alc880_asus_modes,
  2660. .need_dac_fix = 1,
  2661. .input_mux = &alc880_capture_source,
  2662. },
  2663. [ALC880_ASUS_DIG2] = {
  2664. .mixers = { alc880_asus_mixer },
  2665. .init_verbs = { alc880_volume_init_verbs,
  2666. alc880_pin_asus_init_verbs,
  2667. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2668. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2669. .dac_nids = alc880_asus_dac_nids,
  2670. .dig_out_nid = ALC880_DIGOUT_NID,
  2671. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2672. .channel_mode = alc880_asus_modes,
  2673. .need_dac_fix = 1,
  2674. .input_mux = &alc880_capture_source,
  2675. },
  2676. [ALC880_ASUS_W1V] = {
  2677. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2678. .init_verbs = { alc880_volume_init_verbs,
  2679. alc880_pin_asus_init_verbs,
  2680. alc880_gpio1_init_verbs },
  2681. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2682. .dac_nids = alc880_asus_dac_nids,
  2683. .dig_out_nid = ALC880_DIGOUT_NID,
  2684. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2685. .channel_mode = alc880_asus_modes,
  2686. .need_dac_fix = 1,
  2687. .input_mux = &alc880_capture_source,
  2688. },
  2689. [ALC880_UNIWILL_DIG] = {
  2690. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2691. .init_verbs = { alc880_volume_init_verbs,
  2692. alc880_pin_asus_init_verbs },
  2693. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2694. .dac_nids = alc880_asus_dac_nids,
  2695. .dig_out_nid = ALC880_DIGOUT_NID,
  2696. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2697. .channel_mode = alc880_asus_modes,
  2698. .need_dac_fix = 1,
  2699. .input_mux = &alc880_capture_source,
  2700. },
  2701. [ALC880_UNIWILL] = {
  2702. .mixers = { alc880_uniwill_mixer },
  2703. .init_verbs = { alc880_volume_init_verbs,
  2704. alc880_uniwill_init_verbs },
  2705. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2706. .dac_nids = alc880_asus_dac_nids,
  2707. .dig_out_nid = ALC880_DIGOUT_NID,
  2708. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2709. .channel_mode = alc880_threestack_modes,
  2710. .need_dac_fix = 1,
  2711. .input_mux = &alc880_capture_source,
  2712. .unsol_event = alc880_uniwill_unsol_event,
  2713. .init_hook = alc880_uniwill_automute,
  2714. },
  2715. [ALC880_UNIWILL_P53] = {
  2716. .mixers = { alc880_uniwill_p53_mixer },
  2717. .init_verbs = { alc880_volume_init_verbs,
  2718. alc880_uniwill_p53_init_verbs },
  2719. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2720. .dac_nids = alc880_asus_dac_nids,
  2721. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2722. .channel_mode = alc880_threestack_modes,
  2723. .input_mux = &alc880_capture_source,
  2724. .unsol_event = alc880_uniwill_p53_unsol_event,
  2725. .init_hook = alc880_uniwill_p53_hp_automute,
  2726. },
  2727. [ALC880_FUJITSU] = {
  2728. .mixers = { alc880_fujitsu_mixer,
  2729. alc880_pcbeep_mixer, },
  2730. .init_verbs = { alc880_volume_init_verbs,
  2731. alc880_uniwill_p53_init_verbs,
  2732. alc880_beep_init_verbs },
  2733. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2734. .dac_nids = alc880_dac_nids,
  2735. .dig_out_nid = ALC880_DIGOUT_NID,
  2736. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2737. .channel_mode = alc880_2_jack_modes,
  2738. .input_mux = &alc880_capture_source,
  2739. .unsol_event = alc880_uniwill_p53_unsol_event,
  2740. .init_hook = alc880_uniwill_p53_hp_automute,
  2741. },
  2742. [ALC880_CLEVO] = {
  2743. .mixers = { alc880_three_stack_mixer },
  2744. .init_verbs = { alc880_volume_init_verbs,
  2745. alc880_pin_clevo_init_verbs },
  2746. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2747. .dac_nids = alc880_dac_nids,
  2748. .hp_nid = 0x03,
  2749. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2750. .channel_mode = alc880_threestack_modes,
  2751. .need_dac_fix = 1,
  2752. .input_mux = &alc880_capture_source,
  2753. },
  2754. [ALC880_LG] = {
  2755. .mixers = { alc880_lg_mixer },
  2756. .init_verbs = { alc880_volume_init_verbs,
  2757. alc880_lg_init_verbs },
  2758. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2759. .dac_nids = alc880_lg_dac_nids,
  2760. .dig_out_nid = ALC880_DIGOUT_NID,
  2761. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2762. .channel_mode = alc880_lg_ch_modes,
  2763. .need_dac_fix = 1,
  2764. .input_mux = &alc880_lg_capture_source,
  2765. .unsol_event = alc880_lg_unsol_event,
  2766. .init_hook = alc880_lg_automute,
  2767. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2768. .loopbacks = alc880_lg_loopbacks,
  2769. #endif
  2770. },
  2771. [ALC880_LG_LW] = {
  2772. .mixers = { alc880_lg_lw_mixer },
  2773. .init_verbs = { alc880_volume_init_verbs,
  2774. alc880_lg_lw_init_verbs },
  2775. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2776. .dac_nids = alc880_dac_nids,
  2777. .dig_out_nid = ALC880_DIGOUT_NID,
  2778. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2779. .channel_mode = alc880_lg_lw_modes,
  2780. .input_mux = &alc880_lg_lw_capture_source,
  2781. .unsol_event = alc880_lg_lw_unsol_event,
  2782. .init_hook = alc880_lg_lw_automute,
  2783. },
  2784. #ifdef CONFIG_SND_DEBUG
  2785. [ALC880_TEST] = {
  2786. .mixers = { alc880_test_mixer },
  2787. .init_verbs = { alc880_test_init_verbs },
  2788. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2789. .dac_nids = alc880_test_dac_nids,
  2790. .dig_out_nid = ALC880_DIGOUT_NID,
  2791. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2792. .channel_mode = alc880_test_modes,
  2793. .input_mux = &alc880_test_capture_source,
  2794. },
  2795. #endif
  2796. };
  2797. /*
  2798. * Automatic parse of I/O pins from the BIOS configuration
  2799. */
  2800. #define NUM_CONTROL_ALLOC 32
  2801. #define NUM_VERB_ALLOC 32
  2802. enum {
  2803. ALC_CTL_WIDGET_VOL,
  2804. ALC_CTL_WIDGET_MUTE,
  2805. ALC_CTL_BIND_MUTE,
  2806. };
  2807. static struct snd_kcontrol_new alc880_control_templates[] = {
  2808. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2809. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2810. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2811. };
  2812. /* add dynamic controls */
  2813. static int add_control(struct alc_spec *spec, int type, const char *name,
  2814. unsigned long val)
  2815. {
  2816. struct snd_kcontrol_new *knew;
  2817. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2818. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2819. /* array + terminator */
  2820. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2821. if (!knew)
  2822. return -ENOMEM;
  2823. if (spec->kctl_alloc) {
  2824. memcpy(knew, spec->kctl_alloc,
  2825. sizeof(*knew) * spec->num_kctl_alloc);
  2826. kfree(spec->kctl_alloc);
  2827. }
  2828. spec->kctl_alloc = knew;
  2829. spec->num_kctl_alloc = num;
  2830. }
  2831. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2832. *knew = alc880_control_templates[type];
  2833. knew->name = kstrdup(name, GFP_KERNEL);
  2834. if (!knew->name)
  2835. return -ENOMEM;
  2836. knew->private_value = val;
  2837. spec->num_kctl_used++;
  2838. return 0;
  2839. }
  2840. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2841. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2842. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2843. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2844. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2845. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2846. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2847. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2848. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2849. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2850. #define ALC880_PIN_CD_NID 0x1c
  2851. /* fill in the dac_nids table from the parsed pin configuration */
  2852. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2853. const struct auto_pin_cfg *cfg)
  2854. {
  2855. hda_nid_t nid;
  2856. int assigned[4];
  2857. int i, j;
  2858. memset(assigned, 0, sizeof(assigned));
  2859. spec->multiout.dac_nids = spec->private_dac_nids;
  2860. /* check the pins hardwired to audio widget */
  2861. for (i = 0; i < cfg->line_outs; i++) {
  2862. nid = cfg->line_out_pins[i];
  2863. if (alc880_is_fixed_pin(nid)) {
  2864. int idx = alc880_fixed_pin_idx(nid);
  2865. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2866. assigned[idx] = 1;
  2867. }
  2868. }
  2869. /* left pins can be connect to any audio widget */
  2870. for (i = 0; i < cfg->line_outs; i++) {
  2871. nid = cfg->line_out_pins[i];
  2872. if (alc880_is_fixed_pin(nid))
  2873. continue;
  2874. /* search for an empty channel */
  2875. for (j = 0; j < cfg->line_outs; j++) {
  2876. if (!assigned[j]) {
  2877. spec->multiout.dac_nids[i] =
  2878. alc880_idx_to_dac(j);
  2879. assigned[j] = 1;
  2880. break;
  2881. }
  2882. }
  2883. }
  2884. spec->multiout.num_dacs = cfg->line_outs;
  2885. return 0;
  2886. }
  2887. /* add playback controls from the parsed DAC table */
  2888. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2889. const struct auto_pin_cfg *cfg)
  2890. {
  2891. char name[32];
  2892. static const char *chname[4] = {
  2893. "Front", "Surround", NULL /*CLFE*/, "Side"
  2894. };
  2895. hda_nid_t nid;
  2896. int i, err;
  2897. for (i = 0; i < cfg->line_outs; i++) {
  2898. if (!spec->multiout.dac_nids[i])
  2899. continue;
  2900. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2901. if (i == 2) {
  2902. /* Center/LFE */
  2903. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2904. "Center Playback Volume",
  2905. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2906. HDA_OUTPUT));
  2907. if (err < 0)
  2908. return err;
  2909. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2910. "LFE Playback Volume",
  2911. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2912. HDA_OUTPUT));
  2913. if (err < 0)
  2914. return err;
  2915. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2916. "Center Playback Switch",
  2917. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2918. HDA_INPUT));
  2919. if (err < 0)
  2920. return err;
  2921. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2922. "LFE Playback Switch",
  2923. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2924. HDA_INPUT));
  2925. if (err < 0)
  2926. return err;
  2927. } else {
  2928. sprintf(name, "%s Playback Volume", chname[i]);
  2929. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2930. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2931. HDA_OUTPUT));
  2932. if (err < 0)
  2933. return err;
  2934. sprintf(name, "%s Playback Switch", chname[i]);
  2935. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2936. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2937. HDA_INPUT));
  2938. if (err < 0)
  2939. return err;
  2940. }
  2941. }
  2942. return 0;
  2943. }
  2944. /* add playback controls for speaker and HP outputs */
  2945. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2946. const char *pfx)
  2947. {
  2948. hda_nid_t nid;
  2949. int err;
  2950. char name[32];
  2951. if (!pin)
  2952. return 0;
  2953. if (alc880_is_fixed_pin(pin)) {
  2954. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2955. /* specify the DAC as the extra output */
  2956. if (!spec->multiout.hp_nid)
  2957. spec->multiout.hp_nid = nid;
  2958. else
  2959. spec->multiout.extra_out_nid[0] = nid;
  2960. /* control HP volume/switch on the output mixer amp */
  2961. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2962. sprintf(name, "%s Playback Volume", pfx);
  2963. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2964. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2965. if (err < 0)
  2966. return err;
  2967. sprintf(name, "%s Playback Switch", pfx);
  2968. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2969. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2970. if (err < 0)
  2971. return err;
  2972. } else if (alc880_is_multi_pin(pin)) {
  2973. /* set manual connection */
  2974. /* we have only a switch on HP-out PIN */
  2975. sprintf(name, "%s Playback Switch", pfx);
  2976. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2977. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2978. if (err < 0)
  2979. return err;
  2980. }
  2981. return 0;
  2982. }
  2983. /* create input playback/capture controls for the given pin */
  2984. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2985. const char *ctlname,
  2986. int idx, hda_nid_t mix_nid)
  2987. {
  2988. char name[32];
  2989. int err;
  2990. sprintf(name, "%s Playback Volume", ctlname);
  2991. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2992. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2993. if (err < 0)
  2994. return err;
  2995. sprintf(name, "%s Playback Switch", ctlname);
  2996. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2997. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2998. if (err < 0)
  2999. return err;
  3000. return 0;
  3001. }
  3002. /* create playback/capture controls for input pins */
  3003. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  3004. const struct auto_pin_cfg *cfg)
  3005. {
  3006. struct hda_input_mux *imux = &spec->private_imux;
  3007. int i, err, idx;
  3008. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3009. if (alc880_is_input_pin(cfg->input_pins[i])) {
  3010. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  3011. err = new_analog_input(spec, cfg->input_pins[i],
  3012. auto_pin_cfg_labels[i],
  3013. idx, 0x0b);
  3014. if (err < 0)
  3015. return err;
  3016. imux->items[imux->num_items].label =
  3017. auto_pin_cfg_labels[i];
  3018. imux->items[imux->num_items].index =
  3019. alc880_input_pin_idx(cfg->input_pins[i]);
  3020. imux->num_items++;
  3021. }
  3022. }
  3023. return 0;
  3024. }
  3025. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  3026. hda_nid_t nid, int pin_type,
  3027. int dac_idx)
  3028. {
  3029. /* set as output */
  3030. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3031. pin_type);
  3032. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3033. AMP_OUT_UNMUTE);
  3034. /* need the manual connection? */
  3035. if (alc880_is_multi_pin(nid)) {
  3036. struct alc_spec *spec = codec->spec;
  3037. int idx = alc880_multi_pin_idx(nid);
  3038. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  3039. AC_VERB_SET_CONNECT_SEL,
  3040. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  3041. }
  3042. }
  3043. static int get_pin_type(int line_out_type)
  3044. {
  3045. if (line_out_type == AUTO_PIN_HP_OUT)
  3046. return PIN_HP;
  3047. else
  3048. return PIN_OUT;
  3049. }
  3050. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  3051. {
  3052. struct alc_spec *spec = codec->spec;
  3053. int i;
  3054. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  3055. for (i = 0; i < spec->autocfg.line_outs; i++) {
  3056. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3057. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3058. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  3059. }
  3060. }
  3061. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  3062. {
  3063. struct alc_spec *spec = codec->spec;
  3064. hda_nid_t pin;
  3065. pin = spec->autocfg.speaker_pins[0];
  3066. if (pin) /* connect to front */
  3067. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  3068. pin = spec->autocfg.hp_pins[0];
  3069. if (pin) /* connect to front */
  3070. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  3071. }
  3072. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  3073. {
  3074. struct alc_spec *spec = codec->spec;
  3075. int i;
  3076. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3077. hda_nid_t nid = spec->autocfg.input_pins[i];
  3078. if (alc880_is_input_pin(nid)) {
  3079. snd_hda_codec_write(codec, nid, 0,
  3080. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3081. i <= AUTO_PIN_FRONT_MIC ?
  3082. PIN_VREF80 : PIN_IN);
  3083. if (nid != ALC880_PIN_CD_NID)
  3084. snd_hda_codec_write(codec, nid, 0,
  3085. AC_VERB_SET_AMP_GAIN_MUTE,
  3086. AMP_OUT_MUTE);
  3087. }
  3088. }
  3089. }
  3090. /* parse the BIOS configuration and set up the alc_spec */
  3091. /* return 1 if successful, 0 if the proper config is not found,
  3092. * or a negative error code
  3093. */
  3094. static int alc880_parse_auto_config(struct hda_codec *codec)
  3095. {
  3096. struct alc_spec *spec = codec->spec;
  3097. int err;
  3098. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  3099. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3100. alc880_ignore);
  3101. if (err < 0)
  3102. return err;
  3103. if (!spec->autocfg.line_outs)
  3104. return 0; /* can't find valid BIOS pin config */
  3105. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  3106. if (err < 0)
  3107. return err;
  3108. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  3109. if (err < 0)
  3110. return err;
  3111. err = alc880_auto_create_extra_out(spec,
  3112. spec->autocfg.speaker_pins[0],
  3113. "Speaker");
  3114. if (err < 0)
  3115. return err;
  3116. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  3117. "Headphone");
  3118. if (err < 0)
  3119. return err;
  3120. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  3121. if (err < 0)
  3122. return err;
  3123. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  3124. if (spec->autocfg.dig_out_pin)
  3125. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  3126. if (spec->autocfg.dig_in_pin)
  3127. spec->dig_in_nid = ALC880_DIGIN_NID;
  3128. if (spec->kctl_alloc)
  3129. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3130. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  3131. spec->num_mux_defs = 1;
  3132. spec->input_mux = &spec->private_imux;
  3133. return 1;
  3134. }
  3135. /* additional initialization for auto-configuration model */
  3136. static void alc880_auto_init(struct hda_codec *codec)
  3137. {
  3138. alc880_auto_init_multi_out(codec);
  3139. alc880_auto_init_extra_out(codec);
  3140. alc880_auto_init_analog_input(codec);
  3141. }
  3142. /*
  3143. * OK, here we have finally the patch for ALC880
  3144. */
  3145. static int patch_alc880(struct hda_codec *codec)
  3146. {
  3147. struct alc_spec *spec;
  3148. int board_config;
  3149. int err;
  3150. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3151. if (spec == NULL)
  3152. return -ENOMEM;
  3153. codec->spec = spec;
  3154. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3155. alc880_models,
  3156. alc880_cfg_tbl);
  3157. if (board_config < 0) {
  3158. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3159. "trying auto-probe from BIOS...\n");
  3160. board_config = ALC880_AUTO;
  3161. }
  3162. if (board_config == ALC880_AUTO) {
  3163. /* automatic parse from the BIOS config */
  3164. err = alc880_parse_auto_config(codec);
  3165. if (err < 0) {
  3166. alc_free(codec);
  3167. return err;
  3168. } else if (!err) {
  3169. printk(KERN_INFO
  3170. "hda_codec: Cannot set up configuration "
  3171. "from BIOS. Using 3-stack mode...\n");
  3172. board_config = ALC880_3ST;
  3173. }
  3174. }
  3175. if (board_config != ALC880_AUTO)
  3176. setup_preset(spec, &alc880_presets[board_config]);
  3177. spec->stream_name_analog = "ALC880 Analog";
  3178. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3179. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3180. spec->stream_name_digital = "ALC880 Digital";
  3181. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3182. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3183. if (!spec->adc_nids && spec->input_mux) {
  3184. /* check whether NID 0x07 is valid */
  3185. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3186. /* get type */
  3187. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3188. if (wcap != AC_WID_AUD_IN) {
  3189. spec->adc_nids = alc880_adc_nids_alt;
  3190. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3191. spec->mixers[spec->num_mixers] =
  3192. alc880_capture_alt_mixer;
  3193. spec->num_mixers++;
  3194. } else {
  3195. spec->adc_nids = alc880_adc_nids;
  3196. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3197. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3198. spec->num_mixers++;
  3199. }
  3200. }
  3201. codec->patch_ops = alc_patch_ops;
  3202. if (board_config == ALC880_AUTO)
  3203. spec->init_hook = alc880_auto_init;
  3204. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3205. if (!spec->loopback.amplist)
  3206. spec->loopback.amplist = alc880_loopbacks;
  3207. #endif
  3208. return 0;
  3209. }
  3210. /*
  3211. * ALC260 support
  3212. */
  3213. static hda_nid_t alc260_dac_nids[1] = {
  3214. /* front */
  3215. 0x02,
  3216. };
  3217. static hda_nid_t alc260_adc_nids[1] = {
  3218. /* ADC0 */
  3219. 0x04,
  3220. };
  3221. static hda_nid_t alc260_adc_nids_alt[1] = {
  3222. /* ADC1 */
  3223. 0x05,
  3224. };
  3225. static hda_nid_t alc260_hp_adc_nids[2] = {
  3226. /* ADC1, 0 */
  3227. 0x05, 0x04
  3228. };
  3229. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3230. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3231. */
  3232. static hda_nid_t alc260_dual_adc_nids[2] = {
  3233. /* ADC0, ADC1 */
  3234. 0x04, 0x05
  3235. };
  3236. #define ALC260_DIGOUT_NID 0x03
  3237. #define ALC260_DIGIN_NID 0x06
  3238. static struct hda_input_mux alc260_capture_source = {
  3239. .num_items = 4,
  3240. .items = {
  3241. { "Mic", 0x0 },
  3242. { "Front Mic", 0x1 },
  3243. { "Line", 0x2 },
  3244. { "CD", 0x4 },
  3245. },
  3246. };
  3247. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3248. * headphone jack and the internal CD lines since these are the only pins at
  3249. * which audio can appear. For flexibility, also allow the option of
  3250. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3251. * connection to the mixer output).
  3252. */
  3253. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3254. {
  3255. .num_items = 3,
  3256. .items = {
  3257. { "Mic/Line", 0x0 },
  3258. { "CD", 0x4 },
  3259. { "Headphone", 0x2 },
  3260. },
  3261. },
  3262. {
  3263. .num_items = 4,
  3264. .items = {
  3265. { "Mic/Line", 0x0 },
  3266. { "CD", 0x4 },
  3267. { "Headphone", 0x2 },
  3268. { "Mixer", 0x5 },
  3269. },
  3270. },
  3271. };
  3272. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3273. * the Fujitsu S702x, but jacks are marked differently.
  3274. */
  3275. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3276. {
  3277. .num_items = 4,
  3278. .items = {
  3279. { "Mic", 0x0 },
  3280. { "Line", 0x2 },
  3281. { "CD", 0x4 },
  3282. { "Headphone", 0x5 },
  3283. },
  3284. },
  3285. {
  3286. .num_items = 5,
  3287. .items = {
  3288. { "Mic", 0x0 },
  3289. { "Line", 0x2 },
  3290. { "CD", 0x4 },
  3291. { "Headphone", 0x6 },
  3292. { "Mixer", 0x5 },
  3293. },
  3294. },
  3295. };
  3296. /*
  3297. * This is just place-holder, so there's something for alc_build_pcms to look
  3298. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3299. * element which allows changing the channel mode, so the verb list is
  3300. * never used.
  3301. */
  3302. static struct hda_channel_mode alc260_modes[1] = {
  3303. { 2, NULL },
  3304. };
  3305. /* Mixer combinations
  3306. *
  3307. * basic: base_output + input + pc_beep + capture
  3308. * HP: base_output + input + capture_alt
  3309. * HP_3013: hp_3013 + input + capture
  3310. * fujitsu: fujitsu + capture
  3311. * acer: acer + capture
  3312. */
  3313. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3314. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3315. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3316. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3317. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3318. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3319. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3320. { } /* end */
  3321. };
  3322. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3323. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3324. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3325. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3326. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3327. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3328. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3329. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3330. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3331. { } /* end */
  3332. };
  3333. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3334. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3335. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3336. { } /* end */
  3337. };
  3338. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3339. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3340. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3341. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3342. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3343. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3344. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3345. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3346. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3347. { } /* end */
  3348. };
  3349. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3350. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3351. */
  3352. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3353. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3354. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3355. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3356. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3357. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3358. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3359. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3360. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3361. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3362. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3363. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3364. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3365. { } /* end */
  3366. };
  3367. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3368. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3369. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3370. * datasheet doesn't mention this restriction. At this stage it's not clear
  3371. * whether this behaviour is intentional or is a hardware bug in chip
  3372. * revisions available in early 2006. Therefore for now allow the
  3373. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3374. * that the lack of mic bias for this NID is intentional we could change the
  3375. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3376. *
  3377. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3378. * don't appear to make the mic bias available from the "line" jack, even
  3379. * though the NID used for this jack (0x14) can supply it. The theory is
  3380. * that perhaps Acer have included blocking capacitors between the ALC260
  3381. * and the output jack. If this turns out to be the case for all such
  3382. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3383. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3384. *
  3385. * The C20x Tablet series have a mono internal speaker which is controlled
  3386. * via the chip's Mono sum widget and pin complex, so include the necessary
  3387. * controls for such models. On models without a "mono speaker" the control
  3388. * won't do anything.
  3389. */
  3390. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3391. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3392. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3393. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3394. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3395. HDA_OUTPUT),
  3396. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3397. HDA_INPUT),
  3398. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3399. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3400. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3401. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3402. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3403. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3404. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3405. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3406. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3407. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3408. { } /* end */
  3409. };
  3410. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3411. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3412. */
  3413. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3414. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3415. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3416. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3417. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3418. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3419. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3420. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3421. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3422. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3423. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3424. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3425. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3426. { } /* end */
  3427. };
  3428. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3429. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3430. */
  3431. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3432. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3433. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3434. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3435. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3436. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3437. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3438. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3439. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3440. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3441. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3442. { } /* end */
  3443. };
  3444. /* capture mixer elements */
  3445. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3446. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3447. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3448. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3449. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3450. {
  3451. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3452. /* The multiple "Capture Source" controls confuse alsamixer
  3453. * So call somewhat different..
  3454. * FIXME: the controls appear in the "playback" view!
  3455. */
  3456. /* .name = "Capture Source", */
  3457. .name = "Input Source",
  3458. .count = 2,
  3459. .info = alc_mux_enum_info,
  3460. .get = alc_mux_enum_get,
  3461. .put = alc_mux_enum_put,
  3462. },
  3463. { } /* end */
  3464. };
  3465. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3466. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3467. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3468. {
  3469. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3470. /* The multiple "Capture Source" controls confuse alsamixer
  3471. * So call somewhat different..
  3472. * FIXME: the controls appear in the "playback" view!
  3473. */
  3474. /* .name = "Capture Source", */
  3475. .name = "Input Source",
  3476. .count = 1,
  3477. .info = alc_mux_enum_info,
  3478. .get = alc_mux_enum_get,
  3479. .put = alc_mux_enum_put,
  3480. },
  3481. { } /* end */
  3482. };
  3483. /*
  3484. * initialization verbs
  3485. */
  3486. static struct hda_verb alc260_init_verbs[] = {
  3487. /* Line In pin widget for input */
  3488. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3489. /* CD pin widget for input */
  3490. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3491. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3492. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3493. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3494. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3495. /* LINE-2 is used for line-out in rear */
  3496. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3497. /* select line-out */
  3498. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3499. /* LINE-OUT pin */
  3500. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3501. /* enable HP */
  3502. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3503. /* enable Mono */
  3504. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3505. /* mute capture amp left and right */
  3506. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3507. /* set connection select to line in (default select for this ADC) */
  3508. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3509. /* mute capture amp left and right */
  3510. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3511. /* set connection select to line in (default select for this ADC) */
  3512. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3513. /* set vol=0 Line-Out mixer amp left and right */
  3514. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3515. /* unmute pin widget amp left and right (no gain on this amp) */
  3516. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3517. /* set vol=0 HP mixer amp left and right */
  3518. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3519. /* unmute pin widget amp left and right (no gain on this amp) */
  3520. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3521. /* set vol=0 Mono mixer amp left and right */
  3522. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3523. /* unmute pin widget amp left and right (no gain on this amp) */
  3524. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3525. /* unmute LINE-2 out pin */
  3526. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3527. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3528. * Line In 2 = 0x03
  3529. */
  3530. /* mute analog inputs */
  3531. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3532. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3533. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3534. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3535. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3536. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3537. /* mute Front out path */
  3538. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3539. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3540. /* mute Headphone out path */
  3541. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3542. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3543. /* mute Mono out path */
  3544. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3545. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3546. { }
  3547. };
  3548. #if 0 /* should be identical with alc260_init_verbs? */
  3549. static struct hda_verb alc260_hp_init_verbs[] = {
  3550. /* Headphone and output */
  3551. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3552. /* mono output */
  3553. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3554. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3555. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3556. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3557. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3558. /* Line In pin widget for input */
  3559. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3560. /* Line-2 pin widget for output */
  3561. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3562. /* CD pin widget for input */
  3563. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3564. /* unmute amp left and right */
  3565. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3566. /* set connection select to line in (default select for this ADC) */
  3567. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3568. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3569. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3570. /* mute pin widget amp left and right (no gain on this amp) */
  3571. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3572. /* unmute HP mixer amp left and right (volume = 0) */
  3573. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3574. /* mute pin widget amp left and right (no gain on this amp) */
  3575. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3576. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3577. * Line In 2 = 0x03
  3578. */
  3579. /* mute analog inputs */
  3580. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3581. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3582. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3583. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3584. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3585. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3586. /* Unmute Front out path */
  3587. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3588. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3589. /* Unmute Headphone out path */
  3590. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3591. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3592. /* Unmute Mono out path */
  3593. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3594. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3595. { }
  3596. };
  3597. #endif
  3598. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3599. /* Line out and output */
  3600. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3601. /* mono output */
  3602. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3603. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3604. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3605. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3606. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3607. /* Line In pin widget for input */
  3608. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3609. /* Headphone pin widget for output */
  3610. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3611. /* CD pin widget for input */
  3612. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3613. /* unmute amp left and right */
  3614. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3615. /* set connection select to line in (default select for this ADC) */
  3616. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3617. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3618. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3619. /* mute pin widget amp left and right (no gain on this amp) */
  3620. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3621. /* unmute HP mixer amp left and right (volume = 0) */
  3622. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3623. /* mute pin widget amp left and right (no gain on this amp) */
  3624. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3625. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3626. * Line In 2 = 0x03
  3627. */
  3628. /* mute analog inputs */
  3629. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3630. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3631. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3632. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3633. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3634. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3635. /* Unmute Front out path */
  3636. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3637. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3638. /* Unmute Headphone out path */
  3639. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3640. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3641. /* Unmute Mono out path */
  3642. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3643. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3644. { }
  3645. };
  3646. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3647. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3648. * audio = 0x16, internal speaker = 0x10.
  3649. */
  3650. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3651. /* Disable all GPIOs */
  3652. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3653. /* Internal speaker is connected to headphone pin */
  3654. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3655. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3656. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3657. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3658. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3659. /* Ensure all other unused pins are disabled and muted. */
  3660. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3661. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3662. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3663. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3664. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3665. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3666. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3667. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3668. /* Disable digital (SPDIF) pins */
  3669. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3670. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3671. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3672. * when acting as an output.
  3673. */
  3674. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3675. /* Start with output sum widgets muted and their output gains at min */
  3676. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3677. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3678. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3679. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3680. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3681. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3682. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3683. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3684. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3685. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3686. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3687. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3688. * If the pin mode is changed by the user the pin mode control will
  3689. * take care of enabling the pin's input/output buffers as needed.
  3690. * Therefore there's no need to enable the input buffer at this
  3691. * stage.
  3692. */
  3693. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3694. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3695. * mixer ctrl)
  3696. */
  3697. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3698. /* Mute capture amp left and right */
  3699. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3700. /* Set ADC connection select to match default mixer setting - line
  3701. * in (on mic1 pin)
  3702. */
  3703. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3704. /* Do the same for the second ADC: mute capture input amp and
  3705. * set ADC connection to line in (on mic1 pin)
  3706. */
  3707. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3708. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3709. /* Mute all inputs to mixer widget (even unconnected ones) */
  3710. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3711. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3712. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3713. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3714. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3715. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3716. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3717. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3718. { }
  3719. };
  3720. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3721. * similar laptops (adapted from Fujitsu init verbs).
  3722. */
  3723. static struct hda_verb alc260_acer_init_verbs[] = {
  3724. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3725. * the headphone jack. Turn this on and rely on the standard mute
  3726. * methods whenever the user wants to turn these outputs off.
  3727. */
  3728. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3729. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3730. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3731. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3732. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3733. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3734. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3735. /* Line In jack is connected to Line1 pin */
  3736. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3737. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3738. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3739. /* Ensure all other unused pins are disabled and muted. */
  3740. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3741. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3742. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3743. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3744. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3745. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3746. /* Disable digital (SPDIF) pins */
  3747. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3748. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3749. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3750. * bus when acting as outputs.
  3751. */
  3752. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3753. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3754. /* Start with output sum widgets muted and their output gains at min */
  3755. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3756. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3757. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3758. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3759. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3760. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3761. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3762. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3763. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3764. /* Unmute Line-out pin widget amp left and right
  3765. * (no equiv mixer ctrl)
  3766. */
  3767. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3768. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3769. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3770. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3771. * inputs. If the pin mode is changed by the user the pin mode control
  3772. * will take care of enabling the pin's input/output buffers as needed.
  3773. * Therefore there's no need to enable the input buffer at this
  3774. * stage.
  3775. */
  3776. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3777. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3778. /* Mute capture amp left and right */
  3779. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3780. /* Set ADC connection select to match default mixer setting - mic
  3781. * (on mic1 pin)
  3782. */
  3783. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3784. /* Do similar with the second ADC: mute capture input amp and
  3785. * set ADC connection to mic to match ALSA's default state.
  3786. */
  3787. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3788. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3789. /* Mute all inputs to mixer widget (even unconnected ones) */
  3790. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3791. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3792. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3793. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3794. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3795. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3796. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3797. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3798. { }
  3799. };
  3800. static struct hda_verb alc260_will_verbs[] = {
  3801. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3802. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3803. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3804. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3805. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3806. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3807. {}
  3808. };
  3809. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3810. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3811. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3812. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3813. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3814. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3815. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3816. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3817. {}
  3818. };
  3819. /* toggle speaker-output according to the hp-jack state */
  3820. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3821. {
  3822. unsigned int present;
  3823. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3824. present = snd_hda_codec_read(codec, 0x0f, 0,
  3825. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3826. if (present) {
  3827. snd_hda_codec_write_cache(codec, 0x01, 0,
  3828. AC_VERB_SET_GPIO_DATA, 1);
  3829. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3830. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3831. PIN_HP);
  3832. } else {
  3833. snd_hda_codec_write_cache(codec, 0x01, 0,
  3834. AC_VERB_SET_GPIO_DATA, 0);
  3835. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3836. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3837. PIN_OUT);
  3838. }
  3839. }
  3840. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3841. unsigned int res)
  3842. {
  3843. if ((res >> 26) == ALC880_HP_EVENT)
  3844. alc260_replacer_672v_automute(codec);
  3845. }
  3846. /* Test configuration for debugging, modelled after the ALC880 test
  3847. * configuration.
  3848. */
  3849. #ifdef CONFIG_SND_DEBUG
  3850. static hda_nid_t alc260_test_dac_nids[1] = {
  3851. 0x02,
  3852. };
  3853. static hda_nid_t alc260_test_adc_nids[2] = {
  3854. 0x04, 0x05,
  3855. };
  3856. /* For testing the ALC260, each input MUX needs its own definition since
  3857. * the signal assignments are different. This assumes that the first ADC
  3858. * is NID 0x04.
  3859. */
  3860. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3861. {
  3862. .num_items = 7,
  3863. .items = {
  3864. { "MIC1 pin", 0x0 },
  3865. { "MIC2 pin", 0x1 },
  3866. { "LINE1 pin", 0x2 },
  3867. { "LINE2 pin", 0x3 },
  3868. { "CD pin", 0x4 },
  3869. { "LINE-OUT pin", 0x5 },
  3870. { "HP-OUT pin", 0x6 },
  3871. },
  3872. },
  3873. {
  3874. .num_items = 8,
  3875. .items = {
  3876. { "MIC1 pin", 0x0 },
  3877. { "MIC2 pin", 0x1 },
  3878. { "LINE1 pin", 0x2 },
  3879. { "LINE2 pin", 0x3 },
  3880. { "CD pin", 0x4 },
  3881. { "Mixer", 0x5 },
  3882. { "LINE-OUT pin", 0x6 },
  3883. { "HP-OUT pin", 0x7 },
  3884. },
  3885. },
  3886. };
  3887. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3888. /* Output driver widgets */
  3889. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3890. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3891. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3892. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3893. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3894. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3895. /* Modes for retasking pin widgets
  3896. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3897. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3898. * mention this restriction. At this stage it's not clear whether
  3899. * this behaviour is intentional or is a hardware bug in chip
  3900. * revisions available at least up until early 2006. Therefore for
  3901. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3902. * choices, but if it turns out that the lack of mic bias for these
  3903. * NIDs is intentional we could change their modes from
  3904. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3905. */
  3906. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3907. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3908. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3909. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3910. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3911. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3912. /* Loopback mixer controls */
  3913. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3914. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3915. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3916. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3917. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3918. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3919. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3920. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3921. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3922. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3923. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3924. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3925. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3926. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3927. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3928. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3929. /* Controls for GPIO pins, assuming they are configured as outputs */
  3930. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3931. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3932. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3933. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3934. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3935. * is ambigious as to which NID is which; testing on laptops which
  3936. * make this output available should provide clarification.
  3937. */
  3938. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3939. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3940. { } /* end */
  3941. };
  3942. static struct hda_verb alc260_test_init_verbs[] = {
  3943. /* Enable all GPIOs as outputs with an initial value of 0 */
  3944. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3945. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3946. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3947. /* Enable retasking pins as output, initially without power amp */
  3948. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3949. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3950. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3951. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3952. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3953. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3954. /* Disable digital (SPDIF) pins initially, but users can enable
  3955. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3956. * payload also sets the generation to 0, output to be in "consumer"
  3957. * PCM format, copyright asserted, no pre-emphasis and no validity
  3958. * control.
  3959. */
  3960. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3961. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3962. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3963. * OUT1 sum bus when acting as an output.
  3964. */
  3965. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3966. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3967. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3968. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3969. /* Start with output sum widgets muted and their output gains at min */
  3970. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3971. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3972. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3973. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3974. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3975. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3976. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3977. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3978. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3979. /* Unmute retasking pin widget output buffers since the default
  3980. * state appears to be output. As the pin mode is changed by the
  3981. * user the pin mode control will take care of enabling the pin's
  3982. * input/output buffers as needed.
  3983. */
  3984. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3985. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3986. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3987. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3988. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3989. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3990. /* Also unmute the mono-out pin widget */
  3991. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3992. /* Mute capture amp left and right */
  3993. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3994. /* Set ADC connection select to match default mixer setting (mic1
  3995. * pin)
  3996. */
  3997. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3998. /* Do the same for the second ADC: mute capture input amp and
  3999. * set ADC connection to mic1 pin
  4000. */
  4001. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4002. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4003. /* Mute all inputs to mixer widget (even unconnected ones) */
  4004. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  4005. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  4006. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  4007. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  4008. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  4009. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  4010. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  4011. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  4012. { }
  4013. };
  4014. #endif
  4015. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  4016. .substreams = 1,
  4017. .channels_min = 2,
  4018. .channels_max = 2,
  4019. };
  4020. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  4021. .substreams = 1,
  4022. .channels_min = 2,
  4023. .channels_max = 2,
  4024. };
  4025. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  4026. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  4027. /*
  4028. * for BIOS auto-configuration
  4029. */
  4030. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  4031. const char *pfx)
  4032. {
  4033. hda_nid_t nid_vol;
  4034. unsigned long vol_val, sw_val;
  4035. char name[32];
  4036. int err;
  4037. if (nid >= 0x0f && nid < 0x11) {
  4038. nid_vol = nid - 0x7;
  4039. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  4040. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  4041. } else if (nid == 0x11) {
  4042. nid_vol = nid - 0x7;
  4043. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  4044. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  4045. } else if (nid >= 0x12 && nid <= 0x15) {
  4046. nid_vol = 0x08;
  4047. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  4048. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  4049. } else
  4050. return 0; /* N/A */
  4051. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  4052. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  4053. if (err < 0)
  4054. return err;
  4055. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  4056. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  4057. if (err < 0)
  4058. return err;
  4059. return 1;
  4060. }
  4061. /* add playback controls from the parsed DAC table */
  4062. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  4063. const struct auto_pin_cfg *cfg)
  4064. {
  4065. hda_nid_t nid;
  4066. int err;
  4067. spec->multiout.num_dacs = 1;
  4068. spec->multiout.dac_nids = spec->private_dac_nids;
  4069. spec->multiout.dac_nids[0] = 0x02;
  4070. nid = cfg->line_out_pins[0];
  4071. if (nid) {
  4072. err = alc260_add_playback_controls(spec, nid, "Front");
  4073. if (err < 0)
  4074. return err;
  4075. }
  4076. nid = cfg->speaker_pins[0];
  4077. if (nid) {
  4078. err = alc260_add_playback_controls(spec, nid, "Speaker");
  4079. if (err < 0)
  4080. return err;
  4081. }
  4082. nid = cfg->hp_pins[0];
  4083. if (nid) {
  4084. err = alc260_add_playback_controls(spec, nid, "Headphone");
  4085. if (err < 0)
  4086. return err;
  4087. }
  4088. return 0;
  4089. }
  4090. /* create playback/capture controls for input pins */
  4091. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  4092. const struct auto_pin_cfg *cfg)
  4093. {
  4094. struct hda_input_mux *imux = &spec->private_imux;
  4095. int i, err, idx;
  4096. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4097. if (cfg->input_pins[i] >= 0x12) {
  4098. idx = cfg->input_pins[i] - 0x12;
  4099. err = new_analog_input(spec, cfg->input_pins[i],
  4100. auto_pin_cfg_labels[i], idx,
  4101. 0x07);
  4102. if (err < 0)
  4103. return err;
  4104. imux->items[imux->num_items].label =
  4105. auto_pin_cfg_labels[i];
  4106. imux->items[imux->num_items].index = idx;
  4107. imux->num_items++;
  4108. }
  4109. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  4110. idx = cfg->input_pins[i] - 0x09;
  4111. err = new_analog_input(spec, cfg->input_pins[i],
  4112. auto_pin_cfg_labels[i], idx,
  4113. 0x07);
  4114. if (err < 0)
  4115. return err;
  4116. imux->items[imux->num_items].label =
  4117. auto_pin_cfg_labels[i];
  4118. imux->items[imux->num_items].index = idx;
  4119. imux->num_items++;
  4120. }
  4121. }
  4122. return 0;
  4123. }
  4124. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  4125. hda_nid_t nid, int pin_type,
  4126. int sel_idx)
  4127. {
  4128. /* set as output */
  4129. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4130. pin_type);
  4131. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4132. AMP_OUT_UNMUTE);
  4133. /* need the manual connection? */
  4134. if (nid >= 0x12) {
  4135. int idx = nid - 0x12;
  4136. snd_hda_codec_write(codec, idx + 0x0b, 0,
  4137. AC_VERB_SET_CONNECT_SEL, sel_idx);
  4138. }
  4139. }
  4140. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4141. {
  4142. struct alc_spec *spec = codec->spec;
  4143. hda_nid_t nid;
  4144. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4145. nid = spec->autocfg.line_out_pins[0];
  4146. if (nid) {
  4147. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4148. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4149. }
  4150. nid = spec->autocfg.speaker_pins[0];
  4151. if (nid)
  4152. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4153. nid = spec->autocfg.hp_pins[0];
  4154. if (nid)
  4155. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4156. }
  4157. #define ALC260_PIN_CD_NID 0x16
  4158. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4159. {
  4160. struct alc_spec *spec = codec->spec;
  4161. int i;
  4162. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4163. hda_nid_t nid = spec->autocfg.input_pins[i];
  4164. if (nid >= 0x12) {
  4165. snd_hda_codec_write(codec, nid, 0,
  4166. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4167. i <= AUTO_PIN_FRONT_MIC ?
  4168. PIN_VREF80 : PIN_IN);
  4169. if (nid != ALC260_PIN_CD_NID)
  4170. snd_hda_codec_write(codec, nid, 0,
  4171. AC_VERB_SET_AMP_GAIN_MUTE,
  4172. AMP_OUT_MUTE);
  4173. }
  4174. }
  4175. }
  4176. /*
  4177. * generic initialization of ADC, input mixers and output mixers
  4178. */
  4179. static struct hda_verb alc260_volume_init_verbs[] = {
  4180. /*
  4181. * Unmute ADC0-1 and set the default input to mic-in
  4182. */
  4183. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4184. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4185. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4186. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4187. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4188. * mixer widget
  4189. * Note: PASD motherboards uses the Line In 2 as the input for
  4190. * front panel mic (mic 2)
  4191. */
  4192. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4193. /* mute analog inputs */
  4194. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4195. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4196. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4197. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4198. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4199. /*
  4200. * Set up output mixers (0x08 - 0x0a)
  4201. */
  4202. /* set vol=0 to output mixers */
  4203. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4204. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4205. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4206. /* set up input amps for analog loopback */
  4207. /* Amp Indices: DAC = 0, mixer = 1 */
  4208. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4209. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4210. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4211. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4212. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4213. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4214. { }
  4215. };
  4216. static int alc260_parse_auto_config(struct hda_codec *codec)
  4217. {
  4218. struct alc_spec *spec = codec->spec;
  4219. unsigned int wcap;
  4220. int err;
  4221. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4222. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4223. alc260_ignore);
  4224. if (err < 0)
  4225. return err;
  4226. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4227. if (err < 0)
  4228. return err;
  4229. if (!spec->kctl_alloc)
  4230. return 0; /* can't find valid BIOS pin config */
  4231. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4232. if (err < 0)
  4233. return err;
  4234. spec->multiout.max_channels = 2;
  4235. if (spec->autocfg.dig_out_pin)
  4236. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4237. if (spec->kctl_alloc)
  4238. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4239. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4240. spec->num_mux_defs = 1;
  4241. spec->input_mux = &spec->private_imux;
  4242. /* check whether NID 0x04 is valid */
  4243. wcap = get_wcaps(codec, 0x04);
  4244. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4245. if (wcap != AC_WID_AUD_IN) {
  4246. spec->adc_nids = alc260_adc_nids_alt;
  4247. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4248. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4249. } else {
  4250. spec->adc_nids = alc260_adc_nids;
  4251. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4252. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4253. }
  4254. spec->num_mixers++;
  4255. return 1;
  4256. }
  4257. /* additional initialization for auto-configuration model */
  4258. static void alc260_auto_init(struct hda_codec *codec)
  4259. {
  4260. alc260_auto_init_multi_out(codec);
  4261. alc260_auto_init_analog_input(codec);
  4262. }
  4263. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4264. static struct hda_amp_list alc260_loopbacks[] = {
  4265. { 0x07, HDA_INPUT, 0 },
  4266. { 0x07, HDA_INPUT, 1 },
  4267. { 0x07, HDA_INPUT, 2 },
  4268. { 0x07, HDA_INPUT, 3 },
  4269. { 0x07, HDA_INPUT, 4 },
  4270. { } /* end */
  4271. };
  4272. #endif
  4273. /*
  4274. * ALC260 configurations
  4275. */
  4276. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4277. [ALC260_BASIC] = "basic",
  4278. [ALC260_HP] = "hp",
  4279. [ALC260_HP_3013] = "hp-3013",
  4280. [ALC260_FUJITSU_S702X] = "fujitsu",
  4281. [ALC260_ACER] = "acer",
  4282. [ALC260_WILL] = "will",
  4283. [ALC260_REPLACER_672V] = "replacer",
  4284. #ifdef CONFIG_SND_DEBUG
  4285. [ALC260_TEST] = "test",
  4286. #endif
  4287. [ALC260_AUTO] = "auto",
  4288. };
  4289. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4290. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4291. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4292. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4293. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4294. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4295. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4296. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4297. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4298. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4299. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4300. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4301. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4302. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4303. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4304. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4305. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4306. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4307. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4308. {}
  4309. };
  4310. static struct alc_config_preset alc260_presets[] = {
  4311. [ALC260_BASIC] = {
  4312. .mixers = { alc260_base_output_mixer,
  4313. alc260_input_mixer,
  4314. alc260_pc_beep_mixer,
  4315. alc260_capture_mixer },
  4316. .init_verbs = { alc260_init_verbs },
  4317. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4318. .dac_nids = alc260_dac_nids,
  4319. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4320. .adc_nids = alc260_adc_nids,
  4321. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4322. .channel_mode = alc260_modes,
  4323. .input_mux = &alc260_capture_source,
  4324. },
  4325. [ALC260_HP] = {
  4326. .mixers = { alc260_base_output_mixer,
  4327. alc260_input_mixer,
  4328. alc260_capture_alt_mixer },
  4329. .init_verbs = { alc260_init_verbs },
  4330. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4331. .dac_nids = alc260_dac_nids,
  4332. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4333. .adc_nids = alc260_hp_adc_nids,
  4334. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4335. .channel_mode = alc260_modes,
  4336. .input_mux = &alc260_capture_source,
  4337. },
  4338. [ALC260_HP_3013] = {
  4339. .mixers = { alc260_hp_3013_mixer,
  4340. alc260_input_mixer,
  4341. alc260_capture_alt_mixer },
  4342. .init_verbs = { alc260_hp_3013_init_verbs },
  4343. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4344. .dac_nids = alc260_dac_nids,
  4345. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4346. .adc_nids = alc260_hp_adc_nids,
  4347. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4348. .channel_mode = alc260_modes,
  4349. .input_mux = &alc260_capture_source,
  4350. },
  4351. [ALC260_FUJITSU_S702X] = {
  4352. .mixers = { alc260_fujitsu_mixer,
  4353. alc260_capture_mixer },
  4354. .init_verbs = { alc260_fujitsu_init_verbs },
  4355. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4356. .dac_nids = alc260_dac_nids,
  4357. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4358. .adc_nids = alc260_dual_adc_nids,
  4359. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4360. .channel_mode = alc260_modes,
  4361. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4362. .input_mux = alc260_fujitsu_capture_sources,
  4363. },
  4364. [ALC260_ACER] = {
  4365. .mixers = { alc260_acer_mixer,
  4366. alc260_capture_mixer },
  4367. .init_verbs = { alc260_acer_init_verbs },
  4368. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4369. .dac_nids = alc260_dac_nids,
  4370. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4371. .adc_nids = alc260_dual_adc_nids,
  4372. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4373. .channel_mode = alc260_modes,
  4374. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4375. .input_mux = alc260_acer_capture_sources,
  4376. },
  4377. [ALC260_WILL] = {
  4378. .mixers = { alc260_will_mixer,
  4379. alc260_capture_mixer },
  4380. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4381. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4382. .dac_nids = alc260_dac_nids,
  4383. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4384. .adc_nids = alc260_adc_nids,
  4385. .dig_out_nid = ALC260_DIGOUT_NID,
  4386. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4387. .channel_mode = alc260_modes,
  4388. .input_mux = &alc260_capture_source,
  4389. },
  4390. [ALC260_REPLACER_672V] = {
  4391. .mixers = { alc260_replacer_672v_mixer,
  4392. alc260_capture_mixer },
  4393. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4394. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4395. .dac_nids = alc260_dac_nids,
  4396. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4397. .adc_nids = alc260_adc_nids,
  4398. .dig_out_nid = ALC260_DIGOUT_NID,
  4399. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4400. .channel_mode = alc260_modes,
  4401. .input_mux = &alc260_capture_source,
  4402. .unsol_event = alc260_replacer_672v_unsol_event,
  4403. .init_hook = alc260_replacer_672v_automute,
  4404. },
  4405. #ifdef CONFIG_SND_DEBUG
  4406. [ALC260_TEST] = {
  4407. .mixers = { alc260_test_mixer,
  4408. alc260_capture_mixer },
  4409. .init_verbs = { alc260_test_init_verbs },
  4410. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4411. .dac_nids = alc260_test_dac_nids,
  4412. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4413. .adc_nids = alc260_test_adc_nids,
  4414. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4415. .channel_mode = alc260_modes,
  4416. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4417. .input_mux = alc260_test_capture_sources,
  4418. },
  4419. #endif
  4420. };
  4421. static int patch_alc260(struct hda_codec *codec)
  4422. {
  4423. struct alc_spec *spec;
  4424. int err, board_config;
  4425. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4426. if (spec == NULL)
  4427. return -ENOMEM;
  4428. codec->spec = spec;
  4429. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4430. alc260_models,
  4431. alc260_cfg_tbl);
  4432. if (board_config < 0) {
  4433. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4434. "trying auto-probe from BIOS...\n");
  4435. board_config = ALC260_AUTO;
  4436. }
  4437. if (board_config == ALC260_AUTO) {
  4438. /* automatic parse from the BIOS config */
  4439. err = alc260_parse_auto_config(codec);
  4440. if (err < 0) {
  4441. alc_free(codec);
  4442. return err;
  4443. } else if (!err) {
  4444. printk(KERN_INFO
  4445. "hda_codec: Cannot set up configuration "
  4446. "from BIOS. Using base mode...\n");
  4447. board_config = ALC260_BASIC;
  4448. }
  4449. }
  4450. if (board_config != ALC260_AUTO)
  4451. setup_preset(spec, &alc260_presets[board_config]);
  4452. spec->stream_name_analog = "ALC260 Analog";
  4453. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4454. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4455. spec->stream_name_digital = "ALC260 Digital";
  4456. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4457. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4458. codec->patch_ops = alc_patch_ops;
  4459. if (board_config == ALC260_AUTO)
  4460. spec->init_hook = alc260_auto_init;
  4461. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4462. if (!spec->loopback.amplist)
  4463. spec->loopback.amplist = alc260_loopbacks;
  4464. #endif
  4465. return 0;
  4466. }
  4467. /*
  4468. * ALC882 support
  4469. *
  4470. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4471. * configuration. Each pin widget can choose any input DACs and a mixer.
  4472. * Each ADC is connected from a mixer of all inputs. This makes possible
  4473. * 6-channel independent captures.
  4474. *
  4475. * In addition, an independent DAC for the multi-playback (not used in this
  4476. * driver yet).
  4477. */
  4478. #define ALC882_DIGOUT_NID 0x06
  4479. #define ALC882_DIGIN_NID 0x0a
  4480. static struct hda_channel_mode alc882_ch_modes[1] = {
  4481. { 8, NULL }
  4482. };
  4483. static hda_nid_t alc882_dac_nids[4] = {
  4484. /* front, rear, clfe, rear_surr */
  4485. 0x02, 0x03, 0x04, 0x05
  4486. };
  4487. /* identical with ALC880 */
  4488. #define alc882_adc_nids alc880_adc_nids
  4489. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4490. /* input MUX */
  4491. /* FIXME: should be a matrix-type input source selection */
  4492. static struct hda_input_mux alc882_capture_source = {
  4493. .num_items = 4,
  4494. .items = {
  4495. { "Mic", 0x0 },
  4496. { "Front Mic", 0x1 },
  4497. { "Line", 0x2 },
  4498. { "CD", 0x4 },
  4499. },
  4500. };
  4501. #define alc882_mux_enum_info alc_mux_enum_info
  4502. #define alc882_mux_enum_get alc_mux_enum_get
  4503. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4504. struct snd_ctl_elem_value *ucontrol)
  4505. {
  4506. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4507. struct alc_spec *spec = codec->spec;
  4508. const struct hda_input_mux *imux = spec->input_mux;
  4509. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4510. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4511. hda_nid_t nid = capture_mixers[adc_idx];
  4512. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4513. unsigned int i, idx;
  4514. idx = ucontrol->value.enumerated.item[0];
  4515. if (idx >= imux->num_items)
  4516. idx = imux->num_items - 1;
  4517. if (*cur_val == idx)
  4518. return 0;
  4519. for (i = 0; i < imux->num_items; i++) {
  4520. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4521. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4522. imux->items[i].index,
  4523. HDA_AMP_MUTE, v);
  4524. }
  4525. *cur_val = idx;
  4526. return 1;
  4527. }
  4528. /*
  4529. * 2ch mode
  4530. */
  4531. static struct hda_verb alc882_3ST_ch2_init[] = {
  4532. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4533. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4534. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4535. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4536. { } /* end */
  4537. };
  4538. /*
  4539. * 6ch mode
  4540. */
  4541. static struct hda_verb alc882_3ST_ch6_init[] = {
  4542. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4543. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4544. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4545. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4546. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4547. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4548. { } /* end */
  4549. };
  4550. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4551. { 2, alc882_3ST_ch2_init },
  4552. { 6, alc882_3ST_ch6_init },
  4553. };
  4554. /*
  4555. * 6ch mode
  4556. */
  4557. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4558. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4559. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4560. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4561. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4562. { } /* end */
  4563. };
  4564. /*
  4565. * 8ch mode
  4566. */
  4567. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4568. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4569. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4570. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4571. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4572. { } /* end */
  4573. };
  4574. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4575. { 6, alc882_sixstack_ch6_init },
  4576. { 8, alc882_sixstack_ch8_init },
  4577. };
  4578. /*
  4579. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4580. */
  4581. /*
  4582. * 2ch mode
  4583. */
  4584. static struct hda_verb alc885_mbp_ch2_init[] = {
  4585. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4586. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4587. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4588. { } /* end */
  4589. };
  4590. /*
  4591. * 6ch mode
  4592. */
  4593. static struct hda_verb alc885_mbp_ch6_init[] = {
  4594. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4595. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4596. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4597. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4598. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4599. { } /* end */
  4600. };
  4601. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4602. { 2, alc885_mbp_ch2_init },
  4603. { 6, alc885_mbp_ch6_init },
  4604. };
  4605. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4606. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4607. */
  4608. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4609. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4610. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4611. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4612. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4613. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4614. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4615. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4616. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4617. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4618. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4619. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4620. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4621. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4622. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4623. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4624. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4625. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4626. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4627. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4628. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4629. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4630. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4631. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4632. { } /* end */
  4633. };
  4634. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4635. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4636. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4637. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4638. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4639. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4640. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4641. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4642. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4643. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4644. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4645. { } /* end */
  4646. };
  4647. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4648. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4649. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4650. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4651. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4652. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4653. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4654. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4655. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4656. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4657. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4658. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4659. { } /* end */
  4660. };
  4661. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4662. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4663. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4664. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4665. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4666. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4667. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4668. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4669. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4670. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4671. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4672. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4673. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4674. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4675. { } /* end */
  4676. };
  4677. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4678. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4679. */
  4680. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4681. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4682. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4683. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4684. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4685. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4686. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4687. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4688. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4689. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4690. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4691. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4692. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4693. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4694. { } /* end */
  4695. };
  4696. static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
  4697. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4698. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4699. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4700. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4701. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4702. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4703. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4704. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4705. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4706. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4707. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4708. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4709. { } /* end */
  4710. };
  4711. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4712. {
  4713. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4714. .name = "Channel Mode",
  4715. .info = alc_ch_mode_info,
  4716. .get = alc_ch_mode_get,
  4717. .put = alc_ch_mode_put,
  4718. },
  4719. { } /* end */
  4720. };
  4721. static struct hda_verb alc882_init_verbs[] = {
  4722. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4723. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4724. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4725. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4726. /* Rear mixer */
  4727. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4728. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4729. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4730. /* CLFE mixer */
  4731. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4732. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4733. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4734. /* Side mixer */
  4735. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4736. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4737. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4738. /* Front Pin: output 0 (0x0c) */
  4739. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4740. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4741. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4742. /* Rear Pin: output 1 (0x0d) */
  4743. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4744. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4745. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4746. /* CLFE Pin: output 2 (0x0e) */
  4747. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4748. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4749. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4750. /* Side Pin: output 3 (0x0f) */
  4751. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4752. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4753. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4754. /* Mic (rear) pin: input vref at 80% */
  4755. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4756. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4757. /* Front Mic pin: input vref at 80% */
  4758. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4759. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4760. /* Line In pin: input */
  4761. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4762. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4763. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4764. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4765. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4766. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4767. /* CD pin widget for input */
  4768. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4769. /* FIXME: use matrix-type input source selection */
  4770. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4771. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4772. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4773. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4774. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4775. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4776. /* Input mixer2 */
  4777. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4778. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4779. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4780. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4781. /* Input mixer3 */
  4782. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4783. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4784. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4785. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4786. /* ADC1: mute amp left and right */
  4787. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4788. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4789. /* ADC2: mute amp left and right */
  4790. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4791. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4792. /* ADC3: mute amp left and right */
  4793. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4794. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4795. { }
  4796. };
  4797. static struct hda_verb alc882_eapd_verbs[] = {
  4798. /* change to EAPD mode */
  4799. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4800. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4801. { }
  4802. };
  4803. /* Mac Pro test */
  4804. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4805. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4806. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4807. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4808. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4809. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4810. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4811. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4812. { } /* end */
  4813. };
  4814. static struct hda_verb alc882_macpro_init_verbs[] = {
  4815. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4816. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4817. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4818. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4819. /* Front Pin: output 0 (0x0c) */
  4820. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4821. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4822. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4823. /* Front Mic pin: input vref at 80% */
  4824. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4825. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4826. /* Speaker: output */
  4827. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4828. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4829. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4830. /* Headphone output (output 0 - 0x0c) */
  4831. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4832. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4833. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4834. /* FIXME: use matrix-type input source selection */
  4835. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4836. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4837. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4838. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4839. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4840. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4841. /* Input mixer2 */
  4842. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4843. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4844. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4845. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4846. /* Input mixer3 */
  4847. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4848. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4849. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4850. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4851. /* ADC1: mute amp left and right */
  4852. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4853. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4854. /* ADC2: mute amp left and right */
  4855. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4856. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4857. /* ADC3: mute amp left and right */
  4858. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4859. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4860. { }
  4861. };
  4862. /* Macbook Pro rev3 */
  4863. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4864. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4865. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4866. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4867. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4868. /* Rear mixer */
  4869. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4870. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4871. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4872. /* Front Pin: output 0 (0x0c) */
  4873. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4874. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4875. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4876. /* HP Pin: output 0 (0x0d) */
  4877. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4878. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4879. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4880. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4881. /* Mic (rear) pin: input vref at 80% */
  4882. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4883. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4884. /* Front Mic pin: input vref at 80% */
  4885. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4886. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4887. /* Line In pin: use output 1 when in LineOut mode */
  4888. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4889. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4890. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4891. /* FIXME: use matrix-type input source selection */
  4892. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4893. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4894. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4895. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4896. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4897. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4898. /* Input mixer2 */
  4899. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4900. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4901. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4902. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4903. /* Input mixer3 */
  4904. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4905. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4906. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4907. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4908. /* ADC1: mute amp left and right */
  4909. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4910. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4911. /* ADC2: mute amp left and right */
  4912. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4913. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4914. /* ADC3: mute amp left and right */
  4915. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4916. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4917. { }
  4918. };
  4919. /* iMac 24 mixer. */
  4920. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4921. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4922. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4923. { } /* end */
  4924. };
  4925. /* iMac 24 init verbs. */
  4926. static struct hda_verb alc885_imac24_init_verbs[] = {
  4927. /* Internal speakers: output 0 (0x0c) */
  4928. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4929. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4930. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4931. /* Internal speakers: output 0 (0x0c) */
  4932. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4933. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4934. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4935. /* Headphone: output 0 (0x0c) */
  4936. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4937. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4938. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4939. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4940. /* Front Mic: input vref at 80% */
  4941. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4942. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4943. { }
  4944. };
  4945. /* Toggle speaker-output according to the hp-jack state */
  4946. static void alc885_imac24_automute(struct hda_codec *codec)
  4947. {
  4948. unsigned int present;
  4949. present = snd_hda_codec_read(codec, 0x14, 0,
  4950. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4951. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4952. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4953. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4954. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4955. }
  4956. /* Processes unsolicited events. */
  4957. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4958. unsigned int res)
  4959. {
  4960. /* Headphone insertion or removal. */
  4961. if ((res >> 26) == ALC880_HP_EVENT)
  4962. alc885_imac24_automute(codec);
  4963. }
  4964. static void alc885_mbp3_automute(struct hda_codec *codec)
  4965. {
  4966. unsigned int present;
  4967. present = snd_hda_codec_read(codec, 0x15, 0,
  4968. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4969. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  4970. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4971. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  4972. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  4973. }
  4974. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  4975. unsigned int res)
  4976. {
  4977. /* Headphone insertion or removal. */
  4978. if ((res >> 26) == ALC880_HP_EVENT)
  4979. alc885_mbp3_automute(codec);
  4980. }
  4981. static struct hda_verb alc882_targa_verbs[] = {
  4982. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4983. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4984. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4985. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4986. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4987. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4988. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4989. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4990. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4991. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4992. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4993. { } /* end */
  4994. };
  4995. /* toggle speaker-output according to the hp-jack state */
  4996. static void alc882_targa_automute(struct hda_codec *codec)
  4997. {
  4998. unsigned int present;
  4999. present = snd_hda_codec_read(codec, 0x14, 0,
  5000. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5001. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  5002. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5003. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5004. present ? 1 : 3);
  5005. }
  5006. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  5007. {
  5008. /* Looks like the unsol event is incompatible with the standard
  5009. * definition. 4bit tag is placed at 26 bit!
  5010. */
  5011. if (((res >> 26) == ALC880_HP_EVENT)) {
  5012. alc882_targa_automute(codec);
  5013. }
  5014. }
  5015. static struct hda_verb alc882_asus_a7j_verbs[] = {
  5016. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5017. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5018. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5019. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5020. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5021. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5022. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5023. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5024. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5025. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5026. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5027. { } /* end */
  5028. };
  5029. static struct hda_verb alc882_asus_a7m_verbs[] = {
  5030. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5031. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5032. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5033. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5034. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5035. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5036. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5037. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5038. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5039. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5040. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5041. { } /* end */
  5042. };
  5043. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  5044. {
  5045. unsigned int gpiostate, gpiomask, gpiodir;
  5046. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  5047. AC_VERB_GET_GPIO_DATA, 0);
  5048. if (!muted)
  5049. gpiostate |= (1 << pin);
  5050. else
  5051. gpiostate &= ~(1 << pin);
  5052. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  5053. AC_VERB_GET_GPIO_MASK, 0);
  5054. gpiomask |= (1 << pin);
  5055. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  5056. AC_VERB_GET_GPIO_DIRECTION, 0);
  5057. gpiodir |= (1 << pin);
  5058. snd_hda_codec_write(codec, codec->afg, 0,
  5059. AC_VERB_SET_GPIO_MASK, gpiomask);
  5060. snd_hda_codec_write(codec, codec->afg, 0,
  5061. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  5062. msleep(1);
  5063. snd_hda_codec_write(codec, codec->afg, 0,
  5064. AC_VERB_SET_GPIO_DATA, gpiostate);
  5065. }
  5066. /* set up GPIO at initialization */
  5067. static void alc885_macpro_init_hook(struct hda_codec *codec)
  5068. {
  5069. alc882_gpio_mute(codec, 0, 0);
  5070. alc882_gpio_mute(codec, 1, 0);
  5071. }
  5072. /* set up GPIO and update auto-muting at initialization */
  5073. static void alc885_imac24_init_hook(struct hda_codec *codec)
  5074. {
  5075. alc885_macpro_init_hook(codec);
  5076. alc885_imac24_automute(codec);
  5077. }
  5078. /*
  5079. * generic initialization of ADC, input mixers and output mixers
  5080. */
  5081. static struct hda_verb alc882_auto_init_verbs[] = {
  5082. /*
  5083. * Unmute ADC0-2 and set the default input to mic-in
  5084. */
  5085. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5086. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5087. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5088. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5089. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5090. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5091. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5092. * mixer widget
  5093. * Note: PASD motherboards uses the Line In 2 as the input for
  5094. * front panel mic (mic 2)
  5095. */
  5096. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5097. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5098. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5099. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5100. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5101. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5102. /*
  5103. * Set up output mixers (0x0c - 0x0f)
  5104. */
  5105. /* set vol=0 to output mixers */
  5106. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5107. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5108. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5109. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5110. /* set up input amps for analog loopback */
  5111. /* Amp Indices: DAC = 0, mixer = 1 */
  5112. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5113. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5114. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5115. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5116. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5117. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5118. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5119. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5120. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5121. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5122. /* FIXME: use matrix-type input source selection */
  5123. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5124. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5125. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5126. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5127. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5128. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5129. /* Input mixer2 */
  5130. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5131. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5132. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5133. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5134. /* Input mixer3 */
  5135. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5136. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5137. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5138. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5139. { }
  5140. };
  5141. /* capture mixer elements */
  5142. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  5143. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5144. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5145. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5146. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5147. {
  5148. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5149. /* The multiple "Capture Source" controls confuse alsamixer
  5150. * So call somewhat different..
  5151. * FIXME: the controls appear in the "playback" view!
  5152. */
  5153. /* .name = "Capture Source", */
  5154. .name = "Input Source",
  5155. .count = 2,
  5156. .info = alc882_mux_enum_info,
  5157. .get = alc882_mux_enum_get,
  5158. .put = alc882_mux_enum_put,
  5159. },
  5160. { } /* end */
  5161. };
  5162. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  5163. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  5164. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  5165. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  5166. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  5167. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  5168. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  5169. {
  5170. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5171. /* The multiple "Capture Source" controls confuse alsamixer
  5172. * So call somewhat different..
  5173. * FIXME: the controls appear in the "playback" view!
  5174. */
  5175. /* .name = "Capture Source", */
  5176. .name = "Input Source",
  5177. .count = 3,
  5178. .info = alc882_mux_enum_info,
  5179. .get = alc882_mux_enum_get,
  5180. .put = alc882_mux_enum_put,
  5181. },
  5182. { } /* end */
  5183. };
  5184. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5185. #define alc882_loopbacks alc880_loopbacks
  5186. #endif
  5187. /* pcm configuration: identiacal with ALC880 */
  5188. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5189. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5190. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5191. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5192. /*
  5193. * configuration and preset
  5194. */
  5195. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5196. [ALC882_3ST_DIG] = "3stack-dig",
  5197. [ALC882_6ST_DIG] = "6stack-dig",
  5198. [ALC882_ARIMA] = "arima",
  5199. [ALC882_W2JC] = "w2jc",
  5200. [ALC882_TARGA] = "targa",
  5201. [ALC882_ASUS_A7J] = "asus-a7j",
  5202. [ALC882_ASUS_A7M] = "asus-a7m",
  5203. [ALC885_MACPRO] = "macpro",
  5204. [ALC885_MBP3] = "mbp3",
  5205. [ALC885_IMAC24] = "imac24",
  5206. [ALC882_AUTO] = "auto",
  5207. };
  5208. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5209. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5210. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5211. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5212. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5213. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5214. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5215. SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
  5216. SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
  5217. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5218. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5219. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5220. {}
  5221. };
  5222. static struct alc_config_preset alc882_presets[] = {
  5223. [ALC882_3ST_DIG] = {
  5224. .mixers = { alc882_base_mixer },
  5225. .init_verbs = { alc882_init_verbs },
  5226. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5227. .dac_nids = alc882_dac_nids,
  5228. .dig_out_nid = ALC882_DIGOUT_NID,
  5229. .dig_in_nid = ALC882_DIGIN_NID,
  5230. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5231. .channel_mode = alc882_ch_modes,
  5232. .need_dac_fix = 1,
  5233. .input_mux = &alc882_capture_source,
  5234. },
  5235. [ALC882_6ST_DIG] = {
  5236. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5237. .init_verbs = { alc882_init_verbs },
  5238. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5239. .dac_nids = alc882_dac_nids,
  5240. .dig_out_nid = ALC882_DIGOUT_NID,
  5241. .dig_in_nid = ALC882_DIGIN_NID,
  5242. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5243. .channel_mode = alc882_sixstack_modes,
  5244. .input_mux = &alc882_capture_source,
  5245. },
  5246. [ALC882_ARIMA] = {
  5247. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5248. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5249. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5250. .dac_nids = alc882_dac_nids,
  5251. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5252. .channel_mode = alc882_sixstack_modes,
  5253. .input_mux = &alc882_capture_source,
  5254. },
  5255. [ALC882_W2JC] = {
  5256. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5257. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5258. alc880_gpio1_init_verbs },
  5259. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5260. .dac_nids = alc882_dac_nids,
  5261. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5262. .channel_mode = alc880_threestack_modes,
  5263. .need_dac_fix = 1,
  5264. .input_mux = &alc882_capture_source,
  5265. .dig_out_nid = ALC882_DIGOUT_NID,
  5266. },
  5267. [ALC885_MBP3] = {
  5268. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5269. .init_verbs = { alc885_mbp3_init_verbs,
  5270. alc880_gpio1_init_verbs },
  5271. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5272. .dac_nids = alc882_dac_nids,
  5273. .channel_mode = alc885_mbp_6ch_modes,
  5274. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5275. .input_mux = &alc882_capture_source,
  5276. .dig_out_nid = ALC882_DIGOUT_NID,
  5277. .dig_in_nid = ALC882_DIGIN_NID,
  5278. .unsol_event = alc885_mbp3_unsol_event,
  5279. .init_hook = alc885_mbp3_automute,
  5280. },
  5281. [ALC885_MACPRO] = {
  5282. .mixers = { alc882_macpro_mixer },
  5283. .init_verbs = { alc882_macpro_init_verbs },
  5284. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5285. .dac_nids = alc882_dac_nids,
  5286. .dig_out_nid = ALC882_DIGOUT_NID,
  5287. .dig_in_nid = ALC882_DIGIN_NID,
  5288. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5289. .channel_mode = alc882_ch_modes,
  5290. .input_mux = &alc882_capture_source,
  5291. .init_hook = alc885_macpro_init_hook,
  5292. },
  5293. [ALC885_IMAC24] = {
  5294. .mixers = { alc885_imac24_mixer },
  5295. .init_verbs = { alc885_imac24_init_verbs },
  5296. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5297. .dac_nids = alc882_dac_nids,
  5298. .dig_out_nid = ALC882_DIGOUT_NID,
  5299. .dig_in_nid = ALC882_DIGIN_NID,
  5300. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5301. .channel_mode = alc882_ch_modes,
  5302. .input_mux = &alc882_capture_source,
  5303. .unsol_event = alc885_imac24_unsol_event,
  5304. .init_hook = alc885_imac24_init_hook,
  5305. },
  5306. [ALC882_TARGA] = {
  5307. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5308. alc882_capture_mixer },
  5309. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5310. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5311. .dac_nids = alc882_dac_nids,
  5312. .dig_out_nid = ALC882_DIGOUT_NID,
  5313. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5314. .adc_nids = alc882_adc_nids,
  5315. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5316. .channel_mode = alc882_3ST_6ch_modes,
  5317. .need_dac_fix = 1,
  5318. .input_mux = &alc882_capture_source,
  5319. .unsol_event = alc882_targa_unsol_event,
  5320. .init_hook = alc882_targa_automute,
  5321. },
  5322. [ALC882_ASUS_A7J] = {
  5323. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5324. alc882_capture_mixer },
  5325. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5326. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5327. .dac_nids = alc882_dac_nids,
  5328. .dig_out_nid = ALC882_DIGOUT_NID,
  5329. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5330. .adc_nids = alc882_adc_nids,
  5331. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5332. .channel_mode = alc882_3ST_6ch_modes,
  5333. .need_dac_fix = 1,
  5334. .input_mux = &alc882_capture_source,
  5335. },
  5336. [ALC882_ASUS_A7M] = {
  5337. .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
  5338. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5339. alc880_gpio1_init_verbs,
  5340. alc882_asus_a7m_verbs },
  5341. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5342. .dac_nids = alc882_dac_nids,
  5343. .dig_out_nid = ALC882_DIGOUT_NID,
  5344. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5345. .channel_mode = alc880_threestack_modes,
  5346. .need_dac_fix = 1,
  5347. .input_mux = &alc882_capture_source,
  5348. },
  5349. };
  5350. /*
  5351. * Pin config fixes
  5352. */
  5353. enum {
  5354. PINFIX_ABIT_AW9D_MAX
  5355. };
  5356. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5357. { 0x15, 0x01080104 }, /* side */
  5358. { 0x16, 0x01011012 }, /* rear */
  5359. { 0x17, 0x01016011 }, /* clfe */
  5360. { }
  5361. };
  5362. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5363. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5364. };
  5365. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5366. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5367. {}
  5368. };
  5369. /*
  5370. * BIOS auto configuration
  5371. */
  5372. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5373. hda_nid_t nid, int pin_type,
  5374. int dac_idx)
  5375. {
  5376. /* set as output */
  5377. struct alc_spec *spec = codec->spec;
  5378. int idx;
  5379. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5380. idx = 4;
  5381. else
  5382. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5383. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5384. pin_type);
  5385. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5386. AMP_OUT_UNMUTE);
  5387. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5388. }
  5389. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5390. {
  5391. struct alc_spec *spec = codec->spec;
  5392. int i;
  5393. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5394. for (i = 0; i <= HDA_SIDE; i++) {
  5395. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5396. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5397. if (nid)
  5398. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5399. i);
  5400. }
  5401. }
  5402. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5403. {
  5404. struct alc_spec *spec = codec->spec;
  5405. hda_nid_t pin;
  5406. pin = spec->autocfg.hp_pins[0];
  5407. if (pin) /* connect to front */
  5408. /* use dac 0 */
  5409. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5410. }
  5411. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5412. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5413. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5414. {
  5415. struct alc_spec *spec = codec->spec;
  5416. int i;
  5417. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5418. hda_nid_t nid = spec->autocfg.input_pins[i];
  5419. if (alc882_is_input_pin(nid)) {
  5420. snd_hda_codec_write(codec, nid, 0,
  5421. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5422. i <= AUTO_PIN_FRONT_MIC ?
  5423. PIN_VREF80 : PIN_IN);
  5424. if (nid != ALC882_PIN_CD_NID)
  5425. snd_hda_codec_write(codec, nid, 0,
  5426. AC_VERB_SET_AMP_GAIN_MUTE,
  5427. AMP_OUT_MUTE);
  5428. }
  5429. }
  5430. }
  5431. /* add mic boosts if needed */
  5432. static int alc_auto_add_mic_boost(struct hda_codec *codec)
  5433. {
  5434. struct alc_spec *spec = codec->spec;
  5435. int err;
  5436. hda_nid_t nid;
  5437. nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
  5438. if (nid) {
  5439. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5440. "Mic Boost",
  5441. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5442. if (err < 0)
  5443. return err;
  5444. }
  5445. nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
  5446. if (nid) {
  5447. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5448. "Front Mic Boost",
  5449. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5450. if (err < 0)
  5451. return err;
  5452. }
  5453. return 0;
  5454. }
  5455. /* almost identical with ALC880 parser... */
  5456. static int alc882_parse_auto_config(struct hda_codec *codec)
  5457. {
  5458. struct alc_spec *spec = codec->spec;
  5459. int err = alc880_parse_auto_config(codec);
  5460. if (err < 0)
  5461. return err;
  5462. else if (!err)
  5463. return 0; /* no config found */
  5464. err = alc_auto_add_mic_boost(codec);
  5465. if (err < 0)
  5466. return err;
  5467. /* hack - override the init verbs */
  5468. spec->init_verbs[0] = alc882_auto_init_verbs;
  5469. return 1; /* config found */
  5470. }
  5471. /* additional initialization for auto-configuration model */
  5472. static void alc882_auto_init(struct hda_codec *codec)
  5473. {
  5474. alc882_auto_init_multi_out(codec);
  5475. alc882_auto_init_hp_out(codec);
  5476. alc882_auto_init_analog_input(codec);
  5477. }
  5478. static int patch_alc882(struct hda_codec *codec)
  5479. {
  5480. struct alc_spec *spec;
  5481. int err, board_config;
  5482. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5483. if (spec == NULL)
  5484. return -ENOMEM;
  5485. codec->spec = spec;
  5486. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5487. alc882_models,
  5488. alc882_cfg_tbl);
  5489. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5490. /* Pick up systems that don't supply PCI SSID */
  5491. switch (codec->subsystem_id) {
  5492. case 0x106b0c00: /* Mac Pro */
  5493. board_config = ALC885_MACPRO;
  5494. break;
  5495. case 0x106b1000: /* iMac 24 */
  5496. board_config = ALC885_IMAC24;
  5497. break;
  5498. case 0x106b2c00: /* Macbook Pro rev3 */
  5499. board_config = ALC885_MBP3;
  5500. break;
  5501. default:
  5502. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5503. "trying auto-probe from BIOS...\n");
  5504. board_config = ALC882_AUTO;
  5505. }
  5506. }
  5507. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5508. if (board_config == ALC882_AUTO) {
  5509. /* automatic parse from the BIOS config */
  5510. err = alc882_parse_auto_config(codec);
  5511. if (err < 0) {
  5512. alc_free(codec);
  5513. return err;
  5514. } else if (!err) {
  5515. printk(KERN_INFO
  5516. "hda_codec: Cannot set up configuration "
  5517. "from BIOS. Using base mode...\n");
  5518. board_config = ALC882_3ST_DIG;
  5519. }
  5520. }
  5521. if (board_config != ALC882_AUTO)
  5522. setup_preset(spec, &alc882_presets[board_config]);
  5523. spec->stream_name_analog = "ALC882 Analog";
  5524. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5525. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5526. spec->stream_name_digital = "ALC882 Digital";
  5527. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5528. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5529. if (!spec->adc_nids && spec->input_mux) {
  5530. /* check whether NID 0x07 is valid */
  5531. unsigned int wcap = get_wcaps(codec, 0x07);
  5532. /* get type */
  5533. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5534. if (wcap != AC_WID_AUD_IN) {
  5535. spec->adc_nids = alc882_adc_nids_alt;
  5536. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5537. spec->mixers[spec->num_mixers] =
  5538. alc882_capture_alt_mixer;
  5539. spec->num_mixers++;
  5540. } else {
  5541. spec->adc_nids = alc882_adc_nids;
  5542. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5543. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5544. spec->num_mixers++;
  5545. }
  5546. }
  5547. codec->patch_ops = alc_patch_ops;
  5548. if (board_config == ALC882_AUTO)
  5549. spec->init_hook = alc882_auto_init;
  5550. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5551. if (!spec->loopback.amplist)
  5552. spec->loopback.amplist = alc882_loopbacks;
  5553. #endif
  5554. return 0;
  5555. }
  5556. /*
  5557. * ALC883 support
  5558. *
  5559. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5560. * configuration. Each pin widget can choose any input DACs and a mixer.
  5561. * Each ADC is connected from a mixer of all inputs. This makes possible
  5562. * 6-channel independent captures.
  5563. *
  5564. * In addition, an independent DAC for the multi-playback (not used in this
  5565. * driver yet).
  5566. */
  5567. #define ALC883_DIGOUT_NID 0x06
  5568. #define ALC883_DIGIN_NID 0x0a
  5569. static hda_nid_t alc883_dac_nids[4] = {
  5570. /* front, rear, clfe, rear_surr */
  5571. 0x02, 0x04, 0x03, 0x05
  5572. };
  5573. static hda_nid_t alc883_adc_nids[2] = {
  5574. /* ADC1-2 */
  5575. 0x08, 0x09,
  5576. };
  5577. /* input MUX */
  5578. /* FIXME: should be a matrix-type input source selection */
  5579. static struct hda_input_mux alc883_capture_source = {
  5580. .num_items = 4,
  5581. .items = {
  5582. { "Mic", 0x0 },
  5583. { "Front Mic", 0x1 },
  5584. { "Line", 0x2 },
  5585. { "CD", 0x4 },
  5586. },
  5587. };
  5588. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5589. .num_items = 2,
  5590. .items = {
  5591. { "Mic", 0x1 },
  5592. { "Line", 0x2 },
  5593. },
  5594. };
  5595. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5596. .num_items = 4,
  5597. .items = {
  5598. { "Mic", 0x0 },
  5599. { "iMic", 0x1 },
  5600. { "Line", 0x2 },
  5601. { "CD", 0x4 },
  5602. },
  5603. };
  5604. #define alc883_mux_enum_info alc_mux_enum_info
  5605. #define alc883_mux_enum_get alc_mux_enum_get
  5606. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5607. struct snd_ctl_elem_value *ucontrol)
  5608. {
  5609. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5610. struct alc_spec *spec = codec->spec;
  5611. const struct hda_input_mux *imux = spec->input_mux;
  5612. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5613. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5614. hda_nid_t nid = capture_mixers[adc_idx];
  5615. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5616. unsigned int i, idx;
  5617. idx = ucontrol->value.enumerated.item[0];
  5618. if (idx >= imux->num_items)
  5619. idx = imux->num_items - 1;
  5620. if (*cur_val == idx)
  5621. return 0;
  5622. for (i = 0; i < imux->num_items; i++) {
  5623. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5624. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5625. imux->items[i].index,
  5626. HDA_AMP_MUTE, v);
  5627. }
  5628. *cur_val = idx;
  5629. return 1;
  5630. }
  5631. /*
  5632. * 2ch mode
  5633. */
  5634. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5635. { 2, NULL }
  5636. };
  5637. /*
  5638. * 2ch mode
  5639. */
  5640. static struct hda_verb alc883_3ST_ch2_init[] = {
  5641. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5642. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5643. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5644. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5645. { } /* end */
  5646. };
  5647. /*
  5648. * 4ch mode
  5649. */
  5650. static struct hda_verb alc883_3ST_ch4_init[] = {
  5651. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5652. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5653. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5654. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5655. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5656. { } /* end */
  5657. };
  5658. /*
  5659. * 6ch mode
  5660. */
  5661. static struct hda_verb alc883_3ST_ch6_init[] = {
  5662. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5663. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5664. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5665. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5666. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5667. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5668. { } /* end */
  5669. };
  5670. static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
  5671. { 2, alc883_3ST_ch2_init },
  5672. { 4, alc883_3ST_ch4_init },
  5673. { 6, alc883_3ST_ch6_init },
  5674. };
  5675. /*
  5676. * 6ch mode
  5677. */
  5678. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5679. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5680. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5681. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5682. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5683. { } /* end */
  5684. };
  5685. /*
  5686. * 8ch mode
  5687. */
  5688. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5689. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5690. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5691. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5692. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5693. { } /* end */
  5694. };
  5695. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5696. { 6, alc883_sixstack_ch6_init },
  5697. { 8, alc883_sixstack_ch8_init },
  5698. };
  5699. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5700. /* eanable EAPD on medion laptop */
  5701. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5702. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5703. { }
  5704. };
  5705. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5706. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5707. */
  5708. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5709. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5710. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5711. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5712. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5713. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5714. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5715. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5716. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5717. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5718. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5719. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5720. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5721. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5722. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5723. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5724. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5725. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5726. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5727. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5728. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5729. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5730. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5731. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5732. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5733. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5734. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5735. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5736. {
  5737. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5738. /* .name = "Capture Source", */
  5739. .name = "Input Source",
  5740. .count = 2,
  5741. .info = alc883_mux_enum_info,
  5742. .get = alc883_mux_enum_get,
  5743. .put = alc883_mux_enum_put,
  5744. },
  5745. { } /* end */
  5746. };
  5747. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5748. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5749. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5750. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5751. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5752. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5753. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5754. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5755. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5756. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5757. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5758. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5759. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5760. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5761. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5762. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5763. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5764. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5765. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5766. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5767. {
  5768. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5769. /* .name = "Capture Source", */
  5770. .name = "Input Source",
  5771. .count = 2,
  5772. .info = alc883_mux_enum_info,
  5773. .get = alc883_mux_enum_get,
  5774. .put = alc883_mux_enum_put,
  5775. },
  5776. { } /* end */
  5777. };
  5778. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5779. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5780. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5781. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5782. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5783. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5784. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5785. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5786. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5787. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5788. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5789. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5790. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5791. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5792. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5793. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5794. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5795. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5796. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5797. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5798. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5799. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5800. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5801. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5802. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5803. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5804. {
  5805. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5806. /* .name = "Capture Source", */
  5807. .name = "Input Source",
  5808. .count = 2,
  5809. .info = alc883_mux_enum_info,
  5810. .get = alc883_mux_enum_get,
  5811. .put = alc883_mux_enum_put,
  5812. },
  5813. { } /* end */
  5814. };
  5815. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5816. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5817. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5818. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5819. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5820. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5821. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5822. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5823. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5824. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5825. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5826. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5827. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5828. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5829. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5830. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5831. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5832. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5833. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5834. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5835. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5836. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5837. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5838. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5839. {
  5840. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5841. /* .name = "Capture Source", */
  5842. .name = "Input Source",
  5843. .count = 1,
  5844. .info = alc883_mux_enum_info,
  5845. .get = alc883_mux_enum_get,
  5846. .put = alc883_mux_enum_put,
  5847. },
  5848. { } /* end */
  5849. };
  5850. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5851. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5852. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5853. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5854. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5855. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5856. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5857. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5858. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5859. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5860. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5861. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5862. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5863. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5864. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5865. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5866. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5867. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5868. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5869. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5870. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5871. {
  5872. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5873. /* .name = "Capture Source", */
  5874. .name = "Input Source",
  5875. .count = 2,
  5876. .info = alc883_mux_enum_info,
  5877. .get = alc883_mux_enum_get,
  5878. .put = alc883_mux_enum_put,
  5879. },
  5880. { } /* end */
  5881. };
  5882. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5883. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5884. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5885. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5886. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5887. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5888. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5889. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5890. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5891. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5892. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5893. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5894. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5895. {
  5896. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5897. /* .name = "Capture Source", */
  5898. .name = "Input Source",
  5899. .count = 2,
  5900. .info = alc883_mux_enum_info,
  5901. .get = alc883_mux_enum_get,
  5902. .put = alc883_mux_enum_put,
  5903. },
  5904. { } /* end */
  5905. };
  5906. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5907. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5908. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5909. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5910. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5911. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5912. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5913. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5914. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5915. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5916. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5917. {
  5918. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5919. /* .name = "Capture Source", */
  5920. .name = "Input Source",
  5921. .count = 1,
  5922. .info = alc883_mux_enum_info,
  5923. .get = alc883_mux_enum_get,
  5924. .put = alc883_mux_enum_put,
  5925. },
  5926. { } /* end */
  5927. };
  5928. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5929. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5930. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5931. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5932. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5933. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5934. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5935. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5936. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5937. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5938. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5939. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5940. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5941. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5942. {
  5943. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5944. /* .name = "Capture Source", */
  5945. .name = "Input Source",
  5946. .count = 2,
  5947. .info = alc883_mux_enum_info,
  5948. .get = alc883_mux_enum_get,
  5949. .put = alc883_mux_enum_put,
  5950. },
  5951. { } /* end */
  5952. };
  5953. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5954. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5955. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5956. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5957. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5958. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5959. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5960. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5961. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5962. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5963. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5964. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5965. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5966. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5967. {
  5968. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5969. /* .name = "Capture Source", */
  5970. .name = "Input Source",
  5971. .count = 2,
  5972. .info = alc883_mux_enum_info,
  5973. .get = alc883_mux_enum_get,
  5974. .put = alc883_mux_enum_put,
  5975. },
  5976. { } /* end */
  5977. };
  5978. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5979. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5980. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5981. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5982. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5983. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5984. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5985. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5986. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5987. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5988. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5989. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5990. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5991. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5992. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5993. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5994. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5995. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5996. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5997. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5998. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5999. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6000. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6001. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6002. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6003. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6004. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6005. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6006. {
  6007. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6008. /* .name = "Capture Source", */
  6009. .name = "Input Source",
  6010. .count = 2,
  6011. .info = alc883_mux_enum_info,
  6012. .get = alc883_mux_enum_get,
  6013. .put = alc883_mux_enum_put,
  6014. },
  6015. { } /* end */
  6016. };
  6017. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  6018. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6019. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6020. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  6021. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  6022. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  6023. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  6024. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  6025. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  6026. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6027. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6028. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6029. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6030. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6031. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6032. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6033. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6034. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  6035. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6036. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6037. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6038. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6039. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6040. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6041. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6042. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6043. {
  6044. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6045. /* .name = "Capture Source", */
  6046. .name = "Input Source",
  6047. .count = 2,
  6048. .info = alc883_mux_enum_info,
  6049. .get = alc883_mux_enum_get,
  6050. .put = alc883_mux_enum_put,
  6051. },
  6052. { } /* end */
  6053. };
  6054. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  6055. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6056. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6057. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6058. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6059. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6060. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6061. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6062. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6063. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6064. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6065. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6066. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6067. {
  6068. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6069. /* .name = "Capture Source", */
  6070. .name = "Input Source",
  6071. .count = 2,
  6072. .info = alc883_mux_enum_info,
  6073. .get = alc883_mux_enum_get,
  6074. .put = alc883_mux_enum_put,
  6075. },
  6076. { } /* end */
  6077. };
  6078. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  6079. {
  6080. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6081. .name = "Channel Mode",
  6082. .info = alc_ch_mode_info,
  6083. .get = alc_ch_mode_get,
  6084. .put = alc_ch_mode_put,
  6085. },
  6086. { } /* end */
  6087. };
  6088. static struct hda_verb alc883_init_verbs[] = {
  6089. /* ADC1: mute amp left and right */
  6090. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6091. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6092. /* ADC2: mute amp left and right */
  6093. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6094. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6095. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  6096. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6097. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6098. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6099. /* Rear mixer */
  6100. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6101. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6102. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6103. /* CLFE mixer */
  6104. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6105. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6106. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6107. /* Side mixer */
  6108. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6109. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6110. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6111. /* mute analog input loopbacks */
  6112. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6113. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6114. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6115. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6116. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6117. /* Front Pin: output 0 (0x0c) */
  6118. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6119. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6120. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6121. /* Rear Pin: output 1 (0x0d) */
  6122. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6123. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6124. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6125. /* CLFE Pin: output 2 (0x0e) */
  6126. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6127. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6128. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  6129. /* Side Pin: output 3 (0x0f) */
  6130. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6131. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6132. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  6133. /* Mic (rear) pin: input vref at 80% */
  6134. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6135. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6136. /* Front Mic pin: input vref at 80% */
  6137. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6138. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6139. /* Line In pin: input */
  6140. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6141. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6142. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  6143. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6144. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6145. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6146. /* CD pin widget for input */
  6147. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6148. /* FIXME: use matrix-type input source selection */
  6149. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6150. /* Input mixer2 */
  6151. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6152. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6153. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6154. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6155. /* Input mixer3 */
  6156. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6157. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6158. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6159. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6160. { }
  6161. };
  6162. static struct hda_verb alc883_tagra_verbs[] = {
  6163. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6164. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6165. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6166. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6167. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  6168. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  6169. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  6170. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6171. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  6172. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  6173. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  6174. { } /* end */
  6175. };
  6176. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  6177. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6178. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  6179. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  6180. { } /* end */
  6181. };
  6182. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  6183. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6184. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6185. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6186. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6187. { } /* end */
  6188. };
  6189. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  6190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6192. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6193. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  6194. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6195. { } /* end */
  6196. };
  6197. static struct hda_verb alc883_haier_w66_verbs[] = {
  6198. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6199. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6200. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6201. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6202. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6203. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6204. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6205. { } /* end */
  6206. };
  6207. static struct hda_verb alc888_6st_hp_verbs[] = {
  6208. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6209. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  6210. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  6211. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  6212. { }
  6213. };
  6214. static struct hda_verb alc888_3st_hp_verbs[] = {
  6215. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6216. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  6217. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  6218. { }
  6219. };
  6220. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  6221. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  6222. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6223. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  6224. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6225. { }
  6226. };
  6227. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  6228. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6229. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6230. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6231. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6232. { }
  6233. };
  6234. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  6235. { 2, alc888_3st_hp_2ch_init },
  6236. { 6, alc888_3st_hp_6ch_init },
  6237. };
  6238. /* toggle front-jack and RCA according to the hp-jack state */
  6239. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6240. {
  6241. unsigned int present;
  6242. present = snd_hda_codec_read(codec, 0x1b, 0,
  6243. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6244. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6245. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6246. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6247. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6248. }
  6249. /* toggle RCA according to the front-jack state */
  6250. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6251. {
  6252. unsigned int present;
  6253. present = snd_hda_codec_read(codec, 0x14, 0,
  6254. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6255. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6256. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6257. }
  6258. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6259. unsigned int res)
  6260. {
  6261. if ((res >> 26) == ALC880_HP_EVENT)
  6262. alc888_lenovo_ms7195_front_automute(codec);
  6263. if ((res >> 26) == ALC880_FRONT_EVENT)
  6264. alc888_lenovo_ms7195_rca_automute(codec);
  6265. }
  6266. static struct hda_verb alc883_medion_md2_verbs[] = {
  6267. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6268. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6269. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6270. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6271. { } /* end */
  6272. };
  6273. /* toggle speaker-output according to the hp-jack state */
  6274. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6275. {
  6276. unsigned int present;
  6277. present = snd_hda_codec_read(codec, 0x14, 0,
  6278. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6279. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6280. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6281. }
  6282. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6283. unsigned int res)
  6284. {
  6285. if ((res >> 26) == ALC880_HP_EVENT)
  6286. alc883_medion_md2_automute(codec);
  6287. }
  6288. /* toggle speaker-output according to the hp-jack state */
  6289. static void alc883_tagra_automute(struct hda_codec *codec)
  6290. {
  6291. unsigned int present;
  6292. unsigned char bits;
  6293. present = snd_hda_codec_read(codec, 0x14, 0,
  6294. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6295. bits = present ? HDA_AMP_MUTE : 0;
  6296. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6297. HDA_AMP_MUTE, bits);
  6298. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6299. present ? 1 : 3);
  6300. }
  6301. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6302. {
  6303. if ((res >> 26) == ALC880_HP_EVENT)
  6304. alc883_tagra_automute(codec);
  6305. }
  6306. static void alc883_haier_w66_automute(struct hda_codec *codec)
  6307. {
  6308. unsigned int present;
  6309. unsigned char bits;
  6310. present = snd_hda_codec_read(codec, 0x1b, 0,
  6311. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6312. bits = present ? 0x80 : 0;
  6313. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6314. 0x80, bits);
  6315. }
  6316. static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
  6317. unsigned int res)
  6318. {
  6319. if ((res >> 26) == ALC880_HP_EVENT)
  6320. alc883_haier_w66_automute(codec);
  6321. }
  6322. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6323. {
  6324. unsigned int present;
  6325. unsigned char bits;
  6326. present = snd_hda_codec_read(codec, 0x14, 0,
  6327. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6328. bits = present ? HDA_AMP_MUTE : 0;
  6329. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6330. HDA_AMP_MUTE, bits);
  6331. }
  6332. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6333. {
  6334. unsigned int present;
  6335. unsigned char bits;
  6336. present = snd_hda_codec_read(codec, 0x1b, 0,
  6337. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6338. bits = present ? HDA_AMP_MUTE : 0;
  6339. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6340. HDA_AMP_MUTE, bits);
  6341. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6342. HDA_AMP_MUTE, bits);
  6343. }
  6344. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6345. unsigned int res)
  6346. {
  6347. if ((res >> 26) == ALC880_HP_EVENT)
  6348. alc883_lenovo_101e_all_automute(codec);
  6349. if ((res >> 26) == ALC880_FRONT_EVENT)
  6350. alc883_lenovo_101e_ispeaker_automute(codec);
  6351. }
  6352. /* toggle speaker-output according to the hp-jack state */
  6353. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6354. {
  6355. unsigned int present;
  6356. present = snd_hda_codec_read(codec, 0x14, 0,
  6357. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6358. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6359. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6360. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6361. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6362. }
  6363. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6364. unsigned int res)
  6365. {
  6366. if ((res >> 26) == ALC880_HP_EVENT)
  6367. alc883_acer_aspire_automute(codec);
  6368. }
  6369. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6370. /* HP Pin: output 0 (0x0c) */
  6371. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6372. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6373. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6374. /* Front Pin: output 0 (0x0c) */
  6375. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6376. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6377. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6378. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6379. /* eanable EAPD on medion laptop */
  6380. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6381. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6382. /* enable unsolicited event */
  6383. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6384. { }
  6385. };
  6386. /*
  6387. * generic initialization of ADC, input mixers and output mixers
  6388. */
  6389. static struct hda_verb alc883_auto_init_verbs[] = {
  6390. /*
  6391. * Unmute ADC0-2 and set the default input to mic-in
  6392. */
  6393. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6394. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6395. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6396. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6397. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6398. * mixer widget
  6399. * Note: PASD motherboards uses the Line In 2 as the input for
  6400. * front panel mic (mic 2)
  6401. */
  6402. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6403. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6404. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6405. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6406. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6407. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6408. /*
  6409. * Set up output mixers (0x0c - 0x0f)
  6410. */
  6411. /* set vol=0 to output mixers */
  6412. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6413. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6414. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6415. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6416. /* set up input amps for analog loopback */
  6417. /* Amp Indices: DAC = 0, mixer = 1 */
  6418. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6419. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6420. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6421. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6422. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6423. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6424. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6425. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6426. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6427. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6428. /* FIXME: use matrix-type input source selection */
  6429. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6430. /* Input mixer1 */
  6431. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6432. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6433. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6434. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6435. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6436. /* Input mixer2 */
  6437. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6438. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6439. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6440. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6441. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6442. { }
  6443. };
  6444. /* capture mixer elements */
  6445. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6446. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6447. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6448. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6449. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6450. {
  6451. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6452. /* The multiple "Capture Source" controls confuse alsamixer
  6453. * So call somewhat different..
  6454. * FIXME: the controls appear in the "playback" view!
  6455. */
  6456. /* .name = "Capture Source", */
  6457. .name = "Input Source",
  6458. .count = 2,
  6459. .info = alc882_mux_enum_info,
  6460. .get = alc882_mux_enum_get,
  6461. .put = alc882_mux_enum_put,
  6462. },
  6463. { } /* end */
  6464. };
  6465. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6466. #define alc883_loopbacks alc880_loopbacks
  6467. #endif
  6468. /* pcm configuration: identiacal with ALC880 */
  6469. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6470. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6471. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6472. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6473. /*
  6474. * configuration and preset
  6475. */
  6476. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6477. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6478. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6479. [ALC883_3ST_6ch] = "3stack-6ch",
  6480. [ALC883_6ST_DIG] = "6stack-dig",
  6481. [ALC883_TARGA_DIG] = "targa-dig",
  6482. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6483. [ALC883_ACER] = "acer",
  6484. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6485. [ALC883_MEDION] = "medion",
  6486. [ALC883_MEDION_MD2] = "medion-md2",
  6487. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6488. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6489. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6490. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6491. [ALC883_HAIER_W66] = "haier-w66",
  6492. [ALC888_6ST_HP] = "6stack-hp",
  6493. [ALC888_3ST_HP] = "3stack-hp",
  6494. [ALC883_AUTO] = "auto",
  6495. };
  6496. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6497. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6498. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6499. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6500. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6501. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6502. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6503. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6504. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6505. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6506. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6507. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6508. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6509. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6510. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6511. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6512. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6513. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6514. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6515. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6516. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6517. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6518. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6519. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6520. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6521. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6522. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6523. SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
  6524. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6525. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6526. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6527. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6528. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6529. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6530. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6531. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6532. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6533. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6534. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6535. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6536. SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
  6537. SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6538. SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
  6539. SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
  6540. {}
  6541. };
  6542. static struct alc_config_preset alc883_presets[] = {
  6543. [ALC883_3ST_2ch_DIG] = {
  6544. .mixers = { alc883_3ST_2ch_mixer },
  6545. .init_verbs = { alc883_init_verbs },
  6546. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6547. .dac_nids = alc883_dac_nids,
  6548. .dig_out_nid = ALC883_DIGOUT_NID,
  6549. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6550. .adc_nids = alc883_adc_nids,
  6551. .dig_in_nid = ALC883_DIGIN_NID,
  6552. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6553. .channel_mode = alc883_3ST_2ch_modes,
  6554. .input_mux = &alc883_capture_source,
  6555. },
  6556. [ALC883_3ST_6ch_DIG] = {
  6557. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6558. .init_verbs = { alc883_init_verbs },
  6559. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6560. .dac_nids = alc883_dac_nids,
  6561. .dig_out_nid = ALC883_DIGOUT_NID,
  6562. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6563. .adc_nids = alc883_adc_nids,
  6564. .dig_in_nid = ALC883_DIGIN_NID,
  6565. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6566. .channel_mode = alc883_3ST_6ch_modes,
  6567. .need_dac_fix = 1,
  6568. .input_mux = &alc883_capture_source,
  6569. },
  6570. [ALC883_3ST_6ch] = {
  6571. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6572. .init_verbs = { alc883_init_verbs },
  6573. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6574. .dac_nids = alc883_dac_nids,
  6575. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6576. .adc_nids = alc883_adc_nids,
  6577. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6578. .channel_mode = alc883_3ST_6ch_modes,
  6579. .need_dac_fix = 1,
  6580. .input_mux = &alc883_capture_source,
  6581. },
  6582. [ALC883_6ST_DIG] = {
  6583. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6584. .init_verbs = { alc883_init_verbs },
  6585. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6586. .dac_nids = alc883_dac_nids,
  6587. .dig_out_nid = ALC883_DIGOUT_NID,
  6588. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6589. .adc_nids = alc883_adc_nids,
  6590. .dig_in_nid = ALC883_DIGIN_NID,
  6591. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6592. .channel_mode = alc883_sixstack_modes,
  6593. .input_mux = &alc883_capture_source,
  6594. },
  6595. [ALC883_TARGA_DIG] = {
  6596. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6597. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6598. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6599. .dac_nids = alc883_dac_nids,
  6600. .dig_out_nid = ALC883_DIGOUT_NID,
  6601. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6602. .adc_nids = alc883_adc_nids,
  6603. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6604. .channel_mode = alc883_3ST_6ch_modes,
  6605. .need_dac_fix = 1,
  6606. .input_mux = &alc883_capture_source,
  6607. .unsol_event = alc883_tagra_unsol_event,
  6608. .init_hook = alc883_tagra_automute,
  6609. },
  6610. [ALC883_TARGA_2ch_DIG] = {
  6611. .mixers = { alc883_tagra_2ch_mixer},
  6612. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6613. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6614. .dac_nids = alc883_dac_nids,
  6615. .dig_out_nid = ALC883_DIGOUT_NID,
  6616. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6617. .adc_nids = alc883_adc_nids,
  6618. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6619. .channel_mode = alc883_3ST_2ch_modes,
  6620. .input_mux = &alc883_capture_source,
  6621. .unsol_event = alc883_tagra_unsol_event,
  6622. .init_hook = alc883_tagra_automute,
  6623. },
  6624. [ALC883_ACER] = {
  6625. .mixers = { alc883_base_mixer },
  6626. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6627. * and the headphone jack. Turn this on and rely on the
  6628. * standard mute methods whenever the user wants to turn
  6629. * these outputs off.
  6630. */
  6631. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6632. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6633. .dac_nids = alc883_dac_nids,
  6634. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6635. .adc_nids = alc883_adc_nids,
  6636. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6637. .channel_mode = alc883_3ST_2ch_modes,
  6638. .input_mux = &alc883_capture_source,
  6639. },
  6640. [ALC883_ACER_ASPIRE] = {
  6641. .mixers = { alc883_acer_aspire_mixer },
  6642. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6643. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6644. .dac_nids = alc883_dac_nids,
  6645. .dig_out_nid = ALC883_DIGOUT_NID,
  6646. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6647. .adc_nids = alc883_adc_nids,
  6648. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6649. .channel_mode = alc883_3ST_2ch_modes,
  6650. .input_mux = &alc883_capture_source,
  6651. .unsol_event = alc883_acer_aspire_unsol_event,
  6652. .init_hook = alc883_acer_aspire_automute,
  6653. },
  6654. [ALC883_MEDION] = {
  6655. .mixers = { alc883_fivestack_mixer,
  6656. alc883_chmode_mixer },
  6657. .init_verbs = { alc883_init_verbs,
  6658. alc883_medion_eapd_verbs },
  6659. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6660. .dac_nids = alc883_dac_nids,
  6661. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6662. .adc_nids = alc883_adc_nids,
  6663. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6664. .channel_mode = alc883_sixstack_modes,
  6665. .input_mux = &alc883_capture_source,
  6666. },
  6667. [ALC883_MEDION_MD2] = {
  6668. .mixers = { alc883_medion_md2_mixer},
  6669. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6670. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6671. .dac_nids = alc883_dac_nids,
  6672. .dig_out_nid = ALC883_DIGOUT_NID,
  6673. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6674. .adc_nids = alc883_adc_nids,
  6675. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6676. .channel_mode = alc883_3ST_2ch_modes,
  6677. .input_mux = &alc883_capture_source,
  6678. .unsol_event = alc883_medion_md2_unsol_event,
  6679. .init_hook = alc883_medion_md2_automute,
  6680. },
  6681. [ALC883_LAPTOP_EAPD] = {
  6682. .mixers = { alc883_base_mixer },
  6683. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6684. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6685. .dac_nids = alc883_dac_nids,
  6686. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6687. .adc_nids = alc883_adc_nids,
  6688. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6689. .channel_mode = alc883_3ST_2ch_modes,
  6690. .input_mux = &alc883_capture_source,
  6691. },
  6692. [ALC883_LENOVO_101E_2ch] = {
  6693. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6694. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6695. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6696. .dac_nids = alc883_dac_nids,
  6697. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6698. .adc_nids = alc883_adc_nids,
  6699. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6700. .channel_mode = alc883_3ST_2ch_modes,
  6701. .input_mux = &alc883_lenovo_101e_capture_source,
  6702. .unsol_event = alc883_lenovo_101e_unsol_event,
  6703. .init_hook = alc883_lenovo_101e_all_automute,
  6704. },
  6705. [ALC883_LENOVO_NB0763] = {
  6706. .mixers = { alc883_lenovo_nb0763_mixer },
  6707. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6708. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6709. .dac_nids = alc883_dac_nids,
  6710. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6711. .adc_nids = alc883_adc_nids,
  6712. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6713. .channel_mode = alc883_3ST_2ch_modes,
  6714. .need_dac_fix = 1,
  6715. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6716. .unsol_event = alc883_medion_md2_unsol_event,
  6717. .init_hook = alc883_medion_md2_automute,
  6718. },
  6719. [ALC888_LENOVO_MS7195_DIG] = {
  6720. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6721. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6722. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6723. .dac_nids = alc883_dac_nids,
  6724. .dig_out_nid = ALC883_DIGOUT_NID,
  6725. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6726. .adc_nids = alc883_adc_nids,
  6727. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6728. .channel_mode = alc883_3ST_6ch_modes,
  6729. .need_dac_fix = 1,
  6730. .input_mux = &alc883_capture_source,
  6731. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6732. .init_hook = alc888_lenovo_ms7195_front_automute,
  6733. },
  6734. [ALC883_HAIER_W66] = {
  6735. .mixers = { alc883_tagra_2ch_mixer},
  6736. .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
  6737. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6738. .dac_nids = alc883_dac_nids,
  6739. .dig_out_nid = ALC883_DIGOUT_NID,
  6740. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6741. .adc_nids = alc883_adc_nids,
  6742. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6743. .channel_mode = alc883_3ST_2ch_modes,
  6744. .input_mux = &alc883_capture_source,
  6745. .unsol_event = alc883_haier_w66_unsol_event,
  6746. .init_hook = alc883_haier_w66_automute,
  6747. },
  6748. [ALC888_6ST_HP] = {
  6749. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6750. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6751. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6752. .dac_nids = alc883_dac_nids,
  6753. .dig_out_nid = ALC883_DIGOUT_NID,
  6754. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6755. .adc_nids = alc883_adc_nids,
  6756. .dig_in_nid = ALC883_DIGIN_NID,
  6757. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6758. .channel_mode = alc883_sixstack_modes,
  6759. .input_mux = &alc883_capture_source,
  6760. },
  6761. [ALC888_3ST_HP] = {
  6762. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6763. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6764. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6765. .dac_nids = alc883_dac_nids,
  6766. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6767. .adc_nids = alc883_adc_nids,
  6768. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6769. .channel_mode = alc888_3st_hp_modes,
  6770. .need_dac_fix = 1,
  6771. .input_mux = &alc883_capture_source,
  6772. },
  6773. };
  6774. /*
  6775. * BIOS auto configuration
  6776. */
  6777. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6778. hda_nid_t nid, int pin_type,
  6779. int dac_idx)
  6780. {
  6781. /* set as output */
  6782. struct alc_spec *spec = codec->spec;
  6783. int idx;
  6784. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6785. idx = 4;
  6786. else
  6787. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6788. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6789. pin_type);
  6790. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6791. AMP_OUT_UNMUTE);
  6792. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6793. }
  6794. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6795. {
  6796. struct alc_spec *spec = codec->spec;
  6797. int i;
  6798. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6799. for (i = 0; i <= HDA_SIDE; i++) {
  6800. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6801. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6802. if (nid)
  6803. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6804. i);
  6805. }
  6806. }
  6807. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6808. {
  6809. struct alc_spec *spec = codec->spec;
  6810. hda_nid_t pin;
  6811. pin = spec->autocfg.hp_pins[0];
  6812. if (pin) /* connect to front */
  6813. /* use dac 0 */
  6814. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6815. }
  6816. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6817. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6818. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6819. {
  6820. struct alc_spec *spec = codec->spec;
  6821. int i;
  6822. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6823. hda_nid_t nid = spec->autocfg.input_pins[i];
  6824. if (alc883_is_input_pin(nid)) {
  6825. snd_hda_codec_write(codec, nid, 0,
  6826. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6827. (i <= AUTO_PIN_FRONT_MIC ?
  6828. PIN_VREF80 : PIN_IN));
  6829. if (nid != ALC883_PIN_CD_NID)
  6830. snd_hda_codec_write(codec, nid, 0,
  6831. AC_VERB_SET_AMP_GAIN_MUTE,
  6832. AMP_OUT_MUTE);
  6833. }
  6834. }
  6835. }
  6836. /* almost identical with ALC880 parser... */
  6837. static int alc883_parse_auto_config(struct hda_codec *codec)
  6838. {
  6839. struct alc_spec *spec = codec->spec;
  6840. int err = alc880_parse_auto_config(codec);
  6841. if (err < 0)
  6842. return err;
  6843. else if (!err)
  6844. return 0; /* no config found */
  6845. err = alc_auto_add_mic_boost(codec);
  6846. if (err < 0)
  6847. return err;
  6848. /* hack - override the init verbs */
  6849. spec->init_verbs[0] = alc883_auto_init_verbs;
  6850. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6851. spec->num_mixers++;
  6852. return 1; /* config found */
  6853. }
  6854. /* additional initialization for auto-configuration model */
  6855. static void alc883_auto_init(struct hda_codec *codec)
  6856. {
  6857. alc883_auto_init_multi_out(codec);
  6858. alc883_auto_init_hp_out(codec);
  6859. alc883_auto_init_analog_input(codec);
  6860. }
  6861. static int patch_alc883(struct hda_codec *codec)
  6862. {
  6863. struct alc_spec *spec;
  6864. int err, board_config;
  6865. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6866. if (spec == NULL)
  6867. return -ENOMEM;
  6868. codec->spec = spec;
  6869. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6870. alc883_models,
  6871. alc883_cfg_tbl);
  6872. if (board_config < 0) {
  6873. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6874. "trying auto-probe from BIOS...\n");
  6875. board_config = ALC883_AUTO;
  6876. }
  6877. if (board_config == ALC883_AUTO) {
  6878. /* automatic parse from the BIOS config */
  6879. err = alc883_parse_auto_config(codec);
  6880. if (err < 0) {
  6881. alc_free(codec);
  6882. return err;
  6883. } else if (!err) {
  6884. printk(KERN_INFO
  6885. "hda_codec: Cannot set up configuration "
  6886. "from BIOS. Using base mode...\n");
  6887. board_config = ALC883_3ST_2ch_DIG;
  6888. }
  6889. }
  6890. if (board_config != ALC883_AUTO)
  6891. setup_preset(spec, &alc883_presets[board_config]);
  6892. spec->stream_name_analog = "ALC883 Analog";
  6893. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6894. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6895. spec->stream_name_digital = "ALC883 Digital";
  6896. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6897. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6898. if (!spec->adc_nids && spec->input_mux) {
  6899. spec->adc_nids = alc883_adc_nids;
  6900. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6901. }
  6902. codec->patch_ops = alc_patch_ops;
  6903. if (board_config == ALC883_AUTO)
  6904. spec->init_hook = alc883_auto_init;
  6905. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6906. if (!spec->loopback.amplist)
  6907. spec->loopback.amplist = alc883_loopbacks;
  6908. #endif
  6909. return 0;
  6910. }
  6911. /*
  6912. * ALC262 support
  6913. */
  6914. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6915. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6916. #define alc262_dac_nids alc260_dac_nids
  6917. #define alc262_adc_nids alc882_adc_nids
  6918. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6919. #define alc262_modes alc260_modes
  6920. #define alc262_capture_source alc882_capture_source
  6921. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6922. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6923. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6924. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6925. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6926. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6927. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6928. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6929. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6930. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6931. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6932. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6933. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6934. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6935. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6936. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6937. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6938. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6939. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6940. { } /* end */
  6941. };
  6942. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6943. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6944. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6945. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6946. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6947. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6948. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6949. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6950. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6951. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6952. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6953. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6954. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6955. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6956. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6957. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6958. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6959. { } /* end */
  6960. };
  6961. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6962. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6963. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6964. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6965. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6966. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6967. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6968. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6969. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6970. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6971. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6972. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6973. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6974. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6975. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6976. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6977. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6978. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6979. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6980. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6981. { } /* end */
  6982. };
  6983. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6984. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6985. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6986. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6987. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6988. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6989. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6990. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6991. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6992. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6993. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6994. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6995. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6996. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6997. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6998. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6999. { } /* end */
  7000. };
  7001. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  7002. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7003. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7004. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  7005. { } /* end */
  7006. };
  7007. /* bind hp and internal speaker mute (with plug check) */
  7008. static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
  7009. struct snd_ctl_elem_value *ucontrol)
  7010. {
  7011. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7012. long *valp = ucontrol->value.integer.value;
  7013. int change;
  7014. /* change hp mute */
  7015. change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  7016. HDA_AMP_MUTE,
  7017. valp[0] ? 0 : HDA_AMP_MUTE);
  7018. change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  7019. HDA_AMP_MUTE,
  7020. valp[1] ? 0 : HDA_AMP_MUTE);
  7021. if (change) {
  7022. /* change speaker according to HP jack state */
  7023. struct alc_spec *spec = codec->spec;
  7024. unsigned int mute;
  7025. if (spec->jack_present)
  7026. mute = HDA_AMP_MUTE;
  7027. else
  7028. mute = snd_hda_codec_amp_read(codec, 0x15, 0,
  7029. HDA_OUTPUT, 0);
  7030. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7031. HDA_AMP_MUTE, mute);
  7032. }
  7033. return change;
  7034. }
  7035. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  7036. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7037. {
  7038. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7039. .name = "Master Playback Switch",
  7040. .info = snd_hda_mixer_amp_switch_info,
  7041. .get = snd_hda_mixer_amp_switch_get,
  7042. .put = alc262_sony_master_sw_put,
  7043. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  7044. },
  7045. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7046. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7047. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7048. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7049. { } /* end */
  7050. };
  7051. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  7052. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7053. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7054. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7055. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7056. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7057. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7058. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7059. { } /* end */
  7060. };
  7061. #define alc262_capture_mixer alc882_capture_mixer
  7062. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  7063. /*
  7064. * generic initialization of ADC, input mixers and output mixers
  7065. */
  7066. static struct hda_verb alc262_init_verbs[] = {
  7067. /*
  7068. * Unmute ADC0-2 and set the default input to mic-in
  7069. */
  7070. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7071. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7072. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7073. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7074. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7075. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7076. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7077. * mixer widget
  7078. * Note: PASD motherboards uses the Line In 2 as the input for
  7079. * front panel mic (mic 2)
  7080. */
  7081. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7082. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7083. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7084. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7085. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7086. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7087. /*
  7088. * Set up output mixers (0x0c - 0x0e)
  7089. */
  7090. /* set vol=0 to output mixers */
  7091. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7092. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7093. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7094. /* set up input amps for analog loopback */
  7095. /* Amp Indices: DAC = 0, mixer = 1 */
  7096. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7097. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7098. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7099. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7100. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7101. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7102. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7103. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7104. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7105. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7106. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7107. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7108. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7109. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7110. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7111. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7112. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7113. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7114. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7115. /* FIXME: use matrix-type input source selection */
  7116. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7117. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7118. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7119. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7120. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7121. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7122. /* Input mixer2 */
  7123. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7124. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7125. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7126. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7127. /* Input mixer3 */
  7128. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7129. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7130. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7131. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7132. { }
  7133. };
  7134. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  7135. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7136. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7137. {}
  7138. };
  7139. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  7140. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7141. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7142. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7143. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7144. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7145. {}
  7146. };
  7147. static struct hda_verb alc262_sony_unsol_verbs[] = {
  7148. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7149. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7150. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  7151. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7152. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7153. };
  7154. /* mute/unmute internal speaker according to the hp jack and mute state */
  7155. static void alc262_hippo_automute(struct hda_codec *codec)
  7156. {
  7157. struct alc_spec *spec = codec->spec;
  7158. unsigned int mute;
  7159. unsigned int present;
  7160. /* need to execute and sync at first */
  7161. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7162. present = snd_hda_codec_read(codec, 0x15, 0,
  7163. AC_VERB_GET_PIN_SENSE, 0);
  7164. spec->jack_present = (present & 0x80000000) != 0;
  7165. if (spec->jack_present) {
  7166. /* mute internal speaker */
  7167. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7168. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7169. } else {
  7170. /* unmute internal speaker if necessary */
  7171. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7172. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7173. HDA_AMP_MUTE, mute);
  7174. }
  7175. }
  7176. /* unsolicited event for HP jack sensing */
  7177. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  7178. unsigned int res)
  7179. {
  7180. if ((res >> 26) != ALC880_HP_EVENT)
  7181. return;
  7182. alc262_hippo_automute(codec);
  7183. }
  7184. static void alc262_hippo1_automute(struct hda_codec *codec)
  7185. {
  7186. unsigned int mute;
  7187. unsigned int present;
  7188. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  7189. present = snd_hda_codec_read(codec, 0x1b, 0,
  7190. AC_VERB_GET_PIN_SENSE, 0);
  7191. present = (present & 0x80000000) != 0;
  7192. if (present) {
  7193. /* mute internal speaker */
  7194. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7195. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7196. } else {
  7197. /* unmute internal speaker if necessary */
  7198. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  7199. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7200. HDA_AMP_MUTE, mute);
  7201. }
  7202. }
  7203. /* unsolicited event for HP jack sensing */
  7204. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  7205. unsigned int res)
  7206. {
  7207. if ((res >> 26) != ALC880_HP_EVENT)
  7208. return;
  7209. alc262_hippo1_automute(codec);
  7210. }
  7211. /*
  7212. * fujitsu model
  7213. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  7214. */
  7215. #define ALC_HP_EVENT 0x37
  7216. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  7217. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  7218. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7219. {}
  7220. };
  7221. static struct hda_input_mux alc262_fujitsu_capture_source = {
  7222. .num_items = 3,
  7223. .items = {
  7224. { "Mic", 0x0 },
  7225. { "Int Mic", 0x1 },
  7226. { "CD", 0x4 },
  7227. },
  7228. };
  7229. static struct hda_input_mux alc262_HP_capture_source = {
  7230. .num_items = 5,
  7231. .items = {
  7232. { "Mic", 0x0 },
  7233. { "Front Mic", 0x1 },
  7234. { "Line", 0x2 },
  7235. { "CD", 0x4 },
  7236. { "AUX IN", 0x6 },
  7237. },
  7238. };
  7239. static struct hda_input_mux alc262_HP_D7000_capture_source = {
  7240. .num_items = 4,
  7241. .items = {
  7242. { "Mic", 0x0 },
  7243. { "Front Mic", 0x2 },
  7244. { "Line", 0x1 },
  7245. { "CD", 0x4 },
  7246. },
  7247. };
  7248. /* mute/unmute internal speaker according to the hp jack and mute state */
  7249. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  7250. {
  7251. struct alc_spec *spec = codec->spec;
  7252. unsigned int mute;
  7253. if (force || !spec->sense_updated) {
  7254. unsigned int present;
  7255. /* need to execute and sync at first */
  7256. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  7257. present = snd_hda_codec_read(codec, 0x14, 0,
  7258. AC_VERB_GET_PIN_SENSE, 0);
  7259. spec->jack_present = (present & 0x80000000) != 0;
  7260. spec->sense_updated = 1;
  7261. }
  7262. if (spec->jack_present) {
  7263. /* mute internal speaker */
  7264. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7265. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7266. } else {
  7267. /* unmute internal speaker if necessary */
  7268. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7269. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7270. HDA_AMP_MUTE, mute);
  7271. }
  7272. }
  7273. /* unsolicited event for HP jack sensing */
  7274. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  7275. unsigned int res)
  7276. {
  7277. if ((res >> 26) != ALC_HP_EVENT)
  7278. return;
  7279. alc262_fujitsu_automute(codec, 1);
  7280. }
  7281. /* bind volumes of both NID 0x0c and 0x0d */
  7282. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  7283. .ops = &snd_hda_bind_vol,
  7284. .values = {
  7285. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7286. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7287. 0
  7288. },
  7289. };
  7290. /* bind hp and internal speaker mute (with plug check) */
  7291. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  7292. struct snd_ctl_elem_value *ucontrol)
  7293. {
  7294. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7295. long *valp = ucontrol->value.integer.value;
  7296. int change;
  7297. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7298. HDA_AMP_MUTE,
  7299. valp[0] ? 0 : HDA_AMP_MUTE);
  7300. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7301. HDA_AMP_MUTE,
  7302. valp[1] ? 0 : HDA_AMP_MUTE);
  7303. if (change)
  7304. alc262_fujitsu_automute(codec, 0);
  7305. return change;
  7306. }
  7307. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  7308. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  7309. {
  7310. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7311. .name = "Master Playback Switch",
  7312. .info = snd_hda_mixer_amp_switch_info,
  7313. .get = snd_hda_mixer_amp_switch_get,
  7314. .put = alc262_fujitsu_master_sw_put,
  7315. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7316. },
  7317. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7318. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7319. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7320. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7321. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7322. HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
  7323. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7324. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7325. { } /* end */
  7326. };
  7327. /* additional init verbs for Benq laptops */
  7328. static struct hda_verb alc262_EAPD_verbs[] = {
  7329. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7330. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7331. {}
  7332. };
  7333. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7334. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7335. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7336. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7337. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7338. {}
  7339. };
  7340. /* add playback controls from the parsed DAC table */
  7341. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7342. const struct auto_pin_cfg *cfg)
  7343. {
  7344. hda_nid_t nid;
  7345. int err;
  7346. spec->multiout.num_dacs = 1; /* only use one dac */
  7347. spec->multiout.dac_nids = spec->private_dac_nids;
  7348. spec->multiout.dac_nids[0] = 2;
  7349. nid = cfg->line_out_pins[0];
  7350. if (nid) {
  7351. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7352. "Front Playback Volume",
  7353. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7354. if (err < 0)
  7355. return err;
  7356. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7357. "Front Playback Switch",
  7358. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7359. if (err < 0)
  7360. return err;
  7361. }
  7362. nid = cfg->speaker_pins[0];
  7363. if (nid) {
  7364. if (nid == 0x16) {
  7365. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7366. "Speaker Playback Volume",
  7367. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7368. HDA_OUTPUT));
  7369. if (err < 0)
  7370. return err;
  7371. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7372. "Speaker Playback Switch",
  7373. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7374. HDA_OUTPUT));
  7375. if (err < 0)
  7376. return err;
  7377. } else {
  7378. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7379. "Speaker Playback Switch",
  7380. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7381. HDA_OUTPUT));
  7382. if (err < 0)
  7383. return err;
  7384. }
  7385. }
  7386. nid = cfg->hp_pins[0];
  7387. if (nid) {
  7388. /* spec->multiout.hp_nid = 2; */
  7389. if (nid == 0x16) {
  7390. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7391. "Headphone Playback Volume",
  7392. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7393. HDA_OUTPUT));
  7394. if (err < 0)
  7395. return err;
  7396. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7397. "Headphone Playback Switch",
  7398. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7399. HDA_OUTPUT));
  7400. if (err < 0)
  7401. return err;
  7402. } else {
  7403. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7404. "Headphone Playback Switch",
  7405. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7406. HDA_OUTPUT));
  7407. if (err < 0)
  7408. return err;
  7409. }
  7410. }
  7411. return 0;
  7412. }
  7413. /* identical with ALC880 */
  7414. #define alc262_auto_create_analog_input_ctls \
  7415. alc880_auto_create_analog_input_ctls
  7416. /*
  7417. * generic initialization of ADC, input mixers and output mixers
  7418. */
  7419. static struct hda_verb alc262_volume_init_verbs[] = {
  7420. /*
  7421. * Unmute ADC0-2 and set the default input to mic-in
  7422. */
  7423. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7424. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7425. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7426. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7427. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7428. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7429. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7430. * mixer widget
  7431. * Note: PASD motherboards uses the Line In 2 as the input for
  7432. * front panel mic (mic 2)
  7433. */
  7434. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7435. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7436. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7437. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7438. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7439. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7440. /*
  7441. * Set up output mixers (0x0c - 0x0f)
  7442. */
  7443. /* set vol=0 to output mixers */
  7444. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7445. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7446. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7447. /* set up input amps for analog loopback */
  7448. /* Amp Indices: DAC = 0, mixer = 1 */
  7449. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7450. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7451. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7452. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7453. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7454. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7455. /* FIXME: use matrix-type input source selection */
  7456. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7457. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7458. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7459. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7460. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7461. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7462. /* Input mixer2 */
  7463. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7464. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7465. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7466. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7467. /* Input mixer3 */
  7468. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7469. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7470. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7471. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7472. { }
  7473. };
  7474. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7475. /*
  7476. * Unmute ADC0-2 and set the default input to mic-in
  7477. */
  7478. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7479. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7480. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7481. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7482. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7483. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7484. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7485. * mixer widget
  7486. * Note: PASD motherboards uses the Line In 2 as the input for
  7487. * front panel mic (mic 2)
  7488. */
  7489. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7490. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7491. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7492. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7493. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7494. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7495. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7496. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7497. /*
  7498. * Set up output mixers (0x0c - 0x0e)
  7499. */
  7500. /* set vol=0 to output mixers */
  7501. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7502. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7503. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7504. /* set up input amps for analog loopback */
  7505. /* Amp Indices: DAC = 0, mixer = 1 */
  7506. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7507. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7508. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7509. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7510. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7511. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7512. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7513. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7514. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7515. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7516. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7517. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7518. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7519. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7520. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7521. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7522. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7523. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7524. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7525. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7526. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7527. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7528. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7529. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7530. /* FIXME: use matrix-type input source selection */
  7531. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7532. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7533. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7534. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7535. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7536. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7537. /* Input mixer2 */
  7538. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7539. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7540. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7541. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7542. /* Input mixer3 */
  7543. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7544. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7545. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7546. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7547. { }
  7548. };
  7549. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7550. /*
  7551. * Unmute ADC0-2 and set the default input to mic-in
  7552. */
  7553. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7554. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7555. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7556. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7557. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7558. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7559. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7560. * mixer widget
  7561. * Note: PASD motherboards uses the Line In 2 as the input for front
  7562. * panel mic (mic 2)
  7563. */
  7564. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7565. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7566. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7567. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7568. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7569. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7570. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7571. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7572. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7573. /*
  7574. * Set up output mixers (0x0c - 0x0e)
  7575. */
  7576. /* set vol=0 to output mixers */
  7577. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7578. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7579. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7580. /* set up input amps for analog loopback */
  7581. /* Amp Indices: DAC = 0, mixer = 1 */
  7582. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7583. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7584. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7585. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7586. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7587. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7588. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7589. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7590. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7591. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7592. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7593. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7594. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7595. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7596. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7597. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7598. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7599. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7600. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7601. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7602. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7603. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7604. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7605. /* FIXME: use matrix-type input source selection */
  7606. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7607. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7608. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7609. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7610. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7611. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7612. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7613. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7614. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7615. /* Input mixer2 */
  7616. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7617. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7618. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7619. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7620. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7621. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7622. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7623. /* Input mixer3 */
  7624. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7625. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7626. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7627. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7628. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7629. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7630. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7631. { }
  7632. };
  7633. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7634. #define alc262_loopbacks alc880_loopbacks
  7635. #endif
  7636. /* pcm configuration: identiacal with ALC880 */
  7637. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7638. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7639. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7640. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7641. /*
  7642. * BIOS auto configuration
  7643. */
  7644. static int alc262_parse_auto_config(struct hda_codec *codec)
  7645. {
  7646. struct alc_spec *spec = codec->spec;
  7647. int err;
  7648. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7649. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7650. alc262_ignore);
  7651. if (err < 0)
  7652. return err;
  7653. if (!spec->autocfg.line_outs)
  7654. return 0; /* can't find valid BIOS pin config */
  7655. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7656. if (err < 0)
  7657. return err;
  7658. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7659. if (err < 0)
  7660. return err;
  7661. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7662. if (spec->autocfg.dig_out_pin)
  7663. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7664. if (spec->autocfg.dig_in_pin)
  7665. spec->dig_in_nid = ALC262_DIGIN_NID;
  7666. if (spec->kctl_alloc)
  7667. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7668. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7669. spec->num_mux_defs = 1;
  7670. spec->input_mux = &spec->private_imux;
  7671. err = alc_auto_add_mic_boost(codec);
  7672. if (err < 0)
  7673. return err;
  7674. return 1;
  7675. }
  7676. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7677. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7678. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7679. /* init callback for auto-configuration model -- overriding the default init */
  7680. static void alc262_auto_init(struct hda_codec *codec)
  7681. {
  7682. alc262_auto_init_multi_out(codec);
  7683. alc262_auto_init_hp_out(codec);
  7684. alc262_auto_init_analog_input(codec);
  7685. }
  7686. /*
  7687. * configuration and preset
  7688. */
  7689. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7690. [ALC262_BASIC] = "basic",
  7691. [ALC262_HIPPO] = "hippo",
  7692. [ALC262_HIPPO_1] = "hippo_1",
  7693. [ALC262_FUJITSU] = "fujitsu",
  7694. [ALC262_HP_BPC] = "hp-bpc",
  7695. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7696. [ALC262_BENQ_ED8] = "benq",
  7697. [ALC262_BENQ_T31] = "benq-t31",
  7698. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7699. [ALC262_AUTO] = "auto",
  7700. };
  7701. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7702. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7703. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7704. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7705. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7706. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7707. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7708. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7709. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7710. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7711. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7712. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7713. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7714. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7715. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7716. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7717. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7718. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7719. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7720. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7721. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7722. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7723. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7724. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7725. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7726. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7727. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7728. {}
  7729. };
  7730. static struct alc_config_preset alc262_presets[] = {
  7731. [ALC262_BASIC] = {
  7732. .mixers = { alc262_base_mixer },
  7733. .init_verbs = { alc262_init_verbs },
  7734. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7735. .dac_nids = alc262_dac_nids,
  7736. .hp_nid = 0x03,
  7737. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7738. .channel_mode = alc262_modes,
  7739. .input_mux = &alc262_capture_source,
  7740. },
  7741. [ALC262_HIPPO] = {
  7742. .mixers = { alc262_base_mixer },
  7743. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7744. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7745. .dac_nids = alc262_dac_nids,
  7746. .hp_nid = 0x03,
  7747. .dig_out_nid = ALC262_DIGOUT_NID,
  7748. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7749. .channel_mode = alc262_modes,
  7750. .input_mux = &alc262_capture_source,
  7751. .unsol_event = alc262_hippo_unsol_event,
  7752. .init_hook = alc262_hippo_automute,
  7753. },
  7754. [ALC262_HIPPO_1] = {
  7755. .mixers = { alc262_hippo1_mixer },
  7756. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7757. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7758. .dac_nids = alc262_dac_nids,
  7759. .hp_nid = 0x02,
  7760. .dig_out_nid = ALC262_DIGOUT_NID,
  7761. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7762. .channel_mode = alc262_modes,
  7763. .input_mux = &alc262_capture_source,
  7764. .unsol_event = alc262_hippo1_unsol_event,
  7765. .init_hook = alc262_hippo1_automute,
  7766. },
  7767. [ALC262_FUJITSU] = {
  7768. .mixers = { alc262_fujitsu_mixer },
  7769. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
  7770. alc262_fujitsu_unsol_verbs },
  7771. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7772. .dac_nids = alc262_dac_nids,
  7773. .hp_nid = 0x03,
  7774. .dig_out_nid = ALC262_DIGOUT_NID,
  7775. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7776. .channel_mode = alc262_modes,
  7777. .input_mux = &alc262_fujitsu_capture_source,
  7778. .unsol_event = alc262_fujitsu_unsol_event,
  7779. },
  7780. [ALC262_HP_BPC] = {
  7781. .mixers = { alc262_HP_BPC_mixer },
  7782. .init_verbs = { alc262_HP_BPC_init_verbs },
  7783. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7784. .dac_nids = alc262_dac_nids,
  7785. .hp_nid = 0x03,
  7786. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7787. .channel_mode = alc262_modes,
  7788. .input_mux = &alc262_HP_capture_source,
  7789. },
  7790. [ALC262_HP_BPC_D7000_WF] = {
  7791. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7792. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7793. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7794. .dac_nids = alc262_dac_nids,
  7795. .hp_nid = 0x03,
  7796. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7797. .channel_mode = alc262_modes,
  7798. .input_mux = &alc262_HP_D7000_capture_source,
  7799. },
  7800. [ALC262_HP_BPC_D7000_WL] = {
  7801. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7802. alc262_HP_BPC_WildWest_option_mixer },
  7803. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7804. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7805. .dac_nids = alc262_dac_nids,
  7806. .hp_nid = 0x03,
  7807. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7808. .channel_mode = alc262_modes,
  7809. .input_mux = &alc262_HP_D7000_capture_source,
  7810. },
  7811. [ALC262_BENQ_ED8] = {
  7812. .mixers = { alc262_base_mixer },
  7813. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7814. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7815. .dac_nids = alc262_dac_nids,
  7816. .hp_nid = 0x03,
  7817. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7818. .channel_mode = alc262_modes,
  7819. .input_mux = &alc262_capture_source,
  7820. },
  7821. [ALC262_SONY_ASSAMD] = {
  7822. .mixers = { alc262_sony_mixer },
  7823. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7824. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7825. .dac_nids = alc262_dac_nids,
  7826. .hp_nid = 0x02,
  7827. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7828. .channel_mode = alc262_modes,
  7829. .input_mux = &alc262_capture_source,
  7830. .unsol_event = alc262_hippo_unsol_event,
  7831. .init_hook = alc262_hippo_automute,
  7832. },
  7833. [ALC262_BENQ_T31] = {
  7834. .mixers = { alc262_benq_t31_mixer },
  7835. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7836. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7837. .dac_nids = alc262_dac_nids,
  7838. .hp_nid = 0x03,
  7839. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7840. .channel_mode = alc262_modes,
  7841. .input_mux = &alc262_capture_source,
  7842. .unsol_event = alc262_hippo_unsol_event,
  7843. .init_hook = alc262_hippo_automute,
  7844. },
  7845. };
  7846. static int patch_alc262(struct hda_codec *codec)
  7847. {
  7848. struct alc_spec *spec;
  7849. int board_config;
  7850. int err;
  7851. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7852. if (spec == NULL)
  7853. return -ENOMEM;
  7854. codec->spec = spec;
  7855. #if 0
  7856. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7857. * under-run
  7858. */
  7859. {
  7860. int tmp;
  7861. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7862. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7863. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7864. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7865. }
  7866. #endif
  7867. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7868. alc262_models,
  7869. alc262_cfg_tbl);
  7870. if (board_config < 0) {
  7871. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7872. "trying auto-probe from BIOS...\n");
  7873. board_config = ALC262_AUTO;
  7874. }
  7875. if (board_config == ALC262_AUTO) {
  7876. /* automatic parse from the BIOS config */
  7877. err = alc262_parse_auto_config(codec);
  7878. if (err < 0) {
  7879. alc_free(codec);
  7880. return err;
  7881. } else if (!err) {
  7882. printk(KERN_INFO
  7883. "hda_codec: Cannot set up configuration "
  7884. "from BIOS. Using base mode...\n");
  7885. board_config = ALC262_BASIC;
  7886. }
  7887. }
  7888. if (board_config != ALC262_AUTO)
  7889. setup_preset(spec, &alc262_presets[board_config]);
  7890. spec->stream_name_analog = "ALC262 Analog";
  7891. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7892. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7893. spec->stream_name_digital = "ALC262 Digital";
  7894. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7895. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7896. if (!spec->adc_nids && spec->input_mux) {
  7897. /* check whether NID 0x07 is valid */
  7898. unsigned int wcap = get_wcaps(codec, 0x07);
  7899. /* get type */
  7900. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7901. if (wcap != AC_WID_AUD_IN) {
  7902. spec->adc_nids = alc262_adc_nids_alt;
  7903. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7904. spec->mixers[spec->num_mixers] =
  7905. alc262_capture_alt_mixer;
  7906. spec->num_mixers++;
  7907. } else {
  7908. spec->adc_nids = alc262_adc_nids;
  7909. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7910. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7911. spec->num_mixers++;
  7912. }
  7913. }
  7914. codec->patch_ops = alc_patch_ops;
  7915. if (board_config == ALC262_AUTO)
  7916. spec->init_hook = alc262_auto_init;
  7917. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7918. if (!spec->loopback.amplist)
  7919. spec->loopback.amplist = alc262_loopbacks;
  7920. #endif
  7921. return 0;
  7922. }
  7923. /*
  7924. * ALC268 channel source setting (2 channel)
  7925. */
  7926. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7927. #define alc268_modes alc260_modes
  7928. static hda_nid_t alc268_dac_nids[2] = {
  7929. /* front, hp */
  7930. 0x02, 0x03
  7931. };
  7932. static hda_nid_t alc268_adc_nids[2] = {
  7933. /* ADC0-1 */
  7934. 0x08, 0x07
  7935. };
  7936. static hda_nid_t alc268_adc_nids_alt[1] = {
  7937. /* ADC0 */
  7938. 0x08
  7939. };
  7940. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7941. /* output mixer control */
  7942. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7943. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7944. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7945. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7946. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7947. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7948. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7949. { }
  7950. };
  7951. static struct hda_verb alc268_eapd_verbs[] = {
  7952. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7953. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7954. { }
  7955. };
  7956. /* Toshiba specific */
  7957. #define alc268_toshiba_automute alc262_hippo_automute
  7958. static struct hda_verb alc268_toshiba_verbs[] = {
  7959. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7960. { } /* end */
  7961. };
  7962. /* Acer specific */
  7963. /* bind volumes of both NID 0x02 and 0x03 */
  7964. static struct hda_bind_ctls alc268_acer_bind_master_vol = {
  7965. .ops = &snd_hda_bind_vol,
  7966. .values = {
  7967. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  7968. HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
  7969. 0
  7970. },
  7971. };
  7972. /* mute/unmute internal speaker according to the hp jack and mute state */
  7973. static void alc268_acer_automute(struct hda_codec *codec, int force)
  7974. {
  7975. struct alc_spec *spec = codec->spec;
  7976. unsigned int mute;
  7977. if (force || !spec->sense_updated) {
  7978. unsigned int present;
  7979. present = snd_hda_codec_read(codec, 0x14, 0,
  7980. AC_VERB_GET_PIN_SENSE, 0);
  7981. spec->jack_present = (present & 0x80000000) != 0;
  7982. spec->sense_updated = 1;
  7983. }
  7984. if (spec->jack_present)
  7985. mute = HDA_AMP_MUTE; /* mute internal speaker */
  7986. else /* unmute internal speaker if necessary */
  7987. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7988. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7989. HDA_AMP_MUTE, mute);
  7990. }
  7991. /* bind hp and internal speaker mute (with plug check) */
  7992. static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
  7993. struct snd_ctl_elem_value *ucontrol)
  7994. {
  7995. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7996. long *valp = ucontrol->value.integer.value;
  7997. int change;
  7998. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7999. HDA_AMP_MUTE,
  8000. valp[0] ? 0 : HDA_AMP_MUTE);
  8001. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8002. HDA_AMP_MUTE,
  8003. valp[1] ? 0 : HDA_AMP_MUTE);
  8004. if (change)
  8005. alc268_acer_automute(codec, 0);
  8006. return change;
  8007. }
  8008. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  8009. /* output mixer control */
  8010. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  8011. {
  8012. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8013. .name = "Master Playback Switch",
  8014. .info = snd_hda_mixer_amp_switch_info,
  8015. .get = snd_hda_mixer_amp_switch_get,
  8016. .put = alc268_acer_master_sw_put,
  8017. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  8018. },
  8019. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8020. HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
  8021. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  8022. { }
  8023. };
  8024. static struct hda_verb alc268_acer_verbs[] = {
  8025. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8026. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8027. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  8028. { }
  8029. };
  8030. /* unsolicited event for HP jack sensing */
  8031. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  8032. unsigned int res)
  8033. {
  8034. if ((res >> 26) != ALC880_HP_EVENT)
  8035. return;
  8036. alc268_toshiba_automute(codec);
  8037. }
  8038. static void alc268_acer_unsol_event(struct hda_codec *codec,
  8039. unsigned int res)
  8040. {
  8041. if ((res >> 26) != ALC880_HP_EVENT)
  8042. return;
  8043. alc268_acer_automute(codec, 1);
  8044. }
  8045. static void alc268_acer_init_hook(struct hda_codec *codec)
  8046. {
  8047. alc268_acer_automute(codec, 1);
  8048. }
  8049. /*
  8050. * generic initialization of ADC, input mixers and output mixers
  8051. */
  8052. static struct hda_verb alc268_base_init_verbs[] = {
  8053. /* Unmute DAC0-1 and set vol = 0 */
  8054. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8055. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8056. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8057. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8058. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8059. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8060. /*
  8061. * Set up output mixers (0x0c - 0x0e)
  8062. */
  8063. /* set vol=0 to output mixers */
  8064. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8065. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8066. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8067. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  8068. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8069. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8070. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  8071. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  8072. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  8073. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8074. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8075. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8076. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8077. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8078. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8079. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8080. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8081. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8082. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8083. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8084. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8085. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8086. /* FIXME: use matrix-type input source selection */
  8087. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  8088. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  8089. /* Input mixer2 */
  8090. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8091. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  8092. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  8093. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  8094. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8095. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  8096. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  8097. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  8098. { }
  8099. };
  8100. /*
  8101. * generic initialization of ADC, input mixers and output mixers
  8102. */
  8103. static struct hda_verb alc268_volume_init_verbs[] = {
  8104. /* set output DAC */
  8105. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8106. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8107. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8108. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8109. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8110. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8111. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8112. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8113. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8114. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8115. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8116. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8117. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8118. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8119. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8120. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8121. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8122. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8123. /* set PCBEEP vol = 0 */
  8124. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  8125. { }
  8126. };
  8127. #define alc268_mux_enum_info alc_mux_enum_info
  8128. #define alc268_mux_enum_get alc_mux_enum_get
  8129. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  8130. struct snd_ctl_elem_value *ucontrol)
  8131. {
  8132. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8133. struct alc_spec *spec = codec->spec;
  8134. const struct hda_input_mux *imux = spec->input_mux;
  8135. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8136. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  8137. hda_nid_t nid = capture_mixers[adc_idx];
  8138. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8139. unsigned int i, idx;
  8140. idx = ucontrol->value.enumerated.item[0];
  8141. if (idx >= imux->num_items)
  8142. idx = imux->num_items - 1;
  8143. if (*cur_val == idx)
  8144. return 0;
  8145. for (i = 0; i < imux->num_items; i++) {
  8146. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  8147. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  8148. imux->items[i].index,
  8149. HDA_AMP_MUTE, v);
  8150. snd_hda_codec_write_cache(codec, nid, 0,
  8151. AC_VERB_SET_CONNECT_SEL,
  8152. idx );
  8153. }
  8154. *cur_val = idx;
  8155. return 1;
  8156. }
  8157. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  8158. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8159. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8160. {
  8161. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8162. /* The multiple "Capture Source" controls confuse alsamixer
  8163. * So call somewhat different..
  8164. * FIXME: the controls appear in the "playback" view!
  8165. */
  8166. /* .name = "Capture Source", */
  8167. .name = "Input Source",
  8168. .count = 1,
  8169. .info = alc268_mux_enum_info,
  8170. .get = alc268_mux_enum_get,
  8171. .put = alc268_mux_enum_put,
  8172. },
  8173. { } /* end */
  8174. };
  8175. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  8176. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8177. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8178. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  8179. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  8180. {
  8181. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8182. /* The multiple "Capture Source" controls confuse alsamixer
  8183. * So call somewhat different..
  8184. * FIXME: the controls appear in the "playback" view!
  8185. */
  8186. /* .name = "Capture Source", */
  8187. .name = "Input Source",
  8188. .count = 2,
  8189. .info = alc268_mux_enum_info,
  8190. .get = alc268_mux_enum_get,
  8191. .put = alc268_mux_enum_put,
  8192. },
  8193. { } /* end */
  8194. };
  8195. static struct hda_input_mux alc268_capture_source = {
  8196. .num_items = 4,
  8197. .items = {
  8198. { "Mic", 0x0 },
  8199. { "Front Mic", 0x1 },
  8200. { "Line", 0x2 },
  8201. { "CD", 0x3 },
  8202. },
  8203. };
  8204. /* create input playback/capture controls for the given pin */
  8205. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  8206. const char *ctlname, int idx)
  8207. {
  8208. char name[32];
  8209. int err;
  8210. sprintf(name, "%s Playback Volume", ctlname);
  8211. if (nid == 0x14) {
  8212. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8213. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  8214. HDA_OUTPUT));
  8215. if (err < 0)
  8216. return err;
  8217. } else if (nid == 0x15) {
  8218. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8219. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  8220. HDA_OUTPUT));
  8221. if (err < 0)
  8222. return err;
  8223. } else
  8224. return -1;
  8225. sprintf(name, "%s Playback Switch", ctlname);
  8226. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8227. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  8228. if (err < 0)
  8229. return err;
  8230. return 0;
  8231. }
  8232. /* add playback controls from the parsed DAC table */
  8233. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  8234. const struct auto_pin_cfg *cfg)
  8235. {
  8236. hda_nid_t nid;
  8237. int err;
  8238. spec->multiout.num_dacs = 2; /* only use one dac */
  8239. spec->multiout.dac_nids = spec->private_dac_nids;
  8240. spec->multiout.dac_nids[0] = 2;
  8241. spec->multiout.dac_nids[1] = 3;
  8242. nid = cfg->line_out_pins[0];
  8243. if (nid)
  8244. alc268_new_analog_output(spec, nid, "Front", 0);
  8245. nid = cfg->speaker_pins[0];
  8246. if (nid == 0x1d) {
  8247. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8248. "Speaker Playback Volume",
  8249. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  8250. if (err < 0)
  8251. return err;
  8252. }
  8253. nid = cfg->hp_pins[0];
  8254. if (nid)
  8255. alc268_new_analog_output(spec, nid, "Headphone", 0);
  8256. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  8257. if (nid == 0x16) {
  8258. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8259. "Mono Playback Switch",
  8260. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  8261. if (err < 0)
  8262. return err;
  8263. }
  8264. return 0;
  8265. }
  8266. /* create playback/capture controls for input pins */
  8267. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  8268. const struct auto_pin_cfg *cfg)
  8269. {
  8270. struct hda_input_mux *imux = &spec->private_imux;
  8271. int i, idx1;
  8272. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8273. switch(cfg->input_pins[i]) {
  8274. case 0x18:
  8275. idx1 = 0; /* Mic 1 */
  8276. break;
  8277. case 0x19:
  8278. idx1 = 1; /* Mic 2 */
  8279. break;
  8280. case 0x1a:
  8281. idx1 = 2; /* Line In */
  8282. break;
  8283. case 0x1c:
  8284. idx1 = 3; /* CD */
  8285. break;
  8286. default:
  8287. continue;
  8288. }
  8289. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8290. imux->items[imux->num_items].index = idx1;
  8291. imux->num_items++;
  8292. }
  8293. return 0;
  8294. }
  8295. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  8296. {
  8297. struct alc_spec *spec = codec->spec;
  8298. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  8299. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  8300. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  8301. unsigned int dac_vol1, dac_vol2;
  8302. if (speaker_nid) {
  8303. snd_hda_codec_write(codec, speaker_nid, 0,
  8304. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  8305. snd_hda_codec_write(codec, 0x0f, 0,
  8306. AC_VERB_SET_AMP_GAIN_MUTE,
  8307. AMP_IN_UNMUTE(1));
  8308. snd_hda_codec_write(codec, 0x10, 0,
  8309. AC_VERB_SET_AMP_GAIN_MUTE,
  8310. AMP_IN_UNMUTE(1));
  8311. } else {
  8312. snd_hda_codec_write(codec, 0x0f, 0,
  8313. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8314. snd_hda_codec_write(codec, 0x10, 0,
  8315. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8316. }
  8317. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  8318. if (line_nid == 0x14)
  8319. dac_vol2 = AMP_OUT_ZERO;
  8320. else if (line_nid == 0x15)
  8321. dac_vol1 = AMP_OUT_ZERO;
  8322. if (hp_nid == 0x14)
  8323. dac_vol2 = AMP_OUT_ZERO;
  8324. else if (hp_nid == 0x15)
  8325. dac_vol1 = AMP_OUT_ZERO;
  8326. if (line_nid != 0x16 || hp_nid != 0x16 ||
  8327. spec->autocfg.line_out_pins[1] != 0x16 ||
  8328. spec->autocfg.line_out_pins[2] != 0x16)
  8329. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  8330. snd_hda_codec_write(codec, 0x02, 0,
  8331. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  8332. snd_hda_codec_write(codec, 0x03, 0,
  8333. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  8334. }
  8335. /* pcm configuration: identiacal with ALC880 */
  8336. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  8337. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  8338. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  8339. /*
  8340. * BIOS auto configuration
  8341. */
  8342. static int alc268_parse_auto_config(struct hda_codec *codec)
  8343. {
  8344. struct alc_spec *spec = codec->spec;
  8345. int err;
  8346. static hda_nid_t alc268_ignore[] = { 0 };
  8347. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8348. alc268_ignore);
  8349. if (err < 0)
  8350. return err;
  8351. if (!spec->autocfg.line_outs)
  8352. return 0; /* can't find valid BIOS pin config */
  8353. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8354. if (err < 0)
  8355. return err;
  8356. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8357. if (err < 0)
  8358. return err;
  8359. spec->multiout.max_channels = 2;
  8360. /* digital only support output */
  8361. if (spec->autocfg.dig_out_pin)
  8362. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  8363. if (spec->kctl_alloc)
  8364. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8365. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  8366. spec->num_mux_defs = 1;
  8367. spec->input_mux = &spec->private_imux;
  8368. err = alc_auto_add_mic_boost(codec);
  8369. if (err < 0)
  8370. return err;
  8371. return 1;
  8372. }
  8373. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  8374. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  8375. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  8376. /* init callback for auto-configuration model -- overriding the default init */
  8377. static void alc268_auto_init(struct hda_codec *codec)
  8378. {
  8379. alc268_auto_init_multi_out(codec);
  8380. alc268_auto_init_hp_out(codec);
  8381. alc268_auto_init_mono_speaker_out(codec);
  8382. alc268_auto_init_analog_input(codec);
  8383. }
  8384. /*
  8385. * configuration and preset
  8386. */
  8387. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8388. [ALC268_3ST] = "3stack",
  8389. [ALC268_TOSHIBA] = "toshiba",
  8390. [ALC268_ACER] = "acer",
  8391. [ALC268_AUTO] = "auto",
  8392. };
  8393. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8394. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8395. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8396. SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
  8397. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8398. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8399. SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
  8400. SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
  8401. {}
  8402. };
  8403. static struct alc_config_preset alc268_presets[] = {
  8404. [ALC268_3ST] = {
  8405. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8406. .init_verbs = { alc268_base_init_verbs },
  8407. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8408. .dac_nids = alc268_dac_nids,
  8409. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8410. .adc_nids = alc268_adc_nids_alt,
  8411. .hp_nid = 0x03,
  8412. .dig_out_nid = ALC268_DIGOUT_NID,
  8413. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8414. .channel_mode = alc268_modes,
  8415. .input_mux = &alc268_capture_source,
  8416. },
  8417. [ALC268_TOSHIBA] = {
  8418. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8419. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8420. alc268_toshiba_verbs },
  8421. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8422. .dac_nids = alc268_dac_nids,
  8423. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8424. .adc_nids = alc268_adc_nids_alt,
  8425. .hp_nid = 0x03,
  8426. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8427. .channel_mode = alc268_modes,
  8428. .input_mux = &alc268_capture_source,
  8429. .input_mux = &alc268_capture_source,
  8430. .unsol_event = alc268_toshiba_unsol_event,
  8431. .init_hook = alc268_toshiba_automute,
  8432. },
  8433. [ALC268_ACER] = {
  8434. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8435. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8436. alc268_acer_verbs },
  8437. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8438. .dac_nids = alc268_dac_nids,
  8439. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8440. .adc_nids = alc268_adc_nids_alt,
  8441. .hp_nid = 0x02,
  8442. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8443. .channel_mode = alc268_modes,
  8444. .input_mux = &alc268_capture_source,
  8445. .unsol_event = alc268_acer_unsol_event,
  8446. .init_hook = alc268_acer_init_hook,
  8447. },
  8448. };
  8449. static int patch_alc268(struct hda_codec *codec)
  8450. {
  8451. struct alc_spec *spec;
  8452. int board_config;
  8453. int err;
  8454. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8455. if (spec == NULL)
  8456. return -ENOMEM;
  8457. codec->spec = spec;
  8458. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8459. alc268_models,
  8460. alc268_cfg_tbl);
  8461. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8462. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8463. "trying auto-probe from BIOS...\n");
  8464. board_config = ALC268_AUTO;
  8465. }
  8466. if (board_config == ALC268_AUTO) {
  8467. /* automatic parse from the BIOS config */
  8468. err = alc268_parse_auto_config(codec);
  8469. if (err < 0) {
  8470. alc_free(codec);
  8471. return err;
  8472. } else if (!err) {
  8473. printk(KERN_INFO
  8474. "hda_codec: Cannot set up configuration "
  8475. "from BIOS. Using base mode...\n");
  8476. board_config = ALC268_3ST;
  8477. }
  8478. }
  8479. if (board_config != ALC268_AUTO)
  8480. setup_preset(spec, &alc268_presets[board_config]);
  8481. spec->stream_name_analog = "ALC268 Analog";
  8482. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8483. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8484. spec->stream_name_digital = "ALC268 Digital";
  8485. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8486. if (board_config == ALC268_AUTO) {
  8487. if (!spec->adc_nids && spec->input_mux) {
  8488. /* check whether NID 0x07 is valid */
  8489. unsigned int wcap = get_wcaps(codec, 0x07);
  8490. /* get type */
  8491. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8492. if (wcap != AC_WID_AUD_IN) {
  8493. spec->adc_nids = alc268_adc_nids_alt;
  8494. spec->num_adc_nids =
  8495. ARRAY_SIZE(alc268_adc_nids_alt);
  8496. spec->mixers[spec->num_mixers] =
  8497. alc268_capture_alt_mixer;
  8498. spec->num_mixers++;
  8499. } else {
  8500. spec->adc_nids = alc268_adc_nids;
  8501. spec->num_adc_nids =
  8502. ARRAY_SIZE(alc268_adc_nids);
  8503. spec->mixers[spec->num_mixers] =
  8504. alc268_capture_mixer;
  8505. spec->num_mixers++;
  8506. }
  8507. }
  8508. }
  8509. codec->patch_ops = alc_patch_ops;
  8510. if (board_config == ALC268_AUTO)
  8511. spec->init_hook = alc268_auto_init;
  8512. return 0;
  8513. }
  8514. /*
  8515. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8516. */
  8517. /*
  8518. * set the path ways for 2 channel output
  8519. * need to set the codec line out and mic 1 pin widgets to inputs
  8520. */
  8521. static struct hda_verb alc861_threestack_ch2_init[] = {
  8522. /* set pin widget 1Ah (line in) for input */
  8523. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8524. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8525. * the vref
  8526. */
  8527. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8528. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8529. #if 0
  8530. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8531. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8532. #endif
  8533. { } /* end */
  8534. };
  8535. /*
  8536. * 6ch mode
  8537. * need to set the codec line out and mic 1 pin widgets to outputs
  8538. */
  8539. static struct hda_verb alc861_threestack_ch6_init[] = {
  8540. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8541. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8542. /* set pin widget 18h (mic1) for output (CLFE)*/
  8543. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8544. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8545. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8546. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8547. #if 0
  8548. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8549. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8550. #endif
  8551. { } /* end */
  8552. };
  8553. static struct hda_channel_mode alc861_threestack_modes[2] = {
  8554. { 2, alc861_threestack_ch2_init },
  8555. { 6, alc861_threestack_ch6_init },
  8556. };
  8557. /* Set mic1 as input and unmute the mixer */
  8558. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  8559. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8560. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8561. { } /* end */
  8562. };
  8563. /* Set mic1 as output and mute mixer */
  8564. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  8565. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8566. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8567. { } /* end */
  8568. };
  8569. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  8570. { 2, alc861_uniwill_m31_ch2_init },
  8571. { 4, alc861_uniwill_m31_ch4_init },
  8572. };
  8573. /* Set mic1 and line-in as input and unmute the mixer */
  8574. static struct hda_verb alc861_asus_ch2_init[] = {
  8575. /* set pin widget 1Ah (line in) for input */
  8576. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8577. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8578. * the vref
  8579. */
  8580. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8581. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8582. #if 0
  8583. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8584. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8585. #endif
  8586. { } /* end */
  8587. };
  8588. /* Set mic1 nad line-in as output and mute mixer */
  8589. static struct hda_verb alc861_asus_ch6_init[] = {
  8590. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8591. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8592. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8593. /* set pin widget 18h (mic1) for output (CLFE)*/
  8594. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8595. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8596. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8597. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8598. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8599. #if 0
  8600. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8601. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8602. #endif
  8603. { } /* end */
  8604. };
  8605. static struct hda_channel_mode alc861_asus_modes[2] = {
  8606. { 2, alc861_asus_ch2_init },
  8607. { 6, alc861_asus_ch6_init },
  8608. };
  8609. /* patch-ALC861 */
  8610. static struct snd_kcontrol_new alc861_base_mixer[] = {
  8611. /* output mixer control */
  8612. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8613. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8614. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8615. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8616. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8617. /*Input mixer control */
  8618. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8619. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8620. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8621. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8622. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8623. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8624. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8625. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8626. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8627. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8628. /* Capture mixer control */
  8629. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8630. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8631. {
  8632. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8633. .name = "Capture Source",
  8634. .count = 1,
  8635. .info = alc_mux_enum_info,
  8636. .get = alc_mux_enum_get,
  8637. .put = alc_mux_enum_put,
  8638. },
  8639. { } /* end */
  8640. };
  8641. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8642. /* output mixer control */
  8643. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8644. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8645. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8646. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8647. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8648. /* Input mixer control */
  8649. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8650. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8651. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8652. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8653. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8654. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8655. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8656. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8657. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8658. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8659. /* Capture mixer control */
  8660. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8661. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8662. {
  8663. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8664. .name = "Capture Source",
  8665. .count = 1,
  8666. .info = alc_mux_enum_info,
  8667. .get = alc_mux_enum_get,
  8668. .put = alc_mux_enum_put,
  8669. },
  8670. {
  8671. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8672. .name = "Channel Mode",
  8673. .info = alc_ch_mode_info,
  8674. .get = alc_ch_mode_get,
  8675. .put = alc_ch_mode_put,
  8676. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8677. },
  8678. { } /* end */
  8679. };
  8680. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8681. /* output mixer control */
  8682. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8683. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8684. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8685. /*Capture mixer control */
  8686. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8687. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8688. {
  8689. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8690. .name = "Capture Source",
  8691. .count = 1,
  8692. .info = alc_mux_enum_info,
  8693. .get = alc_mux_enum_get,
  8694. .put = alc_mux_enum_put,
  8695. },
  8696. { } /* end */
  8697. };
  8698. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8699. /* output mixer control */
  8700. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8701. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8702. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8703. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8704. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8705. /* Input mixer control */
  8706. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8707. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8708. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8709. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8710. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8711. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8712. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8713. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8714. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8715. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8716. /* Capture mixer control */
  8717. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8718. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8719. {
  8720. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8721. .name = "Capture Source",
  8722. .count = 1,
  8723. .info = alc_mux_enum_info,
  8724. .get = alc_mux_enum_get,
  8725. .put = alc_mux_enum_put,
  8726. },
  8727. {
  8728. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8729. .name = "Channel Mode",
  8730. .info = alc_ch_mode_info,
  8731. .get = alc_ch_mode_get,
  8732. .put = alc_ch_mode_put,
  8733. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8734. },
  8735. { } /* end */
  8736. };
  8737. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8738. /* output mixer control */
  8739. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8740. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8741. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8742. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8743. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8744. /* Input mixer control */
  8745. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8746. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8747. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8748. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8749. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8750. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8751. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8752. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8753. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8754. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8755. /* Capture mixer control */
  8756. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8757. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8758. {
  8759. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8760. .name = "Capture Source",
  8761. .count = 1,
  8762. .info = alc_mux_enum_info,
  8763. .get = alc_mux_enum_get,
  8764. .put = alc_mux_enum_put,
  8765. },
  8766. {
  8767. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8768. .name = "Channel Mode",
  8769. .info = alc_ch_mode_info,
  8770. .get = alc_ch_mode_get,
  8771. .put = alc_ch_mode_put,
  8772. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8773. },
  8774. { }
  8775. };
  8776. /* additional mixer */
  8777. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8778. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8779. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8780. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8781. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8782. { }
  8783. };
  8784. /*
  8785. * generic initialization of ADC, input mixers and output mixers
  8786. */
  8787. static struct hda_verb alc861_base_init_verbs[] = {
  8788. /*
  8789. * Unmute ADC0 and set the default input to mic-in
  8790. */
  8791. /* port-A for surround (rear panel) */
  8792. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8793. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8794. /* port-B for mic-in (rear panel) with vref */
  8795. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8796. /* port-C for line-in (rear panel) */
  8797. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8798. /* port-D for Front */
  8799. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8800. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8801. /* port-E for HP out (front panel) */
  8802. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8803. /* route front PCM to HP */
  8804. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8805. /* port-F for mic-in (front panel) with vref */
  8806. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8807. /* port-G for CLFE (rear panel) */
  8808. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8809. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8810. /* port-H for side (rear panel) */
  8811. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8812. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8813. /* CD-in */
  8814. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8815. /* route front mic to ADC1*/
  8816. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8817. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8818. /* Unmute DAC0~3 & spdif out*/
  8819. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8820. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8821. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8822. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8823. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8824. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8825. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8826. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8827. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8828. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8829. /* Unmute Stereo Mixer 15 */
  8830. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8831. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8832. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8833. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8834. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8835. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8836. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8837. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8838. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8839. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8840. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8841. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8842. /* hp used DAC 3 (Front) */
  8843. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8844. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8845. { }
  8846. };
  8847. static struct hda_verb alc861_threestack_init_verbs[] = {
  8848. /*
  8849. * Unmute ADC0 and set the default input to mic-in
  8850. */
  8851. /* port-A for surround (rear panel) */
  8852. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8853. /* port-B for mic-in (rear panel) with vref */
  8854. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8855. /* port-C for line-in (rear panel) */
  8856. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8857. /* port-D for Front */
  8858. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8859. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8860. /* port-E for HP out (front panel) */
  8861. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8862. /* route front PCM to HP */
  8863. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8864. /* port-F for mic-in (front panel) with vref */
  8865. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8866. /* port-G for CLFE (rear panel) */
  8867. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8868. /* port-H for side (rear panel) */
  8869. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8870. /* CD-in */
  8871. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8872. /* route front mic to ADC1*/
  8873. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8874. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8875. /* Unmute DAC0~3 & spdif out*/
  8876. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8877. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8878. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8879. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8880. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8881. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8882. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8883. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8884. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8885. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8886. /* Unmute Stereo Mixer 15 */
  8887. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8888. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8889. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8890. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8891. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8892. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8893. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8894. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8895. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8896. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8897. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8898. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8899. /* hp used DAC 3 (Front) */
  8900. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8901. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8902. { }
  8903. };
  8904. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8905. /*
  8906. * Unmute ADC0 and set the default input to mic-in
  8907. */
  8908. /* port-A for surround (rear panel) */
  8909. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8910. /* port-B for mic-in (rear panel) with vref */
  8911. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8912. /* port-C for line-in (rear panel) */
  8913. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8914. /* port-D for Front */
  8915. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8916. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8917. /* port-E for HP out (front panel) */
  8918. /* this has to be set to VREF80 */
  8919. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8920. /* route front PCM to HP */
  8921. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8922. /* port-F for mic-in (front panel) with vref */
  8923. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8924. /* port-G for CLFE (rear panel) */
  8925. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8926. /* port-H for side (rear panel) */
  8927. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8928. /* CD-in */
  8929. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8930. /* route front mic to ADC1*/
  8931. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8932. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8933. /* Unmute DAC0~3 & spdif out*/
  8934. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8935. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8936. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8937. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8938. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8939. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8940. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8941. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8942. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8943. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8944. /* Unmute Stereo Mixer 15 */
  8945. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8946. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8947. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8948. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8949. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8950. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8951. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8952. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8953. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8954. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8955. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8956. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8957. /* hp used DAC 3 (Front) */
  8958. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8959. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8960. { }
  8961. };
  8962. static struct hda_verb alc861_asus_init_verbs[] = {
  8963. /*
  8964. * Unmute ADC0 and set the default input to mic-in
  8965. */
  8966. /* port-A for surround (rear panel)
  8967. * according to codec#0 this is the HP jack
  8968. */
  8969. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8970. /* route front PCM to HP */
  8971. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8972. /* port-B for mic-in (rear panel) with vref */
  8973. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8974. /* port-C for line-in (rear panel) */
  8975. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8976. /* port-D for Front */
  8977. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8978. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8979. /* port-E for HP out (front panel) */
  8980. /* this has to be set to VREF80 */
  8981. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8982. /* route front PCM to HP */
  8983. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8984. /* port-F for mic-in (front panel) with vref */
  8985. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8986. /* port-G for CLFE (rear panel) */
  8987. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8988. /* port-H for side (rear panel) */
  8989. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8990. /* CD-in */
  8991. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8992. /* route front mic to ADC1*/
  8993. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8994. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8995. /* Unmute DAC0~3 & spdif out*/
  8996. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8997. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8998. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8999. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9000. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9001. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9002. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9003. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9004. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9005. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9006. /* Unmute Stereo Mixer 15 */
  9007. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9008. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9009. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9010. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9011. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9012. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9013. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9014. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9015. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9016. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9017. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9018. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9019. /* hp used DAC 3 (Front) */
  9020. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9021. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9022. { }
  9023. };
  9024. /* additional init verbs for ASUS laptops */
  9025. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  9026. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  9027. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  9028. { }
  9029. };
  9030. /*
  9031. * generic initialization of ADC, input mixers and output mixers
  9032. */
  9033. static struct hda_verb alc861_auto_init_verbs[] = {
  9034. /*
  9035. * Unmute ADC0 and set the default input to mic-in
  9036. */
  9037. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  9038. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9039. /* Unmute DAC0~3 & spdif out*/
  9040. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9041. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9042. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9043. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9044. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9045. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9046. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9047. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9048. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9049. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9050. /* Unmute Stereo Mixer 15 */
  9051. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9052. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9053. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9054. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  9055. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9056. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9057. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9058. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9059. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9060. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9061. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9062. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9063. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9064. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9065. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9066. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9067. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9068. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9069. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9070. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9071. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  9072. { }
  9073. };
  9074. static struct hda_verb alc861_toshiba_init_verbs[] = {
  9075. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9076. { }
  9077. };
  9078. /* toggle speaker-output according to the hp-jack state */
  9079. static void alc861_toshiba_automute(struct hda_codec *codec)
  9080. {
  9081. unsigned int present;
  9082. present = snd_hda_codec_read(codec, 0x0f, 0,
  9083. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9084. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  9085. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9086. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  9087. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  9088. }
  9089. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  9090. unsigned int res)
  9091. {
  9092. if ((res >> 26) == ALC880_HP_EVENT)
  9093. alc861_toshiba_automute(codec);
  9094. }
  9095. /* pcm configuration: identiacal with ALC880 */
  9096. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  9097. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  9098. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  9099. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  9100. #define ALC861_DIGOUT_NID 0x07
  9101. static struct hda_channel_mode alc861_8ch_modes[1] = {
  9102. { 8, NULL }
  9103. };
  9104. static hda_nid_t alc861_dac_nids[4] = {
  9105. /* front, surround, clfe, side */
  9106. 0x03, 0x06, 0x05, 0x04
  9107. };
  9108. static hda_nid_t alc660_dac_nids[3] = {
  9109. /* front, clfe, surround */
  9110. 0x03, 0x05, 0x06
  9111. };
  9112. static hda_nid_t alc861_adc_nids[1] = {
  9113. /* ADC0-2 */
  9114. 0x08,
  9115. };
  9116. static struct hda_input_mux alc861_capture_source = {
  9117. .num_items = 5,
  9118. .items = {
  9119. { "Mic", 0x0 },
  9120. { "Front Mic", 0x3 },
  9121. { "Line", 0x1 },
  9122. { "CD", 0x4 },
  9123. { "Mixer", 0x5 },
  9124. },
  9125. };
  9126. /* fill in the dac_nids table from the parsed pin configuration */
  9127. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  9128. const struct auto_pin_cfg *cfg)
  9129. {
  9130. int i;
  9131. hda_nid_t nid;
  9132. spec->multiout.dac_nids = spec->private_dac_nids;
  9133. for (i = 0; i < cfg->line_outs; i++) {
  9134. nid = cfg->line_out_pins[i];
  9135. if (nid) {
  9136. if (i >= ARRAY_SIZE(alc861_dac_nids))
  9137. continue;
  9138. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  9139. }
  9140. }
  9141. spec->multiout.num_dacs = cfg->line_outs;
  9142. return 0;
  9143. }
  9144. /* add playback controls from the parsed DAC table */
  9145. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  9146. const struct auto_pin_cfg *cfg)
  9147. {
  9148. char name[32];
  9149. static const char *chname[4] = {
  9150. "Front", "Surround", NULL /*CLFE*/, "Side"
  9151. };
  9152. hda_nid_t nid;
  9153. int i, idx, err;
  9154. for (i = 0; i < cfg->line_outs; i++) {
  9155. nid = spec->multiout.dac_nids[i];
  9156. if (!nid)
  9157. continue;
  9158. if (nid == 0x05) {
  9159. /* Center/LFE */
  9160. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9161. "Center Playback Switch",
  9162. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9163. HDA_OUTPUT));
  9164. if (err < 0)
  9165. return err;
  9166. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9167. "LFE Playback Switch",
  9168. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9169. HDA_OUTPUT));
  9170. if (err < 0)
  9171. return err;
  9172. } else {
  9173. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  9174. idx++)
  9175. if (nid == alc861_dac_nids[idx])
  9176. break;
  9177. sprintf(name, "%s Playback Switch", chname[idx]);
  9178. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9179. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9180. HDA_OUTPUT));
  9181. if (err < 0)
  9182. return err;
  9183. }
  9184. }
  9185. return 0;
  9186. }
  9187. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  9188. {
  9189. int err;
  9190. hda_nid_t nid;
  9191. if (!pin)
  9192. return 0;
  9193. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  9194. nid = 0x03;
  9195. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  9196. "Headphone Playback Switch",
  9197. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9198. if (err < 0)
  9199. return err;
  9200. spec->multiout.hp_nid = nid;
  9201. }
  9202. return 0;
  9203. }
  9204. /* create playback/capture controls for input pins */
  9205. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  9206. const struct auto_pin_cfg *cfg)
  9207. {
  9208. struct hda_input_mux *imux = &spec->private_imux;
  9209. int i, err, idx, idx1;
  9210. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9211. switch (cfg->input_pins[i]) {
  9212. case 0x0c:
  9213. idx1 = 1;
  9214. idx = 2; /* Line In */
  9215. break;
  9216. case 0x0f:
  9217. idx1 = 2;
  9218. idx = 2; /* Line In */
  9219. break;
  9220. case 0x0d:
  9221. idx1 = 0;
  9222. idx = 1; /* Mic In */
  9223. break;
  9224. case 0x10:
  9225. idx1 = 3;
  9226. idx = 1; /* Mic In */
  9227. break;
  9228. case 0x11:
  9229. idx1 = 4;
  9230. idx = 0; /* CD */
  9231. break;
  9232. default:
  9233. continue;
  9234. }
  9235. err = new_analog_input(spec, cfg->input_pins[i],
  9236. auto_pin_cfg_labels[i], idx, 0x15);
  9237. if (err < 0)
  9238. return err;
  9239. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  9240. imux->items[imux->num_items].index = idx1;
  9241. imux->num_items++;
  9242. }
  9243. return 0;
  9244. }
  9245. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  9246. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9247. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9248. {
  9249. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9250. /* The multiple "Capture Source" controls confuse alsamixer
  9251. * So call somewhat different..
  9252. *FIXME: the controls appear in the "playback" view!
  9253. */
  9254. /* .name = "Capture Source", */
  9255. .name = "Input Source",
  9256. .count = 1,
  9257. .info = alc_mux_enum_info,
  9258. .get = alc_mux_enum_get,
  9259. .put = alc_mux_enum_put,
  9260. },
  9261. { } /* end */
  9262. };
  9263. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  9264. hda_nid_t nid,
  9265. int pin_type, int dac_idx)
  9266. {
  9267. /* set as output */
  9268. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  9269. pin_type);
  9270. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9271. AMP_OUT_UNMUTE);
  9272. }
  9273. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  9274. {
  9275. struct alc_spec *spec = codec->spec;
  9276. int i;
  9277. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  9278. for (i = 0; i < spec->autocfg.line_outs; i++) {
  9279. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9280. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9281. if (nid)
  9282. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  9283. spec->multiout.dac_nids[i]);
  9284. }
  9285. }
  9286. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  9287. {
  9288. struct alc_spec *spec = codec->spec;
  9289. hda_nid_t pin;
  9290. pin = spec->autocfg.hp_pins[0];
  9291. if (pin) /* connect to front */
  9292. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  9293. spec->multiout.dac_nids[0]);
  9294. }
  9295. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  9296. {
  9297. struct alc_spec *spec = codec->spec;
  9298. int i;
  9299. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9300. hda_nid_t nid = spec->autocfg.input_pins[i];
  9301. if (nid >= 0x0c && nid <= 0x11) {
  9302. snd_hda_codec_write(codec, nid, 0,
  9303. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9304. i <= AUTO_PIN_FRONT_MIC ?
  9305. PIN_VREF80 : PIN_IN);
  9306. }
  9307. }
  9308. }
  9309. /* parse the BIOS configuration and set up the alc_spec */
  9310. /* return 1 if successful, 0 if the proper config is not found,
  9311. * or a negative error code
  9312. */
  9313. static int alc861_parse_auto_config(struct hda_codec *codec)
  9314. {
  9315. struct alc_spec *spec = codec->spec;
  9316. int err;
  9317. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  9318. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9319. alc861_ignore);
  9320. if (err < 0)
  9321. return err;
  9322. if (!spec->autocfg.line_outs)
  9323. return 0; /* can't find valid BIOS pin config */
  9324. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  9325. if (err < 0)
  9326. return err;
  9327. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9328. if (err < 0)
  9329. return err;
  9330. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  9331. if (err < 0)
  9332. return err;
  9333. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9334. if (err < 0)
  9335. return err;
  9336. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9337. if (spec->autocfg.dig_out_pin)
  9338. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  9339. if (spec->kctl_alloc)
  9340. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9341. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  9342. spec->num_mux_defs = 1;
  9343. spec->input_mux = &spec->private_imux;
  9344. spec->adc_nids = alc861_adc_nids;
  9345. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  9346. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  9347. spec->num_mixers++;
  9348. return 1;
  9349. }
  9350. /* additional initialization for auto-configuration model */
  9351. static void alc861_auto_init(struct hda_codec *codec)
  9352. {
  9353. alc861_auto_init_multi_out(codec);
  9354. alc861_auto_init_hp_out(codec);
  9355. alc861_auto_init_analog_input(codec);
  9356. }
  9357. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9358. static struct hda_amp_list alc861_loopbacks[] = {
  9359. { 0x15, HDA_INPUT, 0 },
  9360. { 0x15, HDA_INPUT, 1 },
  9361. { 0x15, HDA_INPUT, 2 },
  9362. { 0x15, HDA_INPUT, 3 },
  9363. { } /* end */
  9364. };
  9365. #endif
  9366. /*
  9367. * configuration and preset
  9368. */
  9369. static const char *alc861_models[ALC861_MODEL_LAST] = {
  9370. [ALC861_3ST] = "3stack",
  9371. [ALC660_3ST] = "3stack-660",
  9372. [ALC861_3ST_DIG] = "3stack-dig",
  9373. [ALC861_6ST_DIG] = "6stack-dig",
  9374. [ALC861_UNIWILL_M31] = "uniwill-m31",
  9375. [ALC861_TOSHIBA] = "toshiba",
  9376. [ALC861_ASUS] = "asus",
  9377. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  9378. [ALC861_AUTO] = "auto",
  9379. };
  9380. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  9381. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9382. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9383. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9384. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9385. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9386. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9387. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9388. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9389. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9390. * Any other models that need this preset?
  9391. */
  9392. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9393. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9394. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  9395. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9396. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9397. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9398. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9399. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9400. {}
  9401. };
  9402. static struct alc_config_preset alc861_presets[] = {
  9403. [ALC861_3ST] = {
  9404. .mixers = { alc861_3ST_mixer },
  9405. .init_verbs = { alc861_threestack_init_verbs },
  9406. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9407. .dac_nids = alc861_dac_nids,
  9408. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9409. .channel_mode = alc861_threestack_modes,
  9410. .need_dac_fix = 1,
  9411. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9412. .adc_nids = alc861_adc_nids,
  9413. .input_mux = &alc861_capture_source,
  9414. },
  9415. [ALC861_3ST_DIG] = {
  9416. .mixers = { alc861_base_mixer },
  9417. .init_verbs = { alc861_threestack_init_verbs },
  9418. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9419. .dac_nids = alc861_dac_nids,
  9420. .dig_out_nid = ALC861_DIGOUT_NID,
  9421. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9422. .channel_mode = alc861_threestack_modes,
  9423. .need_dac_fix = 1,
  9424. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9425. .adc_nids = alc861_adc_nids,
  9426. .input_mux = &alc861_capture_source,
  9427. },
  9428. [ALC861_6ST_DIG] = {
  9429. .mixers = { alc861_base_mixer },
  9430. .init_verbs = { alc861_base_init_verbs },
  9431. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9432. .dac_nids = alc861_dac_nids,
  9433. .dig_out_nid = ALC861_DIGOUT_NID,
  9434. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  9435. .channel_mode = alc861_8ch_modes,
  9436. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9437. .adc_nids = alc861_adc_nids,
  9438. .input_mux = &alc861_capture_source,
  9439. },
  9440. [ALC660_3ST] = {
  9441. .mixers = { alc861_3ST_mixer },
  9442. .init_verbs = { alc861_threestack_init_verbs },
  9443. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  9444. .dac_nids = alc660_dac_nids,
  9445. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9446. .channel_mode = alc861_threestack_modes,
  9447. .need_dac_fix = 1,
  9448. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9449. .adc_nids = alc861_adc_nids,
  9450. .input_mux = &alc861_capture_source,
  9451. },
  9452. [ALC861_UNIWILL_M31] = {
  9453. .mixers = { alc861_uniwill_m31_mixer },
  9454. .init_verbs = { alc861_uniwill_m31_init_verbs },
  9455. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9456. .dac_nids = alc861_dac_nids,
  9457. .dig_out_nid = ALC861_DIGOUT_NID,
  9458. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9459. .channel_mode = alc861_uniwill_m31_modes,
  9460. .need_dac_fix = 1,
  9461. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9462. .adc_nids = alc861_adc_nids,
  9463. .input_mux = &alc861_capture_source,
  9464. },
  9465. [ALC861_TOSHIBA] = {
  9466. .mixers = { alc861_toshiba_mixer },
  9467. .init_verbs = { alc861_base_init_verbs,
  9468. alc861_toshiba_init_verbs },
  9469. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9470. .dac_nids = alc861_dac_nids,
  9471. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9472. .channel_mode = alc883_3ST_2ch_modes,
  9473. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9474. .adc_nids = alc861_adc_nids,
  9475. .input_mux = &alc861_capture_source,
  9476. .unsol_event = alc861_toshiba_unsol_event,
  9477. .init_hook = alc861_toshiba_automute,
  9478. },
  9479. [ALC861_ASUS] = {
  9480. .mixers = { alc861_asus_mixer },
  9481. .init_verbs = { alc861_asus_init_verbs },
  9482. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9483. .dac_nids = alc861_dac_nids,
  9484. .dig_out_nid = ALC861_DIGOUT_NID,
  9485. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  9486. .channel_mode = alc861_asus_modes,
  9487. .need_dac_fix = 1,
  9488. .hp_nid = 0x06,
  9489. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9490. .adc_nids = alc861_adc_nids,
  9491. .input_mux = &alc861_capture_source,
  9492. },
  9493. [ALC861_ASUS_LAPTOP] = {
  9494. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  9495. .init_verbs = { alc861_asus_init_verbs,
  9496. alc861_asus_laptop_init_verbs },
  9497. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9498. .dac_nids = alc861_dac_nids,
  9499. .dig_out_nid = ALC861_DIGOUT_NID,
  9500. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9501. .channel_mode = alc883_3ST_2ch_modes,
  9502. .need_dac_fix = 1,
  9503. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9504. .adc_nids = alc861_adc_nids,
  9505. .input_mux = &alc861_capture_source,
  9506. },
  9507. };
  9508. static int patch_alc861(struct hda_codec *codec)
  9509. {
  9510. struct alc_spec *spec;
  9511. int board_config;
  9512. int err;
  9513. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9514. if (spec == NULL)
  9515. return -ENOMEM;
  9516. codec->spec = spec;
  9517. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9518. alc861_models,
  9519. alc861_cfg_tbl);
  9520. if (board_config < 0) {
  9521. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9522. "trying auto-probe from BIOS...\n");
  9523. board_config = ALC861_AUTO;
  9524. }
  9525. if (board_config == ALC861_AUTO) {
  9526. /* automatic parse from the BIOS config */
  9527. err = alc861_parse_auto_config(codec);
  9528. if (err < 0) {
  9529. alc_free(codec);
  9530. return err;
  9531. } else if (!err) {
  9532. printk(KERN_INFO
  9533. "hda_codec: Cannot set up configuration "
  9534. "from BIOS. Using base mode...\n");
  9535. board_config = ALC861_3ST_DIG;
  9536. }
  9537. }
  9538. if (board_config != ALC861_AUTO)
  9539. setup_preset(spec, &alc861_presets[board_config]);
  9540. spec->stream_name_analog = "ALC861 Analog";
  9541. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  9542. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  9543. spec->stream_name_digital = "ALC861 Digital";
  9544. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  9545. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  9546. codec->patch_ops = alc_patch_ops;
  9547. if (board_config == ALC861_AUTO)
  9548. spec->init_hook = alc861_auto_init;
  9549. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9550. if (!spec->loopback.amplist)
  9551. spec->loopback.amplist = alc861_loopbacks;
  9552. #endif
  9553. return 0;
  9554. }
  9555. /*
  9556. * ALC861-VD support
  9557. *
  9558. * Based on ALC882
  9559. *
  9560. * In addition, an independent DAC
  9561. */
  9562. #define ALC861VD_DIGOUT_NID 0x06
  9563. static hda_nid_t alc861vd_dac_nids[4] = {
  9564. /* front, surr, clfe, side surr */
  9565. 0x02, 0x03, 0x04, 0x05
  9566. };
  9567. /* dac_nids for ALC660vd are in a different order - according to
  9568. * Realtek's driver.
  9569. * This should probably tesult in a different mixer for 6stack models
  9570. * of ALC660vd codecs, but for now there is only 3stack mixer
  9571. * - and it is the same as in 861vd.
  9572. * adc_nids in ALC660vd are (is) the same as in 861vd
  9573. */
  9574. static hda_nid_t alc660vd_dac_nids[3] = {
  9575. /* front, rear, clfe, rear_surr */
  9576. 0x02, 0x04, 0x03
  9577. };
  9578. static hda_nid_t alc861vd_adc_nids[1] = {
  9579. /* ADC0 */
  9580. 0x09,
  9581. };
  9582. /* input MUX */
  9583. /* FIXME: should be a matrix-type input source selection */
  9584. static struct hda_input_mux alc861vd_capture_source = {
  9585. .num_items = 4,
  9586. .items = {
  9587. { "Mic", 0x0 },
  9588. { "Front Mic", 0x1 },
  9589. { "Line", 0x2 },
  9590. { "CD", 0x4 },
  9591. },
  9592. };
  9593. static struct hda_input_mux alc861vd_dallas_capture_source = {
  9594. .num_items = 3,
  9595. .items = {
  9596. { "Front Mic", 0x0 },
  9597. { "ATAPI Mic", 0x1 },
  9598. { "Line In", 0x5 },
  9599. },
  9600. };
  9601. static struct hda_input_mux alc861vd_hp_capture_source = {
  9602. .num_items = 2,
  9603. .items = {
  9604. { "Front Mic", 0x0 },
  9605. { "ATAPI Mic", 0x1 },
  9606. },
  9607. };
  9608. #define alc861vd_mux_enum_info alc_mux_enum_info
  9609. #define alc861vd_mux_enum_get alc_mux_enum_get
  9610. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  9611. struct snd_ctl_elem_value *ucontrol)
  9612. {
  9613. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9614. struct alc_spec *spec = codec->spec;
  9615. const struct hda_input_mux *imux = spec->input_mux;
  9616. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9617. static hda_nid_t capture_mixers[1] = { 0x22 };
  9618. hda_nid_t nid = capture_mixers[adc_idx];
  9619. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9620. unsigned int i, idx;
  9621. idx = ucontrol->value.enumerated.item[0];
  9622. if (idx >= imux->num_items)
  9623. idx = imux->num_items - 1;
  9624. if (*cur_val == idx)
  9625. return 0;
  9626. for (i = 0; i < imux->num_items; i++) {
  9627. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9628. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9629. imux->items[i].index,
  9630. HDA_AMP_MUTE, v);
  9631. }
  9632. *cur_val = idx;
  9633. return 1;
  9634. }
  9635. /*
  9636. * 2ch mode
  9637. */
  9638. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9639. { 2, NULL }
  9640. };
  9641. /*
  9642. * 6ch mode
  9643. */
  9644. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9645. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9646. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9647. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9648. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9649. { } /* end */
  9650. };
  9651. /*
  9652. * 8ch mode
  9653. */
  9654. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9655. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9656. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9657. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9658. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9659. { } /* end */
  9660. };
  9661. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9662. { 6, alc861vd_6stack_ch6_init },
  9663. { 8, alc861vd_6stack_ch8_init },
  9664. };
  9665. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9666. {
  9667. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9668. .name = "Channel Mode",
  9669. .info = alc_ch_mode_info,
  9670. .get = alc_ch_mode_get,
  9671. .put = alc_ch_mode_put,
  9672. },
  9673. { } /* end */
  9674. };
  9675. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9676. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9677. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9678. {
  9679. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9680. /* The multiple "Capture Source" controls confuse alsamixer
  9681. * So call somewhat different..
  9682. *FIXME: the controls appear in the "playback" view!
  9683. */
  9684. /* .name = "Capture Source", */
  9685. .name = "Input Source",
  9686. .count = 1,
  9687. .info = alc861vd_mux_enum_info,
  9688. .get = alc861vd_mux_enum_get,
  9689. .put = alc861vd_mux_enum_put,
  9690. },
  9691. { } /* end */
  9692. };
  9693. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9694. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9695. */
  9696. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9697. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9698. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9699. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9700. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9701. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9702. HDA_OUTPUT),
  9703. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9704. HDA_OUTPUT),
  9705. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9706. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9707. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9708. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9709. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9710. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9711. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9712. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9713. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9714. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9715. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9716. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9717. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9718. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9719. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9720. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9721. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9722. { } /* end */
  9723. };
  9724. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9725. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9726. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9727. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9728. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9729. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9730. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9731. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9732. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9733. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9734. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9735. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9736. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9737. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9738. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9739. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9740. { } /* end */
  9741. };
  9742. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9743. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9744. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9745. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9746. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9747. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9748. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9749. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9750. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9751. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9752. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9753. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9754. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9755. { } /* end */
  9756. };
  9757. /* Pin assignment: Front=0x14, HP = 0x15,
  9758. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9759. */
  9760. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9761. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9762. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9763. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9764. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9765. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9766. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9767. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9768. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9769. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9770. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9771. { } /* end */
  9772. };
  9773. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  9774. * Front Mic=0x18, ATAPI Mic = 0x19,
  9775. */
  9776. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  9777. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9778. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9779. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9780. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9781. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9782. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9783. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9784. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9785. { } /* end */
  9786. };
  9787. /*
  9788. * generic initialization of ADC, input mixers and output mixers
  9789. */
  9790. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9791. /*
  9792. * Unmute ADC0 and set the default input to mic-in
  9793. */
  9794. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9795. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9796. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9797. * the analog-loopback mixer widget
  9798. */
  9799. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9800. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9801. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9802. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9803. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9804. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9805. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9806. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9807. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9808. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9809. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9810. /*
  9811. * Set up output mixers (0x02 - 0x05)
  9812. */
  9813. /* set vol=0 to output mixers */
  9814. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9815. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9816. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9817. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9818. /* set up input amps for analog loopback */
  9819. /* Amp Indices: DAC = 0, mixer = 1 */
  9820. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9821. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9822. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9823. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9824. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9825. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9826. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9827. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9828. { }
  9829. };
  9830. /*
  9831. * 3-stack pin configuration:
  9832. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9833. */
  9834. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9835. /*
  9836. * Set pin mode and muting
  9837. */
  9838. /* set front pin widgets 0x14 for output */
  9839. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9840. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9841. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9842. /* Mic (rear) pin: input vref at 80% */
  9843. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9844. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9845. /* Front Mic pin: input vref at 80% */
  9846. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9847. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9848. /* Line In pin: input */
  9849. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9850. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9851. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9852. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9853. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9854. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9855. /* CD pin widget for input */
  9856. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9857. { }
  9858. };
  9859. /*
  9860. * 6-stack pin configuration:
  9861. */
  9862. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9863. /*
  9864. * Set pin mode and muting
  9865. */
  9866. /* set front pin widgets 0x14 for output */
  9867. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9868. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9869. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9870. /* Rear Pin: output 1 (0x0d) */
  9871. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9872. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9873. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9874. /* CLFE Pin: output 2 (0x0e) */
  9875. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9876. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9877. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9878. /* Side Pin: output 3 (0x0f) */
  9879. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9880. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9881. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9882. /* Mic (rear) pin: input vref at 80% */
  9883. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9884. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9885. /* Front Mic pin: input vref at 80% */
  9886. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9887. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9888. /* Line In pin: input */
  9889. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9890. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9891. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9892. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9893. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9894. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9895. /* CD pin widget for input */
  9896. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9897. { }
  9898. };
  9899. static struct hda_verb alc861vd_eapd_verbs[] = {
  9900. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9901. { }
  9902. };
  9903. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9904. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9905. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9906. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9907. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9908. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9909. {}
  9910. };
  9911. /* toggle speaker-output according to the hp-jack state */
  9912. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9913. {
  9914. unsigned int present;
  9915. unsigned char bits;
  9916. present = snd_hda_codec_read(codec, 0x1b, 0,
  9917. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9918. bits = present ? HDA_AMP_MUTE : 0;
  9919. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9920. HDA_AMP_MUTE, bits);
  9921. }
  9922. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9923. {
  9924. unsigned int present;
  9925. unsigned char bits;
  9926. present = snd_hda_codec_read(codec, 0x18, 0,
  9927. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9928. bits = present ? HDA_AMP_MUTE : 0;
  9929. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  9930. HDA_AMP_MUTE, bits);
  9931. }
  9932. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9933. {
  9934. alc861vd_lenovo_hp_automute(codec);
  9935. alc861vd_lenovo_mic_automute(codec);
  9936. }
  9937. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9938. unsigned int res)
  9939. {
  9940. switch (res >> 26) {
  9941. case ALC880_HP_EVENT:
  9942. alc861vd_lenovo_hp_automute(codec);
  9943. break;
  9944. case ALC880_MIC_EVENT:
  9945. alc861vd_lenovo_mic_automute(codec);
  9946. break;
  9947. }
  9948. }
  9949. static struct hda_verb alc861vd_dallas_verbs[] = {
  9950. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9951. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9952. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9953. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9954. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9955. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9956. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9957. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9958. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9959. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9960. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9961. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9962. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9963. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9964. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9965. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9966. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9967. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9968. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9969. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9970. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9971. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9972. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9973. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9974. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9975. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9976. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9977. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9978. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9979. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9980. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9981. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9982. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9983. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9984. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9985. { } /* end */
  9986. };
  9987. /* toggle speaker-output according to the hp-jack state */
  9988. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9989. {
  9990. unsigned int present;
  9991. present = snd_hda_codec_read(codec, 0x15, 0,
  9992. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9993. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9994. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9995. }
  9996. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9997. {
  9998. if ((res >> 26) == ALC880_HP_EVENT)
  9999. alc861vd_dallas_automute(codec);
  10000. }
  10001. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10002. #define alc861vd_loopbacks alc880_loopbacks
  10003. #endif
  10004. /* pcm configuration: identiacal with ALC880 */
  10005. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  10006. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  10007. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  10008. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  10009. /*
  10010. * configuration and preset
  10011. */
  10012. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  10013. [ALC660VD_3ST] = "3stack-660",
  10014. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  10015. [ALC861VD_3ST] = "3stack",
  10016. [ALC861VD_3ST_DIG] = "3stack-digout",
  10017. [ALC861VD_6ST_DIG] = "6stack-digout",
  10018. [ALC861VD_LENOVO] = "lenovo",
  10019. [ALC861VD_DALLAS] = "dallas",
  10020. [ALC861VD_HP] = "hp",
  10021. [ALC861VD_AUTO] = "auto",
  10022. };
  10023. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  10024. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  10025. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  10026. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  10027. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  10028. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  10029. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  10030. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  10031. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  10032. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  10033. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  10034. SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
  10035. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  10036. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  10037. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  10038. {}
  10039. };
  10040. static struct alc_config_preset alc861vd_presets[] = {
  10041. [ALC660VD_3ST] = {
  10042. .mixers = { alc861vd_3st_mixer },
  10043. .init_verbs = { alc861vd_volume_init_verbs,
  10044. alc861vd_3stack_init_verbs },
  10045. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10046. .dac_nids = alc660vd_dac_nids,
  10047. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10048. .adc_nids = alc861vd_adc_nids,
  10049. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10050. .channel_mode = alc861vd_3stack_2ch_modes,
  10051. .input_mux = &alc861vd_capture_source,
  10052. },
  10053. [ALC660VD_3ST_DIG] = {
  10054. .mixers = { alc861vd_3st_mixer },
  10055. .init_verbs = { alc861vd_volume_init_verbs,
  10056. alc861vd_3stack_init_verbs },
  10057. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10058. .dac_nids = alc660vd_dac_nids,
  10059. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10060. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10061. .adc_nids = alc861vd_adc_nids,
  10062. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10063. .channel_mode = alc861vd_3stack_2ch_modes,
  10064. .input_mux = &alc861vd_capture_source,
  10065. },
  10066. [ALC861VD_3ST] = {
  10067. .mixers = { alc861vd_3st_mixer },
  10068. .init_verbs = { alc861vd_volume_init_verbs,
  10069. alc861vd_3stack_init_verbs },
  10070. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10071. .dac_nids = alc861vd_dac_nids,
  10072. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10073. .channel_mode = alc861vd_3stack_2ch_modes,
  10074. .input_mux = &alc861vd_capture_source,
  10075. },
  10076. [ALC861VD_3ST_DIG] = {
  10077. .mixers = { alc861vd_3st_mixer },
  10078. .init_verbs = { alc861vd_volume_init_verbs,
  10079. alc861vd_3stack_init_verbs },
  10080. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10081. .dac_nids = alc861vd_dac_nids,
  10082. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10083. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10084. .channel_mode = alc861vd_3stack_2ch_modes,
  10085. .input_mux = &alc861vd_capture_source,
  10086. },
  10087. [ALC861VD_6ST_DIG] = {
  10088. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  10089. .init_verbs = { alc861vd_volume_init_verbs,
  10090. alc861vd_6stack_init_verbs },
  10091. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10092. .dac_nids = alc861vd_dac_nids,
  10093. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10094. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  10095. .channel_mode = alc861vd_6stack_modes,
  10096. .input_mux = &alc861vd_capture_source,
  10097. },
  10098. [ALC861VD_LENOVO] = {
  10099. .mixers = { alc861vd_lenovo_mixer },
  10100. .init_verbs = { alc861vd_volume_init_verbs,
  10101. alc861vd_3stack_init_verbs,
  10102. alc861vd_eapd_verbs,
  10103. alc861vd_lenovo_unsol_verbs },
  10104. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10105. .dac_nids = alc660vd_dac_nids,
  10106. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10107. .adc_nids = alc861vd_adc_nids,
  10108. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10109. .channel_mode = alc861vd_3stack_2ch_modes,
  10110. .input_mux = &alc861vd_capture_source,
  10111. .unsol_event = alc861vd_lenovo_unsol_event,
  10112. .init_hook = alc861vd_lenovo_automute,
  10113. },
  10114. [ALC861VD_DALLAS] = {
  10115. .mixers = { alc861vd_dallas_mixer },
  10116. .init_verbs = { alc861vd_dallas_verbs },
  10117. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10118. .dac_nids = alc861vd_dac_nids,
  10119. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10120. .adc_nids = alc861vd_adc_nids,
  10121. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10122. .channel_mode = alc861vd_3stack_2ch_modes,
  10123. .input_mux = &alc861vd_dallas_capture_source,
  10124. .unsol_event = alc861vd_dallas_unsol_event,
  10125. .init_hook = alc861vd_dallas_automute,
  10126. },
  10127. [ALC861VD_HP] = {
  10128. .mixers = { alc861vd_hp_mixer },
  10129. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  10130. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10131. .dac_nids = alc861vd_dac_nids,
  10132. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10133. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10134. .adc_nids = alc861vd_adc_nids,
  10135. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10136. .channel_mode = alc861vd_3stack_2ch_modes,
  10137. .input_mux = &alc861vd_hp_capture_source,
  10138. .unsol_event = alc861vd_dallas_unsol_event,
  10139. .init_hook = alc861vd_dallas_automute,
  10140. },
  10141. };
  10142. /*
  10143. * BIOS auto configuration
  10144. */
  10145. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  10146. hda_nid_t nid, int pin_type, int dac_idx)
  10147. {
  10148. /* set as output */
  10149. snd_hda_codec_write(codec, nid, 0,
  10150. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10151. snd_hda_codec_write(codec, nid, 0,
  10152. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10153. }
  10154. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  10155. {
  10156. struct alc_spec *spec = codec->spec;
  10157. int i;
  10158. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  10159. for (i = 0; i <= HDA_SIDE; i++) {
  10160. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10161. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10162. if (nid)
  10163. alc861vd_auto_set_output_and_unmute(codec, nid,
  10164. pin_type, i);
  10165. }
  10166. }
  10167. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  10168. {
  10169. struct alc_spec *spec = codec->spec;
  10170. hda_nid_t pin;
  10171. pin = spec->autocfg.hp_pins[0];
  10172. if (pin) /* connect to front and use dac 0 */
  10173. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10174. }
  10175. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  10176. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  10177. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  10178. {
  10179. struct alc_spec *spec = codec->spec;
  10180. int i;
  10181. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10182. hda_nid_t nid = spec->autocfg.input_pins[i];
  10183. if (alc861vd_is_input_pin(nid)) {
  10184. snd_hda_codec_write(codec, nid, 0,
  10185. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10186. i <= AUTO_PIN_FRONT_MIC ?
  10187. PIN_VREF80 : PIN_IN);
  10188. if (nid != ALC861VD_PIN_CD_NID)
  10189. snd_hda_codec_write(codec, nid, 0,
  10190. AC_VERB_SET_AMP_GAIN_MUTE,
  10191. AMP_OUT_MUTE);
  10192. }
  10193. }
  10194. }
  10195. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  10196. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  10197. /* add playback controls from the parsed DAC table */
  10198. /* Based on ALC880 version. But ALC861VD has separate,
  10199. * different NIDs for mute/unmute switch and volume control */
  10200. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  10201. const struct auto_pin_cfg *cfg)
  10202. {
  10203. char name[32];
  10204. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  10205. hda_nid_t nid_v, nid_s;
  10206. int i, err;
  10207. for (i = 0; i < cfg->line_outs; i++) {
  10208. if (!spec->multiout.dac_nids[i])
  10209. continue;
  10210. nid_v = alc861vd_idx_to_mixer_vol(
  10211. alc880_dac_to_idx(
  10212. spec->multiout.dac_nids[i]));
  10213. nid_s = alc861vd_idx_to_mixer_switch(
  10214. alc880_dac_to_idx(
  10215. spec->multiout.dac_nids[i]));
  10216. if (i == 2) {
  10217. /* Center/LFE */
  10218. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10219. "Center Playback Volume",
  10220. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  10221. HDA_OUTPUT));
  10222. if (err < 0)
  10223. return err;
  10224. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10225. "LFE Playback Volume",
  10226. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  10227. HDA_OUTPUT));
  10228. if (err < 0)
  10229. return err;
  10230. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10231. "Center Playback Switch",
  10232. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  10233. HDA_INPUT));
  10234. if (err < 0)
  10235. return err;
  10236. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10237. "LFE Playback Switch",
  10238. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  10239. HDA_INPUT));
  10240. if (err < 0)
  10241. return err;
  10242. } else {
  10243. sprintf(name, "%s Playback Volume", chname[i]);
  10244. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10245. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  10246. HDA_OUTPUT));
  10247. if (err < 0)
  10248. return err;
  10249. sprintf(name, "%s Playback Switch", chname[i]);
  10250. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10251. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  10252. HDA_INPUT));
  10253. if (err < 0)
  10254. return err;
  10255. }
  10256. }
  10257. return 0;
  10258. }
  10259. /* add playback controls for speaker and HP outputs */
  10260. /* Based on ALC880 version. But ALC861VD has separate,
  10261. * different NIDs for mute/unmute switch and volume control */
  10262. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  10263. hda_nid_t pin, const char *pfx)
  10264. {
  10265. hda_nid_t nid_v, nid_s;
  10266. int err;
  10267. char name[32];
  10268. if (!pin)
  10269. return 0;
  10270. if (alc880_is_fixed_pin(pin)) {
  10271. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10272. /* specify the DAC as the extra output */
  10273. if (!spec->multiout.hp_nid)
  10274. spec->multiout.hp_nid = nid_v;
  10275. else
  10276. spec->multiout.extra_out_nid[0] = nid_v;
  10277. /* control HP volume/switch on the output mixer amp */
  10278. nid_v = alc861vd_idx_to_mixer_vol(
  10279. alc880_fixed_pin_idx(pin));
  10280. nid_s = alc861vd_idx_to_mixer_switch(
  10281. alc880_fixed_pin_idx(pin));
  10282. sprintf(name, "%s Playback Volume", pfx);
  10283. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10284. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  10285. if (err < 0)
  10286. return err;
  10287. sprintf(name, "%s Playback Switch", pfx);
  10288. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10289. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  10290. if (err < 0)
  10291. return err;
  10292. } else if (alc880_is_multi_pin(pin)) {
  10293. /* set manual connection */
  10294. /* we have only a switch on HP-out PIN */
  10295. sprintf(name, "%s Playback Switch", pfx);
  10296. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10297. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10298. if (err < 0)
  10299. return err;
  10300. }
  10301. return 0;
  10302. }
  10303. /* parse the BIOS configuration and set up the alc_spec
  10304. * return 1 if successful, 0 if the proper config is not found,
  10305. * or a negative error code
  10306. * Based on ALC880 version - had to change it to override
  10307. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  10308. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  10309. {
  10310. struct alc_spec *spec = codec->spec;
  10311. int err;
  10312. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  10313. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10314. alc861vd_ignore);
  10315. if (err < 0)
  10316. return err;
  10317. if (!spec->autocfg.line_outs)
  10318. return 0; /* can't find valid BIOS pin config */
  10319. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10320. if (err < 0)
  10321. return err;
  10322. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10323. if (err < 0)
  10324. return err;
  10325. err = alc861vd_auto_create_extra_out(spec,
  10326. spec->autocfg.speaker_pins[0],
  10327. "Speaker");
  10328. if (err < 0)
  10329. return err;
  10330. err = alc861vd_auto_create_extra_out(spec,
  10331. spec->autocfg.hp_pins[0],
  10332. "Headphone");
  10333. if (err < 0)
  10334. return err;
  10335. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10336. if (err < 0)
  10337. return err;
  10338. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10339. if (spec->autocfg.dig_out_pin)
  10340. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  10341. if (spec->kctl_alloc)
  10342. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10343. spec->init_verbs[spec->num_init_verbs++]
  10344. = alc861vd_volume_init_verbs;
  10345. spec->num_mux_defs = 1;
  10346. spec->input_mux = &spec->private_imux;
  10347. err = alc_auto_add_mic_boost(codec);
  10348. if (err < 0)
  10349. return err;
  10350. return 1;
  10351. }
  10352. /* additional initialization for auto-configuration model */
  10353. static void alc861vd_auto_init(struct hda_codec *codec)
  10354. {
  10355. alc861vd_auto_init_multi_out(codec);
  10356. alc861vd_auto_init_hp_out(codec);
  10357. alc861vd_auto_init_analog_input(codec);
  10358. }
  10359. static int patch_alc861vd(struct hda_codec *codec)
  10360. {
  10361. struct alc_spec *spec;
  10362. int err, board_config;
  10363. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10364. if (spec == NULL)
  10365. return -ENOMEM;
  10366. codec->spec = spec;
  10367. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  10368. alc861vd_models,
  10369. alc861vd_cfg_tbl);
  10370. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  10371. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  10372. "ALC861VD, trying auto-probe from BIOS...\n");
  10373. board_config = ALC861VD_AUTO;
  10374. }
  10375. if (board_config == ALC861VD_AUTO) {
  10376. /* automatic parse from the BIOS config */
  10377. err = alc861vd_parse_auto_config(codec);
  10378. if (err < 0) {
  10379. alc_free(codec);
  10380. return err;
  10381. } else if (!err) {
  10382. printk(KERN_INFO
  10383. "hda_codec: Cannot set up configuration "
  10384. "from BIOS. Using base mode...\n");
  10385. board_config = ALC861VD_3ST;
  10386. }
  10387. }
  10388. if (board_config != ALC861VD_AUTO)
  10389. setup_preset(spec, &alc861vd_presets[board_config]);
  10390. spec->stream_name_analog = "ALC861VD Analog";
  10391. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10392. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10393. spec->stream_name_digital = "ALC861VD Digital";
  10394. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10395. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10396. spec->adc_nids = alc861vd_adc_nids;
  10397. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10398. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10399. spec->num_mixers++;
  10400. codec->patch_ops = alc_patch_ops;
  10401. if (board_config == ALC861VD_AUTO)
  10402. spec->init_hook = alc861vd_auto_init;
  10403. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10404. if (!spec->loopback.amplist)
  10405. spec->loopback.amplist = alc861vd_loopbacks;
  10406. #endif
  10407. return 0;
  10408. }
  10409. /*
  10410. * ALC662 support
  10411. *
  10412. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  10413. * configuration. Each pin widget can choose any input DACs and a mixer.
  10414. * Each ADC is connected from a mixer of all inputs. This makes possible
  10415. * 6-channel independent captures.
  10416. *
  10417. * In addition, an independent DAC for the multi-playback (not used in this
  10418. * driver yet).
  10419. */
  10420. #define ALC662_DIGOUT_NID 0x06
  10421. #define ALC662_DIGIN_NID 0x0a
  10422. static hda_nid_t alc662_dac_nids[4] = {
  10423. /* front, rear, clfe, rear_surr */
  10424. 0x02, 0x03, 0x04
  10425. };
  10426. static hda_nid_t alc662_adc_nids[1] = {
  10427. /* ADC1-2 */
  10428. 0x09,
  10429. };
  10430. /* input MUX */
  10431. /* FIXME: should be a matrix-type input source selection */
  10432. static struct hda_input_mux alc662_capture_source = {
  10433. .num_items = 4,
  10434. .items = {
  10435. { "Mic", 0x0 },
  10436. { "Front Mic", 0x1 },
  10437. { "Line", 0x2 },
  10438. { "CD", 0x4 },
  10439. },
  10440. };
  10441. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  10442. .num_items = 2,
  10443. .items = {
  10444. { "Mic", 0x1 },
  10445. { "Line", 0x2 },
  10446. },
  10447. };
  10448. static struct hda_input_mux alc662_eeepc_capture_source = {
  10449. .num_items = 2,
  10450. .items = {
  10451. { "i-Mic", 0x1 },
  10452. { "e-Mic", 0x0 },
  10453. },
  10454. };
  10455. #define alc662_mux_enum_info alc_mux_enum_info
  10456. #define alc662_mux_enum_get alc_mux_enum_get
  10457. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  10458. struct snd_ctl_elem_value *ucontrol)
  10459. {
  10460. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10461. struct alc_spec *spec = codec->spec;
  10462. const struct hda_input_mux *imux = spec->input_mux;
  10463. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10464. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  10465. hda_nid_t nid = capture_mixers[adc_idx];
  10466. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10467. unsigned int i, idx;
  10468. idx = ucontrol->value.enumerated.item[0];
  10469. if (idx >= imux->num_items)
  10470. idx = imux->num_items - 1;
  10471. if (*cur_val == idx)
  10472. return 0;
  10473. for (i = 0; i < imux->num_items; i++) {
  10474. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10475. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10476. imux->items[i].index,
  10477. HDA_AMP_MUTE, v);
  10478. }
  10479. *cur_val = idx;
  10480. return 1;
  10481. }
  10482. /*
  10483. * 2ch mode
  10484. */
  10485. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  10486. { 2, NULL }
  10487. };
  10488. /*
  10489. * 2ch mode
  10490. */
  10491. static struct hda_verb alc662_3ST_ch2_init[] = {
  10492. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  10493. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10494. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  10495. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10496. { } /* end */
  10497. };
  10498. /*
  10499. * 6ch mode
  10500. */
  10501. static struct hda_verb alc662_3ST_ch6_init[] = {
  10502. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10503. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10504. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  10505. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10506. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10507. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  10508. { } /* end */
  10509. };
  10510. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  10511. { 2, alc662_3ST_ch2_init },
  10512. { 6, alc662_3ST_ch6_init },
  10513. };
  10514. /*
  10515. * 2ch mode
  10516. */
  10517. static struct hda_verb alc662_sixstack_ch6_init[] = {
  10518. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10519. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10520. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10521. { } /* end */
  10522. };
  10523. /*
  10524. * 6ch mode
  10525. */
  10526. static struct hda_verb alc662_sixstack_ch8_init[] = {
  10527. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10528. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10529. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10530. { } /* end */
  10531. };
  10532. static struct hda_channel_mode alc662_5stack_modes[2] = {
  10533. { 2, alc662_sixstack_ch6_init },
  10534. { 6, alc662_sixstack_ch8_init },
  10535. };
  10536. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10537. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10538. */
  10539. static struct snd_kcontrol_new alc662_base_mixer[] = {
  10540. /* output mixer control */
  10541. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  10542. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  10543. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  10544. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  10545. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10546. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10547. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10548. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10549. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10550. /*Input mixer control */
  10551. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  10552. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  10553. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  10554. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  10555. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  10556. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  10557. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  10558. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  10559. /* Capture mixer control */
  10560. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10561. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10562. {
  10563. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10564. .name = "Capture Source",
  10565. .count = 1,
  10566. .info = alc_mux_enum_info,
  10567. .get = alc_mux_enum_get,
  10568. .put = alc_mux_enum_put,
  10569. },
  10570. { } /* end */
  10571. };
  10572. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  10573. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10574. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10575. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10576. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10577. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10578. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10579. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10580. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10581. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10582. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10583. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10584. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10585. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10586. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10587. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10588. {
  10589. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10590. /* .name = "Capture Source", */
  10591. .name = "Input Source",
  10592. .count = 1,
  10593. .info = alc662_mux_enum_info,
  10594. .get = alc662_mux_enum_get,
  10595. .put = alc662_mux_enum_put,
  10596. },
  10597. { } /* end */
  10598. };
  10599. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  10600. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10601. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10602. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10603. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  10604. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10605. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10606. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10607. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10608. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10609. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10610. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10611. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10612. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10613. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10614. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10615. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10616. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10617. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10618. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10619. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10620. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10621. {
  10622. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10623. /* .name = "Capture Source", */
  10624. .name = "Input Source",
  10625. .count = 1,
  10626. .info = alc662_mux_enum_info,
  10627. .get = alc662_mux_enum_get,
  10628. .put = alc662_mux_enum_put,
  10629. },
  10630. { } /* end */
  10631. };
  10632. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  10633. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10634. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10635. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10636. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  10637. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10638. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10639. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10640. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10641. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10642. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10643. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10644. {
  10645. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10646. /* .name = "Capture Source", */
  10647. .name = "Input Source",
  10648. .count = 1,
  10649. .info = alc662_mux_enum_info,
  10650. .get = alc662_mux_enum_get,
  10651. .put = alc662_mux_enum_put,
  10652. },
  10653. { } /* end */
  10654. };
  10655. static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
  10656. HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  10657. HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10658. HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10659. HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
  10660. HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10661. HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10662. HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
  10663. HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10664. HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10665. { } /* end */
  10666. };
  10667. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  10668. {
  10669. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10670. .name = "Channel Mode",
  10671. .info = alc_ch_mode_info,
  10672. .get = alc_ch_mode_get,
  10673. .put = alc_ch_mode_put,
  10674. },
  10675. { } /* end */
  10676. };
  10677. static struct hda_verb alc662_init_verbs[] = {
  10678. /* ADC: mute amp left and right */
  10679. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10680. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10681. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10682. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10683. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10684. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10685. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10686. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10687. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10688. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10689. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10690. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10691. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10692. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10693. /* Front Pin: output 0 (0x0c) */
  10694. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10695. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10696. /* Rear Pin: output 1 (0x0d) */
  10697. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10698. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10699. /* CLFE Pin: output 2 (0x0e) */
  10700. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10701. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10702. /* Mic (rear) pin: input vref at 80% */
  10703. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10704. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10705. /* Front Mic pin: input vref at 80% */
  10706. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10707. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10708. /* Line In pin: input */
  10709. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10710. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10711. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10712. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10713. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10714. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10715. /* CD pin widget for input */
  10716. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10717. /* FIXME: use matrix-type input source selection */
  10718. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10719. /* Input mixer */
  10720. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10721. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10722. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10723. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10724. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10725. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10726. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10727. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10728. { }
  10729. };
  10730. static struct hda_verb alc662_sue_init_verbs[] = {
  10731. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10732. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10733. {}
  10734. };
  10735. static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
  10736. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  10737. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  10738. {}
  10739. };
  10740. /*
  10741. * generic initialization of ADC, input mixers and output mixers
  10742. */
  10743. static struct hda_verb alc662_auto_init_verbs[] = {
  10744. /*
  10745. * Unmute ADC and set the default input to mic-in
  10746. */
  10747. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10748. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10749. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10750. * mixer widget
  10751. * Note: PASD motherboards uses the Line In 2 as the input for front
  10752. * panel mic (mic 2)
  10753. */
  10754. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10755. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10756. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10757. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10758. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10759. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10760. /*
  10761. * Set up output mixers (0x0c - 0x0f)
  10762. */
  10763. /* set vol=0 to output mixers */
  10764. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10765. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10766. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10767. /* set up input amps for analog loopback */
  10768. /* Amp Indices: DAC = 0, mixer = 1 */
  10769. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10770. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10771. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10772. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10773. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10774. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10775. /* FIXME: use matrix-type input source selection */
  10776. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10777. /* Input mixer */
  10778. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10779. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10780. { }
  10781. };
  10782. /* capture mixer elements */
  10783. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10784. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10785. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10786. {
  10787. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10788. /* The multiple "Capture Source" controls confuse alsamixer
  10789. * So call somewhat different..
  10790. * FIXME: the controls appear in the "playback" view!
  10791. */
  10792. /* .name = "Capture Source", */
  10793. .name = "Input Source",
  10794. .count = 1,
  10795. .info = alc882_mux_enum_info,
  10796. .get = alc882_mux_enum_get,
  10797. .put = alc882_mux_enum_put,
  10798. },
  10799. { } /* end */
  10800. };
  10801. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10802. {
  10803. unsigned int present;
  10804. unsigned char bits;
  10805. present = snd_hda_codec_read(codec, 0x14, 0,
  10806. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10807. bits = present ? HDA_AMP_MUTE : 0;
  10808. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10809. HDA_AMP_MUTE, bits);
  10810. }
  10811. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10812. {
  10813. unsigned int present;
  10814. unsigned char bits;
  10815. present = snd_hda_codec_read(codec, 0x1b, 0,
  10816. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10817. bits = present ? HDA_AMP_MUTE : 0;
  10818. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10819. HDA_AMP_MUTE, bits);
  10820. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10821. HDA_AMP_MUTE, bits);
  10822. }
  10823. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10824. unsigned int res)
  10825. {
  10826. if ((res >> 26) == ALC880_HP_EVENT)
  10827. alc662_lenovo_101e_all_automute(codec);
  10828. if ((res >> 26) == ALC880_FRONT_EVENT)
  10829. alc662_lenovo_101e_ispeaker_automute(codec);
  10830. }
  10831. static void alc662_eeepc_mic_automute(struct hda_codec *codec)
  10832. {
  10833. unsigned int present;
  10834. present = snd_hda_codec_read(codec, 0x18, 0,
  10835. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10836. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10837. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  10838. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10839. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  10840. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10841. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  10842. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10843. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  10844. }
  10845. /* unsolicited event for HP jack sensing */
  10846. static void alc662_eeepc_unsol_event(struct hda_codec *codec,
  10847. unsigned int res)
  10848. {
  10849. if ((res >> 26) == ALC880_HP_EVENT)
  10850. alc262_hippo1_automute( codec );
  10851. if ((res >> 26) == ALC880_MIC_EVENT)
  10852. alc662_eeepc_mic_automute(codec);
  10853. }
  10854. static void alc662_eeepc_inithook(struct hda_codec *codec)
  10855. {
  10856. alc262_hippo1_automute( codec );
  10857. alc662_eeepc_mic_automute(codec);
  10858. }
  10859. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10860. #define alc662_loopbacks alc880_loopbacks
  10861. #endif
  10862. /* pcm configuration: identiacal with ALC880 */
  10863. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10864. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10865. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10866. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10867. /*
  10868. * configuration and preset
  10869. */
  10870. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10871. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10872. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10873. [ALC662_3ST_6ch] = "3stack-6ch",
  10874. [ALC662_5ST_DIG] = "6stack-dig",
  10875. [ALC662_LENOVO_101E] = "lenovo-101e",
  10876. [ALC662_AUTO] = "auto",
  10877. };
  10878. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10879. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10880. SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
  10881. {}
  10882. };
  10883. static struct alc_config_preset alc662_presets[] = {
  10884. [ALC662_3ST_2ch_DIG] = {
  10885. .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
  10886. .init_verbs = { alc662_init_verbs },
  10887. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10888. .dac_nids = alc662_dac_nids,
  10889. .dig_out_nid = ALC662_DIGOUT_NID,
  10890. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10891. .adc_nids = alc662_adc_nids,
  10892. .dig_in_nid = ALC662_DIGIN_NID,
  10893. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10894. .channel_mode = alc662_3ST_2ch_modes,
  10895. .input_mux = &alc662_capture_source,
  10896. },
  10897. [ALC662_3ST_6ch_DIG] = {
  10898. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  10899. alc662_capture_mixer },
  10900. .init_verbs = { alc662_init_verbs },
  10901. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10902. .dac_nids = alc662_dac_nids,
  10903. .dig_out_nid = ALC662_DIGOUT_NID,
  10904. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10905. .adc_nids = alc662_adc_nids,
  10906. .dig_in_nid = ALC662_DIGIN_NID,
  10907. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10908. .channel_mode = alc662_3ST_6ch_modes,
  10909. .need_dac_fix = 1,
  10910. .input_mux = &alc662_capture_source,
  10911. },
  10912. [ALC662_3ST_6ch] = {
  10913. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  10914. alc662_capture_mixer },
  10915. .init_verbs = { alc662_init_verbs },
  10916. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10917. .dac_nids = alc662_dac_nids,
  10918. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10919. .adc_nids = alc662_adc_nids,
  10920. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10921. .channel_mode = alc662_3ST_6ch_modes,
  10922. .need_dac_fix = 1,
  10923. .input_mux = &alc662_capture_source,
  10924. },
  10925. [ALC662_5ST_DIG] = {
  10926. .mixers = { alc662_base_mixer, alc662_chmode_mixer,
  10927. alc662_capture_mixer },
  10928. .init_verbs = { alc662_init_verbs },
  10929. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10930. .dac_nids = alc662_dac_nids,
  10931. .dig_out_nid = ALC662_DIGOUT_NID,
  10932. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10933. .adc_nids = alc662_adc_nids,
  10934. .dig_in_nid = ALC662_DIGIN_NID,
  10935. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10936. .channel_mode = alc662_5stack_modes,
  10937. .input_mux = &alc662_capture_source,
  10938. },
  10939. [ALC662_LENOVO_101E] = {
  10940. .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
  10941. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10942. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10943. .dac_nids = alc662_dac_nids,
  10944. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10945. .adc_nids = alc662_adc_nids,
  10946. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10947. .channel_mode = alc662_3ST_2ch_modes,
  10948. .input_mux = &alc662_lenovo_101e_capture_source,
  10949. .unsol_event = alc662_lenovo_101e_unsol_event,
  10950. .init_hook = alc662_lenovo_101e_all_automute,
  10951. },
  10952. [ALC662_ASUS_EEEPC_P701] = {
  10953. .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
  10954. .init_verbs = { alc662_init_verbs,
  10955. alc662_eeepc_sue_init_verbs },
  10956. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10957. .dac_nids = alc662_dac_nids,
  10958. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10959. .adc_nids = alc662_adc_nids,
  10960. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10961. .channel_mode = alc662_3ST_2ch_modes,
  10962. .input_mux = &alc662_eeepc_capture_source,
  10963. .unsol_event = alc662_eeepc_unsol_event,
  10964. .init_hook = alc662_eeepc_inithook,
  10965. },
  10966. };
  10967. /*
  10968. * BIOS auto configuration
  10969. */
  10970. /* add playback controls from the parsed DAC table */
  10971. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10972. const struct auto_pin_cfg *cfg)
  10973. {
  10974. char name[32];
  10975. static const char *chname[4] = {
  10976. "Front", "Surround", NULL /*CLFE*/, "Side"
  10977. };
  10978. hda_nid_t nid;
  10979. int i, err;
  10980. for (i = 0; i < cfg->line_outs; i++) {
  10981. if (!spec->multiout.dac_nids[i])
  10982. continue;
  10983. nid = alc880_idx_to_dac(i);
  10984. if (i == 2) {
  10985. /* Center/LFE */
  10986. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10987. "Center Playback Volume",
  10988. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10989. HDA_OUTPUT));
  10990. if (err < 0)
  10991. return err;
  10992. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10993. "LFE Playback Volume",
  10994. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10995. HDA_OUTPUT));
  10996. if (err < 0)
  10997. return err;
  10998. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10999. "Center Playback Switch",
  11000. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  11001. HDA_INPUT));
  11002. if (err < 0)
  11003. return err;
  11004. err = add_control(spec, ALC_CTL_BIND_MUTE,
  11005. "LFE Playback Switch",
  11006. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  11007. HDA_INPUT));
  11008. if (err < 0)
  11009. return err;
  11010. } else {
  11011. sprintf(name, "%s Playback Volume", chname[i]);
  11012. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  11013. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  11014. HDA_OUTPUT));
  11015. if (err < 0)
  11016. return err;
  11017. sprintf(name, "%s Playback Switch", chname[i]);
  11018. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  11019. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  11020. HDA_INPUT));
  11021. if (err < 0)
  11022. return err;
  11023. }
  11024. }
  11025. return 0;
  11026. }
  11027. /* add playback controls for speaker and HP outputs */
  11028. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  11029. const char *pfx)
  11030. {
  11031. hda_nid_t nid;
  11032. int err;
  11033. char name[32];
  11034. if (!pin)
  11035. return 0;
  11036. if (alc880_is_fixed_pin(pin)) {
  11037. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  11038. /* printk("DAC nid=%x\n",nid); */
  11039. /* specify the DAC as the extra output */
  11040. if (!spec->multiout.hp_nid)
  11041. spec->multiout.hp_nid = nid;
  11042. else
  11043. spec->multiout.extra_out_nid[0] = nid;
  11044. /* control HP volume/switch on the output mixer amp */
  11045. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  11046. sprintf(name, "%s Playback Volume", pfx);
  11047. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  11048. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  11049. if (err < 0)
  11050. return err;
  11051. sprintf(name, "%s Playback Switch", pfx);
  11052. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  11053. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  11054. if (err < 0)
  11055. return err;
  11056. } else if (alc880_is_multi_pin(pin)) {
  11057. /* set manual connection */
  11058. /* we have only a switch on HP-out PIN */
  11059. sprintf(name, "%s Playback Switch", pfx);
  11060. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  11061. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  11062. if (err < 0)
  11063. return err;
  11064. }
  11065. return 0;
  11066. }
  11067. /* create playback/capture controls for input pins */
  11068. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  11069. const struct auto_pin_cfg *cfg)
  11070. {
  11071. struct hda_input_mux *imux = &spec->private_imux;
  11072. int i, err, idx;
  11073. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11074. if (alc880_is_input_pin(cfg->input_pins[i])) {
  11075. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  11076. err = new_analog_input(spec, cfg->input_pins[i],
  11077. auto_pin_cfg_labels[i],
  11078. idx, 0x0b);
  11079. if (err < 0)
  11080. return err;
  11081. imux->items[imux->num_items].label =
  11082. auto_pin_cfg_labels[i];
  11083. imux->items[imux->num_items].index =
  11084. alc880_input_pin_idx(cfg->input_pins[i]);
  11085. imux->num_items++;
  11086. }
  11087. }
  11088. return 0;
  11089. }
  11090. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  11091. hda_nid_t nid, int pin_type,
  11092. int dac_idx)
  11093. {
  11094. /* set as output */
  11095. snd_hda_codec_write(codec, nid, 0,
  11096. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  11097. snd_hda_codec_write(codec, nid, 0,
  11098. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  11099. /* need the manual connection? */
  11100. if (alc880_is_multi_pin(nid)) {
  11101. struct alc_spec *spec = codec->spec;
  11102. int idx = alc880_multi_pin_idx(nid);
  11103. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  11104. AC_VERB_SET_CONNECT_SEL,
  11105. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  11106. }
  11107. }
  11108. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  11109. {
  11110. struct alc_spec *spec = codec->spec;
  11111. int i;
  11112. for (i = 0; i <= HDA_SIDE; i++) {
  11113. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  11114. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  11115. if (nid)
  11116. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  11117. i);
  11118. }
  11119. }
  11120. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  11121. {
  11122. struct alc_spec *spec = codec->spec;
  11123. hda_nid_t pin;
  11124. pin = spec->autocfg.hp_pins[0];
  11125. if (pin) /* connect to front */
  11126. /* use dac 0 */
  11127. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  11128. }
  11129. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  11130. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  11131. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  11132. {
  11133. struct alc_spec *spec = codec->spec;
  11134. int i;
  11135. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11136. hda_nid_t nid = spec->autocfg.input_pins[i];
  11137. if (alc662_is_input_pin(nid)) {
  11138. snd_hda_codec_write(codec, nid, 0,
  11139. AC_VERB_SET_PIN_WIDGET_CONTROL,
  11140. (i <= AUTO_PIN_FRONT_MIC ?
  11141. PIN_VREF80 : PIN_IN));
  11142. if (nid != ALC662_PIN_CD_NID)
  11143. snd_hda_codec_write(codec, nid, 0,
  11144. AC_VERB_SET_AMP_GAIN_MUTE,
  11145. AMP_OUT_MUTE);
  11146. }
  11147. }
  11148. }
  11149. static int alc662_parse_auto_config(struct hda_codec *codec)
  11150. {
  11151. struct alc_spec *spec = codec->spec;
  11152. int err;
  11153. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  11154. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  11155. alc662_ignore);
  11156. if (err < 0)
  11157. return err;
  11158. if (!spec->autocfg.line_outs)
  11159. return 0; /* can't find valid BIOS pin config */
  11160. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  11161. if (err < 0)
  11162. return err;
  11163. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  11164. if (err < 0)
  11165. return err;
  11166. err = alc662_auto_create_extra_out(spec,
  11167. spec->autocfg.speaker_pins[0],
  11168. "Speaker");
  11169. if (err < 0)
  11170. return err;
  11171. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  11172. "Headphone");
  11173. if (err < 0)
  11174. return err;
  11175. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  11176. if (err < 0)
  11177. return err;
  11178. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  11179. if (spec->autocfg.dig_out_pin)
  11180. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  11181. if (spec->kctl_alloc)
  11182. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  11183. spec->num_mux_defs = 1;
  11184. spec->input_mux = &spec->private_imux;
  11185. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  11186. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  11187. spec->num_mixers++;
  11188. return 1;
  11189. }
  11190. /* additional initialization for auto-configuration model */
  11191. static void alc662_auto_init(struct hda_codec *codec)
  11192. {
  11193. alc662_auto_init_multi_out(codec);
  11194. alc662_auto_init_hp_out(codec);
  11195. alc662_auto_init_analog_input(codec);
  11196. }
  11197. static int patch_alc662(struct hda_codec *codec)
  11198. {
  11199. struct alc_spec *spec;
  11200. int err, board_config;
  11201. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  11202. if (!spec)
  11203. return -ENOMEM;
  11204. codec->spec = spec;
  11205. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  11206. alc662_models,
  11207. alc662_cfg_tbl);
  11208. if (board_config < 0) {
  11209. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  11210. "trying auto-probe from BIOS...\n");
  11211. board_config = ALC662_AUTO;
  11212. }
  11213. if (board_config == ALC662_AUTO) {
  11214. /* automatic parse from the BIOS config */
  11215. err = alc662_parse_auto_config(codec);
  11216. if (err < 0) {
  11217. alc_free(codec);
  11218. return err;
  11219. } else if (!err) {
  11220. printk(KERN_INFO
  11221. "hda_codec: Cannot set up configuration "
  11222. "from BIOS. Using base mode...\n");
  11223. board_config = ALC662_3ST_2ch_DIG;
  11224. }
  11225. }
  11226. if (board_config != ALC662_AUTO)
  11227. setup_preset(spec, &alc662_presets[board_config]);
  11228. spec->stream_name_analog = "ALC662 Analog";
  11229. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  11230. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  11231. spec->stream_name_digital = "ALC662 Digital";
  11232. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  11233. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  11234. if (!spec->adc_nids && spec->input_mux) {
  11235. spec->adc_nids = alc662_adc_nids;
  11236. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  11237. }
  11238. codec->patch_ops = alc_patch_ops;
  11239. if (board_config == ALC662_AUTO)
  11240. spec->init_hook = alc662_auto_init;
  11241. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11242. if (!spec->loopback.amplist)
  11243. spec->loopback.amplist = alc662_loopbacks;
  11244. #endif
  11245. return 0;
  11246. }
  11247. /*
  11248. * patch entries
  11249. */
  11250. struct hda_codec_preset snd_hda_preset_realtek[] = {
  11251. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  11252. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  11253. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  11254. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  11255. .patch = patch_alc861 },
  11256. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  11257. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  11258. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  11259. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  11260. .patch = patch_alc883 },
  11261. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  11262. .patch = patch_alc662 },
  11263. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  11264. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  11265. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  11266. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  11267. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  11268. {} /* terminator */
  11269. };