patch_realtek.c 391 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_BENQ_T31,
  93. ALC262_AUTO,
  94. ALC262_MODEL_LAST /* last tag */
  95. };
  96. /* ALC268 models */
  97. enum {
  98. ALC268_3ST,
  99. ALC268_TOSHIBA,
  100. ALC268_ACER,
  101. ALC268_AUTO,
  102. ALC268_MODEL_LAST /* last tag */
  103. };
  104. /* ALC861 models */
  105. enum {
  106. ALC861_3ST,
  107. ALC660_3ST,
  108. ALC861_3ST_DIG,
  109. ALC861_6ST_DIG,
  110. ALC861_UNIWILL_M31,
  111. ALC861_TOSHIBA,
  112. ALC861_ASUS,
  113. ALC861_ASUS_LAPTOP,
  114. ALC861_AUTO,
  115. ALC861_MODEL_LAST,
  116. };
  117. /* ALC861-VD models */
  118. enum {
  119. ALC660VD_3ST,
  120. ALC660VD_3ST_DIG,
  121. ALC861VD_3ST,
  122. ALC861VD_3ST_DIG,
  123. ALC861VD_6ST_DIG,
  124. ALC861VD_LENOVO,
  125. ALC861VD_DALLAS,
  126. ALC861VD_HP,
  127. ALC861VD_AUTO,
  128. ALC861VD_MODEL_LAST,
  129. };
  130. /* ALC662 models */
  131. enum {
  132. ALC662_3ST_2ch_DIG,
  133. ALC662_3ST_6ch_DIG,
  134. ALC662_3ST_6ch,
  135. ALC662_5ST_DIG,
  136. ALC662_LENOVO_101E,
  137. ALC662_AUTO,
  138. ALC662_MODEL_LAST,
  139. };
  140. /* ALC882 models */
  141. enum {
  142. ALC882_3ST_DIG,
  143. ALC882_6ST_DIG,
  144. ALC882_ARIMA,
  145. ALC882_W2JC,
  146. ALC882_TARGA,
  147. ALC882_ASUS_A7J,
  148. ALC885_MACPRO,
  149. ALC885_IMAC24,
  150. ALC882_AUTO,
  151. ALC882_MODEL_LAST,
  152. };
  153. /* ALC883 models */
  154. enum {
  155. ALC883_3ST_2ch_DIG,
  156. ALC883_3ST_6ch_DIG,
  157. ALC883_3ST_6ch,
  158. ALC883_6ST_DIG,
  159. ALC883_TARGA_DIG,
  160. ALC883_TARGA_2ch_DIG,
  161. ALC883_ACER,
  162. ALC883_ACER_ASPIRE,
  163. ALC883_MEDION,
  164. ALC883_MEDION_MD2,
  165. ALC883_LAPTOP_EAPD,
  166. ALC883_LENOVO_101E_2ch,
  167. ALC883_LENOVO_NB0763,
  168. ALC888_LENOVO_MS7195_DIG,
  169. ALC888_6ST_HP,
  170. ALC888_3ST_HP,
  171. ALC883_AUTO,
  172. ALC883_MODEL_LAST,
  173. };
  174. /* for GPIO Poll */
  175. #define GPIO_MASK 0x03
  176. struct alc_spec {
  177. /* codec parameterization */
  178. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  179. unsigned int num_mixers;
  180. const struct hda_verb *init_verbs[5]; /* initialization verbs
  181. * don't forget NULL
  182. * termination!
  183. */
  184. unsigned int num_init_verbs;
  185. char *stream_name_analog; /* analog PCM stream */
  186. struct hda_pcm_stream *stream_analog_playback;
  187. struct hda_pcm_stream *stream_analog_capture;
  188. char *stream_name_digital; /* digital PCM stream */
  189. struct hda_pcm_stream *stream_digital_playback;
  190. struct hda_pcm_stream *stream_digital_capture;
  191. /* playback */
  192. struct hda_multi_out multiout; /* playback set-up
  193. * max_channels, dacs must be set
  194. * dig_out_nid and hp_nid are optional
  195. */
  196. /* capture */
  197. unsigned int num_adc_nids;
  198. hda_nid_t *adc_nids;
  199. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  200. /* capture source */
  201. unsigned int num_mux_defs;
  202. const struct hda_input_mux *input_mux;
  203. unsigned int cur_mux[3];
  204. /* channel model */
  205. const struct hda_channel_mode *channel_mode;
  206. int num_channel_mode;
  207. int need_dac_fix;
  208. /* PCM information */
  209. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  210. /* dynamic controls, init_verbs and input_mux */
  211. struct auto_pin_cfg autocfg;
  212. unsigned int num_kctl_alloc, num_kctl_used;
  213. struct snd_kcontrol_new *kctl_alloc;
  214. struct hda_input_mux private_imux;
  215. hda_nid_t private_dac_nids[5];
  216. /* hooks */
  217. void (*init_hook)(struct hda_codec *codec);
  218. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  219. /* for pin sensing */
  220. unsigned int sense_updated: 1;
  221. unsigned int jack_present: 1;
  222. #ifdef CONFIG_SND_HDA_POWER_SAVE
  223. struct hda_loopback_check loopback;
  224. #endif
  225. };
  226. /*
  227. * configuration template - to be copied to the spec instance
  228. */
  229. struct alc_config_preset {
  230. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  231. * with spec
  232. */
  233. const struct hda_verb *init_verbs[5];
  234. unsigned int num_dacs;
  235. hda_nid_t *dac_nids;
  236. hda_nid_t dig_out_nid; /* optional */
  237. hda_nid_t hp_nid; /* optional */
  238. unsigned int num_adc_nids;
  239. hda_nid_t *adc_nids;
  240. hda_nid_t dig_in_nid;
  241. unsigned int num_channel_mode;
  242. const struct hda_channel_mode *channel_mode;
  243. int need_dac_fix;
  244. unsigned int num_mux_defs;
  245. const struct hda_input_mux *input_mux;
  246. void (*unsol_event)(struct hda_codec *, unsigned int);
  247. void (*init_hook)(struct hda_codec *);
  248. #ifdef CONFIG_SND_HDA_POWER_SAVE
  249. struct hda_amp_list *loopbacks;
  250. #endif
  251. };
  252. /*
  253. * input MUX handling
  254. */
  255. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  256. struct snd_ctl_elem_info *uinfo)
  257. {
  258. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  259. struct alc_spec *spec = codec->spec;
  260. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  261. if (mux_idx >= spec->num_mux_defs)
  262. mux_idx = 0;
  263. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  264. }
  265. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  266. struct snd_ctl_elem_value *ucontrol)
  267. {
  268. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  269. struct alc_spec *spec = codec->spec;
  270. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  271. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  272. return 0;
  273. }
  274. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  275. struct snd_ctl_elem_value *ucontrol)
  276. {
  277. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  278. struct alc_spec *spec = codec->spec;
  279. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  280. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  281. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  282. spec->adc_nids[adc_idx],
  283. &spec->cur_mux[adc_idx]);
  284. }
  285. /*
  286. * channel mode setting
  287. */
  288. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  289. struct snd_ctl_elem_info *uinfo)
  290. {
  291. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  292. struct alc_spec *spec = codec->spec;
  293. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  294. spec->num_channel_mode);
  295. }
  296. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  297. struct snd_ctl_elem_value *ucontrol)
  298. {
  299. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  300. struct alc_spec *spec = codec->spec;
  301. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  302. spec->num_channel_mode,
  303. spec->multiout.max_channels);
  304. }
  305. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  306. struct snd_ctl_elem_value *ucontrol)
  307. {
  308. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  309. struct alc_spec *spec = codec->spec;
  310. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  311. spec->num_channel_mode,
  312. &spec->multiout.max_channels);
  313. if (err >= 0 && spec->need_dac_fix)
  314. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  315. return err;
  316. }
  317. /*
  318. * Control the mode of pin widget settings via the mixer. "pc" is used
  319. * instead of "%" to avoid consequences of accidently treating the % as
  320. * being part of a format specifier. Maximum allowed length of a value is
  321. * 63 characters plus NULL terminator.
  322. *
  323. * Note: some retasking pin complexes seem to ignore requests for input
  324. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  325. * are requested. Therefore order this list so that this behaviour will not
  326. * cause problems when mixer clients move through the enum sequentially.
  327. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  328. * March 2006.
  329. */
  330. static char *alc_pin_mode_names[] = {
  331. "Mic 50pc bias", "Mic 80pc bias",
  332. "Line in", "Line out", "Headphone out",
  333. };
  334. static unsigned char alc_pin_mode_values[] = {
  335. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  336. };
  337. /* The control can present all 5 options, or it can limit the options based
  338. * in the pin being assumed to be exclusively an input or an output pin. In
  339. * addition, "input" pins may or may not process the mic bias option
  340. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  341. * accept requests for bias as of chip versions up to March 2006) and/or
  342. * wiring in the computer.
  343. */
  344. #define ALC_PIN_DIR_IN 0x00
  345. #define ALC_PIN_DIR_OUT 0x01
  346. #define ALC_PIN_DIR_INOUT 0x02
  347. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  348. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  349. /* Info about the pin modes supported by the different pin direction modes.
  350. * For each direction the minimum and maximum values are given.
  351. */
  352. static signed char alc_pin_mode_dir_info[5][2] = {
  353. { 0, 2 }, /* ALC_PIN_DIR_IN */
  354. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  355. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  356. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  357. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  358. };
  359. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  360. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  361. #define alc_pin_mode_n_items(_dir) \
  362. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  363. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  364. struct snd_ctl_elem_info *uinfo)
  365. {
  366. unsigned int item_num = uinfo->value.enumerated.item;
  367. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  368. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  369. uinfo->count = 1;
  370. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  371. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  372. item_num = alc_pin_mode_min(dir);
  373. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  374. return 0;
  375. }
  376. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  377. struct snd_ctl_elem_value *ucontrol)
  378. {
  379. unsigned int i;
  380. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  381. hda_nid_t nid = kcontrol->private_value & 0xffff;
  382. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  383. long *valp = ucontrol->value.integer.value;
  384. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  385. AC_VERB_GET_PIN_WIDGET_CONTROL,
  386. 0x00);
  387. /* Find enumerated value for current pinctl setting */
  388. i = alc_pin_mode_min(dir);
  389. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  390. i++;
  391. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  392. return 0;
  393. }
  394. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  395. struct snd_ctl_elem_value *ucontrol)
  396. {
  397. signed int change;
  398. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  399. hda_nid_t nid = kcontrol->private_value & 0xffff;
  400. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  401. long val = *ucontrol->value.integer.value;
  402. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  403. AC_VERB_GET_PIN_WIDGET_CONTROL,
  404. 0x00);
  405. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  406. val = alc_pin_mode_min(dir);
  407. change = pinctl != alc_pin_mode_values[val];
  408. if (change) {
  409. /* Set pin mode to that requested */
  410. snd_hda_codec_write_cache(codec, nid, 0,
  411. AC_VERB_SET_PIN_WIDGET_CONTROL,
  412. alc_pin_mode_values[val]);
  413. /* Also enable the retasking pin's input/output as required
  414. * for the requested pin mode. Enum values of 2 or less are
  415. * input modes.
  416. *
  417. * Dynamically switching the input/output buffers probably
  418. * reduces noise slightly (particularly on input) so we'll
  419. * do it. However, having both input and output buffers
  420. * enabled simultaneously doesn't seem to be problematic if
  421. * this turns out to be necessary in the future.
  422. */
  423. if (val <= 2) {
  424. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  425. HDA_AMP_MUTE, HDA_AMP_MUTE);
  426. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  427. HDA_AMP_MUTE, 0);
  428. } else {
  429. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  430. HDA_AMP_MUTE, HDA_AMP_MUTE);
  431. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  432. HDA_AMP_MUTE, 0);
  433. }
  434. }
  435. return change;
  436. }
  437. #define ALC_PIN_MODE(xname, nid, dir) \
  438. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  439. .info = alc_pin_mode_info, \
  440. .get = alc_pin_mode_get, \
  441. .put = alc_pin_mode_put, \
  442. .private_value = nid | (dir<<16) }
  443. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  444. * together using a mask with more than one bit set. This control is
  445. * currently used only by the ALC260 test model. At this stage they are not
  446. * needed for any "production" models.
  447. */
  448. #ifdef CONFIG_SND_DEBUG
  449. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  450. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  451. struct snd_ctl_elem_value *ucontrol)
  452. {
  453. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  454. hda_nid_t nid = kcontrol->private_value & 0xffff;
  455. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  456. long *valp = ucontrol->value.integer.value;
  457. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  458. AC_VERB_GET_GPIO_DATA, 0x00);
  459. *valp = (val & mask) != 0;
  460. return 0;
  461. }
  462. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  463. struct snd_ctl_elem_value *ucontrol)
  464. {
  465. signed int change;
  466. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  467. hda_nid_t nid = kcontrol->private_value & 0xffff;
  468. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  469. long val = *ucontrol->value.integer.value;
  470. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  471. AC_VERB_GET_GPIO_DATA,
  472. 0x00);
  473. /* Set/unset the masked GPIO bit(s) as needed */
  474. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  475. if (val == 0)
  476. gpio_data &= ~mask;
  477. else
  478. gpio_data |= mask;
  479. snd_hda_codec_write_cache(codec, nid, 0,
  480. AC_VERB_SET_GPIO_DATA, gpio_data);
  481. return change;
  482. }
  483. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  484. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  485. .info = alc_gpio_data_info, \
  486. .get = alc_gpio_data_get, \
  487. .put = alc_gpio_data_put, \
  488. .private_value = nid | (mask<<16) }
  489. #endif /* CONFIG_SND_DEBUG */
  490. /* A switch control to allow the enabling of the digital IO pins on the
  491. * ALC260. This is incredibly simplistic; the intention of this control is
  492. * to provide something in the test model allowing digital outputs to be
  493. * identified if present. If models are found which can utilise these
  494. * outputs a more complete mixer control can be devised for those models if
  495. * necessary.
  496. */
  497. #ifdef CONFIG_SND_DEBUG
  498. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  499. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  500. struct snd_ctl_elem_value *ucontrol)
  501. {
  502. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  503. hda_nid_t nid = kcontrol->private_value & 0xffff;
  504. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  505. long *valp = ucontrol->value.integer.value;
  506. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  507. AC_VERB_GET_DIGI_CONVERT, 0x00);
  508. *valp = (val & mask) != 0;
  509. return 0;
  510. }
  511. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  512. struct snd_ctl_elem_value *ucontrol)
  513. {
  514. signed int change;
  515. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  516. hda_nid_t nid = kcontrol->private_value & 0xffff;
  517. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  518. long val = *ucontrol->value.integer.value;
  519. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  520. AC_VERB_GET_DIGI_CONVERT,
  521. 0x00);
  522. /* Set/unset the masked control bit(s) as needed */
  523. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  524. if (val==0)
  525. ctrl_data &= ~mask;
  526. else
  527. ctrl_data |= mask;
  528. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  529. ctrl_data);
  530. return change;
  531. }
  532. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  533. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  534. .info = alc_spdif_ctrl_info, \
  535. .get = alc_spdif_ctrl_get, \
  536. .put = alc_spdif_ctrl_put, \
  537. .private_value = nid | (mask<<16) }
  538. #endif /* CONFIG_SND_DEBUG */
  539. /*
  540. * set up from the preset table
  541. */
  542. static void setup_preset(struct alc_spec *spec,
  543. const struct alc_config_preset *preset)
  544. {
  545. int i;
  546. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  547. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  548. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  549. i++)
  550. spec->init_verbs[spec->num_init_verbs++] =
  551. preset->init_verbs[i];
  552. spec->channel_mode = preset->channel_mode;
  553. spec->num_channel_mode = preset->num_channel_mode;
  554. spec->need_dac_fix = preset->need_dac_fix;
  555. spec->multiout.max_channels = spec->channel_mode[0].channels;
  556. spec->multiout.num_dacs = preset->num_dacs;
  557. spec->multiout.dac_nids = preset->dac_nids;
  558. spec->multiout.dig_out_nid = preset->dig_out_nid;
  559. spec->multiout.hp_nid = preset->hp_nid;
  560. spec->num_mux_defs = preset->num_mux_defs;
  561. if (!spec->num_mux_defs)
  562. spec->num_mux_defs = 1;
  563. spec->input_mux = preset->input_mux;
  564. spec->num_adc_nids = preset->num_adc_nids;
  565. spec->adc_nids = preset->adc_nids;
  566. spec->dig_in_nid = preset->dig_in_nid;
  567. spec->unsol_event = preset->unsol_event;
  568. spec->init_hook = preset->init_hook;
  569. #ifdef CONFIG_SND_HDA_POWER_SAVE
  570. spec->loopback.amplist = preset->loopbacks;
  571. #endif
  572. }
  573. /* Enable GPIO mask and set output */
  574. static struct hda_verb alc_gpio1_init_verbs[] = {
  575. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  576. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  577. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  578. { }
  579. };
  580. static struct hda_verb alc_gpio2_init_verbs[] = {
  581. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  582. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  583. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  584. { }
  585. };
  586. static struct hda_verb alc_gpio3_init_verbs[] = {
  587. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  588. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  589. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  590. { }
  591. };
  592. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  593. * 31 ~ 16 : Manufacture ID
  594. * 15 ~ 8 : SKU ID
  595. * 7 ~ 0 : Assembly ID
  596. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  597. */
  598. static void alc_subsystem_id(struct hda_codec *codec,
  599. unsigned int porta, unsigned int porte,
  600. unsigned int portd)
  601. {
  602. unsigned int ass, tmp;
  603. ass = codec->subsystem_id;
  604. if (!(ass & 1))
  605. return;
  606. /* Override */
  607. tmp = (ass & 0x38) >> 3; /* external Amp control */
  608. switch (tmp) {
  609. case 1:
  610. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  611. break;
  612. case 3:
  613. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  614. break;
  615. case 7:
  616. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  617. break;
  618. case 5:
  619. switch (codec->vendor_id) {
  620. case 0x10ec0862:
  621. case 0x10ec0660:
  622. case 0x10ec0662:
  623. case 0x10ec0267:
  624. case 0x10ec0268:
  625. snd_hda_codec_write(codec, 0x14, 0,
  626. AC_VERB_SET_EAPD_BTLENABLE, 2);
  627. snd_hda_codec_write(codec, 0x15, 0,
  628. AC_VERB_SET_EAPD_BTLENABLE, 2);
  629. return;
  630. }
  631. case 6:
  632. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  633. hda_nid_t port = 0;
  634. tmp = (ass & 0x1800) >> 11;
  635. switch (tmp) {
  636. case 0: port = porta; break;
  637. case 1: port = porte; break;
  638. case 2: port = portd; break;
  639. }
  640. if (port)
  641. snd_hda_codec_write(codec, port, 0,
  642. AC_VERB_SET_EAPD_BTLENABLE,
  643. 2);
  644. }
  645. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  646. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  647. (tmp == 5 ? 0x3040 : 0x3050));
  648. break;
  649. }
  650. }
  651. /*
  652. * Fix-up pin default configurations
  653. */
  654. struct alc_pincfg {
  655. hda_nid_t nid;
  656. u32 val;
  657. };
  658. static void alc_fix_pincfg(struct hda_codec *codec,
  659. const struct snd_pci_quirk *quirk,
  660. const struct alc_pincfg **pinfix)
  661. {
  662. const struct alc_pincfg *cfg;
  663. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  664. if (!quirk)
  665. return;
  666. cfg = pinfix[quirk->value];
  667. for (; cfg->nid; cfg++) {
  668. int i;
  669. u32 val = cfg->val;
  670. for (i = 0; i < 4; i++) {
  671. snd_hda_codec_write(codec, cfg->nid, 0,
  672. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  673. val & 0xff);
  674. val >>= 8;
  675. }
  676. }
  677. }
  678. /*
  679. * ALC880 3-stack model
  680. *
  681. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  682. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  683. * F-Mic = 0x1b, HP = 0x19
  684. */
  685. static hda_nid_t alc880_dac_nids[4] = {
  686. /* front, rear, clfe, rear_surr */
  687. 0x02, 0x05, 0x04, 0x03
  688. };
  689. static hda_nid_t alc880_adc_nids[3] = {
  690. /* ADC0-2 */
  691. 0x07, 0x08, 0x09,
  692. };
  693. /* The datasheet says the node 0x07 is connected from inputs,
  694. * but it shows zero connection in the real implementation on some devices.
  695. * Note: this is a 915GAV bug, fixed on 915GLV
  696. */
  697. static hda_nid_t alc880_adc_nids_alt[2] = {
  698. /* ADC1-2 */
  699. 0x08, 0x09,
  700. };
  701. #define ALC880_DIGOUT_NID 0x06
  702. #define ALC880_DIGIN_NID 0x0a
  703. static struct hda_input_mux alc880_capture_source = {
  704. .num_items = 4,
  705. .items = {
  706. { "Mic", 0x0 },
  707. { "Front Mic", 0x3 },
  708. { "Line", 0x2 },
  709. { "CD", 0x4 },
  710. },
  711. };
  712. /* channel source setting (2/6 channel selection for 3-stack) */
  713. /* 2ch mode */
  714. static struct hda_verb alc880_threestack_ch2_init[] = {
  715. /* set line-in to input, mute it */
  716. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  717. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  718. /* set mic-in to input vref 80%, mute it */
  719. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  720. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  721. { } /* end */
  722. };
  723. /* 6ch mode */
  724. static struct hda_verb alc880_threestack_ch6_init[] = {
  725. /* set line-in to output, unmute it */
  726. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  727. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  728. /* set mic-in to output, unmute it */
  729. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  730. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  731. { } /* end */
  732. };
  733. static struct hda_channel_mode alc880_threestack_modes[2] = {
  734. { 2, alc880_threestack_ch2_init },
  735. { 6, alc880_threestack_ch6_init },
  736. };
  737. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  738. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  739. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  740. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  741. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  742. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  743. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  744. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  745. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  746. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  747. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  748. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  749. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  750. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  751. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  752. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  753. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  754. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  755. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  756. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  757. {
  758. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  759. .name = "Channel Mode",
  760. .info = alc_ch_mode_info,
  761. .get = alc_ch_mode_get,
  762. .put = alc_ch_mode_put,
  763. },
  764. { } /* end */
  765. };
  766. /* capture mixer elements */
  767. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  768. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  769. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  770. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  771. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  772. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  773. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  774. {
  775. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  776. /* The multiple "Capture Source" controls confuse alsamixer
  777. * So call somewhat different..
  778. * FIXME: the controls appear in the "playback" view!
  779. */
  780. /* .name = "Capture Source", */
  781. .name = "Input Source",
  782. .count = 3,
  783. .info = alc_mux_enum_info,
  784. .get = alc_mux_enum_get,
  785. .put = alc_mux_enum_put,
  786. },
  787. { } /* end */
  788. };
  789. /* capture mixer elements (in case NID 0x07 not available) */
  790. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  791. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  792. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  793. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  794. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  795. {
  796. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  797. /* The multiple "Capture Source" controls confuse alsamixer
  798. * So call somewhat different..
  799. * FIXME: the controls appear in the "playback" view!
  800. */
  801. /* .name = "Capture Source", */
  802. .name = "Input Source",
  803. .count = 2,
  804. .info = alc_mux_enum_info,
  805. .get = alc_mux_enum_get,
  806. .put = alc_mux_enum_put,
  807. },
  808. { } /* end */
  809. };
  810. /*
  811. * ALC880 5-stack model
  812. *
  813. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  814. * Side = 0x02 (0xd)
  815. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  816. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  817. */
  818. /* additional mixers to alc880_three_stack_mixer */
  819. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  820. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  821. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  822. { } /* end */
  823. };
  824. /* channel source setting (6/8 channel selection for 5-stack) */
  825. /* 6ch mode */
  826. static struct hda_verb alc880_fivestack_ch6_init[] = {
  827. /* set line-in to input, mute it */
  828. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  829. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  830. { } /* end */
  831. };
  832. /* 8ch mode */
  833. static struct hda_verb alc880_fivestack_ch8_init[] = {
  834. /* set line-in to output, unmute it */
  835. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  836. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  837. { } /* end */
  838. };
  839. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  840. { 6, alc880_fivestack_ch6_init },
  841. { 8, alc880_fivestack_ch8_init },
  842. };
  843. /*
  844. * ALC880 6-stack model
  845. *
  846. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  847. * Side = 0x05 (0x0f)
  848. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  849. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  850. */
  851. static hda_nid_t alc880_6st_dac_nids[4] = {
  852. /* front, rear, clfe, rear_surr */
  853. 0x02, 0x03, 0x04, 0x05
  854. };
  855. static struct hda_input_mux alc880_6stack_capture_source = {
  856. .num_items = 4,
  857. .items = {
  858. { "Mic", 0x0 },
  859. { "Front Mic", 0x1 },
  860. { "Line", 0x2 },
  861. { "CD", 0x4 },
  862. },
  863. };
  864. /* fixed 8-channels */
  865. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  866. { 8, NULL },
  867. };
  868. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  869. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  870. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  871. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  872. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  873. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  874. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  875. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  876. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  877. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  878. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  879. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  880. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  881. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  882. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  883. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  884. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  885. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  886. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  887. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  888. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  889. {
  890. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  891. .name = "Channel Mode",
  892. .info = alc_ch_mode_info,
  893. .get = alc_ch_mode_get,
  894. .put = alc_ch_mode_put,
  895. },
  896. { } /* end */
  897. };
  898. /*
  899. * ALC880 W810 model
  900. *
  901. * W810 has rear IO for:
  902. * Front (DAC 02)
  903. * Surround (DAC 03)
  904. * Center/LFE (DAC 04)
  905. * Digital out (06)
  906. *
  907. * The system also has a pair of internal speakers, and a headphone jack.
  908. * These are both connected to Line2 on the codec, hence to DAC 02.
  909. *
  910. * There is a variable resistor to control the speaker or headphone
  911. * volume. This is a hardware-only device without a software API.
  912. *
  913. * Plugging headphones in will disable the internal speakers. This is
  914. * implemented in hardware, not via the driver using jack sense. In
  915. * a similar fashion, plugging into the rear socket marked "front" will
  916. * disable both the speakers and headphones.
  917. *
  918. * For input, there's a microphone jack, and an "audio in" jack.
  919. * These may not do anything useful with this driver yet, because I
  920. * haven't setup any initialization verbs for these yet...
  921. */
  922. static hda_nid_t alc880_w810_dac_nids[3] = {
  923. /* front, rear/surround, clfe */
  924. 0x02, 0x03, 0x04
  925. };
  926. /* fixed 6 channels */
  927. static struct hda_channel_mode alc880_w810_modes[1] = {
  928. { 6, NULL }
  929. };
  930. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  931. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  932. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  933. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  934. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  935. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  936. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  937. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  938. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  939. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  940. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  941. { } /* end */
  942. };
  943. /*
  944. * Z710V model
  945. *
  946. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  947. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  948. * Line = 0x1a
  949. */
  950. static hda_nid_t alc880_z71v_dac_nids[1] = {
  951. 0x02
  952. };
  953. #define ALC880_Z71V_HP_DAC 0x03
  954. /* fixed 2 channels */
  955. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  956. { 2, NULL }
  957. };
  958. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  959. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  960. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  961. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  962. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  963. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  964. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  965. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  966. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  967. { } /* end */
  968. };
  969. /* FIXME! */
  970. /*
  971. * ALC880 F1734 model
  972. *
  973. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  974. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  975. */
  976. static hda_nid_t alc880_f1734_dac_nids[1] = {
  977. 0x03
  978. };
  979. #define ALC880_F1734_HP_DAC 0x02
  980. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  981. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  982. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  983. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  984. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  985. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  986. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  987. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  988. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  989. { } /* end */
  990. };
  991. /* FIXME! */
  992. /*
  993. * ALC880 ASUS model
  994. *
  995. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  996. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  997. * Mic = 0x18, Line = 0x1a
  998. */
  999. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1000. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1001. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1002. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1003. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1004. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1005. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1006. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1007. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1008. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1009. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1010. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1011. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1012. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1013. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1014. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1015. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1016. {
  1017. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1018. .name = "Channel Mode",
  1019. .info = alc_ch_mode_info,
  1020. .get = alc_ch_mode_get,
  1021. .put = alc_ch_mode_put,
  1022. },
  1023. { } /* end */
  1024. };
  1025. /* FIXME! */
  1026. /*
  1027. * ALC880 ASUS W1V model
  1028. *
  1029. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1030. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1031. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1032. */
  1033. /* additional mixers to alc880_asus_mixer */
  1034. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1035. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1036. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1037. { } /* end */
  1038. };
  1039. /* additional mixers to alc880_asus_mixer */
  1040. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1041. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1042. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1043. { } /* end */
  1044. };
  1045. /* TCL S700 */
  1046. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1047. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1048. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1049. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1050. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1051. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1052. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1053. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1054. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1055. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1056. {
  1057. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1058. /* The multiple "Capture Source" controls confuse alsamixer
  1059. * So call somewhat different..
  1060. * FIXME: the controls appear in the "playback" view!
  1061. */
  1062. /* .name = "Capture Source", */
  1063. .name = "Input Source",
  1064. .count = 1,
  1065. .info = alc_mux_enum_info,
  1066. .get = alc_mux_enum_get,
  1067. .put = alc_mux_enum_put,
  1068. },
  1069. { } /* end */
  1070. };
  1071. /* Uniwill */
  1072. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1073. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1074. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1075. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1076. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1077. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1078. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1079. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1080. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1081. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1082. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1083. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1084. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1085. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1086. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1087. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1088. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1089. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1090. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1091. {
  1092. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1093. .name = "Channel Mode",
  1094. .info = alc_ch_mode_info,
  1095. .get = alc_ch_mode_get,
  1096. .put = alc_ch_mode_put,
  1097. },
  1098. { } /* end */
  1099. };
  1100. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1101. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1102. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1103. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1104. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1105. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1106. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1107. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1108. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1109. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1110. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1111. { } /* end */
  1112. };
  1113. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1114. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1115. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1116. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1117. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1118. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1119. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1120. { } /* end */
  1121. };
  1122. /*
  1123. * build control elements
  1124. */
  1125. static int alc_build_controls(struct hda_codec *codec)
  1126. {
  1127. struct alc_spec *spec = codec->spec;
  1128. int err;
  1129. int i;
  1130. for (i = 0; i < spec->num_mixers; i++) {
  1131. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1132. if (err < 0)
  1133. return err;
  1134. }
  1135. if (spec->multiout.dig_out_nid) {
  1136. err = snd_hda_create_spdif_out_ctls(codec,
  1137. spec->multiout.dig_out_nid);
  1138. if (err < 0)
  1139. return err;
  1140. }
  1141. if (spec->dig_in_nid) {
  1142. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1143. if (err < 0)
  1144. return err;
  1145. }
  1146. return 0;
  1147. }
  1148. /*
  1149. * initialize the codec volumes, etc
  1150. */
  1151. /*
  1152. * generic initialization of ADC, input mixers and output mixers
  1153. */
  1154. static struct hda_verb alc880_volume_init_verbs[] = {
  1155. /*
  1156. * Unmute ADC0-2 and set the default input to mic-in
  1157. */
  1158. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1159. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1160. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1161. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1162. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1163. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1164. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1165. * mixer widget
  1166. * Note: PASD motherboards uses the Line In 2 as the input for front
  1167. * panel mic (mic 2)
  1168. */
  1169. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1170. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1171. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1172. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1173. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1174. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1175. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1177. /*
  1178. * Set up output mixers (0x0c - 0x0f)
  1179. */
  1180. /* set vol=0 to output mixers */
  1181. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1182. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1183. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1184. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1185. /* set up input amps for analog loopback */
  1186. /* Amp Indices: DAC = 0, mixer = 1 */
  1187. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1188. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1189. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1190. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1191. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1192. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1193. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1194. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1195. { }
  1196. };
  1197. /*
  1198. * 3-stack pin configuration:
  1199. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1200. */
  1201. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1202. /*
  1203. * preset connection lists of input pins
  1204. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1205. */
  1206. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1207. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1208. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1209. /*
  1210. * Set pin mode and muting
  1211. */
  1212. /* set front pin widgets 0x14 for output */
  1213. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1214. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1215. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1216. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1217. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1218. /* Mic2 (as headphone out) for HP output */
  1219. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1220. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1221. /* Line In pin widget for input */
  1222. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1223. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1224. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1225. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1226. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1227. /* CD pin widget for input */
  1228. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1229. { }
  1230. };
  1231. /*
  1232. * 5-stack pin configuration:
  1233. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1234. * line-in/side = 0x1a, f-mic = 0x1b
  1235. */
  1236. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1237. /*
  1238. * preset connection lists of input pins
  1239. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1240. */
  1241. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1242. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1243. /*
  1244. * Set pin mode and muting
  1245. */
  1246. /* set pin widgets 0x14-0x17 for output */
  1247. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1248. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1249. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1250. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1251. /* unmute pins for output (no gain on this amp) */
  1252. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1253. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1254. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1255. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1257. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1258. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1259. /* Mic2 (as headphone out) for HP output */
  1260. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1261. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1262. /* Line In pin widget for input */
  1263. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1264. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1265. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1266. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1267. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1268. /* CD pin widget for input */
  1269. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1270. { }
  1271. };
  1272. /*
  1273. * W810 pin configuration:
  1274. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1275. */
  1276. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1277. /* hphone/speaker input selector: front DAC */
  1278. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1279. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1280. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1281. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1282. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1283. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1284. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1285. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1286. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1287. { }
  1288. };
  1289. /*
  1290. * Z71V pin configuration:
  1291. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1292. */
  1293. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1294. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1295. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1296. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1297. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1298. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1299. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1300. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1301. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1302. { }
  1303. };
  1304. /*
  1305. * 6-stack pin configuration:
  1306. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1307. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1308. */
  1309. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1310. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1311. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1312. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1313. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1314. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1315. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1316. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1318. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1319. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1320. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1321. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1322. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1323. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1324. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1325. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1326. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1327. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1328. { }
  1329. };
  1330. /*
  1331. * Uniwill pin configuration:
  1332. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1333. * line = 0x1a
  1334. */
  1335. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1336. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1337. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1338. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1339. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1340. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1341. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1342. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1343. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1344. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1345. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1346. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1347. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1348. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1349. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1350. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1351. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1352. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1353. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1354. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1355. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1356. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1357. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1358. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1359. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1360. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1361. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1362. { }
  1363. };
  1364. /*
  1365. * Uniwill P53
  1366. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1367. */
  1368. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1369. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1370. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1371. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1372. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1373. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1374. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1375. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1376. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1377. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1378. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1379. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1380. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1381. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1382. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1383. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1384. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1385. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1386. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1387. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1388. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1389. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1390. { }
  1391. };
  1392. static struct hda_verb alc880_beep_init_verbs[] = {
  1393. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1394. { }
  1395. };
  1396. /* toggle speaker-output according to the hp-jack state */
  1397. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1398. {
  1399. unsigned int present;
  1400. unsigned char bits;
  1401. present = snd_hda_codec_read(codec, 0x14, 0,
  1402. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1403. bits = present ? HDA_AMP_MUTE : 0;
  1404. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1405. HDA_AMP_MUTE, bits);
  1406. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1407. HDA_AMP_MUTE, bits);
  1408. }
  1409. /* auto-toggle front mic */
  1410. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1411. {
  1412. unsigned int present;
  1413. unsigned char bits;
  1414. present = snd_hda_codec_read(codec, 0x18, 0,
  1415. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1416. bits = present ? HDA_AMP_MUTE : 0;
  1417. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1418. }
  1419. static void alc880_uniwill_automute(struct hda_codec *codec)
  1420. {
  1421. alc880_uniwill_hp_automute(codec);
  1422. alc880_uniwill_mic_automute(codec);
  1423. }
  1424. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1425. unsigned int res)
  1426. {
  1427. /* Looks like the unsol event is incompatible with the standard
  1428. * definition. 4bit tag is placed at 28 bit!
  1429. */
  1430. switch (res >> 28) {
  1431. case ALC880_HP_EVENT:
  1432. alc880_uniwill_hp_automute(codec);
  1433. break;
  1434. case ALC880_MIC_EVENT:
  1435. alc880_uniwill_mic_automute(codec);
  1436. break;
  1437. }
  1438. }
  1439. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1440. {
  1441. unsigned int present;
  1442. unsigned char bits;
  1443. present = snd_hda_codec_read(codec, 0x14, 0,
  1444. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1445. bits = present ? HDA_AMP_MUTE : 0;
  1446. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1447. }
  1448. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1449. {
  1450. unsigned int present;
  1451. present = snd_hda_codec_read(codec, 0x21, 0,
  1452. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1453. present &= HDA_AMP_VOLMASK;
  1454. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1455. HDA_AMP_VOLMASK, present);
  1456. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1457. HDA_AMP_VOLMASK, present);
  1458. }
  1459. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1460. unsigned int res)
  1461. {
  1462. /* Looks like the unsol event is incompatible with the standard
  1463. * definition. 4bit tag is placed at 28 bit!
  1464. */
  1465. if ((res >> 28) == ALC880_HP_EVENT)
  1466. alc880_uniwill_p53_hp_automute(codec);
  1467. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1468. alc880_uniwill_p53_dcvol_automute(codec);
  1469. }
  1470. /* FIXME! */
  1471. /*
  1472. * F1734 pin configuration:
  1473. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1474. */
  1475. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1476. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1477. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1478. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1479. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1480. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1481. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1482. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1483. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1484. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1485. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1486. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1487. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1488. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1489. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1490. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1491. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1492. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1493. { }
  1494. };
  1495. /* FIXME! */
  1496. /*
  1497. * ASUS pin configuration:
  1498. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1499. */
  1500. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1501. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1502. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1503. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1504. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1505. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1506. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1507. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1508. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1509. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1510. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1511. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1512. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1513. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1514. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1515. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1516. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1517. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1518. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1519. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1520. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1521. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1522. { }
  1523. };
  1524. /* Enable GPIO mask and set output */
  1525. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1526. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1527. /* Clevo m520g init */
  1528. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1529. /* headphone output */
  1530. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1531. /* line-out */
  1532. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1533. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1534. /* Line-in */
  1535. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1536. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1537. /* CD */
  1538. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1539. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1540. /* Mic1 (rear panel) */
  1541. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1542. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1543. /* Mic2 (front panel) */
  1544. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1545. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1546. /* headphone */
  1547. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1548. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1549. /* change to EAPD mode */
  1550. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1551. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1552. { }
  1553. };
  1554. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1555. /* change to EAPD mode */
  1556. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1557. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1558. /* Headphone output */
  1559. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1560. /* Front output*/
  1561. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1562. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1563. /* Line In pin widget for input */
  1564. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1565. /* CD pin widget for input */
  1566. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1567. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1568. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1569. /* change to EAPD mode */
  1570. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1571. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1572. { }
  1573. };
  1574. /*
  1575. * LG m1 express dual
  1576. *
  1577. * Pin assignment:
  1578. * Rear Line-In/Out (blue): 0x14
  1579. * Build-in Mic-In: 0x15
  1580. * Speaker-out: 0x17
  1581. * HP-Out (green): 0x1b
  1582. * Mic-In/Out (red): 0x19
  1583. * SPDIF-Out: 0x1e
  1584. */
  1585. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1586. static hda_nid_t alc880_lg_dac_nids[3] = {
  1587. 0x05, 0x02, 0x03
  1588. };
  1589. /* seems analog CD is not working */
  1590. static struct hda_input_mux alc880_lg_capture_source = {
  1591. .num_items = 3,
  1592. .items = {
  1593. { "Mic", 0x1 },
  1594. { "Line", 0x5 },
  1595. { "Internal Mic", 0x6 },
  1596. },
  1597. };
  1598. /* 2,4,6 channel modes */
  1599. static struct hda_verb alc880_lg_ch2_init[] = {
  1600. /* set line-in and mic-in to input */
  1601. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1602. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1603. { }
  1604. };
  1605. static struct hda_verb alc880_lg_ch4_init[] = {
  1606. /* set line-in to out and mic-in to input */
  1607. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1608. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1609. { }
  1610. };
  1611. static struct hda_verb alc880_lg_ch6_init[] = {
  1612. /* set line-in and mic-in to output */
  1613. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1614. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1615. { }
  1616. };
  1617. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1618. { 2, alc880_lg_ch2_init },
  1619. { 4, alc880_lg_ch4_init },
  1620. { 6, alc880_lg_ch6_init },
  1621. };
  1622. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1623. /* FIXME: it's not really "master" but front channels */
  1624. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1625. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1626. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1627. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1628. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1629. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1630. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1631. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1632. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1633. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1634. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1635. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1636. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1637. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1638. {
  1639. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1640. .name = "Channel Mode",
  1641. .info = alc_ch_mode_info,
  1642. .get = alc_ch_mode_get,
  1643. .put = alc_ch_mode_put,
  1644. },
  1645. { } /* end */
  1646. };
  1647. static struct hda_verb alc880_lg_init_verbs[] = {
  1648. /* set capture source to mic-in */
  1649. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1650. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1651. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1652. /* mute all amp mixer inputs */
  1653. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1654. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1655. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1656. /* line-in to input */
  1657. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1658. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1659. /* built-in mic */
  1660. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1661. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1662. /* speaker-out */
  1663. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1664. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1665. /* mic-in to input */
  1666. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1667. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1668. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1669. /* HP-out */
  1670. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1671. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1672. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1673. /* jack sense */
  1674. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1675. { }
  1676. };
  1677. /* toggle speaker-output according to the hp-jack state */
  1678. static void alc880_lg_automute(struct hda_codec *codec)
  1679. {
  1680. unsigned int present;
  1681. unsigned char bits;
  1682. present = snd_hda_codec_read(codec, 0x1b, 0,
  1683. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1684. bits = present ? HDA_AMP_MUTE : 0;
  1685. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1686. HDA_AMP_MUTE, bits);
  1687. }
  1688. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1689. {
  1690. /* Looks like the unsol event is incompatible with the standard
  1691. * definition. 4bit tag is placed at 28 bit!
  1692. */
  1693. if ((res >> 28) == 0x01)
  1694. alc880_lg_automute(codec);
  1695. }
  1696. /*
  1697. * LG LW20
  1698. *
  1699. * Pin assignment:
  1700. * Speaker-out: 0x14
  1701. * Mic-In: 0x18
  1702. * Built-in Mic-In: 0x19
  1703. * Line-In: 0x1b
  1704. * HP-Out: 0x1a
  1705. * SPDIF-Out: 0x1e
  1706. */
  1707. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1708. .num_items = 3,
  1709. .items = {
  1710. { "Mic", 0x0 },
  1711. { "Internal Mic", 0x1 },
  1712. { "Line In", 0x2 },
  1713. },
  1714. };
  1715. #define alc880_lg_lw_modes alc880_threestack_modes
  1716. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1717. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1718. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1719. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1720. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1721. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1722. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1723. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1724. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1725. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1726. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1727. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1728. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1729. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1730. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1731. {
  1732. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1733. .name = "Channel Mode",
  1734. .info = alc_ch_mode_info,
  1735. .get = alc_ch_mode_get,
  1736. .put = alc_ch_mode_put,
  1737. },
  1738. { } /* end */
  1739. };
  1740. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1741. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1742. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1743. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1744. /* set capture source to mic-in */
  1745. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1746. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1747. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1748. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1749. /* speaker-out */
  1750. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1751. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1752. /* HP-out */
  1753. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1754. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1755. /* mic-in to input */
  1756. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1757. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1758. /* built-in mic */
  1759. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1760. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1761. /* jack sense */
  1762. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1763. { }
  1764. };
  1765. /* toggle speaker-output according to the hp-jack state */
  1766. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1767. {
  1768. unsigned int present;
  1769. unsigned char bits;
  1770. present = snd_hda_codec_read(codec, 0x1b, 0,
  1771. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1772. bits = present ? HDA_AMP_MUTE : 0;
  1773. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1774. HDA_AMP_MUTE, bits);
  1775. }
  1776. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1777. {
  1778. /* Looks like the unsol event is incompatible with the standard
  1779. * definition. 4bit tag is placed at 28 bit!
  1780. */
  1781. if ((res >> 28) == 0x01)
  1782. alc880_lg_lw_automute(codec);
  1783. }
  1784. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1785. static struct hda_amp_list alc880_loopbacks[] = {
  1786. { 0x0b, HDA_INPUT, 0 },
  1787. { 0x0b, HDA_INPUT, 1 },
  1788. { 0x0b, HDA_INPUT, 2 },
  1789. { 0x0b, HDA_INPUT, 3 },
  1790. { 0x0b, HDA_INPUT, 4 },
  1791. { } /* end */
  1792. };
  1793. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1794. { 0x0b, HDA_INPUT, 1 },
  1795. { 0x0b, HDA_INPUT, 6 },
  1796. { 0x0b, HDA_INPUT, 7 },
  1797. { } /* end */
  1798. };
  1799. #endif
  1800. /*
  1801. * Common callbacks
  1802. */
  1803. static int alc_init(struct hda_codec *codec)
  1804. {
  1805. struct alc_spec *spec = codec->spec;
  1806. unsigned int i;
  1807. for (i = 0; i < spec->num_init_verbs; i++)
  1808. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1809. if (spec->init_hook)
  1810. spec->init_hook(codec);
  1811. return 0;
  1812. }
  1813. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1814. {
  1815. struct alc_spec *spec = codec->spec;
  1816. if (spec->unsol_event)
  1817. spec->unsol_event(codec, res);
  1818. }
  1819. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1820. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1821. {
  1822. struct alc_spec *spec = codec->spec;
  1823. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1824. }
  1825. #endif
  1826. /*
  1827. * Analog playback callbacks
  1828. */
  1829. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1830. struct hda_codec *codec,
  1831. struct snd_pcm_substream *substream)
  1832. {
  1833. struct alc_spec *spec = codec->spec;
  1834. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1835. }
  1836. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1837. struct hda_codec *codec,
  1838. unsigned int stream_tag,
  1839. unsigned int format,
  1840. struct snd_pcm_substream *substream)
  1841. {
  1842. struct alc_spec *spec = codec->spec;
  1843. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1844. stream_tag, format, substream);
  1845. }
  1846. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1847. struct hda_codec *codec,
  1848. struct snd_pcm_substream *substream)
  1849. {
  1850. struct alc_spec *spec = codec->spec;
  1851. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1852. }
  1853. /*
  1854. * Digital out
  1855. */
  1856. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1857. struct hda_codec *codec,
  1858. struct snd_pcm_substream *substream)
  1859. {
  1860. struct alc_spec *spec = codec->spec;
  1861. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1862. }
  1863. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1864. struct hda_codec *codec,
  1865. unsigned int stream_tag,
  1866. unsigned int format,
  1867. struct snd_pcm_substream *substream)
  1868. {
  1869. struct alc_spec *spec = codec->spec;
  1870. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1871. stream_tag, format, substream);
  1872. }
  1873. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1874. struct hda_codec *codec,
  1875. struct snd_pcm_substream *substream)
  1876. {
  1877. struct alc_spec *spec = codec->spec;
  1878. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1879. }
  1880. /*
  1881. * Analog capture
  1882. */
  1883. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1884. struct hda_codec *codec,
  1885. unsigned int stream_tag,
  1886. unsigned int format,
  1887. struct snd_pcm_substream *substream)
  1888. {
  1889. struct alc_spec *spec = codec->spec;
  1890. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1891. stream_tag, 0, format);
  1892. return 0;
  1893. }
  1894. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1895. struct hda_codec *codec,
  1896. struct snd_pcm_substream *substream)
  1897. {
  1898. struct alc_spec *spec = codec->spec;
  1899. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1900. 0, 0, 0);
  1901. return 0;
  1902. }
  1903. /*
  1904. */
  1905. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1906. .substreams = 1,
  1907. .channels_min = 2,
  1908. .channels_max = 8,
  1909. /* NID is set in alc_build_pcms */
  1910. .ops = {
  1911. .open = alc880_playback_pcm_open,
  1912. .prepare = alc880_playback_pcm_prepare,
  1913. .cleanup = alc880_playback_pcm_cleanup
  1914. },
  1915. };
  1916. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1917. .substreams = 2,
  1918. .channels_min = 2,
  1919. .channels_max = 2,
  1920. /* NID is set in alc_build_pcms */
  1921. .ops = {
  1922. .prepare = alc880_capture_pcm_prepare,
  1923. .cleanup = alc880_capture_pcm_cleanup
  1924. },
  1925. };
  1926. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1927. .substreams = 1,
  1928. .channels_min = 2,
  1929. .channels_max = 2,
  1930. /* NID is set in alc_build_pcms */
  1931. .ops = {
  1932. .open = alc880_dig_playback_pcm_open,
  1933. .close = alc880_dig_playback_pcm_close,
  1934. .prepare = alc880_dig_playback_pcm_prepare
  1935. },
  1936. };
  1937. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1938. .substreams = 1,
  1939. .channels_min = 2,
  1940. .channels_max = 2,
  1941. /* NID is set in alc_build_pcms */
  1942. };
  1943. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1944. static struct hda_pcm_stream alc_pcm_null_playback = {
  1945. .substreams = 0,
  1946. .channels_min = 0,
  1947. .channels_max = 0,
  1948. };
  1949. static int alc_build_pcms(struct hda_codec *codec)
  1950. {
  1951. struct alc_spec *spec = codec->spec;
  1952. struct hda_pcm *info = spec->pcm_rec;
  1953. int i;
  1954. codec->num_pcms = 1;
  1955. codec->pcm_info = info;
  1956. info->name = spec->stream_name_analog;
  1957. if (spec->stream_analog_playback) {
  1958. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1959. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1960. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1961. }
  1962. if (spec->stream_analog_capture) {
  1963. snd_assert(spec->adc_nids, return -EINVAL);
  1964. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1965. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1966. }
  1967. if (spec->channel_mode) {
  1968. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1969. for (i = 0; i < spec->num_channel_mode; i++) {
  1970. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1971. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1972. }
  1973. }
  1974. }
  1975. /* SPDIF for stream index #1 */
  1976. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1977. codec->num_pcms = 2;
  1978. info = spec->pcm_rec + 1;
  1979. info->name = spec->stream_name_digital;
  1980. if (spec->multiout.dig_out_nid &&
  1981. spec->stream_digital_playback) {
  1982. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1983. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1984. }
  1985. if (spec->dig_in_nid &&
  1986. spec->stream_digital_capture) {
  1987. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1988. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1989. }
  1990. }
  1991. /* If the use of more than one ADC is requested for the current
  1992. * model, configure a second analog capture-only PCM.
  1993. */
  1994. /* Additional Analaog capture for index #2 */
  1995. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1996. spec->adc_nids) {
  1997. codec->num_pcms = 3;
  1998. info = spec->pcm_rec + 2;
  1999. info->name = spec->stream_name_analog;
  2000. /* No playback stream for second PCM */
  2001. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2002. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2003. if (spec->stream_analog_capture) {
  2004. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2005. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2006. }
  2007. }
  2008. return 0;
  2009. }
  2010. static void alc_free(struct hda_codec *codec)
  2011. {
  2012. struct alc_spec *spec = codec->spec;
  2013. unsigned int i;
  2014. if (!spec)
  2015. return;
  2016. if (spec->kctl_alloc) {
  2017. for (i = 0; i < spec->num_kctl_used; i++)
  2018. kfree(spec->kctl_alloc[i].name);
  2019. kfree(spec->kctl_alloc);
  2020. }
  2021. kfree(spec);
  2022. }
  2023. /*
  2024. */
  2025. static struct hda_codec_ops alc_patch_ops = {
  2026. .build_controls = alc_build_controls,
  2027. .build_pcms = alc_build_pcms,
  2028. .init = alc_init,
  2029. .free = alc_free,
  2030. .unsol_event = alc_unsol_event,
  2031. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2032. .check_power_status = alc_check_power_status,
  2033. #endif
  2034. };
  2035. /*
  2036. * Test configuration for debugging
  2037. *
  2038. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2039. * enum controls.
  2040. */
  2041. #ifdef CONFIG_SND_DEBUG
  2042. static hda_nid_t alc880_test_dac_nids[4] = {
  2043. 0x02, 0x03, 0x04, 0x05
  2044. };
  2045. static struct hda_input_mux alc880_test_capture_source = {
  2046. .num_items = 7,
  2047. .items = {
  2048. { "In-1", 0x0 },
  2049. { "In-2", 0x1 },
  2050. { "In-3", 0x2 },
  2051. { "In-4", 0x3 },
  2052. { "CD", 0x4 },
  2053. { "Front", 0x5 },
  2054. { "Surround", 0x6 },
  2055. },
  2056. };
  2057. static struct hda_channel_mode alc880_test_modes[4] = {
  2058. { 2, NULL },
  2059. { 4, NULL },
  2060. { 6, NULL },
  2061. { 8, NULL },
  2062. };
  2063. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2064. struct snd_ctl_elem_info *uinfo)
  2065. {
  2066. static char *texts[] = {
  2067. "N/A", "Line Out", "HP Out",
  2068. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2069. };
  2070. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2071. uinfo->count = 1;
  2072. uinfo->value.enumerated.items = 8;
  2073. if (uinfo->value.enumerated.item >= 8)
  2074. uinfo->value.enumerated.item = 7;
  2075. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2076. return 0;
  2077. }
  2078. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2079. struct snd_ctl_elem_value *ucontrol)
  2080. {
  2081. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2082. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2083. unsigned int pin_ctl, item = 0;
  2084. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2085. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2086. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2087. if (pin_ctl & AC_PINCTL_HP_EN)
  2088. item = 2;
  2089. else
  2090. item = 1;
  2091. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2092. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2093. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2094. case AC_PINCTL_VREF_50: item = 4; break;
  2095. case AC_PINCTL_VREF_GRD: item = 5; break;
  2096. case AC_PINCTL_VREF_80: item = 6; break;
  2097. case AC_PINCTL_VREF_100: item = 7; break;
  2098. }
  2099. }
  2100. ucontrol->value.enumerated.item[0] = item;
  2101. return 0;
  2102. }
  2103. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2104. struct snd_ctl_elem_value *ucontrol)
  2105. {
  2106. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2107. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2108. static unsigned int ctls[] = {
  2109. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2110. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2111. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2112. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2113. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2114. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2115. };
  2116. unsigned int old_ctl, new_ctl;
  2117. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2118. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2119. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2120. if (old_ctl != new_ctl) {
  2121. int val;
  2122. snd_hda_codec_write_cache(codec, nid, 0,
  2123. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2124. new_ctl);
  2125. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2126. HDA_AMP_MUTE : 0;
  2127. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2128. HDA_AMP_MUTE, val);
  2129. return 1;
  2130. }
  2131. return 0;
  2132. }
  2133. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2134. struct snd_ctl_elem_info *uinfo)
  2135. {
  2136. static char *texts[] = {
  2137. "Front", "Surround", "CLFE", "Side"
  2138. };
  2139. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2140. uinfo->count = 1;
  2141. uinfo->value.enumerated.items = 4;
  2142. if (uinfo->value.enumerated.item >= 4)
  2143. uinfo->value.enumerated.item = 3;
  2144. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2145. return 0;
  2146. }
  2147. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2148. struct snd_ctl_elem_value *ucontrol)
  2149. {
  2150. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2151. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2152. unsigned int sel;
  2153. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2154. ucontrol->value.enumerated.item[0] = sel & 3;
  2155. return 0;
  2156. }
  2157. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2158. struct snd_ctl_elem_value *ucontrol)
  2159. {
  2160. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2161. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2162. unsigned int sel;
  2163. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2164. if (ucontrol->value.enumerated.item[0] != sel) {
  2165. sel = ucontrol->value.enumerated.item[0] & 3;
  2166. snd_hda_codec_write_cache(codec, nid, 0,
  2167. AC_VERB_SET_CONNECT_SEL, sel);
  2168. return 1;
  2169. }
  2170. return 0;
  2171. }
  2172. #define PIN_CTL_TEST(xname,nid) { \
  2173. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2174. .name = xname, \
  2175. .info = alc_test_pin_ctl_info, \
  2176. .get = alc_test_pin_ctl_get, \
  2177. .put = alc_test_pin_ctl_put, \
  2178. .private_value = nid \
  2179. }
  2180. #define PIN_SRC_TEST(xname,nid) { \
  2181. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2182. .name = xname, \
  2183. .info = alc_test_pin_src_info, \
  2184. .get = alc_test_pin_src_get, \
  2185. .put = alc_test_pin_src_put, \
  2186. .private_value = nid \
  2187. }
  2188. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2189. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2190. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2191. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2192. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2193. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2194. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2195. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2196. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2197. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2198. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2199. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2200. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2201. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2202. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2203. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2204. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2205. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2206. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2207. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2208. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2209. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2210. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2211. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2212. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2213. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2214. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2215. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2216. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2217. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2218. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2219. {
  2220. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2221. .name = "Channel Mode",
  2222. .info = alc_ch_mode_info,
  2223. .get = alc_ch_mode_get,
  2224. .put = alc_ch_mode_put,
  2225. },
  2226. { } /* end */
  2227. };
  2228. static struct hda_verb alc880_test_init_verbs[] = {
  2229. /* Unmute inputs of 0x0c - 0x0f */
  2230. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2231. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2232. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2233. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2234. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2235. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2236. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2237. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2238. /* Vol output for 0x0c-0x0f */
  2239. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2240. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2241. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2242. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2243. /* Set output pins 0x14-0x17 */
  2244. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2245. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2246. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2247. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2248. /* Unmute output pins 0x14-0x17 */
  2249. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2250. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2251. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2252. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2253. /* Set input pins 0x18-0x1c */
  2254. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2255. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2256. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2257. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2258. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2259. /* Mute input pins 0x18-0x1b */
  2260. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2261. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2262. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2263. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2264. /* ADC set up */
  2265. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2266. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2267. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2268. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2269. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2270. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2271. /* Analog input/passthru */
  2272. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2273. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2274. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2275. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2276. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2277. { }
  2278. };
  2279. #endif
  2280. /*
  2281. */
  2282. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2283. [ALC880_3ST] = "3stack",
  2284. [ALC880_TCL_S700] = "tcl",
  2285. [ALC880_3ST_DIG] = "3stack-digout",
  2286. [ALC880_CLEVO] = "clevo",
  2287. [ALC880_5ST] = "5stack",
  2288. [ALC880_5ST_DIG] = "5stack-digout",
  2289. [ALC880_W810] = "w810",
  2290. [ALC880_Z71V] = "z71v",
  2291. [ALC880_6ST] = "6stack",
  2292. [ALC880_6ST_DIG] = "6stack-digout",
  2293. [ALC880_ASUS] = "asus",
  2294. [ALC880_ASUS_W1V] = "asus-w1v",
  2295. [ALC880_ASUS_DIG] = "asus-dig",
  2296. [ALC880_ASUS_DIG2] = "asus-dig2",
  2297. [ALC880_UNIWILL_DIG] = "uniwill",
  2298. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2299. [ALC880_FUJITSU] = "fujitsu",
  2300. [ALC880_F1734] = "F1734",
  2301. [ALC880_LG] = "lg",
  2302. [ALC880_LG_LW] = "lg-lw",
  2303. #ifdef CONFIG_SND_DEBUG
  2304. [ALC880_TEST] = "test",
  2305. #endif
  2306. [ALC880_AUTO] = "auto",
  2307. };
  2308. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2309. /* Broken BIOS configuration */
  2310. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2311. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2312. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2313. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2314. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2315. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2316. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2317. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2318. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2319. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2320. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2321. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2322. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2323. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2324. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2325. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2326. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2327. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2328. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2329. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2330. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2331. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2332. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2333. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2334. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2335. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2336. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2337. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2338. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2339. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2340. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2341. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2342. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2343. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2344. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2345. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2346. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2347. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2348. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2349. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2350. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2351. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2352. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2353. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2354. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2355. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2356. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2357. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2358. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2359. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2360. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2361. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2362. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2363. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2364. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2365. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2366. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2367. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2368. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2369. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2370. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2371. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2372. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2373. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2374. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2375. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2376. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2377. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2378. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2379. {}
  2380. };
  2381. /*
  2382. * ALC880 codec presets
  2383. */
  2384. static struct alc_config_preset alc880_presets[] = {
  2385. [ALC880_3ST] = {
  2386. .mixers = { alc880_three_stack_mixer },
  2387. .init_verbs = { alc880_volume_init_verbs,
  2388. alc880_pin_3stack_init_verbs },
  2389. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2390. .dac_nids = alc880_dac_nids,
  2391. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2392. .channel_mode = alc880_threestack_modes,
  2393. .need_dac_fix = 1,
  2394. .input_mux = &alc880_capture_source,
  2395. },
  2396. [ALC880_3ST_DIG] = {
  2397. .mixers = { alc880_three_stack_mixer },
  2398. .init_verbs = { alc880_volume_init_verbs,
  2399. alc880_pin_3stack_init_verbs },
  2400. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2401. .dac_nids = alc880_dac_nids,
  2402. .dig_out_nid = ALC880_DIGOUT_NID,
  2403. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2404. .channel_mode = alc880_threestack_modes,
  2405. .need_dac_fix = 1,
  2406. .input_mux = &alc880_capture_source,
  2407. },
  2408. [ALC880_TCL_S700] = {
  2409. .mixers = { alc880_tcl_s700_mixer },
  2410. .init_verbs = { alc880_volume_init_verbs,
  2411. alc880_pin_tcl_S700_init_verbs,
  2412. alc880_gpio2_init_verbs },
  2413. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2414. .dac_nids = alc880_dac_nids,
  2415. .hp_nid = 0x03,
  2416. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2417. .channel_mode = alc880_2_jack_modes,
  2418. .input_mux = &alc880_capture_source,
  2419. },
  2420. [ALC880_5ST] = {
  2421. .mixers = { alc880_three_stack_mixer,
  2422. alc880_five_stack_mixer},
  2423. .init_verbs = { alc880_volume_init_verbs,
  2424. alc880_pin_5stack_init_verbs },
  2425. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2426. .dac_nids = alc880_dac_nids,
  2427. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2428. .channel_mode = alc880_fivestack_modes,
  2429. .input_mux = &alc880_capture_source,
  2430. },
  2431. [ALC880_5ST_DIG] = {
  2432. .mixers = { alc880_three_stack_mixer,
  2433. alc880_five_stack_mixer },
  2434. .init_verbs = { alc880_volume_init_verbs,
  2435. alc880_pin_5stack_init_verbs },
  2436. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2437. .dac_nids = alc880_dac_nids,
  2438. .dig_out_nid = ALC880_DIGOUT_NID,
  2439. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2440. .channel_mode = alc880_fivestack_modes,
  2441. .input_mux = &alc880_capture_source,
  2442. },
  2443. [ALC880_6ST] = {
  2444. .mixers = { alc880_six_stack_mixer },
  2445. .init_verbs = { alc880_volume_init_verbs,
  2446. alc880_pin_6stack_init_verbs },
  2447. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2448. .dac_nids = alc880_6st_dac_nids,
  2449. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2450. .channel_mode = alc880_sixstack_modes,
  2451. .input_mux = &alc880_6stack_capture_source,
  2452. },
  2453. [ALC880_6ST_DIG] = {
  2454. .mixers = { alc880_six_stack_mixer },
  2455. .init_verbs = { alc880_volume_init_verbs,
  2456. alc880_pin_6stack_init_verbs },
  2457. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2458. .dac_nids = alc880_6st_dac_nids,
  2459. .dig_out_nid = ALC880_DIGOUT_NID,
  2460. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2461. .channel_mode = alc880_sixstack_modes,
  2462. .input_mux = &alc880_6stack_capture_source,
  2463. },
  2464. [ALC880_W810] = {
  2465. .mixers = { alc880_w810_base_mixer },
  2466. .init_verbs = { alc880_volume_init_verbs,
  2467. alc880_pin_w810_init_verbs,
  2468. alc880_gpio2_init_verbs },
  2469. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2470. .dac_nids = alc880_w810_dac_nids,
  2471. .dig_out_nid = ALC880_DIGOUT_NID,
  2472. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2473. .channel_mode = alc880_w810_modes,
  2474. .input_mux = &alc880_capture_source,
  2475. },
  2476. [ALC880_Z71V] = {
  2477. .mixers = { alc880_z71v_mixer },
  2478. .init_verbs = { alc880_volume_init_verbs,
  2479. alc880_pin_z71v_init_verbs },
  2480. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2481. .dac_nids = alc880_z71v_dac_nids,
  2482. .dig_out_nid = ALC880_DIGOUT_NID,
  2483. .hp_nid = 0x03,
  2484. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2485. .channel_mode = alc880_2_jack_modes,
  2486. .input_mux = &alc880_capture_source,
  2487. },
  2488. [ALC880_F1734] = {
  2489. .mixers = { alc880_f1734_mixer },
  2490. .init_verbs = { alc880_volume_init_verbs,
  2491. alc880_pin_f1734_init_verbs },
  2492. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2493. .dac_nids = alc880_f1734_dac_nids,
  2494. .hp_nid = 0x02,
  2495. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2496. .channel_mode = alc880_2_jack_modes,
  2497. .input_mux = &alc880_capture_source,
  2498. },
  2499. [ALC880_ASUS] = {
  2500. .mixers = { alc880_asus_mixer },
  2501. .init_verbs = { alc880_volume_init_verbs,
  2502. alc880_pin_asus_init_verbs,
  2503. alc880_gpio1_init_verbs },
  2504. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2505. .dac_nids = alc880_asus_dac_nids,
  2506. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2507. .channel_mode = alc880_asus_modes,
  2508. .need_dac_fix = 1,
  2509. .input_mux = &alc880_capture_source,
  2510. },
  2511. [ALC880_ASUS_DIG] = {
  2512. .mixers = { alc880_asus_mixer },
  2513. .init_verbs = { alc880_volume_init_verbs,
  2514. alc880_pin_asus_init_verbs,
  2515. alc880_gpio1_init_verbs },
  2516. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2517. .dac_nids = alc880_asus_dac_nids,
  2518. .dig_out_nid = ALC880_DIGOUT_NID,
  2519. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2520. .channel_mode = alc880_asus_modes,
  2521. .need_dac_fix = 1,
  2522. .input_mux = &alc880_capture_source,
  2523. },
  2524. [ALC880_ASUS_DIG2] = {
  2525. .mixers = { alc880_asus_mixer },
  2526. .init_verbs = { alc880_volume_init_verbs,
  2527. alc880_pin_asus_init_verbs,
  2528. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2529. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2530. .dac_nids = alc880_asus_dac_nids,
  2531. .dig_out_nid = ALC880_DIGOUT_NID,
  2532. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2533. .channel_mode = alc880_asus_modes,
  2534. .need_dac_fix = 1,
  2535. .input_mux = &alc880_capture_source,
  2536. },
  2537. [ALC880_ASUS_W1V] = {
  2538. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2539. .init_verbs = { alc880_volume_init_verbs,
  2540. alc880_pin_asus_init_verbs,
  2541. alc880_gpio1_init_verbs },
  2542. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2543. .dac_nids = alc880_asus_dac_nids,
  2544. .dig_out_nid = ALC880_DIGOUT_NID,
  2545. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2546. .channel_mode = alc880_asus_modes,
  2547. .need_dac_fix = 1,
  2548. .input_mux = &alc880_capture_source,
  2549. },
  2550. [ALC880_UNIWILL_DIG] = {
  2551. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2552. .init_verbs = { alc880_volume_init_verbs,
  2553. alc880_pin_asus_init_verbs },
  2554. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2555. .dac_nids = alc880_asus_dac_nids,
  2556. .dig_out_nid = ALC880_DIGOUT_NID,
  2557. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2558. .channel_mode = alc880_asus_modes,
  2559. .need_dac_fix = 1,
  2560. .input_mux = &alc880_capture_source,
  2561. },
  2562. [ALC880_UNIWILL] = {
  2563. .mixers = { alc880_uniwill_mixer },
  2564. .init_verbs = { alc880_volume_init_verbs,
  2565. alc880_uniwill_init_verbs },
  2566. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2567. .dac_nids = alc880_asus_dac_nids,
  2568. .dig_out_nid = ALC880_DIGOUT_NID,
  2569. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2570. .channel_mode = alc880_threestack_modes,
  2571. .need_dac_fix = 1,
  2572. .input_mux = &alc880_capture_source,
  2573. .unsol_event = alc880_uniwill_unsol_event,
  2574. .init_hook = alc880_uniwill_automute,
  2575. },
  2576. [ALC880_UNIWILL_P53] = {
  2577. .mixers = { alc880_uniwill_p53_mixer },
  2578. .init_verbs = { alc880_volume_init_verbs,
  2579. alc880_uniwill_p53_init_verbs },
  2580. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2581. .dac_nids = alc880_asus_dac_nids,
  2582. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2583. .channel_mode = alc880_threestack_modes,
  2584. .input_mux = &alc880_capture_source,
  2585. .unsol_event = alc880_uniwill_p53_unsol_event,
  2586. .init_hook = alc880_uniwill_p53_hp_automute,
  2587. },
  2588. [ALC880_FUJITSU] = {
  2589. .mixers = { alc880_fujitsu_mixer,
  2590. alc880_pcbeep_mixer, },
  2591. .init_verbs = { alc880_volume_init_verbs,
  2592. alc880_uniwill_p53_init_verbs,
  2593. alc880_beep_init_verbs },
  2594. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2595. .dac_nids = alc880_dac_nids,
  2596. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2597. .channel_mode = alc880_2_jack_modes,
  2598. .input_mux = &alc880_capture_source,
  2599. .unsol_event = alc880_uniwill_p53_unsol_event,
  2600. .init_hook = alc880_uniwill_p53_hp_automute,
  2601. },
  2602. [ALC880_CLEVO] = {
  2603. .mixers = { alc880_three_stack_mixer },
  2604. .init_verbs = { alc880_volume_init_verbs,
  2605. alc880_pin_clevo_init_verbs },
  2606. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2607. .dac_nids = alc880_dac_nids,
  2608. .hp_nid = 0x03,
  2609. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2610. .channel_mode = alc880_threestack_modes,
  2611. .need_dac_fix = 1,
  2612. .input_mux = &alc880_capture_source,
  2613. },
  2614. [ALC880_LG] = {
  2615. .mixers = { alc880_lg_mixer },
  2616. .init_verbs = { alc880_volume_init_verbs,
  2617. alc880_lg_init_verbs },
  2618. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2619. .dac_nids = alc880_lg_dac_nids,
  2620. .dig_out_nid = ALC880_DIGOUT_NID,
  2621. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2622. .channel_mode = alc880_lg_ch_modes,
  2623. .need_dac_fix = 1,
  2624. .input_mux = &alc880_lg_capture_source,
  2625. .unsol_event = alc880_lg_unsol_event,
  2626. .init_hook = alc880_lg_automute,
  2627. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2628. .loopbacks = alc880_lg_loopbacks,
  2629. #endif
  2630. },
  2631. [ALC880_LG_LW] = {
  2632. .mixers = { alc880_lg_lw_mixer },
  2633. .init_verbs = { alc880_volume_init_verbs,
  2634. alc880_lg_lw_init_verbs },
  2635. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2636. .dac_nids = alc880_dac_nids,
  2637. .dig_out_nid = ALC880_DIGOUT_NID,
  2638. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2639. .channel_mode = alc880_lg_lw_modes,
  2640. .input_mux = &alc880_lg_lw_capture_source,
  2641. .unsol_event = alc880_lg_lw_unsol_event,
  2642. .init_hook = alc880_lg_lw_automute,
  2643. },
  2644. #ifdef CONFIG_SND_DEBUG
  2645. [ALC880_TEST] = {
  2646. .mixers = { alc880_test_mixer },
  2647. .init_verbs = { alc880_test_init_verbs },
  2648. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2649. .dac_nids = alc880_test_dac_nids,
  2650. .dig_out_nid = ALC880_DIGOUT_NID,
  2651. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2652. .channel_mode = alc880_test_modes,
  2653. .input_mux = &alc880_test_capture_source,
  2654. },
  2655. #endif
  2656. };
  2657. /*
  2658. * Automatic parse of I/O pins from the BIOS configuration
  2659. */
  2660. #define NUM_CONTROL_ALLOC 32
  2661. #define NUM_VERB_ALLOC 32
  2662. enum {
  2663. ALC_CTL_WIDGET_VOL,
  2664. ALC_CTL_WIDGET_MUTE,
  2665. ALC_CTL_BIND_MUTE,
  2666. };
  2667. static struct snd_kcontrol_new alc880_control_templates[] = {
  2668. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2669. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2670. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2671. };
  2672. /* add dynamic controls */
  2673. static int add_control(struct alc_spec *spec, int type, const char *name,
  2674. unsigned long val)
  2675. {
  2676. struct snd_kcontrol_new *knew;
  2677. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2678. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2679. /* array + terminator */
  2680. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2681. if (!knew)
  2682. return -ENOMEM;
  2683. if (spec->kctl_alloc) {
  2684. memcpy(knew, spec->kctl_alloc,
  2685. sizeof(*knew) * spec->num_kctl_alloc);
  2686. kfree(spec->kctl_alloc);
  2687. }
  2688. spec->kctl_alloc = knew;
  2689. spec->num_kctl_alloc = num;
  2690. }
  2691. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2692. *knew = alc880_control_templates[type];
  2693. knew->name = kstrdup(name, GFP_KERNEL);
  2694. if (!knew->name)
  2695. return -ENOMEM;
  2696. knew->private_value = val;
  2697. spec->num_kctl_used++;
  2698. return 0;
  2699. }
  2700. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2701. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2702. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2703. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2704. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2705. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2706. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2707. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2708. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2709. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2710. #define ALC880_PIN_CD_NID 0x1c
  2711. /* fill in the dac_nids table from the parsed pin configuration */
  2712. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2713. const struct auto_pin_cfg *cfg)
  2714. {
  2715. hda_nid_t nid;
  2716. int assigned[4];
  2717. int i, j;
  2718. memset(assigned, 0, sizeof(assigned));
  2719. spec->multiout.dac_nids = spec->private_dac_nids;
  2720. /* check the pins hardwired to audio widget */
  2721. for (i = 0; i < cfg->line_outs; i++) {
  2722. nid = cfg->line_out_pins[i];
  2723. if (alc880_is_fixed_pin(nid)) {
  2724. int idx = alc880_fixed_pin_idx(nid);
  2725. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2726. assigned[idx] = 1;
  2727. }
  2728. }
  2729. /* left pins can be connect to any audio widget */
  2730. for (i = 0; i < cfg->line_outs; i++) {
  2731. nid = cfg->line_out_pins[i];
  2732. if (alc880_is_fixed_pin(nid))
  2733. continue;
  2734. /* search for an empty channel */
  2735. for (j = 0; j < cfg->line_outs; j++) {
  2736. if (!assigned[j]) {
  2737. spec->multiout.dac_nids[i] =
  2738. alc880_idx_to_dac(j);
  2739. assigned[j] = 1;
  2740. break;
  2741. }
  2742. }
  2743. }
  2744. spec->multiout.num_dacs = cfg->line_outs;
  2745. return 0;
  2746. }
  2747. /* add playback controls from the parsed DAC table */
  2748. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2749. const struct auto_pin_cfg *cfg)
  2750. {
  2751. char name[32];
  2752. static const char *chname[4] = {
  2753. "Front", "Surround", NULL /*CLFE*/, "Side"
  2754. };
  2755. hda_nid_t nid;
  2756. int i, err;
  2757. for (i = 0; i < cfg->line_outs; i++) {
  2758. if (!spec->multiout.dac_nids[i])
  2759. continue;
  2760. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2761. if (i == 2) {
  2762. /* Center/LFE */
  2763. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2764. "Center Playback Volume",
  2765. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2766. HDA_OUTPUT));
  2767. if (err < 0)
  2768. return err;
  2769. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2770. "LFE Playback Volume",
  2771. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2772. HDA_OUTPUT));
  2773. if (err < 0)
  2774. return err;
  2775. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2776. "Center Playback Switch",
  2777. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2778. HDA_INPUT));
  2779. if (err < 0)
  2780. return err;
  2781. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2782. "LFE Playback Switch",
  2783. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2784. HDA_INPUT));
  2785. if (err < 0)
  2786. return err;
  2787. } else {
  2788. sprintf(name, "%s Playback Volume", chname[i]);
  2789. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2790. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2791. HDA_OUTPUT));
  2792. if (err < 0)
  2793. return err;
  2794. sprintf(name, "%s Playback Switch", chname[i]);
  2795. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2796. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2797. HDA_INPUT));
  2798. if (err < 0)
  2799. return err;
  2800. }
  2801. }
  2802. return 0;
  2803. }
  2804. /* add playback controls for speaker and HP outputs */
  2805. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2806. const char *pfx)
  2807. {
  2808. hda_nid_t nid;
  2809. int err;
  2810. char name[32];
  2811. if (!pin)
  2812. return 0;
  2813. if (alc880_is_fixed_pin(pin)) {
  2814. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2815. /* specify the DAC as the extra output */
  2816. if (!spec->multiout.hp_nid)
  2817. spec->multiout.hp_nid = nid;
  2818. else
  2819. spec->multiout.extra_out_nid[0] = nid;
  2820. /* control HP volume/switch on the output mixer amp */
  2821. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2822. sprintf(name, "%s Playback Volume", pfx);
  2823. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2824. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2825. if (err < 0)
  2826. return err;
  2827. sprintf(name, "%s Playback Switch", pfx);
  2828. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2829. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2830. if (err < 0)
  2831. return err;
  2832. } else if (alc880_is_multi_pin(pin)) {
  2833. /* set manual connection */
  2834. /* we have only a switch on HP-out PIN */
  2835. sprintf(name, "%s Playback Switch", pfx);
  2836. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2837. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2838. if (err < 0)
  2839. return err;
  2840. }
  2841. return 0;
  2842. }
  2843. /* create input playback/capture controls for the given pin */
  2844. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2845. const char *ctlname,
  2846. int idx, hda_nid_t mix_nid)
  2847. {
  2848. char name[32];
  2849. int err;
  2850. sprintf(name, "%s Playback Volume", ctlname);
  2851. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2852. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2853. if (err < 0)
  2854. return err;
  2855. sprintf(name, "%s Playback Switch", ctlname);
  2856. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2857. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2858. if (err < 0)
  2859. return err;
  2860. return 0;
  2861. }
  2862. /* create playback/capture controls for input pins */
  2863. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2864. const struct auto_pin_cfg *cfg)
  2865. {
  2866. struct hda_input_mux *imux = &spec->private_imux;
  2867. int i, err, idx;
  2868. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2869. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2870. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2871. err = new_analog_input(spec, cfg->input_pins[i],
  2872. auto_pin_cfg_labels[i],
  2873. idx, 0x0b);
  2874. if (err < 0)
  2875. return err;
  2876. imux->items[imux->num_items].label =
  2877. auto_pin_cfg_labels[i];
  2878. imux->items[imux->num_items].index =
  2879. alc880_input_pin_idx(cfg->input_pins[i]);
  2880. imux->num_items++;
  2881. }
  2882. }
  2883. return 0;
  2884. }
  2885. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2886. hda_nid_t nid, int pin_type,
  2887. int dac_idx)
  2888. {
  2889. /* set as output */
  2890. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2891. pin_type);
  2892. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2893. AMP_OUT_UNMUTE);
  2894. /* need the manual connection? */
  2895. if (alc880_is_multi_pin(nid)) {
  2896. struct alc_spec *spec = codec->spec;
  2897. int idx = alc880_multi_pin_idx(nid);
  2898. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2899. AC_VERB_SET_CONNECT_SEL,
  2900. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2901. }
  2902. }
  2903. static int get_pin_type(int line_out_type)
  2904. {
  2905. if (line_out_type == AUTO_PIN_HP_OUT)
  2906. return PIN_HP;
  2907. else
  2908. return PIN_OUT;
  2909. }
  2910. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2911. {
  2912. struct alc_spec *spec = codec->spec;
  2913. int i;
  2914. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2915. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2916. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2917. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2918. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2919. }
  2920. }
  2921. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2922. {
  2923. struct alc_spec *spec = codec->spec;
  2924. hda_nid_t pin;
  2925. pin = spec->autocfg.speaker_pins[0];
  2926. if (pin) /* connect to front */
  2927. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2928. pin = spec->autocfg.hp_pins[0];
  2929. if (pin) /* connect to front */
  2930. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2931. }
  2932. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2933. {
  2934. struct alc_spec *spec = codec->spec;
  2935. int i;
  2936. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2937. hda_nid_t nid = spec->autocfg.input_pins[i];
  2938. if (alc880_is_input_pin(nid)) {
  2939. snd_hda_codec_write(codec, nid, 0,
  2940. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2941. i <= AUTO_PIN_FRONT_MIC ?
  2942. PIN_VREF80 : PIN_IN);
  2943. if (nid != ALC880_PIN_CD_NID)
  2944. snd_hda_codec_write(codec, nid, 0,
  2945. AC_VERB_SET_AMP_GAIN_MUTE,
  2946. AMP_OUT_MUTE);
  2947. }
  2948. }
  2949. }
  2950. /* parse the BIOS configuration and set up the alc_spec */
  2951. /* return 1 if successful, 0 if the proper config is not found,
  2952. * or a negative error code
  2953. */
  2954. static int alc880_parse_auto_config(struct hda_codec *codec)
  2955. {
  2956. struct alc_spec *spec = codec->spec;
  2957. int err;
  2958. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2959. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2960. alc880_ignore);
  2961. if (err < 0)
  2962. return err;
  2963. if (!spec->autocfg.line_outs)
  2964. return 0; /* can't find valid BIOS pin config */
  2965. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2966. if (err < 0)
  2967. return err;
  2968. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2969. if (err < 0)
  2970. return err;
  2971. err = alc880_auto_create_extra_out(spec,
  2972. spec->autocfg.speaker_pins[0],
  2973. "Speaker");
  2974. if (err < 0)
  2975. return err;
  2976. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2977. "Headphone");
  2978. if (err < 0)
  2979. return err;
  2980. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2981. if (err < 0)
  2982. return err;
  2983. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2984. if (spec->autocfg.dig_out_pin)
  2985. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2986. if (spec->autocfg.dig_in_pin)
  2987. spec->dig_in_nid = ALC880_DIGIN_NID;
  2988. if (spec->kctl_alloc)
  2989. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2990. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2991. spec->num_mux_defs = 1;
  2992. spec->input_mux = &spec->private_imux;
  2993. return 1;
  2994. }
  2995. /* additional initialization for auto-configuration model */
  2996. static void alc880_auto_init(struct hda_codec *codec)
  2997. {
  2998. alc880_auto_init_multi_out(codec);
  2999. alc880_auto_init_extra_out(codec);
  3000. alc880_auto_init_analog_input(codec);
  3001. }
  3002. /*
  3003. * OK, here we have finally the patch for ALC880
  3004. */
  3005. static int patch_alc880(struct hda_codec *codec)
  3006. {
  3007. struct alc_spec *spec;
  3008. int board_config;
  3009. int err;
  3010. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3011. if (spec == NULL)
  3012. return -ENOMEM;
  3013. codec->spec = spec;
  3014. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3015. alc880_models,
  3016. alc880_cfg_tbl);
  3017. if (board_config < 0) {
  3018. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3019. "trying auto-probe from BIOS...\n");
  3020. board_config = ALC880_AUTO;
  3021. }
  3022. if (board_config == ALC880_AUTO) {
  3023. /* automatic parse from the BIOS config */
  3024. err = alc880_parse_auto_config(codec);
  3025. if (err < 0) {
  3026. alc_free(codec);
  3027. return err;
  3028. } else if (!err) {
  3029. printk(KERN_INFO
  3030. "hda_codec: Cannot set up configuration "
  3031. "from BIOS. Using 3-stack mode...\n");
  3032. board_config = ALC880_3ST;
  3033. }
  3034. }
  3035. if (board_config != ALC880_AUTO)
  3036. setup_preset(spec, &alc880_presets[board_config]);
  3037. spec->stream_name_analog = "ALC880 Analog";
  3038. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3039. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3040. spec->stream_name_digital = "ALC880 Digital";
  3041. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3042. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3043. if (!spec->adc_nids && spec->input_mux) {
  3044. /* check whether NID 0x07 is valid */
  3045. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3046. /* get type */
  3047. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3048. if (wcap != AC_WID_AUD_IN) {
  3049. spec->adc_nids = alc880_adc_nids_alt;
  3050. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3051. spec->mixers[spec->num_mixers] =
  3052. alc880_capture_alt_mixer;
  3053. spec->num_mixers++;
  3054. } else {
  3055. spec->adc_nids = alc880_adc_nids;
  3056. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3057. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3058. spec->num_mixers++;
  3059. }
  3060. }
  3061. codec->patch_ops = alc_patch_ops;
  3062. if (board_config == ALC880_AUTO)
  3063. spec->init_hook = alc880_auto_init;
  3064. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3065. if (!spec->loopback.amplist)
  3066. spec->loopback.amplist = alc880_loopbacks;
  3067. #endif
  3068. return 0;
  3069. }
  3070. /*
  3071. * ALC260 support
  3072. */
  3073. static hda_nid_t alc260_dac_nids[1] = {
  3074. /* front */
  3075. 0x02,
  3076. };
  3077. static hda_nid_t alc260_adc_nids[1] = {
  3078. /* ADC0 */
  3079. 0x04,
  3080. };
  3081. static hda_nid_t alc260_adc_nids_alt[1] = {
  3082. /* ADC1 */
  3083. 0x05,
  3084. };
  3085. static hda_nid_t alc260_hp_adc_nids[2] = {
  3086. /* ADC1, 0 */
  3087. 0x05, 0x04
  3088. };
  3089. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3090. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3091. */
  3092. static hda_nid_t alc260_dual_adc_nids[2] = {
  3093. /* ADC0, ADC1 */
  3094. 0x04, 0x05
  3095. };
  3096. #define ALC260_DIGOUT_NID 0x03
  3097. #define ALC260_DIGIN_NID 0x06
  3098. static struct hda_input_mux alc260_capture_source = {
  3099. .num_items = 4,
  3100. .items = {
  3101. { "Mic", 0x0 },
  3102. { "Front Mic", 0x1 },
  3103. { "Line", 0x2 },
  3104. { "CD", 0x4 },
  3105. },
  3106. };
  3107. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3108. * headphone jack and the internal CD lines since these are the only pins at
  3109. * which audio can appear. For flexibility, also allow the option of
  3110. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3111. * connection to the mixer output).
  3112. */
  3113. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3114. {
  3115. .num_items = 3,
  3116. .items = {
  3117. { "Mic/Line", 0x0 },
  3118. { "CD", 0x4 },
  3119. { "Headphone", 0x2 },
  3120. },
  3121. },
  3122. {
  3123. .num_items = 4,
  3124. .items = {
  3125. { "Mic/Line", 0x0 },
  3126. { "CD", 0x4 },
  3127. { "Headphone", 0x2 },
  3128. { "Mixer", 0x5 },
  3129. },
  3130. },
  3131. };
  3132. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3133. * the Fujitsu S702x, but jacks are marked differently.
  3134. */
  3135. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3136. {
  3137. .num_items = 4,
  3138. .items = {
  3139. { "Mic", 0x0 },
  3140. { "Line", 0x2 },
  3141. { "CD", 0x4 },
  3142. { "Headphone", 0x5 },
  3143. },
  3144. },
  3145. {
  3146. .num_items = 5,
  3147. .items = {
  3148. { "Mic", 0x0 },
  3149. { "Line", 0x2 },
  3150. { "CD", 0x4 },
  3151. { "Headphone", 0x6 },
  3152. { "Mixer", 0x5 },
  3153. },
  3154. },
  3155. };
  3156. /*
  3157. * This is just place-holder, so there's something for alc_build_pcms to look
  3158. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3159. * element which allows changing the channel mode, so the verb list is
  3160. * never used.
  3161. */
  3162. static struct hda_channel_mode alc260_modes[1] = {
  3163. { 2, NULL },
  3164. };
  3165. /* Mixer combinations
  3166. *
  3167. * basic: base_output + input + pc_beep + capture
  3168. * HP: base_output + input + capture_alt
  3169. * HP_3013: hp_3013 + input + capture
  3170. * fujitsu: fujitsu + capture
  3171. * acer: acer + capture
  3172. */
  3173. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3174. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3175. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3176. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3177. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3178. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3179. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3180. { } /* end */
  3181. };
  3182. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3183. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3184. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3185. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3186. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3187. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3188. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3189. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3190. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3191. { } /* end */
  3192. };
  3193. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3194. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3195. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3196. { } /* end */
  3197. };
  3198. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3199. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3200. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3201. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3202. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3203. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3204. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3205. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3206. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3207. { } /* end */
  3208. };
  3209. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3210. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3211. */
  3212. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3213. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3214. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3215. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3216. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3217. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3218. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3219. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3220. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3221. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3222. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3223. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3224. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3225. { } /* end */
  3226. };
  3227. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3228. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3229. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3230. * datasheet doesn't mention this restriction. At this stage it's not clear
  3231. * whether this behaviour is intentional or is a hardware bug in chip
  3232. * revisions available in early 2006. Therefore for now allow the
  3233. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3234. * that the lack of mic bias for this NID is intentional we could change the
  3235. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3236. *
  3237. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3238. * don't appear to make the mic bias available from the "line" jack, even
  3239. * though the NID used for this jack (0x14) can supply it. The theory is
  3240. * that perhaps Acer have included blocking capacitors between the ALC260
  3241. * and the output jack. If this turns out to be the case for all such
  3242. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3243. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3244. *
  3245. * The C20x Tablet series have a mono internal speaker which is controlled
  3246. * via the chip's Mono sum widget and pin complex, so include the necessary
  3247. * controls for such models. On models without a "mono speaker" the control
  3248. * won't do anything.
  3249. */
  3250. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3251. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3252. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3253. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3254. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3255. HDA_OUTPUT),
  3256. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3257. HDA_INPUT),
  3258. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3259. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3260. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3261. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3262. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3263. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3264. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3265. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3266. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3267. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3268. { } /* end */
  3269. };
  3270. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3271. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3272. */
  3273. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3274. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3275. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3276. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3277. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3278. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3279. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3280. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3281. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3282. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3283. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3284. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3285. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3286. { } /* end */
  3287. };
  3288. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3289. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3290. */
  3291. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3292. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3293. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3294. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3295. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3296. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3297. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3298. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3299. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3300. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3301. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3302. { } /* end */
  3303. };
  3304. /* capture mixer elements */
  3305. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3306. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3307. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3308. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3309. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3310. {
  3311. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3312. /* The multiple "Capture Source" controls confuse alsamixer
  3313. * So call somewhat different..
  3314. * FIXME: the controls appear in the "playback" view!
  3315. */
  3316. /* .name = "Capture Source", */
  3317. .name = "Input Source",
  3318. .count = 2,
  3319. .info = alc_mux_enum_info,
  3320. .get = alc_mux_enum_get,
  3321. .put = alc_mux_enum_put,
  3322. },
  3323. { } /* end */
  3324. };
  3325. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3326. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3327. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3328. {
  3329. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3330. /* The multiple "Capture Source" controls confuse alsamixer
  3331. * So call somewhat different..
  3332. * FIXME: the controls appear in the "playback" view!
  3333. */
  3334. /* .name = "Capture Source", */
  3335. .name = "Input Source",
  3336. .count = 1,
  3337. .info = alc_mux_enum_info,
  3338. .get = alc_mux_enum_get,
  3339. .put = alc_mux_enum_put,
  3340. },
  3341. { } /* end */
  3342. };
  3343. /*
  3344. * initialization verbs
  3345. */
  3346. static struct hda_verb alc260_init_verbs[] = {
  3347. /* Line In pin widget for input */
  3348. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3349. /* CD pin widget for input */
  3350. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3351. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3352. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3353. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3354. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3355. /* LINE-2 is used for line-out in rear */
  3356. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3357. /* select line-out */
  3358. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3359. /* LINE-OUT pin */
  3360. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3361. /* enable HP */
  3362. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3363. /* enable Mono */
  3364. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3365. /* mute capture amp left and right */
  3366. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3367. /* set connection select to line in (default select for this ADC) */
  3368. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3369. /* mute capture amp left and right */
  3370. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3371. /* set connection select to line in (default select for this ADC) */
  3372. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3373. /* set vol=0 Line-Out mixer amp left and right */
  3374. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3375. /* unmute pin widget amp left and right (no gain on this amp) */
  3376. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3377. /* set vol=0 HP mixer amp left and right */
  3378. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3379. /* unmute pin widget amp left and right (no gain on this amp) */
  3380. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3381. /* set vol=0 Mono mixer amp left and right */
  3382. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3383. /* unmute pin widget amp left and right (no gain on this amp) */
  3384. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3385. /* unmute LINE-2 out pin */
  3386. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3387. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3388. * Line In 2 = 0x03
  3389. */
  3390. /* mute analog inputs */
  3391. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3392. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3393. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3394. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3395. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3396. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3397. /* mute Front out path */
  3398. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3399. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3400. /* mute Headphone out path */
  3401. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3402. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3403. /* mute Mono out path */
  3404. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3405. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3406. { }
  3407. };
  3408. #if 0 /* should be identical with alc260_init_verbs? */
  3409. static struct hda_verb alc260_hp_init_verbs[] = {
  3410. /* Headphone and output */
  3411. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3412. /* mono output */
  3413. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3414. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3415. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3416. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3417. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3418. /* Line In pin widget for input */
  3419. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3420. /* Line-2 pin widget for output */
  3421. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3422. /* CD pin widget for input */
  3423. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3424. /* unmute amp left and right */
  3425. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3426. /* set connection select to line in (default select for this ADC) */
  3427. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3428. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3429. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3430. /* mute pin widget amp left and right (no gain on this amp) */
  3431. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3432. /* unmute HP mixer amp left and right (volume = 0) */
  3433. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3434. /* mute pin widget amp left and right (no gain on this amp) */
  3435. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3436. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3437. * Line In 2 = 0x03
  3438. */
  3439. /* mute analog inputs */
  3440. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3441. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3442. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3443. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3444. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3445. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3446. /* Unmute Front out path */
  3447. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3448. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3449. /* Unmute Headphone out path */
  3450. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3451. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3452. /* Unmute Mono out path */
  3453. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3454. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3455. { }
  3456. };
  3457. #endif
  3458. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3459. /* Line out and output */
  3460. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3461. /* mono output */
  3462. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3463. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3464. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3465. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3466. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3467. /* Line In pin widget for input */
  3468. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3469. /* Headphone pin widget for output */
  3470. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3471. /* CD pin widget for input */
  3472. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3473. /* unmute amp left and right */
  3474. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3475. /* set connection select to line in (default select for this ADC) */
  3476. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3477. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3478. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3479. /* mute pin widget amp left and right (no gain on this amp) */
  3480. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3481. /* unmute HP mixer amp left and right (volume = 0) */
  3482. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3483. /* mute pin widget amp left and right (no gain on this amp) */
  3484. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3485. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3486. * Line In 2 = 0x03
  3487. */
  3488. /* mute analog inputs */
  3489. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3490. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3491. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3492. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3493. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3494. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3495. /* Unmute Front out path */
  3496. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3497. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3498. /* Unmute Headphone out path */
  3499. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3500. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3501. /* Unmute Mono out path */
  3502. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3503. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3504. { }
  3505. };
  3506. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3507. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3508. * audio = 0x16, internal speaker = 0x10.
  3509. */
  3510. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3511. /* Disable all GPIOs */
  3512. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3513. /* Internal speaker is connected to headphone pin */
  3514. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3515. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3516. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3517. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3518. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3519. /* Ensure all other unused pins are disabled and muted. */
  3520. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3521. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3522. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3523. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3524. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3525. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3526. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3527. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3528. /* Disable digital (SPDIF) pins */
  3529. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3530. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3531. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3532. * when acting as an output.
  3533. */
  3534. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3535. /* Start with output sum widgets muted and their output gains at min */
  3536. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3537. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3538. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3539. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3540. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3541. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3542. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3543. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3544. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3545. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3546. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3547. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3548. * If the pin mode is changed by the user the pin mode control will
  3549. * take care of enabling the pin's input/output buffers as needed.
  3550. * Therefore there's no need to enable the input buffer at this
  3551. * stage.
  3552. */
  3553. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3554. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3555. * mixer ctrl)
  3556. */
  3557. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3558. /* Mute capture amp left and right */
  3559. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3560. /* Set ADC connection select to match default mixer setting - line
  3561. * in (on mic1 pin)
  3562. */
  3563. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3564. /* Do the same for the second ADC: mute capture input amp and
  3565. * set ADC connection to line in (on mic1 pin)
  3566. */
  3567. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3568. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3569. /* Mute all inputs to mixer widget (even unconnected ones) */
  3570. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3571. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3572. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3573. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3575. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3576. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3578. { }
  3579. };
  3580. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3581. * similar laptops (adapted from Fujitsu init verbs).
  3582. */
  3583. static struct hda_verb alc260_acer_init_verbs[] = {
  3584. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3585. * the headphone jack. Turn this on and rely on the standard mute
  3586. * methods whenever the user wants to turn these outputs off.
  3587. */
  3588. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3589. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3590. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3591. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3592. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3593. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3594. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3595. /* Line In jack is connected to Line1 pin */
  3596. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3597. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3598. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3599. /* Ensure all other unused pins are disabled and muted. */
  3600. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3601. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3602. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3603. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3604. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3605. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3606. /* Disable digital (SPDIF) pins */
  3607. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3608. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3609. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3610. * bus when acting as outputs.
  3611. */
  3612. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3613. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3614. /* Start with output sum widgets muted and their output gains at min */
  3615. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3616. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3617. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3618. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3619. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3620. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3621. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3622. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3623. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3624. /* Unmute Line-out pin widget amp left and right
  3625. * (no equiv mixer ctrl)
  3626. */
  3627. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3628. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3629. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3630. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3631. * inputs. If the pin mode is changed by the user the pin mode control
  3632. * will take care of enabling the pin's input/output buffers as needed.
  3633. * Therefore there's no need to enable the input buffer at this
  3634. * stage.
  3635. */
  3636. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3637. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3638. /* Mute capture amp left and right */
  3639. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3640. /* Set ADC connection select to match default mixer setting - mic
  3641. * (on mic1 pin)
  3642. */
  3643. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3644. /* Do similar with the second ADC: mute capture input amp and
  3645. * set ADC connection to mic to match ALSA's default state.
  3646. */
  3647. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3648. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3649. /* Mute all inputs to mixer widget (even unconnected ones) */
  3650. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3651. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3652. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3653. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3658. { }
  3659. };
  3660. static struct hda_verb alc260_will_verbs[] = {
  3661. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3662. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3663. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3664. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3665. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3666. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3667. {}
  3668. };
  3669. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3670. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3671. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3672. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3673. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3674. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3675. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3676. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3677. {}
  3678. };
  3679. /* toggle speaker-output according to the hp-jack state */
  3680. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3681. {
  3682. unsigned int present;
  3683. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3684. present = snd_hda_codec_read(codec, 0x0f, 0,
  3685. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3686. if (present) {
  3687. snd_hda_codec_write_cache(codec, 0x01, 0,
  3688. AC_VERB_SET_GPIO_DATA, 1);
  3689. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3690. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3691. PIN_HP);
  3692. } else {
  3693. snd_hda_codec_write_cache(codec, 0x01, 0,
  3694. AC_VERB_SET_GPIO_DATA, 0);
  3695. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3696. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3697. PIN_OUT);
  3698. }
  3699. }
  3700. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3701. unsigned int res)
  3702. {
  3703. if ((res >> 26) == ALC880_HP_EVENT)
  3704. alc260_replacer_672v_automute(codec);
  3705. }
  3706. /* Test configuration for debugging, modelled after the ALC880 test
  3707. * configuration.
  3708. */
  3709. #ifdef CONFIG_SND_DEBUG
  3710. static hda_nid_t alc260_test_dac_nids[1] = {
  3711. 0x02,
  3712. };
  3713. static hda_nid_t alc260_test_adc_nids[2] = {
  3714. 0x04, 0x05,
  3715. };
  3716. /* For testing the ALC260, each input MUX needs its own definition since
  3717. * the signal assignments are different. This assumes that the first ADC
  3718. * is NID 0x04.
  3719. */
  3720. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3721. {
  3722. .num_items = 7,
  3723. .items = {
  3724. { "MIC1 pin", 0x0 },
  3725. { "MIC2 pin", 0x1 },
  3726. { "LINE1 pin", 0x2 },
  3727. { "LINE2 pin", 0x3 },
  3728. { "CD pin", 0x4 },
  3729. { "LINE-OUT pin", 0x5 },
  3730. { "HP-OUT pin", 0x6 },
  3731. },
  3732. },
  3733. {
  3734. .num_items = 8,
  3735. .items = {
  3736. { "MIC1 pin", 0x0 },
  3737. { "MIC2 pin", 0x1 },
  3738. { "LINE1 pin", 0x2 },
  3739. { "LINE2 pin", 0x3 },
  3740. { "CD pin", 0x4 },
  3741. { "Mixer", 0x5 },
  3742. { "LINE-OUT pin", 0x6 },
  3743. { "HP-OUT pin", 0x7 },
  3744. },
  3745. },
  3746. };
  3747. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3748. /* Output driver widgets */
  3749. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3750. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3751. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3752. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3753. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3754. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3755. /* Modes for retasking pin widgets
  3756. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3757. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3758. * mention this restriction. At this stage it's not clear whether
  3759. * this behaviour is intentional or is a hardware bug in chip
  3760. * revisions available at least up until early 2006. Therefore for
  3761. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3762. * choices, but if it turns out that the lack of mic bias for these
  3763. * NIDs is intentional we could change their modes from
  3764. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3765. */
  3766. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3767. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3768. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3769. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3770. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3771. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3772. /* Loopback mixer controls */
  3773. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3774. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3775. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3776. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3777. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3778. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3779. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3780. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3781. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3782. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3783. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3784. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3785. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3786. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3787. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3788. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3789. /* Controls for GPIO pins, assuming they are configured as outputs */
  3790. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3791. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3792. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3793. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3794. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3795. * is ambigious as to which NID is which; testing on laptops which
  3796. * make this output available should provide clarification.
  3797. */
  3798. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3799. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3800. { } /* end */
  3801. };
  3802. static struct hda_verb alc260_test_init_verbs[] = {
  3803. /* Enable all GPIOs as outputs with an initial value of 0 */
  3804. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3805. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3806. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3807. /* Enable retasking pins as output, initially without power amp */
  3808. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3809. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3810. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3811. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3812. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3813. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3814. /* Disable digital (SPDIF) pins initially, but users can enable
  3815. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3816. * payload also sets the generation to 0, output to be in "consumer"
  3817. * PCM format, copyright asserted, no pre-emphasis and no validity
  3818. * control.
  3819. */
  3820. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3821. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3822. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3823. * OUT1 sum bus when acting as an output.
  3824. */
  3825. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3826. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3827. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3828. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3829. /* Start with output sum widgets muted and their output gains at min */
  3830. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3831. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3832. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3833. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3834. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3835. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3836. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3837. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3838. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3839. /* Unmute retasking pin widget output buffers since the default
  3840. * state appears to be output. As the pin mode is changed by the
  3841. * user the pin mode control will take care of enabling the pin's
  3842. * input/output buffers as needed.
  3843. */
  3844. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3845. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3846. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3847. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3848. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3849. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3850. /* Also unmute the mono-out pin widget */
  3851. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3852. /* Mute capture amp left and right */
  3853. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3854. /* Set ADC connection select to match default mixer setting (mic1
  3855. * pin)
  3856. */
  3857. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3858. /* Do the same for the second ADC: mute capture input amp and
  3859. * set ADC connection to mic1 pin
  3860. */
  3861. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3862. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3863. /* Mute all inputs to mixer widget (even unconnected ones) */
  3864. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3865. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3866. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3867. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3871. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3872. { }
  3873. };
  3874. #endif
  3875. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3876. .substreams = 1,
  3877. .channels_min = 2,
  3878. .channels_max = 2,
  3879. };
  3880. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3881. .substreams = 1,
  3882. .channels_min = 2,
  3883. .channels_max = 2,
  3884. };
  3885. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3886. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3887. /*
  3888. * for BIOS auto-configuration
  3889. */
  3890. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3891. const char *pfx)
  3892. {
  3893. hda_nid_t nid_vol;
  3894. unsigned long vol_val, sw_val;
  3895. char name[32];
  3896. int err;
  3897. if (nid >= 0x0f && nid < 0x11) {
  3898. nid_vol = nid - 0x7;
  3899. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3900. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3901. } else if (nid == 0x11) {
  3902. nid_vol = nid - 0x7;
  3903. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3904. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3905. } else if (nid >= 0x12 && nid <= 0x15) {
  3906. nid_vol = 0x08;
  3907. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3908. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3909. } else
  3910. return 0; /* N/A */
  3911. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3912. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3913. if (err < 0)
  3914. return err;
  3915. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3916. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3917. if (err < 0)
  3918. return err;
  3919. return 1;
  3920. }
  3921. /* add playback controls from the parsed DAC table */
  3922. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3923. const struct auto_pin_cfg *cfg)
  3924. {
  3925. hda_nid_t nid;
  3926. int err;
  3927. spec->multiout.num_dacs = 1;
  3928. spec->multiout.dac_nids = spec->private_dac_nids;
  3929. spec->multiout.dac_nids[0] = 0x02;
  3930. nid = cfg->line_out_pins[0];
  3931. if (nid) {
  3932. err = alc260_add_playback_controls(spec, nid, "Front");
  3933. if (err < 0)
  3934. return err;
  3935. }
  3936. nid = cfg->speaker_pins[0];
  3937. if (nid) {
  3938. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3939. if (err < 0)
  3940. return err;
  3941. }
  3942. nid = cfg->hp_pins[0];
  3943. if (nid) {
  3944. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3945. if (err < 0)
  3946. return err;
  3947. }
  3948. return 0;
  3949. }
  3950. /* create playback/capture controls for input pins */
  3951. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3952. const struct auto_pin_cfg *cfg)
  3953. {
  3954. struct hda_input_mux *imux = &spec->private_imux;
  3955. int i, err, idx;
  3956. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3957. if (cfg->input_pins[i] >= 0x12) {
  3958. idx = cfg->input_pins[i] - 0x12;
  3959. err = new_analog_input(spec, cfg->input_pins[i],
  3960. auto_pin_cfg_labels[i], idx,
  3961. 0x07);
  3962. if (err < 0)
  3963. return err;
  3964. imux->items[imux->num_items].label =
  3965. auto_pin_cfg_labels[i];
  3966. imux->items[imux->num_items].index = idx;
  3967. imux->num_items++;
  3968. }
  3969. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3970. idx = cfg->input_pins[i] - 0x09;
  3971. err = new_analog_input(spec, cfg->input_pins[i],
  3972. auto_pin_cfg_labels[i], idx,
  3973. 0x07);
  3974. if (err < 0)
  3975. return err;
  3976. imux->items[imux->num_items].label =
  3977. auto_pin_cfg_labels[i];
  3978. imux->items[imux->num_items].index = idx;
  3979. imux->num_items++;
  3980. }
  3981. }
  3982. return 0;
  3983. }
  3984. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3985. hda_nid_t nid, int pin_type,
  3986. int sel_idx)
  3987. {
  3988. /* set as output */
  3989. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3990. pin_type);
  3991. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3992. AMP_OUT_UNMUTE);
  3993. /* need the manual connection? */
  3994. if (nid >= 0x12) {
  3995. int idx = nid - 0x12;
  3996. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3997. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3998. }
  3999. }
  4000. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4001. {
  4002. struct alc_spec *spec = codec->spec;
  4003. hda_nid_t nid;
  4004. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4005. nid = spec->autocfg.line_out_pins[0];
  4006. if (nid) {
  4007. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4008. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4009. }
  4010. nid = spec->autocfg.speaker_pins[0];
  4011. if (nid)
  4012. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4013. nid = spec->autocfg.hp_pins[0];
  4014. if (nid)
  4015. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4016. }
  4017. #define ALC260_PIN_CD_NID 0x16
  4018. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4019. {
  4020. struct alc_spec *spec = codec->spec;
  4021. int i;
  4022. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4023. hda_nid_t nid = spec->autocfg.input_pins[i];
  4024. if (nid >= 0x12) {
  4025. snd_hda_codec_write(codec, nid, 0,
  4026. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4027. i <= AUTO_PIN_FRONT_MIC ?
  4028. PIN_VREF80 : PIN_IN);
  4029. if (nid != ALC260_PIN_CD_NID)
  4030. snd_hda_codec_write(codec, nid, 0,
  4031. AC_VERB_SET_AMP_GAIN_MUTE,
  4032. AMP_OUT_MUTE);
  4033. }
  4034. }
  4035. }
  4036. /*
  4037. * generic initialization of ADC, input mixers and output mixers
  4038. */
  4039. static struct hda_verb alc260_volume_init_verbs[] = {
  4040. /*
  4041. * Unmute ADC0-1 and set the default input to mic-in
  4042. */
  4043. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4044. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4045. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4046. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4047. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4048. * mixer widget
  4049. * Note: PASD motherboards uses the Line In 2 as the input for
  4050. * front panel mic (mic 2)
  4051. */
  4052. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4053. /* mute analog inputs */
  4054. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4055. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4056. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4057. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4059. /*
  4060. * Set up output mixers (0x08 - 0x0a)
  4061. */
  4062. /* set vol=0 to output mixers */
  4063. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4064. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4065. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4066. /* set up input amps for analog loopback */
  4067. /* Amp Indices: DAC = 0, mixer = 1 */
  4068. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4069. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4070. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4071. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4072. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4073. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4074. { }
  4075. };
  4076. static int alc260_parse_auto_config(struct hda_codec *codec)
  4077. {
  4078. struct alc_spec *spec = codec->spec;
  4079. unsigned int wcap;
  4080. int err;
  4081. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4082. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4083. alc260_ignore);
  4084. if (err < 0)
  4085. return err;
  4086. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4087. if (err < 0)
  4088. return err;
  4089. if (!spec->kctl_alloc)
  4090. return 0; /* can't find valid BIOS pin config */
  4091. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4092. if (err < 0)
  4093. return err;
  4094. spec->multiout.max_channels = 2;
  4095. if (spec->autocfg.dig_out_pin)
  4096. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4097. if (spec->kctl_alloc)
  4098. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4099. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4100. spec->num_mux_defs = 1;
  4101. spec->input_mux = &spec->private_imux;
  4102. /* check whether NID 0x04 is valid */
  4103. wcap = get_wcaps(codec, 0x04);
  4104. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4105. if (wcap != AC_WID_AUD_IN) {
  4106. spec->adc_nids = alc260_adc_nids_alt;
  4107. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4108. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4109. } else {
  4110. spec->adc_nids = alc260_adc_nids;
  4111. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4112. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4113. }
  4114. spec->num_mixers++;
  4115. return 1;
  4116. }
  4117. /* additional initialization for auto-configuration model */
  4118. static void alc260_auto_init(struct hda_codec *codec)
  4119. {
  4120. alc260_auto_init_multi_out(codec);
  4121. alc260_auto_init_analog_input(codec);
  4122. }
  4123. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4124. static struct hda_amp_list alc260_loopbacks[] = {
  4125. { 0x07, HDA_INPUT, 0 },
  4126. { 0x07, HDA_INPUT, 1 },
  4127. { 0x07, HDA_INPUT, 2 },
  4128. { 0x07, HDA_INPUT, 3 },
  4129. { 0x07, HDA_INPUT, 4 },
  4130. { } /* end */
  4131. };
  4132. #endif
  4133. /*
  4134. * ALC260 configurations
  4135. */
  4136. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4137. [ALC260_BASIC] = "basic",
  4138. [ALC260_HP] = "hp",
  4139. [ALC260_HP_3013] = "hp-3013",
  4140. [ALC260_FUJITSU_S702X] = "fujitsu",
  4141. [ALC260_ACER] = "acer",
  4142. [ALC260_WILL] = "will",
  4143. [ALC260_REPLACER_672V] = "replacer",
  4144. #ifdef CONFIG_SND_DEBUG
  4145. [ALC260_TEST] = "test",
  4146. #endif
  4147. [ALC260_AUTO] = "auto",
  4148. };
  4149. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4150. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4151. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4152. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4153. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4154. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4155. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4156. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4157. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4158. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4159. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4160. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4161. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4162. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4163. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4164. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4165. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4166. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4167. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4168. {}
  4169. };
  4170. static struct alc_config_preset alc260_presets[] = {
  4171. [ALC260_BASIC] = {
  4172. .mixers = { alc260_base_output_mixer,
  4173. alc260_input_mixer,
  4174. alc260_pc_beep_mixer,
  4175. alc260_capture_mixer },
  4176. .init_verbs = { alc260_init_verbs },
  4177. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4178. .dac_nids = alc260_dac_nids,
  4179. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4180. .adc_nids = alc260_adc_nids,
  4181. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4182. .channel_mode = alc260_modes,
  4183. .input_mux = &alc260_capture_source,
  4184. },
  4185. [ALC260_HP] = {
  4186. .mixers = { alc260_base_output_mixer,
  4187. alc260_input_mixer,
  4188. alc260_capture_alt_mixer },
  4189. .init_verbs = { alc260_init_verbs },
  4190. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4191. .dac_nids = alc260_dac_nids,
  4192. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4193. .adc_nids = alc260_hp_adc_nids,
  4194. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4195. .channel_mode = alc260_modes,
  4196. .input_mux = &alc260_capture_source,
  4197. },
  4198. [ALC260_HP_3013] = {
  4199. .mixers = { alc260_hp_3013_mixer,
  4200. alc260_input_mixer,
  4201. alc260_capture_alt_mixer },
  4202. .init_verbs = { alc260_hp_3013_init_verbs },
  4203. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4204. .dac_nids = alc260_dac_nids,
  4205. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4206. .adc_nids = alc260_hp_adc_nids,
  4207. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4208. .channel_mode = alc260_modes,
  4209. .input_mux = &alc260_capture_source,
  4210. },
  4211. [ALC260_FUJITSU_S702X] = {
  4212. .mixers = { alc260_fujitsu_mixer,
  4213. alc260_capture_mixer },
  4214. .init_verbs = { alc260_fujitsu_init_verbs },
  4215. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4216. .dac_nids = alc260_dac_nids,
  4217. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4218. .adc_nids = alc260_dual_adc_nids,
  4219. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4220. .channel_mode = alc260_modes,
  4221. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4222. .input_mux = alc260_fujitsu_capture_sources,
  4223. },
  4224. [ALC260_ACER] = {
  4225. .mixers = { alc260_acer_mixer,
  4226. alc260_capture_mixer },
  4227. .init_verbs = { alc260_acer_init_verbs },
  4228. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4229. .dac_nids = alc260_dac_nids,
  4230. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4231. .adc_nids = alc260_dual_adc_nids,
  4232. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4233. .channel_mode = alc260_modes,
  4234. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4235. .input_mux = alc260_acer_capture_sources,
  4236. },
  4237. [ALC260_WILL] = {
  4238. .mixers = { alc260_will_mixer,
  4239. alc260_capture_mixer },
  4240. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4241. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4242. .dac_nids = alc260_dac_nids,
  4243. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4244. .adc_nids = alc260_adc_nids,
  4245. .dig_out_nid = ALC260_DIGOUT_NID,
  4246. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4247. .channel_mode = alc260_modes,
  4248. .input_mux = &alc260_capture_source,
  4249. },
  4250. [ALC260_REPLACER_672V] = {
  4251. .mixers = { alc260_replacer_672v_mixer,
  4252. alc260_capture_mixer },
  4253. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4254. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4255. .dac_nids = alc260_dac_nids,
  4256. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4257. .adc_nids = alc260_adc_nids,
  4258. .dig_out_nid = ALC260_DIGOUT_NID,
  4259. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4260. .channel_mode = alc260_modes,
  4261. .input_mux = &alc260_capture_source,
  4262. .unsol_event = alc260_replacer_672v_unsol_event,
  4263. .init_hook = alc260_replacer_672v_automute,
  4264. },
  4265. #ifdef CONFIG_SND_DEBUG
  4266. [ALC260_TEST] = {
  4267. .mixers = { alc260_test_mixer,
  4268. alc260_capture_mixer },
  4269. .init_verbs = { alc260_test_init_verbs },
  4270. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4271. .dac_nids = alc260_test_dac_nids,
  4272. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4273. .adc_nids = alc260_test_adc_nids,
  4274. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4275. .channel_mode = alc260_modes,
  4276. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4277. .input_mux = alc260_test_capture_sources,
  4278. },
  4279. #endif
  4280. };
  4281. static int patch_alc260(struct hda_codec *codec)
  4282. {
  4283. struct alc_spec *spec;
  4284. int err, board_config;
  4285. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4286. if (spec == NULL)
  4287. return -ENOMEM;
  4288. codec->spec = spec;
  4289. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4290. alc260_models,
  4291. alc260_cfg_tbl);
  4292. if (board_config < 0) {
  4293. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4294. "trying auto-probe from BIOS...\n");
  4295. board_config = ALC260_AUTO;
  4296. }
  4297. if (board_config == ALC260_AUTO) {
  4298. /* automatic parse from the BIOS config */
  4299. err = alc260_parse_auto_config(codec);
  4300. if (err < 0) {
  4301. alc_free(codec);
  4302. return err;
  4303. } else if (!err) {
  4304. printk(KERN_INFO
  4305. "hda_codec: Cannot set up configuration "
  4306. "from BIOS. Using base mode...\n");
  4307. board_config = ALC260_BASIC;
  4308. }
  4309. }
  4310. if (board_config != ALC260_AUTO)
  4311. setup_preset(spec, &alc260_presets[board_config]);
  4312. spec->stream_name_analog = "ALC260 Analog";
  4313. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4314. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4315. spec->stream_name_digital = "ALC260 Digital";
  4316. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4317. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4318. codec->patch_ops = alc_patch_ops;
  4319. if (board_config == ALC260_AUTO)
  4320. spec->init_hook = alc260_auto_init;
  4321. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4322. if (!spec->loopback.amplist)
  4323. spec->loopback.amplist = alc260_loopbacks;
  4324. #endif
  4325. return 0;
  4326. }
  4327. /*
  4328. * ALC882 support
  4329. *
  4330. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4331. * configuration. Each pin widget can choose any input DACs and a mixer.
  4332. * Each ADC is connected from a mixer of all inputs. This makes possible
  4333. * 6-channel independent captures.
  4334. *
  4335. * In addition, an independent DAC for the multi-playback (not used in this
  4336. * driver yet).
  4337. */
  4338. #define ALC882_DIGOUT_NID 0x06
  4339. #define ALC882_DIGIN_NID 0x0a
  4340. static struct hda_channel_mode alc882_ch_modes[1] = {
  4341. { 8, NULL }
  4342. };
  4343. static hda_nid_t alc882_dac_nids[4] = {
  4344. /* front, rear, clfe, rear_surr */
  4345. 0x02, 0x03, 0x04, 0x05
  4346. };
  4347. /* identical with ALC880 */
  4348. #define alc882_adc_nids alc880_adc_nids
  4349. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4350. /* input MUX */
  4351. /* FIXME: should be a matrix-type input source selection */
  4352. static struct hda_input_mux alc882_capture_source = {
  4353. .num_items = 4,
  4354. .items = {
  4355. { "Mic", 0x0 },
  4356. { "Front Mic", 0x1 },
  4357. { "Line", 0x2 },
  4358. { "CD", 0x4 },
  4359. },
  4360. };
  4361. #define alc882_mux_enum_info alc_mux_enum_info
  4362. #define alc882_mux_enum_get alc_mux_enum_get
  4363. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4364. struct snd_ctl_elem_value *ucontrol)
  4365. {
  4366. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4367. struct alc_spec *spec = codec->spec;
  4368. const struct hda_input_mux *imux = spec->input_mux;
  4369. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4370. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4371. hda_nid_t nid = capture_mixers[adc_idx];
  4372. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4373. unsigned int i, idx;
  4374. idx = ucontrol->value.enumerated.item[0];
  4375. if (idx >= imux->num_items)
  4376. idx = imux->num_items - 1;
  4377. if (*cur_val == idx)
  4378. return 0;
  4379. for (i = 0; i < imux->num_items; i++) {
  4380. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4381. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4382. imux->items[i].index,
  4383. HDA_AMP_MUTE, v);
  4384. }
  4385. *cur_val = idx;
  4386. return 1;
  4387. }
  4388. /*
  4389. * 2ch mode
  4390. */
  4391. static struct hda_verb alc882_3ST_ch2_init[] = {
  4392. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4393. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4394. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4395. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4396. { } /* end */
  4397. };
  4398. /*
  4399. * 6ch mode
  4400. */
  4401. static struct hda_verb alc882_3ST_ch6_init[] = {
  4402. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4403. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4404. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4405. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4406. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4407. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4408. { } /* end */
  4409. };
  4410. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4411. { 2, alc882_3ST_ch2_init },
  4412. { 6, alc882_3ST_ch6_init },
  4413. };
  4414. /*
  4415. * 6ch mode
  4416. */
  4417. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4418. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4419. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4420. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4421. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4422. { } /* end */
  4423. };
  4424. /*
  4425. * 8ch mode
  4426. */
  4427. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4428. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4429. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4430. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4431. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4432. { } /* end */
  4433. };
  4434. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4435. { 6, alc882_sixstack_ch6_init },
  4436. { 8, alc882_sixstack_ch8_init },
  4437. };
  4438. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4439. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4440. */
  4441. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4442. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4443. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4444. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4445. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4446. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4447. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4448. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4449. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4450. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4451. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4452. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4453. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4454. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4455. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4456. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4457. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4458. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4459. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4460. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4461. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4462. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4463. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4464. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4465. { } /* end */
  4466. };
  4467. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4468. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4469. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4470. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4471. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4472. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4473. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4474. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4475. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4476. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4477. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4478. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4479. { } /* end */
  4480. };
  4481. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4482. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4483. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4484. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4485. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4486. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4487. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4488. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4489. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4490. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4491. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4492. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4493. { } /* end */
  4494. };
  4495. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4496. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4497. */
  4498. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4499. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4500. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4501. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4502. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4503. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4504. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4505. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4506. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4507. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4508. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4509. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4510. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4511. { } /* end */
  4512. };
  4513. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4514. {
  4515. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4516. .name = "Channel Mode",
  4517. .info = alc_ch_mode_info,
  4518. .get = alc_ch_mode_get,
  4519. .put = alc_ch_mode_put,
  4520. },
  4521. { } /* end */
  4522. };
  4523. static struct hda_verb alc882_init_verbs[] = {
  4524. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4525. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4526. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4527. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4528. /* Rear mixer */
  4529. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4530. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4531. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4532. /* CLFE mixer */
  4533. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4534. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4535. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4536. /* Side mixer */
  4537. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4538. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4539. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4540. /* Front Pin: output 0 (0x0c) */
  4541. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4542. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4543. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4544. /* Rear Pin: output 1 (0x0d) */
  4545. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4546. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4547. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4548. /* CLFE Pin: output 2 (0x0e) */
  4549. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4550. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4551. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4552. /* Side Pin: output 3 (0x0f) */
  4553. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4554. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4555. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4556. /* Mic (rear) pin: input vref at 80% */
  4557. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4558. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4559. /* Front Mic pin: input vref at 80% */
  4560. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4561. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4562. /* Line In pin: input */
  4563. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4564. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4565. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4566. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4567. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4568. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4569. /* CD pin widget for input */
  4570. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4571. /* FIXME: use matrix-type input source selection */
  4572. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4573. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4574. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4575. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4576. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4577. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4578. /* Input mixer2 */
  4579. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4580. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4581. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4582. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4583. /* Input mixer3 */
  4584. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4585. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4586. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4587. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4588. /* ADC1: mute amp left and right */
  4589. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4590. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4591. /* ADC2: mute amp left and right */
  4592. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4593. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4594. /* ADC3: mute amp left and right */
  4595. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4596. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4597. { }
  4598. };
  4599. static struct hda_verb alc882_eapd_verbs[] = {
  4600. /* change to EAPD mode */
  4601. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4602. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4603. { }
  4604. };
  4605. /* Mac Pro test */
  4606. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4607. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4608. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4609. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4610. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4611. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4612. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4613. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4614. { } /* end */
  4615. };
  4616. static struct hda_verb alc882_macpro_init_verbs[] = {
  4617. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4618. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4619. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4620. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4621. /* Front Pin: output 0 (0x0c) */
  4622. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4623. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4624. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4625. /* Front Mic pin: input vref at 80% */
  4626. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4627. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4628. /* Speaker: output */
  4629. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4630. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4631. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4632. /* Headphone output (output 0 - 0x0c) */
  4633. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4634. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4635. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4636. /* FIXME: use matrix-type input source selection */
  4637. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4638. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4639. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4640. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4641. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4642. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4643. /* Input mixer2 */
  4644. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4645. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4646. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4647. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4648. /* Input mixer3 */
  4649. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4650. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4651. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4652. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4653. /* ADC1: mute amp left and right */
  4654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4655. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4656. /* ADC2: mute amp left and right */
  4657. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4658. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4659. /* ADC3: mute amp left and right */
  4660. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4661. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4662. { }
  4663. };
  4664. /* iMac 24 mixer. */
  4665. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4666. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4667. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4668. { } /* end */
  4669. };
  4670. /* iMac 24 init verbs. */
  4671. static struct hda_verb alc885_imac24_init_verbs[] = {
  4672. /* Internal speakers: output 0 (0x0c) */
  4673. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4674. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4675. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4676. /* Internal speakers: output 0 (0x0c) */
  4677. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4678. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4679. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4680. /* Headphone: output 0 (0x0c) */
  4681. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4682. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4683. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4684. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4685. /* Front Mic: input vref at 80% */
  4686. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4687. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4688. { }
  4689. };
  4690. /* Toggle speaker-output according to the hp-jack state */
  4691. static void alc885_imac24_automute(struct hda_codec *codec)
  4692. {
  4693. unsigned int present;
  4694. present = snd_hda_codec_read(codec, 0x14, 0,
  4695. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4696. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4697. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4698. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4699. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4700. }
  4701. /* Processes unsolicited events. */
  4702. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4703. unsigned int res)
  4704. {
  4705. /* Headphone insertion or removal. */
  4706. if ((res >> 26) == ALC880_HP_EVENT)
  4707. alc885_imac24_automute(codec);
  4708. }
  4709. static struct hda_verb alc882_targa_verbs[] = {
  4710. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4711. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4712. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4713. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4714. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4715. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4716. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4717. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4718. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4719. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4720. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4721. { } /* end */
  4722. };
  4723. /* toggle speaker-output according to the hp-jack state */
  4724. static void alc882_targa_automute(struct hda_codec *codec)
  4725. {
  4726. unsigned int present;
  4727. present = snd_hda_codec_read(codec, 0x14, 0,
  4728. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4729. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  4730. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4731. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  4732. present ? 1 : 3);
  4733. }
  4734. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4735. {
  4736. /* Looks like the unsol event is incompatible with the standard
  4737. * definition. 4bit tag is placed at 26 bit!
  4738. */
  4739. if (((res >> 26) == ALC880_HP_EVENT)) {
  4740. alc882_targa_automute(codec);
  4741. }
  4742. }
  4743. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4744. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4745. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4746. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4747. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4748. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4749. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4750. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4751. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4752. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4753. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4754. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4755. { } /* end */
  4756. };
  4757. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4758. {
  4759. unsigned int gpiostate, gpiomask, gpiodir;
  4760. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4761. AC_VERB_GET_GPIO_DATA, 0);
  4762. if (!muted)
  4763. gpiostate |= (1 << pin);
  4764. else
  4765. gpiostate &= ~(1 << pin);
  4766. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4767. AC_VERB_GET_GPIO_MASK, 0);
  4768. gpiomask |= (1 << pin);
  4769. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4770. AC_VERB_GET_GPIO_DIRECTION, 0);
  4771. gpiodir |= (1 << pin);
  4772. snd_hda_codec_write(codec, codec->afg, 0,
  4773. AC_VERB_SET_GPIO_MASK, gpiomask);
  4774. snd_hda_codec_write(codec, codec->afg, 0,
  4775. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4776. msleep(1);
  4777. snd_hda_codec_write(codec, codec->afg, 0,
  4778. AC_VERB_SET_GPIO_DATA, gpiostate);
  4779. }
  4780. /* set up GPIO at initialization */
  4781. static void alc885_macpro_init_hook(struct hda_codec *codec)
  4782. {
  4783. alc882_gpio_mute(codec, 0, 0);
  4784. alc882_gpio_mute(codec, 1, 0);
  4785. }
  4786. /* set up GPIO and update auto-muting at initialization */
  4787. static void alc885_imac24_init_hook(struct hda_codec *codec)
  4788. {
  4789. alc885_macpro_init_hook(codec);
  4790. alc885_imac24_automute(codec);
  4791. }
  4792. /*
  4793. * generic initialization of ADC, input mixers and output mixers
  4794. */
  4795. static struct hda_verb alc882_auto_init_verbs[] = {
  4796. /*
  4797. * Unmute ADC0-2 and set the default input to mic-in
  4798. */
  4799. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4800. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4801. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4802. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4803. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4804. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4805. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4806. * mixer widget
  4807. * Note: PASD motherboards uses the Line In 2 as the input for
  4808. * front panel mic (mic 2)
  4809. */
  4810. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4811. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4812. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4813. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4814. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4815. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4816. /*
  4817. * Set up output mixers (0x0c - 0x0f)
  4818. */
  4819. /* set vol=0 to output mixers */
  4820. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4821. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4822. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4823. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4824. /* set up input amps for analog loopback */
  4825. /* Amp Indices: DAC = 0, mixer = 1 */
  4826. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4827. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4828. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4829. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4830. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4831. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4832. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4833. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4834. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4835. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4836. /* FIXME: use matrix-type input source selection */
  4837. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4838. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4839. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4840. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4841. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4842. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4843. /* Input mixer2 */
  4844. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4845. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4846. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4847. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4848. /* Input mixer3 */
  4849. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4850. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4851. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4852. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4853. { }
  4854. };
  4855. /* capture mixer elements */
  4856. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4857. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4858. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4859. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4860. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4861. {
  4862. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4863. /* The multiple "Capture Source" controls confuse alsamixer
  4864. * So call somewhat different..
  4865. * FIXME: the controls appear in the "playback" view!
  4866. */
  4867. /* .name = "Capture Source", */
  4868. .name = "Input Source",
  4869. .count = 2,
  4870. .info = alc882_mux_enum_info,
  4871. .get = alc882_mux_enum_get,
  4872. .put = alc882_mux_enum_put,
  4873. },
  4874. { } /* end */
  4875. };
  4876. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4877. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4878. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4879. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4880. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4881. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4882. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4883. {
  4884. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4885. /* The multiple "Capture Source" controls confuse alsamixer
  4886. * So call somewhat different..
  4887. * FIXME: the controls appear in the "playback" view!
  4888. */
  4889. /* .name = "Capture Source", */
  4890. .name = "Input Source",
  4891. .count = 3,
  4892. .info = alc882_mux_enum_info,
  4893. .get = alc882_mux_enum_get,
  4894. .put = alc882_mux_enum_put,
  4895. },
  4896. { } /* end */
  4897. };
  4898. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4899. #define alc882_loopbacks alc880_loopbacks
  4900. #endif
  4901. /* pcm configuration: identiacal with ALC880 */
  4902. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4903. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4904. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4905. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4906. /*
  4907. * configuration and preset
  4908. */
  4909. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4910. [ALC882_3ST_DIG] = "3stack-dig",
  4911. [ALC882_6ST_DIG] = "6stack-dig",
  4912. [ALC882_ARIMA] = "arima",
  4913. [ALC882_W2JC] = "w2jc",
  4914. [ALC885_MACPRO] = "macpro",
  4915. [ALC885_IMAC24] = "imac24",
  4916. [ALC882_AUTO] = "auto",
  4917. };
  4918. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4919. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4920. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4921. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4922. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4923. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4924. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4925. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  4926. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4927. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4928. {}
  4929. };
  4930. static struct alc_config_preset alc882_presets[] = {
  4931. [ALC882_3ST_DIG] = {
  4932. .mixers = { alc882_base_mixer },
  4933. .init_verbs = { alc882_init_verbs },
  4934. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4935. .dac_nids = alc882_dac_nids,
  4936. .dig_out_nid = ALC882_DIGOUT_NID,
  4937. .dig_in_nid = ALC882_DIGIN_NID,
  4938. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4939. .channel_mode = alc882_ch_modes,
  4940. .need_dac_fix = 1,
  4941. .input_mux = &alc882_capture_source,
  4942. },
  4943. [ALC882_6ST_DIG] = {
  4944. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4945. .init_verbs = { alc882_init_verbs },
  4946. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4947. .dac_nids = alc882_dac_nids,
  4948. .dig_out_nid = ALC882_DIGOUT_NID,
  4949. .dig_in_nid = ALC882_DIGIN_NID,
  4950. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4951. .channel_mode = alc882_sixstack_modes,
  4952. .input_mux = &alc882_capture_source,
  4953. },
  4954. [ALC882_ARIMA] = {
  4955. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4956. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4957. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4958. .dac_nids = alc882_dac_nids,
  4959. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4960. .channel_mode = alc882_sixstack_modes,
  4961. .input_mux = &alc882_capture_source,
  4962. },
  4963. [ALC882_W2JC] = {
  4964. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4965. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4966. alc880_gpio1_init_verbs },
  4967. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4968. .dac_nids = alc882_dac_nids,
  4969. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4970. .channel_mode = alc880_threestack_modes,
  4971. .need_dac_fix = 1,
  4972. .input_mux = &alc882_capture_source,
  4973. .dig_out_nid = ALC882_DIGOUT_NID,
  4974. },
  4975. [ALC885_MACPRO] = {
  4976. .mixers = { alc882_macpro_mixer },
  4977. .init_verbs = { alc882_macpro_init_verbs },
  4978. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4979. .dac_nids = alc882_dac_nids,
  4980. .dig_out_nid = ALC882_DIGOUT_NID,
  4981. .dig_in_nid = ALC882_DIGIN_NID,
  4982. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4983. .channel_mode = alc882_ch_modes,
  4984. .input_mux = &alc882_capture_source,
  4985. .init_hook = alc885_macpro_init_hook,
  4986. },
  4987. [ALC885_IMAC24] = {
  4988. .mixers = { alc885_imac24_mixer },
  4989. .init_verbs = { alc885_imac24_init_verbs },
  4990. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4991. .dac_nids = alc882_dac_nids,
  4992. .dig_out_nid = ALC882_DIGOUT_NID,
  4993. .dig_in_nid = ALC882_DIGIN_NID,
  4994. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4995. .channel_mode = alc882_ch_modes,
  4996. .input_mux = &alc882_capture_source,
  4997. .unsol_event = alc885_imac24_unsol_event,
  4998. .init_hook = alc885_imac24_init_hook,
  4999. },
  5000. [ALC882_TARGA] = {
  5001. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5002. alc882_capture_mixer },
  5003. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5004. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5005. .dac_nids = alc882_dac_nids,
  5006. .dig_out_nid = ALC882_DIGOUT_NID,
  5007. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5008. .adc_nids = alc882_adc_nids,
  5009. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5010. .channel_mode = alc882_3ST_6ch_modes,
  5011. .need_dac_fix = 1,
  5012. .input_mux = &alc882_capture_source,
  5013. .unsol_event = alc882_targa_unsol_event,
  5014. .init_hook = alc882_targa_automute,
  5015. },
  5016. [ALC882_ASUS_A7J] = {
  5017. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5018. alc882_capture_mixer },
  5019. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5020. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5021. .dac_nids = alc882_dac_nids,
  5022. .dig_out_nid = ALC882_DIGOUT_NID,
  5023. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5024. .adc_nids = alc882_adc_nids,
  5025. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5026. .channel_mode = alc882_3ST_6ch_modes,
  5027. .need_dac_fix = 1,
  5028. .input_mux = &alc882_capture_source,
  5029. },
  5030. };
  5031. /*
  5032. * Pin config fixes
  5033. */
  5034. enum {
  5035. PINFIX_ABIT_AW9D_MAX
  5036. };
  5037. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5038. { 0x15, 0x01080104 }, /* side */
  5039. { 0x16, 0x01011012 }, /* rear */
  5040. { 0x17, 0x01016011 }, /* clfe */
  5041. { }
  5042. };
  5043. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5044. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5045. };
  5046. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5047. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5048. {}
  5049. };
  5050. /*
  5051. * BIOS auto configuration
  5052. */
  5053. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5054. hda_nid_t nid, int pin_type,
  5055. int dac_idx)
  5056. {
  5057. /* set as output */
  5058. struct alc_spec *spec = codec->spec;
  5059. int idx;
  5060. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5061. idx = 4;
  5062. else
  5063. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5064. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5065. pin_type);
  5066. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5067. AMP_OUT_UNMUTE);
  5068. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5069. }
  5070. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5071. {
  5072. struct alc_spec *spec = codec->spec;
  5073. int i;
  5074. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5075. for (i = 0; i <= HDA_SIDE; i++) {
  5076. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5077. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5078. if (nid)
  5079. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5080. i);
  5081. }
  5082. }
  5083. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5084. {
  5085. struct alc_spec *spec = codec->spec;
  5086. hda_nid_t pin;
  5087. pin = spec->autocfg.hp_pins[0];
  5088. if (pin) /* connect to front */
  5089. /* use dac 0 */
  5090. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5091. }
  5092. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5093. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5094. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5095. {
  5096. struct alc_spec *spec = codec->spec;
  5097. int i;
  5098. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5099. hda_nid_t nid = spec->autocfg.input_pins[i];
  5100. if (alc882_is_input_pin(nid)) {
  5101. snd_hda_codec_write(codec, nid, 0,
  5102. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5103. i <= AUTO_PIN_FRONT_MIC ?
  5104. PIN_VREF80 : PIN_IN);
  5105. if (nid != ALC882_PIN_CD_NID)
  5106. snd_hda_codec_write(codec, nid, 0,
  5107. AC_VERB_SET_AMP_GAIN_MUTE,
  5108. AMP_OUT_MUTE);
  5109. }
  5110. }
  5111. }
  5112. /* almost identical with ALC880 parser... */
  5113. static int alc882_parse_auto_config(struct hda_codec *codec)
  5114. {
  5115. struct alc_spec *spec = codec->spec;
  5116. int err = alc880_parse_auto_config(codec);
  5117. if (err < 0)
  5118. return err;
  5119. else if (err > 0)
  5120. /* hack - override the init verbs */
  5121. spec->init_verbs[0] = alc882_auto_init_verbs;
  5122. return err;
  5123. }
  5124. /* additional initialization for auto-configuration model */
  5125. static void alc882_auto_init(struct hda_codec *codec)
  5126. {
  5127. alc882_auto_init_multi_out(codec);
  5128. alc882_auto_init_hp_out(codec);
  5129. alc882_auto_init_analog_input(codec);
  5130. }
  5131. static int patch_alc882(struct hda_codec *codec)
  5132. {
  5133. struct alc_spec *spec;
  5134. int err, board_config;
  5135. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5136. if (spec == NULL)
  5137. return -ENOMEM;
  5138. codec->spec = spec;
  5139. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5140. alc882_models,
  5141. alc882_cfg_tbl);
  5142. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5143. /* Pick up systems that don't supply PCI SSID */
  5144. switch (codec->subsystem_id) {
  5145. case 0x106b0c00: /* Mac Pro */
  5146. board_config = ALC885_MACPRO;
  5147. break;
  5148. case 0x106b1000: /* iMac 24 */
  5149. board_config = ALC885_IMAC24;
  5150. break;
  5151. default:
  5152. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5153. "trying auto-probe from BIOS...\n");
  5154. board_config = ALC882_AUTO;
  5155. }
  5156. }
  5157. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5158. if (board_config == ALC882_AUTO) {
  5159. /* automatic parse from the BIOS config */
  5160. err = alc882_parse_auto_config(codec);
  5161. if (err < 0) {
  5162. alc_free(codec);
  5163. return err;
  5164. } else if (!err) {
  5165. printk(KERN_INFO
  5166. "hda_codec: Cannot set up configuration "
  5167. "from BIOS. Using base mode...\n");
  5168. board_config = ALC882_3ST_DIG;
  5169. }
  5170. }
  5171. if (board_config != ALC882_AUTO)
  5172. setup_preset(spec, &alc882_presets[board_config]);
  5173. spec->stream_name_analog = "ALC882 Analog";
  5174. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5175. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5176. spec->stream_name_digital = "ALC882 Digital";
  5177. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5178. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5179. if (!spec->adc_nids && spec->input_mux) {
  5180. /* check whether NID 0x07 is valid */
  5181. unsigned int wcap = get_wcaps(codec, 0x07);
  5182. /* get type */
  5183. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5184. if (wcap != AC_WID_AUD_IN) {
  5185. spec->adc_nids = alc882_adc_nids_alt;
  5186. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5187. spec->mixers[spec->num_mixers] =
  5188. alc882_capture_alt_mixer;
  5189. spec->num_mixers++;
  5190. } else {
  5191. spec->adc_nids = alc882_adc_nids;
  5192. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5193. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5194. spec->num_mixers++;
  5195. }
  5196. }
  5197. codec->patch_ops = alc_patch_ops;
  5198. if (board_config == ALC882_AUTO)
  5199. spec->init_hook = alc882_auto_init;
  5200. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5201. if (!spec->loopback.amplist)
  5202. spec->loopback.amplist = alc882_loopbacks;
  5203. #endif
  5204. return 0;
  5205. }
  5206. /*
  5207. * ALC883 support
  5208. *
  5209. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5210. * configuration. Each pin widget can choose any input DACs and a mixer.
  5211. * Each ADC is connected from a mixer of all inputs. This makes possible
  5212. * 6-channel independent captures.
  5213. *
  5214. * In addition, an independent DAC for the multi-playback (not used in this
  5215. * driver yet).
  5216. */
  5217. #define ALC883_DIGOUT_NID 0x06
  5218. #define ALC883_DIGIN_NID 0x0a
  5219. static hda_nid_t alc883_dac_nids[4] = {
  5220. /* front, rear, clfe, rear_surr */
  5221. 0x02, 0x04, 0x03, 0x05
  5222. };
  5223. static hda_nid_t alc883_adc_nids[2] = {
  5224. /* ADC1-2 */
  5225. 0x08, 0x09,
  5226. };
  5227. /* input MUX */
  5228. /* FIXME: should be a matrix-type input source selection */
  5229. static struct hda_input_mux alc883_capture_source = {
  5230. .num_items = 4,
  5231. .items = {
  5232. { "Mic", 0x0 },
  5233. { "Front Mic", 0x1 },
  5234. { "Line", 0x2 },
  5235. { "CD", 0x4 },
  5236. },
  5237. };
  5238. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5239. .num_items = 2,
  5240. .items = {
  5241. { "Mic", 0x1 },
  5242. { "Line", 0x2 },
  5243. },
  5244. };
  5245. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5246. .num_items = 4,
  5247. .items = {
  5248. { "Mic", 0x0 },
  5249. { "iMic", 0x1 },
  5250. { "Line", 0x2 },
  5251. { "CD", 0x4 },
  5252. },
  5253. };
  5254. #define alc883_mux_enum_info alc_mux_enum_info
  5255. #define alc883_mux_enum_get alc_mux_enum_get
  5256. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5257. struct snd_ctl_elem_value *ucontrol)
  5258. {
  5259. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5260. struct alc_spec *spec = codec->spec;
  5261. const struct hda_input_mux *imux = spec->input_mux;
  5262. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5263. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5264. hda_nid_t nid = capture_mixers[adc_idx];
  5265. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5266. unsigned int i, idx;
  5267. idx = ucontrol->value.enumerated.item[0];
  5268. if (idx >= imux->num_items)
  5269. idx = imux->num_items - 1;
  5270. if (*cur_val == idx)
  5271. return 0;
  5272. for (i = 0; i < imux->num_items; i++) {
  5273. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5274. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5275. imux->items[i].index,
  5276. HDA_AMP_MUTE, v);
  5277. }
  5278. *cur_val = idx;
  5279. return 1;
  5280. }
  5281. /*
  5282. * 2ch mode
  5283. */
  5284. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5285. { 2, NULL }
  5286. };
  5287. /*
  5288. * 2ch mode
  5289. */
  5290. static struct hda_verb alc883_3ST_ch2_init[] = {
  5291. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5292. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5293. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5294. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5295. { } /* end */
  5296. };
  5297. /*
  5298. * 6ch mode
  5299. */
  5300. static struct hda_verb alc883_3ST_ch6_init[] = {
  5301. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5302. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5303. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5304. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5305. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5306. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5307. { } /* end */
  5308. };
  5309. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5310. { 2, alc883_3ST_ch2_init },
  5311. { 6, alc883_3ST_ch6_init },
  5312. };
  5313. /*
  5314. * 6ch mode
  5315. */
  5316. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5317. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5318. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5319. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5320. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5321. { } /* end */
  5322. };
  5323. /*
  5324. * 8ch mode
  5325. */
  5326. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5327. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5328. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5329. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5330. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5331. { } /* end */
  5332. };
  5333. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5334. { 6, alc883_sixstack_ch6_init },
  5335. { 8, alc883_sixstack_ch8_init },
  5336. };
  5337. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5338. /* eanable EAPD on medion laptop */
  5339. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5340. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5341. { }
  5342. };
  5343. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5344. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5345. */
  5346. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5347. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5348. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5349. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5350. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5351. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5352. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5353. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5354. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5355. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5356. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5357. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5358. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5359. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5360. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5361. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5362. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5363. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5364. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5365. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5366. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5367. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5368. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5369. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5370. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5371. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5372. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5373. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5374. {
  5375. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5376. /* .name = "Capture Source", */
  5377. .name = "Input Source",
  5378. .count = 2,
  5379. .info = alc883_mux_enum_info,
  5380. .get = alc883_mux_enum_get,
  5381. .put = alc883_mux_enum_put,
  5382. },
  5383. { } /* end */
  5384. };
  5385. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5386. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5387. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5388. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5389. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5390. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5391. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5392. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5393. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5394. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5395. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5396. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5397. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5398. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5399. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5400. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5401. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5402. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5403. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5404. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5405. {
  5406. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5407. /* .name = "Capture Source", */
  5408. .name = "Input Source",
  5409. .count = 2,
  5410. .info = alc883_mux_enum_info,
  5411. .get = alc883_mux_enum_get,
  5412. .put = alc883_mux_enum_put,
  5413. },
  5414. { } /* end */
  5415. };
  5416. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5417. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5418. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5419. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5420. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5421. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5422. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5423. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5424. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5425. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5426. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5427. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5428. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5429. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5430. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5431. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5432. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5433. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5434. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5435. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5436. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5437. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5438. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5439. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5440. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5441. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5442. {
  5443. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5444. /* .name = "Capture Source", */
  5445. .name = "Input Source",
  5446. .count = 2,
  5447. .info = alc883_mux_enum_info,
  5448. .get = alc883_mux_enum_get,
  5449. .put = alc883_mux_enum_put,
  5450. },
  5451. { } /* end */
  5452. };
  5453. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5454. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5455. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5456. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5457. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5458. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5459. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5460. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5461. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5462. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5463. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5464. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5465. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5466. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5467. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5468. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5469. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5470. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5471. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5472. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5473. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5474. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5475. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5476. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5477. {
  5478. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5479. /* .name = "Capture Source", */
  5480. .name = "Input Source",
  5481. .count = 1,
  5482. .info = alc883_mux_enum_info,
  5483. .get = alc883_mux_enum_get,
  5484. .put = alc883_mux_enum_put,
  5485. },
  5486. { } /* end */
  5487. };
  5488. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5489. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5490. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5491. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5492. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5493. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5494. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5495. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5496. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5497. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5498. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5499. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5500. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5501. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5502. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5503. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5504. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5505. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5506. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5507. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5508. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5509. {
  5510. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5511. /* .name = "Capture Source", */
  5512. .name = "Input Source",
  5513. .count = 2,
  5514. .info = alc883_mux_enum_info,
  5515. .get = alc883_mux_enum_get,
  5516. .put = alc883_mux_enum_put,
  5517. },
  5518. { } /* end */
  5519. };
  5520. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5521. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5522. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5523. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5524. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5525. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5526. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5527. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5528. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5529. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5530. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5531. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5532. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5533. {
  5534. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5535. /* .name = "Capture Source", */
  5536. .name = "Input Source",
  5537. .count = 2,
  5538. .info = alc883_mux_enum_info,
  5539. .get = alc883_mux_enum_get,
  5540. .put = alc883_mux_enum_put,
  5541. },
  5542. { } /* end */
  5543. };
  5544. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5545. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5546. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5547. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5548. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5549. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5550. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5551. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5552. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5553. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5554. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5555. {
  5556. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5557. /* .name = "Capture Source", */
  5558. .name = "Input Source",
  5559. .count = 1,
  5560. .info = alc883_mux_enum_info,
  5561. .get = alc883_mux_enum_get,
  5562. .put = alc883_mux_enum_put,
  5563. },
  5564. { } /* end */
  5565. };
  5566. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5567. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5568. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5569. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5570. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5571. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5572. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5573. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5574. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5575. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5576. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5577. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5578. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5579. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5580. {
  5581. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5582. /* .name = "Capture Source", */
  5583. .name = "Input Source",
  5584. .count = 2,
  5585. .info = alc883_mux_enum_info,
  5586. .get = alc883_mux_enum_get,
  5587. .put = alc883_mux_enum_put,
  5588. },
  5589. { } /* end */
  5590. };
  5591. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5592. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5593. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5594. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5595. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5596. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5597. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5598. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5599. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5600. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5601. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5602. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5603. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5604. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5605. {
  5606. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5607. /* .name = "Capture Source", */
  5608. .name = "Input Source",
  5609. .count = 2,
  5610. .info = alc883_mux_enum_info,
  5611. .get = alc883_mux_enum_get,
  5612. .put = alc883_mux_enum_put,
  5613. },
  5614. { } /* end */
  5615. };
  5616. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5617. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5618. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5619. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5620. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5621. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5622. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5623. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5624. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5625. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5626. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5627. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5628. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5629. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5630. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5631. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5632. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5633. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5634. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5635. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5636. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5637. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5638. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5639. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5640. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5641. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5642. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5643. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5644. {
  5645. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5646. /* .name = "Capture Source", */
  5647. .name = "Input Source",
  5648. .count = 2,
  5649. .info = alc883_mux_enum_info,
  5650. .get = alc883_mux_enum_get,
  5651. .put = alc883_mux_enum_put,
  5652. },
  5653. { } /* end */
  5654. };
  5655. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  5656. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5657. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5658. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5659. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5660. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5661. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5662. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5663. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5664. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5665. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5666. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5667. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5668. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5669. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5670. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5671. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5672. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5673. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5674. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5675. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5676. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5677. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5678. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5679. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5680. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5681. {
  5682. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5683. /* .name = "Capture Source", */
  5684. .name = "Input Source",
  5685. .count = 2,
  5686. .info = alc883_mux_enum_info,
  5687. .get = alc883_mux_enum_get,
  5688. .put = alc883_mux_enum_put,
  5689. },
  5690. { } /* end */
  5691. };
  5692. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  5693. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5694. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5695. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5696. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5697. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5698. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5699. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5700. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5701. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5702. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5703. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5704. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5705. {
  5706. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5707. /* .name = "Capture Source", */
  5708. .name = "Input Source",
  5709. .count = 2,
  5710. .info = alc883_mux_enum_info,
  5711. .get = alc883_mux_enum_get,
  5712. .put = alc883_mux_enum_put,
  5713. },
  5714. { } /* end */
  5715. };
  5716. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5717. {
  5718. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5719. .name = "Channel Mode",
  5720. .info = alc_ch_mode_info,
  5721. .get = alc_ch_mode_get,
  5722. .put = alc_ch_mode_put,
  5723. },
  5724. { } /* end */
  5725. };
  5726. static struct hda_verb alc883_init_verbs[] = {
  5727. /* ADC1: mute amp left and right */
  5728. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5729. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5730. /* ADC2: mute amp left and right */
  5731. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5732. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5733. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5734. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5735. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5736. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5737. /* Rear mixer */
  5738. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5739. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5740. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5741. /* CLFE mixer */
  5742. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5743. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5744. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5745. /* Side mixer */
  5746. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5747. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5748. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5749. /* mute analog input loopbacks */
  5750. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5751. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5752. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5753. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5754. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5755. /* Front Pin: output 0 (0x0c) */
  5756. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5757. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5758. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5759. /* Rear Pin: output 1 (0x0d) */
  5760. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5761. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5762. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5763. /* CLFE Pin: output 2 (0x0e) */
  5764. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5765. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5766. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5767. /* Side Pin: output 3 (0x0f) */
  5768. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5769. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5770. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5771. /* Mic (rear) pin: input vref at 80% */
  5772. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5773. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5774. /* Front Mic pin: input vref at 80% */
  5775. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5776. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5777. /* Line In pin: input */
  5778. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5779. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5780. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5781. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5782. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5783. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5784. /* CD pin widget for input */
  5785. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5786. /* FIXME: use matrix-type input source selection */
  5787. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5788. /* Input mixer2 */
  5789. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5790. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5791. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5792. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5793. /* Input mixer3 */
  5794. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5795. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5796. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5797. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5798. { }
  5799. };
  5800. static struct hda_verb alc883_tagra_verbs[] = {
  5801. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5802. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5803. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5804. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5805. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5806. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5807. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5808. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5809. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5810. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5811. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5812. { } /* end */
  5813. };
  5814. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5815. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5816. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5817. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5818. { } /* end */
  5819. };
  5820. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5821. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5822. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5823. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5824. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5825. { } /* end */
  5826. };
  5827. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5828. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5829. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5830. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5831. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5832. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5833. { } /* end */
  5834. };
  5835. static struct hda_verb alc888_6st_hp_verbs[] = {
  5836. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5837. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  5838. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  5839. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  5840. { }
  5841. };
  5842. static struct hda_verb alc888_3st_hp_verbs[] = {
  5843. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5844. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  5845. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  5846. { }
  5847. };
  5848. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  5849. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5850. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5851. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5852. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5853. { }
  5854. };
  5855. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  5856. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5857. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5858. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5859. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5860. { }
  5861. };
  5862. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  5863. { 2, alc888_3st_hp_2ch_init },
  5864. { 6, alc888_3st_hp_6ch_init },
  5865. };
  5866. /* toggle front-jack and RCA according to the hp-jack state */
  5867. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5868. {
  5869. unsigned int present;
  5870. present = snd_hda_codec_read(codec, 0x1b, 0,
  5871. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5872. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  5873. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5874. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  5875. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5876. }
  5877. /* toggle RCA according to the front-jack state */
  5878. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5879. {
  5880. unsigned int present;
  5881. present = snd_hda_codec_read(codec, 0x14, 0,
  5882. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5883. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  5884. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5885. }
  5886. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5887. unsigned int res)
  5888. {
  5889. if ((res >> 26) == ALC880_HP_EVENT)
  5890. alc888_lenovo_ms7195_front_automute(codec);
  5891. if ((res >> 26) == ALC880_FRONT_EVENT)
  5892. alc888_lenovo_ms7195_rca_automute(codec);
  5893. }
  5894. static struct hda_verb alc883_medion_md2_verbs[] = {
  5895. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5896. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5897. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5898. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5899. { } /* end */
  5900. };
  5901. /* toggle speaker-output according to the hp-jack state */
  5902. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5903. {
  5904. unsigned int present;
  5905. present = snd_hda_codec_read(codec, 0x14, 0,
  5906. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5907. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  5908. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5909. }
  5910. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5911. unsigned int res)
  5912. {
  5913. if ((res >> 26) == ALC880_HP_EVENT)
  5914. alc883_medion_md2_automute(codec);
  5915. }
  5916. /* toggle speaker-output according to the hp-jack state */
  5917. static void alc883_tagra_automute(struct hda_codec *codec)
  5918. {
  5919. unsigned int present;
  5920. unsigned char bits;
  5921. present = snd_hda_codec_read(codec, 0x14, 0,
  5922. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5923. bits = present ? HDA_AMP_MUTE : 0;
  5924. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  5925. HDA_AMP_MUTE, bits);
  5926. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5927. present ? 1 : 3);
  5928. }
  5929. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5930. {
  5931. if ((res >> 26) == ALC880_HP_EVENT)
  5932. alc883_tagra_automute(codec);
  5933. }
  5934. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5935. {
  5936. unsigned int present;
  5937. unsigned char bits;
  5938. present = snd_hda_codec_read(codec, 0x14, 0,
  5939. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5940. bits = present ? HDA_AMP_MUTE : 0;
  5941. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  5942. HDA_AMP_MUTE, bits);
  5943. }
  5944. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5945. {
  5946. unsigned int present;
  5947. unsigned char bits;
  5948. present = snd_hda_codec_read(codec, 0x1b, 0,
  5949. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5950. bits = present ? HDA_AMP_MUTE : 0;
  5951. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  5952. HDA_AMP_MUTE, bits);
  5953. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  5954. HDA_AMP_MUTE, bits);
  5955. }
  5956. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5957. unsigned int res)
  5958. {
  5959. if ((res >> 26) == ALC880_HP_EVENT)
  5960. alc883_lenovo_101e_all_automute(codec);
  5961. if ((res >> 26) == ALC880_FRONT_EVENT)
  5962. alc883_lenovo_101e_ispeaker_automute(codec);
  5963. }
  5964. /* toggle speaker-output according to the hp-jack state */
  5965. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  5966. {
  5967. unsigned int present;
  5968. present = snd_hda_codec_read(codec, 0x14, 0,
  5969. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5970. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  5971. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5972. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  5973. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5974. }
  5975. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  5976. unsigned int res)
  5977. {
  5978. if ((res >> 26) == ALC880_HP_EVENT)
  5979. alc883_acer_aspire_automute(codec);
  5980. }
  5981. static struct hda_verb alc883_acer_eapd_verbs[] = {
  5982. /* HP Pin: output 0 (0x0c) */
  5983. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5984. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5985. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5986. /* Front Pin: output 0 (0x0c) */
  5987. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5988. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5989. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5990. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  5991. /* eanable EAPD on medion laptop */
  5992. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5993. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  5994. /* enable unsolicited event */
  5995. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5996. { }
  5997. };
  5998. /*
  5999. * generic initialization of ADC, input mixers and output mixers
  6000. */
  6001. static struct hda_verb alc883_auto_init_verbs[] = {
  6002. /*
  6003. * Unmute ADC0-2 and set the default input to mic-in
  6004. */
  6005. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6006. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6007. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6008. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6009. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6010. * mixer widget
  6011. * Note: PASD motherboards uses the Line In 2 as the input for
  6012. * front panel mic (mic 2)
  6013. */
  6014. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6015. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6016. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6017. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6018. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6019. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6020. /*
  6021. * Set up output mixers (0x0c - 0x0f)
  6022. */
  6023. /* set vol=0 to output mixers */
  6024. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6025. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6026. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6027. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6028. /* set up input amps for analog loopback */
  6029. /* Amp Indices: DAC = 0, mixer = 1 */
  6030. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6031. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6032. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6033. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6034. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6035. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6036. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6037. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6038. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6039. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6040. /* FIXME: use matrix-type input source selection */
  6041. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6042. /* Input mixer1 */
  6043. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6044. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6045. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6046. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6047. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6048. /* Input mixer2 */
  6049. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6050. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6051. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6052. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6053. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6054. { }
  6055. };
  6056. /* capture mixer elements */
  6057. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6058. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6059. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6060. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6061. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6062. {
  6063. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6064. /* The multiple "Capture Source" controls confuse alsamixer
  6065. * So call somewhat different..
  6066. * FIXME: the controls appear in the "playback" view!
  6067. */
  6068. /* .name = "Capture Source", */
  6069. .name = "Input Source",
  6070. .count = 2,
  6071. .info = alc882_mux_enum_info,
  6072. .get = alc882_mux_enum_get,
  6073. .put = alc882_mux_enum_put,
  6074. },
  6075. { } /* end */
  6076. };
  6077. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6078. #define alc883_loopbacks alc880_loopbacks
  6079. #endif
  6080. /* pcm configuration: identiacal with ALC880 */
  6081. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6082. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6083. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6084. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6085. /*
  6086. * configuration and preset
  6087. */
  6088. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6089. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6090. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6091. [ALC883_3ST_6ch] = "3stack-6ch",
  6092. [ALC883_6ST_DIG] = "6stack-dig",
  6093. [ALC883_TARGA_DIG] = "targa-dig",
  6094. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6095. [ALC883_ACER] = "acer",
  6096. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6097. [ALC883_MEDION] = "medion",
  6098. [ALC883_MEDION_MD2] = "medion-md2",
  6099. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6100. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6101. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6102. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6103. [ALC888_6ST_HP] = "6stack-hp",
  6104. [ALC888_3ST_HP] = "3stack-hp",
  6105. [ALC883_AUTO] = "auto",
  6106. };
  6107. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6108. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6109. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6110. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6111. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6112. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6113. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6114. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6115. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6116. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6117. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6118. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6119. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6120. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6121. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6122. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6123. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6124. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6125. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6126. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6127. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6128. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6129. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6130. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6131. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6132. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6133. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6134. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6135. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6136. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6137. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6138. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6139. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6140. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6141. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6142. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6143. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6144. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6145. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6146. {}
  6147. };
  6148. static struct alc_config_preset alc883_presets[] = {
  6149. [ALC883_3ST_2ch_DIG] = {
  6150. .mixers = { alc883_3ST_2ch_mixer },
  6151. .init_verbs = { alc883_init_verbs },
  6152. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6153. .dac_nids = alc883_dac_nids,
  6154. .dig_out_nid = ALC883_DIGOUT_NID,
  6155. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6156. .adc_nids = alc883_adc_nids,
  6157. .dig_in_nid = ALC883_DIGIN_NID,
  6158. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6159. .channel_mode = alc883_3ST_2ch_modes,
  6160. .input_mux = &alc883_capture_source,
  6161. },
  6162. [ALC883_3ST_6ch_DIG] = {
  6163. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6164. .init_verbs = { alc883_init_verbs },
  6165. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6166. .dac_nids = alc883_dac_nids,
  6167. .dig_out_nid = ALC883_DIGOUT_NID,
  6168. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6169. .adc_nids = alc883_adc_nids,
  6170. .dig_in_nid = ALC883_DIGIN_NID,
  6171. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6172. .channel_mode = alc883_3ST_6ch_modes,
  6173. .need_dac_fix = 1,
  6174. .input_mux = &alc883_capture_source,
  6175. },
  6176. [ALC883_3ST_6ch] = {
  6177. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6178. .init_verbs = { alc883_init_verbs },
  6179. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6180. .dac_nids = alc883_dac_nids,
  6181. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6182. .adc_nids = alc883_adc_nids,
  6183. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6184. .channel_mode = alc883_3ST_6ch_modes,
  6185. .need_dac_fix = 1,
  6186. .input_mux = &alc883_capture_source,
  6187. },
  6188. [ALC883_6ST_DIG] = {
  6189. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6190. .init_verbs = { alc883_init_verbs },
  6191. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6192. .dac_nids = alc883_dac_nids,
  6193. .dig_out_nid = ALC883_DIGOUT_NID,
  6194. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6195. .adc_nids = alc883_adc_nids,
  6196. .dig_in_nid = ALC883_DIGIN_NID,
  6197. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6198. .channel_mode = alc883_sixstack_modes,
  6199. .input_mux = &alc883_capture_source,
  6200. },
  6201. [ALC883_TARGA_DIG] = {
  6202. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6203. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6204. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6205. .dac_nids = alc883_dac_nids,
  6206. .dig_out_nid = ALC883_DIGOUT_NID,
  6207. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6208. .adc_nids = alc883_adc_nids,
  6209. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6210. .channel_mode = alc883_3ST_6ch_modes,
  6211. .need_dac_fix = 1,
  6212. .input_mux = &alc883_capture_source,
  6213. .unsol_event = alc883_tagra_unsol_event,
  6214. .init_hook = alc883_tagra_automute,
  6215. },
  6216. [ALC883_TARGA_2ch_DIG] = {
  6217. .mixers = { alc883_tagra_2ch_mixer},
  6218. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6219. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6220. .dac_nids = alc883_dac_nids,
  6221. .dig_out_nid = ALC883_DIGOUT_NID,
  6222. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6223. .adc_nids = alc883_adc_nids,
  6224. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6225. .channel_mode = alc883_3ST_2ch_modes,
  6226. .input_mux = &alc883_capture_source,
  6227. .unsol_event = alc883_tagra_unsol_event,
  6228. .init_hook = alc883_tagra_automute,
  6229. },
  6230. [ALC883_ACER] = {
  6231. .mixers = { alc883_base_mixer },
  6232. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6233. * and the headphone jack. Turn this on and rely on the
  6234. * standard mute methods whenever the user wants to turn
  6235. * these outputs off.
  6236. */
  6237. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6238. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6239. .dac_nids = alc883_dac_nids,
  6240. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6241. .adc_nids = alc883_adc_nids,
  6242. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6243. .channel_mode = alc883_3ST_2ch_modes,
  6244. .input_mux = &alc883_capture_source,
  6245. },
  6246. [ALC883_ACER_ASPIRE] = {
  6247. .mixers = { alc883_acer_aspire_mixer },
  6248. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6249. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6250. .dac_nids = alc883_dac_nids,
  6251. .dig_out_nid = ALC883_DIGOUT_NID,
  6252. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6253. .adc_nids = alc883_adc_nids,
  6254. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6255. .channel_mode = alc883_3ST_2ch_modes,
  6256. .input_mux = &alc883_capture_source,
  6257. .unsol_event = alc883_acer_aspire_unsol_event,
  6258. .init_hook = alc883_acer_aspire_automute,
  6259. },
  6260. [ALC883_MEDION] = {
  6261. .mixers = { alc883_fivestack_mixer,
  6262. alc883_chmode_mixer },
  6263. .init_verbs = { alc883_init_verbs,
  6264. alc883_medion_eapd_verbs },
  6265. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6266. .dac_nids = alc883_dac_nids,
  6267. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6268. .adc_nids = alc883_adc_nids,
  6269. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6270. .channel_mode = alc883_sixstack_modes,
  6271. .input_mux = &alc883_capture_source,
  6272. },
  6273. [ALC883_MEDION_MD2] = {
  6274. .mixers = { alc883_medion_md2_mixer},
  6275. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6276. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6277. .dac_nids = alc883_dac_nids,
  6278. .dig_out_nid = ALC883_DIGOUT_NID,
  6279. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6280. .adc_nids = alc883_adc_nids,
  6281. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6282. .channel_mode = alc883_3ST_2ch_modes,
  6283. .input_mux = &alc883_capture_source,
  6284. .unsol_event = alc883_medion_md2_unsol_event,
  6285. .init_hook = alc883_medion_md2_automute,
  6286. },
  6287. [ALC883_LAPTOP_EAPD] = {
  6288. .mixers = { alc883_base_mixer },
  6289. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6290. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6291. .dac_nids = alc883_dac_nids,
  6292. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6293. .adc_nids = alc883_adc_nids,
  6294. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6295. .channel_mode = alc883_3ST_2ch_modes,
  6296. .input_mux = &alc883_capture_source,
  6297. },
  6298. [ALC883_LENOVO_101E_2ch] = {
  6299. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6300. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6301. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6302. .dac_nids = alc883_dac_nids,
  6303. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6304. .adc_nids = alc883_adc_nids,
  6305. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6306. .channel_mode = alc883_3ST_2ch_modes,
  6307. .input_mux = &alc883_lenovo_101e_capture_source,
  6308. .unsol_event = alc883_lenovo_101e_unsol_event,
  6309. .init_hook = alc883_lenovo_101e_all_automute,
  6310. },
  6311. [ALC883_LENOVO_NB0763] = {
  6312. .mixers = { alc883_lenovo_nb0763_mixer },
  6313. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6314. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6315. .dac_nids = alc883_dac_nids,
  6316. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6317. .adc_nids = alc883_adc_nids,
  6318. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6319. .channel_mode = alc883_3ST_2ch_modes,
  6320. .need_dac_fix = 1,
  6321. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6322. .unsol_event = alc883_medion_md2_unsol_event,
  6323. .init_hook = alc883_medion_md2_automute,
  6324. },
  6325. [ALC888_LENOVO_MS7195_DIG] = {
  6326. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6327. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6328. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6329. .dac_nids = alc883_dac_nids,
  6330. .dig_out_nid = ALC883_DIGOUT_NID,
  6331. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6332. .adc_nids = alc883_adc_nids,
  6333. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6334. .channel_mode = alc883_3ST_6ch_modes,
  6335. .need_dac_fix = 1,
  6336. .input_mux = &alc883_capture_source,
  6337. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6338. .init_hook = alc888_lenovo_ms7195_front_automute,
  6339. },
  6340. [ALC888_6ST_HP] = {
  6341. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6342. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6343. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6344. .dac_nids = alc883_dac_nids,
  6345. .dig_out_nid = ALC883_DIGOUT_NID,
  6346. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6347. .adc_nids = alc883_adc_nids,
  6348. .dig_in_nid = ALC883_DIGIN_NID,
  6349. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6350. .channel_mode = alc883_sixstack_modes,
  6351. .input_mux = &alc883_capture_source,
  6352. },
  6353. [ALC888_3ST_HP] = {
  6354. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6355. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6356. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6357. .dac_nids = alc883_dac_nids,
  6358. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6359. .adc_nids = alc883_adc_nids,
  6360. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6361. .channel_mode = alc888_3st_hp_modes,
  6362. .need_dac_fix = 1,
  6363. .input_mux = &alc883_capture_source,
  6364. },
  6365. };
  6366. /*
  6367. * BIOS auto configuration
  6368. */
  6369. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6370. hda_nid_t nid, int pin_type,
  6371. int dac_idx)
  6372. {
  6373. /* set as output */
  6374. struct alc_spec *spec = codec->spec;
  6375. int idx;
  6376. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6377. idx = 4;
  6378. else
  6379. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6380. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6381. pin_type);
  6382. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6383. AMP_OUT_UNMUTE);
  6384. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6385. }
  6386. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6387. {
  6388. struct alc_spec *spec = codec->spec;
  6389. int i;
  6390. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6391. for (i = 0; i <= HDA_SIDE; i++) {
  6392. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6393. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6394. if (nid)
  6395. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6396. i);
  6397. }
  6398. }
  6399. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6400. {
  6401. struct alc_spec *spec = codec->spec;
  6402. hda_nid_t pin;
  6403. pin = spec->autocfg.hp_pins[0];
  6404. if (pin) /* connect to front */
  6405. /* use dac 0 */
  6406. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6407. }
  6408. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6409. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6410. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6411. {
  6412. struct alc_spec *spec = codec->spec;
  6413. int i;
  6414. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6415. hda_nid_t nid = spec->autocfg.input_pins[i];
  6416. if (alc883_is_input_pin(nid)) {
  6417. snd_hda_codec_write(codec, nid, 0,
  6418. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6419. (i <= AUTO_PIN_FRONT_MIC ?
  6420. PIN_VREF80 : PIN_IN));
  6421. if (nid != ALC883_PIN_CD_NID)
  6422. snd_hda_codec_write(codec, nid, 0,
  6423. AC_VERB_SET_AMP_GAIN_MUTE,
  6424. AMP_OUT_MUTE);
  6425. }
  6426. }
  6427. }
  6428. /* almost identical with ALC880 parser... */
  6429. static int alc883_parse_auto_config(struct hda_codec *codec)
  6430. {
  6431. struct alc_spec *spec = codec->spec;
  6432. int err = alc880_parse_auto_config(codec);
  6433. if (err < 0)
  6434. return err;
  6435. else if (err > 0)
  6436. /* hack - override the init verbs */
  6437. spec->init_verbs[0] = alc883_auto_init_verbs;
  6438. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6439. spec->num_mixers++;
  6440. return err;
  6441. }
  6442. /* additional initialization for auto-configuration model */
  6443. static void alc883_auto_init(struct hda_codec *codec)
  6444. {
  6445. alc883_auto_init_multi_out(codec);
  6446. alc883_auto_init_hp_out(codec);
  6447. alc883_auto_init_analog_input(codec);
  6448. }
  6449. static int patch_alc883(struct hda_codec *codec)
  6450. {
  6451. struct alc_spec *spec;
  6452. int err, board_config;
  6453. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6454. if (spec == NULL)
  6455. return -ENOMEM;
  6456. codec->spec = spec;
  6457. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6458. alc883_models,
  6459. alc883_cfg_tbl);
  6460. if (board_config < 0) {
  6461. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6462. "trying auto-probe from BIOS...\n");
  6463. board_config = ALC883_AUTO;
  6464. }
  6465. if (board_config == ALC883_AUTO) {
  6466. /* automatic parse from the BIOS config */
  6467. err = alc883_parse_auto_config(codec);
  6468. if (err < 0) {
  6469. alc_free(codec);
  6470. return err;
  6471. } else if (!err) {
  6472. printk(KERN_INFO
  6473. "hda_codec: Cannot set up configuration "
  6474. "from BIOS. Using base mode...\n");
  6475. board_config = ALC883_3ST_2ch_DIG;
  6476. }
  6477. }
  6478. if (board_config != ALC883_AUTO)
  6479. setup_preset(spec, &alc883_presets[board_config]);
  6480. spec->stream_name_analog = "ALC883 Analog";
  6481. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6482. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6483. spec->stream_name_digital = "ALC883 Digital";
  6484. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6485. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6486. if (!spec->adc_nids && spec->input_mux) {
  6487. spec->adc_nids = alc883_adc_nids;
  6488. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6489. }
  6490. codec->patch_ops = alc_patch_ops;
  6491. if (board_config == ALC883_AUTO)
  6492. spec->init_hook = alc883_auto_init;
  6493. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6494. if (!spec->loopback.amplist)
  6495. spec->loopback.amplist = alc883_loopbacks;
  6496. #endif
  6497. return 0;
  6498. }
  6499. /*
  6500. * ALC262 support
  6501. */
  6502. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6503. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6504. #define alc262_dac_nids alc260_dac_nids
  6505. #define alc262_adc_nids alc882_adc_nids
  6506. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6507. #define alc262_modes alc260_modes
  6508. #define alc262_capture_source alc882_capture_source
  6509. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6510. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6511. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6512. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6513. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6514. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6515. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6516. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6517. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6518. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6519. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6520. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6521. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6522. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6523. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6524. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6525. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6526. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6527. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6528. { } /* end */
  6529. };
  6530. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6531. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6532. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6533. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6534. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6535. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6536. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6537. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6538. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6539. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6540. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6541. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6542. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6543. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6544. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6545. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6546. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6547. { } /* end */
  6548. };
  6549. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6550. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6551. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6552. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6553. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6554. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6555. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6556. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6557. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6558. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6559. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6560. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6561. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6562. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6563. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6564. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6565. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6566. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6567. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6568. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6569. { } /* end */
  6570. };
  6571. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6572. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6573. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6574. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6575. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6576. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6577. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6578. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6579. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6580. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6581. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6582. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6583. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6584. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6585. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6586. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6587. { } /* end */
  6588. };
  6589. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6590. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6591. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6592. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6593. { } /* end */
  6594. };
  6595. static struct hda_bind_ctls alc262_sony_bind_sw = {
  6596. .ops = &snd_hda_bind_sw,
  6597. .values = {
  6598. HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  6599. HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6600. 0,
  6601. },
  6602. };
  6603. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6604. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6605. HDA_BIND_SW("Front Playback Switch", &alc262_sony_bind_sw),
  6606. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6607. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6608. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6609. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6610. { } /* end */
  6611. };
  6612. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6613. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6614. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6615. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6616. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6617. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6618. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6619. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6620. { } /* end */
  6621. };
  6622. #define alc262_capture_mixer alc882_capture_mixer
  6623. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6624. /*
  6625. * generic initialization of ADC, input mixers and output mixers
  6626. */
  6627. static struct hda_verb alc262_init_verbs[] = {
  6628. /*
  6629. * Unmute ADC0-2 and set the default input to mic-in
  6630. */
  6631. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6632. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6633. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6634. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6635. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6636. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6637. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6638. * mixer widget
  6639. * Note: PASD motherboards uses the Line In 2 as the input for
  6640. * front panel mic (mic 2)
  6641. */
  6642. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6643. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6644. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6645. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6646. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6647. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6648. /*
  6649. * Set up output mixers (0x0c - 0x0e)
  6650. */
  6651. /* set vol=0 to output mixers */
  6652. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6653. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6654. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6655. /* set up input amps for analog loopback */
  6656. /* Amp Indices: DAC = 0, mixer = 1 */
  6657. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6658. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6659. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6660. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6661. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6662. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6663. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6664. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6665. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6666. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6667. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6668. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6669. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6670. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6671. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6672. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6673. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6674. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6675. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6676. /* FIXME: use matrix-type input source selection */
  6677. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6678. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6679. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6680. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6681. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6682. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6683. /* Input mixer2 */
  6684. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6685. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6686. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6687. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6688. /* Input mixer3 */
  6689. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6690. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6691. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6692. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6693. { }
  6694. };
  6695. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6696. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6697. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6698. {}
  6699. };
  6700. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6701. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6702. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6703. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6704. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6705. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6706. {}
  6707. };
  6708. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6709. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6710. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6711. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6712. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6713. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6714. };
  6715. /* mute/unmute internal speaker according to the hp jack and mute state */
  6716. static void alc262_hippo_automute(struct hda_codec *codec)
  6717. {
  6718. struct alc_spec *spec = codec->spec;
  6719. unsigned int mute;
  6720. unsigned int present;
  6721. /* need to execute and sync at first */
  6722. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6723. present = snd_hda_codec_read(codec, 0x15, 0,
  6724. AC_VERB_GET_PIN_SENSE, 0);
  6725. spec->jack_present = (present & 0x80000000) != 0;
  6726. if (spec->jack_present) {
  6727. /* mute internal speaker */
  6728. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6729. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6730. } else {
  6731. /* unmute internal speaker if necessary */
  6732. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6733. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6734. HDA_AMP_MUTE, mute);
  6735. }
  6736. }
  6737. /* unsolicited event for HP jack sensing */
  6738. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6739. unsigned int res)
  6740. {
  6741. if ((res >> 26) != ALC880_HP_EVENT)
  6742. return;
  6743. alc262_hippo_automute(codec);
  6744. }
  6745. static void alc262_hippo1_automute(struct hda_codec *codec)
  6746. {
  6747. unsigned int mute;
  6748. unsigned int present;
  6749. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6750. present = snd_hda_codec_read(codec, 0x1b, 0,
  6751. AC_VERB_GET_PIN_SENSE, 0);
  6752. present = (present & 0x80000000) != 0;
  6753. if (present) {
  6754. /* mute internal speaker */
  6755. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6756. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6757. } else {
  6758. /* unmute internal speaker if necessary */
  6759. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6760. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6761. HDA_AMP_MUTE, mute);
  6762. }
  6763. }
  6764. /* unsolicited event for HP jack sensing */
  6765. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6766. unsigned int res)
  6767. {
  6768. if ((res >> 26) != ALC880_HP_EVENT)
  6769. return;
  6770. alc262_hippo1_automute(codec);
  6771. }
  6772. /*
  6773. * fujitsu model
  6774. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6775. */
  6776. #define ALC_HP_EVENT 0x37
  6777. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6778. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6779. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6780. {}
  6781. };
  6782. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6783. .num_items = 2,
  6784. .items = {
  6785. { "Mic", 0x0 },
  6786. { "CD", 0x4 },
  6787. },
  6788. };
  6789. static struct hda_input_mux alc262_HP_capture_source = {
  6790. .num_items = 5,
  6791. .items = {
  6792. { "Mic", 0x0 },
  6793. { "Front Mic", 0x3 },
  6794. { "Line", 0x2 },
  6795. { "CD", 0x4 },
  6796. { "AUX IN", 0x6 },
  6797. },
  6798. };
  6799. /* mute/unmute internal speaker according to the hp jack and mute state */
  6800. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6801. {
  6802. struct alc_spec *spec = codec->spec;
  6803. unsigned int mute;
  6804. if (force || !spec->sense_updated) {
  6805. unsigned int present;
  6806. /* need to execute and sync at first */
  6807. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6808. present = snd_hda_codec_read(codec, 0x14, 0,
  6809. AC_VERB_GET_PIN_SENSE, 0);
  6810. spec->jack_present = (present & 0x80000000) != 0;
  6811. spec->sense_updated = 1;
  6812. }
  6813. if (spec->jack_present) {
  6814. /* mute internal speaker */
  6815. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6816. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6817. } else {
  6818. /* unmute internal speaker if necessary */
  6819. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6820. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6821. HDA_AMP_MUTE, mute);
  6822. }
  6823. }
  6824. /* unsolicited event for HP jack sensing */
  6825. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6826. unsigned int res)
  6827. {
  6828. if ((res >> 26) != ALC_HP_EVENT)
  6829. return;
  6830. alc262_fujitsu_automute(codec, 1);
  6831. }
  6832. /* bind volumes of both NID 0x0c and 0x0d */
  6833. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  6834. .ops = &snd_hda_bind_vol,
  6835. .values = {
  6836. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6837. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  6838. 0
  6839. },
  6840. };
  6841. /* bind hp and internal speaker mute (with plug check) */
  6842. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6843. struct snd_ctl_elem_value *ucontrol)
  6844. {
  6845. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6846. long *valp = ucontrol->value.integer.value;
  6847. int change;
  6848. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6849. HDA_AMP_MUTE,
  6850. valp[0] ? 0 : HDA_AMP_MUTE);
  6851. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6852. HDA_AMP_MUTE,
  6853. valp[1] ? 0 : HDA_AMP_MUTE);
  6854. if (change)
  6855. alc262_fujitsu_automute(codec, 0);
  6856. return change;
  6857. }
  6858. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6859. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  6860. {
  6861. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6862. .name = "Master Playback Switch",
  6863. .info = snd_hda_mixer_amp_switch_info,
  6864. .get = snd_hda_mixer_amp_switch_get,
  6865. .put = alc262_fujitsu_master_sw_put,
  6866. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6867. },
  6868. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6869. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6870. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6871. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6872. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6873. { } /* end */
  6874. };
  6875. /* additional init verbs for Benq laptops */
  6876. static struct hda_verb alc262_EAPD_verbs[] = {
  6877. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6878. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6879. {}
  6880. };
  6881. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  6882. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6883. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6884. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6885. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6886. {}
  6887. };
  6888. /* add playback controls from the parsed DAC table */
  6889. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6890. const struct auto_pin_cfg *cfg)
  6891. {
  6892. hda_nid_t nid;
  6893. int err;
  6894. spec->multiout.num_dacs = 1; /* only use one dac */
  6895. spec->multiout.dac_nids = spec->private_dac_nids;
  6896. spec->multiout.dac_nids[0] = 2;
  6897. nid = cfg->line_out_pins[0];
  6898. if (nid) {
  6899. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6900. "Front Playback Volume",
  6901. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6902. if (err < 0)
  6903. return err;
  6904. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6905. "Front Playback Switch",
  6906. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6907. if (err < 0)
  6908. return err;
  6909. }
  6910. nid = cfg->speaker_pins[0];
  6911. if (nid) {
  6912. if (nid == 0x16) {
  6913. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6914. "Speaker Playback Volume",
  6915. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6916. HDA_OUTPUT));
  6917. if (err < 0)
  6918. return err;
  6919. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6920. "Speaker Playback Switch",
  6921. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6922. HDA_OUTPUT));
  6923. if (err < 0)
  6924. return err;
  6925. } else {
  6926. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6927. "Speaker Playback Switch",
  6928. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6929. HDA_OUTPUT));
  6930. if (err < 0)
  6931. return err;
  6932. }
  6933. }
  6934. nid = cfg->hp_pins[0];
  6935. if (nid) {
  6936. /* spec->multiout.hp_nid = 2; */
  6937. if (nid == 0x16) {
  6938. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6939. "Headphone Playback Volume",
  6940. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6941. HDA_OUTPUT));
  6942. if (err < 0)
  6943. return err;
  6944. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6945. "Headphone Playback Switch",
  6946. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6947. HDA_OUTPUT));
  6948. if (err < 0)
  6949. return err;
  6950. } else {
  6951. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6952. "Headphone Playback Switch",
  6953. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6954. HDA_OUTPUT));
  6955. if (err < 0)
  6956. return err;
  6957. }
  6958. }
  6959. return 0;
  6960. }
  6961. /* identical with ALC880 */
  6962. #define alc262_auto_create_analog_input_ctls \
  6963. alc880_auto_create_analog_input_ctls
  6964. /*
  6965. * generic initialization of ADC, input mixers and output mixers
  6966. */
  6967. static struct hda_verb alc262_volume_init_verbs[] = {
  6968. /*
  6969. * Unmute ADC0-2 and set the default input to mic-in
  6970. */
  6971. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6972. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6973. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6974. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6975. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6976. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6977. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6978. * mixer widget
  6979. * Note: PASD motherboards uses the Line In 2 as the input for
  6980. * front panel mic (mic 2)
  6981. */
  6982. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6983. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6984. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6985. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6986. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6987. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6988. /*
  6989. * Set up output mixers (0x0c - 0x0f)
  6990. */
  6991. /* set vol=0 to output mixers */
  6992. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6993. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6994. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6995. /* set up input amps for analog loopback */
  6996. /* Amp Indices: DAC = 0, mixer = 1 */
  6997. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6998. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6999. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7000. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7001. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7002. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7003. /* FIXME: use matrix-type input source selection */
  7004. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7005. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7006. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7007. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7008. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7009. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7010. /* Input mixer2 */
  7011. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7012. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7013. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7014. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7015. /* Input mixer3 */
  7016. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7017. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7018. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7019. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7020. { }
  7021. };
  7022. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7023. /*
  7024. * Unmute ADC0-2 and set the default input to mic-in
  7025. */
  7026. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7027. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7028. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7029. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7030. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7031. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7032. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7033. * mixer widget
  7034. * Note: PASD motherboards uses the Line In 2 as the input for
  7035. * front panel mic (mic 2)
  7036. */
  7037. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7038. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7039. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7040. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7041. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7042. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7043. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7044. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7045. /*
  7046. * Set up output mixers (0x0c - 0x0e)
  7047. */
  7048. /* set vol=0 to output mixers */
  7049. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7050. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7051. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7052. /* set up input amps for analog loopback */
  7053. /* Amp Indices: DAC = 0, mixer = 1 */
  7054. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7055. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7056. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7057. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7058. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7059. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7060. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7061. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7062. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7063. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7064. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7065. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7066. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7067. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7068. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7069. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7070. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7071. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7072. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7073. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7074. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7075. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7076. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7077. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7078. /* FIXME: use matrix-type input source selection */
  7079. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7080. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7081. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7082. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7083. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7084. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7085. /* Input mixer2 */
  7086. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7087. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7088. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7089. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7090. /* Input mixer3 */
  7091. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7092. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7093. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7094. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7095. { }
  7096. };
  7097. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7098. /*
  7099. * Unmute ADC0-2 and set the default input to mic-in
  7100. */
  7101. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7102. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7103. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7104. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7105. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7106. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7107. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7108. * mixer widget
  7109. * Note: PASD motherboards uses the Line In 2 as the input for front
  7110. * panel mic (mic 2)
  7111. */
  7112. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7113. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7114. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7115. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7116. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7117. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7118. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7119. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7120. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7121. /*
  7122. * Set up output mixers (0x0c - 0x0e)
  7123. */
  7124. /* set vol=0 to output mixers */
  7125. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7126. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7127. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7128. /* set up input amps for analog loopback */
  7129. /* Amp Indices: DAC = 0, mixer = 1 */
  7130. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7131. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7132. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7133. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7134. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7135. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7136. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7137. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7138. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7139. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7140. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7141. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7142. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7143. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7144. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7145. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7146. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7147. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7148. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7149. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7150. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7151. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7152. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7153. /* FIXME: use matrix-type input source selection */
  7154. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7155. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7156. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7157. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7158. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7159. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7160. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7161. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7162. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7163. /* Input mixer2 */
  7164. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7165. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7166. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7167. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7168. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7169. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7170. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7171. /* Input mixer3 */
  7172. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7173. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7174. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7175. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7176. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7177. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7178. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7179. { }
  7180. };
  7181. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7182. #define alc262_loopbacks alc880_loopbacks
  7183. #endif
  7184. /* pcm configuration: identiacal with ALC880 */
  7185. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7186. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7187. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7188. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7189. /*
  7190. * BIOS auto configuration
  7191. */
  7192. static int alc262_parse_auto_config(struct hda_codec *codec)
  7193. {
  7194. struct alc_spec *spec = codec->spec;
  7195. int err;
  7196. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7197. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7198. alc262_ignore);
  7199. if (err < 0)
  7200. return err;
  7201. if (!spec->autocfg.line_outs)
  7202. return 0; /* can't find valid BIOS pin config */
  7203. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7204. if (err < 0)
  7205. return err;
  7206. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7207. if (err < 0)
  7208. return err;
  7209. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7210. if (spec->autocfg.dig_out_pin)
  7211. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7212. if (spec->autocfg.dig_in_pin)
  7213. spec->dig_in_nid = ALC262_DIGIN_NID;
  7214. if (spec->kctl_alloc)
  7215. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7216. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7217. spec->num_mux_defs = 1;
  7218. spec->input_mux = &spec->private_imux;
  7219. return 1;
  7220. }
  7221. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7222. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7223. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7224. /* init callback for auto-configuration model -- overriding the default init */
  7225. static void alc262_auto_init(struct hda_codec *codec)
  7226. {
  7227. alc262_auto_init_multi_out(codec);
  7228. alc262_auto_init_hp_out(codec);
  7229. alc262_auto_init_analog_input(codec);
  7230. }
  7231. /*
  7232. * configuration and preset
  7233. */
  7234. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7235. [ALC262_BASIC] = "basic",
  7236. [ALC262_HIPPO] = "hippo",
  7237. [ALC262_HIPPO_1] = "hippo_1",
  7238. [ALC262_FUJITSU] = "fujitsu",
  7239. [ALC262_HP_BPC] = "hp-bpc",
  7240. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7241. [ALC262_BENQ_ED8] = "benq",
  7242. [ALC262_BENQ_T31] = "benq-t31",
  7243. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7244. [ALC262_AUTO] = "auto",
  7245. };
  7246. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7247. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7248. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7249. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7250. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7251. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7252. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7253. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7254. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7255. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7256. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7257. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7258. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7259. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7260. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7261. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7262. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7263. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7264. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7265. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7266. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7267. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7268. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7269. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7270. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7271. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7272. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7273. {}
  7274. };
  7275. static struct alc_config_preset alc262_presets[] = {
  7276. [ALC262_BASIC] = {
  7277. .mixers = { alc262_base_mixer },
  7278. .init_verbs = { alc262_init_verbs },
  7279. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7280. .dac_nids = alc262_dac_nids,
  7281. .hp_nid = 0x03,
  7282. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7283. .channel_mode = alc262_modes,
  7284. .input_mux = &alc262_capture_source,
  7285. },
  7286. [ALC262_HIPPO] = {
  7287. .mixers = { alc262_base_mixer },
  7288. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7289. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7290. .dac_nids = alc262_dac_nids,
  7291. .hp_nid = 0x03,
  7292. .dig_out_nid = ALC262_DIGOUT_NID,
  7293. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7294. .channel_mode = alc262_modes,
  7295. .input_mux = &alc262_capture_source,
  7296. .unsol_event = alc262_hippo_unsol_event,
  7297. .init_hook = alc262_hippo_automute,
  7298. },
  7299. [ALC262_HIPPO_1] = {
  7300. .mixers = { alc262_hippo1_mixer },
  7301. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7302. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7303. .dac_nids = alc262_dac_nids,
  7304. .hp_nid = 0x02,
  7305. .dig_out_nid = ALC262_DIGOUT_NID,
  7306. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7307. .channel_mode = alc262_modes,
  7308. .input_mux = &alc262_capture_source,
  7309. .unsol_event = alc262_hippo1_unsol_event,
  7310. .init_hook = alc262_hippo1_automute,
  7311. },
  7312. [ALC262_FUJITSU] = {
  7313. .mixers = { alc262_fujitsu_mixer },
  7314. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7315. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7316. .dac_nids = alc262_dac_nids,
  7317. .hp_nid = 0x03,
  7318. .dig_out_nid = ALC262_DIGOUT_NID,
  7319. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7320. .channel_mode = alc262_modes,
  7321. .input_mux = &alc262_fujitsu_capture_source,
  7322. .unsol_event = alc262_fujitsu_unsol_event,
  7323. },
  7324. [ALC262_HP_BPC] = {
  7325. .mixers = { alc262_HP_BPC_mixer },
  7326. .init_verbs = { alc262_HP_BPC_init_verbs },
  7327. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7328. .dac_nids = alc262_dac_nids,
  7329. .hp_nid = 0x03,
  7330. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7331. .channel_mode = alc262_modes,
  7332. .input_mux = &alc262_HP_capture_source,
  7333. },
  7334. [ALC262_HP_BPC_D7000_WF] = {
  7335. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7336. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7337. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7338. .dac_nids = alc262_dac_nids,
  7339. .hp_nid = 0x03,
  7340. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7341. .channel_mode = alc262_modes,
  7342. .input_mux = &alc262_HP_capture_source,
  7343. },
  7344. [ALC262_HP_BPC_D7000_WL] = {
  7345. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7346. alc262_HP_BPC_WildWest_option_mixer },
  7347. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7348. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7349. .dac_nids = alc262_dac_nids,
  7350. .hp_nid = 0x03,
  7351. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7352. .channel_mode = alc262_modes,
  7353. .input_mux = &alc262_HP_capture_source,
  7354. },
  7355. [ALC262_BENQ_ED8] = {
  7356. .mixers = { alc262_base_mixer },
  7357. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7358. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7359. .dac_nids = alc262_dac_nids,
  7360. .hp_nid = 0x03,
  7361. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7362. .channel_mode = alc262_modes,
  7363. .input_mux = &alc262_capture_source,
  7364. },
  7365. [ALC262_SONY_ASSAMD] = {
  7366. .mixers = { alc262_sony_mixer },
  7367. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7368. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7369. .dac_nids = alc262_dac_nids,
  7370. .hp_nid = 0x02,
  7371. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7372. .channel_mode = alc262_modes,
  7373. .input_mux = &alc262_capture_source,
  7374. .unsol_event = alc262_hippo_unsol_event,
  7375. .init_hook = alc262_hippo_automute,
  7376. },
  7377. [ALC262_BENQ_T31] = {
  7378. .mixers = { alc262_benq_t31_mixer },
  7379. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7380. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7381. .dac_nids = alc262_dac_nids,
  7382. .hp_nid = 0x03,
  7383. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7384. .channel_mode = alc262_modes,
  7385. .input_mux = &alc262_capture_source,
  7386. .unsol_event = alc262_hippo_unsol_event,
  7387. .init_hook = alc262_hippo_automute,
  7388. },
  7389. };
  7390. static int patch_alc262(struct hda_codec *codec)
  7391. {
  7392. struct alc_spec *spec;
  7393. int board_config;
  7394. int err;
  7395. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7396. if (spec == NULL)
  7397. return -ENOMEM;
  7398. codec->spec = spec;
  7399. #if 0
  7400. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7401. * under-run
  7402. */
  7403. {
  7404. int tmp;
  7405. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7406. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7407. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7408. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7409. }
  7410. #endif
  7411. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7412. alc262_models,
  7413. alc262_cfg_tbl);
  7414. if (board_config < 0) {
  7415. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7416. "trying auto-probe from BIOS...\n");
  7417. board_config = ALC262_AUTO;
  7418. }
  7419. if (board_config == ALC262_AUTO) {
  7420. /* automatic parse from the BIOS config */
  7421. err = alc262_parse_auto_config(codec);
  7422. if (err < 0) {
  7423. alc_free(codec);
  7424. return err;
  7425. } else if (!err) {
  7426. printk(KERN_INFO
  7427. "hda_codec: Cannot set up configuration "
  7428. "from BIOS. Using base mode...\n");
  7429. board_config = ALC262_BASIC;
  7430. }
  7431. }
  7432. if (board_config != ALC262_AUTO)
  7433. setup_preset(spec, &alc262_presets[board_config]);
  7434. spec->stream_name_analog = "ALC262 Analog";
  7435. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7436. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7437. spec->stream_name_digital = "ALC262 Digital";
  7438. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7439. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7440. if (!spec->adc_nids && spec->input_mux) {
  7441. /* check whether NID 0x07 is valid */
  7442. unsigned int wcap = get_wcaps(codec, 0x07);
  7443. /* get type */
  7444. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7445. if (wcap != AC_WID_AUD_IN) {
  7446. spec->adc_nids = alc262_adc_nids_alt;
  7447. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7448. spec->mixers[spec->num_mixers] =
  7449. alc262_capture_alt_mixer;
  7450. spec->num_mixers++;
  7451. } else {
  7452. spec->adc_nids = alc262_adc_nids;
  7453. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7454. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7455. spec->num_mixers++;
  7456. }
  7457. }
  7458. codec->patch_ops = alc_patch_ops;
  7459. if (board_config == ALC262_AUTO)
  7460. spec->init_hook = alc262_auto_init;
  7461. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7462. if (!spec->loopback.amplist)
  7463. spec->loopback.amplist = alc262_loopbacks;
  7464. #endif
  7465. return 0;
  7466. }
  7467. /*
  7468. * ALC268 channel source setting (2 channel)
  7469. */
  7470. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7471. #define alc268_modes alc260_modes
  7472. static hda_nid_t alc268_dac_nids[2] = {
  7473. /* front, hp */
  7474. 0x02, 0x03
  7475. };
  7476. static hda_nid_t alc268_adc_nids[2] = {
  7477. /* ADC0-1 */
  7478. 0x08, 0x07
  7479. };
  7480. static hda_nid_t alc268_adc_nids_alt[1] = {
  7481. /* ADC0 */
  7482. 0x08
  7483. };
  7484. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7485. /* output mixer control */
  7486. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7487. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7488. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7489. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7490. { }
  7491. };
  7492. static struct hda_verb alc268_eapd_verbs[] = {
  7493. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7494. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7495. { }
  7496. };
  7497. /* Toshiba specific */
  7498. #define alc268_toshiba_automute alc262_hippo_automute
  7499. static struct hda_verb alc268_toshiba_verbs[] = {
  7500. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7501. { } /* end */
  7502. };
  7503. /* Acer specific */
  7504. #define alc268_acer_bind_master_vol alc262_fujitsu_bind_master_vol
  7505. #define alc268_acer_master_sw_put alc262_fujitsu_master_sw_put
  7506. #define alc268_acer_automute alc262_fujitsu_automute
  7507. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  7508. /* output mixer control */
  7509. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  7510. {
  7511. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7512. .name = "Master Playback Switch",
  7513. .info = snd_hda_mixer_amp_switch_info,
  7514. .get = snd_hda_mixer_amp_switch_get,
  7515. .put = alc268_acer_master_sw_put,
  7516. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7517. },
  7518. { }
  7519. };
  7520. static struct hda_verb alc268_acer_verbs[] = {
  7521. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7522. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7523. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7524. { }
  7525. };
  7526. /* unsolicited event for HP jack sensing */
  7527. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  7528. unsigned int res)
  7529. {
  7530. if ((res >> 28) != ALC880_HP_EVENT)
  7531. return;
  7532. alc268_toshiba_automute(codec);
  7533. }
  7534. static void alc268_acer_unsol_event(struct hda_codec *codec,
  7535. unsigned int res)
  7536. {
  7537. if ((res >> 28) != ALC880_HP_EVENT)
  7538. return;
  7539. alc268_acer_automute(codec, 1);
  7540. }
  7541. /*
  7542. * generic initialization of ADC, input mixers and output mixers
  7543. */
  7544. static struct hda_verb alc268_base_init_verbs[] = {
  7545. /* Unmute DAC0-1 and set vol = 0 */
  7546. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7547. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7548. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7549. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7550. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7551. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7552. /*
  7553. * Set up output mixers (0x0c - 0x0e)
  7554. */
  7555. /* set vol=0 to output mixers */
  7556. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7557. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7558. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7559. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7560. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7561. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7562. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7563. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7564. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7565. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7566. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7567. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7568. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7569. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7570. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7571. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7572. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7573. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7574. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7575. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7576. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7577. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7578. /* FIXME: use matrix-type input source selection */
  7579. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7580. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7581. /* Input mixer2 */
  7582. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7583. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7584. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7585. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7586. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7587. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7588. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7589. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7590. { }
  7591. };
  7592. /*
  7593. * generic initialization of ADC, input mixers and output mixers
  7594. */
  7595. static struct hda_verb alc268_volume_init_verbs[] = {
  7596. /* set output DAC */
  7597. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7598. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7599. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7600. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7601. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7602. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7603. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7604. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7605. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7606. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7607. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7608. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7609. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7610. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7611. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7612. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7613. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7614. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7615. /* set PCBEEP vol = 0 */
  7616. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7617. { }
  7618. };
  7619. #define alc268_mux_enum_info alc_mux_enum_info
  7620. #define alc268_mux_enum_get alc_mux_enum_get
  7621. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7622. struct snd_ctl_elem_value *ucontrol)
  7623. {
  7624. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7625. struct alc_spec *spec = codec->spec;
  7626. const struct hda_input_mux *imux = spec->input_mux;
  7627. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7628. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7629. hda_nid_t nid = capture_mixers[adc_idx];
  7630. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7631. unsigned int i, idx;
  7632. idx = ucontrol->value.enumerated.item[0];
  7633. if (idx >= imux->num_items)
  7634. idx = imux->num_items - 1;
  7635. if (*cur_val == idx)
  7636. return 0;
  7637. for (i = 0; i < imux->num_items; i++) {
  7638. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  7639. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  7640. imux->items[i].index,
  7641. HDA_AMP_MUTE, v);
  7642. snd_hda_codec_write_cache(codec, nid, 0,
  7643. AC_VERB_SET_CONNECT_SEL,
  7644. idx );
  7645. }
  7646. *cur_val = idx;
  7647. return 1;
  7648. }
  7649. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7650. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7651. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7652. {
  7653. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7654. /* The multiple "Capture Source" controls confuse alsamixer
  7655. * So call somewhat different..
  7656. * FIXME: the controls appear in the "playback" view!
  7657. */
  7658. /* .name = "Capture Source", */
  7659. .name = "Input Source",
  7660. .count = 1,
  7661. .info = alc268_mux_enum_info,
  7662. .get = alc268_mux_enum_get,
  7663. .put = alc268_mux_enum_put,
  7664. },
  7665. { } /* end */
  7666. };
  7667. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7668. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7669. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7670. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7671. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7672. {
  7673. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7674. /* The multiple "Capture Source" controls confuse alsamixer
  7675. * So call somewhat different..
  7676. * FIXME: the controls appear in the "playback" view!
  7677. */
  7678. /* .name = "Capture Source", */
  7679. .name = "Input Source",
  7680. .count = 2,
  7681. .info = alc268_mux_enum_info,
  7682. .get = alc268_mux_enum_get,
  7683. .put = alc268_mux_enum_put,
  7684. },
  7685. { } /* end */
  7686. };
  7687. static struct hda_input_mux alc268_capture_source = {
  7688. .num_items = 4,
  7689. .items = {
  7690. { "Mic", 0x0 },
  7691. { "Front Mic", 0x1 },
  7692. { "Line", 0x2 },
  7693. { "CD", 0x3 },
  7694. },
  7695. };
  7696. /* create input playback/capture controls for the given pin */
  7697. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7698. const char *ctlname, int idx)
  7699. {
  7700. char name[32];
  7701. int err;
  7702. sprintf(name, "%s Playback Volume", ctlname);
  7703. if (nid == 0x14) {
  7704. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7705. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7706. HDA_OUTPUT));
  7707. if (err < 0)
  7708. return err;
  7709. } else if (nid == 0x15) {
  7710. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7711. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7712. HDA_OUTPUT));
  7713. if (err < 0)
  7714. return err;
  7715. } else
  7716. return -1;
  7717. sprintf(name, "%s Playback Switch", ctlname);
  7718. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7719. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7720. if (err < 0)
  7721. return err;
  7722. return 0;
  7723. }
  7724. /* add playback controls from the parsed DAC table */
  7725. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7726. const struct auto_pin_cfg *cfg)
  7727. {
  7728. hda_nid_t nid;
  7729. int err;
  7730. spec->multiout.num_dacs = 2; /* only use one dac */
  7731. spec->multiout.dac_nids = spec->private_dac_nids;
  7732. spec->multiout.dac_nids[0] = 2;
  7733. spec->multiout.dac_nids[1] = 3;
  7734. nid = cfg->line_out_pins[0];
  7735. if (nid)
  7736. alc268_new_analog_output(spec, nid, "Front", 0);
  7737. nid = cfg->speaker_pins[0];
  7738. if (nid == 0x1d) {
  7739. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7740. "Speaker Playback Volume",
  7741. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7742. if (err < 0)
  7743. return err;
  7744. }
  7745. nid = cfg->hp_pins[0];
  7746. if (nid)
  7747. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7748. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7749. if (nid == 0x16) {
  7750. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7751. "Mono Playback Switch",
  7752. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7753. if (err < 0)
  7754. return err;
  7755. }
  7756. return 0;
  7757. }
  7758. /* create playback/capture controls for input pins */
  7759. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7760. const struct auto_pin_cfg *cfg)
  7761. {
  7762. struct hda_input_mux *imux = &spec->private_imux;
  7763. int i, idx1;
  7764. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7765. switch(cfg->input_pins[i]) {
  7766. case 0x18:
  7767. idx1 = 0; /* Mic 1 */
  7768. break;
  7769. case 0x19:
  7770. idx1 = 1; /* Mic 2 */
  7771. break;
  7772. case 0x1a:
  7773. idx1 = 2; /* Line In */
  7774. break;
  7775. case 0x1c:
  7776. idx1 = 3; /* CD */
  7777. break;
  7778. default:
  7779. continue;
  7780. }
  7781. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7782. imux->items[imux->num_items].index = idx1;
  7783. imux->num_items++;
  7784. }
  7785. return 0;
  7786. }
  7787. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7788. {
  7789. struct alc_spec *spec = codec->spec;
  7790. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7791. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7792. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7793. unsigned int dac_vol1, dac_vol2;
  7794. if (speaker_nid) {
  7795. snd_hda_codec_write(codec, speaker_nid, 0,
  7796. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7797. snd_hda_codec_write(codec, 0x0f, 0,
  7798. AC_VERB_SET_AMP_GAIN_MUTE,
  7799. AMP_IN_UNMUTE(1));
  7800. snd_hda_codec_write(codec, 0x10, 0,
  7801. AC_VERB_SET_AMP_GAIN_MUTE,
  7802. AMP_IN_UNMUTE(1));
  7803. } else {
  7804. snd_hda_codec_write(codec, 0x0f, 0,
  7805. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7806. snd_hda_codec_write(codec, 0x10, 0,
  7807. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7808. }
  7809. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7810. if (line_nid == 0x14)
  7811. dac_vol2 = AMP_OUT_ZERO;
  7812. else if (line_nid == 0x15)
  7813. dac_vol1 = AMP_OUT_ZERO;
  7814. if (hp_nid == 0x14)
  7815. dac_vol2 = AMP_OUT_ZERO;
  7816. else if (hp_nid == 0x15)
  7817. dac_vol1 = AMP_OUT_ZERO;
  7818. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7819. spec->autocfg.line_out_pins[1] != 0x16 ||
  7820. spec->autocfg.line_out_pins[2] != 0x16)
  7821. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7822. snd_hda_codec_write(codec, 0x02, 0,
  7823. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7824. snd_hda_codec_write(codec, 0x03, 0,
  7825. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7826. }
  7827. /* pcm configuration: identiacal with ALC880 */
  7828. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7829. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7830. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7831. /*
  7832. * BIOS auto configuration
  7833. */
  7834. static int alc268_parse_auto_config(struct hda_codec *codec)
  7835. {
  7836. struct alc_spec *spec = codec->spec;
  7837. int err;
  7838. static hda_nid_t alc268_ignore[] = { 0 };
  7839. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7840. alc268_ignore);
  7841. if (err < 0)
  7842. return err;
  7843. if (!spec->autocfg.line_outs)
  7844. return 0; /* can't find valid BIOS pin config */
  7845. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7846. if (err < 0)
  7847. return err;
  7848. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7849. if (err < 0)
  7850. return err;
  7851. spec->multiout.max_channels = 2;
  7852. /* digital only support output */
  7853. if (spec->autocfg.dig_out_pin)
  7854. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7855. if (spec->kctl_alloc)
  7856. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7857. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7858. spec->num_mux_defs = 1;
  7859. spec->input_mux = &spec->private_imux;
  7860. return 1;
  7861. }
  7862. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7863. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7864. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7865. /* init callback for auto-configuration model -- overriding the default init */
  7866. static void alc268_auto_init(struct hda_codec *codec)
  7867. {
  7868. alc268_auto_init_multi_out(codec);
  7869. alc268_auto_init_hp_out(codec);
  7870. alc268_auto_init_mono_speaker_out(codec);
  7871. alc268_auto_init_analog_input(codec);
  7872. }
  7873. /*
  7874. * configuration and preset
  7875. */
  7876. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7877. [ALC268_3ST] = "3stack",
  7878. [ALC268_TOSHIBA] = "toshiba",
  7879. [ALC268_ACER] = "acer",
  7880. [ALC268_AUTO] = "auto",
  7881. };
  7882. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7883. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7884. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  7885. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  7886. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  7887. {}
  7888. };
  7889. static struct alc_config_preset alc268_presets[] = {
  7890. [ALC268_3ST] = {
  7891. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7892. .init_verbs = { alc268_base_init_verbs },
  7893. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7894. .dac_nids = alc268_dac_nids,
  7895. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7896. .adc_nids = alc268_adc_nids_alt,
  7897. .hp_nid = 0x03,
  7898. .dig_out_nid = ALC268_DIGOUT_NID,
  7899. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7900. .channel_mode = alc268_modes,
  7901. .input_mux = &alc268_capture_source,
  7902. },
  7903. [ALC268_TOSHIBA] = {
  7904. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7905. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  7906. alc268_toshiba_verbs },
  7907. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7908. .dac_nids = alc268_dac_nids,
  7909. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7910. .adc_nids = alc268_adc_nids_alt,
  7911. .hp_nid = 0x03,
  7912. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7913. .channel_mode = alc268_modes,
  7914. .input_mux = &alc268_capture_source,
  7915. .input_mux = &alc268_capture_source,
  7916. .unsol_event = alc268_toshiba_unsol_event,
  7917. .init_hook = alc268_toshiba_automute,
  7918. },
  7919. [ALC268_ACER] = {
  7920. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  7921. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  7922. alc268_acer_verbs },
  7923. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7924. .dac_nids = alc268_dac_nids,
  7925. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7926. .adc_nids = alc268_adc_nids_alt,
  7927. .hp_nid = 0x02,
  7928. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7929. .channel_mode = alc268_modes,
  7930. .input_mux = &alc268_capture_source,
  7931. .unsol_event = alc268_acer_unsol_event,
  7932. },
  7933. };
  7934. static int patch_alc268(struct hda_codec *codec)
  7935. {
  7936. struct alc_spec *spec;
  7937. int board_config;
  7938. int err;
  7939. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7940. if (spec == NULL)
  7941. return -ENOMEM;
  7942. codec->spec = spec;
  7943. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7944. alc268_models,
  7945. alc268_cfg_tbl);
  7946. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7947. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7948. "trying auto-probe from BIOS...\n");
  7949. board_config = ALC268_AUTO;
  7950. }
  7951. if (board_config == ALC268_AUTO) {
  7952. /* automatic parse from the BIOS config */
  7953. err = alc268_parse_auto_config(codec);
  7954. if (err < 0) {
  7955. alc_free(codec);
  7956. return err;
  7957. } else if (!err) {
  7958. printk(KERN_INFO
  7959. "hda_codec: Cannot set up configuration "
  7960. "from BIOS. Using base mode...\n");
  7961. board_config = ALC268_3ST;
  7962. }
  7963. }
  7964. if (board_config != ALC268_AUTO)
  7965. setup_preset(spec, &alc268_presets[board_config]);
  7966. spec->stream_name_analog = "ALC268 Analog";
  7967. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7968. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7969. spec->stream_name_digital = "ALC268 Digital";
  7970. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7971. if (board_config == ALC268_AUTO) {
  7972. if (!spec->adc_nids && spec->input_mux) {
  7973. /* check whether NID 0x07 is valid */
  7974. unsigned int wcap = get_wcaps(codec, 0x07);
  7975. /* get type */
  7976. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7977. if (wcap != AC_WID_AUD_IN) {
  7978. spec->adc_nids = alc268_adc_nids_alt;
  7979. spec->num_adc_nids =
  7980. ARRAY_SIZE(alc268_adc_nids_alt);
  7981. spec->mixers[spec->num_mixers] =
  7982. alc268_capture_alt_mixer;
  7983. spec->num_mixers++;
  7984. } else {
  7985. spec->adc_nids = alc268_adc_nids;
  7986. spec->num_adc_nids =
  7987. ARRAY_SIZE(alc268_adc_nids);
  7988. spec->mixers[spec->num_mixers] =
  7989. alc268_capture_mixer;
  7990. spec->num_mixers++;
  7991. }
  7992. }
  7993. }
  7994. codec->patch_ops = alc_patch_ops;
  7995. if (board_config == ALC268_AUTO)
  7996. spec->init_hook = alc268_auto_init;
  7997. return 0;
  7998. }
  7999. /*
  8000. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8001. */
  8002. /*
  8003. * set the path ways for 2 channel output
  8004. * need to set the codec line out and mic 1 pin widgets to inputs
  8005. */
  8006. static struct hda_verb alc861_threestack_ch2_init[] = {
  8007. /* set pin widget 1Ah (line in) for input */
  8008. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8009. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8010. * the vref
  8011. */
  8012. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8013. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8014. #if 0
  8015. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8016. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8017. #endif
  8018. { } /* end */
  8019. };
  8020. /*
  8021. * 6ch mode
  8022. * need to set the codec line out and mic 1 pin widgets to outputs
  8023. */
  8024. static struct hda_verb alc861_threestack_ch6_init[] = {
  8025. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8026. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8027. /* set pin widget 18h (mic1) for output (CLFE)*/
  8028. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8029. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8030. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8031. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8032. #if 0
  8033. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8034. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8035. #endif
  8036. { } /* end */
  8037. };
  8038. static struct hda_channel_mode alc861_threestack_modes[2] = {
  8039. { 2, alc861_threestack_ch2_init },
  8040. { 6, alc861_threestack_ch6_init },
  8041. };
  8042. /* Set mic1 as input and unmute the mixer */
  8043. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  8044. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8045. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8046. { } /* end */
  8047. };
  8048. /* Set mic1 as output and mute mixer */
  8049. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  8050. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8051. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8052. { } /* end */
  8053. };
  8054. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  8055. { 2, alc861_uniwill_m31_ch2_init },
  8056. { 4, alc861_uniwill_m31_ch4_init },
  8057. };
  8058. /* Set mic1 and line-in as input and unmute the mixer */
  8059. static struct hda_verb alc861_asus_ch2_init[] = {
  8060. /* set pin widget 1Ah (line in) for input */
  8061. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8062. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8063. * the vref
  8064. */
  8065. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8066. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8067. #if 0
  8068. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8069. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8070. #endif
  8071. { } /* end */
  8072. };
  8073. /* Set mic1 nad line-in as output and mute mixer */
  8074. static struct hda_verb alc861_asus_ch6_init[] = {
  8075. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8076. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8077. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8078. /* set pin widget 18h (mic1) for output (CLFE)*/
  8079. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8080. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8081. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8082. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8083. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8084. #if 0
  8085. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8086. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8087. #endif
  8088. { } /* end */
  8089. };
  8090. static struct hda_channel_mode alc861_asus_modes[2] = {
  8091. { 2, alc861_asus_ch2_init },
  8092. { 6, alc861_asus_ch6_init },
  8093. };
  8094. /* patch-ALC861 */
  8095. static struct snd_kcontrol_new alc861_base_mixer[] = {
  8096. /* output mixer control */
  8097. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8098. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8099. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8100. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8101. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8102. /*Input mixer control */
  8103. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8104. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8105. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8106. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8107. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8108. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8109. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8110. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8111. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8112. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8113. /* Capture mixer control */
  8114. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8115. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8116. {
  8117. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8118. .name = "Capture Source",
  8119. .count = 1,
  8120. .info = alc_mux_enum_info,
  8121. .get = alc_mux_enum_get,
  8122. .put = alc_mux_enum_put,
  8123. },
  8124. { } /* end */
  8125. };
  8126. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8127. /* output mixer control */
  8128. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8129. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8130. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8131. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8132. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8133. /* Input mixer control */
  8134. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8135. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8136. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8137. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8138. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8139. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8140. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8141. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8142. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8143. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8144. /* Capture mixer control */
  8145. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8146. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8147. {
  8148. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8149. .name = "Capture Source",
  8150. .count = 1,
  8151. .info = alc_mux_enum_info,
  8152. .get = alc_mux_enum_get,
  8153. .put = alc_mux_enum_put,
  8154. },
  8155. {
  8156. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8157. .name = "Channel Mode",
  8158. .info = alc_ch_mode_info,
  8159. .get = alc_ch_mode_get,
  8160. .put = alc_ch_mode_put,
  8161. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8162. },
  8163. { } /* end */
  8164. };
  8165. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8166. /* output mixer control */
  8167. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8168. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8169. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8170. /*Capture mixer control */
  8171. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8172. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8173. {
  8174. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8175. .name = "Capture Source",
  8176. .count = 1,
  8177. .info = alc_mux_enum_info,
  8178. .get = alc_mux_enum_get,
  8179. .put = alc_mux_enum_put,
  8180. },
  8181. { } /* end */
  8182. };
  8183. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8184. /* output mixer control */
  8185. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8186. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8187. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8188. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8189. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8190. /* Input mixer control */
  8191. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8192. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8193. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8194. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8195. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8196. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8197. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8198. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8199. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8200. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8201. /* Capture mixer control */
  8202. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8203. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8204. {
  8205. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8206. .name = "Capture Source",
  8207. .count = 1,
  8208. .info = alc_mux_enum_info,
  8209. .get = alc_mux_enum_get,
  8210. .put = alc_mux_enum_put,
  8211. },
  8212. {
  8213. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8214. .name = "Channel Mode",
  8215. .info = alc_ch_mode_info,
  8216. .get = alc_ch_mode_get,
  8217. .put = alc_ch_mode_put,
  8218. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8219. },
  8220. { } /* end */
  8221. };
  8222. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8223. /* output mixer control */
  8224. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8225. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8226. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8227. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8228. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8229. /* Input mixer control */
  8230. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8231. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8232. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8233. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8234. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8235. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8236. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8237. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8238. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8239. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8240. /* Capture mixer control */
  8241. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8242. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8243. {
  8244. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8245. .name = "Capture Source",
  8246. .count = 1,
  8247. .info = alc_mux_enum_info,
  8248. .get = alc_mux_enum_get,
  8249. .put = alc_mux_enum_put,
  8250. },
  8251. {
  8252. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8253. .name = "Channel Mode",
  8254. .info = alc_ch_mode_info,
  8255. .get = alc_ch_mode_get,
  8256. .put = alc_ch_mode_put,
  8257. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8258. },
  8259. { }
  8260. };
  8261. /* additional mixer */
  8262. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8263. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8264. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8265. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8266. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8267. { }
  8268. };
  8269. /*
  8270. * generic initialization of ADC, input mixers and output mixers
  8271. */
  8272. static struct hda_verb alc861_base_init_verbs[] = {
  8273. /*
  8274. * Unmute ADC0 and set the default input to mic-in
  8275. */
  8276. /* port-A for surround (rear panel) */
  8277. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8278. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8279. /* port-B for mic-in (rear panel) with vref */
  8280. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8281. /* port-C for line-in (rear panel) */
  8282. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8283. /* port-D for Front */
  8284. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8285. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8286. /* port-E for HP out (front panel) */
  8287. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8288. /* route front PCM to HP */
  8289. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8290. /* port-F for mic-in (front panel) with vref */
  8291. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8292. /* port-G for CLFE (rear panel) */
  8293. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8294. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8295. /* port-H for side (rear panel) */
  8296. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8297. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8298. /* CD-in */
  8299. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8300. /* route front mic to ADC1*/
  8301. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8302. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8303. /* Unmute DAC0~3 & spdif out*/
  8304. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8305. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8306. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8307. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8308. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8309. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8310. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8311. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8312. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8313. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8314. /* Unmute Stereo Mixer 15 */
  8315. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8316. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8317. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8318. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8319. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8320. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8321. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8322. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8323. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8324. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8325. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8326. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8327. /* hp used DAC 3 (Front) */
  8328. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8329. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8330. { }
  8331. };
  8332. static struct hda_verb alc861_threestack_init_verbs[] = {
  8333. /*
  8334. * Unmute ADC0 and set the default input to mic-in
  8335. */
  8336. /* port-A for surround (rear panel) */
  8337. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8338. /* port-B for mic-in (rear panel) with vref */
  8339. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8340. /* port-C for line-in (rear panel) */
  8341. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8342. /* port-D for Front */
  8343. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8344. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8345. /* port-E for HP out (front panel) */
  8346. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8347. /* route front PCM to HP */
  8348. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8349. /* port-F for mic-in (front panel) with vref */
  8350. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8351. /* port-G for CLFE (rear panel) */
  8352. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8353. /* port-H for side (rear panel) */
  8354. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8355. /* CD-in */
  8356. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8357. /* route front mic to ADC1*/
  8358. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8359. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8360. /* Unmute DAC0~3 & spdif out*/
  8361. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8362. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8363. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8364. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8365. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8366. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8367. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8368. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8369. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8370. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8371. /* Unmute Stereo Mixer 15 */
  8372. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8373. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8374. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8375. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8376. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8377. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8378. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8379. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8380. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8381. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8382. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8383. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8384. /* hp used DAC 3 (Front) */
  8385. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8386. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8387. { }
  8388. };
  8389. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8390. /*
  8391. * Unmute ADC0 and set the default input to mic-in
  8392. */
  8393. /* port-A for surround (rear panel) */
  8394. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8395. /* port-B for mic-in (rear panel) with vref */
  8396. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8397. /* port-C for line-in (rear panel) */
  8398. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8399. /* port-D for Front */
  8400. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8401. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8402. /* port-E for HP out (front panel) */
  8403. /* this has to be set to VREF80 */
  8404. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8405. /* route front PCM to HP */
  8406. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8407. /* port-F for mic-in (front panel) with vref */
  8408. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8409. /* port-G for CLFE (rear panel) */
  8410. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8411. /* port-H for side (rear panel) */
  8412. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8413. /* CD-in */
  8414. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8415. /* route front mic to ADC1*/
  8416. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8417. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8418. /* Unmute DAC0~3 & spdif out*/
  8419. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8420. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8421. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8422. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8423. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8424. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8425. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8426. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8427. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8428. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8429. /* Unmute Stereo Mixer 15 */
  8430. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8431. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8432. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8433. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8434. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8435. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8436. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8437. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8438. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8439. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8440. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8441. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8442. /* hp used DAC 3 (Front) */
  8443. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8444. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8445. { }
  8446. };
  8447. static struct hda_verb alc861_asus_init_verbs[] = {
  8448. /*
  8449. * Unmute ADC0 and set the default input to mic-in
  8450. */
  8451. /* port-A for surround (rear panel)
  8452. * according to codec#0 this is the HP jack
  8453. */
  8454. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8455. /* route front PCM to HP */
  8456. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8457. /* port-B for mic-in (rear panel) with vref */
  8458. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8459. /* port-C for line-in (rear panel) */
  8460. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8461. /* port-D for Front */
  8462. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8463. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8464. /* port-E for HP out (front panel) */
  8465. /* this has to be set to VREF80 */
  8466. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8467. /* route front PCM to HP */
  8468. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8469. /* port-F for mic-in (front panel) with vref */
  8470. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8471. /* port-G for CLFE (rear panel) */
  8472. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8473. /* port-H for side (rear panel) */
  8474. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8475. /* CD-in */
  8476. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8477. /* route front mic to ADC1*/
  8478. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8479. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8480. /* Unmute DAC0~3 & spdif out*/
  8481. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8482. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8483. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8484. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8485. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8486. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8487. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8488. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8489. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8490. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8491. /* Unmute Stereo Mixer 15 */
  8492. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8493. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8494. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8495. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8496. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8497. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8498. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8499. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8500. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8501. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8502. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8503. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8504. /* hp used DAC 3 (Front) */
  8505. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8506. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8507. { }
  8508. };
  8509. /* additional init verbs for ASUS laptops */
  8510. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8511. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8512. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8513. { }
  8514. };
  8515. /*
  8516. * generic initialization of ADC, input mixers and output mixers
  8517. */
  8518. static struct hda_verb alc861_auto_init_verbs[] = {
  8519. /*
  8520. * Unmute ADC0 and set the default input to mic-in
  8521. */
  8522. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8523. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8524. /* Unmute DAC0~3 & spdif out*/
  8525. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8526. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8527. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8528. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8529. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8530. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8531. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8532. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8533. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8534. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8535. /* Unmute Stereo Mixer 15 */
  8536. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8537. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8538. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8539. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8540. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8541. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8542. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8543. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8544. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8545. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8546. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8547. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8548. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8549. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8550. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8551. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8552. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8553. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8554. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8555. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8556. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8557. { }
  8558. };
  8559. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8560. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8561. { }
  8562. };
  8563. /* toggle speaker-output according to the hp-jack state */
  8564. static void alc861_toshiba_automute(struct hda_codec *codec)
  8565. {
  8566. unsigned int present;
  8567. present = snd_hda_codec_read(codec, 0x0f, 0,
  8568. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8569. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  8570. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  8571. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  8572. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  8573. }
  8574. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8575. unsigned int res)
  8576. {
  8577. if ((res >> 26) == ALC880_HP_EVENT)
  8578. alc861_toshiba_automute(codec);
  8579. }
  8580. /* pcm configuration: identiacal with ALC880 */
  8581. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8582. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8583. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8584. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8585. #define ALC861_DIGOUT_NID 0x07
  8586. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8587. { 8, NULL }
  8588. };
  8589. static hda_nid_t alc861_dac_nids[4] = {
  8590. /* front, surround, clfe, side */
  8591. 0x03, 0x06, 0x05, 0x04
  8592. };
  8593. static hda_nid_t alc660_dac_nids[3] = {
  8594. /* front, clfe, surround */
  8595. 0x03, 0x05, 0x06
  8596. };
  8597. static hda_nid_t alc861_adc_nids[1] = {
  8598. /* ADC0-2 */
  8599. 0x08,
  8600. };
  8601. static struct hda_input_mux alc861_capture_source = {
  8602. .num_items = 5,
  8603. .items = {
  8604. { "Mic", 0x0 },
  8605. { "Front Mic", 0x3 },
  8606. { "Line", 0x1 },
  8607. { "CD", 0x4 },
  8608. { "Mixer", 0x5 },
  8609. },
  8610. };
  8611. /* fill in the dac_nids table from the parsed pin configuration */
  8612. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8613. const struct auto_pin_cfg *cfg)
  8614. {
  8615. int i;
  8616. hda_nid_t nid;
  8617. spec->multiout.dac_nids = spec->private_dac_nids;
  8618. for (i = 0; i < cfg->line_outs; i++) {
  8619. nid = cfg->line_out_pins[i];
  8620. if (nid) {
  8621. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8622. continue;
  8623. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8624. }
  8625. }
  8626. spec->multiout.num_dacs = cfg->line_outs;
  8627. return 0;
  8628. }
  8629. /* add playback controls from the parsed DAC table */
  8630. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8631. const struct auto_pin_cfg *cfg)
  8632. {
  8633. char name[32];
  8634. static const char *chname[4] = {
  8635. "Front", "Surround", NULL /*CLFE*/, "Side"
  8636. };
  8637. hda_nid_t nid;
  8638. int i, idx, err;
  8639. for (i = 0; i < cfg->line_outs; i++) {
  8640. nid = spec->multiout.dac_nids[i];
  8641. if (!nid)
  8642. continue;
  8643. if (nid == 0x05) {
  8644. /* Center/LFE */
  8645. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8646. "Center Playback Switch",
  8647. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8648. HDA_OUTPUT));
  8649. if (err < 0)
  8650. return err;
  8651. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8652. "LFE Playback Switch",
  8653. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8654. HDA_OUTPUT));
  8655. if (err < 0)
  8656. return err;
  8657. } else {
  8658. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8659. idx++)
  8660. if (nid == alc861_dac_nids[idx])
  8661. break;
  8662. sprintf(name, "%s Playback Switch", chname[idx]);
  8663. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8664. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8665. HDA_OUTPUT));
  8666. if (err < 0)
  8667. return err;
  8668. }
  8669. }
  8670. return 0;
  8671. }
  8672. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8673. {
  8674. int err;
  8675. hda_nid_t nid;
  8676. if (!pin)
  8677. return 0;
  8678. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8679. nid = 0x03;
  8680. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8681. "Headphone Playback Switch",
  8682. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8683. if (err < 0)
  8684. return err;
  8685. spec->multiout.hp_nid = nid;
  8686. }
  8687. return 0;
  8688. }
  8689. /* create playback/capture controls for input pins */
  8690. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8691. const struct auto_pin_cfg *cfg)
  8692. {
  8693. struct hda_input_mux *imux = &spec->private_imux;
  8694. int i, err, idx, idx1;
  8695. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8696. switch (cfg->input_pins[i]) {
  8697. case 0x0c:
  8698. idx1 = 1;
  8699. idx = 2; /* Line In */
  8700. break;
  8701. case 0x0f:
  8702. idx1 = 2;
  8703. idx = 2; /* Line In */
  8704. break;
  8705. case 0x0d:
  8706. idx1 = 0;
  8707. idx = 1; /* Mic In */
  8708. break;
  8709. case 0x10:
  8710. idx1 = 3;
  8711. idx = 1; /* Mic In */
  8712. break;
  8713. case 0x11:
  8714. idx1 = 4;
  8715. idx = 0; /* CD */
  8716. break;
  8717. default:
  8718. continue;
  8719. }
  8720. err = new_analog_input(spec, cfg->input_pins[i],
  8721. auto_pin_cfg_labels[i], idx, 0x15);
  8722. if (err < 0)
  8723. return err;
  8724. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8725. imux->items[imux->num_items].index = idx1;
  8726. imux->num_items++;
  8727. }
  8728. return 0;
  8729. }
  8730. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8731. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8732. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8733. {
  8734. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8735. /* The multiple "Capture Source" controls confuse alsamixer
  8736. * So call somewhat different..
  8737. *FIXME: the controls appear in the "playback" view!
  8738. */
  8739. /* .name = "Capture Source", */
  8740. .name = "Input Source",
  8741. .count = 1,
  8742. .info = alc_mux_enum_info,
  8743. .get = alc_mux_enum_get,
  8744. .put = alc_mux_enum_put,
  8745. },
  8746. { } /* end */
  8747. };
  8748. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8749. hda_nid_t nid,
  8750. int pin_type, int dac_idx)
  8751. {
  8752. /* set as output */
  8753. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8754. pin_type);
  8755. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8756. AMP_OUT_UNMUTE);
  8757. }
  8758. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8759. {
  8760. struct alc_spec *spec = codec->spec;
  8761. int i;
  8762. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8763. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8764. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8765. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8766. if (nid)
  8767. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8768. spec->multiout.dac_nids[i]);
  8769. }
  8770. }
  8771. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8772. {
  8773. struct alc_spec *spec = codec->spec;
  8774. hda_nid_t pin;
  8775. pin = spec->autocfg.hp_pins[0];
  8776. if (pin) /* connect to front */
  8777. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8778. spec->multiout.dac_nids[0]);
  8779. }
  8780. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8781. {
  8782. struct alc_spec *spec = codec->spec;
  8783. int i;
  8784. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8785. hda_nid_t nid = spec->autocfg.input_pins[i];
  8786. if (nid >= 0x0c && nid <= 0x11) {
  8787. snd_hda_codec_write(codec, nid, 0,
  8788. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8789. i <= AUTO_PIN_FRONT_MIC ?
  8790. PIN_VREF80 : PIN_IN);
  8791. }
  8792. }
  8793. }
  8794. /* parse the BIOS configuration and set up the alc_spec */
  8795. /* return 1 if successful, 0 if the proper config is not found,
  8796. * or a negative error code
  8797. */
  8798. static int alc861_parse_auto_config(struct hda_codec *codec)
  8799. {
  8800. struct alc_spec *spec = codec->spec;
  8801. int err;
  8802. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8803. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8804. alc861_ignore);
  8805. if (err < 0)
  8806. return err;
  8807. if (!spec->autocfg.line_outs)
  8808. return 0; /* can't find valid BIOS pin config */
  8809. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8810. if (err < 0)
  8811. return err;
  8812. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8813. if (err < 0)
  8814. return err;
  8815. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8816. if (err < 0)
  8817. return err;
  8818. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8819. if (err < 0)
  8820. return err;
  8821. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8822. if (spec->autocfg.dig_out_pin)
  8823. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8824. if (spec->kctl_alloc)
  8825. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8826. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8827. spec->num_mux_defs = 1;
  8828. spec->input_mux = &spec->private_imux;
  8829. spec->adc_nids = alc861_adc_nids;
  8830. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8831. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8832. spec->num_mixers++;
  8833. return 1;
  8834. }
  8835. /* additional initialization for auto-configuration model */
  8836. static void alc861_auto_init(struct hda_codec *codec)
  8837. {
  8838. alc861_auto_init_multi_out(codec);
  8839. alc861_auto_init_hp_out(codec);
  8840. alc861_auto_init_analog_input(codec);
  8841. }
  8842. #ifdef CONFIG_SND_HDA_POWER_SAVE
  8843. static struct hda_amp_list alc861_loopbacks[] = {
  8844. { 0x15, HDA_INPUT, 0 },
  8845. { 0x15, HDA_INPUT, 1 },
  8846. { 0x15, HDA_INPUT, 2 },
  8847. { 0x15, HDA_INPUT, 3 },
  8848. { } /* end */
  8849. };
  8850. #endif
  8851. /*
  8852. * configuration and preset
  8853. */
  8854. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8855. [ALC861_3ST] = "3stack",
  8856. [ALC660_3ST] = "3stack-660",
  8857. [ALC861_3ST_DIG] = "3stack-dig",
  8858. [ALC861_6ST_DIG] = "6stack-dig",
  8859. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8860. [ALC861_TOSHIBA] = "toshiba",
  8861. [ALC861_ASUS] = "asus",
  8862. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8863. [ALC861_AUTO] = "auto",
  8864. };
  8865. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8866. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8867. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8868. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8869. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8870. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  8871. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8872. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  8873. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8874. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  8875. * Any other models that need this preset?
  8876. */
  8877. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  8878. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8879. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8880. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8881. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8882. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8883. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  8884. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  8885. {}
  8886. };
  8887. static struct alc_config_preset alc861_presets[] = {
  8888. [ALC861_3ST] = {
  8889. .mixers = { alc861_3ST_mixer },
  8890. .init_verbs = { alc861_threestack_init_verbs },
  8891. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8892. .dac_nids = alc861_dac_nids,
  8893. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8894. .channel_mode = alc861_threestack_modes,
  8895. .need_dac_fix = 1,
  8896. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8897. .adc_nids = alc861_adc_nids,
  8898. .input_mux = &alc861_capture_source,
  8899. },
  8900. [ALC861_3ST_DIG] = {
  8901. .mixers = { alc861_base_mixer },
  8902. .init_verbs = { alc861_threestack_init_verbs },
  8903. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8904. .dac_nids = alc861_dac_nids,
  8905. .dig_out_nid = ALC861_DIGOUT_NID,
  8906. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8907. .channel_mode = alc861_threestack_modes,
  8908. .need_dac_fix = 1,
  8909. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8910. .adc_nids = alc861_adc_nids,
  8911. .input_mux = &alc861_capture_source,
  8912. },
  8913. [ALC861_6ST_DIG] = {
  8914. .mixers = { alc861_base_mixer },
  8915. .init_verbs = { alc861_base_init_verbs },
  8916. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8917. .dac_nids = alc861_dac_nids,
  8918. .dig_out_nid = ALC861_DIGOUT_NID,
  8919. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8920. .channel_mode = alc861_8ch_modes,
  8921. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8922. .adc_nids = alc861_adc_nids,
  8923. .input_mux = &alc861_capture_source,
  8924. },
  8925. [ALC660_3ST] = {
  8926. .mixers = { alc861_3ST_mixer },
  8927. .init_verbs = { alc861_threestack_init_verbs },
  8928. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8929. .dac_nids = alc660_dac_nids,
  8930. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8931. .channel_mode = alc861_threestack_modes,
  8932. .need_dac_fix = 1,
  8933. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8934. .adc_nids = alc861_adc_nids,
  8935. .input_mux = &alc861_capture_source,
  8936. },
  8937. [ALC861_UNIWILL_M31] = {
  8938. .mixers = { alc861_uniwill_m31_mixer },
  8939. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8940. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8941. .dac_nids = alc861_dac_nids,
  8942. .dig_out_nid = ALC861_DIGOUT_NID,
  8943. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8944. .channel_mode = alc861_uniwill_m31_modes,
  8945. .need_dac_fix = 1,
  8946. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8947. .adc_nids = alc861_adc_nids,
  8948. .input_mux = &alc861_capture_source,
  8949. },
  8950. [ALC861_TOSHIBA] = {
  8951. .mixers = { alc861_toshiba_mixer },
  8952. .init_verbs = { alc861_base_init_verbs,
  8953. alc861_toshiba_init_verbs },
  8954. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8955. .dac_nids = alc861_dac_nids,
  8956. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8957. .channel_mode = alc883_3ST_2ch_modes,
  8958. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8959. .adc_nids = alc861_adc_nids,
  8960. .input_mux = &alc861_capture_source,
  8961. .unsol_event = alc861_toshiba_unsol_event,
  8962. .init_hook = alc861_toshiba_automute,
  8963. },
  8964. [ALC861_ASUS] = {
  8965. .mixers = { alc861_asus_mixer },
  8966. .init_verbs = { alc861_asus_init_verbs },
  8967. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8968. .dac_nids = alc861_dac_nids,
  8969. .dig_out_nid = ALC861_DIGOUT_NID,
  8970. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8971. .channel_mode = alc861_asus_modes,
  8972. .need_dac_fix = 1,
  8973. .hp_nid = 0x06,
  8974. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8975. .adc_nids = alc861_adc_nids,
  8976. .input_mux = &alc861_capture_source,
  8977. },
  8978. [ALC861_ASUS_LAPTOP] = {
  8979. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8980. .init_verbs = { alc861_asus_init_verbs,
  8981. alc861_asus_laptop_init_verbs },
  8982. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8983. .dac_nids = alc861_dac_nids,
  8984. .dig_out_nid = ALC861_DIGOUT_NID,
  8985. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8986. .channel_mode = alc883_3ST_2ch_modes,
  8987. .need_dac_fix = 1,
  8988. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8989. .adc_nids = alc861_adc_nids,
  8990. .input_mux = &alc861_capture_source,
  8991. },
  8992. };
  8993. static int patch_alc861(struct hda_codec *codec)
  8994. {
  8995. struct alc_spec *spec;
  8996. int board_config;
  8997. int err;
  8998. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8999. if (spec == NULL)
  9000. return -ENOMEM;
  9001. codec->spec = spec;
  9002. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9003. alc861_models,
  9004. alc861_cfg_tbl);
  9005. if (board_config < 0) {
  9006. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9007. "trying auto-probe from BIOS...\n");
  9008. board_config = ALC861_AUTO;
  9009. }
  9010. if (board_config == ALC861_AUTO) {
  9011. /* automatic parse from the BIOS config */
  9012. err = alc861_parse_auto_config(codec);
  9013. if (err < 0) {
  9014. alc_free(codec);
  9015. return err;
  9016. } else if (!err) {
  9017. printk(KERN_INFO
  9018. "hda_codec: Cannot set up configuration "
  9019. "from BIOS. Using base mode...\n");
  9020. board_config = ALC861_3ST_DIG;
  9021. }
  9022. }
  9023. if (board_config != ALC861_AUTO)
  9024. setup_preset(spec, &alc861_presets[board_config]);
  9025. spec->stream_name_analog = "ALC861 Analog";
  9026. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  9027. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  9028. spec->stream_name_digital = "ALC861 Digital";
  9029. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  9030. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  9031. codec->patch_ops = alc_patch_ops;
  9032. if (board_config == ALC861_AUTO)
  9033. spec->init_hook = alc861_auto_init;
  9034. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9035. if (!spec->loopback.amplist)
  9036. spec->loopback.amplist = alc861_loopbacks;
  9037. #endif
  9038. return 0;
  9039. }
  9040. /*
  9041. * ALC861-VD support
  9042. *
  9043. * Based on ALC882
  9044. *
  9045. * In addition, an independent DAC
  9046. */
  9047. #define ALC861VD_DIGOUT_NID 0x06
  9048. static hda_nid_t alc861vd_dac_nids[4] = {
  9049. /* front, surr, clfe, side surr */
  9050. 0x02, 0x03, 0x04, 0x05
  9051. };
  9052. /* dac_nids for ALC660vd are in a different order - according to
  9053. * Realtek's driver.
  9054. * This should probably tesult in a different mixer for 6stack models
  9055. * of ALC660vd codecs, but for now there is only 3stack mixer
  9056. * - and it is the same as in 861vd.
  9057. * adc_nids in ALC660vd are (is) the same as in 861vd
  9058. */
  9059. static hda_nid_t alc660vd_dac_nids[3] = {
  9060. /* front, rear, clfe, rear_surr */
  9061. 0x02, 0x04, 0x03
  9062. };
  9063. static hda_nid_t alc861vd_adc_nids[1] = {
  9064. /* ADC0 */
  9065. 0x09,
  9066. };
  9067. /* input MUX */
  9068. /* FIXME: should be a matrix-type input source selection */
  9069. static struct hda_input_mux alc861vd_capture_source = {
  9070. .num_items = 4,
  9071. .items = {
  9072. { "Mic", 0x0 },
  9073. { "Front Mic", 0x1 },
  9074. { "Line", 0x2 },
  9075. { "CD", 0x4 },
  9076. },
  9077. };
  9078. static struct hda_input_mux alc861vd_dallas_capture_source = {
  9079. .num_items = 3,
  9080. .items = {
  9081. { "Front Mic", 0x0 },
  9082. { "ATAPI Mic", 0x1 },
  9083. { "Line In", 0x5 },
  9084. },
  9085. };
  9086. static struct hda_input_mux alc861vd_hp_capture_source = {
  9087. .num_items = 2,
  9088. .items = {
  9089. { "Front Mic", 0x0 },
  9090. { "ATAPI Mic", 0x1 },
  9091. },
  9092. };
  9093. #define alc861vd_mux_enum_info alc_mux_enum_info
  9094. #define alc861vd_mux_enum_get alc_mux_enum_get
  9095. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  9096. struct snd_ctl_elem_value *ucontrol)
  9097. {
  9098. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9099. struct alc_spec *spec = codec->spec;
  9100. const struct hda_input_mux *imux = spec->input_mux;
  9101. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9102. static hda_nid_t capture_mixers[1] = { 0x22 };
  9103. hda_nid_t nid = capture_mixers[adc_idx];
  9104. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9105. unsigned int i, idx;
  9106. idx = ucontrol->value.enumerated.item[0];
  9107. if (idx >= imux->num_items)
  9108. idx = imux->num_items - 1;
  9109. if (*cur_val == idx)
  9110. return 0;
  9111. for (i = 0; i < imux->num_items; i++) {
  9112. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9113. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9114. imux->items[i].index,
  9115. HDA_AMP_MUTE, v);
  9116. }
  9117. *cur_val = idx;
  9118. return 1;
  9119. }
  9120. /*
  9121. * 2ch mode
  9122. */
  9123. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9124. { 2, NULL }
  9125. };
  9126. /*
  9127. * 6ch mode
  9128. */
  9129. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9130. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9131. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9132. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9133. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9134. { } /* end */
  9135. };
  9136. /*
  9137. * 8ch mode
  9138. */
  9139. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9140. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9141. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9142. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9143. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9144. { } /* end */
  9145. };
  9146. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9147. { 6, alc861vd_6stack_ch6_init },
  9148. { 8, alc861vd_6stack_ch8_init },
  9149. };
  9150. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9151. {
  9152. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9153. .name = "Channel Mode",
  9154. .info = alc_ch_mode_info,
  9155. .get = alc_ch_mode_get,
  9156. .put = alc_ch_mode_put,
  9157. },
  9158. { } /* end */
  9159. };
  9160. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9161. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9162. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9163. {
  9164. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9165. /* The multiple "Capture Source" controls confuse alsamixer
  9166. * So call somewhat different..
  9167. *FIXME: the controls appear in the "playback" view!
  9168. */
  9169. /* .name = "Capture Source", */
  9170. .name = "Input Source",
  9171. .count = 1,
  9172. .info = alc861vd_mux_enum_info,
  9173. .get = alc861vd_mux_enum_get,
  9174. .put = alc861vd_mux_enum_put,
  9175. },
  9176. { } /* end */
  9177. };
  9178. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9179. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9180. */
  9181. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9182. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9183. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9184. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9185. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9186. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9187. HDA_OUTPUT),
  9188. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9189. HDA_OUTPUT),
  9190. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9191. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9192. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9193. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9194. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9195. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9196. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9197. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9198. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9199. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9200. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9201. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9202. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9203. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9204. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9205. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9206. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9207. { } /* end */
  9208. };
  9209. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9210. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9211. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9212. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9213. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9214. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9215. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9216. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9217. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9218. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9219. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9220. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9221. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9222. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9223. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9224. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9225. { } /* end */
  9226. };
  9227. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9228. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9229. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9230. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9231. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9232. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9233. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9234. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9235. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9236. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9237. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9238. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9239. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9240. { } /* end */
  9241. };
  9242. /* Pin assignment: Front=0x14, HP = 0x15,
  9243. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9244. */
  9245. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9246. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9247. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9248. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9249. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9250. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9251. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9252. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9253. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9254. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9255. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9256. { } /* end */
  9257. };
  9258. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  9259. * Front Mic=0x18, ATAPI Mic = 0x19,
  9260. */
  9261. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  9262. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9263. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9264. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9265. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9266. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9267. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9268. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9269. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9270. { } /* end */
  9271. };
  9272. /*
  9273. * generic initialization of ADC, input mixers and output mixers
  9274. */
  9275. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9276. /*
  9277. * Unmute ADC0 and set the default input to mic-in
  9278. */
  9279. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9280. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9281. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9282. * the analog-loopback mixer widget
  9283. */
  9284. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9285. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9286. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9287. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9288. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9289. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9290. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9291. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9292. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9293. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9294. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9295. /*
  9296. * Set up output mixers (0x02 - 0x05)
  9297. */
  9298. /* set vol=0 to output mixers */
  9299. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9300. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9301. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9302. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9303. /* set up input amps for analog loopback */
  9304. /* Amp Indices: DAC = 0, mixer = 1 */
  9305. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9306. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9307. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9308. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9309. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9310. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9311. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9312. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9313. { }
  9314. };
  9315. /*
  9316. * 3-stack pin configuration:
  9317. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9318. */
  9319. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9320. /*
  9321. * Set pin mode and muting
  9322. */
  9323. /* set front pin widgets 0x14 for output */
  9324. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9325. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9326. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9327. /* Mic (rear) pin: input vref at 80% */
  9328. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9329. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9330. /* Front Mic pin: input vref at 80% */
  9331. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9332. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9333. /* Line In pin: input */
  9334. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9335. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9336. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9337. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9338. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9339. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9340. /* CD pin widget for input */
  9341. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9342. { }
  9343. };
  9344. /*
  9345. * 6-stack pin configuration:
  9346. */
  9347. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9348. /*
  9349. * Set pin mode and muting
  9350. */
  9351. /* set front pin widgets 0x14 for output */
  9352. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9353. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9354. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9355. /* Rear Pin: output 1 (0x0d) */
  9356. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9357. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9358. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9359. /* CLFE Pin: output 2 (0x0e) */
  9360. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9361. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9362. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9363. /* Side Pin: output 3 (0x0f) */
  9364. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9365. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9366. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9367. /* Mic (rear) pin: input vref at 80% */
  9368. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9369. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9370. /* Front Mic pin: input vref at 80% */
  9371. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9372. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9373. /* Line In pin: input */
  9374. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9375. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9376. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9377. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9378. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9379. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9380. /* CD pin widget for input */
  9381. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9382. { }
  9383. };
  9384. static struct hda_verb alc861vd_eapd_verbs[] = {
  9385. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9386. { }
  9387. };
  9388. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9389. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9390. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9391. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9392. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9393. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9394. {}
  9395. };
  9396. /* toggle speaker-output according to the hp-jack state */
  9397. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9398. {
  9399. unsigned int present;
  9400. unsigned char bits;
  9401. present = snd_hda_codec_read(codec, 0x1b, 0,
  9402. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9403. bits = present ? HDA_AMP_MUTE : 0;
  9404. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9405. HDA_AMP_MUTE, bits);
  9406. }
  9407. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9408. {
  9409. unsigned int present;
  9410. unsigned char bits;
  9411. present = snd_hda_codec_read(codec, 0x18, 0,
  9412. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9413. bits = present ? HDA_AMP_MUTE : 0;
  9414. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  9415. HDA_AMP_MUTE, bits);
  9416. }
  9417. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9418. {
  9419. alc861vd_lenovo_hp_automute(codec);
  9420. alc861vd_lenovo_mic_automute(codec);
  9421. }
  9422. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9423. unsigned int res)
  9424. {
  9425. switch (res >> 26) {
  9426. case ALC880_HP_EVENT:
  9427. alc861vd_lenovo_hp_automute(codec);
  9428. break;
  9429. case ALC880_MIC_EVENT:
  9430. alc861vd_lenovo_mic_automute(codec);
  9431. break;
  9432. }
  9433. }
  9434. static struct hda_verb alc861vd_dallas_verbs[] = {
  9435. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9436. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9437. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9438. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9439. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9440. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9441. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9442. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9443. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9444. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9445. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9446. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9447. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9448. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9449. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9450. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9451. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9452. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9453. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9454. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9455. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9456. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9457. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9458. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9459. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9460. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9461. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9462. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9463. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9464. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9465. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9466. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9467. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9468. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9469. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9470. { } /* end */
  9471. };
  9472. /* toggle speaker-output according to the hp-jack state */
  9473. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9474. {
  9475. unsigned int present;
  9476. present = snd_hda_codec_read(codec, 0x15, 0,
  9477. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9478. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9479. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9480. }
  9481. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9482. {
  9483. if ((res >> 26) == ALC880_HP_EVENT)
  9484. alc861vd_dallas_automute(codec);
  9485. }
  9486. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9487. #define alc861vd_loopbacks alc880_loopbacks
  9488. #endif
  9489. /* pcm configuration: identiacal with ALC880 */
  9490. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9491. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9492. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9493. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9494. /*
  9495. * configuration and preset
  9496. */
  9497. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9498. [ALC660VD_3ST] = "3stack-660",
  9499. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  9500. [ALC861VD_3ST] = "3stack",
  9501. [ALC861VD_3ST_DIG] = "3stack-digout",
  9502. [ALC861VD_6ST_DIG] = "6stack-digout",
  9503. [ALC861VD_LENOVO] = "lenovo",
  9504. [ALC861VD_DALLAS] = "dallas",
  9505. [ALC861VD_HP] = "hp",
  9506. [ALC861VD_AUTO] = "auto",
  9507. };
  9508. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9509. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9510. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9511. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9512. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9513. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9514. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  9515. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9516. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9517. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9518. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9519. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  9520. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  9521. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  9522. {}
  9523. };
  9524. static struct alc_config_preset alc861vd_presets[] = {
  9525. [ALC660VD_3ST] = {
  9526. .mixers = { alc861vd_3st_mixer },
  9527. .init_verbs = { alc861vd_volume_init_verbs,
  9528. alc861vd_3stack_init_verbs },
  9529. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9530. .dac_nids = alc660vd_dac_nids,
  9531. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9532. .adc_nids = alc861vd_adc_nids,
  9533. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9534. .channel_mode = alc861vd_3stack_2ch_modes,
  9535. .input_mux = &alc861vd_capture_source,
  9536. },
  9537. [ALC660VD_3ST_DIG] = {
  9538. .mixers = { alc861vd_3st_mixer },
  9539. .init_verbs = { alc861vd_volume_init_verbs,
  9540. alc861vd_3stack_init_verbs },
  9541. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9542. .dac_nids = alc660vd_dac_nids,
  9543. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9544. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9545. .adc_nids = alc861vd_adc_nids,
  9546. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9547. .channel_mode = alc861vd_3stack_2ch_modes,
  9548. .input_mux = &alc861vd_capture_source,
  9549. },
  9550. [ALC861VD_3ST] = {
  9551. .mixers = { alc861vd_3st_mixer },
  9552. .init_verbs = { alc861vd_volume_init_verbs,
  9553. alc861vd_3stack_init_verbs },
  9554. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9555. .dac_nids = alc861vd_dac_nids,
  9556. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9557. .channel_mode = alc861vd_3stack_2ch_modes,
  9558. .input_mux = &alc861vd_capture_source,
  9559. },
  9560. [ALC861VD_3ST_DIG] = {
  9561. .mixers = { alc861vd_3st_mixer },
  9562. .init_verbs = { alc861vd_volume_init_verbs,
  9563. alc861vd_3stack_init_verbs },
  9564. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9565. .dac_nids = alc861vd_dac_nids,
  9566. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9567. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9568. .channel_mode = alc861vd_3stack_2ch_modes,
  9569. .input_mux = &alc861vd_capture_source,
  9570. },
  9571. [ALC861VD_6ST_DIG] = {
  9572. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9573. .init_verbs = { alc861vd_volume_init_verbs,
  9574. alc861vd_6stack_init_verbs },
  9575. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9576. .dac_nids = alc861vd_dac_nids,
  9577. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9578. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9579. .channel_mode = alc861vd_6stack_modes,
  9580. .input_mux = &alc861vd_capture_source,
  9581. },
  9582. [ALC861VD_LENOVO] = {
  9583. .mixers = { alc861vd_lenovo_mixer },
  9584. .init_verbs = { alc861vd_volume_init_verbs,
  9585. alc861vd_3stack_init_verbs,
  9586. alc861vd_eapd_verbs,
  9587. alc861vd_lenovo_unsol_verbs },
  9588. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9589. .dac_nids = alc660vd_dac_nids,
  9590. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9591. .adc_nids = alc861vd_adc_nids,
  9592. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9593. .channel_mode = alc861vd_3stack_2ch_modes,
  9594. .input_mux = &alc861vd_capture_source,
  9595. .unsol_event = alc861vd_lenovo_unsol_event,
  9596. .init_hook = alc861vd_lenovo_automute,
  9597. },
  9598. [ALC861VD_DALLAS] = {
  9599. .mixers = { alc861vd_dallas_mixer },
  9600. .init_verbs = { alc861vd_dallas_verbs },
  9601. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9602. .dac_nids = alc861vd_dac_nids,
  9603. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9604. .adc_nids = alc861vd_adc_nids,
  9605. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9606. .channel_mode = alc861vd_3stack_2ch_modes,
  9607. .input_mux = &alc861vd_dallas_capture_source,
  9608. .unsol_event = alc861vd_dallas_unsol_event,
  9609. .init_hook = alc861vd_dallas_automute,
  9610. },
  9611. [ALC861VD_HP] = {
  9612. .mixers = { alc861vd_hp_mixer },
  9613. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  9614. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9615. .dac_nids = alc861vd_dac_nids,
  9616. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9617. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9618. .adc_nids = alc861vd_adc_nids,
  9619. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9620. .channel_mode = alc861vd_3stack_2ch_modes,
  9621. .input_mux = &alc861vd_hp_capture_source,
  9622. .unsol_event = alc861vd_dallas_unsol_event,
  9623. .init_hook = alc861vd_dallas_automute,
  9624. },
  9625. };
  9626. /*
  9627. * BIOS auto configuration
  9628. */
  9629. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9630. hda_nid_t nid, int pin_type, int dac_idx)
  9631. {
  9632. /* set as output */
  9633. snd_hda_codec_write(codec, nid, 0,
  9634. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9635. snd_hda_codec_write(codec, nid, 0,
  9636. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9637. }
  9638. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9639. {
  9640. struct alc_spec *spec = codec->spec;
  9641. int i;
  9642. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9643. for (i = 0; i <= HDA_SIDE; i++) {
  9644. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9645. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9646. if (nid)
  9647. alc861vd_auto_set_output_and_unmute(codec, nid,
  9648. pin_type, i);
  9649. }
  9650. }
  9651. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9652. {
  9653. struct alc_spec *spec = codec->spec;
  9654. hda_nid_t pin;
  9655. pin = spec->autocfg.hp_pins[0];
  9656. if (pin) /* connect to front and use dac 0 */
  9657. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9658. }
  9659. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9660. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9661. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9662. {
  9663. struct alc_spec *spec = codec->spec;
  9664. int i;
  9665. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9666. hda_nid_t nid = spec->autocfg.input_pins[i];
  9667. if (alc861vd_is_input_pin(nid)) {
  9668. snd_hda_codec_write(codec, nid, 0,
  9669. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9670. i <= AUTO_PIN_FRONT_MIC ?
  9671. PIN_VREF80 : PIN_IN);
  9672. if (nid != ALC861VD_PIN_CD_NID)
  9673. snd_hda_codec_write(codec, nid, 0,
  9674. AC_VERB_SET_AMP_GAIN_MUTE,
  9675. AMP_OUT_MUTE);
  9676. }
  9677. }
  9678. }
  9679. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9680. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9681. /* add playback controls from the parsed DAC table */
  9682. /* Based on ALC880 version. But ALC861VD has separate,
  9683. * different NIDs for mute/unmute switch and volume control */
  9684. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9685. const struct auto_pin_cfg *cfg)
  9686. {
  9687. char name[32];
  9688. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9689. hda_nid_t nid_v, nid_s;
  9690. int i, err;
  9691. for (i = 0; i < cfg->line_outs; i++) {
  9692. if (!spec->multiout.dac_nids[i])
  9693. continue;
  9694. nid_v = alc861vd_idx_to_mixer_vol(
  9695. alc880_dac_to_idx(
  9696. spec->multiout.dac_nids[i]));
  9697. nid_s = alc861vd_idx_to_mixer_switch(
  9698. alc880_dac_to_idx(
  9699. spec->multiout.dac_nids[i]));
  9700. if (i == 2) {
  9701. /* Center/LFE */
  9702. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9703. "Center Playback Volume",
  9704. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9705. HDA_OUTPUT));
  9706. if (err < 0)
  9707. return err;
  9708. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9709. "LFE Playback Volume",
  9710. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9711. HDA_OUTPUT));
  9712. if (err < 0)
  9713. return err;
  9714. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9715. "Center Playback Switch",
  9716. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9717. HDA_INPUT));
  9718. if (err < 0)
  9719. return err;
  9720. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9721. "LFE Playback Switch",
  9722. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9723. HDA_INPUT));
  9724. if (err < 0)
  9725. return err;
  9726. } else {
  9727. sprintf(name, "%s Playback Volume", chname[i]);
  9728. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9729. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9730. HDA_OUTPUT));
  9731. if (err < 0)
  9732. return err;
  9733. sprintf(name, "%s Playback Switch", chname[i]);
  9734. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9735. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9736. HDA_INPUT));
  9737. if (err < 0)
  9738. return err;
  9739. }
  9740. }
  9741. return 0;
  9742. }
  9743. /* add playback controls for speaker and HP outputs */
  9744. /* Based on ALC880 version. But ALC861VD has separate,
  9745. * different NIDs for mute/unmute switch and volume control */
  9746. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9747. hda_nid_t pin, const char *pfx)
  9748. {
  9749. hda_nid_t nid_v, nid_s;
  9750. int err;
  9751. char name[32];
  9752. if (!pin)
  9753. return 0;
  9754. if (alc880_is_fixed_pin(pin)) {
  9755. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9756. /* specify the DAC as the extra output */
  9757. if (!spec->multiout.hp_nid)
  9758. spec->multiout.hp_nid = nid_v;
  9759. else
  9760. spec->multiout.extra_out_nid[0] = nid_v;
  9761. /* control HP volume/switch on the output mixer amp */
  9762. nid_v = alc861vd_idx_to_mixer_vol(
  9763. alc880_fixed_pin_idx(pin));
  9764. nid_s = alc861vd_idx_to_mixer_switch(
  9765. alc880_fixed_pin_idx(pin));
  9766. sprintf(name, "%s Playback Volume", pfx);
  9767. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9768. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9769. if (err < 0)
  9770. return err;
  9771. sprintf(name, "%s Playback Switch", pfx);
  9772. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9773. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9774. if (err < 0)
  9775. return err;
  9776. } else if (alc880_is_multi_pin(pin)) {
  9777. /* set manual connection */
  9778. /* we have only a switch on HP-out PIN */
  9779. sprintf(name, "%s Playback Switch", pfx);
  9780. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9781. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9782. if (err < 0)
  9783. return err;
  9784. }
  9785. return 0;
  9786. }
  9787. /* parse the BIOS configuration and set up the alc_spec
  9788. * return 1 if successful, 0 if the proper config is not found,
  9789. * or a negative error code
  9790. * Based on ALC880 version - had to change it to override
  9791. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9792. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9793. {
  9794. struct alc_spec *spec = codec->spec;
  9795. int err;
  9796. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9797. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9798. alc861vd_ignore);
  9799. if (err < 0)
  9800. return err;
  9801. if (!spec->autocfg.line_outs)
  9802. return 0; /* can't find valid BIOS pin config */
  9803. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9804. if (err < 0)
  9805. return err;
  9806. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9807. if (err < 0)
  9808. return err;
  9809. err = alc861vd_auto_create_extra_out(spec,
  9810. spec->autocfg.speaker_pins[0],
  9811. "Speaker");
  9812. if (err < 0)
  9813. return err;
  9814. err = alc861vd_auto_create_extra_out(spec,
  9815. spec->autocfg.hp_pins[0],
  9816. "Headphone");
  9817. if (err < 0)
  9818. return err;
  9819. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9820. if (err < 0)
  9821. return err;
  9822. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9823. if (spec->autocfg.dig_out_pin)
  9824. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9825. if (spec->kctl_alloc)
  9826. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9827. spec->init_verbs[spec->num_init_verbs++]
  9828. = alc861vd_volume_init_verbs;
  9829. spec->num_mux_defs = 1;
  9830. spec->input_mux = &spec->private_imux;
  9831. return 1;
  9832. }
  9833. /* additional initialization for auto-configuration model */
  9834. static void alc861vd_auto_init(struct hda_codec *codec)
  9835. {
  9836. alc861vd_auto_init_multi_out(codec);
  9837. alc861vd_auto_init_hp_out(codec);
  9838. alc861vd_auto_init_analog_input(codec);
  9839. }
  9840. static int patch_alc861vd(struct hda_codec *codec)
  9841. {
  9842. struct alc_spec *spec;
  9843. int err, board_config;
  9844. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9845. if (spec == NULL)
  9846. return -ENOMEM;
  9847. codec->spec = spec;
  9848. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9849. alc861vd_models,
  9850. alc861vd_cfg_tbl);
  9851. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9852. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9853. "ALC861VD, trying auto-probe from BIOS...\n");
  9854. board_config = ALC861VD_AUTO;
  9855. }
  9856. if (board_config == ALC861VD_AUTO) {
  9857. /* automatic parse from the BIOS config */
  9858. err = alc861vd_parse_auto_config(codec);
  9859. if (err < 0) {
  9860. alc_free(codec);
  9861. return err;
  9862. } else if (!err) {
  9863. printk(KERN_INFO
  9864. "hda_codec: Cannot set up configuration "
  9865. "from BIOS. Using base mode...\n");
  9866. board_config = ALC861VD_3ST;
  9867. }
  9868. }
  9869. if (board_config != ALC861VD_AUTO)
  9870. setup_preset(spec, &alc861vd_presets[board_config]);
  9871. spec->stream_name_analog = "ALC861VD Analog";
  9872. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9873. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9874. spec->stream_name_digital = "ALC861VD Digital";
  9875. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9876. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9877. spec->adc_nids = alc861vd_adc_nids;
  9878. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9879. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9880. spec->num_mixers++;
  9881. codec->patch_ops = alc_patch_ops;
  9882. if (board_config == ALC861VD_AUTO)
  9883. spec->init_hook = alc861vd_auto_init;
  9884. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9885. if (!spec->loopback.amplist)
  9886. spec->loopback.amplist = alc861vd_loopbacks;
  9887. #endif
  9888. return 0;
  9889. }
  9890. /*
  9891. * ALC662 support
  9892. *
  9893. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9894. * configuration. Each pin widget can choose any input DACs and a mixer.
  9895. * Each ADC is connected from a mixer of all inputs. This makes possible
  9896. * 6-channel independent captures.
  9897. *
  9898. * In addition, an independent DAC for the multi-playback (not used in this
  9899. * driver yet).
  9900. */
  9901. #define ALC662_DIGOUT_NID 0x06
  9902. #define ALC662_DIGIN_NID 0x0a
  9903. static hda_nid_t alc662_dac_nids[4] = {
  9904. /* front, rear, clfe, rear_surr */
  9905. 0x02, 0x03, 0x04
  9906. };
  9907. static hda_nid_t alc662_adc_nids[1] = {
  9908. /* ADC1-2 */
  9909. 0x09,
  9910. };
  9911. /* input MUX */
  9912. /* FIXME: should be a matrix-type input source selection */
  9913. static struct hda_input_mux alc662_capture_source = {
  9914. .num_items = 4,
  9915. .items = {
  9916. { "Mic", 0x0 },
  9917. { "Front Mic", 0x1 },
  9918. { "Line", 0x2 },
  9919. { "CD", 0x4 },
  9920. },
  9921. };
  9922. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9923. .num_items = 2,
  9924. .items = {
  9925. { "Mic", 0x1 },
  9926. { "Line", 0x2 },
  9927. },
  9928. };
  9929. #define alc662_mux_enum_info alc_mux_enum_info
  9930. #define alc662_mux_enum_get alc_mux_enum_get
  9931. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9932. struct snd_ctl_elem_value *ucontrol)
  9933. {
  9934. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9935. struct alc_spec *spec = codec->spec;
  9936. const struct hda_input_mux *imux = spec->input_mux;
  9937. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9938. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  9939. hda_nid_t nid = capture_mixers[adc_idx];
  9940. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9941. unsigned int i, idx;
  9942. idx = ucontrol->value.enumerated.item[0];
  9943. if (idx >= imux->num_items)
  9944. idx = imux->num_items - 1;
  9945. if (*cur_val == idx)
  9946. return 0;
  9947. for (i = 0; i < imux->num_items; i++) {
  9948. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9949. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9950. imux->items[i].index,
  9951. HDA_AMP_MUTE, v);
  9952. }
  9953. *cur_val = idx;
  9954. return 1;
  9955. }
  9956. /*
  9957. * 2ch mode
  9958. */
  9959. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9960. { 2, NULL }
  9961. };
  9962. /*
  9963. * 2ch mode
  9964. */
  9965. static struct hda_verb alc662_3ST_ch2_init[] = {
  9966. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9967. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9968. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9969. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9970. { } /* end */
  9971. };
  9972. /*
  9973. * 6ch mode
  9974. */
  9975. static struct hda_verb alc662_3ST_ch6_init[] = {
  9976. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9977. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9978. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9979. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9980. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9981. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9982. { } /* end */
  9983. };
  9984. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9985. { 2, alc662_3ST_ch2_init },
  9986. { 6, alc662_3ST_ch6_init },
  9987. };
  9988. /*
  9989. * 2ch mode
  9990. */
  9991. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9992. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9993. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9994. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9995. { } /* end */
  9996. };
  9997. /*
  9998. * 6ch mode
  9999. */
  10000. static struct hda_verb alc662_sixstack_ch8_init[] = {
  10001. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10002. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10003. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10004. { } /* end */
  10005. };
  10006. static struct hda_channel_mode alc662_5stack_modes[2] = {
  10007. { 2, alc662_sixstack_ch6_init },
  10008. { 6, alc662_sixstack_ch8_init },
  10009. };
  10010. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10011. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10012. */
  10013. static struct snd_kcontrol_new alc662_base_mixer[] = {
  10014. /* output mixer control */
  10015. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  10016. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  10017. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  10018. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  10019. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10020. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10021. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10022. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10023. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10024. /*Input mixer control */
  10025. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  10026. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  10027. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  10028. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  10029. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  10030. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  10031. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  10032. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  10033. /* Capture mixer control */
  10034. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10035. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10036. {
  10037. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10038. .name = "Capture Source",
  10039. .count = 1,
  10040. .info = alc_mux_enum_info,
  10041. .get = alc_mux_enum_get,
  10042. .put = alc_mux_enum_put,
  10043. },
  10044. { } /* end */
  10045. };
  10046. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  10047. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10048. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10049. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10050. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10051. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10052. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10053. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10054. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10055. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10056. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10057. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10058. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10059. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10060. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10061. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10062. {
  10063. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10064. /* .name = "Capture Source", */
  10065. .name = "Input Source",
  10066. .count = 1,
  10067. .info = alc662_mux_enum_info,
  10068. .get = alc662_mux_enum_get,
  10069. .put = alc662_mux_enum_put,
  10070. },
  10071. { } /* end */
  10072. };
  10073. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  10074. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10075. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10076. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10077. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  10078. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10079. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10080. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10081. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10082. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10083. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10084. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10085. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10086. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10087. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10088. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10089. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10090. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10091. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10092. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10093. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10094. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10095. {
  10096. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10097. /* .name = "Capture Source", */
  10098. .name = "Input Source",
  10099. .count = 1,
  10100. .info = alc662_mux_enum_info,
  10101. .get = alc662_mux_enum_get,
  10102. .put = alc662_mux_enum_put,
  10103. },
  10104. { } /* end */
  10105. };
  10106. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  10107. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10108. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10109. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10110. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  10111. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10112. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10113. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10114. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10115. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10116. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10117. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10118. {
  10119. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10120. /* .name = "Capture Source", */
  10121. .name = "Input Source",
  10122. .count = 1,
  10123. .info = alc662_mux_enum_info,
  10124. .get = alc662_mux_enum_get,
  10125. .put = alc662_mux_enum_put,
  10126. },
  10127. { } /* end */
  10128. };
  10129. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  10130. {
  10131. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10132. .name = "Channel Mode",
  10133. .info = alc_ch_mode_info,
  10134. .get = alc_ch_mode_get,
  10135. .put = alc_ch_mode_put,
  10136. },
  10137. { } /* end */
  10138. };
  10139. static struct hda_verb alc662_init_verbs[] = {
  10140. /* ADC: mute amp left and right */
  10141. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10142. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10143. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10144. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10145. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10146. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10147. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10148. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10149. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10150. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10151. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10152. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10153. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10154. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10155. /* Front Pin: output 0 (0x0c) */
  10156. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10157. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10158. /* Rear Pin: output 1 (0x0d) */
  10159. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10160. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10161. /* CLFE Pin: output 2 (0x0e) */
  10162. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10163. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10164. /* Mic (rear) pin: input vref at 80% */
  10165. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10166. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10167. /* Front Mic pin: input vref at 80% */
  10168. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10169. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10170. /* Line In pin: input */
  10171. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10172. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10173. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10174. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10175. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10176. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10177. /* CD pin widget for input */
  10178. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10179. /* FIXME: use matrix-type input source selection */
  10180. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10181. /* Input mixer */
  10182. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10183. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10184. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10185. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10186. { }
  10187. };
  10188. static struct hda_verb alc662_sue_init_verbs[] = {
  10189. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10190. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10191. {}
  10192. };
  10193. /*
  10194. * generic initialization of ADC, input mixers and output mixers
  10195. */
  10196. static struct hda_verb alc662_auto_init_verbs[] = {
  10197. /*
  10198. * Unmute ADC and set the default input to mic-in
  10199. */
  10200. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10201. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10202. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10203. * mixer widget
  10204. * Note: PASD motherboards uses the Line In 2 as the input for front
  10205. * panel mic (mic 2)
  10206. */
  10207. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10208. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10209. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10210. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10211. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10212. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10213. /*
  10214. * Set up output mixers (0x0c - 0x0f)
  10215. */
  10216. /* set vol=0 to output mixers */
  10217. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10218. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10219. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10220. /* set up input amps for analog loopback */
  10221. /* Amp Indices: DAC = 0, mixer = 1 */
  10222. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10223. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10224. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10225. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10226. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10227. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10228. /* FIXME: use matrix-type input source selection */
  10229. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10230. /* Input mixer */
  10231. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10232. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10233. { }
  10234. };
  10235. /* capture mixer elements */
  10236. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10237. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10238. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10239. {
  10240. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10241. /* The multiple "Capture Source" controls confuse alsamixer
  10242. * So call somewhat different..
  10243. * FIXME: the controls appear in the "playback" view!
  10244. */
  10245. /* .name = "Capture Source", */
  10246. .name = "Input Source",
  10247. .count = 1,
  10248. .info = alc882_mux_enum_info,
  10249. .get = alc882_mux_enum_get,
  10250. .put = alc882_mux_enum_put,
  10251. },
  10252. { } /* end */
  10253. };
  10254. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10255. {
  10256. unsigned int present;
  10257. unsigned char bits;
  10258. present = snd_hda_codec_read(codec, 0x14, 0,
  10259. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10260. bits = present ? HDA_AMP_MUTE : 0;
  10261. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10262. HDA_AMP_MUTE, bits);
  10263. }
  10264. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10265. {
  10266. unsigned int present;
  10267. unsigned char bits;
  10268. present = snd_hda_codec_read(codec, 0x1b, 0,
  10269. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10270. bits = present ? HDA_AMP_MUTE : 0;
  10271. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10272. HDA_AMP_MUTE, bits);
  10273. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10274. HDA_AMP_MUTE, bits);
  10275. }
  10276. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10277. unsigned int res)
  10278. {
  10279. if ((res >> 26) == ALC880_HP_EVENT)
  10280. alc662_lenovo_101e_all_automute(codec);
  10281. if ((res >> 26) == ALC880_FRONT_EVENT)
  10282. alc662_lenovo_101e_ispeaker_automute(codec);
  10283. }
  10284. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10285. #define alc662_loopbacks alc880_loopbacks
  10286. #endif
  10287. /* pcm configuration: identiacal with ALC880 */
  10288. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10289. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10290. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10291. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10292. /*
  10293. * configuration and preset
  10294. */
  10295. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10296. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10297. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10298. [ALC662_3ST_6ch] = "3stack-6ch",
  10299. [ALC662_5ST_DIG] = "6stack-dig",
  10300. [ALC662_LENOVO_101E] = "lenovo-101e",
  10301. [ALC662_AUTO] = "auto",
  10302. };
  10303. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10304. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10305. {}
  10306. };
  10307. static struct alc_config_preset alc662_presets[] = {
  10308. [ALC662_3ST_2ch_DIG] = {
  10309. .mixers = { alc662_3ST_2ch_mixer },
  10310. .init_verbs = { alc662_init_verbs },
  10311. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10312. .dac_nids = alc662_dac_nids,
  10313. .dig_out_nid = ALC662_DIGOUT_NID,
  10314. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10315. .adc_nids = alc662_adc_nids,
  10316. .dig_in_nid = ALC662_DIGIN_NID,
  10317. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10318. .channel_mode = alc662_3ST_2ch_modes,
  10319. .input_mux = &alc662_capture_source,
  10320. },
  10321. [ALC662_3ST_6ch_DIG] = {
  10322. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10323. .init_verbs = { alc662_init_verbs },
  10324. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10325. .dac_nids = alc662_dac_nids,
  10326. .dig_out_nid = ALC662_DIGOUT_NID,
  10327. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10328. .adc_nids = alc662_adc_nids,
  10329. .dig_in_nid = ALC662_DIGIN_NID,
  10330. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10331. .channel_mode = alc662_3ST_6ch_modes,
  10332. .need_dac_fix = 1,
  10333. .input_mux = &alc662_capture_source,
  10334. },
  10335. [ALC662_3ST_6ch] = {
  10336. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10337. .init_verbs = { alc662_init_verbs },
  10338. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10339. .dac_nids = alc662_dac_nids,
  10340. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10341. .adc_nids = alc662_adc_nids,
  10342. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10343. .channel_mode = alc662_3ST_6ch_modes,
  10344. .need_dac_fix = 1,
  10345. .input_mux = &alc662_capture_source,
  10346. },
  10347. [ALC662_5ST_DIG] = {
  10348. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10349. .init_verbs = { alc662_init_verbs },
  10350. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10351. .dac_nids = alc662_dac_nids,
  10352. .dig_out_nid = ALC662_DIGOUT_NID,
  10353. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10354. .adc_nids = alc662_adc_nids,
  10355. .dig_in_nid = ALC662_DIGIN_NID,
  10356. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10357. .channel_mode = alc662_5stack_modes,
  10358. .input_mux = &alc662_capture_source,
  10359. },
  10360. [ALC662_LENOVO_101E] = {
  10361. .mixers = { alc662_lenovo_101e_mixer },
  10362. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10363. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10364. .dac_nids = alc662_dac_nids,
  10365. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10366. .adc_nids = alc662_adc_nids,
  10367. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10368. .channel_mode = alc662_3ST_2ch_modes,
  10369. .input_mux = &alc662_lenovo_101e_capture_source,
  10370. .unsol_event = alc662_lenovo_101e_unsol_event,
  10371. .init_hook = alc662_lenovo_101e_all_automute,
  10372. },
  10373. };
  10374. /*
  10375. * BIOS auto configuration
  10376. */
  10377. /* add playback controls from the parsed DAC table */
  10378. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10379. const struct auto_pin_cfg *cfg)
  10380. {
  10381. char name[32];
  10382. static const char *chname[4] = {
  10383. "Front", "Surround", NULL /*CLFE*/, "Side"
  10384. };
  10385. hda_nid_t nid;
  10386. int i, err;
  10387. for (i = 0; i < cfg->line_outs; i++) {
  10388. if (!spec->multiout.dac_nids[i])
  10389. continue;
  10390. nid = alc880_idx_to_mixer(i);
  10391. if (i == 2) {
  10392. /* Center/LFE */
  10393. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10394. "Center Playback Volume",
  10395. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10396. HDA_OUTPUT));
  10397. if (err < 0)
  10398. return err;
  10399. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10400. "LFE Playback Volume",
  10401. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10402. HDA_OUTPUT));
  10403. if (err < 0)
  10404. return err;
  10405. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10406. "Center Playback Switch",
  10407. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10408. HDA_INPUT));
  10409. if (err < 0)
  10410. return err;
  10411. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10412. "LFE Playback Switch",
  10413. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10414. HDA_INPUT));
  10415. if (err < 0)
  10416. return err;
  10417. } else {
  10418. sprintf(name, "%s Playback Volume", chname[i]);
  10419. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10420. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10421. HDA_OUTPUT));
  10422. if (err < 0)
  10423. return err;
  10424. sprintf(name, "%s Playback Switch", chname[i]);
  10425. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10426. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10427. HDA_INPUT));
  10428. if (err < 0)
  10429. return err;
  10430. }
  10431. }
  10432. return 0;
  10433. }
  10434. /* add playback controls for speaker and HP outputs */
  10435. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10436. const char *pfx)
  10437. {
  10438. hda_nid_t nid;
  10439. int err;
  10440. char name[32];
  10441. if (!pin)
  10442. return 0;
  10443. if (alc880_is_fixed_pin(pin)) {
  10444. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10445. /* printk("DAC nid=%x\n",nid); */
  10446. /* specify the DAC as the extra output */
  10447. if (!spec->multiout.hp_nid)
  10448. spec->multiout.hp_nid = nid;
  10449. else
  10450. spec->multiout.extra_out_nid[0] = nid;
  10451. /* control HP volume/switch on the output mixer amp */
  10452. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10453. sprintf(name, "%s Playback Volume", pfx);
  10454. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10455. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10456. if (err < 0)
  10457. return err;
  10458. sprintf(name, "%s Playback Switch", pfx);
  10459. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10460. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10461. if (err < 0)
  10462. return err;
  10463. } else if (alc880_is_multi_pin(pin)) {
  10464. /* set manual connection */
  10465. /* we have only a switch on HP-out PIN */
  10466. sprintf(name, "%s Playback Switch", pfx);
  10467. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10468. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10469. if (err < 0)
  10470. return err;
  10471. }
  10472. return 0;
  10473. }
  10474. /* create playback/capture controls for input pins */
  10475. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10476. const struct auto_pin_cfg *cfg)
  10477. {
  10478. struct hda_input_mux *imux = &spec->private_imux;
  10479. int i, err, idx;
  10480. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10481. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10482. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10483. err = new_analog_input(spec, cfg->input_pins[i],
  10484. auto_pin_cfg_labels[i],
  10485. idx, 0x0b);
  10486. if (err < 0)
  10487. return err;
  10488. imux->items[imux->num_items].label =
  10489. auto_pin_cfg_labels[i];
  10490. imux->items[imux->num_items].index =
  10491. alc880_input_pin_idx(cfg->input_pins[i]);
  10492. imux->num_items++;
  10493. }
  10494. }
  10495. return 0;
  10496. }
  10497. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10498. hda_nid_t nid, int pin_type,
  10499. int dac_idx)
  10500. {
  10501. /* set as output */
  10502. snd_hda_codec_write(codec, nid, 0,
  10503. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10504. snd_hda_codec_write(codec, nid, 0,
  10505. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10506. /* need the manual connection? */
  10507. if (alc880_is_multi_pin(nid)) {
  10508. struct alc_spec *spec = codec->spec;
  10509. int idx = alc880_multi_pin_idx(nid);
  10510. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10511. AC_VERB_SET_CONNECT_SEL,
  10512. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10513. }
  10514. }
  10515. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10516. {
  10517. struct alc_spec *spec = codec->spec;
  10518. int i;
  10519. for (i = 0; i <= HDA_SIDE; i++) {
  10520. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10521. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10522. if (nid)
  10523. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10524. i);
  10525. }
  10526. }
  10527. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10528. {
  10529. struct alc_spec *spec = codec->spec;
  10530. hda_nid_t pin;
  10531. pin = spec->autocfg.hp_pins[0];
  10532. if (pin) /* connect to front */
  10533. /* use dac 0 */
  10534. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10535. }
  10536. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10537. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10538. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10539. {
  10540. struct alc_spec *spec = codec->spec;
  10541. int i;
  10542. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10543. hda_nid_t nid = spec->autocfg.input_pins[i];
  10544. if (alc662_is_input_pin(nid)) {
  10545. snd_hda_codec_write(codec, nid, 0,
  10546. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10547. (i <= AUTO_PIN_FRONT_MIC ?
  10548. PIN_VREF80 : PIN_IN));
  10549. if (nid != ALC662_PIN_CD_NID)
  10550. snd_hda_codec_write(codec, nid, 0,
  10551. AC_VERB_SET_AMP_GAIN_MUTE,
  10552. AMP_OUT_MUTE);
  10553. }
  10554. }
  10555. }
  10556. static int alc662_parse_auto_config(struct hda_codec *codec)
  10557. {
  10558. struct alc_spec *spec = codec->spec;
  10559. int err;
  10560. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10561. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10562. alc662_ignore);
  10563. if (err < 0)
  10564. return err;
  10565. if (!spec->autocfg.line_outs)
  10566. return 0; /* can't find valid BIOS pin config */
  10567. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10568. if (err < 0)
  10569. return err;
  10570. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10571. if (err < 0)
  10572. return err;
  10573. err = alc662_auto_create_extra_out(spec,
  10574. spec->autocfg.speaker_pins[0],
  10575. "Speaker");
  10576. if (err < 0)
  10577. return err;
  10578. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10579. "Headphone");
  10580. if (err < 0)
  10581. return err;
  10582. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10583. if (err < 0)
  10584. return err;
  10585. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10586. if (spec->autocfg.dig_out_pin)
  10587. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10588. if (spec->kctl_alloc)
  10589. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10590. spec->num_mux_defs = 1;
  10591. spec->input_mux = &spec->private_imux;
  10592. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10593. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10594. spec->num_mixers++;
  10595. return 1;
  10596. }
  10597. /* additional initialization for auto-configuration model */
  10598. static void alc662_auto_init(struct hda_codec *codec)
  10599. {
  10600. alc662_auto_init_multi_out(codec);
  10601. alc662_auto_init_hp_out(codec);
  10602. alc662_auto_init_analog_input(codec);
  10603. }
  10604. static int patch_alc662(struct hda_codec *codec)
  10605. {
  10606. struct alc_spec *spec;
  10607. int err, board_config;
  10608. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10609. if (!spec)
  10610. return -ENOMEM;
  10611. codec->spec = spec;
  10612. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10613. alc662_models,
  10614. alc662_cfg_tbl);
  10615. if (board_config < 0) {
  10616. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10617. "trying auto-probe from BIOS...\n");
  10618. board_config = ALC662_AUTO;
  10619. }
  10620. if (board_config == ALC662_AUTO) {
  10621. /* automatic parse from the BIOS config */
  10622. err = alc662_parse_auto_config(codec);
  10623. if (err < 0) {
  10624. alc_free(codec);
  10625. return err;
  10626. } else if (!err) {
  10627. printk(KERN_INFO
  10628. "hda_codec: Cannot set up configuration "
  10629. "from BIOS. Using base mode...\n");
  10630. board_config = ALC662_3ST_2ch_DIG;
  10631. }
  10632. }
  10633. if (board_config != ALC662_AUTO)
  10634. setup_preset(spec, &alc662_presets[board_config]);
  10635. spec->stream_name_analog = "ALC662 Analog";
  10636. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10637. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10638. spec->stream_name_digital = "ALC662 Digital";
  10639. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10640. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10641. if (!spec->adc_nids && spec->input_mux) {
  10642. spec->adc_nids = alc662_adc_nids;
  10643. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10644. }
  10645. codec->patch_ops = alc_patch_ops;
  10646. if (board_config == ALC662_AUTO)
  10647. spec->init_hook = alc662_auto_init;
  10648. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10649. if (!spec->loopback.amplist)
  10650. spec->loopback.amplist = alc662_loopbacks;
  10651. #endif
  10652. return 0;
  10653. }
  10654. /*
  10655. * patch entries
  10656. */
  10657. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10658. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10659. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10660. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10661. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10662. .patch = patch_alc861 },
  10663. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10664. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10665. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10666. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10667. .patch = patch_alc883 },
  10668. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10669. .patch = patch_alc662 },
  10670. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10671. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10672. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10673. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10674. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10675. {} /* terminator */
  10676. };