patch_realtek.c 405 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258
  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. ALC882_ASUS_A7M,
  149. ALC885_MACPRO,
  150. ALC885_MBP3,
  151. ALC885_IMAC24,
  152. ALC882_AUTO,
  153. ALC882_MODEL_LAST,
  154. };
  155. /* ALC883 models */
  156. enum {
  157. ALC883_3ST_2ch_DIG,
  158. ALC883_3ST_6ch_DIG,
  159. ALC883_3ST_6ch,
  160. ALC883_6ST_DIG,
  161. ALC883_TARGA_DIG,
  162. ALC883_TARGA_2ch_DIG,
  163. ALC883_ACER,
  164. ALC883_ACER_ASPIRE,
  165. ALC883_MEDION,
  166. ALC883_MEDION_MD2,
  167. ALC883_LAPTOP_EAPD,
  168. ALC883_LENOVO_101E_2ch,
  169. ALC883_LENOVO_NB0763,
  170. ALC888_LENOVO_MS7195_DIG,
  171. ALC883_HAIER_W66,
  172. ALC888_6ST_HP,
  173. ALC888_3ST_HP,
  174. ALC883_AUTO,
  175. ALC883_MODEL_LAST,
  176. };
  177. /* for GPIO Poll */
  178. #define GPIO_MASK 0x03
  179. struct alc_spec {
  180. /* codec parameterization */
  181. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  182. unsigned int num_mixers;
  183. const struct hda_verb *init_verbs[5]; /* initialization verbs
  184. * don't forget NULL
  185. * termination!
  186. */
  187. unsigned int num_init_verbs;
  188. char *stream_name_analog; /* analog PCM stream */
  189. struct hda_pcm_stream *stream_analog_playback;
  190. struct hda_pcm_stream *stream_analog_capture;
  191. char *stream_name_digital; /* digital PCM stream */
  192. struct hda_pcm_stream *stream_digital_playback;
  193. struct hda_pcm_stream *stream_digital_capture;
  194. /* playback */
  195. struct hda_multi_out multiout; /* playback set-up
  196. * max_channels, dacs must be set
  197. * dig_out_nid and hp_nid are optional
  198. */
  199. /* capture */
  200. unsigned int num_adc_nids;
  201. hda_nid_t *adc_nids;
  202. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  203. /* capture source */
  204. unsigned int num_mux_defs;
  205. const struct hda_input_mux *input_mux;
  206. unsigned int cur_mux[3];
  207. /* channel model */
  208. const struct hda_channel_mode *channel_mode;
  209. int num_channel_mode;
  210. int need_dac_fix;
  211. /* PCM information */
  212. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  213. /* dynamic controls, init_verbs and input_mux */
  214. struct auto_pin_cfg autocfg;
  215. unsigned int num_kctl_alloc, num_kctl_used;
  216. struct snd_kcontrol_new *kctl_alloc;
  217. struct hda_input_mux private_imux;
  218. hda_nid_t private_dac_nids[5];
  219. /* hooks */
  220. void (*init_hook)(struct hda_codec *codec);
  221. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  222. /* for pin sensing */
  223. unsigned int sense_updated: 1;
  224. unsigned int jack_present: 1;
  225. #ifdef CONFIG_SND_HDA_POWER_SAVE
  226. struct hda_loopback_check loopback;
  227. #endif
  228. };
  229. /*
  230. * configuration template - to be copied to the spec instance
  231. */
  232. struct alc_config_preset {
  233. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  234. * with spec
  235. */
  236. const struct hda_verb *init_verbs[5];
  237. unsigned int num_dacs;
  238. hda_nid_t *dac_nids;
  239. hda_nid_t dig_out_nid; /* optional */
  240. hda_nid_t hp_nid; /* optional */
  241. unsigned int num_adc_nids;
  242. hda_nid_t *adc_nids;
  243. hda_nid_t dig_in_nid;
  244. unsigned int num_channel_mode;
  245. const struct hda_channel_mode *channel_mode;
  246. int need_dac_fix;
  247. unsigned int num_mux_defs;
  248. const struct hda_input_mux *input_mux;
  249. void (*unsol_event)(struct hda_codec *, unsigned int);
  250. void (*init_hook)(struct hda_codec *);
  251. #ifdef CONFIG_SND_HDA_POWER_SAVE
  252. struct hda_amp_list *loopbacks;
  253. #endif
  254. };
  255. /*
  256. * input MUX handling
  257. */
  258. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  259. struct snd_ctl_elem_info *uinfo)
  260. {
  261. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  262. struct alc_spec *spec = codec->spec;
  263. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  264. if (mux_idx >= spec->num_mux_defs)
  265. mux_idx = 0;
  266. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  267. }
  268. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  269. struct snd_ctl_elem_value *ucontrol)
  270. {
  271. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  272. struct alc_spec *spec = codec->spec;
  273. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  274. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  275. return 0;
  276. }
  277. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  278. struct snd_ctl_elem_value *ucontrol)
  279. {
  280. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  281. struct alc_spec *spec = codec->spec;
  282. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  283. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  284. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  285. spec->adc_nids[adc_idx],
  286. &spec->cur_mux[adc_idx]);
  287. }
  288. /*
  289. * channel mode setting
  290. */
  291. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  292. struct snd_ctl_elem_info *uinfo)
  293. {
  294. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  295. struct alc_spec *spec = codec->spec;
  296. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  297. spec->num_channel_mode);
  298. }
  299. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  300. struct snd_ctl_elem_value *ucontrol)
  301. {
  302. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  303. struct alc_spec *spec = codec->spec;
  304. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  305. spec->num_channel_mode,
  306. spec->multiout.max_channels);
  307. }
  308. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  309. struct snd_ctl_elem_value *ucontrol)
  310. {
  311. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  312. struct alc_spec *spec = codec->spec;
  313. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  314. spec->num_channel_mode,
  315. &spec->multiout.max_channels);
  316. if (err >= 0 && spec->need_dac_fix)
  317. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  318. return err;
  319. }
  320. /*
  321. * Control the mode of pin widget settings via the mixer. "pc" is used
  322. * instead of "%" to avoid consequences of accidently treating the % as
  323. * being part of a format specifier. Maximum allowed length of a value is
  324. * 63 characters plus NULL terminator.
  325. *
  326. * Note: some retasking pin complexes seem to ignore requests for input
  327. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  328. * are requested. Therefore order this list so that this behaviour will not
  329. * cause problems when mixer clients move through the enum sequentially.
  330. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  331. * March 2006.
  332. */
  333. static char *alc_pin_mode_names[] = {
  334. "Mic 50pc bias", "Mic 80pc bias",
  335. "Line in", "Line out", "Headphone out",
  336. };
  337. static unsigned char alc_pin_mode_values[] = {
  338. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  339. };
  340. /* The control can present all 5 options, or it can limit the options based
  341. * in the pin being assumed to be exclusively an input or an output pin. In
  342. * addition, "input" pins may or may not process the mic bias option
  343. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  344. * accept requests for bias as of chip versions up to March 2006) and/or
  345. * wiring in the computer.
  346. */
  347. #define ALC_PIN_DIR_IN 0x00
  348. #define ALC_PIN_DIR_OUT 0x01
  349. #define ALC_PIN_DIR_INOUT 0x02
  350. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  351. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  352. /* Info about the pin modes supported by the different pin direction modes.
  353. * For each direction the minimum and maximum values are given.
  354. */
  355. static signed char alc_pin_mode_dir_info[5][2] = {
  356. { 0, 2 }, /* ALC_PIN_DIR_IN */
  357. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  358. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  359. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  360. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  361. };
  362. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  363. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  364. #define alc_pin_mode_n_items(_dir) \
  365. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  366. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  367. struct snd_ctl_elem_info *uinfo)
  368. {
  369. unsigned int item_num = uinfo->value.enumerated.item;
  370. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  371. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  372. uinfo->count = 1;
  373. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  374. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  375. item_num = alc_pin_mode_min(dir);
  376. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  377. return 0;
  378. }
  379. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  380. struct snd_ctl_elem_value *ucontrol)
  381. {
  382. unsigned int i;
  383. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  384. hda_nid_t nid = kcontrol->private_value & 0xffff;
  385. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  386. long *valp = ucontrol->value.integer.value;
  387. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  388. AC_VERB_GET_PIN_WIDGET_CONTROL,
  389. 0x00);
  390. /* Find enumerated value for current pinctl setting */
  391. i = alc_pin_mode_min(dir);
  392. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  393. i++;
  394. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  395. return 0;
  396. }
  397. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  398. struct snd_ctl_elem_value *ucontrol)
  399. {
  400. signed int change;
  401. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  402. hda_nid_t nid = kcontrol->private_value & 0xffff;
  403. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  404. long val = *ucontrol->value.integer.value;
  405. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  406. AC_VERB_GET_PIN_WIDGET_CONTROL,
  407. 0x00);
  408. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  409. val = alc_pin_mode_min(dir);
  410. change = pinctl != alc_pin_mode_values[val];
  411. if (change) {
  412. /* Set pin mode to that requested */
  413. snd_hda_codec_write_cache(codec, nid, 0,
  414. AC_VERB_SET_PIN_WIDGET_CONTROL,
  415. alc_pin_mode_values[val]);
  416. /* Also enable the retasking pin's input/output as required
  417. * for the requested pin mode. Enum values of 2 or less are
  418. * input modes.
  419. *
  420. * Dynamically switching the input/output buffers probably
  421. * reduces noise slightly (particularly on input) so we'll
  422. * do it. However, having both input and output buffers
  423. * enabled simultaneously doesn't seem to be problematic if
  424. * this turns out to be necessary in the future.
  425. */
  426. if (val <= 2) {
  427. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  428. HDA_AMP_MUTE, HDA_AMP_MUTE);
  429. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  430. HDA_AMP_MUTE, 0);
  431. } else {
  432. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  433. HDA_AMP_MUTE, HDA_AMP_MUTE);
  434. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  435. HDA_AMP_MUTE, 0);
  436. }
  437. }
  438. return change;
  439. }
  440. #define ALC_PIN_MODE(xname, nid, dir) \
  441. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  442. .info = alc_pin_mode_info, \
  443. .get = alc_pin_mode_get, \
  444. .put = alc_pin_mode_put, \
  445. .private_value = nid | (dir<<16) }
  446. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  447. * together using a mask with more than one bit set. This control is
  448. * currently used only by the ALC260 test model. At this stage they are not
  449. * needed for any "production" models.
  450. */
  451. #ifdef CONFIG_SND_DEBUG
  452. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  453. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  454. struct snd_ctl_elem_value *ucontrol)
  455. {
  456. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  457. hda_nid_t nid = kcontrol->private_value & 0xffff;
  458. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  459. long *valp = ucontrol->value.integer.value;
  460. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  461. AC_VERB_GET_GPIO_DATA, 0x00);
  462. *valp = (val & mask) != 0;
  463. return 0;
  464. }
  465. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  466. struct snd_ctl_elem_value *ucontrol)
  467. {
  468. signed int change;
  469. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  470. hda_nid_t nid = kcontrol->private_value & 0xffff;
  471. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  472. long val = *ucontrol->value.integer.value;
  473. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  474. AC_VERB_GET_GPIO_DATA,
  475. 0x00);
  476. /* Set/unset the masked GPIO bit(s) as needed */
  477. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  478. if (val == 0)
  479. gpio_data &= ~mask;
  480. else
  481. gpio_data |= mask;
  482. snd_hda_codec_write_cache(codec, nid, 0,
  483. AC_VERB_SET_GPIO_DATA, gpio_data);
  484. return change;
  485. }
  486. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  487. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  488. .info = alc_gpio_data_info, \
  489. .get = alc_gpio_data_get, \
  490. .put = alc_gpio_data_put, \
  491. .private_value = nid | (mask<<16) }
  492. #endif /* CONFIG_SND_DEBUG */
  493. /* A switch control to allow the enabling of the digital IO pins on the
  494. * ALC260. This is incredibly simplistic; the intention of this control is
  495. * to provide something in the test model allowing digital outputs to be
  496. * identified if present. If models are found which can utilise these
  497. * outputs a more complete mixer control can be devised for those models if
  498. * necessary.
  499. */
  500. #ifdef CONFIG_SND_DEBUG
  501. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  502. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  503. struct snd_ctl_elem_value *ucontrol)
  504. {
  505. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  506. hda_nid_t nid = kcontrol->private_value & 0xffff;
  507. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  508. long *valp = ucontrol->value.integer.value;
  509. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  510. AC_VERB_GET_DIGI_CONVERT, 0x00);
  511. *valp = (val & mask) != 0;
  512. return 0;
  513. }
  514. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  515. struct snd_ctl_elem_value *ucontrol)
  516. {
  517. signed int change;
  518. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  519. hda_nid_t nid = kcontrol->private_value & 0xffff;
  520. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  521. long val = *ucontrol->value.integer.value;
  522. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  523. AC_VERB_GET_DIGI_CONVERT,
  524. 0x00);
  525. /* Set/unset the masked control bit(s) as needed */
  526. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  527. if (val==0)
  528. ctrl_data &= ~mask;
  529. else
  530. ctrl_data |= mask;
  531. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  532. ctrl_data);
  533. return change;
  534. }
  535. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  536. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  537. .info = alc_spdif_ctrl_info, \
  538. .get = alc_spdif_ctrl_get, \
  539. .put = alc_spdif_ctrl_put, \
  540. .private_value = nid | (mask<<16) }
  541. #endif /* CONFIG_SND_DEBUG */
  542. /*
  543. * set up from the preset table
  544. */
  545. static void setup_preset(struct alc_spec *spec,
  546. const struct alc_config_preset *preset)
  547. {
  548. int i;
  549. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  550. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  551. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  552. i++)
  553. spec->init_verbs[spec->num_init_verbs++] =
  554. preset->init_verbs[i];
  555. spec->channel_mode = preset->channel_mode;
  556. spec->num_channel_mode = preset->num_channel_mode;
  557. spec->need_dac_fix = preset->need_dac_fix;
  558. spec->multiout.max_channels = spec->channel_mode[0].channels;
  559. spec->multiout.num_dacs = preset->num_dacs;
  560. spec->multiout.dac_nids = preset->dac_nids;
  561. spec->multiout.dig_out_nid = preset->dig_out_nid;
  562. spec->multiout.hp_nid = preset->hp_nid;
  563. spec->num_mux_defs = preset->num_mux_defs;
  564. if (!spec->num_mux_defs)
  565. spec->num_mux_defs = 1;
  566. spec->input_mux = preset->input_mux;
  567. spec->num_adc_nids = preset->num_adc_nids;
  568. spec->adc_nids = preset->adc_nids;
  569. spec->dig_in_nid = preset->dig_in_nid;
  570. spec->unsol_event = preset->unsol_event;
  571. spec->init_hook = preset->init_hook;
  572. #ifdef CONFIG_SND_HDA_POWER_SAVE
  573. spec->loopback.amplist = preset->loopbacks;
  574. #endif
  575. }
  576. /* Enable GPIO mask and set output */
  577. static struct hda_verb alc_gpio1_init_verbs[] = {
  578. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  579. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  580. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  581. { }
  582. };
  583. static struct hda_verb alc_gpio2_init_verbs[] = {
  584. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  585. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  586. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  587. { }
  588. };
  589. static struct hda_verb alc_gpio3_init_verbs[] = {
  590. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  591. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  592. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  593. { }
  594. };
  595. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  596. * 31 ~ 16 : Manufacture ID
  597. * 15 ~ 8 : SKU ID
  598. * 7 ~ 0 : Assembly ID
  599. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  600. */
  601. static void alc_subsystem_id(struct hda_codec *codec,
  602. unsigned int porta, unsigned int porte,
  603. unsigned int portd)
  604. {
  605. unsigned int ass, tmp;
  606. ass = codec->subsystem_id;
  607. if (!(ass & 1))
  608. return;
  609. /* Override */
  610. tmp = (ass & 0x38) >> 3; /* external Amp control */
  611. switch (tmp) {
  612. case 1:
  613. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  614. break;
  615. case 3:
  616. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  617. break;
  618. case 7:
  619. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  620. break;
  621. case 5:
  622. switch (codec->vendor_id) {
  623. case 0x10ec0862:
  624. case 0x10ec0660:
  625. case 0x10ec0662:
  626. case 0x10ec0267:
  627. case 0x10ec0268:
  628. snd_hda_codec_write(codec, 0x14, 0,
  629. AC_VERB_SET_EAPD_BTLENABLE, 2);
  630. snd_hda_codec_write(codec, 0x15, 0,
  631. AC_VERB_SET_EAPD_BTLENABLE, 2);
  632. return;
  633. }
  634. case 6:
  635. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  636. hda_nid_t port = 0;
  637. tmp = (ass & 0x1800) >> 11;
  638. switch (tmp) {
  639. case 0: port = porta; break;
  640. case 1: port = porte; break;
  641. case 2: port = portd; break;
  642. }
  643. if (port)
  644. snd_hda_codec_write(codec, port, 0,
  645. AC_VERB_SET_EAPD_BTLENABLE,
  646. 2);
  647. }
  648. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  649. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  650. (tmp == 5 ? 0x3040 : 0x3050));
  651. break;
  652. }
  653. }
  654. /*
  655. * Fix-up pin default configurations
  656. */
  657. struct alc_pincfg {
  658. hda_nid_t nid;
  659. u32 val;
  660. };
  661. static void alc_fix_pincfg(struct hda_codec *codec,
  662. const struct snd_pci_quirk *quirk,
  663. const struct alc_pincfg **pinfix)
  664. {
  665. const struct alc_pincfg *cfg;
  666. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  667. if (!quirk)
  668. return;
  669. cfg = pinfix[quirk->value];
  670. for (; cfg->nid; cfg++) {
  671. int i;
  672. u32 val = cfg->val;
  673. for (i = 0; i < 4; i++) {
  674. snd_hda_codec_write(codec, cfg->nid, 0,
  675. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  676. val & 0xff);
  677. val >>= 8;
  678. }
  679. }
  680. }
  681. /*
  682. * ALC880 3-stack model
  683. *
  684. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  685. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  686. * F-Mic = 0x1b, HP = 0x19
  687. */
  688. static hda_nid_t alc880_dac_nids[4] = {
  689. /* front, rear, clfe, rear_surr */
  690. 0x02, 0x05, 0x04, 0x03
  691. };
  692. static hda_nid_t alc880_adc_nids[3] = {
  693. /* ADC0-2 */
  694. 0x07, 0x08, 0x09,
  695. };
  696. /* The datasheet says the node 0x07 is connected from inputs,
  697. * but it shows zero connection in the real implementation on some devices.
  698. * Note: this is a 915GAV bug, fixed on 915GLV
  699. */
  700. static hda_nid_t alc880_adc_nids_alt[2] = {
  701. /* ADC1-2 */
  702. 0x08, 0x09,
  703. };
  704. #define ALC880_DIGOUT_NID 0x06
  705. #define ALC880_DIGIN_NID 0x0a
  706. static struct hda_input_mux alc880_capture_source = {
  707. .num_items = 4,
  708. .items = {
  709. { "Mic", 0x0 },
  710. { "Front Mic", 0x3 },
  711. { "Line", 0x2 },
  712. { "CD", 0x4 },
  713. },
  714. };
  715. /* channel source setting (2/6 channel selection for 3-stack) */
  716. /* 2ch mode */
  717. static struct hda_verb alc880_threestack_ch2_init[] = {
  718. /* set line-in to input, mute it */
  719. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  720. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  721. /* set mic-in to input vref 80%, mute it */
  722. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  723. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  724. { } /* end */
  725. };
  726. /* 6ch mode */
  727. static struct hda_verb alc880_threestack_ch6_init[] = {
  728. /* set line-in to output, unmute it */
  729. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  730. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  731. /* set mic-in to output, unmute it */
  732. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  733. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  734. { } /* end */
  735. };
  736. static struct hda_channel_mode alc880_threestack_modes[2] = {
  737. { 2, alc880_threestack_ch2_init },
  738. { 6, alc880_threestack_ch6_init },
  739. };
  740. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  741. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  742. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  743. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  744. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  745. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  746. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  747. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  748. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  749. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  750. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  751. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  752. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  753. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  754. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  755. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  756. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  757. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  758. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  759. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  760. {
  761. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  762. .name = "Channel Mode",
  763. .info = alc_ch_mode_info,
  764. .get = alc_ch_mode_get,
  765. .put = alc_ch_mode_put,
  766. },
  767. { } /* end */
  768. };
  769. /* capture mixer elements */
  770. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  771. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  772. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  773. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  774. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  775. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  776. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  777. {
  778. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  779. /* The multiple "Capture Source" controls confuse alsamixer
  780. * So call somewhat different..
  781. * FIXME: the controls appear in the "playback" view!
  782. */
  783. /* .name = "Capture Source", */
  784. .name = "Input Source",
  785. .count = 3,
  786. .info = alc_mux_enum_info,
  787. .get = alc_mux_enum_get,
  788. .put = alc_mux_enum_put,
  789. },
  790. { } /* end */
  791. };
  792. /* capture mixer elements (in case NID 0x07 not available) */
  793. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  794. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  795. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  796. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  797. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  798. {
  799. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  800. /* The multiple "Capture Source" controls confuse alsamixer
  801. * So call somewhat different..
  802. * FIXME: the controls appear in the "playback" view!
  803. */
  804. /* .name = "Capture Source", */
  805. .name = "Input Source",
  806. .count = 2,
  807. .info = alc_mux_enum_info,
  808. .get = alc_mux_enum_get,
  809. .put = alc_mux_enum_put,
  810. },
  811. { } /* end */
  812. };
  813. /*
  814. * ALC880 5-stack model
  815. *
  816. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  817. * Side = 0x02 (0xd)
  818. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  819. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  820. */
  821. /* additional mixers to alc880_three_stack_mixer */
  822. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  823. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  824. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  825. { } /* end */
  826. };
  827. /* channel source setting (6/8 channel selection for 5-stack) */
  828. /* 6ch mode */
  829. static struct hda_verb alc880_fivestack_ch6_init[] = {
  830. /* set line-in to input, mute it */
  831. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  832. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  833. { } /* end */
  834. };
  835. /* 8ch mode */
  836. static struct hda_verb alc880_fivestack_ch8_init[] = {
  837. /* set line-in to output, unmute it */
  838. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  839. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  840. { } /* end */
  841. };
  842. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  843. { 6, alc880_fivestack_ch6_init },
  844. { 8, alc880_fivestack_ch8_init },
  845. };
  846. /*
  847. * ALC880 6-stack model
  848. *
  849. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  850. * Side = 0x05 (0x0f)
  851. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  852. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  853. */
  854. static hda_nid_t alc880_6st_dac_nids[4] = {
  855. /* front, rear, clfe, rear_surr */
  856. 0x02, 0x03, 0x04, 0x05
  857. };
  858. static struct hda_input_mux alc880_6stack_capture_source = {
  859. .num_items = 4,
  860. .items = {
  861. { "Mic", 0x0 },
  862. { "Front Mic", 0x1 },
  863. { "Line", 0x2 },
  864. { "CD", 0x4 },
  865. },
  866. };
  867. /* fixed 8-channels */
  868. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  869. { 8, NULL },
  870. };
  871. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  872. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  873. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  874. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  875. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  876. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  877. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  878. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  879. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  880. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  881. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  882. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  883. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  884. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  885. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  886. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  887. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  888. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  889. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  890. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  891. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  892. {
  893. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  894. .name = "Channel Mode",
  895. .info = alc_ch_mode_info,
  896. .get = alc_ch_mode_get,
  897. .put = alc_ch_mode_put,
  898. },
  899. { } /* end */
  900. };
  901. /*
  902. * ALC880 W810 model
  903. *
  904. * W810 has rear IO for:
  905. * Front (DAC 02)
  906. * Surround (DAC 03)
  907. * Center/LFE (DAC 04)
  908. * Digital out (06)
  909. *
  910. * The system also has a pair of internal speakers, and a headphone jack.
  911. * These are both connected to Line2 on the codec, hence to DAC 02.
  912. *
  913. * There is a variable resistor to control the speaker or headphone
  914. * volume. This is a hardware-only device without a software API.
  915. *
  916. * Plugging headphones in will disable the internal speakers. This is
  917. * implemented in hardware, not via the driver using jack sense. In
  918. * a similar fashion, plugging into the rear socket marked "front" will
  919. * disable both the speakers and headphones.
  920. *
  921. * For input, there's a microphone jack, and an "audio in" jack.
  922. * These may not do anything useful with this driver yet, because I
  923. * haven't setup any initialization verbs for these yet...
  924. */
  925. static hda_nid_t alc880_w810_dac_nids[3] = {
  926. /* front, rear/surround, clfe */
  927. 0x02, 0x03, 0x04
  928. };
  929. /* fixed 6 channels */
  930. static struct hda_channel_mode alc880_w810_modes[1] = {
  931. { 6, NULL }
  932. };
  933. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  934. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  935. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  936. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  937. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  938. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  939. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  940. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  941. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  942. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  943. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  944. { } /* end */
  945. };
  946. /*
  947. * Z710V model
  948. *
  949. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  950. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  951. * Line = 0x1a
  952. */
  953. static hda_nid_t alc880_z71v_dac_nids[1] = {
  954. 0x02
  955. };
  956. #define ALC880_Z71V_HP_DAC 0x03
  957. /* fixed 2 channels */
  958. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  959. { 2, NULL }
  960. };
  961. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  962. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  963. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  964. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  965. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  966. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  967. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  968. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  969. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  970. { } /* end */
  971. };
  972. /* FIXME! */
  973. /*
  974. * ALC880 F1734 model
  975. *
  976. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  977. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  978. */
  979. static hda_nid_t alc880_f1734_dac_nids[1] = {
  980. 0x03
  981. };
  982. #define ALC880_F1734_HP_DAC 0x02
  983. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  984. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  985. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  986. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  987. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  988. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  989. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  990. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  991. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  992. { } /* end */
  993. };
  994. /* FIXME! */
  995. /*
  996. * ALC880 ASUS model
  997. *
  998. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  999. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1000. * Mic = 0x18, Line = 0x1a
  1001. */
  1002. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1003. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1004. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1005. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1006. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1007. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1008. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1009. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1010. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1011. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1012. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1013. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1014. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1015. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1016. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1017. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1018. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1019. {
  1020. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1021. .name = "Channel Mode",
  1022. .info = alc_ch_mode_info,
  1023. .get = alc_ch_mode_get,
  1024. .put = alc_ch_mode_put,
  1025. },
  1026. { } /* end */
  1027. };
  1028. /* FIXME! */
  1029. /*
  1030. * ALC880 ASUS W1V model
  1031. *
  1032. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1033. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1034. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1035. */
  1036. /* additional mixers to alc880_asus_mixer */
  1037. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1038. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1039. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1040. { } /* end */
  1041. };
  1042. /* additional mixers to alc880_asus_mixer */
  1043. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1044. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1045. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1046. { } /* end */
  1047. };
  1048. /* TCL S700 */
  1049. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1050. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1051. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1052. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1053. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1054. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1055. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1056. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1057. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1058. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1059. {
  1060. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1061. /* The multiple "Capture Source" controls confuse alsamixer
  1062. * So call somewhat different..
  1063. * FIXME: the controls appear in the "playback" view!
  1064. */
  1065. /* .name = "Capture Source", */
  1066. .name = "Input Source",
  1067. .count = 1,
  1068. .info = alc_mux_enum_info,
  1069. .get = alc_mux_enum_get,
  1070. .put = alc_mux_enum_put,
  1071. },
  1072. { } /* end */
  1073. };
  1074. /* Uniwill */
  1075. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1076. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1077. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1078. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1079. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1080. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1081. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1082. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1083. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1084. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1085. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1086. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1087. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1088. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1089. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1090. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1091. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1092. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1093. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1094. {
  1095. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1096. .name = "Channel Mode",
  1097. .info = alc_ch_mode_info,
  1098. .get = alc_ch_mode_get,
  1099. .put = alc_ch_mode_put,
  1100. },
  1101. { } /* end */
  1102. };
  1103. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1104. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1105. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1106. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1107. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1108. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1109. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1110. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1111. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1112. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1113. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1114. { } /* end */
  1115. };
  1116. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1117. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1118. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1119. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1120. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1121. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1122. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1123. { } /* end */
  1124. };
  1125. /*
  1126. * build control elements
  1127. */
  1128. static int alc_build_controls(struct hda_codec *codec)
  1129. {
  1130. struct alc_spec *spec = codec->spec;
  1131. int err;
  1132. int i;
  1133. for (i = 0; i < spec->num_mixers; i++) {
  1134. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1135. if (err < 0)
  1136. return err;
  1137. }
  1138. if (spec->multiout.dig_out_nid) {
  1139. err = snd_hda_create_spdif_out_ctls(codec,
  1140. spec->multiout.dig_out_nid);
  1141. if (err < 0)
  1142. return err;
  1143. }
  1144. if (spec->dig_in_nid) {
  1145. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1146. if (err < 0)
  1147. return err;
  1148. }
  1149. return 0;
  1150. }
  1151. /*
  1152. * initialize the codec volumes, etc
  1153. */
  1154. /*
  1155. * generic initialization of ADC, input mixers and output mixers
  1156. */
  1157. static struct hda_verb alc880_volume_init_verbs[] = {
  1158. /*
  1159. * Unmute ADC0-2 and set the default input to mic-in
  1160. */
  1161. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1162. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1163. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1164. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1165. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1166. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1167. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1168. * mixer widget
  1169. * Note: PASD motherboards uses the Line In 2 as the input for front
  1170. * panel mic (mic 2)
  1171. */
  1172. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1173. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1174. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1175. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1179. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1180. /*
  1181. * Set up output mixers (0x0c - 0x0f)
  1182. */
  1183. /* set vol=0 to output mixers */
  1184. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1185. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1186. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1187. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1188. /* set up input amps for analog loopback */
  1189. /* Amp Indices: DAC = 0, mixer = 1 */
  1190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1197. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1198. { }
  1199. };
  1200. /*
  1201. * 3-stack pin configuration:
  1202. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1203. */
  1204. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1205. /*
  1206. * preset connection lists of input pins
  1207. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1208. */
  1209. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1210. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1211. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1212. /*
  1213. * Set pin mode and muting
  1214. */
  1215. /* set front pin widgets 0x14 for output */
  1216. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1217. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1218. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1219. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1220. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1221. /* Mic2 (as headphone out) for HP output */
  1222. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1223. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1224. /* Line In pin widget for input */
  1225. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1226. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1227. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1228. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1229. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1230. /* CD pin widget for input */
  1231. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1232. { }
  1233. };
  1234. /*
  1235. * 5-stack pin configuration:
  1236. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1237. * line-in/side = 0x1a, f-mic = 0x1b
  1238. */
  1239. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1240. /*
  1241. * preset connection lists of input pins
  1242. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1243. */
  1244. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1245. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1246. /*
  1247. * Set pin mode and muting
  1248. */
  1249. /* set pin widgets 0x14-0x17 for output */
  1250. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1251. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1253. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1254. /* unmute pins for output (no gain on this amp) */
  1255. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1258. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1259. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1260. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1261. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1262. /* Mic2 (as headphone out) for HP output */
  1263. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1264. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1265. /* Line In pin widget for input */
  1266. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1267. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1268. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1269. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1270. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1271. /* CD pin widget for input */
  1272. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1273. { }
  1274. };
  1275. /*
  1276. * W810 pin configuration:
  1277. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1278. */
  1279. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1280. /* hphone/speaker input selector: front DAC */
  1281. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1282. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1283. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1284. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1285. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1286. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1287. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1288. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1289. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1290. { }
  1291. };
  1292. /*
  1293. * Z71V pin configuration:
  1294. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1295. */
  1296. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1297. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1298. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1299. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1300. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1301. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1302. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1303. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1304. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1305. { }
  1306. };
  1307. /*
  1308. * 6-stack pin configuration:
  1309. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1310. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1311. */
  1312. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1313. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1314. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1315. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1316. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1317. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1318. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1319. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1320. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1321. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1322. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1323. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1324. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1325. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1326. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1327. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1328. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1329. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1330. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1331. { }
  1332. };
  1333. /*
  1334. * Uniwill pin configuration:
  1335. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1336. * line = 0x1a
  1337. */
  1338. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1339. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1340. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1341. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1342. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1343. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1344. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1345. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1346. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1347. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1349. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1351. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1353. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1354. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1355. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1356. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1357. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1358. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1359. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1360. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1361. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1362. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1363. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1364. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1365. { }
  1366. };
  1367. /*
  1368. * Uniwill P53
  1369. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1370. */
  1371. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1372. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1373. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1374. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1375. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1376. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1377. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1378. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1379. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1380. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1381. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1382. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1383. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1384. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1385. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1386. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1387. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1388. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1389. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1390. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1391. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1392. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1393. { }
  1394. };
  1395. static struct hda_verb alc880_beep_init_verbs[] = {
  1396. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1397. { }
  1398. };
  1399. /* toggle speaker-output according to the hp-jack state */
  1400. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1401. {
  1402. unsigned int present;
  1403. unsigned char bits;
  1404. present = snd_hda_codec_read(codec, 0x14, 0,
  1405. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1406. bits = present ? HDA_AMP_MUTE : 0;
  1407. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1408. HDA_AMP_MUTE, bits);
  1409. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1410. HDA_AMP_MUTE, bits);
  1411. }
  1412. /* auto-toggle front mic */
  1413. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1414. {
  1415. unsigned int present;
  1416. unsigned char bits;
  1417. present = snd_hda_codec_read(codec, 0x18, 0,
  1418. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1419. bits = present ? HDA_AMP_MUTE : 0;
  1420. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1421. }
  1422. static void alc880_uniwill_automute(struct hda_codec *codec)
  1423. {
  1424. alc880_uniwill_hp_automute(codec);
  1425. alc880_uniwill_mic_automute(codec);
  1426. }
  1427. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1428. unsigned int res)
  1429. {
  1430. /* Looks like the unsol event is incompatible with the standard
  1431. * definition. 4bit tag is placed at 28 bit!
  1432. */
  1433. switch (res >> 28) {
  1434. case ALC880_HP_EVENT:
  1435. alc880_uniwill_hp_automute(codec);
  1436. break;
  1437. case ALC880_MIC_EVENT:
  1438. alc880_uniwill_mic_automute(codec);
  1439. break;
  1440. }
  1441. }
  1442. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1443. {
  1444. unsigned int present;
  1445. unsigned char bits;
  1446. present = snd_hda_codec_read(codec, 0x14, 0,
  1447. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1448. bits = present ? HDA_AMP_MUTE : 0;
  1449. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1450. }
  1451. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1452. {
  1453. unsigned int present;
  1454. present = snd_hda_codec_read(codec, 0x21, 0,
  1455. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1456. present &= HDA_AMP_VOLMASK;
  1457. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1458. HDA_AMP_VOLMASK, present);
  1459. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1460. HDA_AMP_VOLMASK, present);
  1461. }
  1462. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1463. unsigned int res)
  1464. {
  1465. /* Looks like the unsol event is incompatible with the standard
  1466. * definition. 4bit tag is placed at 28 bit!
  1467. */
  1468. if ((res >> 28) == ALC880_HP_EVENT)
  1469. alc880_uniwill_p53_hp_automute(codec);
  1470. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1471. alc880_uniwill_p53_dcvol_automute(codec);
  1472. }
  1473. /* FIXME! */
  1474. /*
  1475. * F1734 pin configuration:
  1476. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1477. */
  1478. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1479. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1480. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1481. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1482. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1483. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1484. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1485. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1486. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1487. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1488. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1489. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1490. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1491. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1492. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1493. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1494. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1495. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1496. { }
  1497. };
  1498. /* FIXME! */
  1499. /*
  1500. * ASUS pin configuration:
  1501. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1502. */
  1503. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1504. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1505. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1506. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1507. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1508. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1509. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1510. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1511. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1512. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1513. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1514. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1515. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1516. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1517. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1518. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1519. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1520. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1521. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1522. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1523. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1524. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1525. { }
  1526. };
  1527. /* Enable GPIO mask and set output */
  1528. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1529. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1530. /* Clevo m520g init */
  1531. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1532. /* headphone output */
  1533. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1534. /* line-out */
  1535. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1536. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1537. /* Line-in */
  1538. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1539. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1540. /* CD */
  1541. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1542. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1543. /* Mic1 (rear panel) */
  1544. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1545. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1546. /* Mic2 (front panel) */
  1547. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1548. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1549. /* headphone */
  1550. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1551. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1552. /* change to EAPD mode */
  1553. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1554. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1555. { }
  1556. };
  1557. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1558. /* change to EAPD mode */
  1559. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1560. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1561. /* Headphone output */
  1562. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1563. /* Front output*/
  1564. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1565. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1566. /* Line In pin widget for input */
  1567. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1568. /* CD pin widget for input */
  1569. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1570. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1571. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1572. /* change to EAPD mode */
  1573. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1574. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1575. { }
  1576. };
  1577. /*
  1578. * LG m1 express dual
  1579. *
  1580. * Pin assignment:
  1581. * Rear Line-In/Out (blue): 0x14
  1582. * Build-in Mic-In: 0x15
  1583. * Speaker-out: 0x17
  1584. * HP-Out (green): 0x1b
  1585. * Mic-In/Out (red): 0x19
  1586. * SPDIF-Out: 0x1e
  1587. */
  1588. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1589. static hda_nid_t alc880_lg_dac_nids[3] = {
  1590. 0x05, 0x02, 0x03
  1591. };
  1592. /* seems analog CD is not working */
  1593. static struct hda_input_mux alc880_lg_capture_source = {
  1594. .num_items = 3,
  1595. .items = {
  1596. { "Mic", 0x1 },
  1597. { "Line", 0x5 },
  1598. { "Internal Mic", 0x6 },
  1599. },
  1600. };
  1601. /* 2,4,6 channel modes */
  1602. static struct hda_verb alc880_lg_ch2_init[] = {
  1603. /* set line-in and mic-in to input */
  1604. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1605. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1606. { }
  1607. };
  1608. static struct hda_verb alc880_lg_ch4_init[] = {
  1609. /* set line-in to out and mic-in to input */
  1610. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1611. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1612. { }
  1613. };
  1614. static struct hda_verb alc880_lg_ch6_init[] = {
  1615. /* set line-in and mic-in to output */
  1616. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1617. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1618. { }
  1619. };
  1620. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1621. { 2, alc880_lg_ch2_init },
  1622. { 4, alc880_lg_ch4_init },
  1623. { 6, alc880_lg_ch6_init },
  1624. };
  1625. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1626. /* FIXME: it's not really "master" but front channels */
  1627. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1628. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1629. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1630. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1631. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1632. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1633. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1634. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1635. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1636. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1637. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1638. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1639. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1640. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1641. {
  1642. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1643. .name = "Channel Mode",
  1644. .info = alc_ch_mode_info,
  1645. .get = alc_ch_mode_get,
  1646. .put = alc_ch_mode_put,
  1647. },
  1648. { } /* end */
  1649. };
  1650. static struct hda_verb alc880_lg_init_verbs[] = {
  1651. /* set capture source to mic-in */
  1652. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1653. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1654. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1655. /* mute all amp mixer inputs */
  1656. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1657. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1658. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1659. /* line-in to input */
  1660. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1661. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1662. /* built-in mic */
  1663. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1664. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1665. /* speaker-out */
  1666. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1667. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1668. /* mic-in to input */
  1669. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1670. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1671. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1672. /* HP-out */
  1673. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1674. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1675. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1676. /* jack sense */
  1677. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1678. { }
  1679. };
  1680. /* toggle speaker-output according to the hp-jack state */
  1681. static void alc880_lg_automute(struct hda_codec *codec)
  1682. {
  1683. unsigned int present;
  1684. unsigned char bits;
  1685. present = snd_hda_codec_read(codec, 0x1b, 0,
  1686. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1687. bits = present ? HDA_AMP_MUTE : 0;
  1688. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1689. HDA_AMP_MUTE, bits);
  1690. }
  1691. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1692. {
  1693. /* Looks like the unsol event is incompatible with the standard
  1694. * definition. 4bit tag is placed at 28 bit!
  1695. */
  1696. if ((res >> 28) == 0x01)
  1697. alc880_lg_automute(codec);
  1698. }
  1699. /*
  1700. * LG LW20
  1701. *
  1702. * Pin assignment:
  1703. * Speaker-out: 0x14
  1704. * Mic-In: 0x18
  1705. * Built-in Mic-In: 0x19
  1706. * Line-In: 0x1b
  1707. * HP-Out: 0x1a
  1708. * SPDIF-Out: 0x1e
  1709. */
  1710. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1711. .num_items = 3,
  1712. .items = {
  1713. { "Mic", 0x0 },
  1714. { "Internal Mic", 0x1 },
  1715. { "Line In", 0x2 },
  1716. },
  1717. };
  1718. #define alc880_lg_lw_modes alc880_threestack_modes
  1719. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1720. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1721. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1722. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1723. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1724. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1725. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1726. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1727. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1728. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1729. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1730. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1731. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1732. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1733. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1734. {
  1735. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1736. .name = "Channel Mode",
  1737. .info = alc_ch_mode_info,
  1738. .get = alc_ch_mode_get,
  1739. .put = alc_ch_mode_put,
  1740. },
  1741. { } /* end */
  1742. };
  1743. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1744. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1745. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1746. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1747. /* set capture source to mic-in */
  1748. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1749. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1750. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1751. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1752. /* speaker-out */
  1753. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1754. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1755. /* HP-out */
  1756. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1757. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1758. /* mic-in to input */
  1759. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1760. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1761. /* built-in mic */
  1762. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1763. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1764. /* jack sense */
  1765. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1766. { }
  1767. };
  1768. /* toggle speaker-output according to the hp-jack state */
  1769. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1770. {
  1771. unsigned int present;
  1772. unsigned char bits;
  1773. present = snd_hda_codec_read(codec, 0x1b, 0,
  1774. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1775. bits = present ? HDA_AMP_MUTE : 0;
  1776. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1777. HDA_AMP_MUTE, bits);
  1778. }
  1779. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1780. {
  1781. /* Looks like the unsol event is incompatible with the standard
  1782. * definition. 4bit tag is placed at 28 bit!
  1783. */
  1784. if ((res >> 28) == 0x01)
  1785. alc880_lg_lw_automute(codec);
  1786. }
  1787. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1788. static struct hda_amp_list alc880_loopbacks[] = {
  1789. { 0x0b, HDA_INPUT, 0 },
  1790. { 0x0b, HDA_INPUT, 1 },
  1791. { 0x0b, HDA_INPUT, 2 },
  1792. { 0x0b, HDA_INPUT, 3 },
  1793. { 0x0b, HDA_INPUT, 4 },
  1794. { } /* end */
  1795. };
  1796. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1797. { 0x0b, HDA_INPUT, 1 },
  1798. { 0x0b, HDA_INPUT, 6 },
  1799. { 0x0b, HDA_INPUT, 7 },
  1800. { } /* end */
  1801. };
  1802. #endif
  1803. /*
  1804. * Common callbacks
  1805. */
  1806. static int alc_init(struct hda_codec *codec)
  1807. {
  1808. struct alc_spec *spec = codec->spec;
  1809. unsigned int i;
  1810. for (i = 0; i < spec->num_init_verbs; i++)
  1811. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1812. if (spec->init_hook)
  1813. spec->init_hook(codec);
  1814. return 0;
  1815. }
  1816. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1817. {
  1818. struct alc_spec *spec = codec->spec;
  1819. if (spec->unsol_event)
  1820. spec->unsol_event(codec, res);
  1821. }
  1822. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1823. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1824. {
  1825. struct alc_spec *spec = codec->spec;
  1826. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1827. }
  1828. #endif
  1829. /*
  1830. * Analog playback callbacks
  1831. */
  1832. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1833. struct hda_codec *codec,
  1834. struct snd_pcm_substream *substream)
  1835. {
  1836. struct alc_spec *spec = codec->spec;
  1837. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1838. }
  1839. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1840. struct hda_codec *codec,
  1841. unsigned int stream_tag,
  1842. unsigned int format,
  1843. struct snd_pcm_substream *substream)
  1844. {
  1845. struct alc_spec *spec = codec->spec;
  1846. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1847. stream_tag, format, substream);
  1848. }
  1849. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1850. struct hda_codec *codec,
  1851. struct snd_pcm_substream *substream)
  1852. {
  1853. struct alc_spec *spec = codec->spec;
  1854. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1855. }
  1856. /*
  1857. * Digital out
  1858. */
  1859. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1860. struct hda_codec *codec,
  1861. struct snd_pcm_substream *substream)
  1862. {
  1863. struct alc_spec *spec = codec->spec;
  1864. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1865. }
  1866. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1867. struct hda_codec *codec,
  1868. unsigned int stream_tag,
  1869. unsigned int format,
  1870. struct snd_pcm_substream *substream)
  1871. {
  1872. struct alc_spec *spec = codec->spec;
  1873. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1874. stream_tag, format, substream);
  1875. }
  1876. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1877. struct hda_codec *codec,
  1878. struct snd_pcm_substream *substream)
  1879. {
  1880. struct alc_spec *spec = codec->spec;
  1881. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1882. }
  1883. /*
  1884. * Analog capture
  1885. */
  1886. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1887. struct hda_codec *codec,
  1888. unsigned int stream_tag,
  1889. unsigned int format,
  1890. struct snd_pcm_substream *substream)
  1891. {
  1892. struct alc_spec *spec = codec->spec;
  1893. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1894. stream_tag, 0, format);
  1895. return 0;
  1896. }
  1897. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1898. struct hda_codec *codec,
  1899. struct snd_pcm_substream *substream)
  1900. {
  1901. struct alc_spec *spec = codec->spec;
  1902. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1903. 0, 0, 0);
  1904. return 0;
  1905. }
  1906. /*
  1907. */
  1908. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1909. .substreams = 1,
  1910. .channels_min = 2,
  1911. .channels_max = 8,
  1912. /* NID is set in alc_build_pcms */
  1913. .ops = {
  1914. .open = alc880_playback_pcm_open,
  1915. .prepare = alc880_playback_pcm_prepare,
  1916. .cleanup = alc880_playback_pcm_cleanup
  1917. },
  1918. };
  1919. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1920. .substreams = 2,
  1921. .channels_min = 2,
  1922. .channels_max = 2,
  1923. /* NID is set in alc_build_pcms */
  1924. .ops = {
  1925. .prepare = alc880_capture_pcm_prepare,
  1926. .cleanup = alc880_capture_pcm_cleanup
  1927. },
  1928. };
  1929. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1930. .substreams = 1,
  1931. .channels_min = 2,
  1932. .channels_max = 2,
  1933. /* NID is set in alc_build_pcms */
  1934. .ops = {
  1935. .open = alc880_dig_playback_pcm_open,
  1936. .close = alc880_dig_playback_pcm_close,
  1937. .prepare = alc880_dig_playback_pcm_prepare
  1938. },
  1939. };
  1940. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1941. .substreams = 1,
  1942. .channels_min = 2,
  1943. .channels_max = 2,
  1944. /* NID is set in alc_build_pcms */
  1945. };
  1946. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1947. static struct hda_pcm_stream alc_pcm_null_playback = {
  1948. .substreams = 0,
  1949. .channels_min = 0,
  1950. .channels_max = 0,
  1951. };
  1952. static int alc_build_pcms(struct hda_codec *codec)
  1953. {
  1954. struct alc_spec *spec = codec->spec;
  1955. struct hda_pcm *info = spec->pcm_rec;
  1956. int i;
  1957. codec->num_pcms = 1;
  1958. codec->pcm_info = info;
  1959. info->name = spec->stream_name_analog;
  1960. if (spec->stream_analog_playback) {
  1961. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1962. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1963. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1964. }
  1965. if (spec->stream_analog_capture) {
  1966. snd_assert(spec->adc_nids, return -EINVAL);
  1967. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1968. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1969. }
  1970. if (spec->channel_mode) {
  1971. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1972. for (i = 0; i < spec->num_channel_mode; i++) {
  1973. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1974. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1975. }
  1976. }
  1977. }
  1978. /* SPDIF for stream index #1 */
  1979. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1980. codec->num_pcms = 2;
  1981. info = spec->pcm_rec + 1;
  1982. info->name = spec->stream_name_digital;
  1983. if (spec->multiout.dig_out_nid &&
  1984. spec->stream_digital_playback) {
  1985. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1986. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1987. }
  1988. if (spec->dig_in_nid &&
  1989. spec->stream_digital_capture) {
  1990. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1991. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1992. }
  1993. }
  1994. /* If the use of more than one ADC is requested for the current
  1995. * model, configure a second analog capture-only PCM.
  1996. */
  1997. /* Additional Analaog capture for index #2 */
  1998. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1999. spec->adc_nids) {
  2000. codec->num_pcms = 3;
  2001. info = spec->pcm_rec + 2;
  2002. info->name = spec->stream_name_analog;
  2003. /* No playback stream for second PCM */
  2004. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2005. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2006. if (spec->stream_analog_capture) {
  2007. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2008. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2009. }
  2010. }
  2011. return 0;
  2012. }
  2013. static void alc_free(struct hda_codec *codec)
  2014. {
  2015. struct alc_spec *spec = codec->spec;
  2016. unsigned int i;
  2017. if (!spec)
  2018. return;
  2019. if (spec->kctl_alloc) {
  2020. for (i = 0; i < spec->num_kctl_used; i++)
  2021. kfree(spec->kctl_alloc[i].name);
  2022. kfree(spec->kctl_alloc);
  2023. }
  2024. kfree(spec);
  2025. }
  2026. /*
  2027. */
  2028. static struct hda_codec_ops alc_patch_ops = {
  2029. .build_controls = alc_build_controls,
  2030. .build_pcms = alc_build_pcms,
  2031. .init = alc_init,
  2032. .free = alc_free,
  2033. .unsol_event = alc_unsol_event,
  2034. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2035. .check_power_status = alc_check_power_status,
  2036. #endif
  2037. };
  2038. /*
  2039. * Test configuration for debugging
  2040. *
  2041. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2042. * enum controls.
  2043. */
  2044. #ifdef CONFIG_SND_DEBUG
  2045. static hda_nid_t alc880_test_dac_nids[4] = {
  2046. 0x02, 0x03, 0x04, 0x05
  2047. };
  2048. static struct hda_input_mux alc880_test_capture_source = {
  2049. .num_items = 7,
  2050. .items = {
  2051. { "In-1", 0x0 },
  2052. { "In-2", 0x1 },
  2053. { "In-3", 0x2 },
  2054. { "In-4", 0x3 },
  2055. { "CD", 0x4 },
  2056. { "Front", 0x5 },
  2057. { "Surround", 0x6 },
  2058. },
  2059. };
  2060. static struct hda_channel_mode alc880_test_modes[4] = {
  2061. { 2, NULL },
  2062. { 4, NULL },
  2063. { 6, NULL },
  2064. { 8, NULL },
  2065. };
  2066. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2067. struct snd_ctl_elem_info *uinfo)
  2068. {
  2069. static char *texts[] = {
  2070. "N/A", "Line Out", "HP Out",
  2071. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2072. };
  2073. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2074. uinfo->count = 1;
  2075. uinfo->value.enumerated.items = 8;
  2076. if (uinfo->value.enumerated.item >= 8)
  2077. uinfo->value.enumerated.item = 7;
  2078. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2079. return 0;
  2080. }
  2081. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2082. struct snd_ctl_elem_value *ucontrol)
  2083. {
  2084. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2085. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2086. unsigned int pin_ctl, item = 0;
  2087. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2088. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2089. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2090. if (pin_ctl & AC_PINCTL_HP_EN)
  2091. item = 2;
  2092. else
  2093. item = 1;
  2094. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2095. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2096. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2097. case AC_PINCTL_VREF_50: item = 4; break;
  2098. case AC_PINCTL_VREF_GRD: item = 5; break;
  2099. case AC_PINCTL_VREF_80: item = 6; break;
  2100. case AC_PINCTL_VREF_100: item = 7; break;
  2101. }
  2102. }
  2103. ucontrol->value.enumerated.item[0] = item;
  2104. return 0;
  2105. }
  2106. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2107. struct snd_ctl_elem_value *ucontrol)
  2108. {
  2109. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2110. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2111. static unsigned int ctls[] = {
  2112. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2113. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2114. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2115. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2116. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2117. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2118. };
  2119. unsigned int old_ctl, new_ctl;
  2120. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2121. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2122. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2123. if (old_ctl != new_ctl) {
  2124. int val;
  2125. snd_hda_codec_write_cache(codec, nid, 0,
  2126. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2127. new_ctl);
  2128. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2129. HDA_AMP_MUTE : 0;
  2130. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2131. HDA_AMP_MUTE, val);
  2132. return 1;
  2133. }
  2134. return 0;
  2135. }
  2136. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2137. struct snd_ctl_elem_info *uinfo)
  2138. {
  2139. static char *texts[] = {
  2140. "Front", "Surround", "CLFE", "Side"
  2141. };
  2142. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2143. uinfo->count = 1;
  2144. uinfo->value.enumerated.items = 4;
  2145. if (uinfo->value.enumerated.item >= 4)
  2146. uinfo->value.enumerated.item = 3;
  2147. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2148. return 0;
  2149. }
  2150. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2151. struct snd_ctl_elem_value *ucontrol)
  2152. {
  2153. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2154. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2155. unsigned int sel;
  2156. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2157. ucontrol->value.enumerated.item[0] = sel & 3;
  2158. return 0;
  2159. }
  2160. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2161. struct snd_ctl_elem_value *ucontrol)
  2162. {
  2163. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2164. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2165. unsigned int sel;
  2166. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2167. if (ucontrol->value.enumerated.item[0] != sel) {
  2168. sel = ucontrol->value.enumerated.item[0] & 3;
  2169. snd_hda_codec_write_cache(codec, nid, 0,
  2170. AC_VERB_SET_CONNECT_SEL, sel);
  2171. return 1;
  2172. }
  2173. return 0;
  2174. }
  2175. #define PIN_CTL_TEST(xname,nid) { \
  2176. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2177. .name = xname, \
  2178. .info = alc_test_pin_ctl_info, \
  2179. .get = alc_test_pin_ctl_get, \
  2180. .put = alc_test_pin_ctl_put, \
  2181. .private_value = nid \
  2182. }
  2183. #define PIN_SRC_TEST(xname,nid) { \
  2184. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2185. .name = xname, \
  2186. .info = alc_test_pin_src_info, \
  2187. .get = alc_test_pin_src_get, \
  2188. .put = alc_test_pin_src_put, \
  2189. .private_value = nid \
  2190. }
  2191. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2192. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2193. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2194. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2195. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2196. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2197. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2198. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2199. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2200. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2201. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2202. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2203. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2204. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2205. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2206. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2207. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2208. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2209. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2210. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2211. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2212. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2213. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2214. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2215. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2216. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2217. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2218. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2219. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2220. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2221. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2222. {
  2223. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2224. .name = "Channel Mode",
  2225. .info = alc_ch_mode_info,
  2226. .get = alc_ch_mode_get,
  2227. .put = alc_ch_mode_put,
  2228. },
  2229. { } /* end */
  2230. };
  2231. static struct hda_verb alc880_test_init_verbs[] = {
  2232. /* Unmute inputs of 0x0c - 0x0f */
  2233. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2234. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2235. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2236. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2237. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2238. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2239. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2240. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2241. /* Vol output for 0x0c-0x0f */
  2242. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2243. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2244. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2245. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2246. /* Set output pins 0x14-0x17 */
  2247. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2248. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2249. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2250. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2251. /* Unmute output pins 0x14-0x17 */
  2252. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2253. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2254. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2255. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2256. /* Set input pins 0x18-0x1c */
  2257. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2258. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2259. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2260. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2261. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2262. /* Mute input pins 0x18-0x1b */
  2263. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2264. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2265. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2266. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2267. /* ADC set up */
  2268. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2269. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2270. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2271. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2272. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2273. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2274. /* Analog input/passthru */
  2275. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2276. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2277. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2278. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2279. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2280. { }
  2281. };
  2282. #endif
  2283. /*
  2284. */
  2285. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2286. [ALC880_3ST] = "3stack",
  2287. [ALC880_TCL_S700] = "tcl",
  2288. [ALC880_3ST_DIG] = "3stack-digout",
  2289. [ALC880_CLEVO] = "clevo",
  2290. [ALC880_5ST] = "5stack",
  2291. [ALC880_5ST_DIG] = "5stack-digout",
  2292. [ALC880_W810] = "w810",
  2293. [ALC880_Z71V] = "z71v",
  2294. [ALC880_6ST] = "6stack",
  2295. [ALC880_6ST_DIG] = "6stack-digout",
  2296. [ALC880_ASUS] = "asus",
  2297. [ALC880_ASUS_W1V] = "asus-w1v",
  2298. [ALC880_ASUS_DIG] = "asus-dig",
  2299. [ALC880_ASUS_DIG2] = "asus-dig2",
  2300. [ALC880_UNIWILL_DIG] = "uniwill",
  2301. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2302. [ALC880_FUJITSU] = "fujitsu",
  2303. [ALC880_F1734] = "F1734",
  2304. [ALC880_LG] = "lg",
  2305. [ALC880_LG_LW] = "lg-lw",
  2306. #ifdef CONFIG_SND_DEBUG
  2307. [ALC880_TEST] = "test",
  2308. #endif
  2309. [ALC880_AUTO] = "auto",
  2310. };
  2311. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2312. /* Broken BIOS configuration */
  2313. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2314. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2315. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2316. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2317. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2318. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2319. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2320. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2321. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2322. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2323. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2324. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2325. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2326. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2327. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2328. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2329. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2330. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2331. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2332. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2333. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2334. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2335. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2336. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2337. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2338. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2339. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2340. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2341. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2342. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2343. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2344. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2345. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2346. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2347. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2348. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2349. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2350. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2351. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2352. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2353. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2354. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2355. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2356. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2357. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2358. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2359. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2360. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2361. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2362. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2363. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2364. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2365. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2366. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2367. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2368. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2369. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2370. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2371. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2372. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2373. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2374. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2375. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2376. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2377. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2378. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2379. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2380. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2381. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2382. {}
  2383. };
  2384. /*
  2385. * ALC880 codec presets
  2386. */
  2387. static struct alc_config_preset alc880_presets[] = {
  2388. [ALC880_3ST] = {
  2389. .mixers = { alc880_three_stack_mixer },
  2390. .init_verbs = { alc880_volume_init_verbs,
  2391. alc880_pin_3stack_init_verbs },
  2392. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2393. .dac_nids = alc880_dac_nids,
  2394. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2395. .channel_mode = alc880_threestack_modes,
  2396. .need_dac_fix = 1,
  2397. .input_mux = &alc880_capture_source,
  2398. },
  2399. [ALC880_3ST_DIG] = {
  2400. .mixers = { alc880_three_stack_mixer },
  2401. .init_verbs = { alc880_volume_init_verbs,
  2402. alc880_pin_3stack_init_verbs },
  2403. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2404. .dac_nids = alc880_dac_nids,
  2405. .dig_out_nid = ALC880_DIGOUT_NID,
  2406. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2407. .channel_mode = alc880_threestack_modes,
  2408. .need_dac_fix = 1,
  2409. .input_mux = &alc880_capture_source,
  2410. },
  2411. [ALC880_TCL_S700] = {
  2412. .mixers = { alc880_tcl_s700_mixer },
  2413. .init_verbs = { alc880_volume_init_verbs,
  2414. alc880_pin_tcl_S700_init_verbs,
  2415. alc880_gpio2_init_verbs },
  2416. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2417. .dac_nids = alc880_dac_nids,
  2418. .hp_nid = 0x03,
  2419. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2420. .channel_mode = alc880_2_jack_modes,
  2421. .input_mux = &alc880_capture_source,
  2422. },
  2423. [ALC880_5ST] = {
  2424. .mixers = { alc880_three_stack_mixer,
  2425. alc880_five_stack_mixer},
  2426. .init_verbs = { alc880_volume_init_verbs,
  2427. alc880_pin_5stack_init_verbs },
  2428. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2429. .dac_nids = alc880_dac_nids,
  2430. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2431. .channel_mode = alc880_fivestack_modes,
  2432. .input_mux = &alc880_capture_source,
  2433. },
  2434. [ALC880_5ST_DIG] = {
  2435. .mixers = { alc880_three_stack_mixer,
  2436. alc880_five_stack_mixer },
  2437. .init_verbs = { alc880_volume_init_verbs,
  2438. alc880_pin_5stack_init_verbs },
  2439. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2440. .dac_nids = alc880_dac_nids,
  2441. .dig_out_nid = ALC880_DIGOUT_NID,
  2442. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2443. .channel_mode = alc880_fivestack_modes,
  2444. .input_mux = &alc880_capture_source,
  2445. },
  2446. [ALC880_6ST] = {
  2447. .mixers = { alc880_six_stack_mixer },
  2448. .init_verbs = { alc880_volume_init_verbs,
  2449. alc880_pin_6stack_init_verbs },
  2450. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2451. .dac_nids = alc880_6st_dac_nids,
  2452. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2453. .channel_mode = alc880_sixstack_modes,
  2454. .input_mux = &alc880_6stack_capture_source,
  2455. },
  2456. [ALC880_6ST_DIG] = {
  2457. .mixers = { alc880_six_stack_mixer },
  2458. .init_verbs = { alc880_volume_init_verbs,
  2459. alc880_pin_6stack_init_verbs },
  2460. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2461. .dac_nids = alc880_6st_dac_nids,
  2462. .dig_out_nid = ALC880_DIGOUT_NID,
  2463. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2464. .channel_mode = alc880_sixstack_modes,
  2465. .input_mux = &alc880_6stack_capture_source,
  2466. },
  2467. [ALC880_W810] = {
  2468. .mixers = { alc880_w810_base_mixer },
  2469. .init_verbs = { alc880_volume_init_verbs,
  2470. alc880_pin_w810_init_verbs,
  2471. alc880_gpio2_init_verbs },
  2472. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2473. .dac_nids = alc880_w810_dac_nids,
  2474. .dig_out_nid = ALC880_DIGOUT_NID,
  2475. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2476. .channel_mode = alc880_w810_modes,
  2477. .input_mux = &alc880_capture_source,
  2478. },
  2479. [ALC880_Z71V] = {
  2480. .mixers = { alc880_z71v_mixer },
  2481. .init_verbs = { alc880_volume_init_verbs,
  2482. alc880_pin_z71v_init_verbs },
  2483. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2484. .dac_nids = alc880_z71v_dac_nids,
  2485. .dig_out_nid = ALC880_DIGOUT_NID,
  2486. .hp_nid = 0x03,
  2487. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2488. .channel_mode = alc880_2_jack_modes,
  2489. .input_mux = &alc880_capture_source,
  2490. },
  2491. [ALC880_F1734] = {
  2492. .mixers = { alc880_f1734_mixer },
  2493. .init_verbs = { alc880_volume_init_verbs,
  2494. alc880_pin_f1734_init_verbs },
  2495. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2496. .dac_nids = alc880_f1734_dac_nids,
  2497. .hp_nid = 0x02,
  2498. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2499. .channel_mode = alc880_2_jack_modes,
  2500. .input_mux = &alc880_capture_source,
  2501. },
  2502. [ALC880_ASUS] = {
  2503. .mixers = { alc880_asus_mixer },
  2504. .init_verbs = { alc880_volume_init_verbs,
  2505. alc880_pin_asus_init_verbs,
  2506. alc880_gpio1_init_verbs },
  2507. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2508. .dac_nids = alc880_asus_dac_nids,
  2509. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2510. .channel_mode = alc880_asus_modes,
  2511. .need_dac_fix = 1,
  2512. .input_mux = &alc880_capture_source,
  2513. },
  2514. [ALC880_ASUS_DIG] = {
  2515. .mixers = { alc880_asus_mixer },
  2516. .init_verbs = { alc880_volume_init_verbs,
  2517. alc880_pin_asus_init_verbs,
  2518. alc880_gpio1_init_verbs },
  2519. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2520. .dac_nids = alc880_asus_dac_nids,
  2521. .dig_out_nid = ALC880_DIGOUT_NID,
  2522. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2523. .channel_mode = alc880_asus_modes,
  2524. .need_dac_fix = 1,
  2525. .input_mux = &alc880_capture_source,
  2526. },
  2527. [ALC880_ASUS_DIG2] = {
  2528. .mixers = { alc880_asus_mixer },
  2529. .init_verbs = { alc880_volume_init_verbs,
  2530. alc880_pin_asus_init_verbs,
  2531. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2532. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2533. .dac_nids = alc880_asus_dac_nids,
  2534. .dig_out_nid = ALC880_DIGOUT_NID,
  2535. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2536. .channel_mode = alc880_asus_modes,
  2537. .need_dac_fix = 1,
  2538. .input_mux = &alc880_capture_source,
  2539. },
  2540. [ALC880_ASUS_W1V] = {
  2541. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2542. .init_verbs = { alc880_volume_init_verbs,
  2543. alc880_pin_asus_init_verbs,
  2544. alc880_gpio1_init_verbs },
  2545. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2546. .dac_nids = alc880_asus_dac_nids,
  2547. .dig_out_nid = ALC880_DIGOUT_NID,
  2548. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2549. .channel_mode = alc880_asus_modes,
  2550. .need_dac_fix = 1,
  2551. .input_mux = &alc880_capture_source,
  2552. },
  2553. [ALC880_UNIWILL_DIG] = {
  2554. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2555. .init_verbs = { alc880_volume_init_verbs,
  2556. alc880_pin_asus_init_verbs },
  2557. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2558. .dac_nids = alc880_asus_dac_nids,
  2559. .dig_out_nid = ALC880_DIGOUT_NID,
  2560. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2561. .channel_mode = alc880_asus_modes,
  2562. .need_dac_fix = 1,
  2563. .input_mux = &alc880_capture_source,
  2564. },
  2565. [ALC880_UNIWILL] = {
  2566. .mixers = { alc880_uniwill_mixer },
  2567. .init_verbs = { alc880_volume_init_verbs,
  2568. alc880_uniwill_init_verbs },
  2569. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2570. .dac_nids = alc880_asus_dac_nids,
  2571. .dig_out_nid = ALC880_DIGOUT_NID,
  2572. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2573. .channel_mode = alc880_threestack_modes,
  2574. .need_dac_fix = 1,
  2575. .input_mux = &alc880_capture_source,
  2576. .unsol_event = alc880_uniwill_unsol_event,
  2577. .init_hook = alc880_uniwill_automute,
  2578. },
  2579. [ALC880_UNIWILL_P53] = {
  2580. .mixers = { alc880_uniwill_p53_mixer },
  2581. .init_verbs = { alc880_volume_init_verbs,
  2582. alc880_uniwill_p53_init_verbs },
  2583. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2584. .dac_nids = alc880_asus_dac_nids,
  2585. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2586. .channel_mode = alc880_threestack_modes,
  2587. .input_mux = &alc880_capture_source,
  2588. .unsol_event = alc880_uniwill_p53_unsol_event,
  2589. .init_hook = alc880_uniwill_p53_hp_automute,
  2590. },
  2591. [ALC880_FUJITSU] = {
  2592. .mixers = { alc880_fujitsu_mixer,
  2593. alc880_pcbeep_mixer, },
  2594. .init_verbs = { alc880_volume_init_verbs,
  2595. alc880_uniwill_p53_init_verbs,
  2596. alc880_beep_init_verbs },
  2597. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2598. .dac_nids = alc880_dac_nids,
  2599. .dig_out_nid = ALC880_DIGOUT_NID,
  2600. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2601. .channel_mode = alc880_2_jack_modes,
  2602. .input_mux = &alc880_capture_source,
  2603. .unsol_event = alc880_uniwill_p53_unsol_event,
  2604. .init_hook = alc880_uniwill_p53_hp_automute,
  2605. },
  2606. [ALC880_CLEVO] = {
  2607. .mixers = { alc880_three_stack_mixer },
  2608. .init_verbs = { alc880_volume_init_verbs,
  2609. alc880_pin_clevo_init_verbs },
  2610. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2611. .dac_nids = alc880_dac_nids,
  2612. .hp_nid = 0x03,
  2613. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2614. .channel_mode = alc880_threestack_modes,
  2615. .need_dac_fix = 1,
  2616. .input_mux = &alc880_capture_source,
  2617. },
  2618. [ALC880_LG] = {
  2619. .mixers = { alc880_lg_mixer },
  2620. .init_verbs = { alc880_volume_init_verbs,
  2621. alc880_lg_init_verbs },
  2622. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2623. .dac_nids = alc880_lg_dac_nids,
  2624. .dig_out_nid = ALC880_DIGOUT_NID,
  2625. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2626. .channel_mode = alc880_lg_ch_modes,
  2627. .need_dac_fix = 1,
  2628. .input_mux = &alc880_lg_capture_source,
  2629. .unsol_event = alc880_lg_unsol_event,
  2630. .init_hook = alc880_lg_automute,
  2631. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2632. .loopbacks = alc880_lg_loopbacks,
  2633. #endif
  2634. },
  2635. [ALC880_LG_LW] = {
  2636. .mixers = { alc880_lg_lw_mixer },
  2637. .init_verbs = { alc880_volume_init_verbs,
  2638. alc880_lg_lw_init_verbs },
  2639. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2640. .dac_nids = alc880_dac_nids,
  2641. .dig_out_nid = ALC880_DIGOUT_NID,
  2642. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2643. .channel_mode = alc880_lg_lw_modes,
  2644. .input_mux = &alc880_lg_lw_capture_source,
  2645. .unsol_event = alc880_lg_lw_unsol_event,
  2646. .init_hook = alc880_lg_lw_automute,
  2647. },
  2648. #ifdef CONFIG_SND_DEBUG
  2649. [ALC880_TEST] = {
  2650. .mixers = { alc880_test_mixer },
  2651. .init_verbs = { alc880_test_init_verbs },
  2652. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2653. .dac_nids = alc880_test_dac_nids,
  2654. .dig_out_nid = ALC880_DIGOUT_NID,
  2655. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2656. .channel_mode = alc880_test_modes,
  2657. .input_mux = &alc880_test_capture_source,
  2658. },
  2659. #endif
  2660. };
  2661. /*
  2662. * Automatic parse of I/O pins from the BIOS configuration
  2663. */
  2664. #define NUM_CONTROL_ALLOC 32
  2665. #define NUM_VERB_ALLOC 32
  2666. enum {
  2667. ALC_CTL_WIDGET_VOL,
  2668. ALC_CTL_WIDGET_MUTE,
  2669. ALC_CTL_BIND_MUTE,
  2670. };
  2671. static struct snd_kcontrol_new alc880_control_templates[] = {
  2672. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2673. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2674. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2675. };
  2676. /* add dynamic controls */
  2677. static int add_control(struct alc_spec *spec, int type, const char *name,
  2678. unsigned long val)
  2679. {
  2680. struct snd_kcontrol_new *knew;
  2681. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2682. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2683. /* array + terminator */
  2684. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2685. if (!knew)
  2686. return -ENOMEM;
  2687. if (spec->kctl_alloc) {
  2688. memcpy(knew, spec->kctl_alloc,
  2689. sizeof(*knew) * spec->num_kctl_alloc);
  2690. kfree(spec->kctl_alloc);
  2691. }
  2692. spec->kctl_alloc = knew;
  2693. spec->num_kctl_alloc = num;
  2694. }
  2695. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2696. *knew = alc880_control_templates[type];
  2697. knew->name = kstrdup(name, GFP_KERNEL);
  2698. if (!knew->name)
  2699. return -ENOMEM;
  2700. knew->private_value = val;
  2701. spec->num_kctl_used++;
  2702. return 0;
  2703. }
  2704. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2705. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2706. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2707. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2708. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2709. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2710. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2711. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2712. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2713. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2714. #define ALC880_PIN_CD_NID 0x1c
  2715. /* fill in the dac_nids table from the parsed pin configuration */
  2716. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2717. const struct auto_pin_cfg *cfg)
  2718. {
  2719. hda_nid_t nid;
  2720. int assigned[4];
  2721. int i, j;
  2722. memset(assigned, 0, sizeof(assigned));
  2723. spec->multiout.dac_nids = spec->private_dac_nids;
  2724. /* check the pins hardwired to audio widget */
  2725. for (i = 0; i < cfg->line_outs; i++) {
  2726. nid = cfg->line_out_pins[i];
  2727. if (alc880_is_fixed_pin(nid)) {
  2728. int idx = alc880_fixed_pin_idx(nid);
  2729. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2730. assigned[idx] = 1;
  2731. }
  2732. }
  2733. /* left pins can be connect to any audio widget */
  2734. for (i = 0; i < cfg->line_outs; i++) {
  2735. nid = cfg->line_out_pins[i];
  2736. if (alc880_is_fixed_pin(nid))
  2737. continue;
  2738. /* search for an empty channel */
  2739. for (j = 0; j < cfg->line_outs; j++) {
  2740. if (!assigned[j]) {
  2741. spec->multiout.dac_nids[i] =
  2742. alc880_idx_to_dac(j);
  2743. assigned[j] = 1;
  2744. break;
  2745. }
  2746. }
  2747. }
  2748. spec->multiout.num_dacs = cfg->line_outs;
  2749. return 0;
  2750. }
  2751. /* add playback controls from the parsed DAC table */
  2752. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2753. const struct auto_pin_cfg *cfg)
  2754. {
  2755. char name[32];
  2756. static const char *chname[4] = {
  2757. "Front", "Surround", NULL /*CLFE*/, "Side"
  2758. };
  2759. hda_nid_t nid;
  2760. int i, err;
  2761. for (i = 0; i < cfg->line_outs; i++) {
  2762. if (!spec->multiout.dac_nids[i])
  2763. continue;
  2764. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2765. if (i == 2) {
  2766. /* Center/LFE */
  2767. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2768. "Center Playback Volume",
  2769. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2770. HDA_OUTPUT));
  2771. if (err < 0)
  2772. return err;
  2773. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2774. "LFE Playback Volume",
  2775. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2776. HDA_OUTPUT));
  2777. if (err < 0)
  2778. return err;
  2779. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2780. "Center Playback Switch",
  2781. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2782. HDA_INPUT));
  2783. if (err < 0)
  2784. return err;
  2785. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2786. "LFE Playback Switch",
  2787. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2788. HDA_INPUT));
  2789. if (err < 0)
  2790. return err;
  2791. } else {
  2792. sprintf(name, "%s Playback Volume", chname[i]);
  2793. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2794. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2795. HDA_OUTPUT));
  2796. if (err < 0)
  2797. return err;
  2798. sprintf(name, "%s Playback Switch", chname[i]);
  2799. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2800. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2801. HDA_INPUT));
  2802. if (err < 0)
  2803. return err;
  2804. }
  2805. }
  2806. return 0;
  2807. }
  2808. /* add playback controls for speaker and HP outputs */
  2809. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2810. const char *pfx)
  2811. {
  2812. hda_nid_t nid;
  2813. int err;
  2814. char name[32];
  2815. if (!pin)
  2816. return 0;
  2817. if (alc880_is_fixed_pin(pin)) {
  2818. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2819. /* specify the DAC as the extra output */
  2820. if (!spec->multiout.hp_nid)
  2821. spec->multiout.hp_nid = nid;
  2822. else
  2823. spec->multiout.extra_out_nid[0] = nid;
  2824. /* control HP volume/switch on the output mixer amp */
  2825. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2826. sprintf(name, "%s Playback Volume", pfx);
  2827. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2828. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2829. if (err < 0)
  2830. return err;
  2831. sprintf(name, "%s Playback Switch", pfx);
  2832. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2833. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2834. if (err < 0)
  2835. return err;
  2836. } else if (alc880_is_multi_pin(pin)) {
  2837. /* set manual connection */
  2838. /* we have only a switch on HP-out PIN */
  2839. sprintf(name, "%s Playback Switch", pfx);
  2840. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2841. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2842. if (err < 0)
  2843. return err;
  2844. }
  2845. return 0;
  2846. }
  2847. /* create input playback/capture controls for the given pin */
  2848. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2849. const char *ctlname,
  2850. int idx, hda_nid_t mix_nid)
  2851. {
  2852. char name[32];
  2853. int err;
  2854. sprintf(name, "%s Playback Volume", ctlname);
  2855. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2856. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2857. if (err < 0)
  2858. return err;
  2859. sprintf(name, "%s Playback Switch", ctlname);
  2860. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2861. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2862. if (err < 0)
  2863. return err;
  2864. return 0;
  2865. }
  2866. /* create playback/capture controls for input pins */
  2867. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2868. const struct auto_pin_cfg *cfg)
  2869. {
  2870. struct hda_input_mux *imux = &spec->private_imux;
  2871. int i, err, idx;
  2872. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2873. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2874. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2875. err = new_analog_input(spec, cfg->input_pins[i],
  2876. auto_pin_cfg_labels[i],
  2877. idx, 0x0b);
  2878. if (err < 0)
  2879. return err;
  2880. imux->items[imux->num_items].label =
  2881. auto_pin_cfg_labels[i];
  2882. imux->items[imux->num_items].index =
  2883. alc880_input_pin_idx(cfg->input_pins[i]);
  2884. imux->num_items++;
  2885. }
  2886. }
  2887. return 0;
  2888. }
  2889. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2890. hda_nid_t nid, int pin_type,
  2891. int dac_idx)
  2892. {
  2893. /* set as output */
  2894. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2895. pin_type);
  2896. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2897. AMP_OUT_UNMUTE);
  2898. /* need the manual connection? */
  2899. if (alc880_is_multi_pin(nid)) {
  2900. struct alc_spec *spec = codec->spec;
  2901. int idx = alc880_multi_pin_idx(nid);
  2902. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2903. AC_VERB_SET_CONNECT_SEL,
  2904. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2905. }
  2906. }
  2907. static int get_pin_type(int line_out_type)
  2908. {
  2909. if (line_out_type == AUTO_PIN_HP_OUT)
  2910. return PIN_HP;
  2911. else
  2912. return PIN_OUT;
  2913. }
  2914. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2915. {
  2916. struct alc_spec *spec = codec->spec;
  2917. int i;
  2918. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2919. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2920. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2921. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2922. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2923. }
  2924. }
  2925. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2926. {
  2927. struct alc_spec *spec = codec->spec;
  2928. hda_nid_t pin;
  2929. pin = spec->autocfg.speaker_pins[0];
  2930. if (pin) /* connect to front */
  2931. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2932. pin = spec->autocfg.hp_pins[0];
  2933. if (pin) /* connect to front */
  2934. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2935. }
  2936. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2937. {
  2938. struct alc_spec *spec = codec->spec;
  2939. int i;
  2940. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2941. hda_nid_t nid = spec->autocfg.input_pins[i];
  2942. if (alc880_is_input_pin(nid)) {
  2943. snd_hda_codec_write(codec, nid, 0,
  2944. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2945. i <= AUTO_PIN_FRONT_MIC ?
  2946. PIN_VREF80 : PIN_IN);
  2947. if (nid != ALC880_PIN_CD_NID)
  2948. snd_hda_codec_write(codec, nid, 0,
  2949. AC_VERB_SET_AMP_GAIN_MUTE,
  2950. AMP_OUT_MUTE);
  2951. }
  2952. }
  2953. }
  2954. /* parse the BIOS configuration and set up the alc_spec */
  2955. /* return 1 if successful, 0 if the proper config is not found,
  2956. * or a negative error code
  2957. */
  2958. static int alc880_parse_auto_config(struct hda_codec *codec)
  2959. {
  2960. struct alc_spec *spec = codec->spec;
  2961. int err;
  2962. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2963. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2964. alc880_ignore);
  2965. if (err < 0)
  2966. return err;
  2967. if (!spec->autocfg.line_outs)
  2968. return 0; /* can't find valid BIOS pin config */
  2969. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2970. if (err < 0)
  2971. return err;
  2972. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2973. if (err < 0)
  2974. return err;
  2975. err = alc880_auto_create_extra_out(spec,
  2976. spec->autocfg.speaker_pins[0],
  2977. "Speaker");
  2978. if (err < 0)
  2979. return err;
  2980. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2981. "Headphone");
  2982. if (err < 0)
  2983. return err;
  2984. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2985. if (err < 0)
  2986. return err;
  2987. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2988. if (spec->autocfg.dig_out_pin)
  2989. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2990. if (spec->autocfg.dig_in_pin)
  2991. spec->dig_in_nid = ALC880_DIGIN_NID;
  2992. if (spec->kctl_alloc)
  2993. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2994. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2995. spec->num_mux_defs = 1;
  2996. spec->input_mux = &spec->private_imux;
  2997. return 1;
  2998. }
  2999. /* additional initialization for auto-configuration model */
  3000. static void alc880_auto_init(struct hda_codec *codec)
  3001. {
  3002. alc880_auto_init_multi_out(codec);
  3003. alc880_auto_init_extra_out(codec);
  3004. alc880_auto_init_analog_input(codec);
  3005. }
  3006. /*
  3007. * OK, here we have finally the patch for ALC880
  3008. */
  3009. static int patch_alc880(struct hda_codec *codec)
  3010. {
  3011. struct alc_spec *spec;
  3012. int board_config;
  3013. int err;
  3014. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3015. if (spec == NULL)
  3016. return -ENOMEM;
  3017. codec->spec = spec;
  3018. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3019. alc880_models,
  3020. alc880_cfg_tbl);
  3021. if (board_config < 0) {
  3022. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3023. "trying auto-probe from BIOS...\n");
  3024. board_config = ALC880_AUTO;
  3025. }
  3026. if (board_config == ALC880_AUTO) {
  3027. /* automatic parse from the BIOS config */
  3028. err = alc880_parse_auto_config(codec);
  3029. if (err < 0) {
  3030. alc_free(codec);
  3031. return err;
  3032. } else if (!err) {
  3033. printk(KERN_INFO
  3034. "hda_codec: Cannot set up configuration "
  3035. "from BIOS. Using 3-stack mode...\n");
  3036. board_config = ALC880_3ST;
  3037. }
  3038. }
  3039. if (board_config != ALC880_AUTO)
  3040. setup_preset(spec, &alc880_presets[board_config]);
  3041. spec->stream_name_analog = "ALC880 Analog";
  3042. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3043. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3044. spec->stream_name_digital = "ALC880 Digital";
  3045. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3046. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3047. if (!spec->adc_nids && spec->input_mux) {
  3048. /* check whether NID 0x07 is valid */
  3049. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3050. /* get type */
  3051. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3052. if (wcap != AC_WID_AUD_IN) {
  3053. spec->adc_nids = alc880_adc_nids_alt;
  3054. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3055. spec->mixers[spec->num_mixers] =
  3056. alc880_capture_alt_mixer;
  3057. spec->num_mixers++;
  3058. } else {
  3059. spec->adc_nids = alc880_adc_nids;
  3060. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3061. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3062. spec->num_mixers++;
  3063. }
  3064. }
  3065. codec->patch_ops = alc_patch_ops;
  3066. if (board_config == ALC880_AUTO)
  3067. spec->init_hook = alc880_auto_init;
  3068. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3069. if (!spec->loopback.amplist)
  3070. spec->loopback.amplist = alc880_loopbacks;
  3071. #endif
  3072. return 0;
  3073. }
  3074. /*
  3075. * ALC260 support
  3076. */
  3077. static hda_nid_t alc260_dac_nids[1] = {
  3078. /* front */
  3079. 0x02,
  3080. };
  3081. static hda_nid_t alc260_adc_nids[1] = {
  3082. /* ADC0 */
  3083. 0x04,
  3084. };
  3085. static hda_nid_t alc260_adc_nids_alt[1] = {
  3086. /* ADC1 */
  3087. 0x05,
  3088. };
  3089. static hda_nid_t alc260_hp_adc_nids[2] = {
  3090. /* ADC1, 0 */
  3091. 0x05, 0x04
  3092. };
  3093. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3094. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3095. */
  3096. static hda_nid_t alc260_dual_adc_nids[2] = {
  3097. /* ADC0, ADC1 */
  3098. 0x04, 0x05
  3099. };
  3100. #define ALC260_DIGOUT_NID 0x03
  3101. #define ALC260_DIGIN_NID 0x06
  3102. static struct hda_input_mux alc260_capture_source = {
  3103. .num_items = 4,
  3104. .items = {
  3105. { "Mic", 0x0 },
  3106. { "Front Mic", 0x1 },
  3107. { "Line", 0x2 },
  3108. { "CD", 0x4 },
  3109. },
  3110. };
  3111. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3112. * headphone jack and the internal CD lines since these are the only pins at
  3113. * which audio can appear. For flexibility, also allow the option of
  3114. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3115. * connection to the mixer output).
  3116. */
  3117. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3118. {
  3119. .num_items = 3,
  3120. .items = {
  3121. { "Mic/Line", 0x0 },
  3122. { "CD", 0x4 },
  3123. { "Headphone", 0x2 },
  3124. },
  3125. },
  3126. {
  3127. .num_items = 4,
  3128. .items = {
  3129. { "Mic/Line", 0x0 },
  3130. { "CD", 0x4 },
  3131. { "Headphone", 0x2 },
  3132. { "Mixer", 0x5 },
  3133. },
  3134. },
  3135. };
  3136. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3137. * the Fujitsu S702x, but jacks are marked differently.
  3138. */
  3139. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3140. {
  3141. .num_items = 4,
  3142. .items = {
  3143. { "Mic", 0x0 },
  3144. { "Line", 0x2 },
  3145. { "CD", 0x4 },
  3146. { "Headphone", 0x5 },
  3147. },
  3148. },
  3149. {
  3150. .num_items = 5,
  3151. .items = {
  3152. { "Mic", 0x0 },
  3153. { "Line", 0x2 },
  3154. { "CD", 0x4 },
  3155. { "Headphone", 0x6 },
  3156. { "Mixer", 0x5 },
  3157. },
  3158. },
  3159. };
  3160. /*
  3161. * This is just place-holder, so there's something for alc_build_pcms to look
  3162. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3163. * element which allows changing the channel mode, so the verb list is
  3164. * never used.
  3165. */
  3166. static struct hda_channel_mode alc260_modes[1] = {
  3167. { 2, NULL },
  3168. };
  3169. /* Mixer combinations
  3170. *
  3171. * basic: base_output + input + pc_beep + capture
  3172. * HP: base_output + input + capture_alt
  3173. * HP_3013: hp_3013 + input + capture
  3174. * fujitsu: fujitsu + capture
  3175. * acer: acer + capture
  3176. */
  3177. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3178. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3179. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3180. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3181. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3182. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3183. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3184. { } /* end */
  3185. };
  3186. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3187. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3188. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3189. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3190. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3191. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3192. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3193. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3194. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3195. { } /* end */
  3196. };
  3197. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3198. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3199. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3200. { } /* end */
  3201. };
  3202. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3203. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3204. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3205. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3206. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3207. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3208. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3209. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3210. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3211. { } /* end */
  3212. };
  3213. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3214. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3215. */
  3216. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3217. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3218. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3219. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3220. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3221. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3222. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3223. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3224. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3225. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3226. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3227. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3228. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3229. { } /* end */
  3230. };
  3231. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3232. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3233. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3234. * datasheet doesn't mention this restriction. At this stage it's not clear
  3235. * whether this behaviour is intentional or is a hardware bug in chip
  3236. * revisions available in early 2006. Therefore for now allow the
  3237. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3238. * that the lack of mic bias for this NID is intentional we could change the
  3239. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3240. *
  3241. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3242. * don't appear to make the mic bias available from the "line" jack, even
  3243. * though the NID used for this jack (0x14) can supply it. The theory is
  3244. * that perhaps Acer have included blocking capacitors between the ALC260
  3245. * and the output jack. If this turns out to be the case for all such
  3246. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3247. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3248. *
  3249. * The C20x Tablet series have a mono internal speaker which is controlled
  3250. * via the chip's Mono sum widget and pin complex, so include the necessary
  3251. * controls for such models. On models without a "mono speaker" the control
  3252. * won't do anything.
  3253. */
  3254. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3255. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3256. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3257. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3258. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3259. HDA_OUTPUT),
  3260. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3261. HDA_INPUT),
  3262. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3263. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3264. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3265. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3266. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3267. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3268. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3269. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3270. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3271. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3272. { } /* end */
  3273. };
  3274. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3275. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3276. */
  3277. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3278. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3279. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3280. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3281. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3282. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3283. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3284. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3285. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3286. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3287. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3288. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3289. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3290. { } /* end */
  3291. };
  3292. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3293. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3294. */
  3295. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3296. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3297. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3298. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3299. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3300. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3301. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3302. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3303. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3304. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3305. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3306. { } /* end */
  3307. };
  3308. /* capture mixer elements */
  3309. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3310. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3311. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3312. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3313. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3314. {
  3315. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3316. /* The multiple "Capture Source" controls confuse alsamixer
  3317. * So call somewhat different..
  3318. * FIXME: the controls appear in the "playback" view!
  3319. */
  3320. /* .name = "Capture Source", */
  3321. .name = "Input Source",
  3322. .count = 2,
  3323. .info = alc_mux_enum_info,
  3324. .get = alc_mux_enum_get,
  3325. .put = alc_mux_enum_put,
  3326. },
  3327. { } /* end */
  3328. };
  3329. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3330. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3331. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3332. {
  3333. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3334. /* The multiple "Capture Source" controls confuse alsamixer
  3335. * So call somewhat different..
  3336. * FIXME: the controls appear in the "playback" view!
  3337. */
  3338. /* .name = "Capture Source", */
  3339. .name = "Input Source",
  3340. .count = 1,
  3341. .info = alc_mux_enum_info,
  3342. .get = alc_mux_enum_get,
  3343. .put = alc_mux_enum_put,
  3344. },
  3345. { } /* end */
  3346. };
  3347. /*
  3348. * initialization verbs
  3349. */
  3350. static struct hda_verb alc260_init_verbs[] = {
  3351. /* Line In pin widget for input */
  3352. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3353. /* CD pin widget for input */
  3354. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3355. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3356. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3357. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3358. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3359. /* LINE-2 is used for line-out in rear */
  3360. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3361. /* select line-out */
  3362. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3363. /* LINE-OUT pin */
  3364. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3365. /* enable HP */
  3366. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3367. /* enable Mono */
  3368. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3369. /* mute capture amp left and right */
  3370. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3371. /* set connection select to line in (default select for this ADC) */
  3372. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3373. /* mute capture amp left and right */
  3374. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3375. /* set connection select to line in (default select for this ADC) */
  3376. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3377. /* set vol=0 Line-Out mixer amp left and right */
  3378. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3379. /* unmute pin widget amp left and right (no gain on this amp) */
  3380. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3381. /* set vol=0 HP mixer amp left and right */
  3382. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3383. /* unmute pin widget amp left and right (no gain on this amp) */
  3384. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3385. /* set vol=0 Mono mixer amp left and right */
  3386. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3387. /* unmute pin widget amp left and right (no gain on this amp) */
  3388. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3389. /* unmute LINE-2 out pin */
  3390. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3391. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3392. * Line In 2 = 0x03
  3393. */
  3394. /* mute analog inputs */
  3395. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3397. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3398. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3399. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3400. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3401. /* mute Front out path */
  3402. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3403. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3404. /* mute Headphone out path */
  3405. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3406. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3407. /* mute Mono out path */
  3408. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3409. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3410. { }
  3411. };
  3412. #if 0 /* should be identical with alc260_init_verbs? */
  3413. static struct hda_verb alc260_hp_init_verbs[] = {
  3414. /* Headphone and output */
  3415. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3416. /* mono output */
  3417. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3418. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3419. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3420. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3421. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3422. /* Line In pin widget for input */
  3423. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3424. /* Line-2 pin widget for output */
  3425. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3426. /* CD pin widget for input */
  3427. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3428. /* unmute amp left and right */
  3429. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3430. /* set connection select to line in (default select for this ADC) */
  3431. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3432. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3433. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3434. /* mute pin widget amp left and right (no gain on this amp) */
  3435. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3436. /* unmute HP mixer amp left and right (volume = 0) */
  3437. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3438. /* mute pin widget amp left and right (no gain on this amp) */
  3439. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3440. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3441. * Line In 2 = 0x03
  3442. */
  3443. /* mute analog inputs */
  3444. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3445. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3446. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3447. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3448. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3449. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3450. /* Unmute Front out path */
  3451. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3452. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3453. /* Unmute Headphone out path */
  3454. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3455. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3456. /* Unmute Mono out path */
  3457. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3458. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3459. { }
  3460. };
  3461. #endif
  3462. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3463. /* Line out and output */
  3464. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3465. /* mono output */
  3466. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3467. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3468. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3469. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3470. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3471. /* Line In pin widget for input */
  3472. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3473. /* Headphone pin widget for output */
  3474. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3475. /* CD pin widget for input */
  3476. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3477. /* unmute amp left and right */
  3478. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3479. /* set connection select to line in (default select for this ADC) */
  3480. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3481. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3482. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3483. /* mute pin widget amp left and right (no gain on this amp) */
  3484. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3485. /* unmute HP mixer amp left and right (volume = 0) */
  3486. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3487. /* mute pin widget amp left and right (no gain on this amp) */
  3488. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3489. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3490. * Line In 2 = 0x03
  3491. */
  3492. /* mute analog inputs */
  3493. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3494. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3495. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3496. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3497. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3498. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3499. /* Unmute Front out path */
  3500. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3501. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3502. /* Unmute Headphone out path */
  3503. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3504. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3505. /* Unmute Mono out path */
  3506. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3507. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3508. { }
  3509. };
  3510. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3511. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3512. * audio = 0x16, internal speaker = 0x10.
  3513. */
  3514. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3515. /* Disable all GPIOs */
  3516. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3517. /* Internal speaker is connected to headphone pin */
  3518. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3519. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3520. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3521. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3522. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3523. /* Ensure all other unused pins are disabled and muted. */
  3524. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3525. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3526. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3527. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3528. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3529. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3530. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3531. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3532. /* Disable digital (SPDIF) pins */
  3533. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3534. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3535. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3536. * when acting as an output.
  3537. */
  3538. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3539. /* Start with output sum widgets muted and their output gains at min */
  3540. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3541. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3542. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3543. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3544. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3545. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3546. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3547. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3548. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3549. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3550. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3551. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3552. * If the pin mode is changed by the user the pin mode control will
  3553. * take care of enabling the pin's input/output buffers as needed.
  3554. * Therefore there's no need to enable the input buffer at this
  3555. * stage.
  3556. */
  3557. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3558. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3559. * mixer ctrl)
  3560. */
  3561. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3562. /* Mute capture amp left and right */
  3563. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3564. /* Set ADC connection select to match default mixer setting - line
  3565. * in (on mic1 pin)
  3566. */
  3567. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3568. /* Do the same for the second ADC: mute capture input amp and
  3569. * set ADC connection to line in (on mic1 pin)
  3570. */
  3571. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3572. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3573. /* Mute all inputs to mixer widget (even unconnected ones) */
  3574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3575. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3576. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3578. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3579. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3580. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3581. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3582. { }
  3583. };
  3584. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3585. * similar laptops (adapted from Fujitsu init verbs).
  3586. */
  3587. static struct hda_verb alc260_acer_init_verbs[] = {
  3588. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3589. * the headphone jack. Turn this on and rely on the standard mute
  3590. * methods whenever the user wants to turn these outputs off.
  3591. */
  3592. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3593. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3594. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3595. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3596. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3597. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3598. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3599. /* Line In jack is connected to Line1 pin */
  3600. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3601. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3602. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3603. /* Ensure all other unused pins are disabled and muted. */
  3604. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3605. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3606. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3607. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3608. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3609. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3610. /* Disable digital (SPDIF) pins */
  3611. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3612. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3613. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3614. * bus when acting as outputs.
  3615. */
  3616. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3617. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3618. /* Start with output sum widgets muted and their output gains at min */
  3619. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3620. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3621. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3622. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3623. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3624. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3625. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3626. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3627. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3628. /* Unmute Line-out pin widget amp left and right
  3629. * (no equiv mixer ctrl)
  3630. */
  3631. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3632. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3633. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3634. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3635. * inputs. If the pin mode is changed by the user the pin mode control
  3636. * will take care of enabling the pin's input/output buffers as needed.
  3637. * Therefore there's no need to enable the input buffer at this
  3638. * stage.
  3639. */
  3640. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3641. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3642. /* Mute capture amp left and right */
  3643. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3644. /* Set ADC connection select to match default mixer setting - mic
  3645. * (on mic1 pin)
  3646. */
  3647. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3648. /* Do similar with the second ADC: mute capture input amp and
  3649. * set ADC connection to mic to match ALSA's default state.
  3650. */
  3651. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3652. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3653. /* Mute all inputs to mixer widget (even unconnected ones) */
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3658. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3659. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3660. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3661. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3662. { }
  3663. };
  3664. static struct hda_verb alc260_will_verbs[] = {
  3665. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3666. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3667. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3668. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3669. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3670. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3671. {}
  3672. };
  3673. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3674. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3675. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3676. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3677. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3678. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3679. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3680. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3681. {}
  3682. };
  3683. /* toggle speaker-output according to the hp-jack state */
  3684. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3685. {
  3686. unsigned int present;
  3687. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3688. present = snd_hda_codec_read(codec, 0x0f, 0,
  3689. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3690. if (present) {
  3691. snd_hda_codec_write_cache(codec, 0x01, 0,
  3692. AC_VERB_SET_GPIO_DATA, 1);
  3693. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3694. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3695. PIN_HP);
  3696. } else {
  3697. snd_hda_codec_write_cache(codec, 0x01, 0,
  3698. AC_VERB_SET_GPIO_DATA, 0);
  3699. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3700. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3701. PIN_OUT);
  3702. }
  3703. }
  3704. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3705. unsigned int res)
  3706. {
  3707. if ((res >> 26) == ALC880_HP_EVENT)
  3708. alc260_replacer_672v_automute(codec);
  3709. }
  3710. /* Test configuration for debugging, modelled after the ALC880 test
  3711. * configuration.
  3712. */
  3713. #ifdef CONFIG_SND_DEBUG
  3714. static hda_nid_t alc260_test_dac_nids[1] = {
  3715. 0x02,
  3716. };
  3717. static hda_nid_t alc260_test_adc_nids[2] = {
  3718. 0x04, 0x05,
  3719. };
  3720. /* For testing the ALC260, each input MUX needs its own definition since
  3721. * the signal assignments are different. This assumes that the first ADC
  3722. * is NID 0x04.
  3723. */
  3724. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3725. {
  3726. .num_items = 7,
  3727. .items = {
  3728. { "MIC1 pin", 0x0 },
  3729. { "MIC2 pin", 0x1 },
  3730. { "LINE1 pin", 0x2 },
  3731. { "LINE2 pin", 0x3 },
  3732. { "CD pin", 0x4 },
  3733. { "LINE-OUT pin", 0x5 },
  3734. { "HP-OUT pin", 0x6 },
  3735. },
  3736. },
  3737. {
  3738. .num_items = 8,
  3739. .items = {
  3740. { "MIC1 pin", 0x0 },
  3741. { "MIC2 pin", 0x1 },
  3742. { "LINE1 pin", 0x2 },
  3743. { "LINE2 pin", 0x3 },
  3744. { "CD pin", 0x4 },
  3745. { "Mixer", 0x5 },
  3746. { "LINE-OUT pin", 0x6 },
  3747. { "HP-OUT pin", 0x7 },
  3748. },
  3749. },
  3750. };
  3751. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3752. /* Output driver widgets */
  3753. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3754. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3755. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3756. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3757. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3758. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3759. /* Modes for retasking pin widgets
  3760. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3761. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3762. * mention this restriction. At this stage it's not clear whether
  3763. * this behaviour is intentional or is a hardware bug in chip
  3764. * revisions available at least up until early 2006. Therefore for
  3765. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3766. * choices, but if it turns out that the lack of mic bias for these
  3767. * NIDs is intentional we could change their modes from
  3768. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3769. */
  3770. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3771. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3772. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3773. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3774. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3775. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3776. /* Loopback mixer controls */
  3777. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3778. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3779. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3780. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3781. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3782. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3783. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3784. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3785. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3786. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3787. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3788. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3789. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3790. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3791. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3792. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3793. /* Controls for GPIO pins, assuming they are configured as outputs */
  3794. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3795. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3796. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3797. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3798. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3799. * is ambigious as to which NID is which; testing on laptops which
  3800. * make this output available should provide clarification.
  3801. */
  3802. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3803. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3804. { } /* end */
  3805. };
  3806. static struct hda_verb alc260_test_init_verbs[] = {
  3807. /* Enable all GPIOs as outputs with an initial value of 0 */
  3808. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3809. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3810. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3811. /* Enable retasking pins as output, initially without power amp */
  3812. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3813. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3814. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3815. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3816. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3817. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3818. /* Disable digital (SPDIF) pins initially, but users can enable
  3819. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3820. * payload also sets the generation to 0, output to be in "consumer"
  3821. * PCM format, copyright asserted, no pre-emphasis and no validity
  3822. * control.
  3823. */
  3824. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3825. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3826. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3827. * OUT1 sum bus when acting as an output.
  3828. */
  3829. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3830. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3831. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3832. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3833. /* Start with output sum widgets muted and their output gains at min */
  3834. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3835. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3836. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3837. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3838. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3839. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3840. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3841. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3842. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3843. /* Unmute retasking pin widget output buffers since the default
  3844. * state appears to be output. As the pin mode is changed by the
  3845. * user the pin mode control will take care of enabling the pin's
  3846. * input/output buffers as needed.
  3847. */
  3848. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3849. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3850. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3851. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3852. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3853. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3854. /* Also unmute the mono-out pin widget */
  3855. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3856. /* Mute capture amp left and right */
  3857. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3858. /* Set ADC connection select to match default mixer setting (mic1
  3859. * pin)
  3860. */
  3861. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3862. /* Do the same for the second ADC: mute capture input amp and
  3863. * set ADC connection to mic1 pin
  3864. */
  3865. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3866. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3867. /* Mute all inputs to mixer widget (even unconnected ones) */
  3868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3871. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3872. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3873. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3874. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3875. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3876. { }
  3877. };
  3878. #endif
  3879. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3880. .substreams = 1,
  3881. .channels_min = 2,
  3882. .channels_max = 2,
  3883. };
  3884. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3885. .substreams = 1,
  3886. .channels_min = 2,
  3887. .channels_max = 2,
  3888. };
  3889. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3890. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3891. /*
  3892. * for BIOS auto-configuration
  3893. */
  3894. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3895. const char *pfx)
  3896. {
  3897. hda_nid_t nid_vol;
  3898. unsigned long vol_val, sw_val;
  3899. char name[32];
  3900. int err;
  3901. if (nid >= 0x0f && nid < 0x11) {
  3902. nid_vol = nid - 0x7;
  3903. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3904. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3905. } else if (nid == 0x11) {
  3906. nid_vol = nid - 0x7;
  3907. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3908. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3909. } else if (nid >= 0x12 && nid <= 0x15) {
  3910. nid_vol = 0x08;
  3911. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3912. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3913. } else
  3914. return 0; /* N/A */
  3915. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3916. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3917. if (err < 0)
  3918. return err;
  3919. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3920. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3921. if (err < 0)
  3922. return err;
  3923. return 1;
  3924. }
  3925. /* add playback controls from the parsed DAC table */
  3926. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3927. const struct auto_pin_cfg *cfg)
  3928. {
  3929. hda_nid_t nid;
  3930. int err;
  3931. spec->multiout.num_dacs = 1;
  3932. spec->multiout.dac_nids = spec->private_dac_nids;
  3933. spec->multiout.dac_nids[0] = 0x02;
  3934. nid = cfg->line_out_pins[0];
  3935. if (nid) {
  3936. err = alc260_add_playback_controls(spec, nid, "Front");
  3937. if (err < 0)
  3938. return err;
  3939. }
  3940. nid = cfg->speaker_pins[0];
  3941. if (nid) {
  3942. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3943. if (err < 0)
  3944. return err;
  3945. }
  3946. nid = cfg->hp_pins[0];
  3947. if (nid) {
  3948. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3949. if (err < 0)
  3950. return err;
  3951. }
  3952. return 0;
  3953. }
  3954. /* create playback/capture controls for input pins */
  3955. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3956. const struct auto_pin_cfg *cfg)
  3957. {
  3958. struct hda_input_mux *imux = &spec->private_imux;
  3959. int i, err, idx;
  3960. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3961. if (cfg->input_pins[i] >= 0x12) {
  3962. idx = cfg->input_pins[i] - 0x12;
  3963. err = new_analog_input(spec, cfg->input_pins[i],
  3964. auto_pin_cfg_labels[i], idx,
  3965. 0x07);
  3966. if (err < 0)
  3967. return err;
  3968. imux->items[imux->num_items].label =
  3969. auto_pin_cfg_labels[i];
  3970. imux->items[imux->num_items].index = idx;
  3971. imux->num_items++;
  3972. }
  3973. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3974. idx = cfg->input_pins[i] - 0x09;
  3975. err = new_analog_input(spec, cfg->input_pins[i],
  3976. auto_pin_cfg_labels[i], idx,
  3977. 0x07);
  3978. if (err < 0)
  3979. return err;
  3980. imux->items[imux->num_items].label =
  3981. auto_pin_cfg_labels[i];
  3982. imux->items[imux->num_items].index = idx;
  3983. imux->num_items++;
  3984. }
  3985. }
  3986. return 0;
  3987. }
  3988. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3989. hda_nid_t nid, int pin_type,
  3990. int sel_idx)
  3991. {
  3992. /* set as output */
  3993. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3994. pin_type);
  3995. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3996. AMP_OUT_UNMUTE);
  3997. /* need the manual connection? */
  3998. if (nid >= 0x12) {
  3999. int idx = nid - 0x12;
  4000. snd_hda_codec_write(codec, idx + 0x0b, 0,
  4001. AC_VERB_SET_CONNECT_SEL, sel_idx);
  4002. }
  4003. }
  4004. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4005. {
  4006. struct alc_spec *spec = codec->spec;
  4007. hda_nid_t nid;
  4008. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4009. nid = spec->autocfg.line_out_pins[0];
  4010. if (nid) {
  4011. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4012. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4013. }
  4014. nid = spec->autocfg.speaker_pins[0];
  4015. if (nid)
  4016. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4017. nid = spec->autocfg.hp_pins[0];
  4018. if (nid)
  4019. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4020. }
  4021. #define ALC260_PIN_CD_NID 0x16
  4022. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4023. {
  4024. struct alc_spec *spec = codec->spec;
  4025. int i;
  4026. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4027. hda_nid_t nid = spec->autocfg.input_pins[i];
  4028. if (nid >= 0x12) {
  4029. snd_hda_codec_write(codec, nid, 0,
  4030. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4031. i <= AUTO_PIN_FRONT_MIC ?
  4032. PIN_VREF80 : PIN_IN);
  4033. if (nid != ALC260_PIN_CD_NID)
  4034. snd_hda_codec_write(codec, nid, 0,
  4035. AC_VERB_SET_AMP_GAIN_MUTE,
  4036. AMP_OUT_MUTE);
  4037. }
  4038. }
  4039. }
  4040. /*
  4041. * generic initialization of ADC, input mixers and output mixers
  4042. */
  4043. static struct hda_verb alc260_volume_init_verbs[] = {
  4044. /*
  4045. * Unmute ADC0-1 and set the default input to mic-in
  4046. */
  4047. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4048. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4049. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4050. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4051. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4052. * mixer widget
  4053. * Note: PASD motherboards uses the Line In 2 as the input for
  4054. * front panel mic (mic 2)
  4055. */
  4056. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4057. /* mute analog inputs */
  4058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4059. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4062. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4063. /*
  4064. * Set up output mixers (0x08 - 0x0a)
  4065. */
  4066. /* set vol=0 to output mixers */
  4067. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4068. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4069. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4070. /* set up input amps for analog loopback */
  4071. /* Amp Indices: DAC = 0, mixer = 1 */
  4072. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4073. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4074. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4075. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4076. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4077. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4078. { }
  4079. };
  4080. static int alc260_parse_auto_config(struct hda_codec *codec)
  4081. {
  4082. struct alc_spec *spec = codec->spec;
  4083. unsigned int wcap;
  4084. int err;
  4085. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4086. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4087. alc260_ignore);
  4088. if (err < 0)
  4089. return err;
  4090. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4091. if (err < 0)
  4092. return err;
  4093. if (!spec->kctl_alloc)
  4094. return 0; /* can't find valid BIOS pin config */
  4095. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4096. if (err < 0)
  4097. return err;
  4098. spec->multiout.max_channels = 2;
  4099. if (spec->autocfg.dig_out_pin)
  4100. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4101. if (spec->kctl_alloc)
  4102. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4103. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4104. spec->num_mux_defs = 1;
  4105. spec->input_mux = &spec->private_imux;
  4106. /* check whether NID 0x04 is valid */
  4107. wcap = get_wcaps(codec, 0x04);
  4108. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4109. if (wcap != AC_WID_AUD_IN) {
  4110. spec->adc_nids = alc260_adc_nids_alt;
  4111. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4112. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4113. } else {
  4114. spec->adc_nids = alc260_adc_nids;
  4115. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4116. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4117. }
  4118. spec->num_mixers++;
  4119. return 1;
  4120. }
  4121. /* additional initialization for auto-configuration model */
  4122. static void alc260_auto_init(struct hda_codec *codec)
  4123. {
  4124. alc260_auto_init_multi_out(codec);
  4125. alc260_auto_init_analog_input(codec);
  4126. }
  4127. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4128. static struct hda_amp_list alc260_loopbacks[] = {
  4129. { 0x07, HDA_INPUT, 0 },
  4130. { 0x07, HDA_INPUT, 1 },
  4131. { 0x07, HDA_INPUT, 2 },
  4132. { 0x07, HDA_INPUT, 3 },
  4133. { 0x07, HDA_INPUT, 4 },
  4134. { } /* end */
  4135. };
  4136. #endif
  4137. /*
  4138. * ALC260 configurations
  4139. */
  4140. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4141. [ALC260_BASIC] = "basic",
  4142. [ALC260_HP] = "hp",
  4143. [ALC260_HP_3013] = "hp-3013",
  4144. [ALC260_FUJITSU_S702X] = "fujitsu",
  4145. [ALC260_ACER] = "acer",
  4146. [ALC260_WILL] = "will",
  4147. [ALC260_REPLACER_672V] = "replacer",
  4148. #ifdef CONFIG_SND_DEBUG
  4149. [ALC260_TEST] = "test",
  4150. #endif
  4151. [ALC260_AUTO] = "auto",
  4152. };
  4153. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4154. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4155. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4156. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4157. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4158. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4159. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4160. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4161. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4162. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4163. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4164. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4165. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4166. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4167. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4168. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4169. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4170. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4171. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4172. {}
  4173. };
  4174. static struct alc_config_preset alc260_presets[] = {
  4175. [ALC260_BASIC] = {
  4176. .mixers = { alc260_base_output_mixer,
  4177. alc260_input_mixer,
  4178. alc260_pc_beep_mixer,
  4179. alc260_capture_mixer },
  4180. .init_verbs = { alc260_init_verbs },
  4181. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4182. .dac_nids = alc260_dac_nids,
  4183. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4184. .adc_nids = alc260_adc_nids,
  4185. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4186. .channel_mode = alc260_modes,
  4187. .input_mux = &alc260_capture_source,
  4188. },
  4189. [ALC260_HP] = {
  4190. .mixers = { alc260_base_output_mixer,
  4191. alc260_input_mixer,
  4192. alc260_capture_alt_mixer },
  4193. .init_verbs = { alc260_init_verbs },
  4194. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4195. .dac_nids = alc260_dac_nids,
  4196. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4197. .adc_nids = alc260_hp_adc_nids,
  4198. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4199. .channel_mode = alc260_modes,
  4200. .input_mux = &alc260_capture_source,
  4201. },
  4202. [ALC260_HP_3013] = {
  4203. .mixers = { alc260_hp_3013_mixer,
  4204. alc260_input_mixer,
  4205. alc260_capture_alt_mixer },
  4206. .init_verbs = { alc260_hp_3013_init_verbs },
  4207. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4208. .dac_nids = alc260_dac_nids,
  4209. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4210. .adc_nids = alc260_hp_adc_nids,
  4211. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4212. .channel_mode = alc260_modes,
  4213. .input_mux = &alc260_capture_source,
  4214. },
  4215. [ALC260_FUJITSU_S702X] = {
  4216. .mixers = { alc260_fujitsu_mixer,
  4217. alc260_capture_mixer },
  4218. .init_verbs = { alc260_fujitsu_init_verbs },
  4219. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4220. .dac_nids = alc260_dac_nids,
  4221. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4222. .adc_nids = alc260_dual_adc_nids,
  4223. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4224. .channel_mode = alc260_modes,
  4225. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4226. .input_mux = alc260_fujitsu_capture_sources,
  4227. },
  4228. [ALC260_ACER] = {
  4229. .mixers = { alc260_acer_mixer,
  4230. alc260_capture_mixer },
  4231. .init_verbs = { alc260_acer_init_verbs },
  4232. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4233. .dac_nids = alc260_dac_nids,
  4234. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4235. .adc_nids = alc260_dual_adc_nids,
  4236. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4237. .channel_mode = alc260_modes,
  4238. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4239. .input_mux = alc260_acer_capture_sources,
  4240. },
  4241. [ALC260_WILL] = {
  4242. .mixers = { alc260_will_mixer,
  4243. alc260_capture_mixer },
  4244. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4245. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4246. .dac_nids = alc260_dac_nids,
  4247. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4248. .adc_nids = alc260_adc_nids,
  4249. .dig_out_nid = ALC260_DIGOUT_NID,
  4250. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4251. .channel_mode = alc260_modes,
  4252. .input_mux = &alc260_capture_source,
  4253. },
  4254. [ALC260_REPLACER_672V] = {
  4255. .mixers = { alc260_replacer_672v_mixer,
  4256. alc260_capture_mixer },
  4257. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4258. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4259. .dac_nids = alc260_dac_nids,
  4260. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4261. .adc_nids = alc260_adc_nids,
  4262. .dig_out_nid = ALC260_DIGOUT_NID,
  4263. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4264. .channel_mode = alc260_modes,
  4265. .input_mux = &alc260_capture_source,
  4266. .unsol_event = alc260_replacer_672v_unsol_event,
  4267. .init_hook = alc260_replacer_672v_automute,
  4268. },
  4269. #ifdef CONFIG_SND_DEBUG
  4270. [ALC260_TEST] = {
  4271. .mixers = { alc260_test_mixer,
  4272. alc260_capture_mixer },
  4273. .init_verbs = { alc260_test_init_verbs },
  4274. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4275. .dac_nids = alc260_test_dac_nids,
  4276. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4277. .adc_nids = alc260_test_adc_nids,
  4278. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4279. .channel_mode = alc260_modes,
  4280. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4281. .input_mux = alc260_test_capture_sources,
  4282. },
  4283. #endif
  4284. };
  4285. static int patch_alc260(struct hda_codec *codec)
  4286. {
  4287. struct alc_spec *spec;
  4288. int err, board_config;
  4289. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4290. if (spec == NULL)
  4291. return -ENOMEM;
  4292. codec->spec = spec;
  4293. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4294. alc260_models,
  4295. alc260_cfg_tbl);
  4296. if (board_config < 0) {
  4297. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4298. "trying auto-probe from BIOS...\n");
  4299. board_config = ALC260_AUTO;
  4300. }
  4301. if (board_config == ALC260_AUTO) {
  4302. /* automatic parse from the BIOS config */
  4303. err = alc260_parse_auto_config(codec);
  4304. if (err < 0) {
  4305. alc_free(codec);
  4306. return err;
  4307. } else if (!err) {
  4308. printk(KERN_INFO
  4309. "hda_codec: Cannot set up configuration "
  4310. "from BIOS. Using base mode...\n");
  4311. board_config = ALC260_BASIC;
  4312. }
  4313. }
  4314. if (board_config != ALC260_AUTO)
  4315. setup_preset(spec, &alc260_presets[board_config]);
  4316. spec->stream_name_analog = "ALC260 Analog";
  4317. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4318. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4319. spec->stream_name_digital = "ALC260 Digital";
  4320. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4321. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4322. codec->patch_ops = alc_patch_ops;
  4323. if (board_config == ALC260_AUTO)
  4324. spec->init_hook = alc260_auto_init;
  4325. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4326. if (!spec->loopback.amplist)
  4327. spec->loopback.amplist = alc260_loopbacks;
  4328. #endif
  4329. return 0;
  4330. }
  4331. /*
  4332. * ALC882 support
  4333. *
  4334. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4335. * configuration. Each pin widget can choose any input DACs and a mixer.
  4336. * Each ADC is connected from a mixer of all inputs. This makes possible
  4337. * 6-channel independent captures.
  4338. *
  4339. * In addition, an independent DAC for the multi-playback (not used in this
  4340. * driver yet).
  4341. */
  4342. #define ALC882_DIGOUT_NID 0x06
  4343. #define ALC882_DIGIN_NID 0x0a
  4344. static struct hda_channel_mode alc882_ch_modes[1] = {
  4345. { 8, NULL }
  4346. };
  4347. static hda_nid_t alc882_dac_nids[4] = {
  4348. /* front, rear, clfe, rear_surr */
  4349. 0x02, 0x03, 0x04, 0x05
  4350. };
  4351. /* identical with ALC880 */
  4352. #define alc882_adc_nids alc880_adc_nids
  4353. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4354. /* input MUX */
  4355. /* FIXME: should be a matrix-type input source selection */
  4356. static struct hda_input_mux alc882_capture_source = {
  4357. .num_items = 4,
  4358. .items = {
  4359. { "Mic", 0x0 },
  4360. { "Front Mic", 0x1 },
  4361. { "Line", 0x2 },
  4362. { "CD", 0x4 },
  4363. },
  4364. };
  4365. #define alc882_mux_enum_info alc_mux_enum_info
  4366. #define alc882_mux_enum_get alc_mux_enum_get
  4367. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4368. struct snd_ctl_elem_value *ucontrol)
  4369. {
  4370. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4371. struct alc_spec *spec = codec->spec;
  4372. const struct hda_input_mux *imux = spec->input_mux;
  4373. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4374. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4375. hda_nid_t nid = capture_mixers[adc_idx];
  4376. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4377. unsigned int i, idx;
  4378. idx = ucontrol->value.enumerated.item[0];
  4379. if (idx >= imux->num_items)
  4380. idx = imux->num_items - 1;
  4381. if (*cur_val == idx)
  4382. return 0;
  4383. for (i = 0; i < imux->num_items; i++) {
  4384. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4385. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4386. imux->items[i].index,
  4387. HDA_AMP_MUTE, v);
  4388. }
  4389. *cur_val = idx;
  4390. return 1;
  4391. }
  4392. /*
  4393. * 2ch mode
  4394. */
  4395. static struct hda_verb alc882_3ST_ch2_init[] = {
  4396. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4397. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4398. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4399. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4400. { } /* end */
  4401. };
  4402. /*
  4403. * 6ch mode
  4404. */
  4405. static struct hda_verb alc882_3ST_ch6_init[] = {
  4406. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4407. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4408. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4409. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4410. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4411. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4412. { } /* end */
  4413. };
  4414. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4415. { 2, alc882_3ST_ch2_init },
  4416. { 6, alc882_3ST_ch6_init },
  4417. };
  4418. /*
  4419. * 6ch mode
  4420. */
  4421. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4422. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4423. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4424. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4425. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4426. { } /* end */
  4427. };
  4428. /*
  4429. * 8ch mode
  4430. */
  4431. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4432. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4433. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4434. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4435. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4436. { } /* end */
  4437. };
  4438. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4439. { 6, alc882_sixstack_ch6_init },
  4440. { 8, alc882_sixstack_ch8_init },
  4441. };
  4442. /*
  4443. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4444. */
  4445. /*
  4446. * 2ch mode
  4447. */
  4448. static struct hda_verb alc885_mbp_ch2_init[] = {
  4449. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4450. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4451. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4452. { } /* end */
  4453. };
  4454. /*
  4455. * 6ch mode
  4456. */
  4457. static struct hda_verb alc885_mbp_ch6_init[] = {
  4458. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4459. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4460. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4461. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4462. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4463. { } /* end */
  4464. };
  4465. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4466. { 2, alc885_mbp_ch2_init },
  4467. { 6, alc885_mbp_ch6_init },
  4468. };
  4469. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4470. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4471. */
  4472. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4473. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4474. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4475. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4476. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4477. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4478. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4479. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4480. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4481. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4482. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4483. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4484. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4485. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4486. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4487. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4488. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4489. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, 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_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4493. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4494. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4495. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4496. { } /* end */
  4497. };
  4498. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4499. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4500. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4501. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4502. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4503. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4504. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4505. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4506. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4507. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4508. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4509. { } /* end */
  4510. };
  4511. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4512. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4513. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4514. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4515. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4516. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4517. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4518. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4519. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4520. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4521. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4522. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4523. { } /* end */
  4524. };
  4525. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4526. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4527. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4528. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4529. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4530. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4531. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4532. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4533. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4534. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4535. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4536. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4537. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4538. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4539. { } /* end */
  4540. };
  4541. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4542. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4543. */
  4544. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4545. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4546. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4547. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4548. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4549. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4550. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4551. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4552. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4553. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4554. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4555. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4556. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4557. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4558. { } /* end */
  4559. };
  4560. static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
  4561. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4562. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4563. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4564. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4565. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4566. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4567. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4568. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4569. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4570. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4571. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4572. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4573. { } /* end */
  4574. };
  4575. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4576. {
  4577. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4578. .name = "Channel Mode",
  4579. .info = alc_ch_mode_info,
  4580. .get = alc_ch_mode_get,
  4581. .put = alc_ch_mode_put,
  4582. },
  4583. { } /* end */
  4584. };
  4585. static struct hda_verb alc882_init_verbs[] = {
  4586. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4587. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4588. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4589. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4590. /* Rear mixer */
  4591. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4592. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4593. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4594. /* CLFE mixer */
  4595. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4596. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4597. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4598. /* Side mixer */
  4599. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4600. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4601. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4602. /* Front Pin: output 0 (0x0c) */
  4603. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4604. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4605. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4606. /* Rear Pin: output 1 (0x0d) */
  4607. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4608. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4609. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4610. /* CLFE Pin: output 2 (0x0e) */
  4611. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4612. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4613. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4614. /* Side Pin: output 3 (0x0f) */
  4615. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4616. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4617. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4618. /* Mic (rear) pin: input vref at 80% */
  4619. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4620. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4621. /* Front Mic pin: input vref at 80% */
  4622. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4623. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4624. /* Line In pin: input */
  4625. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4626. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4627. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4628. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4629. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4630. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4631. /* CD pin widget for input */
  4632. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4633. /* FIXME: use matrix-type input source selection */
  4634. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4635. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4636. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4637. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4638. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4639. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4640. /* Input mixer2 */
  4641. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4642. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4643. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4644. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4645. /* Input mixer3 */
  4646. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4647. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4648. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4649. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4650. /* ADC1: mute amp left and right */
  4651. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4652. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4653. /* ADC2: mute amp left and right */
  4654. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4655. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4656. /* ADC3: mute amp left and right */
  4657. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4658. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4659. { }
  4660. };
  4661. static struct hda_verb alc882_eapd_verbs[] = {
  4662. /* change to EAPD mode */
  4663. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4664. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4665. { }
  4666. };
  4667. /* Mac Pro test */
  4668. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4669. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4670. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4671. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4672. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4673. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4674. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4675. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4676. { } /* end */
  4677. };
  4678. static struct hda_verb alc882_macpro_init_verbs[] = {
  4679. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4680. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4681. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4682. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4683. /* Front Pin: output 0 (0x0c) */
  4684. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4685. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4686. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4687. /* Front Mic pin: input vref at 80% */
  4688. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4689. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4690. /* Speaker: output */
  4691. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4692. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4693. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4694. /* Headphone output (output 0 - 0x0c) */
  4695. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4696. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4697. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4698. /* FIXME: use matrix-type input source selection */
  4699. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4700. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4701. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4702. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4703. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4704. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4705. /* Input mixer2 */
  4706. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4707. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4708. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4709. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4710. /* Input mixer3 */
  4711. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4712. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4713. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4714. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4715. /* ADC1: mute amp left and right */
  4716. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4717. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4718. /* ADC2: mute amp left and right */
  4719. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4720. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4721. /* ADC3: mute amp left and right */
  4722. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4723. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4724. { }
  4725. };
  4726. /* Macbook Pro rev3 */
  4727. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4728. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4729. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4730. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4731. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4732. /* Rear mixer */
  4733. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4734. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4735. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4736. /* Front Pin: output 0 (0x0c) */
  4737. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4738. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4739. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4740. /* HP Pin: output 0 (0x0d) */
  4741. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4742. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4743. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4744. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4745. /* Mic (rear) pin: input vref at 80% */
  4746. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4747. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4748. /* Front Mic pin: input vref at 80% */
  4749. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4750. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4751. /* Line In pin: use output 1 when in LineOut mode */
  4752. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4753. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4754. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4755. /* FIXME: use matrix-type input source selection */
  4756. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4757. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4758. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4759. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4760. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4761. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4762. /* Input mixer2 */
  4763. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4764. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4765. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4766. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4767. /* Input mixer3 */
  4768. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4769. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4770. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4771. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4772. /* ADC1: mute amp left and right */
  4773. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4774. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4775. /* ADC2: mute amp left and right */
  4776. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4777. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4778. /* ADC3: mute amp left and right */
  4779. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4780. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4781. { }
  4782. };
  4783. /* iMac 24 mixer. */
  4784. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4785. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4786. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4787. { } /* end */
  4788. };
  4789. /* iMac 24 init verbs. */
  4790. static struct hda_verb alc885_imac24_init_verbs[] = {
  4791. /* Internal speakers: output 0 (0x0c) */
  4792. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4793. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4794. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4795. /* Internal speakers: output 0 (0x0c) */
  4796. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4797. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4798. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4799. /* Headphone: output 0 (0x0c) */
  4800. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4801. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4802. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4803. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4804. /* Front Mic: input vref at 80% */
  4805. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4806. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4807. { }
  4808. };
  4809. /* Toggle speaker-output according to the hp-jack state */
  4810. static void alc885_imac24_automute(struct hda_codec *codec)
  4811. {
  4812. unsigned int present;
  4813. present = snd_hda_codec_read(codec, 0x14, 0,
  4814. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4815. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4816. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4817. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4818. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4819. }
  4820. /* Processes unsolicited events. */
  4821. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4822. unsigned int res)
  4823. {
  4824. /* Headphone insertion or removal. */
  4825. if ((res >> 26) == ALC880_HP_EVENT)
  4826. alc885_imac24_automute(codec);
  4827. }
  4828. static void alc885_mbp3_automute(struct hda_codec *codec)
  4829. {
  4830. unsigned int present;
  4831. present = snd_hda_codec_read(codec, 0x15, 0,
  4832. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4833. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  4834. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4835. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  4836. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  4837. }
  4838. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  4839. unsigned int res)
  4840. {
  4841. /* Headphone insertion or removal. */
  4842. if ((res >> 26) == ALC880_HP_EVENT)
  4843. alc885_mbp3_automute(codec);
  4844. }
  4845. static struct hda_verb alc882_targa_verbs[] = {
  4846. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4847. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4848. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4849. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4850. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4851. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4852. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4853. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4854. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4855. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4856. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4857. { } /* end */
  4858. };
  4859. /* toggle speaker-output according to the hp-jack state */
  4860. static void alc882_targa_automute(struct hda_codec *codec)
  4861. {
  4862. unsigned int present;
  4863. present = snd_hda_codec_read(codec, 0x14, 0,
  4864. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4865. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  4866. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4867. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  4868. present ? 1 : 3);
  4869. }
  4870. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4871. {
  4872. /* Looks like the unsol event is incompatible with the standard
  4873. * definition. 4bit tag is placed at 26 bit!
  4874. */
  4875. if (((res >> 26) == ALC880_HP_EVENT)) {
  4876. alc882_targa_automute(codec);
  4877. }
  4878. }
  4879. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4880. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4881. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4882. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4883. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4884. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4885. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4886. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4887. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4888. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4889. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4890. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4891. { } /* end */
  4892. };
  4893. static struct hda_verb alc882_asus_a7m_verbs[] = {
  4894. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4895. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4896. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4897. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4898. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4899. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4900. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4901. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4902. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4903. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4904. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4905. { } /* end */
  4906. };
  4907. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4908. {
  4909. unsigned int gpiostate, gpiomask, gpiodir;
  4910. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4911. AC_VERB_GET_GPIO_DATA, 0);
  4912. if (!muted)
  4913. gpiostate |= (1 << pin);
  4914. else
  4915. gpiostate &= ~(1 << pin);
  4916. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4917. AC_VERB_GET_GPIO_MASK, 0);
  4918. gpiomask |= (1 << pin);
  4919. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4920. AC_VERB_GET_GPIO_DIRECTION, 0);
  4921. gpiodir |= (1 << pin);
  4922. snd_hda_codec_write(codec, codec->afg, 0,
  4923. AC_VERB_SET_GPIO_MASK, gpiomask);
  4924. snd_hda_codec_write(codec, codec->afg, 0,
  4925. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4926. msleep(1);
  4927. snd_hda_codec_write(codec, codec->afg, 0,
  4928. AC_VERB_SET_GPIO_DATA, gpiostate);
  4929. }
  4930. /* set up GPIO at initialization */
  4931. static void alc885_macpro_init_hook(struct hda_codec *codec)
  4932. {
  4933. alc882_gpio_mute(codec, 0, 0);
  4934. alc882_gpio_mute(codec, 1, 0);
  4935. }
  4936. /* set up GPIO and update auto-muting at initialization */
  4937. static void alc885_imac24_init_hook(struct hda_codec *codec)
  4938. {
  4939. alc885_macpro_init_hook(codec);
  4940. alc885_imac24_automute(codec);
  4941. }
  4942. /*
  4943. * generic initialization of ADC, input mixers and output mixers
  4944. */
  4945. static struct hda_verb alc882_auto_init_verbs[] = {
  4946. /*
  4947. * Unmute ADC0-2 and set the default input to mic-in
  4948. */
  4949. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4950. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4951. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4952. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4953. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4954. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4955. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4956. * mixer widget
  4957. * Note: PASD motherboards uses the Line In 2 as the input for
  4958. * front panel mic (mic 2)
  4959. */
  4960. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4961. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4962. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4963. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4964. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4965. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4966. /*
  4967. * Set up output mixers (0x0c - 0x0f)
  4968. */
  4969. /* set vol=0 to output mixers */
  4970. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4971. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4972. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4973. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4974. /* set up input amps for analog loopback */
  4975. /* Amp Indices: DAC = 0, mixer = 1 */
  4976. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4977. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4978. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4979. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4980. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4981. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4982. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4983. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4984. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4985. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4986. /* FIXME: use matrix-type input source selection */
  4987. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4988. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4989. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4990. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4991. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4992. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4993. /* Input mixer2 */
  4994. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4995. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4996. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4997. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4998. /* Input mixer3 */
  4999. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5000. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5001. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5002. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5003. { }
  5004. };
  5005. /* capture mixer elements */
  5006. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  5007. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5008. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5009. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5010. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5011. {
  5012. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5013. /* The multiple "Capture Source" controls confuse alsamixer
  5014. * So call somewhat different..
  5015. * FIXME: the controls appear in the "playback" view!
  5016. */
  5017. /* .name = "Capture Source", */
  5018. .name = "Input Source",
  5019. .count = 2,
  5020. .info = alc882_mux_enum_info,
  5021. .get = alc882_mux_enum_get,
  5022. .put = alc882_mux_enum_put,
  5023. },
  5024. { } /* end */
  5025. };
  5026. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  5027. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  5028. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  5029. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  5030. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  5031. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  5032. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  5033. {
  5034. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5035. /* The multiple "Capture Source" controls confuse alsamixer
  5036. * So call somewhat different..
  5037. * FIXME: the controls appear in the "playback" view!
  5038. */
  5039. /* .name = "Capture Source", */
  5040. .name = "Input Source",
  5041. .count = 3,
  5042. .info = alc882_mux_enum_info,
  5043. .get = alc882_mux_enum_get,
  5044. .put = alc882_mux_enum_put,
  5045. },
  5046. { } /* end */
  5047. };
  5048. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5049. #define alc882_loopbacks alc880_loopbacks
  5050. #endif
  5051. /* pcm configuration: identiacal with ALC880 */
  5052. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5053. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5054. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5055. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5056. /*
  5057. * configuration and preset
  5058. */
  5059. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5060. [ALC882_3ST_DIG] = "3stack-dig",
  5061. [ALC882_6ST_DIG] = "6stack-dig",
  5062. [ALC882_ARIMA] = "arima",
  5063. [ALC882_W2JC] = "w2jc",
  5064. [ALC882_TARGA] = "targa",
  5065. [ALC882_ASUS_A7J] = "asus-a7j",
  5066. [ALC882_ASUS_A7M] = "asus-a7m",
  5067. [ALC885_MACPRO] = "macpro",
  5068. [ALC885_MBP3] = "mbp3",
  5069. [ALC885_IMAC24] = "imac24",
  5070. [ALC882_AUTO] = "auto",
  5071. };
  5072. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5073. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5074. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5075. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5076. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5077. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5078. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5079. SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
  5080. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5081. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5082. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5083. {}
  5084. };
  5085. static struct alc_config_preset alc882_presets[] = {
  5086. [ALC882_3ST_DIG] = {
  5087. .mixers = { alc882_base_mixer },
  5088. .init_verbs = { alc882_init_verbs },
  5089. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5090. .dac_nids = alc882_dac_nids,
  5091. .dig_out_nid = ALC882_DIGOUT_NID,
  5092. .dig_in_nid = ALC882_DIGIN_NID,
  5093. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5094. .channel_mode = alc882_ch_modes,
  5095. .need_dac_fix = 1,
  5096. .input_mux = &alc882_capture_source,
  5097. },
  5098. [ALC882_6ST_DIG] = {
  5099. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5100. .init_verbs = { alc882_init_verbs },
  5101. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5102. .dac_nids = alc882_dac_nids,
  5103. .dig_out_nid = ALC882_DIGOUT_NID,
  5104. .dig_in_nid = ALC882_DIGIN_NID,
  5105. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5106. .channel_mode = alc882_sixstack_modes,
  5107. .input_mux = &alc882_capture_source,
  5108. },
  5109. [ALC882_ARIMA] = {
  5110. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5111. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5112. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5113. .dac_nids = alc882_dac_nids,
  5114. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5115. .channel_mode = alc882_sixstack_modes,
  5116. .input_mux = &alc882_capture_source,
  5117. },
  5118. [ALC882_W2JC] = {
  5119. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5120. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5121. alc880_gpio1_init_verbs },
  5122. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5123. .dac_nids = alc882_dac_nids,
  5124. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5125. .channel_mode = alc880_threestack_modes,
  5126. .need_dac_fix = 1,
  5127. .input_mux = &alc882_capture_source,
  5128. .dig_out_nid = ALC882_DIGOUT_NID,
  5129. },
  5130. [ALC885_MBP3] = {
  5131. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5132. .init_verbs = { alc885_mbp3_init_verbs,
  5133. alc880_gpio1_init_verbs },
  5134. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5135. .dac_nids = alc882_dac_nids,
  5136. .channel_mode = alc885_mbp_6ch_modes,
  5137. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5138. .input_mux = &alc882_capture_source,
  5139. .dig_out_nid = ALC882_DIGOUT_NID,
  5140. .dig_in_nid = ALC882_DIGIN_NID,
  5141. .unsol_event = alc885_mbp3_unsol_event,
  5142. .init_hook = alc885_mbp3_automute,
  5143. },
  5144. [ALC885_MACPRO] = {
  5145. .mixers = { alc882_macpro_mixer },
  5146. .init_verbs = { alc882_macpro_init_verbs },
  5147. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5148. .dac_nids = alc882_dac_nids,
  5149. .dig_out_nid = ALC882_DIGOUT_NID,
  5150. .dig_in_nid = ALC882_DIGIN_NID,
  5151. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5152. .channel_mode = alc882_ch_modes,
  5153. .input_mux = &alc882_capture_source,
  5154. .init_hook = alc885_macpro_init_hook,
  5155. },
  5156. [ALC885_IMAC24] = {
  5157. .mixers = { alc885_imac24_mixer },
  5158. .init_verbs = { alc885_imac24_init_verbs },
  5159. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5160. .dac_nids = alc882_dac_nids,
  5161. .dig_out_nid = ALC882_DIGOUT_NID,
  5162. .dig_in_nid = ALC882_DIGIN_NID,
  5163. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5164. .channel_mode = alc882_ch_modes,
  5165. .input_mux = &alc882_capture_source,
  5166. .unsol_event = alc885_imac24_unsol_event,
  5167. .init_hook = alc885_imac24_init_hook,
  5168. },
  5169. [ALC882_TARGA] = {
  5170. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5171. alc882_capture_mixer },
  5172. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5173. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5174. .dac_nids = alc882_dac_nids,
  5175. .dig_out_nid = ALC882_DIGOUT_NID,
  5176. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5177. .adc_nids = alc882_adc_nids,
  5178. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5179. .channel_mode = alc882_3ST_6ch_modes,
  5180. .need_dac_fix = 1,
  5181. .input_mux = &alc882_capture_source,
  5182. .unsol_event = alc882_targa_unsol_event,
  5183. .init_hook = alc882_targa_automute,
  5184. },
  5185. [ALC882_ASUS_A7J] = {
  5186. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5187. alc882_capture_mixer },
  5188. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5189. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5190. .dac_nids = alc882_dac_nids,
  5191. .dig_out_nid = ALC882_DIGOUT_NID,
  5192. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5193. .adc_nids = alc882_adc_nids,
  5194. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5195. .channel_mode = alc882_3ST_6ch_modes,
  5196. .need_dac_fix = 1,
  5197. .input_mux = &alc882_capture_source,
  5198. },
  5199. [ALC882_ASUS_A7M] = {
  5200. .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
  5201. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5202. alc880_gpio1_init_verbs,
  5203. alc882_asus_a7m_verbs },
  5204. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5205. .dac_nids = alc882_dac_nids,
  5206. .dig_out_nid = ALC882_DIGOUT_NID,
  5207. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5208. .channel_mode = alc880_threestack_modes,
  5209. .need_dac_fix = 1,
  5210. .input_mux = &alc882_capture_source,
  5211. },
  5212. };
  5213. /*
  5214. * Pin config fixes
  5215. */
  5216. enum {
  5217. PINFIX_ABIT_AW9D_MAX
  5218. };
  5219. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5220. { 0x15, 0x01080104 }, /* side */
  5221. { 0x16, 0x01011012 }, /* rear */
  5222. { 0x17, 0x01016011 }, /* clfe */
  5223. { }
  5224. };
  5225. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5226. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5227. };
  5228. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5229. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5230. {}
  5231. };
  5232. /*
  5233. * BIOS auto configuration
  5234. */
  5235. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5236. hda_nid_t nid, int pin_type,
  5237. int dac_idx)
  5238. {
  5239. /* set as output */
  5240. struct alc_spec *spec = codec->spec;
  5241. int idx;
  5242. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5243. idx = 4;
  5244. else
  5245. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5246. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5247. pin_type);
  5248. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5249. AMP_OUT_UNMUTE);
  5250. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5251. }
  5252. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5253. {
  5254. struct alc_spec *spec = codec->spec;
  5255. int i;
  5256. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5257. for (i = 0; i <= HDA_SIDE; i++) {
  5258. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5259. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5260. if (nid)
  5261. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5262. i);
  5263. }
  5264. }
  5265. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5266. {
  5267. struct alc_spec *spec = codec->spec;
  5268. hda_nid_t pin;
  5269. pin = spec->autocfg.hp_pins[0];
  5270. if (pin) /* connect to front */
  5271. /* use dac 0 */
  5272. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5273. }
  5274. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5275. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5276. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5277. {
  5278. struct alc_spec *spec = codec->spec;
  5279. int i;
  5280. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5281. hda_nid_t nid = spec->autocfg.input_pins[i];
  5282. if (alc882_is_input_pin(nid)) {
  5283. snd_hda_codec_write(codec, nid, 0,
  5284. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5285. i <= AUTO_PIN_FRONT_MIC ?
  5286. PIN_VREF80 : PIN_IN);
  5287. if (nid != ALC882_PIN_CD_NID)
  5288. snd_hda_codec_write(codec, nid, 0,
  5289. AC_VERB_SET_AMP_GAIN_MUTE,
  5290. AMP_OUT_MUTE);
  5291. }
  5292. }
  5293. }
  5294. /* add mic boosts if needed */
  5295. static int alc_auto_add_mic_boost(struct hda_codec *codec)
  5296. {
  5297. struct alc_spec *spec = codec->spec;
  5298. int err;
  5299. hda_nid_t nid;
  5300. nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
  5301. if (nid) {
  5302. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5303. "Mic Boost",
  5304. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5305. if (err < 0)
  5306. return err;
  5307. }
  5308. nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
  5309. if (nid) {
  5310. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5311. "Front Mic Boost",
  5312. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5313. if (err < 0)
  5314. return err;
  5315. }
  5316. return 0;
  5317. }
  5318. /* almost identical with ALC880 parser... */
  5319. static int alc882_parse_auto_config(struct hda_codec *codec)
  5320. {
  5321. struct alc_spec *spec = codec->spec;
  5322. int err = alc880_parse_auto_config(codec);
  5323. if (err < 0)
  5324. return err;
  5325. else if (!err)
  5326. return 0; /* no config found */
  5327. err = alc_auto_add_mic_boost(codec);
  5328. if (err < 0)
  5329. return err;
  5330. /* hack - override the init verbs */
  5331. spec->init_verbs[0] = alc882_auto_init_verbs;
  5332. return 1; /* config found */
  5333. }
  5334. /* additional initialization for auto-configuration model */
  5335. static void alc882_auto_init(struct hda_codec *codec)
  5336. {
  5337. alc882_auto_init_multi_out(codec);
  5338. alc882_auto_init_hp_out(codec);
  5339. alc882_auto_init_analog_input(codec);
  5340. }
  5341. static int patch_alc882(struct hda_codec *codec)
  5342. {
  5343. struct alc_spec *spec;
  5344. int err, board_config;
  5345. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5346. if (spec == NULL)
  5347. return -ENOMEM;
  5348. codec->spec = spec;
  5349. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5350. alc882_models,
  5351. alc882_cfg_tbl);
  5352. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5353. /* Pick up systems that don't supply PCI SSID */
  5354. switch (codec->subsystem_id) {
  5355. case 0x106b0c00: /* Mac Pro */
  5356. board_config = ALC885_MACPRO;
  5357. break;
  5358. case 0x106b1000: /* iMac 24 */
  5359. board_config = ALC885_IMAC24;
  5360. break;
  5361. case 0x106b2c00: /* Macbook Pro rev3 */
  5362. board_config = ALC885_MBP3;
  5363. break;
  5364. default:
  5365. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5366. "trying auto-probe from BIOS...\n");
  5367. board_config = ALC882_AUTO;
  5368. }
  5369. }
  5370. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5371. if (board_config == ALC882_AUTO) {
  5372. /* automatic parse from the BIOS config */
  5373. err = alc882_parse_auto_config(codec);
  5374. if (err < 0) {
  5375. alc_free(codec);
  5376. return err;
  5377. } else if (!err) {
  5378. printk(KERN_INFO
  5379. "hda_codec: Cannot set up configuration "
  5380. "from BIOS. Using base mode...\n");
  5381. board_config = ALC882_3ST_DIG;
  5382. }
  5383. }
  5384. if (board_config != ALC882_AUTO)
  5385. setup_preset(spec, &alc882_presets[board_config]);
  5386. spec->stream_name_analog = "ALC882 Analog";
  5387. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5388. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5389. spec->stream_name_digital = "ALC882 Digital";
  5390. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5391. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5392. if (!spec->adc_nids && spec->input_mux) {
  5393. /* check whether NID 0x07 is valid */
  5394. unsigned int wcap = get_wcaps(codec, 0x07);
  5395. /* get type */
  5396. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5397. if (wcap != AC_WID_AUD_IN) {
  5398. spec->adc_nids = alc882_adc_nids_alt;
  5399. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5400. spec->mixers[spec->num_mixers] =
  5401. alc882_capture_alt_mixer;
  5402. spec->num_mixers++;
  5403. } else {
  5404. spec->adc_nids = alc882_adc_nids;
  5405. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5406. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5407. spec->num_mixers++;
  5408. }
  5409. }
  5410. codec->patch_ops = alc_patch_ops;
  5411. if (board_config == ALC882_AUTO)
  5412. spec->init_hook = alc882_auto_init;
  5413. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5414. if (!spec->loopback.amplist)
  5415. spec->loopback.amplist = alc882_loopbacks;
  5416. #endif
  5417. return 0;
  5418. }
  5419. /*
  5420. * ALC883 support
  5421. *
  5422. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5423. * configuration. Each pin widget can choose any input DACs and a mixer.
  5424. * Each ADC is connected from a mixer of all inputs. This makes possible
  5425. * 6-channel independent captures.
  5426. *
  5427. * In addition, an independent DAC for the multi-playback (not used in this
  5428. * driver yet).
  5429. */
  5430. #define ALC883_DIGOUT_NID 0x06
  5431. #define ALC883_DIGIN_NID 0x0a
  5432. static hda_nid_t alc883_dac_nids[4] = {
  5433. /* front, rear, clfe, rear_surr */
  5434. 0x02, 0x04, 0x03, 0x05
  5435. };
  5436. static hda_nid_t alc883_adc_nids[2] = {
  5437. /* ADC1-2 */
  5438. 0x08, 0x09,
  5439. };
  5440. /* input MUX */
  5441. /* FIXME: should be a matrix-type input source selection */
  5442. static struct hda_input_mux alc883_capture_source = {
  5443. .num_items = 4,
  5444. .items = {
  5445. { "Mic", 0x0 },
  5446. { "Front Mic", 0x1 },
  5447. { "Line", 0x2 },
  5448. { "CD", 0x4 },
  5449. },
  5450. };
  5451. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5452. .num_items = 2,
  5453. .items = {
  5454. { "Mic", 0x1 },
  5455. { "Line", 0x2 },
  5456. },
  5457. };
  5458. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5459. .num_items = 4,
  5460. .items = {
  5461. { "Mic", 0x0 },
  5462. { "iMic", 0x1 },
  5463. { "Line", 0x2 },
  5464. { "CD", 0x4 },
  5465. },
  5466. };
  5467. #define alc883_mux_enum_info alc_mux_enum_info
  5468. #define alc883_mux_enum_get alc_mux_enum_get
  5469. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5470. struct snd_ctl_elem_value *ucontrol)
  5471. {
  5472. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5473. struct alc_spec *spec = codec->spec;
  5474. const struct hda_input_mux *imux = spec->input_mux;
  5475. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5476. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5477. hda_nid_t nid = capture_mixers[adc_idx];
  5478. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5479. unsigned int i, idx;
  5480. idx = ucontrol->value.enumerated.item[0];
  5481. if (idx >= imux->num_items)
  5482. idx = imux->num_items - 1;
  5483. if (*cur_val == idx)
  5484. return 0;
  5485. for (i = 0; i < imux->num_items; i++) {
  5486. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5487. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5488. imux->items[i].index,
  5489. HDA_AMP_MUTE, v);
  5490. }
  5491. *cur_val = idx;
  5492. return 1;
  5493. }
  5494. /*
  5495. * 2ch mode
  5496. */
  5497. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5498. { 2, NULL }
  5499. };
  5500. /*
  5501. * 2ch mode
  5502. */
  5503. static struct hda_verb alc883_3ST_ch2_init[] = {
  5504. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5505. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5506. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5507. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5508. { } /* end */
  5509. };
  5510. /*
  5511. * 4ch mode
  5512. */
  5513. static struct hda_verb alc883_3ST_ch4_init[] = {
  5514. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5515. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5516. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5517. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5518. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5519. { } /* end */
  5520. };
  5521. /*
  5522. * 6ch mode
  5523. */
  5524. static struct hda_verb alc883_3ST_ch6_init[] = {
  5525. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5526. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5527. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5528. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5529. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5530. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5531. { } /* end */
  5532. };
  5533. static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
  5534. { 2, alc883_3ST_ch2_init },
  5535. { 4, alc883_3ST_ch4_init },
  5536. { 6, alc883_3ST_ch6_init },
  5537. };
  5538. /*
  5539. * 6ch mode
  5540. */
  5541. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5542. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5543. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5544. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5545. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5546. { } /* end */
  5547. };
  5548. /*
  5549. * 8ch mode
  5550. */
  5551. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5552. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5553. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5554. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5555. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5556. { } /* end */
  5557. };
  5558. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5559. { 6, alc883_sixstack_ch6_init },
  5560. { 8, alc883_sixstack_ch8_init },
  5561. };
  5562. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5563. /* eanable EAPD on medion laptop */
  5564. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5565. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5566. { }
  5567. };
  5568. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5569. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5570. */
  5571. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5572. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5573. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5574. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5575. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5576. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5577. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5578. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5579. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5580. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5581. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5582. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5583. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5584. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5585. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5586. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5587. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5588. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5589. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5590. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5591. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5592. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5593. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5594. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5595. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5596. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5597. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5598. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5599. {
  5600. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5601. /* .name = "Capture Source", */
  5602. .name = "Input Source",
  5603. .count = 2,
  5604. .info = alc883_mux_enum_info,
  5605. .get = alc883_mux_enum_get,
  5606. .put = alc883_mux_enum_put,
  5607. },
  5608. { } /* end */
  5609. };
  5610. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5611. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5612. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5613. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5614. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5615. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5616. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5617. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5618. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5619. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5620. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5621. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5622. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5623. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5624. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5625. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5626. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5627. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5628. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5629. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5630. {
  5631. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5632. /* .name = "Capture Source", */
  5633. .name = "Input Source",
  5634. .count = 2,
  5635. .info = alc883_mux_enum_info,
  5636. .get = alc883_mux_enum_get,
  5637. .put = alc883_mux_enum_put,
  5638. },
  5639. { } /* end */
  5640. };
  5641. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5642. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5643. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5644. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5645. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5646. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5647. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5648. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5649. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5650. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5651. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5652. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5653. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5654. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5655. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5656. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5657. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5658. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5659. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5660. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5661. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5662. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5663. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5664. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5665. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5666. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5667. {
  5668. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5669. /* .name = "Capture Source", */
  5670. .name = "Input Source",
  5671. .count = 2,
  5672. .info = alc883_mux_enum_info,
  5673. .get = alc883_mux_enum_get,
  5674. .put = alc883_mux_enum_put,
  5675. },
  5676. { } /* end */
  5677. };
  5678. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5679. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5680. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5681. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5682. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5683. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5684. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5685. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5686. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5687. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5688. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5689. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5690. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5691. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5692. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5693. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5694. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5695. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5696. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5697. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5698. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5699. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5700. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5701. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5702. {
  5703. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5704. /* .name = "Capture Source", */
  5705. .name = "Input Source",
  5706. .count = 1,
  5707. .info = alc883_mux_enum_info,
  5708. .get = alc883_mux_enum_get,
  5709. .put = alc883_mux_enum_put,
  5710. },
  5711. { } /* end */
  5712. };
  5713. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5714. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5715. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5716. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5717. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5718. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5719. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5720. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5721. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5722. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5723. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5724. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5725. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5726. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5727. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5728. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5729. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5730. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5731. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5732. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5733. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5734. {
  5735. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5736. /* .name = "Capture Source", */
  5737. .name = "Input Source",
  5738. .count = 2,
  5739. .info = alc883_mux_enum_info,
  5740. .get = alc883_mux_enum_get,
  5741. .put = alc883_mux_enum_put,
  5742. },
  5743. { } /* end */
  5744. };
  5745. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5746. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5747. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5748. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5749. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5750. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5751. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5752. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5753. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5754. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5755. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5756. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5757. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5758. {
  5759. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5760. /* .name = "Capture Source", */
  5761. .name = "Input Source",
  5762. .count = 2,
  5763. .info = alc883_mux_enum_info,
  5764. .get = alc883_mux_enum_get,
  5765. .put = alc883_mux_enum_put,
  5766. },
  5767. { } /* end */
  5768. };
  5769. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5770. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5771. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5772. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5773. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5774. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5775. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5776. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5777. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5778. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5779. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5780. {
  5781. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5782. /* .name = "Capture Source", */
  5783. .name = "Input Source",
  5784. .count = 1,
  5785. .info = alc883_mux_enum_info,
  5786. .get = alc883_mux_enum_get,
  5787. .put = alc883_mux_enum_put,
  5788. },
  5789. { } /* end */
  5790. };
  5791. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5792. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5793. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5794. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5795. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5796. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5797. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5798. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5799. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5800. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5801. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5802. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5803. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5804. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5805. {
  5806. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5807. /* .name = "Capture Source", */
  5808. .name = "Input Source",
  5809. .count = 2,
  5810. .info = alc883_mux_enum_info,
  5811. .get = alc883_mux_enum_get,
  5812. .put = alc883_mux_enum_put,
  5813. },
  5814. { } /* end */
  5815. };
  5816. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5817. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5818. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5819. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5820. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5821. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5822. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5823. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5824. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5825. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5826. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5827. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5828. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5829. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5830. {
  5831. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5832. /* .name = "Capture Source", */
  5833. .name = "Input Source",
  5834. .count = 2,
  5835. .info = alc883_mux_enum_info,
  5836. .get = alc883_mux_enum_get,
  5837. .put = alc883_mux_enum_put,
  5838. },
  5839. { } /* end */
  5840. };
  5841. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5842. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5843. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5844. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5845. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5846. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5847. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5848. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5849. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5850. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5851. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5852. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5853. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5854. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5855. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5856. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5857. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5858. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5859. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5860. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5861. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5862. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5863. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5864. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5865. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5866. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5867. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5868. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5869. {
  5870. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5871. /* .name = "Capture Source", */
  5872. .name = "Input Source",
  5873. .count = 2,
  5874. .info = alc883_mux_enum_info,
  5875. .get = alc883_mux_enum_get,
  5876. .put = alc883_mux_enum_put,
  5877. },
  5878. { } /* end */
  5879. };
  5880. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  5881. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5882. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5883. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5884. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5885. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5886. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5887. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5888. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5889. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5890. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5891. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5892. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5893. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5894. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5895. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5896. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5897. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5898. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5899. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5900. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5901. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5902. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5903. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5904. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5905. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5906. {
  5907. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5908. /* .name = "Capture Source", */
  5909. .name = "Input Source",
  5910. .count = 2,
  5911. .info = alc883_mux_enum_info,
  5912. .get = alc883_mux_enum_get,
  5913. .put = alc883_mux_enum_put,
  5914. },
  5915. { } /* end */
  5916. };
  5917. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  5918. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5919. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5920. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5921. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5922. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5923. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5924. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5925. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5926. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5927. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5928. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5929. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5930. {
  5931. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5932. /* .name = "Capture Source", */
  5933. .name = "Input Source",
  5934. .count = 2,
  5935. .info = alc883_mux_enum_info,
  5936. .get = alc883_mux_enum_get,
  5937. .put = alc883_mux_enum_put,
  5938. },
  5939. { } /* end */
  5940. };
  5941. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5942. {
  5943. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5944. .name = "Channel Mode",
  5945. .info = alc_ch_mode_info,
  5946. .get = alc_ch_mode_get,
  5947. .put = alc_ch_mode_put,
  5948. },
  5949. { } /* end */
  5950. };
  5951. static struct hda_verb alc883_init_verbs[] = {
  5952. /* ADC1: mute amp left and right */
  5953. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5954. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5955. /* ADC2: mute amp left and right */
  5956. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5957. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5958. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5959. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5960. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5961. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5962. /* Rear mixer */
  5963. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5964. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5965. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5966. /* CLFE mixer */
  5967. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5968. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5969. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5970. /* Side mixer */
  5971. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5972. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5973. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5974. /* mute analog input loopbacks */
  5975. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5976. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5977. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5978. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5979. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5980. /* Front Pin: output 0 (0x0c) */
  5981. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5982. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5983. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5984. /* Rear Pin: output 1 (0x0d) */
  5985. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5986. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5987. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5988. /* CLFE Pin: output 2 (0x0e) */
  5989. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5990. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5991. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5992. /* Side Pin: output 3 (0x0f) */
  5993. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5994. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5995. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5996. /* Mic (rear) pin: input vref at 80% */
  5997. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5998. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5999. /* Front Mic pin: input vref at 80% */
  6000. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6001. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6002. /* Line In pin: input */
  6003. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6004. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6005. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  6006. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6007. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6008. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6009. /* CD pin widget for input */
  6010. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6011. /* FIXME: use matrix-type input source selection */
  6012. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6013. /* Input mixer2 */
  6014. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6015. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6016. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6017. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6018. /* Input mixer3 */
  6019. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6020. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6021. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6022. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6023. { }
  6024. };
  6025. static struct hda_verb alc883_tagra_verbs[] = {
  6026. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6027. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6028. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6029. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6030. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  6031. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  6032. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  6033. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6034. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  6035. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  6036. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  6037. { } /* end */
  6038. };
  6039. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  6040. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6041. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  6042. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  6043. { } /* end */
  6044. };
  6045. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  6046. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6047. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6048. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6049. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6050. { } /* end */
  6051. };
  6052. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  6053. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6054. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6055. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6056. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  6057. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6058. { } /* end */
  6059. };
  6060. static struct hda_verb alc883_haier_w66_verbs[] = {
  6061. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6062. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6063. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6064. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6065. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6066. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6067. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6068. { } /* end */
  6069. };
  6070. static struct hda_verb alc888_6st_hp_verbs[] = {
  6071. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6072. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  6073. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  6074. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  6075. { }
  6076. };
  6077. static struct hda_verb alc888_3st_hp_verbs[] = {
  6078. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6079. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  6080. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  6081. { }
  6082. };
  6083. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  6084. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  6085. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6086. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  6087. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6088. { }
  6089. };
  6090. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  6091. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6092. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6093. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6094. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6095. { }
  6096. };
  6097. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  6098. { 2, alc888_3st_hp_2ch_init },
  6099. { 6, alc888_3st_hp_6ch_init },
  6100. };
  6101. /* toggle front-jack and RCA according to the hp-jack state */
  6102. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6103. {
  6104. unsigned int present;
  6105. present = snd_hda_codec_read(codec, 0x1b, 0,
  6106. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6107. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6108. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6109. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6110. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6111. }
  6112. /* toggle RCA according to the front-jack state */
  6113. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6114. {
  6115. unsigned int present;
  6116. present = snd_hda_codec_read(codec, 0x14, 0,
  6117. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6118. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6119. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6120. }
  6121. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6122. unsigned int res)
  6123. {
  6124. if ((res >> 26) == ALC880_HP_EVENT)
  6125. alc888_lenovo_ms7195_front_automute(codec);
  6126. if ((res >> 26) == ALC880_FRONT_EVENT)
  6127. alc888_lenovo_ms7195_rca_automute(codec);
  6128. }
  6129. static struct hda_verb alc883_medion_md2_verbs[] = {
  6130. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6131. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6132. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6133. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6134. { } /* end */
  6135. };
  6136. /* toggle speaker-output according to the hp-jack state */
  6137. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6138. {
  6139. unsigned int present;
  6140. present = snd_hda_codec_read(codec, 0x14, 0,
  6141. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6142. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6143. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6144. }
  6145. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6146. unsigned int res)
  6147. {
  6148. if ((res >> 26) == ALC880_HP_EVENT)
  6149. alc883_medion_md2_automute(codec);
  6150. }
  6151. /* toggle speaker-output according to the hp-jack state */
  6152. static void alc883_tagra_automute(struct hda_codec *codec)
  6153. {
  6154. unsigned int present;
  6155. unsigned char bits;
  6156. present = snd_hda_codec_read(codec, 0x14, 0,
  6157. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6158. bits = present ? HDA_AMP_MUTE : 0;
  6159. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6160. HDA_AMP_MUTE, bits);
  6161. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6162. present ? 1 : 3);
  6163. }
  6164. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6165. {
  6166. if ((res >> 26) == ALC880_HP_EVENT)
  6167. alc883_tagra_automute(codec);
  6168. }
  6169. static void alc883_haier_w66_automute(struct hda_codec *codec)
  6170. {
  6171. unsigned int present;
  6172. unsigned char bits;
  6173. present = snd_hda_codec_read(codec, 0x1b, 0,
  6174. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6175. bits = present ? 0x80 : 0;
  6176. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6177. 0x80, bits);
  6178. }
  6179. static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
  6180. unsigned int res)
  6181. {
  6182. if ((res >> 26) == ALC880_HP_EVENT)
  6183. alc883_haier_w66_automute(codec);
  6184. }
  6185. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6186. {
  6187. unsigned int present;
  6188. unsigned char bits;
  6189. present = snd_hda_codec_read(codec, 0x14, 0,
  6190. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6191. bits = present ? HDA_AMP_MUTE : 0;
  6192. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6193. HDA_AMP_MUTE, bits);
  6194. }
  6195. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6196. {
  6197. unsigned int present;
  6198. unsigned char bits;
  6199. present = snd_hda_codec_read(codec, 0x1b, 0,
  6200. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6201. bits = present ? HDA_AMP_MUTE : 0;
  6202. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6203. HDA_AMP_MUTE, bits);
  6204. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6205. HDA_AMP_MUTE, bits);
  6206. }
  6207. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6208. unsigned int res)
  6209. {
  6210. if ((res >> 26) == ALC880_HP_EVENT)
  6211. alc883_lenovo_101e_all_automute(codec);
  6212. if ((res >> 26) == ALC880_FRONT_EVENT)
  6213. alc883_lenovo_101e_ispeaker_automute(codec);
  6214. }
  6215. /* toggle speaker-output according to the hp-jack state */
  6216. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6217. {
  6218. unsigned int present;
  6219. present = snd_hda_codec_read(codec, 0x14, 0,
  6220. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6221. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6222. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6223. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6224. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6225. }
  6226. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6227. unsigned int res)
  6228. {
  6229. if ((res >> 26) == ALC880_HP_EVENT)
  6230. alc883_acer_aspire_automute(codec);
  6231. }
  6232. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6233. /* HP Pin: output 0 (0x0c) */
  6234. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6235. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6236. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6237. /* Front Pin: output 0 (0x0c) */
  6238. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6239. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6240. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6241. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6242. /* eanable EAPD on medion laptop */
  6243. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6244. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6245. /* enable unsolicited event */
  6246. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6247. { }
  6248. };
  6249. /*
  6250. * generic initialization of ADC, input mixers and output mixers
  6251. */
  6252. static struct hda_verb alc883_auto_init_verbs[] = {
  6253. /*
  6254. * Unmute ADC0-2 and set the default input to mic-in
  6255. */
  6256. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6257. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6258. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6259. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6260. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6261. * mixer widget
  6262. * Note: PASD motherboards uses the Line In 2 as the input for
  6263. * front panel mic (mic 2)
  6264. */
  6265. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6266. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6267. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6268. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6269. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6270. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6271. /*
  6272. * Set up output mixers (0x0c - 0x0f)
  6273. */
  6274. /* set vol=0 to output mixers */
  6275. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6276. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6277. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6278. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6279. /* set up input amps for analog loopback */
  6280. /* Amp Indices: DAC = 0, mixer = 1 */
  6281. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6282. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6283. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6284. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6285. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6286. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6287. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6288. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6289. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6290. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6291. /* FIXME: use matrix-type input source selection */
  6292. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6293. /* Input mixer1 */
  6294. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6295. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6296. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6297. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6298. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6299. /* Input mixer2 */
  6300. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6301. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6302. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6303. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6304. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6305. { }
  6306. };
  6307. /* capture mixer elements */
  6308. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6309. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6310. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6311. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6312. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6313. {
  6314. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6315. /* The multiple "Capture Source" controls confuse alsamixer
  6316. * So call somewhat different..
  6317. * FIXME: the controls appear in the "playback" view!
  6318. */
  6319. /* .name = "Capture Source", */
  6320. .name = "Input Source",
  6321. .count = 2,
  6322. .info = alc882_mux_enum_info,
  6323. .get = alc882_mux_enum_get,
  6324. .put = alc882_mux_enum_put,
  6325. },
  6326. { } /* end */
  6327. };
  6328. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6329. #define alc883_loopbacks alc880_loopbacks
  6330. #endif
  6331. /* pcm configuration: identiacal with ALC880 */
  6332. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6333. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6334. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6335. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6336. /*
  6337. * configuration and preset
  6338. */
  6339. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6340. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6341. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6342. [ALC883_3ST_6ch] = "3stack-6ch",
  6343. [ALC883_6ST_DIG] = "6stack-dig",
  6344. [ALC883_TARGA_DIG] = "targa-dig",
  6345. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6346. [ALC883_ACER] = "acer",
  6347. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6348. [ALC883_MEDION] = "medion",
  6349. [ALC883_MEDION_MD2] = "medion-md2",
  6350. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6351. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6352. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6353. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6354. [ALC883_HAIER_W66] = "haier-w66",
  6355. [ALC888_6ST_HP] = "6stack-hp",
  6356. [ALC888_3ST_HP] = "3stack-hp",
  6357. [ALC883_AUTO] = "auto",
  6358. };
  6359. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6360. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6361. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6362. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6363. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6364. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6365. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6366. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6367. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6368. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6369. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6370. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6371. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6372. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6373. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6374. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6375. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6376. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6377. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6378. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6379. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6380. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6381. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6382. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6383. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6384. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6385. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6386. SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
  6387. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6388. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6389. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6390. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6391. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6392. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6393. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6394. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6395. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6396. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6397. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6398. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6399. SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
  6400. SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6401. SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
  6402. SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
  6403. {}
  6404. };
  6405. static struct alc_config_preset alc883_presets[] = {
  6406. [ALC883_3ST_2ch_DIG] = {
  6407. .mixers = { alc883_3ST_2ch_mixer },
  6408. .init_verbs = { alc883_init_verbs },
  6409. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6410. .dac_nids = alc883_dac_nids,
  6411. .dig_out_nid = ALC883_DIGOUT_NID,
  6412. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6413. .adc_nids = alc883_adc_nids,
  6414. .dig_in_nid = ALC883_DIGIN_NID,
  6415. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6416. .channel_mode = alc883_3ST_2ch_modes,
  6417. .input_mux = &alc883_capture_source,
  6418. },
  6419. [ALC883_3ST_6ch_DIG] = {
  6420. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6421. .init_verbs = { alc883_init_verbs },
  6422. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6423. .dac_nids = alc883_dac_nids,
  6424. .dig_out_nid = ALC883_DIGOUT_NID,
  6425. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6426. .adc_nids = alc883_adc_nids,
  6427. .dig_in_nid = ALC883_DIGIN_NID,
  6428. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6429. .channel_mode = alc883_3ST_6ch_modes,
  6430. .need_dac_fix = 1,
  6431. .input_mux = &alc883_capture_source,
  6432. },
  6433. [ALC883_3ST_6ch] = {
  6434. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6435. .init_verbs = { alc883_init_verbs },
  6436. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6437. .dac_nids = alc883_dac_nids,
  6438. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6439. .adc_nids = alc883_adc_nids,
  6440. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6441. .channel_mode = alc883_3ST_6ch_modes,
  6442. .need_dac_fix = 1,
  6443. .input_mux = &alc883_capture_source,
  6444. },
  6445. [ALC883_6ST_DIG] = {
  6446. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6447. .init_verbs = { alc883_init_verbs },
  6448. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6449. .dac_nids = alc883_dac_nids,
  6450. .dig_out_nid = ALC883_DIGOUT_NID,
  6451. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6452. .adc_nids = alc883_adc_nids,
  6453. .dig_in_nid = ALC883_DIGIN_NID,
  6454. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6455. .channel_mode = alc883_sixstack_modes,
  6456. .input_mux = &alc883_capture_source,
  6457. },
  6458. [ALC883_TARGA_DIG] = {
  6459. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6460. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6461. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6462. .dac_nids = alc883_dac_nids,
  6463. .dig_out_nid = ALC883_DIGOUT_NID,
  6464. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6465. .adc_nids = alc883_adc_nids,
  6466. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6467. .channel_mode = alc883_3ST_6ch_modes,
  6468. .need_dac_fix = 1,
  6469. .input_mux = &alc883_capture_source,
  6470. .unsol_event = alc883_tagra_unsol_event,
  6471. .init_hook = alc883_tagra_automute,
  6472. },
  6473. [ALC883_TARGA_2ch_DIG] = {
  6474. .mixers = { alc883_tagra_2ch_mixer},
  6475. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6476. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6477. .dac_nids = alc883_dac_nids,
  6478. .dig_out_nid = ALC883_DIGOUT_NID,
  6479. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6480. .adc_nids = alc883_adc_nids,
  6481. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6482. .channel_mode = alc883_3ST_2ch_modes,
  6483. .input_mux = &alc883_capture_source,
  6484. .unsol_event = alc883_tagra_unsol_event,
  6485. .init_hook = alc883_tagra_automute,
  6486. },
  6487. [ALC883_ACER] = {
  6488. .mixers = { alc883_base_mixer },
  6489. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6490. * and the headphone jack. Turn this on and rely on the
  6491. * standard mute methods whenever the user wants to turn
  6492. * these outputs off.
  6493. */
  6494. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6495. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6496. .dac_nids = alc883_dac_nids,
  6497. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6498. .adc_nids = alc883_adc_nids,
  6499. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6500. .channel_mode = alc883_3ST_2ch_modes,
  6501. .input_mux = &alc883_capture_source,
  6502. },
  6503. [ALC883_ACER_ASPIRE] = {
  6504. .mixers = { alc883_acer_aspire_mixer },
  6505. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6506. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6507. .dac_nids = alc883_dac_nids,
  6508. .dig_out_nid = ALC883_DIGOUT_NID,
  6509. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6510. .adc_nids = alc883_adc_nids,
  6511. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6512. .channel_mode = alc883_3ST_2ch_modes,
  6513. .input_mux = &alc883_capture_source,
  6514. .unsol_event = alc883_acer_aspire_unsol_event,
  6515. .init_hook = alc883_acer_aspire_automute,
  6516. },
  6517. [ALC883_MEDION] = {
  6518. .mixers = { alc883_fivestack_mixer,
  6519. alc883_chmode_mixer },
  6520. .init_verbs = { alc883_init_verbs,
  6521. alc883_medion_eapd_verbs },
  6522. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6523. .dac_nids = alc883_dac_nids,
  6524. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6525. .adc_nids = alc883_adc_nids,
  6526. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6527. .channel_mode = alc883_sixstack_modes,
  6528. .input_mux = &alc883_capture_source,
  6529. },
  6530. [ALC883_MEDION_MD2] = {
  6531. .mixers = { alc883_medion_md2_mixer},
  6532. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6533. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6534. .dac_nids = alc883_dac_nids,
  6535. .dig_out_nid = ALC883_DIGOUT_NID,
  6536. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6537. .adc_nids = alc883_adc_nids,
  6538. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6539. .channel_mode = alc883_3ST_2ch_modes,
  6540. .input_mux = &alc883_capture_source,
  6541. .unsol_event = alc883_medion_md2_unsol_event,
  6542. .init_hook = alc883_medion_md2_automute,
  6543. },
  6544. [ALC883_LAPTOP_EAPD] = {
  6545. .mixers = { alc883_base_mixer },
  6546. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6547. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6548. .dac_nids = alc883_dac_nids,
  6549. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6550. .adc_nids = alc883_adc_nids,
  6551. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6552. .channel_mode = alc883_3ST_2ch_modes,
  6553. .input_mux = &alc883_capture_source,
  6554. },
  6555. [ALC883_LENOVO_101E_2ch] = {
  6556. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6557. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6558. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6559. .dac_nids = alc883_dac_nids,
  6560. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6561. .adc_nids = alc883_adc_nids,
  6562. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6563. .channel_mode = alc883_3ST_2ch_modes,
  6564. .input_mux = &alc883_lenovo_101e_capture_source,
  6565. .unsol_event = alc883_lenovo_101e_unsol_event,
  6566. .init_hook = alc883_lenovo_101e_all_automute,
  6567. },
  6568. [ALC883_LENOVO_NB0763] = {
  6569. .mixers = { alc883_lenovo_nb0763_mixer },
  6570. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6571. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6572. .dac_nids = alc883_dac_nids,
  6573. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6574. .adc_nids = alc883_adc_nids,
  6575. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6576. .channel_mode = alc883_3ST_2ch_modes,
  6577. .need_dac_fix = 1,
  6578. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6579. .unsol_event = alc883_medion_md2_unsol_event,
  6580. .init_hook = alc883_medion_md2_automute,
  6581. },
  6582. [ALC888_LENOVO_MS7195_DIG] = {
  6583. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6584. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6585. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6586. .dac_nids = alc883_dac_nids,
  6587. .dig_out_nid = ALC883_DIGOUT_NID,
  6588. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6589. .adc_nids = alc883_adc_nids,
  6590. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6591. .channel_mode = alc883_3ST_6ch_modes,
  6592. .need_dac_fix = 1,
  6593. .input_mux = &alc883_capture_source,
  6594. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6595. .init_hook = alc888_lenovo_ms7195_front_automute,
  6596. },
  6597. [ALC883_HAIER_W66] = {
  6598. .mixers = { alc883_tagra_2ch_mixer},
  6599. .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
  6600. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6601. .dac_nids = alc883_dac_nids,
  6602. .dig_out_nid = ALC883_DIGOUT_NID,
  6603. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6604. .adc_nids = alc883_adc_nids,
  6605. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6606. .channel_mode = alc883_3ST_2ch_modes,
  6607. .input_mux = &alc883_capture_source,
  6608. .unsol_event = alc883_haier_w66_unsol_event,
  6609. .init_hook = alc883_haier_w66_automute,
  6610. },
  6611. [ALC888_6ST_HP] = {
  6612. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6613. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6614. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6615. .dac_nids = alc883_dac_nids,
  6616. .dig_out_nid = ALC883_DIGOUT_NID,
  6617. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6618. .adc_nids = alc883_adc_nids,
  6619. .dig_in_nid = ALC883_DIGIN_NID,
  6620. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6621. .channel_mode = alc883_sixstack_modes,
  6622. .input_mux = &alc883_capture_source,
  6623. },
  6624. [ALC888_3ST_HP] = {
  6625. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6626. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6627. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6628. .dac_nids = alc883_dac_nids,
  6629. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6630. .adc_nids = alc883_adc_nids,
  6631. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6632. .channel_mode = alc888_3st_hp_modes,
  6633. .need_dac_fix = 1,
  6634. .input_mux = &alc883_capture_source,
  6635. },
  6636. };
  6637. /*
  6638. * BIOS auto configuration
  6639. */
  6640. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6641. hda_nid_t nid, int pin_type,
  6642. int dac_idx)
  6643. {
  6644. /* set as output */
  6645. struct alc_spec *spec = codec->spec;
  6646. int idx;
  6647. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6648. idx = 4;
  6649. else
  6650. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6651. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6652. pin_type);
  6653. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6654. AMP_OUT_UNMUTE);
  6655. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6656. }
  6657. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6658. {
  6659. struct alc_spec *spec = codec->spec;
  6660. int i;
  6661. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6662. for (i = 0; i <= HDA_SIDE; i++) {
  6663. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6664. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6665. if (nid)
  6666. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6667. i);
  6668. }
  6669. }
  6670. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6671. {
  6672. struct alc_spec *spec = codec->spec;
  6673. hda_nid_t pin;
  6674. pin = spec->autocfg.hp_pins[0];
  6675. if (pin) /* connect to front */
  6676. /* use dac 0 */
  6677. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6678. }
  6679. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6680. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6681. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6682. {
  6683. struct alc_spec *spec = codec->spec;
  6684. int i;
  6685. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6686. hda_nid_t nid = spec->autocfg.input_pins[i];
  6687. if (alc883_is_input_pin(nid)) {
  6688. snd_hda_codec_write(codec, nid, 0,
  6689. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6690. (i <= AUTO_PIN_FRONT_MIC ?
  6691. PIN_VREF80 : PIN_IN));
  6692. if (nid != ALC883_PIN_CD_NID)
  6693. snd_hda_codec_write(codec, nid, 0,
  6694. AC_VERB_SET_AMP_GAIN_MUTE,
  6695. AMP_OUT_MUTE);
  6696. }
  6697. }
  6698. }
  6699. /* almost identical with ALC880 parser... */
  6700. static int alc883_parse_auto_config(struct hda_codec *codec)
  6701. {
  6702. struct alc_spec *spec = codec->spec;
  6703. int err = alc880_parse_auto_config(codec);
  6704. if (err < 0)
  6705. return err;
  6706. else if (!err)
  6707. return 0; /* no config found */
  6708. err = alc_auto_add_mic_boost(codec);
  6709. if (err < 0)
  6710. return err;
  6711. /* hack - override the init verbs */
  6712. spec->init_verbs[0] = alc883_auto_init_verbs;
  6713. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6714. spec->num_mixers++;
  6715. return 1; /* config found */
  6716. }
  6717. /* additional initialization for auto-configuration model */
  6718. static void alc883_auto_init(struct hda_codec *codec)
  6719. {
  6720. alc883_auto_init_multi_out(codec);
  6721. alc883_auto_init_hp_out(codec);
  6722. alc883_auto_init_analog_input(codec);
  6723. }
  6724. static int patch_alc883(struct hda_codec *codec)
  6725. {
  6726. struct alc_spec *spec;
  6727. int err, board_config;
  6728. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6729. if (spec == NULL)
  6730. return -ENOMEM;
  6731. codec->spec = spec;
  6732. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6733. alc883_models,
  6734. alc883_cfg_tbl);
  6735. if (board_config < 0) {
  6736. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6737. "trying auto-probe from BIOS...\n");
  6738. board_config = ALC883_AUTO;
  6739. }
  6740. if (board_config == ALC883_AUTO) {
  6741. /* automatic parse from the BIOS config */
  6742. err = alc883_parse_auto_config(codec);
  6743. if (err < 0) {
  6744. alc_free(codec);
  6745. return err;
  6746. } else if (!err) {
  6747. printk(KERN_INFO
  6748. "hda_codec: Cannot set up configuration "
  6749. "from BIOS. Using base mode...\n");
  6750. board_config = ALC883_3ST_2ch_DIG;
  6751. }
  6752. }
  6753. if (board_config != ALC883_AUTO)
  6754. setup_preset(spec, &alc883_presets[board_config]);
  6755. spec->stream_name_analog = "ALC883 Analog";
  6756. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6757. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6758. spec->stream_name_digital = "ALC883 Digital";
  6759. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6760. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6761. if (!spec->adc_nids && spec->input_mux) {
  6762. spec->adc_nids = alc883_adc_nids;
  6763. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6764. }
  6765. codec->patch_ops = alc_patch_ops;
  6766. if (board_config == ALC883_AUTO)
  6767. spec->init_hook = alc883_auto_init;
  6768. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6769. if (!spec->loopback.amplist)
  6770. spec->loopback.amplist = alc883_loopbacks;
  6771. #endif
  6772. return 0;
  6773. }
  6774. /*
  6775. * ALC262 support
  6776. */
  6777. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6778. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6779. #define alc262_dac_nids alc260_dac_nids
  6780. #define alc262_adc_nids alc882_adc_nids
  6781. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6782. #define alc262_modes alc260_modes
  6783. #define alc262_capture_source alc882_capture_source
  6784. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6785. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6786. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6787. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6788. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6789. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6790. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6791. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6792. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6793. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6794. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6795. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6796. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6797. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6798. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6799. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6800. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6801. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6802. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6803. { } /* end */
  6804. };
  6805. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6806. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6807. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6808. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6809. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6810. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6811. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6812. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6813. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6814. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6815. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6816. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6817. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6818. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6819. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6820. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6821. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6822. { } /* end */
  6823. };
  6824. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6825. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6826. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6827. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6828. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6829. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6830. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6831. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6832. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6833. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6834. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6835. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6836. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6837. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6838. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6839. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6840. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6841. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6842. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6843. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6844. { } /* end */
  6845. };
  6846. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6847. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6848. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6849. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6850. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6851. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6852. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6853. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6854. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6855. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6856. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6857. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6858. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6859. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6860. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6861. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6862. { } /* end */
  6863. };
  6864. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6865. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6866. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6867. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6868. { } /* end */
  6869. };
  6870. /* bind hp and internal speaker mute (with plug check) */
  6871. static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
  6872. struct snd_ctl_elem_value *ucontrol)
  6873. {
  6874. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6875. long *valp = ucontrol->value.integer.value;
  6876. int change;
  6877. /* change hp mute */
  6878. change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6879. HDA_AMP_MUTE,
  6880. valp[0] ? 0 : HDA_AMP_MUTE);
  6881. change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6882. HDA_AMP_MUTE,
  6883. valp[1] ? 0 : HDA_AMP_MUTE);
  6884. if (change) {
  6885. /* change speaker according to HP jack state */
  6886. struct alc_spec *spec = codec->spec;
  6887. unsigned int mute;
  6888. if (spec->jack_present)
  6889. mute = HDA_AMP_MUTE;
  6890. else
  6891. mute = snd_hda_codec_amp_read(codec, 0x15, 0,
  6892. HDA_OUTPUT, 0);
  6893. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6894. HDA_AMP_MUTE, mute);
  6895. }
  6896. return change;
  6897. }
  6898. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6899. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6900. {
  6901. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6902. .name = "Master Playback Switch",
  6903. .info = snd_hda_mixer_amp_switch_info,
  6904. .get = snd_hda_mixer_amp_switch_get,
  6905. .put = alc262_sony_master_sw_put,
  6906. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  6907. },
  6908. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6909. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6910. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6911. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6912. { } /* end */
  6913. };
  6914. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6915. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6916. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6917. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6918. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6919. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6920. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6921. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6922. { } /* end */
  6923. };
  6924. #define alc262_capture_mixer alc882_capture_mixer
  6925. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6926. /*
  6927. * generic initialization of ADC, input mixers and output mixers
  6928. */
  6929. static struct hda_verb alc262_init_verbs[] = {
  6930. /*
  6931. * Unmute ADC0-2 and set the default input to mic-in
  6932. */
  6933. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6934. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6935. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6936. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6937. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6938. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6939. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6940. * mixer widget
  6941. * Note: PASD motherboards uses the Line In 2 as the input for
  6942. * front panel mic (mic 2)
  6943. */
  6944. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6945. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6946. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6947. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6948. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6949. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6950. /*
  6951. * Set up output mixers (0x0c - 0x0e)
  6952. */
  6953. /* set vol=0 to output mixers */
  6954. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6955. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6956. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6957. /* set up input amps for analog loopback */
  6958. /* Amp Indices: DAC = 0, mixer = 1 */
  6959. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6960. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6961. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6962. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6963. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6964. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6965. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6966. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6967. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6968. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6969. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6970. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6971. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6972. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6973. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6974. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6975. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6976. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6977. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6978. /* FIXME: use matrix-type input source selection */
  6979. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6980. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6981. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6982. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6983. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6984. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6985. /* Input mixer2 */
  6986. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6987. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6988. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6989. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6990. /* Input mixer3 */
  6991. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6992. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6993. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6994. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6995. { }
  6996. };
  6997. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6998. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6999. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7000. {}
  7001. };
  7002. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  7003. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7004. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7005. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7006. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7007. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7008. {}
  7009. };
  7010. static struct hda_verb alc262_sony_unsol_verbs[] = {
  7011. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7012. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7013. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  7014. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7015. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7016. };
  7017. /* mute/unmute internal speaker according to the hp jack and mute state */
  7018. static void alc262_hippo_automute(struct hda_codec *codec)
  7019. {
  7020. struct alc_spec *spec = codec->spec;
  7021. unsigned int mute;
  7022. unsigned int present;
  7023. /* need to execute and sync at first */
  7024. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7025. present = snd_hda_codec_read(codec, 0x15, 0,
  7026. AC_VERB_GET_PIN_SENSE, 0);
  7027. spec->jack_present = (present & 0x80000000) != 0;
  7028. if (spec->jack_present) {
  7029. /* mute internal speaker */
  7030. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7031. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7032. } else {
  7033. /* unmute internal speaker if necessary */
  7034. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7035. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7036. HDA_AMP_MUTE, mute);
  7037. }
  7038. }
  7039. /* unsolicited event for HP jack sensing */
  7040. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  7041. unsigned int res)
  7042. {
  7043. if ((res >> 26) != ALC880_HP_EVENT)
  7044. return;
  7045. alc262_hippo_automute(codec);
  7046. }
  7047. static void alc262_hippo1_automute(struct hda_codec *codec)
  7048. {
  7049. unsigned int mute;
  7050. unsigned int present;
  7051. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  7052. present = snd_hda_codec_read(codec, 0x1b, 0,
  7053. AC_VERB_GET_PIN_SENSE, 0);
  7054. present = (present & 0x80000000) != 0;
  7055. if (present) {
  7056. /* mute internal speaker */
  7057. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7058. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7059. } else {
  7060. /* unmute internal speaker if necessary */
  7061. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  7062. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7063. HDA_AMP_MUTE, mute);
  7064. }
  7065. }
  7066. /* unsolicited event for HP jack sensing */
  7067. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  7068. unsigned int res)
  7069. {
  7070. if ((res >> 26) != ALC880_HP_EVENT)
  7071. return;
  7072. alc262_hippo1_automute(codec);
  7073. }
  7074. /*
  7075. * fujitsu model
  7076. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  7077. */
  7078. #define ALC_HP_EVENT 0x37
  7079. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  7080. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  7081. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7082. {}
  7083. };
  7084. static struct hda_input_mux alc262_fujitsu_capture_source = {
  7085. .num_items = 2,
  7086. .items = {
  7087. { "Mic", 0x0 },
  7088. { "CD", 0x4 },
  7089. },
  7090. };
  7091. static struct hda_input_mux alc262_HP_capture_source = {
  7092. .num_items = 5,
  7093. .items = {
  7094. { "Mic", 0x0 },
  7095. { "Front Mic", 0x1 },
  7096. { "Line", 0x2 },
  7097. { "CD", 0x4 },
  7098. { "AUX IN", 0x6 },
  7099. },
  7100. };
  7101. static struct hda_input_mux alc262_HP_D7000_capture_source = {
  7102. .num_items = 4,
  7103. .items = {
  7104. { "Mic", 0x0 },
  7105. { "Front Mic", 0x2 },
  7106. { "Line", 0x1 },
  7107. { "CD", 0x4 },
  7108. },
  7109. };
  7110. /* mute/unmute internal speaker according to the hp jack and mute state */
  7111. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  7112. {
  7113. struct alc_spec *spec = codec->spec;
  7114. unsigned int mute;
  7115. if (force || !spec->sense_updated) {
  7116. unsigned int present;
  7117. /* need to execute and sync at first */
  7118. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  7119. present = snd_hda_codec_read(codec, 0x14, 0,
  7120. AC_VERB_GET_PIN_SENSE, 0);
  7121. spec->jack_present = (present & 0x80000000) != 0;
  7122. spec->sense_updated = 1;
  7123. }
  7124. if (spec->jack_present) {
  7125. /* mute internal speaker */
  7126. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7127. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7128. } else {
  7129. /* unmute internal speaker if necessary */
  7130. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7131. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7132. HDA_AMP_MUTE, mute);
  7133. }
  7134. }
  7135. /* unsolicited event for HP jack sensing */
  7136. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  7137. unsigned int res)
  7138. {
  7139. if ((res >> 26) != ALC_HP_EVENT)
  7140. return;
  7141. alc262_fujitsu_automute(codec, 1);
  7142. }
  7143. /* bind volumes of both NID 0x0c and 0x0d */
  7144. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  7145. .ops = &snd_hda_bind_vol,
  7146. .values = {
  7147. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7148. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7149. 0
  7150. },
  7151. };
  7152. /* bind hp and internal speaker mute (with plug check) */
  7153. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  7154. struct snd_ctl_elem_value *ucontrol)
  7155. {
  7156. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7157. long *valp = ucontrol->value.integer.value;
  7158. int change;
  7159. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7160. HDA_AMP_MUTE,
  7161. valp[0] ? 0 : HDA_AMP_MUTE);
  7162. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7163. HDA_AMP_MUTE,
  7164. valp[1] ? 0 : HDA_AMP_MUTE);
  7165. if (change)
  7166. alc262_fujitsu_automute(codec, 0);
  7167. return change;
  7168. }
  7169. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  7170. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  7171. {
  7172. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7173. .name = "Master Playback Switch",
  7174. .info = snd_hda_mixer_amp_switch_info,
  7175. .get = snd_hda_mixer_amp_switch_get,
  7176. .put = alc262_fujitsu_master_sw_put,
  7177. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7178. },
  7179. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7180. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7181. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7182. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7183. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7184. { } /* end */
  7185. };
  7186. /* additional init verbs for Benq laptops */
  7187. static struct hda_verb alc262_EAPD_verbs[] = {
  7188. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7189. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7190. {}
  7191. };
  7192. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7193. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7194. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7195. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7196. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7197. {}
  7198. };
  7199. /* add playback controls from the parsed DAC table */
  7200. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7201. const struct auto_pin_cfg *cfg)
  7202. {
  7203. hda_nid_t nid;
  7204. int err;
  7205. spec->multiout.num_dacs = 1; /* only use one dac */
  7206. spec->multiout.dac_nids = spec->private_dac_nids;
  7207. spec->multiout.dac_nids[0] = 2;
  7208. nid = cfg->line_out_pins[0];
  7209. if (nid) {
  7210. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7211. "Front Playback Volume",
  7212. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7213. if (err < 0)
  7214. return err;
  7215. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7216. "Front Playback Switch",
  7217. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7218. if (err < 0)
  7219. return err;
  7220. }
  7221. nid = cfg->speaker_pins[0];
  7222. if (nid) {
  7223. if (nid == 0x16) {
  7224. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7225. "Speaker Playback Volume",
  7226. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7227. HDA_OUTPUT));
  7228. if (err < 0)
  7229. return err;
  7230. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7231. "Speaker Playback Switch",
  7232. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7233. HDA_OUTPUT));
  7234. if (err < 0)
  7235. return err;
  7236. } else {
  7237. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7238. "Speaker Playback Switch",
  7239. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7240. HDA_OUTPUT));
  7241. if (err < 0)
  7242. return err;
  7243. }
  7244. }
  7245. nid = cfg->hp_pins[0];
  7246. if (nid) {
  7247. /* spec->multiout.hp_nid = 2; */
  7248. if (nid == 0x16) {
  7249. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7250. "Headphone Playback Volume",
  7251. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7252. HDA_OUTPUT));
  7253. if (err < 0)
  7254. return err;
  7255. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7256. "Headphone Playback Switch",
  7257. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7258. HDA_OUTPUT));
  7259. if (err < 0)
  7260. return err;
  7261. } else {
  7262. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7263. "Headphone Playback Switch",
  7264. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7265. HDA_OUTPUT));
  7266. if (err < 0)
  7267. return err;
  7268. }
  7269. }
  7270. return 0;
  7271. }
  7272. /* identical with ALC880 */
  7273. #define alc262_auto_create_analog_input_ctls \
  7274. alc880_auto_create_analog_input_ctls
  7275. /*
  7276. * generic initialization of ADC, input mixers and output mixers
  7277. */
  7278. static struct hda_verb alc262_volume_init_verbs[] = {
  7279. /*
  7280. * Unmute ADC0-2 and set the default input to mic-in
  7281. */
  7282. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7283. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7284. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7285. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7286. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7287. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7288. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7289. * mixer widget
  7290. * Note: PASD motherboards uses the Line In 2 as the input for
  7291. * front panel mic (mic 2)
  7292. */
  7293. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7294. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7295. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7296. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7297. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7298. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7299. /*
  7300. * Set up output mixers (0x0c - 0x0f)
  7301. */
  7302. /* set vol=0 to output mixers */
  7303. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7304. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7305. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7306. /* set up input amps for analog loopback */
  7307. /* Amp Indices: DAC = 0, mixer = 1 */
  7308. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7309. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7310. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7311. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7312. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7313. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7314. /* FIXME: use matrix-type input source selection */
  7315. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7316. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7317. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7318. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7319. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7320. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7321. /* Input mixer2 */
  7322. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7323. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7324. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7325. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7326. /* Input mixer3 */
  7327. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7328. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7329. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7330. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7331. { }
  7332. };
  7333. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7334. /*
  7335. * Unmute ADC0-2 and set the default input to mic-in
  7336. */
  7337. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7338. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7339. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7340. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7341. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7342. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7343. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7344. * mixer widget
  7345. * Note: PASD motherboards uses the Line In 2 as the input for
  7346. * front panel mic (mic 2)
  7347. */
  7348. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7349. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7350. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7351. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7352. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7353. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7354. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7355. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7356. /*
  7357. * Set up output mixers (0x0c - 0x0e)
  7358. */
  7359. /* set vol=0 to output mixers */
  7360. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7361. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7362. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7363. /* set up input amps for analog loopback */
  7364. /* Amp Indices: DAC = 0, mixer = 1 */
  7365. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7366. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7367. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7368. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7369. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7370. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7371. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7372. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7373. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7374. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7375. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7376. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7377. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7378. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7379. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7380. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7381. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7382. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7383. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7384. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7385. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7386. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7387. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7388. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7389. /* FIXME: use matrix-type input source selection */
  7390. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7391. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7392. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7393. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7394. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7395. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7396. /* Input mixer2 */
  7397. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7398. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7399. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7400. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7401. /* Input mixer3 */
  7402. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7403. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7404. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7405. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7406. { }
  7407. };
  7408. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7409. /*
  7410. * Unmute ADC0-2 and set the default input to mic-in
  7411. */
  7412. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7413. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7414. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7415. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7416. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7417. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7418. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7419. * mixer widget
  7420. * Note: PASD motherboards uses the Line In 2 as the input for front
  7421. * panel mic (mic 2)
  7422. */
  7423. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7424. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7425. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7426. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7427. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7428. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7429. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7430. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7431. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7432. /*
  7433. * Set up output mixers (0x0c - 0x0e)
  7434. */
  7435. /* set vol=0 to output mixers */
  7436. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7437. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7438. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7439. /* set up input amps for analog loopback */
  7440. /* Amp Indices: DAC = 0, mixer = 1 */
  7441. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7442. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7443. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7444. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7445. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7446. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7447. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7448. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7449. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7450. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7451. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7452. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7453. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7454. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7455. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7456. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7457. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7458. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7459. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7460. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7461. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7462. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7463. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7464. /* FIXME: use matrix-type input source selection */
  7465. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7466. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7467. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7468. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7469. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7470. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7471. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7472. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7473. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7474. /* Input mixer2 */
  7475. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7476. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7477. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7478. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7479. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7480. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7481. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7482. /* Input mixer3 */
  7483. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7484. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7485. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7486. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7487. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7488. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7489. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7490. { }
  7491. };
  7492. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7493. #define alc262_loopbacks alc880_loopbacks
  7494. #endif
  7495. /* pcm configuration: identiacal with ALC880 */
  7496. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7497. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7498. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7499. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7500. /*
  7501. * BIOS auto configuration
  7502. */
  7503. static int alc262_parse_auto_config(struct hda_codec *codec)
  7504. {
  7505. struct alc_spec *spec = codec->spec;
  7506. int err;
  7507. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7508. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7509. alc262_ignore);
  7510. if (err < 0)
  7511. return err;
  7512. if (!spec->autocfg.line_outs)
  7513. return 0; /* can't find valid BIOS pin config */
  7514. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7515. if (err < 0)
  7516. return err;
  7517. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7518. if (err < 0)
  7519. return err;
  7520. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7521. if (spec->autocfg.dig_out_pin)
  7522. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7523. if (spec->autocfg.dig_in_pin)
  7524. spec->dig_in_nid = ALC262_DIGIN_NID;
  7525. if (spec->kctl_alloc)
  7526. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7527. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7528. spec->num_mux_defs = 1;
  7529. spec->input_mux = &spec->private_imux;
  7530. err = alc_auto_add_mic_boost(codec);
  7531. if (err < 0)
  7532. return err;
  7533. return 1;
  7534. }
  7535. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7536. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7537. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7538. /* init callback for auto-configuration model -- overriding the default init */
  7539. static void alc262_auto_init(struct hda_codec *codec)
  7540. {
  7541. alc262_auto_init_multi_out(codec);
  7542. alc262_auto_init_hp_out(codec);
  7543. alc262_auto_init_analog_input(codec);
  7544. }
  7545. /*
  7546. * configuration and preset
  7547. */
  7548. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7549. [ALC262_BASIC] = "basic",
  7550. [ALC262_HIPPO] = "hippo",
  7551. [ALC262_HIPPO_1] = "hippo_1",
  7552. [ALC262_FUJITSU] = "fujitsu",
  7553. [ALC262_HP_BPC] = "hp-bpc",
  7554. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7555. [ALC262_BENQ_ED8] = "benq",
  7556. [ALC262_BENQ_T31] = "benq-t31",
  7557. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7558. [ALC262_AUTO] = "auto",
  7559. };
  7560. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7561. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7562. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7563. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7564. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7565. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7566. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7567. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7568. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7569. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7570. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7571. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7572. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7573. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7574. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7575. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7576. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7577. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7578. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7579. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7580. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7581. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7582. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7583. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7584. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7585. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7586. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7587. {}
  7588. };
  7589. static struct alc_config_preset alc262_presets[] = {
  7590. [ALC262_BASIC] = {
  7591. .mixers = { alc262_base_mixer },
  7592. .init_verbs = { alc262_init_verbs },
  7593. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7594. .dac_nids = alc262_dac_nids,
  7595. .hp_nid = 0x03,
  7596. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7597. .channel_mode = alc262_modes,
  7598. .input_mux = &alc262_capture_source,
  7599. },
  7600. [ALC262_HIPPO] = {
  7601. .mixers = { alc262_base_mixer },
  7602. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7603. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7604. .dac_nids = alc262_dac_nids,
  7605. .hp_nid = 0x03,
  7606. .dig_out_nid = ALC262_DIGOUT_NID,
  7607. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7608. .channel_mode = alc262_modes,
  7609. .input_mux = &alc262_capture_source,
  7610. .unsol_event = alc262_hippo_unsol_event,
  7611. .init_hook = alc262_hippo_automute,
  7612. },
  7613. [ALC262_HIPPO_1] = {
  7614. .mixers = { alc262_hippo1_mixer },
  7615. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7616. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7617. .dac_nids = alc262_dac_nids,
  7618. .hp_nid = 0x02,
  7619. .dig_out_nid = ALC262_DIGOUT_NID,
  7620. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7621. .channel_mode = alc262_modes,
  7622. .input_mux = &alc262_capture_source,
  7623. .unsol_event = alc262_hippo1_unsol_event,
  7624. .init_hook = alc262_hippo1_automute,
  7625. },
  7626. [ALC262_FUJITSU] = {
  7627. .mixers = { alc262_fujitsu_mixer },
  7628. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7629. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7630. .dac_nids = alc262_dac_nids,
  7631. .hp_nid = 0x03,
  7632. .dig_out_nid = ALC262_DIGOUT_NID,
  7633. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7634. .channel_mode = alc262_modes,
  7635. .input_mux = &alc262_fujitsu_capture_source,
  7636. .unsol_event = alc262_fujitsu_unsol_event,
  7637. },
  7638. [ALC262_HP_BPC] = {
  7639. .mixers = { alc262_HP_BPC_mixer },
  7640. .init_verbs = { alc262_HP_BPC_init_verbs },
  7641. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7642. .dac_nids = alc262_dac_nids,
  7643. .hp_nid = 0x03,
  7644. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7645. .channel_mode = alc262_modes,
  7646. .input_mux = &alc262_HP_capture_source,
  7647. },
  7648. [ALC262_HP_BPC_D7000_WF] = {
  7649. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7650. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7651. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7652. .dac_nids = alc262_dac_nids,
  7653. .hp_nid = 0x03,
  7654. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7655. .channel_mode = alc262_modes,
  7656. .input_mux = &alc262_HP_D7000_capture_source,
  7657. },
  7658. [ALC262_HP_BPC_D7000_WL] = {
  7659. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7660. alc262_HP_BPC_WildWest_option_mixer },
  7661. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7662. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7663. .dac_nids = alc262_dac_nids,
  7664. .hp_nid = 0x03,
  7665. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7666. .channel_mode = alc262_modes,
  7667. .input_mux = &alc262_HP_D7000_capture_source,
  7668. },
  7669. [ALC262_BENQ_ED8] = {
  7670. .mixers = { alc262_base_mixer },
  7671. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7672. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7673. .dac_nids = alc262_dac_nids,
  7674. .hp_nid = 0x03,
  7675. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7676. .channel_mode = alc262_modes,
  7677. .input_mux = &alc262_capture_source,
  7678. },
  7679. [ALC262_SONY_ASSAMD] = {
  7680. .mixers = { alc262_sony_mixer },
  7681. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7682. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7683. .dac_nids = alc262_dac_nids,
  7684. .hp_nid = 0x02,
  7685. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7686. .channel_mode = alc262_modes,
  7687. .input_mux = &alc262_capture_source,
  7688. .unsol_event = alc262_hippo_unsol_event,
  7689. .init_hook = alc262_hippo_automute,
  7690. },
  7691. [ALC262_BENQ_T31] = {
  7692. .mixers = { alc262_benq_t31_mixer },
  7693. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7694. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7695. .dac_nids = alc262_dac_nids,
  7696. .hp_nid = 0x03,
  7697. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7698. .channel_mode = alc262_modes,
  7699. .input_mux = &alc262_capture_source,
  7700. .unsol_event = alc262_hippo_unsol_event,
  7701. .init_hook = alc262_hippo_automute,
  7702. },
  7703. };
  7704. static int patch_alc262(struct hda_codec *codec)
  7705. {
  7706. struct alc_spec *spec;
  7707. int board_config;
  7708. int err;
  7709. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7710. if (spec == NULL)
  7711. return -ENOMEM;
  7712. codec->spec = spec;
  7713. #if 0
  7714. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7715. * under-run
  7716. */
  7717. {
  7718. int tmp;
  7719. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7720. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7721. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7722. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7723. }
  7724. #endif
  7725. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7726. alc262_models,
  7727. alc262_cfg_tbl);
  7728. if (board_config < 0) {
  7729. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7730. "trying auto-probe from BIOS...\n");
  7731. board_config = ALC262_AUTO;
  7732. }
  7733. if (board_config == ALC262_AUTO) {
  7734. /* automatic parse from the BIOS config */
  7735. err = alc262_parse_auto_config(codec);
  7736. if (err < 0) {
  7737. alc_free(codec);
  7738. return err;
  7739. } else if (!err) {
  7740. printk(KERN_INFO
  7741. "hda_codec: Cannot set up configuration "
  7742. "from BIOS. Using base mode...\n");
  7743. board_config = ALC262_BASIC;
  7744. }
  7745. }
  7746. if (board_config != ALC262_AUTO)
  7747. setup_preset(spec, &alc262_presets[board_config]);
  7748. spec->stream_name_analog = "ALC262 Analog";
  7749. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7750. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7751. spec->stream_name_digital = "ALC262 Digital";
  7752. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7753. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7754. if (!spec->adc_nids && spec->input_mux) {
  7755. /* check whether NID 0x07 is valid */
  7756. unsigned int wcap = get_wcaps(codec, 0x07);
  7757. /* get type */
  7758. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7759. if (wcap != AC_WID_AUD_IN) {
  7760. spec->adc_nids = alc262_adc_nids_alt;
  7761. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7762. spec->mixers[spec->num_mixers] =
  7763. alc262_capture_alt_mixer;
  7764. spec->num_mixers++;
  7765. } else {
  7766. spec->adc_nids = alc262_adc_nids;
  7767. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7768. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7769. spec->num_mixers++;
  7770. }
  7771. }
  7772. codec->patch_ops = alc_patch_ops;
  7773. if (board_config == ALC262_AUTO)
  7774. spec->init_hook = alc262_auto_init;
  7775. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7776. if (!spec->loopback.amplist)
  7777. spec->loopback.amplist = alc262_loopbacks;
  7778. #endif
  7779. return 0;
  7780. }
  7781. /*
  7782. * ALC268 channel source setting (2 channel)
  7783. */
  7784. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7785. #define alc268_modes alc260_modes
  7786. static hda_nid_t alc268_dac_nids[2] = {
  7787. /* front, hp */
  7788. 0x02, 0x03
  7789. };
  7790. static hda_nid_t alc268_adc_nids[2] = {
  7791. /* ADC0-1 */
  7792. 0x08, 0x07
  7793. };
  7794. static hda_nid_t alc268_adc_nids_alt[1] = {
  7795. /* ADC0 */
  7796. 0x08
  7797. };
  7798. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7799. /* output mixer control */
  7800. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7801. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7802. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7803. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7804. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7805. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7806. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7807. { }
  7808. };
  7809. static struct hda_verb alc268_eapd_verbs[] = {
  7810. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7811. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7812. { }
  7813. };
  7814. /* Toshiba specific */
  7815. #define alc268_toshiba_automute alc262_hippo_automute
  7816. static struct hda_verb alc268_toshiba_verbs[] = {
  7817. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7818. { } /* end */
  7819. };
  7820. /* Acer specific */
  7821. /* bind volumes of both NID 0x02 and 0x03 */
  7822. static struct hda_bind_ctls alc268_acer_bind_master_vol = {
  7823. .ops = &snd_hda_bind_vol,
  7824. .values = {
  7825. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  7826. HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
  7827. 0
  7828. },
  7829. };
  7830. /* mute/unmute internal speaker according to the hp jack and mute state */
  7831. static void alc268_acer_automute(struct hda_codec *codec, int force)
  7832. {
  7833. struct alc_spec *spec = codec->spec;
  7834. unsigned int mute;
  7835. if (force || !spec->sense_updated) {
  7836. unsigned int present;
  7837. present = snd_hda_codec_read(codec, 0x14, 0,
  7838. AC_VERB_GET_PIN_SENSE, 0);
  7839. spec->jack_present = (present & 0x80000000) != 0;
  7840. spec->sense_updated = 1;
  7841. }
  7842. if (spec->jack_present)
  7843. mute = HDA_AMP_MUTE; /* mute internal speaker */
  7844. else /* unmute internal speaker if necessary */
  7845. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7846. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7847. HDA_AMP_MUTE, mute);
  7848. }
  7849. /* bind hp and internal speaker mute (with plug check) */
  7850. static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
  7851. struct snd_ctl_elem_value *ucontrol)
  7852. {
  7853. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7854. long *valp = ucontrol->value.integer.value;
  7855. int change;
  7856. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7857. HDA_AMP_MUTE,
  7858. valp[0] ? 0 : HDA_AMP_MUTE);
  7859. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7860. HDA_AMP_MUTE,
  7861. valp[1] ? 0 : HDA_AMP_MUTE);
  7862. if (change)
  7863. alc268_acer_automute(codec, 0);
  7864. return change;
  7865. }
  7866. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  7867. /* output mixer control */
  7868. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  7869. {
  7870. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7871. .name = "Master Playback Switch",
  7872. .info = snd_hda_mixer_amp_switch_info,
  7873. .get = snd_hda_mixer_amp_switch_get,
  7874. .put = alc268_acer_master_sw_put,
  7875. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7876. },
  7877. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7878. HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
  7879. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7880. { }
  7881. };
  7882. static struct hda_verb alc268_acer_verbs[] = {
  7883. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7884. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7885. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7886. { }
  7887. };
  7888. /* unsolicited event for HP jack sensing */
  7889. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  7890. unsigned int res)
  7891. {
  7892. if ((res >> 26) != ALC880_HP_EVENT)
  7893. return;
  7894. alc268_toshiba_automute(codec);
  7895. }
  7896. static void alc268_acer_unsol_event(struct hda_codec *codec,
  7897. unsigned int res)
  7898. {
  7899. if ((res >> 26) != ALC880_HP_EVENT)
  7900. return;
  7901. alc268_acer_automute(codec, 1);
  7902. }
  7903. static void alc268_acer_init_hook(struct hda_codec *codec)
  7904. {
  7905. alc268_acer_automute(codec, 1);
  7906. }
  7907. /*
  7908. * generic initialization of ADC, input mixers and output mixers
  7909. */
  7910. static struct hda_verb alc268_base_init_verbs[] = {
  7911. /* Unmute DAC0-1 and set vol = 0 */
  7912. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7913. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7914. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7915. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7916. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7917. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7918. /*
  7919. * Set up output mixers (0x0c - 0x0e)
  7920. */
  7921. /* set vol=0 to output mixers */
  7922. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7923. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7924. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7925. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7926. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7927. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7928. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7929. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7930. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7931. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7932. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7933. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7934. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7935. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7936. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7937. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7938. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7939. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7940. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7941. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7942. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7943. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7944. /* FIXME: use matrix-type input source selection */
  7945. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7946. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7947. /* Input mixer2 */
  7948. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7949. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7950. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7951. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7952. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7953. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7954. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7955. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7956. { }
  7957. };
  7958. /*
  7959. * generic initialization of ADC, input mixers and output mixers
  7960. */
  7961. static struct hda_verb alc268_volume_init_verbs[] = {
  7962. /* set output DAC */
  7963. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7964. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7965. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7966. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7967. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7968. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7969. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7970. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7971. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7972. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7973. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7974. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7975. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7976. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7977. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7978. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7979. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7980. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7981. /* set PCBEEP vol = 0 */
  7982. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7983. { }
  7984. };
  7985. #define alc268_mux_enum_info alc_mux_enum_info
  7986. #define alc268_mux_enum_get alc_mux_enum_get
  7987. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7988. struct snd_ctl_elem_value *ucontrol)
  7989. {
  7990. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7991. struct alc_spec *spec = codec->spec;
  7992. const struct hda_input_mux *imux = spec->input_mux;
  7993. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7994. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7995. hda_nid_t nid = capture_mixers[adc_idx];
  7996. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7997. unsigned int i, idx;
  7998. idx = ucontrol->value.enumerated.item[0];
  7999. if (idx >= imux->num_items)
  8000. idx = imux->num_items - 1;
  8001. if (*cur_val == idx)
  8002. return 0;
  8003. for (i = 0; i < imux->num_items; i++) {
  8004. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  8005. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  8006. imux->items[i].index,
  8007. HDA_AMP_MUTE, v);
  8008. snd_hda_codec_write_cache(codec, nid, 0,
  8009. AC_VERB_SET_CONNECT_SEL,
  8010. idx );
  8011. }
  8012. *cur_val = idx;
  8013. return 1;
  8014. }
  8015. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  8016. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8017. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8018. {
  8019. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8020. /* The multiple "Capture Source" controls confuse alsamixer
  8021. * So call somewhat different..
  8022. * FIXME: the controls appear in the "playback" view!
  8023. */
  8024. /* .name = "Capture Source", */
  8025. .name = "Input Source",
  8026. .count = 1,
  8027. .info = alc268_mux_enum_info,
  8028. .get = alc268_mux_enum_get,
  8029. .put = alc268_mux_enum_put,
  8030. },
  8031. { } /* end */
  8032. };
  8033. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  8034. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8035. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8036. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  8037. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  8038. {
  8039. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8040. /* The multiple "Capture Source" controls confuse alsamixer
  8041. * So call somewhat different..
  8042. * FIXME: the controls appear in the "playback" view!
  8043. */
  8044. /* .name = "Capture Source", */
  8045. .name = "Input Source",
  8046. .count = 2,
  8047. .info = alc268_mux_enum_info,
  8048. .get = alc268_mux_enum_get,
  8049. .put = alc268_mux_enum_put,
  8050. },
  8051. { } /* end */
  8052. };
  8053. static struct hda_input_mux alc268_capture_source = {
  8054. .num_items = 4,
  8055. .items = {
  8056. { "Mic", 0x0 },
  8057. { "Front Mic", 0x1 },
  8058. { "Line", 0x2 },
  8059. { "CD", 0x3 },
  8060. },
  8061. };
  8062. /* create input playback/capture controls for the given pin */
  8063. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  8064. const char *ctlname, int idx)
  8065. {
  8066. char name[32];
  8067. int err;
  8068. sprintf(name, "%s Playback Volume", ctlname);
  8069. if (nid == 0x14) {
  8070. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8071. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  8072. HDA_OUTPUT));
  8073. if (err < 0)
  8074. return err;
  8075. } else if (nid == 0x15) {
  8076. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8077. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  8078. HDA_OUTPUT));
  8079. if (err < 0)
  8080. return err;
  8081. } else
  8082. return -1;
  8083. sprintf(name, "%s Playback Switch", ctlname);
  8084. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8085. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  8086. if (err < 0)
  8087. return err;
  8088. return 0;
  8089. }
  8090. /* add playback controls from the parsed DAC table */
  8091. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  8092. const struct auto_pin_cfg *cfg)
  8093. {
  8094. hda_nid_t nid;
  8095. int err;
  8096. spec->multiout.num_dacs = 2; /* only use one dac */
  8097. spec->multiout.dac_nids = spec->private_dac_nids;
  8098. spec->multiout.dac_nids[0] = 2;
  8099. spec->multiout.dac_nids[1] = 3;
  8100. nid = cfg->line_out_pins[0];
  8101. if (nid)
  8102. alc268_new_analog_output(spec, nid, "Front", 0);
  8103. nid = cfg->speaker_pins[0];
  8104. if (nid == 0x1d) {
  8105. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8106. "Speaker Playback Volume",
  8107. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  8108. if (err < 0)
  8109. return err;
  8110. }
  8111. nid = cfg->hp_pins[0];
  8112. if (nid)
  8113. alc268_new_analog_output(spec, nid, "Headphone", 0);
  8114. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  8115. if (nid == 0x16) {
  8116. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8117. "Mono Playback Switch",
  8118. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  8119. if (err < 0)
  8120. return err;
  8121. }
  8122. return 0;
  8123. }
  8124. /* create playback/capture controls for input pins */
  8125. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  8126. const struct auto_pin_cfg *cfg)
  8127. {
  8128. struct hda_input_mux *imux = &spec->private_imux;
  8129. int i, idx1;
  8130. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8131. switch(cfg->input_pins[i]) {
  8132. case 0x18:
  8133. idx1 = 0; /* Mic 1 */
  8134. break;
  8135. case 0x19:
  8136. idx1 = 1; /* Mic 2 */
  8137. break;
  8138. case 0x1a:
  8139. idx1 = 2; /* Line In */
  8140. break;
  8141. case 0x1c:
  8142. idx1 = 3; /* CD */
  8143. break;
  8144. default:
  8145. continue;
  8146. }
  8147. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8148. imux->items[imux->num_items].index = idx1;
  8149. imux->num_items++;
  8150. }
  8151. return 0;
  8152. }
  8153. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  8154. {
  8155. struct alc_spec *spec = codec->spec;
  8156. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  8157. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  8158. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  8159. unsigned int dac_vol1, dac_vol2;
  8160. if (speaker_nid) {
  8161. snd_hda_codec_write(codec, speaker_nid, 0,
  8162. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  8163. snd_hda_codec_write(codec, 0x0f, 0,
  8164. AC_VERB_SET_AMP_GAIN_MUTE,
  8165. AMP_IN_UNMUTE(1));
  8166. snd_hda_codec_write(codec, 0x10, 0,
  8167. AC_VERB_SET_AMP_GAIN_MUTE,
  8168. AMP_IN_UNMUTE(1));
  8169. } else {
  8170. snd_hda_codec_write(codec, 0x0f, 0,
  8171. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8172. snd_hda_codec_write(codec, 0x10, 0,
  8173. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8174. }
  8175. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  8176. if (line_nid == 0x14)
  8177. dac_vol2 = AMP_OUT_ZERO;
  8178. else if (line_nid == 0x15)
  8179. dac_vol1 = AMP_OUT_ZERO;
  8180. if (hp_nid == 0x14)
  8181. dac_vol2 = AMP_OUT_ZERO;
  8182. else if (hp_nid == 0x15)
  8183. dac_vol1 = AMP_OUT_ZERO;
  8184. if (line_nid != 0x16 || hp_nid != 0x16 ||
  8185. spec->autocfg.line_out_pins[1] != 0x16 ||
  8186. spec->autocfg.line_out_pins[2] != 0x16)
  8187. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  8188. snd_hda_codec_write(codec, 0x02, 0,
  8189. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  8190. snd_hda_codec_write(codec, 0x03, 0,
  8191. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  8192. }
  8193. /* pcm configuration: identiacal with ALC880 */
  8194. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  8195. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  8196. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  8197. /*
  8198. * BIOS auto configuration
  8199. */
  8200. static int alc268_parse_auto_config(struct hda_codec *codec)
  8201. {
  8202. struct alc_spec *spec = codec->spec;
  8203. int err;
  8204. static hda_nid_t alc268_ignore[] = { 0 };
  8205. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8206. alc268_ignore);
  8207. if (err < 0)
  8208. return err;
  8209. if (!spec->autocfg.line_outs)
  8210. return 0; /* can't find valid BIOS pin config */
  8211. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8212. if (err < 0)
  8213. return err;
  8214. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8215. if (err < 0)
  8216. return err;
  8217. spec->multiout.max_channels = 2;
  8218. /* digital only support output */
  8219. if (spec->autocfg.dig_out_pin)
  8220. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  8221. if (spec->kctl_alloc)
  8222. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8223. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  8224. spec->num_mux_defs = 1;
  8225. spec->input_mux = &spec->private_imux;
  8226. err = alc_auto_add_mic_boost(codec);
  8227. if (err < 0)
  8228. return err;
  8229. return 1;
  8230. }
  8231. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  8232. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  8233. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  8234. /* init callback for auto-configuration model -- overriding the default init */
  8235. static void alc268_auto_init(struct hda_codec *codec)
  8236. {
  8237. alc268_auto_init_multi_out(codec);
  8238. alc268_auto_init_hp_out(codec);
  8239. alc268_auto_init_mono_speaker_out(codec);
  8240. alc268_auto_init_analog_input(codec);
  8241. }
  8242. /*
  8243. * configuration and preset
  8244. */
  8245. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8246. [ALC268_3ST] = "3stack",
  8247. [ALC268_TOSHIBA] = "toshiba",
  8248. [ALC268_ACER] = "acer",
  8249. [ALC268_AUTO] = "auto",
  8250. };
  8251. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8252. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8253. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8254. SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
  8255. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8256. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8257. SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
  8258. SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
  8259. {}
  8260. };
  8261. static struct alc_config_preset alc268_presets[] = {
  8262. [ALC268_3ST] = {
  8263. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8264. .init_verbs = { alc268_base_init_verbs },
  8265. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8266. .dac_nids = alc268_dac_nids,
  8267. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8268. .adc_nids = alc268_adc_nids_alt,
  8269. .hp_nid = 0x03,
  8270. .dig_out_nid = ALC268_DIGOUT_NID,
  8271. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8272. .channel_mode = alc268_modes,
  8273. .input_mux = &alc268_capture_source,
  8274. },
  8275. [ALC268_TOSHIBA] = {
  8276. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8277. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8278. alc268_toshiba_verbs },
  8279. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8280. .dac_nids = alc268_dac_nids,
  8281. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8282. .adc_nids = alc268_adc_nids_alt,
  8283. .hp_nid = 0x03,
  8284. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8285. .channel_mode = alc268_modes,
  8286. .input_mux = &alc268_capture_source,
  8287. .input_mux = &alc268_capture_source,
  8288. .unsol_event = alc268_toshiba_unsol_event,
  8289. .init_hook = alc268_toshiba_automute,
  8290. },
  8291. [ALC268_ACER] = {
  8292. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8293. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8294. alc268_acer_verbs },
  8295. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8296. .dac_nids = alc268_dac_nids,
  8297. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8298. .adc_nids = alc268_adc_nids_alt,
  8299. .hp_nid = 0x02,
  8300. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8301. .channel_mode = alc268_modes,
  8302. .input_mux = &alc268_capture_source,
  8303. .unsol_event = alc268_acer_unsol_event,
  8304. .init_hook = alc268_acer_init_hook,
  8305. },
  8306. };
  8307. static int patch_alc268(struct hda_codec *codec)
  8308. {
  8309. struct alc_spec *spec;
  8310. int board_config;
  8311. int err;
  8312. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8313. if (spec == NULL)
  8314. return -ENOMEM;
  8315. codec->spec = spec;
  8316. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8317. alc268_models,
  8318. alc268_cfg_tbl);
  8319. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8320. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8321. "trying auto-probe from BIOS...\n");
  8322. board_config = ALC268_AUTO;
  8323. }
  8324. if (board_config == ALC268_AUTO) {
  8325. /* automatic parse from the BIOS config */
  8326. err = alc268_parse_auto_config(codec);
  8327. if (err < 0) {
  8328. alc_free(codec);
  8329. return err;
  8330. } else if (!err) {
  8331. printk(KERN_INFO
  8332. "hda_codec: Cannot set up configuration "
  8333. "from BIOS. Using base mode...\n");
  8334. board_config = ALC268_3ST;
  8335. }
  8336. }
  8337. if (board_config != ALC268_AUTO)
  8338. setup_preset(spec, &alc268_presets[board_config]);
  8339. spec->stream_name_analog = "ALC268 Analog";
  8340. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8341. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8342. spec->stream_name_digital = "ALC268 Digital";
  8343. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8344. if (board_config == ALC268_AUTO) {
  8345. if (!spec->adc_nids && spec->input_mux) {
  8346. /* check whether NID 0x07 is valid */
  8347. unsigned int wcap = get_wcaps(codec, 0x07);
  8348. /* get type */
  8349. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8350. if (wcap != AC_WID_AUD_IN) {
  8351. spec->adc_nids = alc268_adc_nids_alt;
  8352. spec->num_adc_nids =
  8353. ARRAY_SIZE(alc268_adc_nids_alt);
  8354. spec->mixers[spec->num_mixers] =
  8355. alc268_capture_alt_mixer;
  8356. spec->num_mixers++;
  8357. } else {
  8358. spec->adc_nids = alc268_adc_nids;
  8359. spec->num_adc_nids =
  8360. ARRAY_SIZE(alc268_adc_nids);
  8361. spec->mixers[spec->num_mixers] =
  8362. alc268_capture_mixer;
  8363. spec->num_mixers++;
  8364. }
  8365. }
  8366. }
  8367. codec->patch_ops = alc_patch_ops;
  8368. if (board_config == ALC268_AUTO)
  8369. spec->init_hook = alc268_auto_init;
  8370. return 0;
  8371. }
  8372. /*
  8373. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8374. */
  8375. /*
  8376. * set the path ways for 2 channel output
  8377. * need to set the codec line out and mic 1 pin widgets to inputs
  8378. */
  8379. static struct hda_verb alc861_threestack_ch2_init[] = {
  8380. /* set pin widget 1Ah (line in) for input */
  8381. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8382. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8383. * the vref
  8384. */
  8385. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8386. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8387. #if 0
  8388. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8389. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8390. #endif
  8391. { } /* end */
  8392. };
  8393. /*
  8394. * 6ch mode
  8395. * need to set the codec line out and mic 1 pin widgets to outputs
  8396. */
  8397. static struct hda_verb alc861_threestack_ch6_init[] = {
  8398. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8399. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8400. /* set pin widget 18h (mic1) for output (CLFE)*/
  8401. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8402. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8403. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8404. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8405. #if 0
  8406. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8407. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8408. #endif
  8409. { } /* end */
  8410. };
  8411. static struct hda_channel_mode alc861_threestack_modes[2] = {
  8412. { 2, alc861_threestack_ch2_init },
  8413. { 6, alc861_threestack_ch6_init },
  8414. };
  8415. /* Set mic1 as input and unmute the mixer */
  8416. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  8417. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8418. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8419. { } /* end */
  8420. };
  8421. /* Set mic1 as output and mute mixer */
  8422. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  8423. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8424. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8425. { } /* end */
  8426. };
  8427. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  8428. { 2, alc861_uniwill_m31_ch2_init },
  8429. { 4, alc861_uniwill_m31_ch4_init },
  8430. };
  8431. /* Set mic1 and line-in as input and unmute the mixer */
  8432. static struct hda_verb alc861_asus_ch2_init[] = {
  8433. /* set pin widget 1Ah (line in) for input */
  8434. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8435. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8436. * the vref
  8437. */
  8438. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8439. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8440. #if 0
  8441. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8442. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8443. #endif
  8444. { } /* end */
  8445. };
  8446. /* Set mic1 nad line-in as output and mute mixer */
  8447. static struct hda_verb alc861_asus_ch6_init[] = {
  8448. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8449. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8450. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8451. /* set pin widget 18h (mic1) for output (CLFE)*/
  8452. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8453. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8454. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8455. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8456. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8457. #if 0
  8458. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8459. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8460. #endif
  8461. { } /* end */
  8462. };
  8463. static struct hda_channel_mode alc861_asus_modes[2] = {
  8464. { 2, alc861_asus_ch2_init },
  8465. { 6, alc861_asus_ch6_init },
  8466. };
  8467. /* patch-ALC861 */
  8468. static struct snd_kcontrol_new alc861_base_mixer[] = {
  8469. /* output mixer control */
  8470. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8471. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8472. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8473. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8474. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8475. /*Input mixer control */
  8476. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8477. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8478. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8479. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8480. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8481. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8482. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8483. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8484. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8485. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8486. /* Capture mixer control */
  8487. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8488. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8489. {
  8490. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8491. .name = "Capture Source",
  8492. .count = 1,
  8493. .info = alc_mux_enum_info,
  8494. .get = alc_mux_enum_get,
  8495. .put = alc_mux_enum_put,
  8496. },
  8497. { } /* end */
  8498. };
  8499. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8500. /* output mixer control */
  8501. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8502. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8503. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8504. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8505. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8506. /* Input mixer control */
  8507. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8508. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8509. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8510. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8511. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8512. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8513. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8514. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8515. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8516. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8517. /* Capture mixer control */
  8518. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8519. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8520. {
  8521. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8522. .name = "Capture Source",
  8523. .count = 1,
  8524. .info = alc_mux_enum_info,
  8525. .get = alc_mux_enum_get,
  8526. .put = alc_mux_enum_put,
  8527. },
  8528. {
  8529. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8530. .name = "Channel Mode",
  8531. .info = alc_ch_mode_info,
  8532. .get = alc_ch_mode_get,
  8533. .put = alc_ch_mode_put,
  8534. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8535. },
  8536. { } /* end */
  8537. };
  8538. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8539. /* output mixer control */
  8540. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8541. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8542. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8543. /*Capture mixer control */
  8544. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8545. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8546. {
  8547. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8548. .name = "Capture Source",
  8549. .count = 1,
  8550. .info = alc_mux_enum_info,
  8551. .get = alc_mux_enum_get,
  8552. .put = alc_mux_enum_put,
  8553. },
  8554. { } /* end */
  8555. };
  8556. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8557. /* output mixer control */
  8558. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8559. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8560. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8561. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8562. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8563. /* Input mixer control */
  8564. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8565. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8566. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8567. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8568. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8569. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8570. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8571. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8572. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8573. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8574. /* Capture mixer control */
  8575. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8576. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8577. {
  8578. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8579. .name = "Capture Source",
  8580. .count = 1,
  8581. .info = alc_mux_enum_info,
  8582. .get = alc_mux_enum_get,
  8583. .put = alc_mux_enum_put,
  8584. },
  8585. {
  8586. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8587. .name = "Channel Mode",
  8588. .info = alc_ch_mode_info,
  8589. .get = alc_ch_mode_get,
  8590. .put = alc_ch_mode_put,
  8591. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8592. },
  8593. { } /* end */
  8594. };
  8595. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8596. /* output mixer control */
  8597. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8598. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8599. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8600. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8601. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8602. /* Input mixer control */
  8603. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8604. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8605. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8606. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8607. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8608. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8609. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8610. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8611. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8612. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8613. /* Capture mixer control */
  8614. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8615. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8616. {
  8617. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8618. .name = "Capture Source",
  8619. .count = 1,
  8620. .info = alc_mux_enum_info,
  8621. .get = alc_mux_enum_get,
  8622. .put = alc_mux_enum_put,
  8623. },
  8624. {
  8625. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8626. .name = "Channel Mode",
  8627. .info = alc_ch_mode_info,
  8628. .get = alc_ch_mode_get,
  8629. .put = alc_ch_mode_put,
  8630. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8631. },
  8632. { }
  8633. };
  8634. /* additional mixer */
  8635. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8636. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8637. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8638. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8639. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8640. { }
  8641. };
  8642. /*
  8643. * generic initialization of ADC, input mixers and output mixers
  8644. */
  8645. static struct hda_verb alc861_base_init_verbs[] = {
  8646. /*
  8647. * Unmute ADC0 and set the default input to mic-in
  8648. */
  8649. /* port-A for surround (rear panel) */
  8650. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8651. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8652. /* port-B for mic-in (rear panel) with vref */
  8653. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8654. /* port-C for line-in (rear panel) */
  8655. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8656. /* port-D for Front */
  8657. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8658. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8659. /* port-E for HP out (front panel) */
  8660. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8661. /* route front PCM to HP */
  8662. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8663. /* port-F for mic-in (front panel) with vref */
  8664. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8665. /* port-G for CLFE (rear panel) */
  8666. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8667. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8668. /* port-H for side (rear panel) */
  8669. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8670. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8671. /* CD-in */
  8672. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8673. /* route front mic to ADC1*/
  8674. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8675. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8676. /* Unmute DAC0~3 & spdif out*/
  8677. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8678. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8679. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8680. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8681. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8682. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8683. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8684. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8685. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8686. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8687. /* Unmute Stereo Mixer 15 */
  8688. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8689. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8690. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8691. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8692. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8693. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8694. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8695. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8696. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8697. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8698. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8699. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8700. /* hp used DAC 3 (Front) */
  8701. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8702. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8703. { }
  8704. };
  8705. static struct hda_verb alc861_threestack_init_verbs[] = {
  8706. /*
  8707. * Unmute ADC0 and set the default input to mic-in
  8708. */
  8709. /* port-A for surround (rear panel) */
  8710. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8711. /* port-B for mic-in (rear panel) with vref */
  8712. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8713. /* port-C for line-in (rear panel) */
  8714. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8715. /* port-D for Front */
  8716. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8717. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8718. /* port-E for HP out (front panel) */
  8719. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8720. /* route front PCM to HP */
  8721. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8722. /* port-F for mic-in (front panel) with vref */
  8723. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8724. /* port-G for CLFE (rear panel) */
  8725. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8726. /* port-H for side (rear panel) */
  8727. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8728. /* CD-in */
  8729. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8730. /* route front mic to ADC1*/
  8731. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8732. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8733. /* Unmute DAC0~3 & spdif out*/
  8734. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8735. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8736. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8737. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8738. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8739. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8740. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8741. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8742. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8743. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8744. /* Unmute Stereo Mixer 15 */
  8745. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8746. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8747. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8748. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8749. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8750. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8751. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8752. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8753. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8754. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8755. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8756. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8757. /* hp used DAC 3 (Front) */
  8758. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8759. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8760. { }
  8761. };
  8762. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8763. /*
  8764. * Unmute ADC0 and set the default input to mic-in
  8765. */
  8766. /* port-A for surround (rear panel) */
  8767. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8768. /* port-B for mic-in (rear panel) with vref */
  8769. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8770. /* port-C for line-in (rear panel) */
  8771. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8772. /* port-D for Front */
  8773. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8774. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8775. /* port-E for HP out (front panel) */
  8776. /* this has to be set to VREF80 */
  8777. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8778. /* route front PCM to HP */
  8779. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8780. /* port-F for mic-in (front panel) with vref */
  8781. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8782. /* port-G for CLFE (rear panel) */
  8783. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8784. /* port-H for side (rear panel) */
  8785. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8786. /* CD-in */
  8787. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8788. /* route front mic to ADC1*/
  8789. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8790. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8791. /* Unmute DAC0~3 & spdif out*/
  8792. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8793. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8794. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8795. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8796. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8797. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8798. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8799. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8800. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8801. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8802. /* Unmute Stereo Mixer 15 */
  8803. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8804. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8805. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8806. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8807. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8808. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8809. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8810. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8811. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8812. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8813. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8814. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8815. /* hp used DAC 3 (Front) */
  8816. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8817. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8818. { }
  8819. };
  8820. static struct hda_verb alc861_asus_init_verbs[] = {
  8821. /*
  8822. * Unmute ADC0 and set the default input to mic-in
  8823. */
  8824. /* port-A for surround (rear panel)
  8825. * according to codec#0 this is the HP jack
  8826. */
  8827. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8828. /* route front PCM to HP */
  8829. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8830. /* port-B for mic-in (rear panel) with vref */
  8831. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8832. /* port-C for line-in (rear panel) */
  8833. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8834. /* port-D for Front */
  8835. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8836. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8837. /* port-E for HP out (front panel) */
  8838. /* this has to be set to VREF80 */
  8839. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8840. /* route front PCM to HP */
  8841. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8842. /* port-F for mic-in (front panel) with vref */
  8843. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8844. /* port-G for CLFE (rear panel) */
  8845. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8846. /* port-H for side (rear panel) */
  8847. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8848. /* CD-in */
  8849. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8850. /* route front mic to ADC1*/
  8851. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8852. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8853. /* Unmute DAC0~3 & spdif out*/
  8854. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8855. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8856. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8857. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8858. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8859. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8860. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8861. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8862. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8863. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8864. /* Unmute Stereo Mixer 15 */
  8865. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8866. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8867. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8868. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8869. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8870. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8871. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8872. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8873. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8874. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8875. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8876. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8877. /* hp used DAC 3 (Front) */
  8878. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8879. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8880. { }
  8881. };
  8882. /* additional init verbs for ASUS laptops */
  8883. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8884. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8885. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8886. { }
  8887. };
  8888. /*
  8889. * generic initialization of ADC, input mixers and output mixers
  8890. */
  8891. static struct hda_verb alc861_auto_init_verbs[] = {
  8892. /*
  8893. * Unmute ADC0 and set the default input to mic-in
  8894. */
  8895. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8896. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8897. /* Unmute DAC0~3 & spdif out*/
  8898. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8899. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8900. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8901. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8902. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8903. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8904. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8905. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8906. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8907. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8908. /* Unmute Stereo Mixer 15 */
  8909. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8910. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8911. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8912. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8913. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8914. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8915. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8916. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8917. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8918. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8919. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8920. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8921. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8922. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8923. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8924. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8925. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8926. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8927. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8928. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8929. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8930. { }
  8931. };
  8932. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8933. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8934. { }
  8935. };
  8936. /* toggle speaker-output according to the hp-jack state */
  8937. static void alc861_toshiba_automute(struct hda_codec *codec)
  8938. {
  8939. unsigned int present;
  8940. present = snd_hda_codec_read(codec, 0x0f, 0,
  8941. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8942. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  8943. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  8944. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  8945. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  8946. }
  8947. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8948. unsigned int res)
  8949. {
  8950. if ((res >> 26) == ALC880_HP_EVENT)
  8951. alc861_toshiba_automute(codec);
  8952. }
  8953. /* pcm configuration: identiacal with ALC880 */
  8954. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8955. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8956. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8957. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8958. #define ALC861_DIGOUT_NID 0x07
  8959. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8960. { 8, NULL }
  8961. };
  8962. static hda_nid_t alc861_dac_nids[4] = {
  8963. /* front, surround, clfe, side */
  8964. 0x03, 0x06, 0x05, 0x04
  8965. };
  8966. static hda_nid_t alc660_dac_nids[3] = {
  8967. /* front, clfe, surround */
  8968. 0x03, 0x05, 0x06
  8969. };
  8970. static hda_nid_t alc861_adc_nids[1] = {
  8971. /* ADC0-2 */
  8972. 0x08,
  8973. };
  8974. static struct hda_input_mux alc861_capture_source = {
  8975. .num_items = 5,
  8976. .items = {
  8977. { "Mic", 0x0 },
  8978. { "Front Mic", 0x3 },
  8979. { "Line", 0x1 },
  8980. { "CD", 0x4 },
  8981. { "Mixer", 0x5 },
  8982. },
  8983. };
  8984. /* fill in the dac_nids table from the parsed pin configuration */
  8985. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8986. const struct auto_pin_cfg *cfg)
  8987. {
  8988. int i;
  8989. hda_nid_t nid;
  8990. spec->multiout.dac_nids = spec->private_dac_nids;
  8991. for (i = 0; i < cfg->line_outs; i++) {
  8992. nid = cfg->line_out_pins[i];
  8993. if (nid) {
  8994. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8995. continue;
  8996. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8997. }
  8998. }
  8999. spec->multiout.num_dacs = cfg->line_outs;
  9000. return 0;
  9001. }
  9002. /* add playback controls from the parsed DAC table */
  9003. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  9004. const struct auto_pin_cfg *cfg)
  9005. {
  9006. char name[32];
  9007. static const char *chname[4] = {
  9008. "Front", "Surround", NULL /*CLFE*/, "Side"
  9009. };
  9010. hda_nid_t nid;
  9011. int i, idx, err;
  9012. for (i = 0; i < cfg->line_outs; i++) {
  9013. nid = spec->multiout.dac_nids[i];
  9014. if (!nid)
  9015. continue;
  9016. if (nid == 0x05) {
  9017. /* Center/LFE */
  9018. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9019. "Center Playback Switch",
  9020. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9021. HDA_OUTPUT));
  9022. if (err < 0)
  9023. return err;
  9024. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9025. "LFE Playback Switch",
  9026. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9027. HDA_OUTPUT));
  9028. if (err < 0)
  9029. return err;
  9030. } else {
  9031. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  9032. idx++)
  9033. if (nid == alc861_dac_nids[idx])
  9034. break;
  9035. sprintf(name, "%s Playback Switch", chname[idx]);
  9036. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9037. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9038. HDA_OUTPUT));
  9039. if (err < 0)
  9040. return err;
  9041. }
  9042. }
  9043. return 0;
  9044. }
  9045. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  9046. {
  9047. int err;
  9048. hda_nid_t nid;
  9049. if (!pin)
  9050. return 0;
  9051. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  9052. nid = 0x03;
  9053. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  9054. "Headphone Playback Switch",
  9055. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9056. if (err < 0)
  9057. return err;
  9058. spec->multiout.hp_nid = nid;
  9059. }
  9060. return 0;
  9061. }
  9062. /* create playback/capture controls for input pins */
  9063. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  9064. const struct auto_pin_cfg *cfg)
  9065. {
  9066. struct hda_input_mux *imux = &spec->private_imux;
  9067. int i, err, idx, idx1;
  9068. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9069. switch (cfg->input_pins[i]) {
  9070. case 0x0c:
  9071. idx1 = 1;
  9072. idx = 2; /* Line In */
  9073. break;
  9074. case 0x0f:
  9075. idx1 = 2;
  9076. idx = 2; /* Line In */
  9077. break;
  9078. case 0x0d:
  9079. idx1 = 0;
  9080. idx = 1; /* Mic In */
  9081. break;
  9082. case 0x10:
  9083. idx1 = 3;
  9084. idx = 1; /* Mic In */
  9085. break;
  9086. case 0x11:
  9087. idx1 = 4;
  9088. idx = 0; /* CD */
  9089. break;
  9090. default:
  9091. continue;
  9092. }
  9093. err = new_analog_input(spec, cfg->input_pins[i],
  9094. auto_pin_cfg_labels[i], idx, 0x15);
  9095. if (err < 0)
  9096. return err;
  9097. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  9098. imux->items[imux->num_items].index = idx1;
  9099. imux->num_items++;
  9100. }
  9101. return 0;
  9102. }
  9103. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  9104. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9105. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9106. {
  9107. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9108. /* The multiple "Capture Source" controls confuse alsamixer
  9109. * So call somewhat different..
  9110. *FIXME: the controls appear in the "playback" view!
  9111. */
  9112. /* .name = "Capture Source", */
  9113. .name = "Input Source",
  9114. .count = 1,
  9115. .info = alc_mux_enum_info,
  9116. .get = alc_mux_enum_get,
  9117. .put = alc_mux_enum_put,
  9118. },
  9119. { } /* end */
  9120. };
  9121. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  9122. hda_nid_t nid,
  9123. int pin_type, int dac_idx)
  9124. {
  9125. /* set as output */
  9126. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  9127. pin_type);
  9128. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9129. AMP_OUT_UNMUTE);
  9130. }
  9131. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  9132. {
  9133. struct alc_spec *spec = codec->spec;
  9134. int i;
  9135. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  9136. for (i = 0; i < spec->autocfg.line_outs; i++) {
  9137. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9138. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9139. if (nid)
  9140. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  9141. spec->multiout.dac_nids[i]);
  9142. }
  9143. }
  9144. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  9145. {
  9146. struct alc_spec *spec = codec->spec;
  9147. hda_nid_t pin;
  9148. pin = spec->autocfg.hp_pins[0];
  9149. if (pin) /* connect to front */
  9150. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  9151. spec->multiout.dac_nids[0]);
  9152. }
  9153. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  9154. {
  9155. struct alc_spec *spec = codec->spec;
  9156. int i;
  9157. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9158. hda_nid_t nid = spec->autocfg.input_pins[i];
  9159. if (nid >= 0x0c && nid <= 0x11) {
  9160. snd_hda_codec_write(codec, nid, 0,
  9161. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9162. i <= AUTO_PIN_FRONT_MIC ?
  9163. PIN_VREF80 : PIN_IN);
  9164. }
  9165. }
  9166. }
  9167. /* parse the BIOS configuration and set up the alc_spec */
  9168. /* return 1 if successful, 0 if the proper config is not found,
  9169. * or a negative error code
  9170. */
  9171. static int alc861_parse_auto_config(struct hda_codec *codec)
  9172. {
  9173. struct alc_spec *spec = codec->spec;
  9174. int err;
  9175. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  9176. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9177. alc861_ignore);
  9178. if (err < 0)
  9179. return err;
  9180. if (!spec->autocfg.line_outs)
  9181. return 0; /* can't find valid BIOS pin config */
  9182. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  9183. if (err < 0)
  9184. return err;
  9185. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9186. if (err < 0)
  9187. return err;
  9188. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  9189. if (err < 0)
  9190. return err;
  9191. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9192. if (err < 0)
  9193. return err;
  9194. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9195. if (spec->autocfg.dig_out_pin)
  9196. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  9197. if (spec->kctl_alloc)
  9198. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9199. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  9200. spec->num_mux_defs = 1;
  9201. spec->input_mux = &spec->private_imux;
  9202. spec->adc_nids = alc861_adc_nids;
  9203. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  9204. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  9205. spec->num_mixers++;
  9206. return 1;
  9207. }
  9208. /* additional initialization for auto-configuration model */
  9209. static void alc861_auto_init(struct hda_codec *codec)
  9210. {
  9211. alc861_auto_init_multi_out(codec);
  9212. alc861_auto_init_hp_out(codec);
  9213. alc861_auto_init_analog_input(codec);
  9214. }
  9215. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9216. static struct hda_amp_list alc861_loopbacks[] = {
  9217. { 0x15, HDA_INPUT, 0 },
  9218. { 0x15, HDA_INPUT, 1 },
  9219. { 0x15, HDA_INPUT, 2 },
  9220. { 0x15, HDA_INPUT, 3 },
  9221. { } /* end */
  9222. };
  9223. #endif
  9224. /*
  9225. * configuration and preset
  9226. */
  9227. static const char *alc861_models[ALC861_MODEL_LAST] = {
  9228. [ALC861_3ST] = "3stack",
  9229. [ALC660_3ST] = "3stack-660",
  9230. [ALC861_3ST_DIG] = "3stack-dig",
  9231. [ALC861_6ST_DIG] = "6stack-dig",
  9232. [ALC861_UNIWILL_M31] = "uniwill-m31",
  9233. [ALC861_TOSHIBA] = "toshiba",
  9234. [ALC861_ASUS] = "asus",
  9235. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  9236. [ALC861_AUTO] = "auto",
  9237. };
  9238. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  9239. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9240. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9241. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9242. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9243. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9244. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9245. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9246. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9247. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9248. * Any other models that need this preset?
  9249. */
  9250. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9251. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9252. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  9253. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9254. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9255. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9256. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9257. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9258. {}
  9259. };
  9260. static struct alc_config_preset alc861_presets[] = {
  9261. [ALC861_3ST] = {
  9262. .mixers = { alc861_3ST_mixer },
  9263. .init_verbs = { alc861_threestack_init_verbs },
  9264. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9265. .dac_nids = alc861_dac_nids,
  9266. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9267. .channel_mode = alc861_threestack_modes,
  9268. .need_dac_fix = 1,
  9269. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9270. .adc_nids = alc861_adc_nids,
  9271. .input_mux = &alc861_capture_source,
  9272. },
  9273. [ALC861_3ST_DIG] = {
  9274. .mixers = { alc861_base_mixer },
  9275. .init_verbs = { alc861_threestack_init_verbs },
  9276. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9277. .dac_nids = alc861_dac_nids,
  9278. .dig_out_nid = ALC861_DIGOUT_NID,
  9279. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9280. .channel_mode = alc861_threestack_modes,
  9281. .need_dac_fix = 1,
  9282. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9283. .adc_nids = alc861_adc_nids,
  9284. .input_mux = &alc861_capture_source,
  9285. },
  9286. [ALC861_6ST_DIG] = {
  9287. .mixers = { alc861_base_mixer },
  9288. .init_verbs = { alc861_base_init_verbs },
  9289. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9290. .dac_nids = alc861_dac_nids,
  9291. .dig_out_nid = ALC861_DIGOUT_NID,
  9292. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  9293. .channel_mode = alc861_8ch_modes,
  9294. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9295. .adc_nids = alc861_adc_nids,
  9296. .input_mux = &alc861_capture_source,
  9297. },
  9298. [ALC660_3ST] = {
  9299. .mixers = { alc861_3ST_mixer },
  9300. .init_verbs = { alc861_threestack_init_verbs },
  9301. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  9302. .dac_nids = alc660_dac_nids,
  9303. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9304. .channel_mode = alc861_threestack_modes,
  9305. .need_dac_fix = 1,
  9306. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9307. .adc_nids = alc861_adc_nids,
  9308. .input_mux = &alc861_capture_source,
  9309. },
  9310. [ALC861_UNIWILL_M31] = {
  9311. .mixers = { alc861_uniwill_m31_mixer },
  9312. .init_verbs = { alc861_uniwill_m31_init_verbs },
  9313. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9314. .dac_nids = alc861_dac_nids,
  9315. .dig_out_nid = ALC861_DIGOUT_NID,
  9316. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9317. .channel_mode = alc861_uniwill_m31_modes,
  9318. .need_dac_fix = 1,
  9319. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9320. .adc_nids = alc861_adc_nids,
  9321. .input_mux = &alc861_capture_source,
  9322. },
  9323. [ALC861_TOSHIBA] = {
  9324. .mixers = { alc861_toshiba_mixer },
  9325. .init_verbs = { alc861_base_init_verbs,
  9326. alc861_toshiba_init_verbs },
  9327. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9328. .dac_nids = alc861_dac_nids,
  9329. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9330. .channel_mode = alc883_3ST_2ch_modes,
  9331. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9332. .adc_nids = alc861_adc_nids,
  9333. .input_mux = &alc861_capture_source,
  9334. .unsol_event = alc861_toshiba_unsol_event,
  9335. .init_hook = alc861_toshiba_automute,
  9336. },
  9337. [ALC861_ASUS] = {
  9338. .mixers = { alc861_asus_mixer },
  9339. .init_verbs = { alc861_asus_init_verbs },
  9340. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9341. .dac_nids = alc861_dac_nids,
  9342. .dig_out_nid = ALC861_DIGOUT_NID,
  9343. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  9344. .channel_mode = alc861_asus_modes,
  9345. .need_dac_fix = 1,
  9346. .hp_nid = 0x06,
  9347. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9348. .adc_nids = alc861_adc_nids,
  9349. .input_mux = &alc861_capture_source,
  9350. },
  9351. [ALC861_ASUS_LAPTOP] = {
  9352. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  9353. .init_verbs = { alc861_asus_init_verbs,
  9354. alc861_asus_laptop_init_verbs },
  9355. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9356. .dac_nids = alc861_dac_nids,
  9357. .dig_out_nid = ALC861_DIGOUT_NID,
  9358. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9359. .channel_mode = alc883_3ST_2ch_modes,
  9360. .need_dac_fix = 1,
  9361. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9362. .adc_nids = alc861_adc_nids,
  9363. .input_mux = &alc861_capture_source,
  9364. },
  9365. };
  9366. static int patch_alc861(struct hda_codec *codec)
  9367. {
  9368. struct alc_spec *spec;
  9369. int board_config;
  9370. int err;
  9371. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9372. if (spec == NULL)
  9373. return -ENOMEM;
  9374. codec->spec = spec;
  9375. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9376. alc861_models,
  9377. alc861_cfg_tbl);
  9378. if (board_config < 0) {
  9379. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9380. "trying auto-probe from BIOS...\n");
  9381. board_config = ALC861_AUTO;
  9382. }
  9383. if (board_config == ALC861_AUTO) {
  9384. /* automatic parse from the BIOS config */
  9385. err = alc861_parse_auto_config(codec);
  9386. if (err < 0) {
  9387. alc_free(codec);
  9388. return err;
  9389. } else if (!err) {
  9390. printk(KERN_INFO
  9391. "hda_codec: Cannot set up configuration "
  9392. "from BIOS. Using base mode...\n");
  9393. board_config = ALC861_3ST_DIG;
  9394. }
  9395. }
  9396. if (board_config != ALC861_AUTO)
  9397. setup_preset(spec, &alc861_presets[board_config]);
  9398. spec->stream_name_analog = "ALC861 Analog";
  9399. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  9400. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  9401. spec->stream_name_digital = "ALC861 Digital";
  9402. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  9403. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  9404. codec->patch_ops = alc_patch_ops;
  9405. if (board_config == ALC861_AUTO)
  9406. spec->init_hook = alc861_auto_init;
  9407. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9408. if (!spec->loopback.amplist)
  9409. spec->loopback.amplist = alc861_loopbacks;
  9410. #endif
  9411. return 0;
  9412. }
  9413. /*
  9414. * ALC861-VD support
  9415. *
  9416. * Based on ALC882
  9417. *
  9418. * In addition, an independent DAC
  9419. */
  9420. #define ALC861VD_DIGOUT_NID 0x06
  9421. static hda_nid_t alc861vd_dac_nids[4] = {
  9422. /* front, surr, clfe, side surr */
  9423. 0x02, 0x03, 0x04, 0x05
  9424. };
  9425. /* dac_nids for ALC660vd are in a different order - according to
  9426. * Realtek's driver.
  9427. * This should probably tesult in a different mixer for 6stack models
  9428. * of ALC660vd codecs, but for now there is only 3stack mixer
  9429. * - and it is the same as in 861vd.
  9430. * adc_nids in ALC660vd are (is) the same as in 861vd
  9431. */
  9432. static hda_nid_t alc660vd_dac_nids[3] = {
  9433. /* front, rear, clfe, rear_surr */
  9434. 0x02, 0x04, 0x03
  9435. };
  9436. static hda_nid_t alc861vd_adc_nids[1] = {
  9437. /* ADC0 */
  9438. 0x09,
  9439. };
  9440. /* input MUX */
  9441. /* FIXME: should be a matrix-type input source selection */
  9442. static struct hda_input_mux alc861vd_capture_source = {
  9443. .num_items = 4,
  9444. .items = {
  9445. { "Mic", 0x0 },
  9446. { "Front Mic", 0x1 },
  9447. { "Line", 0x2 },
  9448. { "CD", 0x4 },
  9449. },
  9450. };
  9451. static struct hda_input_mux alc861vd_dallas_capture_source = {
  9452. .num_items = 3,
  9453. .items = {
  9454. { "Front Mic", 0x0 },
  9455. { "ATAPI Mic", 0x1 },
  9456. { "Line In", 0x5 },
  9457. },
  9458. };
  9459. static struct hda_input_mux alc861vd_hp_capture_source = {
  9460. .num_items = 2,
  9461. .items = {
  9462. { "Front Mic", 0x0 },
  9463. { "ATAPI Mic", 0x1 },
  9464. },
  9465. };
  9466. #define alc861vd_mux_enum_info alc_mux_enum_info
  9467. #define alc861vd_mux_enum_get alc_mux_enum_get
  9468. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  9469. struct snd_ctl_elem_value *ucontrol)
  9470. {
  9471. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9472. struct alc_spec *spec = codec->spec;
  9473. const struct hda_input_mux *imux = spec->input_mux;
  9474. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9475. static hda_nid_t capture_mixers[1] = { 0x22 };
  9476. hda_nid_t nid = capture_mixers[adc_idx];
  9477. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9478. unsigned int i, idx;
  9479. idx = ucontrol->value.enumerated.item[0];
  9480. if (idx >= imux->num_items)
  9481. idx = imux->num_items - 1;
  9482. if (*cur_val == idx)
  9483. return 0;
  9484. for (i = 0; i < imux->num_items; i++) {
  9485. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9486. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9487. imux->items[i].index,
  9488. HDA_AMP_MUTE, v);
  9489. }
  9490. *cur_val = idx;
  9491. return 1;
  9492. }
  9493. /*
  9494. * 2ch mode
  9495. */
  9496. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9497. { 2, NULL }
  9498. };
  9499. /*
  9500. * 6ch mode
  9501. */
  9502. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9503. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9504. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9505. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9506. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9507. { } /* end */
  9508. };
  9509. /*
  9510. * 8ch mode
  9511. */
  9512. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9513. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9514. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9515. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9516. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9517. { } /* end */
  9518. };
  9519. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9520. { 6, alc861vd_6stack_ch6_init },
  9521. { 8, alc861vd_6stack_ch8_init },
  9522. };
  9523. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9524. {
  9525. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9526. .name = "Channel Mode",
  9527. .info = alc_ch_mode_info,
  9528. .get = alc_ch_mode_get,
  9529. .put = alc_ch_mode_put,
  9530. },
  9531. { } /* end */
  9532. };
  9533. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9534. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9535. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9536. {
  9537. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9538. /* The multiple "Capture Source" controls confuse alsamixer
  9539. * So call somewhat different..
  9540. *FIXME: the controls appear in the "playback" view!
  9541. */
  9542. /* .name = "Capture Source", */
  9543. .name = "Input Source",
  9544. .count = 1,
  9545. .info = alc861vd_mux_enum_info,
  9546. .get = alc861vd_mux_enum_get,
  9547. .put = alc861vd_mux_enum_put,
  9548. },
  9549. { } /* end */
  9550. };
  9551. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9552. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9553. */
  9554. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9555. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9556. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9557. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9558. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9559. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9560. HDA_OUTPUT),
  9561. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9562. HDA_OUTPUT),
  9563. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9564. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9565. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9566. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9567. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9568. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9569. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9570. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9571. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9572. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9573. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9574. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9575. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9576. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9577. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9578. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9579. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9580. { } /* end */
  9581. };
  9582. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9583. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9584. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9585. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9586. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9587. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9588. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9589. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9590. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9591. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9592. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9593. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9594. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9595. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9596. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9597. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9598. { } /* end */
  9599. };
  9600. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9601. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9602. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9603. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9604. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9605. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9606. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9607. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9608. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9609. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9610. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9611. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9612. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9613. { } /* end */
  9614. };
  9615. /* Pin assignment: Front=0x14, HP = 0x15,
  9616. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9617. */
  9618. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9619. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9620. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9621. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9622. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9623. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9624. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9625. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9626. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9627. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9628. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9629. { } /* end */
  9630. };
  9631. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  9632. * Front Mic=0x18, ATAPI Mic = 0x19,
  9633. */
  9634. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  9635. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9636. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9637. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9638. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9639. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9640. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9641. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9642. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9643. { } /* end */
  9644. };
  9645. /*
  9646. * generic initialization of ADC, input mixers and output mixers
  9647. */
  9648. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9649. /*
  9650. * Unmute ADC0 and set the default input to mic-in
  9651. */
  9652. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9653. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9654. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9655. * the analog-loopback mixer widget
  9656. */
  9657. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9658. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9659. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9660. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9661. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9662. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9663. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9664. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9665. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9666. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9667. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9668. /*
  9669. * Set up output mixers (0x02 - 0x05)
  9670. */
  9671. /* set vol=0 to output mixers */
  9672. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9673. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9674. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9675. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9676. /* set up input amps for analog loopback */
  9677. /* Amp Indices: DAC = 0, mixer = 1 */
  9678. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9679. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9680. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9681. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9682. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9683. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9684. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9685. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9686. { }
  9687. };
  9688. /*
  9689. * 3-stack pin configuration:
  9690. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9691. */
  9692. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9693. /*
  9694. * Set pin mode and muting
  9695. */
  9696. /* set front pin widgets 0x14 for output */
  9697. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9698. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9699. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9700. /* Mic (rear) pin: input vref at 80% */
  9701. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9702. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9703. /* Front Mic pin: input vref at 80% */
  9704. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9705. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9706. /* Line In pin: input */
  9707. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9708. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9709. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9710. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9711. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9712. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9713. /* CD pin widget for input */
  9714. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9715. { }
  9716. };
  9717. /*
  9718. * 6-stack pin configuration:
  9719. */
  9720. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9721. /*
  9722. * Set pin mode and muting
  9723. */
  9724. /* set front pin widgets 0x14 for output */
  9725. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9726. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9727. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9728. /* Rear Pin: output 1 (0x0d) */
  9729. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9730. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9731. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9732. /* CLFE Pin: output 2 (0x0e) */
  9733. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9734. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9735. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9736. /* Side Pin: output 3 (0x0f) */
  9737. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9738. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9739. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9740. /* Mic (rear) pin: input vref at 80% */
  9741. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9742. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9743. /* Front Mic pin: input vref at 80% */
  9744. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9745. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9746. /* Line In pin: input */
  9747. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9748. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9749. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9750. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9751. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9752. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9753. /* CD pin widget for input */
  9754. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9755. { }
  9756. };
  9757. static struct hda_verb alc861vd_eapd_verbs[] = {
  9758. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9759. { }
  9760. };
  9761. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9762. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9763. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9764. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9765. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9766. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9767. {}
  9768. };
  9769. /* toggle speaker-output according to the hp-jack state */
  9770. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9771. {
  9772. unsigned int present;
  9773. unsigned char bits;
  9774. present = snd_hda_codec_read(codec, 0x1b, 0,
  9775. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9776. bits = present ? HDA_AMP_MUTE : 0;
  9777. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9778. HDA_AMP_MUTE, bits);
  9779. }
  9780. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9781. {
  9782. unsigned int present;
  9783. unsigned char bits;
  9784. present = snd_hda_codec_read(codec, 0x18, 0,
  9785. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9786. bits = present ? HDA_AMP_MUTE : 0;
  9787. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  9788. HDA_AMP_MUTE, bits);
  9789. }
  9790. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9791. {
  9792. alc861vd_lenovo_hp_automute(codec);
  9793. alc861vd_lenovo_mic_automute(codec);
  9794. }
  9795. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9796. unsigned int res)
  9797. {
  9798. switch (res >> 26) {
  9799. case ALC880_HP_EVENT:
  9800. alc861vd_lenovo_hp_automute(codec);
  9801. break;
  9802. case ALC880_MIC_EVENT:
  9803. alc861vd_lenovo_mic_automute(codec);
  9804. break;
  9805. }
  9806. }
  9807. static struct hda_verb alc861vd_dallas_verbs[] = {
  9808. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9809. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9810. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9811. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9812. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9813. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9814. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9815. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9816. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9817. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9818. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9819. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9820. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9821. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9822. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9823. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9824. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9825. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9826. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9827. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9828. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9829. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9830. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9831. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9832. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9833. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9834. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9835. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9836. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9837. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9838. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9839. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9840. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9841. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9842. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9843. { } /* end */
  9844. };
  9845. /* toggle speaker-output according to the hp-jack state */
  9846. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9847. {
  9848. unsigned int present;
  9849. present = snd_hda_codec_read(codec, 0x15, 0,
  9850. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9851. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9852. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9853. }
  9854. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9855. {
  9856. if ((res >> 26) == ALC880_HP_EVENT)
  9857. alc861vd_dallas_automute(codec);
  9858. }
  9859. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9860. #define alc861vd_loopbacks alc880_loopbacks
  9861. #endif
  9862. /* pcm configuration: identiacal with ALC880 */
  9863. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9864. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9865. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9866. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9867. /*
  9868. * configuration and preset
  9869. */
  9870. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9871. [ALC660VD_3ST] = "3stack-660",
  9872. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  9873. [ALC861VD_3ST] = "3stack",
  9874. [ALC861VD_3ST_DIG] = "3stack-digout",
  9875. [ALC861VD_6ST_DIG] = "6stack-digout",
  9876. [ALC861VD_LENOVO] = "lenovo",
  9877. [ALC861VD_DALLAS] = "dallas",
  9878. [ALC861VD_HP] = "hp",
  9879. [ALC861VD_AUTO] = "auto",
  9880. };
  9881. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9882. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9883. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9884. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9885. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9886. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9887. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  9888. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9889. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9890. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9891. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9892. SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
  9893. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  9894. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  9895. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  9896. {}
  9897. };
  9898. static struct alc_config_preset alc861vd_presets[] = {
  9899. [ALC660VD_3ST] = {
  9900. .mixers = { alc861vd_3st_mixer },
  9901. .init_verbs = { alc861vd_volume_init_verbs,
  9902. alc861vd_3stack_init_verbs },
  9903. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9904. .dac_nids = alc660vd_dac_nids,
  9905. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9906. .adc_nids = alc861vd_adc_nids,
  9907. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9908. .channel_mode = alc861vd_3stack_2ch_modes,
  9909. .input_mux = &alc861vd_capture_source,
  9910. },
  9911. [ALC660VD_3ST_DIG] = {
  9912. .mixers = { alc861vd_3st_mixer },
  9913. .init_verbs = { alc861vd_volume_init_verbs,
  9914. alc861vd_3stack_init_verbs },
  9915. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9916. .dac_nids = alc660vd_dac_nids,
  9917. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9918. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9919. .adc_nids = alc861vd_adc_nids,
  9920. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9921. .channel_mode = alc861vd_3stack_2ch_modes,
  9922. .input_mux = &alc861vd_capture_source,
  9923. },
  9924. [ALC861VD_3ST] = {
  9925. .mixers = { alc861vd_3st_mixer },
  9926. .init_verbs = { alc861vd_volume_init_verbs,
  9927. alc861vd_3stack_init_verbs },
  9928. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9929. .dac_nids = alc861vd_dac_nids,
  9930. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9931. .channel_mode = alc861vd_3stack_2ch_modes,
  9932. .input_mux = &alc861vd_capture_source,
  9933. },
  9934. [ALC861VD_3ST_DIG] = {
  9935. .mixers = { alc861vd_3st_mixer },
  9936. .init_verbs = { alc861vd_volume_init_verbs,
  9937. alc861vd_3stack_init_verbs },
  9938. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9939. .dac_nids = alc861vd_dac_nids,
  9940. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9941. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9942. .channel_mode = alc861vd_3stack_2ch_modes,
  9943. .input_mux = &alc861vd_capture_source,
  9944. },
  9945. [ALC861VD_6ST_DIG] = {
  9946. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9947. .init_verbs = { alc861vd_volume_init_verbs,
  9948. alc861vd_6stack_init_verbs },
  9949. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9950. .dac_nids = alc861vd_dac_nids,
  9951. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9952. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9953. .channel_mode = alc861vd_6stack_modes,
  9954. .input_mux = &alc861vd_capture_source,
  9955. },
  9956. [ALC861VD_LENOVO] = {
  9957. .mixers = { alc861vd_lenovo_mixer },
  9958. .init_verbs = { alc861vd_volume_init_verbs,
  9959. alc861vd_3stack_init_verbs,
  9960. alc861vd_eapd_verbs,
  9961. alc861vd_lenovo_unsol_verbs },
  9962. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9963. .dac_nids = alc660vd_dac_nids,
  9964. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9965. .adc_nids = alc861vd_adc_nids,
  9966. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9967. .channel_mode = alc861vd_3stack_2ch_modes,
  9968. .input_mux = &alc861vd_capture_source,
  9969. .unsol_event = alc861vd_lenovo_unsol_event,
  9970. .init_hook = alc861vd_lenovo_automute,
  9971. },
  9972. [ALC861VD_DALLAS] = {
  9973. .mixers = { alc861vd_dallas_mixer },
  9974. .init_verbs = { alc861vd_dallas_verbs },
  9975. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9976. .dac_nids = alc861vd_dac_nids,
  9977. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9978. .adc_nids = alc861vd_adc_nids,
  9979. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9980. .channel_mode = alc861vd_3stack_2ch_modes,
  9981. .input_mux = &alc861vd_dallas_capture_source,
  9982. .unsol_event = alc861vd_dallas_unsol_event,
  9983. .init_hook = alc861vd_dallas_automute,
  9984. },
  9985. [ALC861VD_HP] = {
  9986. .mixers = { alc861vd_hp_mixer },
  9987. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  9988. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9989. .dac_nids = alc861vd_dac_nids,
  9990. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9991. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9992. .adc_nids = alc861vd_adc_nids,
  9993. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9994. .channel_mode = alc861vd_3stack_2ch_modes,
  9995. .input_mux = &alc861vd_hp_capture_source,
  9996. .unsol_event = alc861vd_dallas_unsol_event,
  9997. .init_hook = alc861vd_dallas_automute,
  9998. },
  9999. };
  10000. /*
  10001. * BIOS auto configuration
  10002. */
  10003. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  10004. hda_nid_t nid, int pin_type, int dac_idx)
  10005. {
  10006. /* set as output */
  10007. snd_hda_codec_write(codec, nid, 0,
  10008. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10009. snd_hda_codec_write(codec, nid, 0,
  10010. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10011. }
  10012. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  10013. {
  10014. struct alc_spec *spec = codec->spec;
  10015. int i;
  10016. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  10017. for (i = 0; i <= HDA_SIDE; i++) {
  10018. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10019. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10020. if (nid)
  10021. alc861vd_auto_set_output_and_unmute(codec, nid,
  10022. pin_type, i);
  10023. }
  10024. }
  10025. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  10026. {
  10027. struct alc_spec *spec = codec->spec;
  10028. hda_nid_t pin;
  10029. pin = spec->autocfg.hp_pins[0];
  10030. if (pin) /* connect to front and use dac 0 */
  10031. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10032. }
  10033. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  10034. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  10035. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  10036. {
  10037. struct alc_spec *spec = codec->spec;
  10038. int i;
  10039. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10040. hda_nid_t nid = spec->autocfg.input_pins[i];
  10041. if (alc861vd_is_input_pin(nid)) {
  10042. snd_hda_codec_write(codec, nid, 0,
  10043. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10044. i <= AUTO_PIN_FRONT_MIC ?
  10045. PIN_VREF80 : PIN_IN);
  10046. if (nid != ALC861VD_PIN_CD_NID)
  10047. snd_hda_codec_write(codec, nid, 0,
  10048. AC_VERB_SET_AMP_GAIN_MUTE,
  10049. AMP_OUT_MUTE);
  10050. }
  10051. }
  10052. }
  10053. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  10054. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  10055. /* add playback controls from the parsed DAC table */
  10056. /* Based on ALC880 version. But ALC861VD has separate,
  10057. * different NIDs for mute/unmute switch and volume control */
  10058. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  10059. const struct auto_pin_cfg *cfg)
  10060. {
  10061. char name[32];
  10062. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  10063. hda_nid_t nid_v, nid_s;
  10064. int i, err;
  10065. for (i = 0; i < cfg->line_outs; i++) {
  10066. if (!spec->multiout.dac_nids[i])
  10067. continue;
  10068. nid_v = alc861vd_idx_to_mixer_vol(
  10069. alc880_dac_to_idx(
  10070. spec->multiout.dac_nids[i]));
  10071. nid_s = alc861vd_idx_to_mixer_switch(
  10072. alc880_dac_to_idx(
  10073. spec->multiout.dac_nids[i]));
  10074. if (i == 2) {
  10075. /* Center/LFE */
  10076. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10077. "Center Playback Volume",
  10078. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  10079. HDA_OUTPUT));
  10080. if (err < 0)
  10081. return err;
  10082. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10083. "LFE Playback Volume",
  10084. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  10085. HDA_OUTPUT));
  10086. if (err < 0)
  10087. return err;
  10088. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10089. "Center Playback Switch",
  10090. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  10091. HDA_INPUT));
  10092. if (err < 0)
  10093. return err;
  10094. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10095. "LFE Playback Switch",
  10096. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  10097. HDA_INPUT));
  10098. if (err < 0)
  10099. return err;
  10100. } else {
  10101. sprintf(name, "%s Playback Volume", chname[i]);
  10102. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10103. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  10104. HDA_OUTPUT));
  10105. if (err < 0)
  10106. return err;
  10107. sprintf(name, "%s Playback Switch", chname[i]);
  10108. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10109. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  10110. HDA_INPUT));
  10111. if (err < 0)
  10112. return err;
  10113. }
  10114. }
  10115. return 0;
  10116. }
  10117. /* add playback controls for speaker and HP outputs */
  10118. /* Based on ALC880 version. But ALC861VD has separate,
  10119. * different NIDs for mute/unmute switch and volume control */
  10120. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  10121. hda_nid_t pin, const char *pfx)
  10122. {
  10123. hda_nid_t nid_v, nid_s;
  10124. int err;
  10125. char name[32];
  10126. if (!pin)
  10127. return 0;
  10128. if (alc880_is_fixed_pin(pin)) {
  10129. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10130. /* specify the DAC as the extra output */
  10131. if (!spec->multiout.hp_nid)
  10132. spec->multiout.hp_nid = nid_v;
  10133. else
  10134. spec->multiout.extra_out_nid[0] = nid_v;
  10135. /* control HP volume/switch on the output mixer amp */
  10136. nid_v = alc861vd_idx_to_mixer_vol(
  10137. alc880_fixed_pin_idx(pin));
  10138. nid_s = alc861vd_idx_to_mixer_switch(
  10139. alc880_fixed_pin_idx(pin));
  10140. sprintf(name, "%s Playback Volume", pfx);
  10141. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10142. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  10143. if (err < 0)
  10144. return err;
  10145. sprintf(name, "%s Playback Switch", pfx);
  10146. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10147. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  10148. if (err < 0)
  10149. return err;
  10150. } else if (alc880_is_multi_pin(pin)) {
  10151. /* set manual connection */
  10152. /* we have only a switch on HP-out PIN */
  10153. sprintf(name, "%s Playback Switch", pfx);
  10154. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10155. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10156. if (err < 0)
  10157. return err;
  10158. }
  10159. return 0;
  10160. }
  10161. /* parse the BIOS configuration and set up the alc_spec
  10162. * return 1 if successful, 0 if the proper config is not found,
  10163. * or a negative error code
  10164. * Based on ALC880 version - had to change it to override
  10165. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  10166. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  10167. {
  10168. struct alc_spec *spec = codec->spec;
  10169. int err;
  10170. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  10171. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10172. alc861vd_ignore);
  10173. if (err < 0)
  10174. return err;
  10175. if (!spec->autocfg.line_outs)
  10176. return 0; /* can't find valid BIOS pin config */
  10177. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10178. if (err < 0)
  10179. return err;
  10180. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10181. if (err < 0)
  10182. return err;
  10183. err = alc861vd_auto_create_extra_out(spec,
  10184. spec->autocfg.speaker_pins[0],
  10185. "Speaker");
  10186. if (err < 0)
  10187. return err;
  10188. err = alc861vd_auto_create_extra_out(spec,
  10189. spec->autocfg.hp_pins[0],
  10190. "Headphone");
  10191. if (err < 0)
  10192. return err;
  10193. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10194. if (err < 0)
  10195. return err;
  10196. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10197. if (spec->autocfg.dig_out_pin)
  10198. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  10199. if (spec->kctl_alloc)
  10200. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10201. spec->init_verbs[spec->num_init_verbs++]
  10202. = alc861vd_volume_init_verbs;
  10203. spec->num_mux_defs = 1;
  10204. spec->input_mux = &spec->private_imux;
  10205. err = alc_auto_add_mic_boost(codec);
  10206. if (err < 0)
  10207. return err;
  10208. return 1;
  10209. }
  10210. /* additional initialization for auto-configuration model */
  10211. static void alc861vd_auto_init(struct hda_codec *codec)
  10212. {
  10213. alc861vd_auto_init_multi_out(codec);
  10214. alc861vd_auto_init_hp_out(codec);
  10215. alc861vd_auto_init_analog_input(codec);
  10216. }
  10217. static int patch_alc861vd(struct hda_codec *codec)
  10218. {
  10219. struct alc_spec *spec;
  10220. int err, board_config;
  10221. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10222. if (spec == NULL)
  10223. return -ENOMEM;
  10224. codec->spec = spec;
  10225. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  10226. alc861vd_models,
  10227. alc861vd_cfg_tbl);
  10228. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  10229. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  10230. "ALC861VD, trying auto-probe from BIOS...\n");
  10231. board_config = ALC861VD_AUTO;
  10232. }
  10233. if (board_config == ALC861VD_AUTO) {
  10234. /* automatic parse from the BIOS config */
  10235. err = alc861vd_parse_auto_config(codec);
  10236. if (err < 0) {
  10237. alc_free(codec);
  10238. return err;
  10239. } else if (!err) {
  10240. printk(KERN_INFO
  10241. "hda_codec: Cannot set up configuration "
  10242. "from BIOS. Using base mode...\n");
  10243. board_config = ALC861VD_3ST;
  10244. }
  10245. }
  10246. if (board_config != ALC861VD_AUTO)
  10247. setup_preset(spec, &alc861vd_presets[board_config]);
  10248. spec->stream_name_analog = "ALC861VD Analog";
  10249. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10250. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10251. spec->stream_name_digital = "ALC861VD Digital";
  10252. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10253. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10254. spec->adc_nids = alc861vd_adc_nids;
  10255. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10256. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10257. spec->num_mixers++;
  10258. codec->patch_ops = alc_patch_ops;
  10259. if (board_config == ALC861VD_AUTO)
  10260. spec->init_hook = alc861vd_auto_init;
  10261. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10262. if (!spec->loopback.amplist)
  10263. spec->loopback.amplist = alc861vd_loopbacks;
  10264. #endif
  10265. return 0;
  10266. }
  10267. /*
  10268. * ALC662 support
  10269. *
  10270. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  10271. * configuration. Each pin widget can choose any input DACs and a mixer.
  10272. * Each ADC is connected from a mixer of all inputs. This makes possible
  10273. * 6-channel independent captures.
  10274. *
  10275. * In addition, an independent DAC for the multi-playback (not used in this
  10276. * driver yet).
  10277. */
  10278. #define ALC662_DIGOUT_NID 0x06
  10279. #define ALC662_DIGIN_NID 0x0a
  10280. static hda_nid_t alc662_dac_nids[4] = {
  10281. /* front, rear, clfe, rear_surr */
  10282. 0x02, 0x03, 0x04
  10283. };
  10284. static hda_nid_t alc662_adc_nids[1] = {
  10285. /* ADC1-2 */
  10286. 0x09,
  10287. };
  10288. /* input MUX */
  10289. /* FIXME: should be a matrix-type input source selection */
  10290. static struct hda_input_mux alc662_capture_source = {
  10291. .num_items = 4,
  10292. .items = {
  10293. { "Mic", 0x0 },
  10294. { "Front Mic", 0x1 },
  10295. { "Line", 0x2 },
  10296. { "CD", 0x4 },
  10297. },
  10298. };
  10299. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  10300. .num_items = 2,
  10301. .items = {
  10302. { "Mic", 0x1 },
  10303. { "Line", 0x2 },
  10304. },
  10305. };
  10306. #define alc662_mux_enum_info alc_mux_enum_info
  10307. #define alc662_mux_enum_get alc_mux_enum_get
  10308. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  10309. struct snd_ctl_elem_value *ucontrol)
  10310. {
  10311. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10312. struct alc_spec *spec = codec->spec;
  10313. const struct hda_input_mux *imux = spec->input_mux;
  10314. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10315. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  10316. hda_nid_t nid = capture_mixers[adc_idx];
  10317. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10318. unsigned int i, idx;
  10319. idx = ucontrol->value.enumerated.item[0];
  10320. if (idx >= imux->num_items)
  10321. idx = imux->num_items - 1;
  10322. if (*cur_val == idx)
  10323. return 0;
  10324. for (i = 0; i < imux->num_items; i++) {
  10325. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10326. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10327. imux->items[i].index,
  10328. HDA_AMP_MUTE, v);
  10329. }
  10330. *cur_val = idx;
  10331. return 1;
  10332. }
  10333. /*
  10334. * 2ch mode
  10335. */
  10336. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  10337. { 2, NULL }
  10338. };
  10339. /*
  10340. * 2ch mode
  10341. */
  10342. static struct hda_verb alc662_3ST_ch2_init[] = {
  10343. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  10344. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10345. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  10346. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10347. { } /* end */
  10348. };
  10349. /*
  10350. * 6ch mode
  10351. */
  10352. static struct hda_verb alc662_3ST_ch6_init[] = {
  10353. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10354. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10355. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  10356. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10357. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10358. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  10359. { } /* end */
  10360. };
  10361. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  10362. { 2, alc662_3ST_ch2_init },
  10363. { 6, alc662_3ST_ch6_init },
  10364. };
  10365. /*
  10366. * 2ch mode
  10367. */
  10368. static struct hda_verb alc662_sixstack_ch6_init[] = {
  10369. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10370. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10371. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10372. { } /* end */
  10373. };
  10374. /*
  10375. * 6ch mode
  10376. */
  10377. static struct hda_verb alc662_sixstack_ch8_init[] = {
  10378. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10379. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10380. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10381. { } /* end */
  10382. };
  10383. static struct hda_channel_mode alc662_5stack_modes[2] = {
  10384. { 2, alc662_sixstack_ch6_init },
  10385. { 6, alc662_sixstack_ch8_init },
  10386. };
  10387. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10388. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10389. */
  10390. static struct snd_kcontrol_new alc662_base_mixer[] = {
  10391. /* output mixer control */
  10392. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  10393. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  10394. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  10395. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  10396. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10397. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10398. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10399. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10400. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10401. /*Input mixer control */
  10402. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  10403. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  10404. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  10405. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  10406. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  10407. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  10408. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  10409. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  10410. /* Capture mixer control */
  10411. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10412. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10413. {
  10414. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10415. .name = "Capture Source",
  10416. .count = 1,
  10417. .info = alc_mux_enum_info,
  10418. .get = alc_mux_enum_get,
  10419. .put = alc_mux_enum_put,
  10420. },
  10421. { } /* end */
  10422. };
  10423. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  10424. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10425. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10426. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10427. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10428. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10429. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10430. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10431. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10432. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10433. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10434. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10435. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10436. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10437. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10438. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10439. {
  10440. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10441. /* .name = "Capture Source", */
  10442. .name = "Input Source",
  10443. .count = 1,
  10444. .info = alc662_mux_enum_info,
  10445. .get = alc662_mux_enum_get,
  10446. .put = alc662_mux_enum_put,
  10447. },
  10448. { } /* end */
  10449. };
  10450. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  10451. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10452. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10453. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10454. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  10455. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10456. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10457. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10458. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10459. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10460. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10461. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10462. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10463. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10464. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10465. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10466. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10467. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10468. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10469. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10470. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10471. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10472. {
  10473. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10474. /* .name = "Capture Source", */
  10475. .name = "Input Source",
  10476. .count = 1,
  10477. .info = alc662_mux_enum_info,
  10478. .get = alc662_mux_enum_get,
  10479. .put = alc662_mux_enum_put,
  10480. },
  10481. { } /* end */
  10482. };
  10483. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  10484. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10485. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10486. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10487. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  10488. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10489. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10490. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10491. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10492. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10493. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10494. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10495. {
  10496. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10497. /* .name = "Capture Source", */
  10498. .name = "Input Source",
  10499. .count = 1,
  10500. .info = alc662_mux_enum_info,
  10501. .get = alc662_mux_enum_get,
  10502. .put = alc662_mux_enum_put,
  10503. },
  10504. { } /* end */
  10505. };
  10506. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  10507. {
  10508. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10509. .name = "Channel Mode",
  10510. .info = alc_ch_mode_info,
  10511. .get = alc_ch_mode_get,
  10512. .put = alc_ch_mode_put,
  10513. },
  10514. { } /* end */
  10515. };
  10516. static struct hda_verb alc662_init_verbs[] = {
  10517. /* ADC: mute amp left and right */
  10518. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10519. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10520. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10521. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10522. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10523. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10524. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10525. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10526. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10527. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10528. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10529. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10530. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10531. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10532. /* Front Pin: output 0 (0x0c) */
  10533. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10534. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10535. /* Rear Pin: output 1 (0x0d) */
  10536. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10537. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10538. /* CLFE Pin: output 2 (0x0e) */
  10539. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10540. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10541. /* Mic (rear) pin: input vref at 80% */
  10542. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10543. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10544. /* Front Mic pin: input vref at 80% */
  10545. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10546. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10547. /* Line In pin: input */
  10548. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10549. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10550. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10551. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10552. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10553. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10554. /* CD pin widget for input */
  10555. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10556. /* FIXME: use matrix-type input source selection */
  10557. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10558. /* Input mixer */
  10559. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10560. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10561. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10562. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10563. { }
  10564. };
  10565. static struct hda_verb alc662_sue_init_verbs[] = {
  10566. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10567. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10568. {}
  10569. };
  10570. /*
  10571. * generic initialization of ADC, input mixers and output mixers
  10572. */
  10573. static struct hda_verb alc662_auto_init_verbs[] = {
  10574. /*
  10575. * Unmute ADC and set the default input to mic-in
  10576. */
  10577. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10578. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10579. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10580. * mixer widget
  10581. * Note: PASD motherboards uses the Line In 2 as the input for front
  10582. * panel mic (mic 2)
  10583. */
  10584. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10585. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10586. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10587. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10588. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10589. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10590. /*
  10591. * Set up output mixers (0x0c - 0x0f)
  10592. */
  10593. /* set vol=0 to output mixers */
  10594. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10595. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10596. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10597. /* set up input amps for analog loopback */
  10598. /* Amp Indices: DAC = 0, mixer = 1 */
  10599. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10600. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10601. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10602. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10603. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10604. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10605. /* FIXME: use matrix-type input source selection */
  10606. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10607. /* Input mixer */
  10608. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10609. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10610. { }
  10611. };
  10612. /* capture mixer elements */
  10613. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10614. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10615. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10616. {
  10617. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10618. /* The multiple "Capture Source" controls confuse alsamixer
  10619. * So call somewhat different..
  10620. * FIXME: the controls appear in the "playback" view!
  10621. */
  10622. /* .name = "Capture Source", */
  10623. .name = "Input Source",
  10624. .count = 1,
  10625. .info = alc882_mux_enum_info,
  10626. .get = alc882_mux_enum_get,
  10627. .put = alc882_mux_enum_put,
  10628. },
  10629. { } /* end */
  10630. };
  10631. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10632. {
  10633. unsigned int present;
  10634. unsigned char bits;
  10635. present = snd_hda_codec_read(codec, 0x14, 0,
  10636. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10637. bits = present ? HDA_AMP_MUTE : 0;
  10638. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10639. HDA_AMP_MUTE, bits);
  10640. }
  10641. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10642. {
  10643. unsigned int present;
  10644. unsigned char bits;
  10645. present = snd_hda_codec_read(codec, 0x1b, 0,
  10646. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10647. bits = present ? HDA_AMP_MUTE : 0;
  10648. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10649. HDA_AMP_MUTE, bits);
  10650. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10651. HDA_AMP_MUTE, bits);
  10652. }
  10653. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10654. unsigned int res)
  10655. {
  10656. if ((res >> 26) == ALC880_HP_EVENT)
  10657. alc662_lenovo_101e_all_automute(codec);
  10658. if ((res >> 26) == ALC880_FRONT_EVENT)
  10659. alc662_lenovo_101e_ispeaker_automute(codec);
  10660. }
  10661. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10662. #define alc662_loopbacks alc880_loopbacks
  10663. #endif
  10664. /* pcm configuration: identiacal with ALC880 */
  10665. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10666. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10667. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10668. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10669. /*
  10670. * configuration and preset
  10671. */
  10672. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10673. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10674. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10675. [ALC662_3ST_6ch] = "3stack-6ch",
  10676. [ALC662_5ST_DIG] = "6stack-dig",
  10677. [ALC662_LENOVO_101E] = "lenovo-101e",
  10678. [ALC662_AUTO] = "auto",
  10679. };
  10680. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10681. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10682. {}
  10683. };
  10684. static struct alc_config_preset alc662_presets[] = {
  10685. [ALC662_3ST_2ch_DIG] = {
  10686. .mixers = { alc662_3ST_2ch_mixer },
  10687. .init_verbs = { alc662_init_verbs },
  10688. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10689. .dac_nids = alc662_dac_nids,
  10690. .dig_out_nid = ALC662_DIGOUT_NID,
  10691. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10692. .adc_nids = alc662_adc_nids,
  10693. .dig_in_nid = ALC662_DIGIN_NID,
  10694. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10695. .channel_mode = alc662_3ST_2ch_modes,
  10696. .input_mux = &alc662_capture_source,
  10697. },
  10698. [ALC662_3ST_6ch_DIG] = {
  10699. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10700. .init_verbs = { alc662_init_verbs },
  10701. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10702. .dac_nids = alc662_dac_nids,
  10703. .dig_out_nid = ALC662_DIGOUT_NID,
  10704. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10705. .adc_nids = alc662_adc_nids,
  10706. .dig_in_nid = ALC662_DIGIN_NID,
  10707. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10708. .channel_mode = alc662_3ST_6ch_modes,
  10709. .need_dac_fix = 1,
  10710. .input_mux = &alc662_capture_source,
  10711. },
  10712. [ALC662_3ST_6ch] = {
  10713. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10714. .init_verbs = { alc662_init_verbs },
  10715. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10716. .dac_nids = alc662_dac_nids,
  10717. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10718. .adc_nids = alc662_adc_nids,
  10719. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10720. .channel_mode = alc662_3ST_6ch_modes,
  10721. .need_dac_fix = 1,
  10722. .input_mux = &alc662_capture_source,
  10723. },
  10724. [ALC662_5ST_DIG] = {
  10725. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10726. .init_verbs = { alc662_init_verbs },
  10727. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10728. .dac_nids = alc662_dac_nids,
  10729. .dig_out_nid = ALC662_DIGOUT_NID,
  10730. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10731. .adc_nids = alc662_adc_nids,
  10732. .dig_in_nid = ALC662_DIGIN_NID,
  10733. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10734. .channel_mode = alc662_5stack_modes,
  10735. .input_mux = &alc662_capture_source,
  10736. },
  10737. [ALC662_LENOVO_101E] = {
  10738. .mixers = { alc662_lenovo_101e_mixer },
  10739. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10740. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10741. .dac_nids = alc662_dac_nids,
  10742. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10743. .adc_nids = alc662_adc_nids,
  10744. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10745. .channel_mode = alc662_3ST_2ch_modes,
  10746. .input_mux = &alc662_lenovo_101e_capture_source,
  10747. .unsol_event = alc662_lenovo_101e_unsol_event,
  10748. .init_hook = alc662_lenovo_101e_all_automute,
  10749. },
  10750. };
  10751. /*
  10752. * BIOS auto configuration
  10753. */
  10754. /* add playback controls from the parsed DAC table */
  10755. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10756. const struct auto_pin_cfg *cfg)
  10757. {
  10758. char name[32];
  10759. static const char *chname[4] = {
  10760. "Front", "Surround", NULL /*CLFE*/, "Side"
  10761. };
  10762. hda_nid_t nid;
  10763. int i, err;
  10764. for (i = 0; i < cfg->line_outs; i++) {
  10765. if (!spec->multiout.dac_nids[i])
  10766. continue;
  10767. nid = alc880_idx_to_mixer(i);
  10768. if (i == 2) {
  10769. /* Center/LFE */
  10770. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10771. "Center Playback Volume",
  10772. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10773. HDA_OUTPUT));
  10774. if (err < 0)
  10775. return err;
  10776. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10777. "LFE Playback Volume",
  10778. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10779. HDA_OUTPUT));
  10780. if (err < 0)
  10781. return err;
  10782. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10783. "Center Playback Switch",
  10784. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10785. HDA_INPUT));
  10786. if (err < 0)
  10787. return err;
  10788. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10789. "LFE Playback Switch",
  10790. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10791. HDA_INPUT));
  10792. if (err < 0)
  10793. return err;
  10794. } else {
  10795. sprintf(name, "%s Playback Volume", chname[i]);
  10796. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10797. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10798. HDA_OUTPUT));
  10799. if (err < 0)
  10800. return err;
  10801. sprintf(name, "%s Playback Switch", chname[i]);
  10802. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10803. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10804. HDA_INPUT));
  10805. if (err < 0)
  10806. return err;
  10807. }
  10808. }
  10809. return 0;
  10810. }
  10811. /* add playback controls for speaker and HP outputs */
  10812. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10813. const char *pfx)
  10814. {
  10815. hda_nid_t nid;
  10816. int err;
  10817. char name[32];
  10818. if (!pin)
  10819. return 0;
  10820. if (alc880_is_fixed_pin(pin)) {
  10821. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10822. /* printk("DAC nid=%x\n",nid); */
  10823. /* specify the DAC as the extra output */
  10824. if (!spec->multiout.hp_nid)
  10825. spec->multiout.hp_nid = nid;
  10826. else
  10827. spec->multiout.extra_out_nid[0] = nid;
  10828. /* control HP volume/switch on the output mixer amp */
  10829. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10830. sprintf(name, "%s Playback Volume", pfx);
  10831. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10832. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10833. if (err < 0)
  10834. return err;
  10835. sprintf(name, "%s Playback Switch", pfx);
  10836. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10837. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10838. if (err < 0)
  10839. return err;
  10840. } else if (alc880_is_multi_pin(pin)) {
  10841. /* set manual connection */
  10842. /* we have only a switch on HP-out PIN */
  10843. sprintf(name, "%s Playback Switch", pfx);
  10844. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10845. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10846. if (err < 0)
  10847. return err;
  10848. }
  10849. return 0;
  10850. }
  10851. /* create playback/capture controls for input pins */
  10852. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10853. const struct auto_pin_cfg *cfg)
  10854. {
  10855. struct hda_input_mux *imux = &spec->private_imux;
  10856. int i, err, idx;
  10857. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10858. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10859. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10860. err = new_analog_input(spec, cfg->input_pins[i],
  10861. auto_pin_cfg_labels[i],
  10862. idx, 0x0b);
  10863. if (err < 0)
  10864. return err;
  10865. imux->items[imux->num_items].label =
  10866. auto_pin_cfg_labels[i];
  10867. imux->items[imux->num_items].index =
  10868. alc880_input_pin_idx(cfg->input_pins[i]);
  10869. imux->num_items++;
  10870. }
  10871. }
  10872. return 0;
  10873. }
  10874. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10875. hda_nid_t nid, int pin_type,
  10876. int dac_idx)
  10877. {
  10878. /* set as output */
  10879. snd_hda_codec_write(codec, nid, 0,
  10880. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10881. snd_hda_codec_write(codec, nid, 0,
  10882. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10883. /* need the manual connection? */
  10884. if (alc880_is_multi_pin(nid)) {
  10885. struct alc_spec *spec = codec->spec;
  10886. int idx = alc880_multi_pin_idx(nid);
  10887. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10888. AC_VERB_SET_CONNECT_SEL,
  10889. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10890. }
  10891. }
  10892. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10893. {
  10894. struct alc_spec *spec = codec->spec;
  10895. int i;
  10896. for (i = 0; i <= HDA_SIDE; i++) {
  10897. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10898. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10899. if (nid)
  10900. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10901. i);
  10902. }
  10903. }
  10904. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10905. {
  10906. struct alc_spec *spec = codec->spec;
  10907. hda_nid_t pin;
  10908. pin = spec->autocfg.hp_pins[0];
  10909. if (pin) /* connect to front */
  10910. /* use dac 0 */
  10911. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10912. }
  10913. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10914. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10915. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10916. {
  10917. struct alc_spec *spec = codec->spec;
  10918. int i;
  10919. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10920. hda_nid_t nid = spec->autocfg.input_pins[i];
  10921. if (alc662_is_input_pin(nid)) {
  10922. snd_hda_codec_write(codec, nid, 0,
  10923. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10924. (i <= AUTO_PIN_FRONT_MIC ?
  10925. PIN_VREF80 : PIN_IN));
  10926. if (nid != ALC662_PIN_CD_NID)
  10927. snd_hda_codec_write(codec, nid, 0,
  10928. AC_VERB_SET_AMP_GAIN_MUTE,
  10929. AMP_OUT_MUTE);
  10930. }
  10931. }
  10932. }
  10933. static int alc662_parse_auto_config(struct hda_codec *codec)
  10934. {
  10935. struct alc_spec *spec = codec->spec;
  10936. int err;
  10937. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10938. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10939. alc662_ignore);
  10940. if (err < 0)
  10941. return err;
  10942. if (!spec->autocfg.line_outs)
  10943. return 0; /* can't find valid BIOS pin config */
  10944. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10945. if (err < 0)
  10946. return err;
  10947. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10948. if (err < 0)
  10949. return err;
  10950. err = alc662_auto_create_extra_out(spec,
  10951. spec->autocfg.speaker_pins[0],
  10952. "Speaker");
  10953. if (err < 0)
  10954. return err;
  10955. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10956. "Headphone");
  10957. if (err < 0)
  10958. return err;
  10959. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10960. if (err < 0)
  10961. return err;
  10962. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10963. if (spec->autocfg.dig_out_pin)
  10964. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10965. if (spec->kctl_alloc)
  10966. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10967. spec->num_mux_defs = 1;
  10968. spec->input_mux = &spec->private_imux;
  10969. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10970. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10971. spec->num_mixers++;
  10972. return 1;
  10973. }
  10974. /* additional initialization for auto-configuration model */
  10975. static void alc662_auto_init(struct hda_codec *codec)
  10976. {
  10977. alc662_auto_init_multi_out(codec);
  10978. alc662_auto_init_hp_out(codec);
  10979. alc662_auto_init_analog_input(codec);
  10980. }
  10981. static int patch_alc662(struct hda_codec *codec)
  10982. {
  10983. struct alc_spec *spec;
  10984. int err, board_config;
  10985. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10986. if (!spec)
  10987. return -ENOMEM;
  10988. codec->spec = spec;
  10989. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10990. alc662_models,
  10991. alc662_cfg_tbl);
  10992. if (board_config < 0) {
  10993. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10994. "trying auto-probe from BIOS...\n");
  10995. board_config = ALC662_AUTO;
  10996. }
  10997. if (board_config == ALC662_AUTO) {
  10998. /* automatic parse from the BIOS config */
  10999. err = alc662_parse_auto_config(codec);
  11000. if (err < 0) {
  11001. alc_free(codec);
  11002. return err;
  11003. } else if (!err) {
  11004. printk(KERN_INFO
  11005. "hda_codec: Cannot set up configuration "
  11006. "from BIOS. Using base mode...\n");
  11007. board_config = ALC662_3ST_2ch_DIG;
  11008. }
  11009. }
  11010. if (board_config != ALC662_AUTO)
  11011. setup_preset(spec, &alc662_presets[board_config]);
  11012. spec->stream_name_analog = "ALC662 Analog";
  11013. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  11014. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  11015. spec->stream_name_digital = "ALC662 Digital";
  11016. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  11017. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  11018. if (!spec->adc_nids && spec->input_mux) {
  11019. spec->adc_nids = alc662_adc_nids;
  11020. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  11021. }
  11022. codec->patch_ops = alc_patch_ops;
  11023. if (board_config == ALC662_AUTO)
  11024. spec->init_hook = alc662_auto_init;
  11025. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11026. if (!spec->loopback.amplist)
  11027. spec->loopback.amplist = alc662_loopbacks;
  11028. #endif
  11029. return 0;
  11030. }
  11031. /*
  11032. * patch entries
  11033. */
  11034. struct hda_codec_preset snd_hda_preset_realtek[] = {
  11035. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  11036. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  11037. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  11038. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  11039. .patch = patch_alc861 },
  11040. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  11041. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  11042. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  11043. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  11044. .patch = patch_alc883 },
  11045. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  11046. .patch = patch_alc662 },
  11047. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  11048. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  11049. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  11050. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  11051. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  11052. {} /* terminator */
  11053. };