patch_realtek.c 372 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265
  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_AUTO,
  93. ALC262_MODEL_LAST /* last tag */
  94. };
  95. /* ALC268 models */
  96. enum {
  97. ALC268_3ST,
  98. ALC268_AUTO,
  99. ALC268_MODEL_LAST /* last tag */
  100. };
  101. /* ALC861 models */
  102. enum {
  103. ALC861_3ST,
  104. ALC660_3ST,
  105. ALC861_3ST_DIG,
  106. ALC861_6ST_DIG,
  107. ALC861_UNIWILL_M31,
  108. ALC861_TOSHIBA,
  109. ALC861_ASUS,
  110. ALC861_ASUS_LAPTOP,
  111. ALC861_AUTO,
  112. ALC861_MODEL_LAST,
  113. };
  114. /* ALC861-VD models */
  115. enum {
  116. ALC660VD_3ST,
  117. ALC861VD_3ST,
  118. ALC861VD_3ST_DIG,
  119. ALC861VD_6ST_DIG,
  120. ALC861VD_LENOVO,
  121. ALC861VD_DALLAS,
  122. ALC861VD_AUTO,
  123. ALC861VD_MODEL_LAST,
  124. };
  125. /* ALC662 models */
  126. enum {
  127. ALC662_3ST_2ch_DIG,
  128. ALC662_3ST_6ch_DIG,
  129. ALC662_3ST_6ch,
  130. ALC662_5ST_DIG,
  131. ALC662_LENOVO_101E,
  132. ALC662_AUTO,
  133. ALC662_MODEL_LAST,
  134. };
  135. /* ALC882 models */
  136. enum {
  137. ALC882_3ST_DIG,
  138. ALC882_6ST_DIG,
  139. ALC882_ARIMA,
  140. ALC882_W2JC,
  141. ALC882_TARGA,
  142. ALC882_ASUS_A7J,
  143. ALC885_MACPRO,
  144. ALC882_AUTO,
  145. ALC882_MODEL_LAST,
  146. };
  147. /* ALC883 models */
  148. enum {
  149. ALC883_3ST_2ch_DIG,
  150. ALC883_3ST_6ch_DIG,
  151. ALC883_3ST_6ch,
  152. ALC883_6ST_DIG,
  153. ALC883_TARGA_DIG,
  154. ALC883_TARGA_2ch_DIG,
  155. ALC883_ACER,
  156. ALC883_MEDION,
  157. ALC883_MEDION_MD2,
  158. ALC883_LAPTOP_EAPD,
  159. ALC883_LENOVO_101E_2ch,
  160. ALC883_LENOVO_NB0763,
  161. ALC888_LENOVO_MS7195_DIG,
  162. ALC883_AUTO,
  163. ALC883_MODEL_LAST,
  164. };
  165. /* for GPIO Poll */
  166. #define GPIO_MASK 0x03
  167. struct alc_spec {
  168. /* codec parameterization */
  169. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  170. unsigned int num_mixers;
  171. const struct hda_verb *init_verbs[5]; /* initialization verbs
  172. * don't forget NULL
  173. * termination!
  174. */
  175. unsigned int num_init_verbs;
  176. char *stream_name_analog; /* analog PCM stream */
  177. struct hda_pcm_stream *stream_analog_playback;
  178. struct hda_pcm_stream *stream_analog_capture;
  179. char *stream_name_digital; /* digital PCM stream */
  180. struct hda_pcm_stream *stream_digital_playback;
  181. struct hda_pcm_stream *stream_digital_capture;
  182. /* playback */
  183. struct hda_multi_out multiout; /* playback set-up
  184. * max_channels, dacs must be set
  185. * dig_out_nid and hp_nid are optional
  186. */
  187. /* capture */
  188. unsigned int num_adc_nids;
  189. hda_nid_t *adc_nids;
  190. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  191. /* capture source */
  192. unsigned int num_mux_defs;
  193. const struct hda_input_mux *input_mux;
  194. unsigned int cur_mux[3];
  195. /* channel model */
  196. const struct hda_channel_mode *channel_mode;
  197. int num_channel_mode;
  198. int need_dac_fix;
  199. /* PCM information */
  200. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  201. /* dynamic controls, init_verbs and input_mux */
  202. struct auto_pin_cfg autocfg;
  203. unsigned int num_kctl_alloc, num_kctl_used;
  204. struct snd_kcontrol_new *kctl_alloc;
  205. struct hda_input_mux private_imux;
  206. hda_nid_t private_dac_nids[5];
  207. /* hooks */
  208. void (*init_hook)(struct hda_codec *codec);
  209. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  210. /* for pin sensing */
  211. unsigned int sense_updated: 1;
  212. unsigned int jack_present: 1;
  213. };
  214. /*
  215. * configuration template - to be copied to the spec instance
  216. */
  217. struct alc_config_preset {
  218. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  219. * with spec
  220. */
  221. const struct hda_verb *init_verbs[5];
  222. unsigned int num_dacs;
  223. hda_nid_t *dac_nids;
  224. hda_nid_t dig_out_nid; /* optional */
  225. hda_nid_t hp_nid; /* optional */
  226. unsigned int num_adc_nids;
  227. hda_nid_t *adc_nids;
  228. hda_nid_t dig_in_nid;
  229. unsigned int num_channel_mode;
  230. const struct hda_channel_mode *channel_mode;
  231. int need_dac_fix;
  232. unsigned int num_mux_defs;
  233. const struct hda_input_mux *input_mux;
  234. void (*unsol_event)(struct hda_codec *, unsigned int);
  235. void (*init_hook)(struct hda_codec *);
  236. };
  237. /*
  238. * input MUX handling
  239. */
  240. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  241. struct snd_ctl_elem_info *uinfo)
  242. {
  243. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  244. struct alc_spec *spec = codec->spec;
  245. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  246. if (mux_idx >= spec->num_mux_defs)
  247. mux_idx = 0;
  248. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  249. }
  250. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  251. struct snd_ctl_elem_value *ucontrol)
  252. {
  253. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  254. struct alc_spec *spec = codec->spec;
  255. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  256. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  257. return 0;
  258. }
  259. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  260. struct snd_ctl_elem_value *ucontrol)
  261. {
  262. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  263. struct alc_spec *spec = codec->spec;
  264. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  265. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  266. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  267. spec->adc_nids[adc_idx],
  268. &spec->cur_mux[adc_idx]);
  269. }
  270. /*
  271. * channel mode setting
  272. */
  273. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  274. struct snd_ctl_elem_info *uinfo)
  275. {
  276. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  277. struct alc_spec *spec = codec->spec;
  278. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  279. spec->num_channel_mode);
  280. }
  281. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  282. struct snd_ctl_elem_value *ucontrol)
  283. {
  284. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  285. struct alc_spec *spec = codec->spec;
  286. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  287. spec->num_channel_mode,
  288. spec->multiout.max_channels);
  289. }
  290. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  291. struct snd_ctl_elem_value *ucontrol)
  292. {
  293. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  294. struct alc_spec *spec = codec->spec;
  295. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  296. spec->num_channel_mode,
  297. &spec->multiout.max_channels);
  298. if (err >= 0 && spec->need_dac_fix)
  299. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  300. return err;
  301. }
  302. /*
  303. * Control the mode of pin widget settings via the mixer. "pc" is used
  304. * instead of "%" to avoid consequences of accidently treating the % as
  305. * being part of a format specifier. Maximum allowed length of a value is
  306. * 63 characters plus NULL terminator.
  307. *
  308. * Note: some retasking pin complexes seem to ignore requests for input
  309. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  310. * are requested. Therefore order this list so that this behaviour will not
  311. * cause problems when mixer clients move through the enum sequentially.
  312. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  313. * March 2006.
  314. */
  315. static char *alc_pin_mode_names[] = {
  316. "Mic 50pc bias", "Mic 80pc bias",
  317. "Line in", "Line out", "Headphone out",
  318. };
  319. static unsigned char alc_pin_mode_values[] = {
  320. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  321. };
  322. /* The control can present all 5 options, or it can limit the options based
  323. * in the pin being assumed to be exclusively an input or an output pin. In
  324. * addition, "input" pins may or may not process the mic bias option
  325. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  326. * accept requests for bias as of chip versions up to March 2006) and/or
  327. * wiring in the computer.
  328. */
  329. #define ALC_PIN_DIR_IN 0x00
  330. #define ALC_PIN_DIR_OUT 0x01
  331. #define ALC_PIN_DIR_INOUT 0x02
  332. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  333. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  334. /* Info about the pin modes supported by the different pin direction modes.
  335. * For each direction the minimum and maximum values are given.
  336. */
  337. static signed char alc_pin_mode_dir_info[5][2] = {
  338. { 0, 2 }, /* ALC_PIN_DIR_IN */
  339. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  340. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  341. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  342. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  343. };
  344. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  345. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  346. #define alc_pin_mode_n_items(_dir) \
  347. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  348. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  349. struct snd_ctl_elem_info *uinfo)
  350. {
  351. unsigned int item_num = uinfo->value.enumerated.item;
  352. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  353. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  354. uinfo->count = 1;
  355. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  356. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  357. item_num = alc_pin_mode_min(dir);
  358. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  359. return 0;
  360. }
  361. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  362. struct snd_ctl_elem_value *ucontrol)
  363. {
  364. unsigned int i;
  365. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  366. hda_nid_t nid = kcontrol->private_value & 0xffff;
  367. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  368. long *valp = ucontrol->value.integer.value;
  369. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  370. AC_VERB_GET_PIN_WIDGET_CONTROL,
  371. 0x00);
  372. /* Find enumerated value for current pinctl setting */
  373. i = alc_pin_mode_min(dir);
  374. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  375. i++;
  376. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  377. return 0;
  378. }
  379. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  380. struct snd_ctl_elem_value *ucontrol)
  381. {
  382. signed int change;
  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 val = *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. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  391. val = alc_pin_mode_min(dir);
  392. change = pinctl != alc_pin_mode_values[val];
  393. if (change) {
  394. /* Set pin mode to that requested */
  395. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  396. alc_pin_mode_values[val]);
  397. /* Also enable the retasking pin's input/output as required
  398. * for the requested pin mode. Enum values of 2 or less are
  399. * input modes.
  400. *
  401. * Dynamically switching the input/output buffers probably
  402. * reduces noise slightly (particularly on input) so we'll
  403. * do it. However, having both input and output buffers
  404. * enabled simultaneously doesn't seem to be problematic if
  405. * this turns out to be necessary in the future.
  406. */
  407. if (val <= 2) {
  408. snd_hda_codec_write(codec, nid, 0,
  409. AC_VERB_SET_AMP_GAIN_MUTE,
  410. AMP_OUT_MUTE);
  411. snd_hda_codec_write(codec, nid, 0,
  412. AC_VERB_SET_AMP_GAIN_MUTE,
  413. AMP_IN_UNMUTE(0));
  414. } else {
  415. snd_hda_codec_write(codec, nid, 0,
  416. AC_VERB_SET_AMP_GAIN_MUTE,
  417. AMP_IN_MUTE(0));
  418. snd_hda_codec_write(codec, nid, 0,
  419. AC_VERB_SET_AMP_GAIN_MUTE,
  420. AMP_OUT_UNMUTE);
  421. }
  422. }
  423. return change;
  424. }
  425. #define ALC_PIN_MODE(xname, nid, dir) \
  426. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  427. .info = alc_pin_mode_info, \
  428. .get = alc_pin_mode_get, \
  429. .put = alc_pin_mode_put, \
  430. .private_value = nid | (dir<<16) }
  431. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  432. * together using a mask with more than one bit set. This control is
  433. * currently used only by the ALC260 test model. At this stage they are not
  434. * needed for any "production" models.
  435. */
  436. #ifdef CONFIG_SND_DEBUG
  437. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  438. struct snd_ctl_elem_info *uinfo)
  439. {
  440. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  441. uinfo->count = 1;
  442. uinfo->value.integer.min = 0;
  443. uinfo->value.integer.max = 1;
  444. return 0;
  445. }
  446. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  447. struct snd_ctl_elem_value *ucontrol)
  448. {
  449. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  450. hda_nid_t nid = kcontrol->private_value & 0xffff;
  451. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  452. long *valp = ucontrol->value.integer.value;
  453. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  454. AC_VERB_GET_GPIO_DATA, 0x00);
  455. *valp = (val & mask) != 0;
  456. return 0;
  457. }
  458. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  459. struct snd_ctl_elem_value *ucontrol)
  460. {
  461. signed int change;
  462. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  463. hda_nid_t nid = kcontrol->private_value & 0xffff;
  464. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  465. long val = *ucontrol->value.integer.value;
  466. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  467. AC_VERB_GET_GPIO_DATA,
  468. 0x00);
  469. /* Set/unset the masked GPIO bit(s) as needed */
  470. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  471. if (val == 0)
  472. gpio_data &= ~mask;
  473. else
  474. gpio_data |= mask;
  475. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  476. return change;
  477. }
  478. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  479. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  480. .info = alc_gpio_data_info, \
  481. .get = alc_gpio_data_get, \
  482. .put = alc_gpio_data_put, \
  483. .private_value = nid | (mask<<16) }
  484. #endif /* CONFIG_SND_DEBUG */
  485. /* A switch control to allow the enabling of the digital IO pins on the
  486. * ALC260. This is incredibly simplistic; the intention of this control is
  487. * to provide something in the test model allowing digital outputs to be
  488. * identified if present. If models are found which can utilise these
  489. * outputs a more complete mixer control can be devised for those models if
  490. * necessary.
  491. */
  492. #ifdef CONFIG_SND_DEBUG
  493. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  494. struct snd_ctl_elem_info *uinfo)
  495. {
  496. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  497. uinfo->count = 1;
  498. uinfo->value.integer.min = 0;
  499. uinfo->value.integer.max = 1;
  500. return 0;
  501. }
  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(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. }
  573. /* Enable GPIO mask and set output */
  574. static struct hda_verb alc_gpio1_init_verbs[] = {
  575. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  576. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  577. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  578. { }
  579. };
  580. static struct hda_verb alc_gpio2_init_verbs[] = {
  581. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  582. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  583. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  584. { }
  585. };
  586. static struct hda_verb alc_gpio3_init_verbs[] = {
  587. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  588. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  589. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  590. { }
  591. };
  592. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  593. * 31 ~ 16 : Manufacture ID
  594. * 15 ~ 8 : SKU ID
  595. * 7 ~ 0 : Assembly ID
  596. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  597. */
  598. static void alc_subsystem_id(struct hda_codec *codec,
  599. unsigned int porta, unsigned int porte,
  600. unsigned int portd)
  601. {
  602. unsigned int ass, tmp;
  603. ass = codec->subsystem_id;
  604. if (!(ass & 1))
  605. return;
  606. /* Override */
  607. tmp = (ass & 0x38) >> 3; /* external Amp control */
  608. switch (tmp) {
  609. case 1:
  610. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  611. break;
  612. case 3:
  613. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  614. break;
  615. case 7:
  616. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  617. break;
  618. case 5:
  619. switch (codec->vendor_id) {
  620. case 0x10ec0862:
  621. case 0x10ec0660:
  622. case 0x10ec0662:
  623. case 0x10ec0267:
  624. case 0x10ec0268:
  625. snd_hda_codec_write(codec, 0x14, 0,
  626. AC_VERB_SET_EAPD_BTLENABLE, 2);
  627. snd_hda_codec_write(codec, 0x15, 0,
  628. AC_VERB_SET_EAPD_BTLENABLE, 2);
  629. return;
  630. }
  631. case 6:
  632. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  633. hda_nid_t port = 0;
  634. tmp = (ass & 0x1800) >> 11;
  635. switch (tmp) {
  636. case 0: port = porta; break;
  637. case 1: port = porte; break;
  638. case 2: port = portd; break;
  639. }
  640. if (port)
  641. snd_hda_codec_write(codec, port, 0,
  642. AC_VERB_SET_EAPD_BTLENABLE,
  643. 2);
  644. }
  645. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  646. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  647. (tmp == 5 ? 0x3040 : 0x3050));
  648. break;
  649. }
  650. }
  651. /*
  652. * ALC880 3-stack model
  653. *
  654. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  655. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  656. * F-Mic = 0x1b, HP = 0x19
  657. */
  658. static hda_nid_t alc880_dac_nids[4] = {
  659. /* front, rear, clfe, rear_surr */
  660. 0x02, 0x05, 0x04, 0x03
  661. };
  662. static hda_nid_t alc880_adc_nids[3] = {
  663. /* ADC0-2 */
  664. 0x07, 0x08, 0x09,
  665. };
  666. /* The datasheet says the node 0x07 is connected from inputs,
  667. * but it shows zero connection in the real implementation on some devices.
  668. * Note: this is a 915GAV bug, fixed on 915GLV
  669. */
  670. static hda_nid_t alc880_adc_nids_alt[2] = {
  671. /* ADC1-2 */
  672. 0x08, 0x09,
  673. };
  674. #define ALC880_DIGOUT_NID 0x06
  675. #define ALC880_DIGIN_NID 0x0a
  676. static struct hda_input_mux alc880_capture_source = {
  677. .num_items = 4,
  678. .items = {
  679. { "Mic", 0x0 },
  680. { "Front Mic", 0x3 },
  681. { "Line", 0x2 },
  682. { "CD", 0x4 },
  683. },
  684. };
  685. /* channel source setting (2/6 channel selection for 3-stack) */
  686. /* 2ch mode */
  687. static struct hda_verb alc880_threestack_ch2_init[] = {
  688. /* set line-in to input, mute it */
  689. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  690. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  691. /* set mic-in to input vref 80%, mute it */
  692. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  693. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  694. { } /* end */
  695. };
  696. /* 6ch mode */
  697. static struct hda_verb alc880_threestack_ch6_init[] = {
  698. /* set line-in to output, unmute it */
  699. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  700. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  701. /* set mic-in to output, unmute it */
  702. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  703. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  704. { } /* end */
  705. };
  706. static struct hda_channel_mode alc880_threestack_modes[2] = {
  707. { 2, alc880_threestack_ch2_init },
  708. { 6, alc880_threestack_ch6_init },
  709. };
  710. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  711. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  712. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  713. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  714. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  715. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  716. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  717. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  718. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  719. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  720. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  721. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  722. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  723. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  724. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  725. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  726. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  727. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  728. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  729. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  730. {
  731. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  732. .name = "Channel Mode",
  733. .info = alc_ch_mode_info,
  734. .get = alc_ch_mode_get,
  735. .put = alc_ch_mode_put,
  736. },
  737. { } /* end */
  738. };
  739. /* capture mixer elements */
  740. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  741. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  742. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  743. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  744. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  745. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  746. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  747. {
  748. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  749. /* The multiple "Capture Source" controls confuse alsamixer
  750. * So call somewhat different..
  751. * FIXME: the controls appear in the "playback" view!
  752. */
  753. /* .name = "Capture Source", */
  754. .name = "Input Source",
  755. .count = 3,
  756. .info = alc_mux_enum_info,
  757. .get = alc_mux_enum_get,
  758. .put = alc_mux_enum_put,
  759. },
  760. { } /* end */
  761. };
  762. /* capture mixer elements (in case NID 0x07 not available) */
  763. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  764. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  765. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  766. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  767. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  768. {
  769. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  770. /* The multiple "Capture Source" controls confuse alsamixer
  771. * So call somewhat different..
  772. * FIXME: the controls appear in the "playback" view!
  773. */
  774. /* .name = "Capture Source", */
  775. .name = "Input Source",
  776. .count = 2,
  777. .info = alc_mux_enum_info,
  778. .get = alc_mux_enum_get,
  779. .put = alc_mux_enum_put,
  780. },
  781. { } /* end */
  782. };
  783. /*
  784. * ALC880 5-stack model
  785. *
  786. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  787. * Side = 0x02 (0xd)
  788. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  789. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  790. */
  791. /* additional mixers to alc880_three_stack_mixer */
  792. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  793. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  794. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  795. { } /* end */
  796. };
  797. /* channel source setting (6/8 channel selection for 5-stack) */
  798. /* 6ch mode */
  799. static struct hda_verb alc880_fivestack_ch6_init[] = {
  800. /* set line-in to input, mute it */
  801. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  802. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  803. { } /* end */
  804. };
  805. /* 8ch mode */
  806. static struct hda_verb alc880_fivestack_ch8_init[] = {
  807. /* set line-in to output, unmute it */
  808. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  809. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  810. { } /* end */
  811. };
  812. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  813. { 6, alc880_fivestack_ch6_init },
  814. { 8, alc880_fivestack_ch8_init },
  815. };
  816. /*
  817. * ALC880 6-stack model
  818. *
  819. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  820. * Side = 0x05 (0x0f)
  821. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  822. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  823. */
  824. static hda_nid_t alc880_6st_dac_nids[4] = {
  825. /* front, rear, clfe, rear_surr */
  826. 0x02, 0x03, 0x04, 0x05
  827. };
  828. static struct hda_input_mux alc880_6stack_capture_source = {
  829. .num_items = 4,
  830. .items = {
  831. { "Mic", 0x0 },
  832. { "Front Mic", 0x1 },
  833. { "Line", 0x2 },
  834. { "CD", 0x4 },
  835. },
  836. };
  837. /* fixed 8-channels */
  838. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  839. { 8, NULL },
  840. };
  841. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  842. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  843. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  844. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  845. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  846. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  847. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  848. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  849. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  850. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  851. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  852. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  853. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  854. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  855. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  856. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  857. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  858. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  859. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  860. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  861. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  862. {
  863. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  864. .name = "Channel Mode",
  865. .info = alc_ch_mode_info,
  866. .get = alc_ch_mode_get,
  867. .put = alc_ch_mode_put,
  868. },
  869. { } /* end */
  870. };
  871. /*
  872. * ALC880 W810 model
  873. *
  874. * W810 has rear IO for:
  875. * Front (DAC 02)
  876. * Surround (DAC 03)
  877. * Center/LFE (DAC 04)
  878. * Digital out (06)
  879. *
  880. * The system also has a pair of internal speakers, and a headphone jack.
  881. * These are both connected to Line2 on the codec, hence to DAC 02.
  882. *
  883. * There is a variable resistor to control the speaker or headphone
  884. * volume. This is a hardware-only device without a software API.
  885. *
  886. * Plugging headphones in will disable the internal speakers. This is
  887. * implemented in hardware, not via the driver using jack sense. In
  888. * a similar fashion, plugging into the rear socket marked "front" will
  889. * disable both the speakers and headphones.
  890. *
  891. * For input, there's a microphone jack, and an "audio in" jack.
  892. * These may not do anything useful with this driver yet, because I
  893. * haven't setup any initialization verbs for these yet...
  894. */
  895. static hda_nid_t alc880_w810_dac_nids[3] = {
  896. /* front, rear/surround, clfe */
  897. 0x02, 0x03, 0x04
  898. };
  899. /* fixed 6 channels */
  900. static struct hda_channel_mode alc880_w810_modes[1] = {
  901. { 6, NULL }
  902. };
  903. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  904. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  905. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  906. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  907. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  908. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  909. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  910. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  911. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  912. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  913. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  914. { } /* end */
  915. };
  916. /*
  917. * Z710V model
  918. *
  919. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  920. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  921. * Line = 0x1a
  922. */
  923. static hda_nid_t alc880_z71v_dac_nids[1] = {
  924. 0x02
  925. };
  926. #define ALC880_Z71V_HP_DAC 0x03
  927. /* fixed 2 channels */
  928. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  929. { 2, NULL }
  930. };
  931. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  932. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  933. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  934. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  935. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  936. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  937. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  938. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  939. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  940. { } /* end */
  941. };
  942. /* FIXME! */
  943. /*
  944. * ALC880 F1734 model
  945. *
  946. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  947. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  948. */
  949. static hda_nid_t alc880_f1734_dac_nids[1] = {
  950. 0x03
  951. };
  952. #define ALC880_F1734_HP_DAC 0x02
  953. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  954. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  955. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  956. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  957. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  958. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  959. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  960. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  961. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  962. { } /* end */
  963. };
  964. /* FIXME! */
  965. /*
  966. * ALC880 ASUS model
  967. *
  968. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  969. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  970. * Mic = 0x18, Line = 0x1a
  971. */
  972. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  973. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  974. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  975. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  976. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  977. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  978. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  979. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  980. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  981. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  982. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  983. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  984. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  985. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  986. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  987. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  988. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  989. {
  990. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  991. .name = "Channel Mode",
  992. .info = alc_ch_mode_info,
  993. .get = alc_ch_mode_get,
  994. .put = alc_ch_mode_put,
  995. },
  996. { } /* end */
  997. };
  998. /* FIXME! */
  999. /*
  1000. * ALC880 ASUS W1V model
  1001. *
  1002. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1003. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1004. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1005. */
  1006. /* additional mixers to alc880_asus_mixer */
  1007. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1008. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1009. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1010. { } /* end */
  1011. };
  1012. /* additional mixers to alc880_asus_mixer */
  1013. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1014. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1015. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1016. { } /* end */
  1017. };
  1018. /* TCL S700 */
  1019. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1020. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1021. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1022. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1023. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1024. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1025. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1026. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1027. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1028. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1029. {
  1030. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1031. /* The multiple "Capture Source" controls confuse alsamixer
  1032. * So call somewhat different..
  1033. * FIXME: the controls appear in the "playback" view!
  1034. */
  1035. /* .name = "Capture Source", */
  1036. .name = "Input Source",
  1037. .count = 1,
  1038. .info = alc_mux_enum_info,
  1039. .get = alc_mux_enum_get,
  1040. .put = alc_mux_enum_put,
  1041. },
  1042. { } /* end */
  1043. };
  1044. /* Uniwill */
  1045. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1046. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1047. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1048. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1049. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1050. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1051. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1052. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1053. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1054. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1055. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1056. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1057. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1058. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1059. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1060. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1061. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1062. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1063. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1064. {
  1065. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1066. .name = "Channel Mode",
  1067. .info = alc_ch_mode_info,
  1068. .get = alc_ch_mode_get,
  1069. .put = alc_ch_mode_put,
  1070. },
  1071. { } /* end */
  1072. };
  1073. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1074. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1075. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1076. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1077. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1078. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1079. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1080. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1081. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1082. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1083. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1084. { } /* end */
  1085. };
  1086. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1087. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1088. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1089. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1090. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1091. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1092. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1093. { } /* end */
  1094. };
  1095. /*
  1096. * build control elements
  1097. */
  1098. static int alc_build_controls(struct hda_codec *codec)
  1099. {
  1100. struct alc_spec *spec = codec->spec;
  1101. int err;
  1102. int i;
  1103. for (i = 0; i < spec->num_mixers; i++) {
  1104. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1105. if (err < 0)
  1106. return err;
  1107. }
  1108. if (spec->multiout.dig_out_nid) {
  1109. err = snd_hda_create_spdif_out_ctls(codec,
  1110. spec->multiout.dig_out_nid);
  1111. if (err < 0)
  1112. return err;
  1113. }
  1114. if (spec->dig_in_nid) {
  1115. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1116. if (err < 0)
  1117. return err;
  1118. }
  1119. return 0;
  1120. }
  1121. /*
  1122. * initialize the codec volumes, etc
  1123. */
  1124. /*
  1125. * generic initialization of ADC, input mixers and output mixers
  1126. */
  1127. static struct hda_verb alc880_volume_init_verbs[] = {
  1128. /*
  1129. * Unmute ADC0-2 and set the default input to mic-in
  1130. */
  1131. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1132. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1133. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1134. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1135. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1136. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1137. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1138. * mixer widget
  1139. * Note: PASD motherboards uses the Line In 2 as the input for front
  1140. * panel mic (mic 2)
  1141. */
  1142. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1143. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1144. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1145. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1146. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1147. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1148. /*
  1149. * Set up output mixers (0x0c - 0x0f)
  1150. */
  1151. /* set vol=0 to output mixers */
  1152. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1153. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1154. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1155. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1156. /* set up input amps for analog loopback */
  1157. /* Amp Indices: DAC = 0, mixer = 1 */
  1158. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1159. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1160. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1161. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1162. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1163. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1164. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1165. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1166. { }
  1167. };
  1168. /*
  1169. * 3-stack pin configuration:
  1170. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1171. */
  1172. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1173. /*
  1174. * preset connection lists of input pins
  1175. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1176. */
  1177. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1178. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1179. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1180. /*
  1181. * Set pin mode and muting
  1182. */
  1183. /* set front pin widgets 0x14 for output */
  1184. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1185. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1186. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1187. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1188. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1189. /* Mic2 (as headphone out) for HP output */
  1190. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1191. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1192. /* Line In pin widget for input */
  1193. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1194. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1195. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1196. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1197. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1198. /* CD pin widget for input */
  1199. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1200. { }
  1201. };
  1202. /*
  1203. * 5-stack pin configuration:
  1204. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1205. * line-in/side = 0x1a, f-mic = 0x1b
  1206. */
  1207. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1208. /*
  1209. * preset connection lists of input pins
  1210. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1211. */
  1212. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1213. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1214. /*
  1215. * Set pin mode and muting
  1216. */
  1217. /* set pin widgets 0x14-0x17 for output */
  1218. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1219. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1220. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1221. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1222. /* unmute pins for output (no gain on this amp) */
  1223. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1224. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1225. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1226. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1227. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1228. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1229. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1230. /* Mic2 (as headphone out) for HP output */
  1231. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1232. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1233. /* Line In pin widget for input */
  1234. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1235. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1236. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1237. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1238. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1239. /* CD pin widget for input */
  1240. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1241. { }
  1242. };
  1243. /*
  1244. * W810 pin configuration:
  1245. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1246. */
  1247. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1248. /* hphone/speaker input selector: front DAC */
  1249. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1250. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1251. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1252. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1253. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1254. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1255. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1257. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1258. { }
  1259. };
  1260. /*
  1261. * Z71V pin configuration:
  1262. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1263. */
  1264. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1265. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1266. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1267. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1268. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1269. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1270. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1271. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1272. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1273. { }
  1274. };
  1275. /*
  1276. * 6-stack pin configuration:
  1277. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1278. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1279. */
  1280. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1281. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  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. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1289. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1290. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1291. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1292. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1293. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1294. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1295. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1296. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1297. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1298. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1299. { }
  1300. };
  1301. /*
  1302. * Uniwill pin configuration:
  1303. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1304. * line = 0x1a
  1305. */
  1306. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1307. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1308. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1309. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1310. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1311. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1312. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1313. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1314. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1315. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1316. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1317. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1318. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1319. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1320. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1321. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  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. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1332. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1333. { }
  1334. };
  1335. /*
  1336. * Uniwill P53
  1337. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1338. */
  1339. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1340. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1341. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1342. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1343. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1344. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1345. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1346. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1347. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1349. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1351. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1353. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1354. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1355. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1356. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1357. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1358. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1359. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1360. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1361. { }
  1362. };
  1363. static struct hda_verb alc880_beep_init_verbs[] = {
  1364. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1365. { }
  1366. };
  1367. /* toggle speaker-output according to the hp-jack state */
  1368. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1369. {
  1370. unsigned int present;
  1371. unsigned char bits;
  1372. present = snd_hda_codec_read(codec, 0x14, 0,
  1373. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1374. bits = present ? 0x80 : 0;
  1375. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1376. 0x80, bits);
  1377. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1378. 0x80, bits);
  1379. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1380. 0x80, bits);
  1381. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1382. 0x80, bits);
  1383. }
  1384. /* auto-toggle front mic */
  1385. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1386. {
  1387. unsigned int present;
  1388. unsigned char bits;
  1389. present = snd_hda_codec_read(codec, 0x18, 0,
  1390. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1391. bits = present ? 0x80 : 0;
  1392. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1393. 0x80, bits);
  1394. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1395. 0x80, bits);
  1396. }
  1397. static void alc880_uniwill_automute(struct hda_codec *codec)
  1398. {
  1399. alc880_uniwill_hp_automute(codec);
  1400. alc880_uniwill_mic_automute(codec);
  1401. }
  1402. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1403. unsigned int res)
  1404. {
  1405. /* Looks like the unsol event is incompatible with the standard
  1406. * definition. 4bit tag is placed at 28 bit!
  1407. */
  1408. switch (res >> 28) {
  1409. case ALC880_HP_EVENT:
  1410. alc880_uniwill_hp_automute(codec);
  1411. break;
  1412. case ALC880_MIC_EVENT:
  1413. alc880_uniwill_mic_automute(codec);
  1414. break;
  1415. }
  1416. }
  1417. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1418. {
  1419. unsigned int present;
  1420. unsigned char bits;
  1421. present = snd_hda_codec_read(codec, 0x14, 0,
  1422. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1423. bits = present ? 0x80 : 0;
  1424. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1425. 0x80, bits);
  1426. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1427. 0x80, bits);
  1428. }
  1429. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1430. {
  1431. unsigned int present;
  1432. present = snd_hda_codec_read(codec, 0x21, 0,
  1433. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1434. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1435. 0x7f, present);
  1436. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1437. 0x7f, present);
  1438. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1439. 0x7f, present);
  1440. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1441. 0x7f, present);
  1442. }
  1443. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1444. unsigned int res)
  1445. {
  1446. /* Looks like the unsol event is incompatible with the standard
  1447. * definition. 4bit tag is placed at 28 bit!
  1448. */
  1449. if ((res >> 28) == ALC880_HP_EVENT)
  1450. alc880_uniwill_p53_hp_automute(codec);
  1451. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1452. alc880_uniwill_p53_dcvol_automute(codec);
  1453. }
  1454. /* FIXME! */
  1455. /*
  1456. * F1734 pin configuration:
  1457. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1458. */
  1459. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1460. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1461. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1462. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1463. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1464. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1465. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1466. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1467. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1468. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1469. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1470. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1471. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1472. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1473. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1474. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1475. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1476. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1477. { }
  1478. };
  1479. /* FIXME! */
  1480. /*
  1481. * ASUS pin configuration:
  1482. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1483. */
  1484. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1485. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1486. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1487. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1488. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1489. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1490. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1491. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1492. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1493. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1494. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1495. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1496. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1497. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1498. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1499. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1500. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1501. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1502. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1503. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1504. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1505. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1506. { }
  1507. };
  1508. /* Enable GPIO mask and set output */
  1509. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1510. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1511. /* Clevo m520g init */
  1512. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1513. /* headphone output */
  1514. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1515. /* line-out */
  1516. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1517. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1518. /* Line-in */
  1519. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1520. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1521. /* CD */
  1522. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1523. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1524. /* Mic1 (rear panel) */
  1525. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1526. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1527. /* Mic2 (front panel) */
  1528. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1529. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1530. /* headphone */
  1531. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1532. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1533. /* change to EAPD mode */
  1534. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1535. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1536. { }
  1537. };
  1538. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1539. /* change to EAPD mode */
  1540. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1541. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1542. /* Headphone output */
  1543. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1544. /* Front output*/
  1545. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1546. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1547. /* Line In pin widget for input */
  1548. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1549. /* CD pin widget for input */
  1550. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1551. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1552. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1553. /* change to EAPD mode */
  1554. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1555. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1556. { }
  1557. };
  1558. /*
  1559. * LG m1 express dual
  1560. *
  1561. * Pin assignment:
  1562. * Rear Line-In/Out (blue): 0x14
  1563. * Build-in Mic-In: 0x15
  1564. * Speaker-out: 0x17
  1565. * HP-Out (green): 0x1b
  1566. * Mic-In/Out (red): 0x19
  1567. * SPDIF-Out: 0x1e
  1568. */
  1569. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1570. static hda_nid_t alc880_lg_dac_nids[3] = {
  1571. 0x05, 0x02, 0x03
  1572. };
  1573. /* seems analog CD is not working */
  1574. static struct hda_input_mux alc880_lg_capture_source = {
  1575. .num_items = 3,
  1576. .items = {
  1577. { "Mic", 0x1 },
  1578. { "Line", 0x5 },
  1579. { "Internal Mic", 0x6 },
  1580. },
  1581. };
  1582. /* 2,4,6 channel modes */
  1583. static struct hda_verb alc880_lg_ch2_init[] = {
  1584. /* set line-in and mic-in to input */
  1585. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1586. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1587. { }
  1588. };
  1589. static struct hda_verb alc880_lg_ch4_init[] = {
  1590. /* set line-in to out and mic-in to input */
  1591. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1592. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1593. { }
  1594. };
  1595. static struct hda_verb alc880_lg_ch6_init[] = {
  1596. /* set line-in and mic-in to output */
  1597. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1598. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1599. { }
  1600. };
  1601. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1602. { 2, alc880_lg_ch2_init },
  1603. { 4, alc880_lg_ch4_init },
  1604. { 6, alc880_lg_ch6_init },
  1605. };
  1606. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1607. /* FIXME: it's not really "master" but front channels */
  1608. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1609. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1610. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1611. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1612. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1613. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1614. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1615. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1616. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1617. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1618. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1619. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1620. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1621. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1622. {
  1623. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1624. .name = "Channel Mode",
  1625. .info = alc_ch_mode_info,
  1626. .get = alc_ch_mode_get,
  1627. .put = alc_ch_mode_put,
  1628. },
  1629. { } /* end */
  1630. };
  1631. static struct hda_verb alc880_lg_init_verbs[] = {
  1632. /* set capture source to mic-in */
  1633. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1634. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1635. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1636. /* mute all amp mixer inputs */
  1637. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1638. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1639. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1640. /* line-in to input */
  1641. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1642. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1643. /* built-in mic */
  1644. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1645. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1646. /* speaker-out */
  1647. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1648. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1649. /* mic-in to input */
  1650. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1651. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1652. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1653. /* HP-out */
  1654. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1655. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1656. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1657. /* jack sense */
  1658. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1659. { }
  1660. };
  1661. /* toggle speaker-output according to the hp-jack state */
  1662. static void alc880_lg_automute(struct hda_codec *codec)
  1663. {
  1664. unsigned int present;
  1665. unsigned char bits;
  1666. present = snd_hda_codec_read(codec, 0x1b, 0,
  1667. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1668. bits = present ? 0x80 : 0;
  1669. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1670. 0x80, bits);
  1671. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1672. 0x80, bits);
  1673. }
  1674. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1675. {
  1676. /* Looks like the unsol event is incompatible with the standard
  1677. * definition. 4bit tag is placed at 28 bit!
  1678. */
  1679. if ((res >> 28) == 0x01)
  1680. alc880_lg_automute(codec);
  1681. }
  1682. /*
  1683. * LG LW20
  1684. *
  1685. * Pin assignment:
  1686. * Speaker-out: 0x14
  1687. * Mic-In: 0x18
  1688. * Built-in Mic-In: 0x19 (?)
  1689. * HP-Out: 0x1b
  1690. * SPDIF-Out: 0x1e
  1691. */
  1692. /* seems analog CD is not working */
  1693. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1694. .num_items = 2,
  1695. .items = {
  1696. { "Mic", 0x0 },
  1697. { "Internal Mic", 0x1 },
  1698. },
  1699. };
  1700. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1701. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1702. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1703. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1704. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1705. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1706. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1707. { } /* end */
  1708. };
  1709. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1710. /* set capture source to mic-in */
  1711. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1712. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1713. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1714. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1715. /* speaker-out */
  1716. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1717. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1718. /* HP-out */
  1719. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1720. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1721. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1722. /* mic-in to input */
  1723. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1724. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1725. /* built-in mic */
  1726. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1727. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1728. /* jack sense */
  1729. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1730. { }
  1731. };
  1732. /* toggle speaker-output according to the hp-jack state */
  1733. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1734. {
  1735. unsigned int present;
  1736. unsigned char bits;
  1737. present = snd_hda_codec_read(codec, 0x1b, 0,
  1738. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1739. bits = present ? 0x80 : 0;
  1740. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1741. 0x80, bits);
  1742. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1743. 0x80, bits);
  1744. }
  1745. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1746. {
  1747. /* Looks like the unsol event is incompatible with the standard
  1748. * definition. 4bit tag is placed at 28 bit!
  1749. */
  1750. if ((res >> 28) == 0x01)
  1751. alc880_lg_lw_automute(codec);
  1752. }
  1753. /*
  1754. * Common callbacks
  1755. */
  1756. static int alc_init(struct hda_codec *codec)
  1757. {
  1758. struct alc_spec *spec = codec->spec;
  1759. unsigned int i;
  1760. for (i = 0; i < spec->num_init_verbs; i++)
  1761. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1762. if (spec->init_hook)
  1763. spec->init_hook(codec);
  1764. return 0;
  1765. }
  1766. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1767. {
  1768. struct alc_spec *spec = codec->spec;
  1769. if (spec->unsol_event)
  1770. spec->unsol_event(codec, res);
  1771. }
  1772. #ifdef CONFIG_PM
  1773. /*
  1774. * resume
  1775. */
  1776. static int alc_resume(struct hda_codec *codec)
  1777. {
  1778. struct alc_spec *spec = codec->spec;
  1779. int i;
  1780. alc_init(codec);
  1781. for (i = 0; i < spec->num_mixers; i++)
  1782. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1783. if (spec->multiout.dig_out_nid)
  1784. snd_hda_resume_spdif_out(codec);
  1785. if (spec->dig_in_nid)
  1786. snd_hda_resume_spdif_in(codec);
  1787. return 0;
  1788. }
  1789. #endif
  1790. /*
  1791. * Analog playback callbacks
  1792. */
  1793. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1794. struct hda_codec *codec,
  1795. struct snd_pcm_substream *substream)
  1796. {
  1797. struct alc_spec *spec = codec->spec;
  1798. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1799. }
  1800. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1801. struct hda_codec *codec,
  1802. unsigned int stream_tag,
  1803. unsigned int format,
  1804. struct snd_pcm_substream *substream)
  1805. {
  1806. struct alc_spec *spec = codec->spec;
  1807. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1808. stream_tag, format, substream);
  1809. }
  1810. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1811. struct hda_codec *codec,
  1812. struct snd_pcm_substream *substream)
  1813. {
  1814. struct alc_spec *spec = codec->spec;
  1815. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1816. }
  1817. /*
  1818. * Digital out
  1819. */
  1820. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1821. struct hda_codec *codec,
  1822. struct snd_pcm_substream *substream)
  1823. {
  1824. struct alc_spec *spec = codec->spec;
  1825. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1826. }
  1827. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1828. struct hda_codec *codec,
  1829. unsigned int stream_tag,
  1830. unsigned int format,
  1831. struct snd_pcm_substream *substream)
  1832. {
  1833. struct alc_spec *spec = codec->spec;
  1834. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1835. stream_tag, format, substream);
  1836. }
  1837. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1838. struct hda_codec *codec,
  1839. struct snd_pcm_substream *substream)
  1840. {
  1841. struct alc_spec *spec = codec->spec;
  1842. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1843. }
  1844. /*
  1845. * Analog capture
  1846. */
  1847. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1848. struct hda_codec *codec,
  1849. unsigned int stream_tag,
  1850. unsigned int format,
  1851. struct snd_pcm_substream *substream)
  1852. {
  1853. struct alc_spec *spec = codec->spec;
  1854. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1855. stream_tag, 0, format);
  1856. return 0;
  1857. }
  1858. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1859. struct hda_codec *codec,
  1860. struct snd_pcm_substream *substream)
  1861. {
  1862. struct alc_spec *spec = codec->spec;
  1863. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1864. 0, 0, 0);
  1865. return 0;
  1866. }
  1867. /*
  1868. */
  1869. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1870. .substreams = 1,
  1871. .channels_min = 2,
  1872. .channels_max = 8,
  1873. /* NID is set in alc_build_pcms */
  1874. .ops = {
  1875. .open = alc880_playback_pcm_open,
  1876. .prepare = alc880_playback_pcm_prepare,
  1877. .cleanup = alc880_playback_pcm_cleanup
  1878. },
  1879. };
  1880. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1881. .substreams = 2,
  1882. .channels_min = 2,
  1883. .channels_max = 2,
  1884. /* NID is set in alc_build_pcms */
  1885. .ops = {
  1886. .prepare = alc880_capture_pcm_prepare,
  1887. .cleanup = alc880_capture_pcm_cleanup
  1888. },
  1889. };
  1890. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1891. .substreams = 1,
  1892. .channels_min = 2,
  1893. .channels_max = 2,
  1894. /* NID is set in alc_build_pcms */
  1895. .ops = {
  1896. .open = alc880_dig_playback_pcm_open,
  1897. .close = alc880_dig_playback_pcm_close,
  1898. .prepare = alc880_dig_playback_pcm_prepare
  1899. },
  1900. };
  1901. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1902. .substreams = 1,
  1903. .channels_min = 2,
  1904. .channels_max = 2,
  1905. /* NID is set in alc_build_pcms */
  1906. };
  1907. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1908. static struct hda_pcm_stream alc_pcm_null_playback = {
  1909. .substreams = 0,
  1910. .channels_min = 0,
  1911. .channels_max = 0,
  1912. };
  1913. static int alc_build_pcms(struct hda_codec *codec)
  1914. {
  1915. struct alc_spec *spec = codec->spec;
  1916. struct hda_pcm *info = spec->pcm_rec;
  1917. int i;
  1918. codec->num_pcms = 1;
  1919. codec->pcm_info = info;
  1920. info->name = spec->stream_name_analog;
  1921. if (spec->stream_analog_playback) {
  1922. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1923. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1924. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1925. }
  1926. if (spec->stream_analog_capture) {
  1927. snd_assert(spec->adc_nids, return -EINVAL);
  1928. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1929. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1930. }
  1931. if (spec->channel_mode) {
  1932. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1933. for (i = 0; i < spec->num_channel_mode; i++) {
  1934. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1935. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1936. }
  1937. }
  1938. }
  1939. /* SPDIF for stream index #1 */
  1940. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1941. codec->num_pcms = 2;
  1942. info = spec->pcm_rec + 1;
  1943. info->name = spec->stream_name_digital;
  1944. if (spec->multiout.dig_out_nid &&
  1945. spec->stream_digital_playback) {
  1946. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1947. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1948. }
  1949. if (spec->dig_in_nid &&
  1950. spec->stream_digital_capture) {
  1951. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1952. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1953. }
  1954. }
  1955. /* If the use of more than one ADC is requested for the current
  1956. * model, configure a second analog capture-only PCM.
  1957. */
  1958. /* Additional Analaog capture for index #2 */
  1959. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1960. spec->adc_nids) {
  1961. codec->num_pcms = 3;
  1962. info = spec->pcm_rec + 2;
  1963. info->name = spec->stream_name_analog;
  1964. /* No playback stream for second PCM */
  1965. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1966. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1967. if (spec->stream_analog_capture) {
  1968. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1969. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1970. }
  1971. }
  1972. return 0;
  1973. }
  1974. static void alc_free(struct hda_codec *codec)
  1975. {
  1976. struct alc_spec *spec = codec->spec;
  1977. unsigned int i;
  1978. if (!spec)
  1979. return;
  1980. if (spec->kctl_alloc) {
  1981. for (i = 0; i < spec->num_kctl_used; i++)
  1982. kfree(spec->kctl_alloc[i].name);
  1983. kfree(spec->kctl_alloc);
  1984. }
  1985. kfree(spec);
  1986. }
  1987. /*
  1988. */
  1989. static struct hda_codec_ops alc_patch_ops = {
  1990. .build_controls = alc_build_controls,
  1991. .build_pcms = alc_build_pcms,
  1992. .init = alc_init,
  1993. .free = alc_free,
  1994. .unsol_event = alc_unsol_event,
  1995. #ifdef CONFIG_PM
  1996. .resume = alc_resume,
  1997. #endif
  1998. };
  1999. /*
  2000. * Test configuration for debugging
  2001. *
  2002. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2003. * enum controls.
  2004. */
  2005. #ifdef CONFIG_SND_DEBUG
  2006. static hda_nid_t alc880_test_dac_nids[4] = {
  2007. 0x02, 0x03, 0x04, 0x05
  2008. };
  2009. static struct hda_input_mux alc880_test_capture_source = {
  2010. .num_items = 7,
  2011. .items = {
  2012. { "In-1", 0x0 },
  2013. { "In-2", 0x1 },
  2014. { "In-3", 0x2 },
  2015. { "In-4", 0x3 },
  2016. { "CD", 0x4 },
  2017. { "Front", 0x5 },
  2018. { "Surround", 0x6 },
  2019. },
  2020. };
  2021. static struct hda_channel_mode alc880_test_modes[4] = {
  2022. { 2, NULL },
  2023. { 4, NULL },
  2024. { 6, NULL },
  2025. { 8, NULL },
  2026. };
  2027. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2028. struct snd_ctl_elem_info *uinfo)
  2029. {
  2030. static char *texts[] = {
  2031. "N/A", "Line Out", "HP Out",
  2032. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2033. };
  2034. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2035. uinfo->count = 1;
  2036. uinfo->value.enumerated.items = 8;
  2037. if (uinfo->value.enumerated.item >= 8)
  2038. uinfo->value.enumerated.item = 7;
  2039. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2040. return 0;
  2041. }
  2042. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2043. struct snd_ctl_elem_value *ucontrol)
  2044. {
  2045. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2046. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2047. unsigned int pin_ctl, item = 0;
  2048. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2049. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2050. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2051. if (pin_ctl & AC_PINCTL_HP_EN)
  2052. item = 2;
  2053. else
  2054. item = 1;
  2055. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2056. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2057. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2058. case AC_PINCTL_VREF_50: item = 4; break;
  2059. case AC_PINCTL_VREF_GRD: item = 5; break;
  2060. case AC_PINCTL_VREF_80: item = 6; break;
  2061. case AC_PINCTL_VREF_100: item = 7; break;
  2062. }
  2063. }
  2064. ucontrol->value.enumerated.item[0] = item;
  2065. return 0;
  2066. }
  2067. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2068. struct snd_ctl_elem_value *ucontrol)
  2069. {
  2070. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2071. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2072. static unsigned int ctls[] = {
  2073. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2074. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2075. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2076. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2077. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2078. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2079. };
  2080. unsigned int old_ctl, new_ctl;
  2081. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2082. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2083. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2084. if (old_ctl != new_ctl) {
  2085. snd_hda_codec_write(codec, nid, 0,
  2086. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2087. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2088. (ucontrol->value.enumerated.item[0] >= 3 ?
  2089. 0xb080 : 0xb000));
  2090. return 1;
  2091. }
  2092. return 0;
  2093. }
  2094. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2095. struct snd_ctl_elem_info *uinfo)
  2096. {
  2097. static char *texts[] = {
  2098. "Front", "Surround", "CLFE", "Side"
  2099. };
  2100. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2101. uinfo->count = 1;
  2102. uinfo->value.enumerated.items = 4;
  2103. if (uinfo->value.enumerated.item >= 4)
  2104. uinfo->value.enumerated.item = 3;
  2105. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2106. return 0;
  2107. }
  2108. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2109. struct snd_ctl_elem_value *ucontrol)
  2110. {
  2111. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2112. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2113. unsigned int sel;
  2114. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2115. ucontrol->value.enumerated.item[0] = sel & 3;
  2116. return 0;
  2117. }
  2118. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2119. struct snd_ctl_elem_value *ucontrol)
  2120. {
  2121. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2122. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2123. unsigned int sel;
  2124. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2125. if (ucontrol->value.enumerated.item[0] != sel) {
  2126. sel = ucontrol->value.enumerated.item[0] & 3;
  2127. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2128. return 1;
  2129. }
  2130. return 0;
  2131. }
  2132. #define PIN_CTL_TEST(xname,nid) { \
  2133. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2134. .name = xname, \
  2135. .info = alc_test_pin_ctl_info, \
  2136. .get = alc_test_pin_ctl_get, \
  2137. .put = alc_test_pin_ctl_put, \
  2138. .private_value = nid \
  2139. }
  2140. #define PIN_SRC_TEST(xname,nid) { \
  2141. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2142. .name = xname, \
  2143. .info = alc_test_pin_src_info, \
  2144. .get = alc_test_pin_src_get, \
  2145. .put = alc_test_pin_src_put, \
  2146. .private_value = nid \
  2147. }
  2148. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2149. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2150. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2151. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2152. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2153. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2154. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2155. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2156. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2157. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2158. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2159. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2160. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2161. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2162. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2163. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2164. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2165. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2166. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2167. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2168. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2169. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2170. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2171. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2172. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2173. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2174. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2175. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2176. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2177. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2178. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2179. {
  2180. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2181. .name = "Channel Mode",
  2182. .info = alc_ch_mode_info,
  2183. .get = alc_ch_mode_get,
  2184. .put = alc_ch_mode_put,
  2185. },
  2186. { } /* end */
  2187. };
  2188. static struct hda_verb alc880_test_init_verbs[] = {
  2189. /* Unmute inputs of 0x0c - 0x0f */
  2190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2197. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2198. /* Vol output for 0x0c-0x0f */
  2199. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2200. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2201. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2202. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2203. /* Set output pins 0x14-0x17 */
  2204. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2205. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2206. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2207. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2208. /* Unmute output pins 0x14-0x17 */
  2209. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2210. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2211. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2212. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2213. /* Set input pins 0x18-0x1c */
  2214. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2215. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2216. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2217. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2218. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2219. /* Mute input pins 0x18-0x1b */
  2220. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2221. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2222. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2223. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2224. /* ADC set up */
  2225. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2226. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2227. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2228. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2229. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2230. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2231. /* Analog input/passthru */
  2232. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2233. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2234. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2235. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2236. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2237. { }
  2238. };
  2239. #endif
  2240. /*
  2241. */
  2242. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2243. [ALC880_3ST] = "3stack",
  2244. [ALC880_TCL_S700] = "tcl",
  2245. [ALC880_3ST_DIG] = "3stack-digout",
  2246. [ALC880_CLEVO] = "clevo",
  2247. [ALC880_5ST] = "5stack",
  2248. [ALC880_5ST_DIG] = "5stack-digout",
  2249. [ALC880_W810] = "w810",
  2250. [ALC880_Z71V] = "z71v",
  2251. [ALC880_6ST] = "6stack",
  2252. [ALC880_6ST_DIG] = "6stack-digout",
  2253. [ALC880_ASUS] = "asus",
  2254. [ALC880_ASUS_W1V] = "asus-w1v",
  2255. [ALC880_ASUS_DIG] = "asus-dig",
  2256. [ALC880_ASUS_DIG2] = "asus-dig2",
  2257. [ALC880_UNIWILL_DIG] = "uniwill",
  2258. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2259. [ALC880_FUJITSU] = "fujitsu",
  2260. [ALC880_F1734] = "F1734",
  2261. [ALC880_LG] = "lg",
  2262. [ALC880_LG_LW] = "lg-lw",
  2263. #ifdef CONFIG_SND_DEBUG
  2264. [ALC880_TEST] = "test",
  2265. #endif
  2266. [ALC880_AUTO] = "auto",
  2267. };
  2268. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2269. /* Broken BIOS configuration */
  2270. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2271. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2272. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2273. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2274. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2275. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2276. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2277. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2278. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2279. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2280. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2281. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2282. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2283. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2284. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2285. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2286. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2287. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2288. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2289. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2290. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2291. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2292. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2293. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2294. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2295. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2296. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2297. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2298. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2299. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2300. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2301. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2302. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2303. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2304. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2305. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2306. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2307. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2308. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2309. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2310. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2311. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2312. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2313. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2314. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2315. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2316. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2317. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2318. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2319. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2320. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2321. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2322. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2323. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2324. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2325. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2326. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2327. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2328. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2329. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2330. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2331. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2332. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2333. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2334. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2335. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2336. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2337. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2338. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2339. {}
  2340. };
  2341. /*
  2342. * ALC880 codec presets
  2343. */
  2344. static struct alc_config_preset alc880_presets[] = {
  2345. [ALC880_3ST] = {
  2346. .mixers = { alc880_three_stack_mixer },
  2347. .init_verbs = { alc880_volume_init_verbs,
  2348. alc880_pin_3stack_init_verbs },
  2349. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2350. .dac_nids = alc880_dac_nids,
  2351. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2352. .channel_mode = alc880_threestack_modes,
  2353. .need_dac_fix = 1,
  2354. .input_mux = &alc880_capture_source,
  2355. },
  2356. [ALC880_3ST_DIG] = {
  2357. .mixers = { alc880_three_stack_mixer },
  2358. .init_verbs = { alc880_volume_init_verbs,
  2359. alc880_pin_3stack_init_verbs },
  2360. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2361. .dac_nids = alc880_dac_nids,
  2362. .dig_out_nid = ALC880_DIGOUT_NID,
  2363. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2364. .channel_mode = alc880_threestack_modes,
  2365. .need_dac_fix = 1,
  2366. .input_mux = &alc880_capture_source,
  2367. },
  2368. [ALC880_TCL_S700] = {
  2369. .mixers = { alc880_tcl_s700_mixer },
  2370. .init_verbs = { alc880_volume_init_verbs,
  2371. alc880_pin_tcl_S700_init_verbs,
  2372. alc880_gpio2_init_verbs },
  2373. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2374. .dac_nids = alc880_dac_nids,
  2375. .hp_nid = 0x03,
  2376. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2377. .channel_mode = alc880_2_jack_modes,
  2378. .input_mux = &alc880_capture_source,
  2379. },
  2380. [ALC880_5ST] = {
  2381. .mixers = { alc880_three_stack_mixer,
  2382. alc880_five_stack_mixer},
  2383. .init_verbs = { alc880_volume_init_verbs,
  2384. alc880_pin_5stack_init_verbs },
  2385. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2386. .dac_nids = alc880_dac_nids,
  2387. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2388. .channel_mode = alc880_fivestack_modes,
  2389. .input_mux = &alc880_capture_source,
  2390. },
  2391. [ALC880_5ST_DIG] = {
  2392. .mixers = { alc880_three_stack_mixer,
  2393. alc880_five_stack_mixer },
  2394. .init_verbs = { alc880_volume_init_verbs,
  2395. alc880_pin_5stack_init_verbs },
  2396. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2397. .dac_nids = alc880_dac_nids,
  2398. .dig_out_nid = ALC880_DIGOUT_NID,
  2399. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2400. .channel_mode = alc880_fivestack_modes,
  2401. .input_mux = &alc880_capture_source,
  2402. },
  2403. [ALC880_6ST] = {
  2404. .mixers = { alc880_six_stack_mixer },
  2405. .init_verbs = { alc880_volume_init_verbs,
  2406. alc880_pin_6stack_init_verbs },
  2407. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2408. .dac_nids = alc880_6st_dac_nids,
  2409. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2410. .channel_mode = alc880_sixstack_modes,
  2411. .input_mux = &alc880_6stack_capture_source,
  2412. },
  2413. [ALC880_6ST_DIG] = {
  2414. .mixers = { alc880_six_stack_mixer },
  2415. .init_verbs = { alc880_volume_init_verbs,
  2416. alc880_pin_6stack_init_verbs },
  2417. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2418. .dac_nids = alc880_6st_dac_nids,
  2419. .dig_out_nid = ALC880_DIGOUT_NID,
  2420. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2421. .channel_mode = alc880_sixstack_modes,
  2422. .input_mux = &alc880_6stack_capture_source,
  2423. },
  2424. [ALC880_W810] = {
  2425. .mixers = { alc880_w810_base_mixer },
  2426. .init_verbs = { alc880_volume_init_verbs,
  2427. alc880_pin_w810_init_verbs,
  2428. alc880_gpio2_init_verbs },
  2429. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2430. .dac_nids = alc880_w810_dac_nids,
  2431. .dig_out_nid = ALC880_DIGOUT_NID,
  2432. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2433. .channel_mode = alc880_w810_modes,
  2434. .input_mux = &alc880_capture_source,
  2435. },
  2436. [ALC880_Z71V] = {
  2437. .mixers = { alc880_z71v_mixer },
  2438. .init_verbs = { alc880_volume_init_verbs,
  2439. alc880_pin_z71v_init_verbs },
  2440. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2441. .dac_nids = alc880_z71v_dac_nids,
  2442. .dig_out_nid = ALC880_DIGOUT_NID,
  2443. .hp_nid = 0x03,
  2444. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2445. .channel_mode = alc880_2_jack_modes,
  2446. .input_mux = &alc880_capture_source,
  2447. },
  2448. [ALC880_F1734] = {
  2449. .mixers = { alc880_f1734_mixer },
  2450. .init_verbs = { alc880_volume_init_verbs,
  2451. alc880_pin_f1734_init_verbs },
  2452. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2453. .dac_nids = alc880_f1734_dac_nids,
  2454. .hp_nid = 0x02,
  2455. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2456. .channel_mode = alc880_2_jack_modes,
  2457. .input_mux = &alc880_capture_source,
  2458. },
  2459. [ALC880_ASUS] = {
  2460. .mixers = { alc880_asus_mixer },
  2461. .init_verbs = { alc880_volume_init_verbs,
  2462. alc880_pin_asus_init_verbs,
  2463. alc880_gpio1_init_verbs },
  2464. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2465. .dac_nids = alc880_asus_dac_nids,
  2466. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2467. .channel_mode = alc880_asus_modes,
  2468. .need_dac_fix = 1,
  2469. .input_mux = &alc880_capture_source,
  2470. },
  2471. [ALC880_ASUS_DIG] = {
  2472. .mixers = { alc880_asus_mixer },
  2473. .init_verbs = { alc880_volume_init_verbs,
  2474. alc880_pin_asus_init_verbs,
  2475. alc880_gpio1_init_verbs },
  2476. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2477. .dac_nids = alc880_asus_dac_nids,
  2478. .dig_out_nid = ALC880_DIGOUT_NID,
  2479. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2480. .channel_mode = alc880_asus_modes,
  2481. .need_dac_fix = 1,
  2482. .input_mux = &alc880_capture_source,
  2483. },
  2484. [ALC880_ASUS_DIG2] = {
  2485. .mixers = { alc880_asus_mixer },
  2486. .init_verbs = { alc880_volume_init_verbs,
  2487. alc880_pin_asus_init_verbs,
  2488. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2489. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2490. .dac_nids = alc880_asus_dac_nids,
  2491. .dig_out_nid = ALC880_DIGOUT_NID,
  2492. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2493. .channel_mode = alc880_asus_modes,
  2494. .need_dac_fix = 1,
  2495. .input_mux = &alc880_capture_source,
  2496. },
  2497. [ALC880_ASUS_W1V] = {
  2498. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2499. .init_verbs = { alc880_volume_init_verbs,
  2500. alc880_pin_asus_init_verbs,
  2501. alc880_gpio1_init_verbs },
  2502. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2503. .dac_nids = alc880_asus_dac_nids,
  2504. .dig_out_nid = ALC880_DIGOUT_NID,
  2505. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2506. .channel_mode = alc880_asus_modes,
  2507. .need_dac_fix = 1,
  2508. .input_mux = &alc880_capture_source,
  2509. },
  2510. [ALC880_UNIWILL_DIG] = {
  2511. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2512. .init_verbs = { alc880_volume_init_verbs,
  2513. alc880_pin_asus_init_verbs },
  2514. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2515. .dac_nids = alc880_asus_dac_nids,
  2516. .dig_out_nid = ALC880_DIGOUT_NID,
  2517. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2518. .channel_mode = alc880_asus_modes,
  2519. .need_dac_fix = 1,
  2520. .input_mux = &alc880_capture_source,
  2521. },
  2522. [ALC880_UNIWILL] = {
  2523. .mixers = { alc880_uniwill_mixer },
  2524. .init_verbs = { alc880_volume_init_verbs,
  2525. alc880_uniwill_init_verbs },
  2526. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2527. .dac_nids = alc880_asus_dac_nids,
  2528. .dig_out_nid = ALC880_DIGOUT_NID,
  2529. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2530. .channel_mode = alc880_threestack_modes,
  2531. .need_dac_fix = 1,
  2532. .input_mux = &alc880_capture_source,
  2533. .unsol_event = alc880_uniwill_unsol_event,
  2534. .init_hook = alc880_uniwill_automute,
  2535. },
  2536. [ALC880_UNIWILL_P53] = {
  2537. .mixers = { alc880_uniwill_p53_mixer },
  2538. .init_verbs = { alc880_volume_init_verbs,
  2539. alc880_uniwill_p53_init_verbs },
  2540. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2541. .dac_nids = alc880_asus_dac_nids,
  2542. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2543. .channel_mode = alc880_threestack_modes,
  2544. .input_mux = &alc880_capture_source,
  2545. .unsol_event = alc880_uniwill_p53_unsol_event,
  2546. .init_hook = alc880_uniwill_p53_hp_automute,
  2547. },
  2548. [ALC880_FUJITSU] = {
  2549. .mixers = { alc880_fujitsu_mixer,
  2550. alc880_pcbeep_mixer, },
  2551. .init_verbs = { alc880_volume_init_verbs,
  2552. alc880_uniwill_p53_init_verbs,
  2553. alc880_beep_init_verbs },
  2554. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2555. .dac_nids = alc880_dac_nids,
  2556. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2557. .channel_mode = alc880_2_jack_modes,
  2558. .input_mux = &alc880_capture_source,
  2559. .unsol_event = alc880_uniwill_p53_unsol_event,
  2560. .init_hook = alc880_uniwill_p53_hp_automute,
  2561. },
  2562. [ALC880_CLEVO] = {
  2563. .mixers = { alc880_three_stack_mixer },
  2564. .init_verbs = { alc880_volume_init_verbs,
  2565. alc880_pin_clevo_init_verbs },
  2566. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2567. .dac_nids = alc880_dac_nids,
  2568. .hp_nid = 0x03,
  2569. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2570. .channel_mode = alc880_threestack_modes,
  2571. .need_dac_fix = 1,
  2572. .input_mux = &alc880_capture_source,
  2573. },
  2574. [ALC880_LG] = {
  2575. .mixers = { alc880_lg_mixer },
  2576. .init_verbs = { alc880_volume_init_verbs,
  2577. alc880_lg_init_verbs },
  2578. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2579. .dac_nids = alc880_lg_dac_nids,
  2580. .dig_out_nid = ALC880_DIGOUT_NID,
  2581. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2582. .channel_mode = alc880_lg_ch_modes,
  2583. .need_dac_fix = 1,
  2584. .input_mux = &alc880_lg_capture_source,
  2585. .unsol_event = alc880_lg_unsol_event,
  2586. .init_hook = alc880_lg_automute,
  2587. },
  2588. [ALC880_LG_LW] = {
  2589. .mixers = { alc880_lg_lw_mixer },
  2590. .init_verbs = { alc880_volume_init_verbs,
  2591. alc880_lg_lw_init_verbs },
  2592. .num_dacs = 1,
  2593. .dac_nids = alc880_dac_nids,
  2594. .dig_out_nid = ALC880_DIGOUT_NID,
  2595. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2596. .channel_mode = alc880_2_jack_modes,
  2597. .input_mux = &alc880_lg_lw_capture_source,
  2598. .unsol_event = alc880_lg_lw_unsol_event,
  2599. .init_hook = alc880_lg_lw_automute,
  2600. },
  2601. #ifdef CONFIG_SND_DEBUG
  2602. [ALC880_TEST] = {
  2603. .mixers = { alc880_test_mixer },
  2604. .init_verbs = { alc880_test_init_verbs },
  2605. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2606. .dac_nids = alc880_test_dac_nids,
  2607. .dig_out_nid = ALC880_DIGOUT_NID,
  2608. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2609. .channel_mode = alc880_test_modes,
  2610. .input_mux = &alc880_test_capture_source,
  2611. },
  2612. #endif
  2613. };
  2614. /*
  2615. * Automatic parse of I/O pins from the BIOS configuration
  2616. */
  2617. #define NUM_CONTROL_ALLOC 32
  2618. #define NUM_VERB_ALLOC 32
  2619. enum {
  2620. ALC_CTL_WIDGET_VOL,
  2621. ALC_CTL_WIDGET_MUTE,
  2622. ALC_CTL_BIND_MUTE,
  2623. };
  2624. static struct snd_kcontrol_new alc880_control_templates[] = {
  2625. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2626. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2627. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2628. };
  2629. /* add dynamic controls */
  2630. static int add_control(struct alc_spec *spec, int type, const char *name,
  2631. unsigned long val)
  2632. {
  2633. struct snd_kcontrol_new *knew;
  2634. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2635. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2636. /* array + terminator */
  2637. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2638. if (!knew)
  2639. return -ENOMEM;
  2640. if (spec->kctl_alloc) {
  2641. memcpy(knew, spec->kctl_alloc,
  2642. sizeof(*knew) * spec->num_kctl_alloc);
  2643. kfree(spec->kctl_alloc);
  2644. }
  2645. spec->kctl_alloc = knew;
  2646. spec->num_kctl_alloc = num;
  2647. }
  2648. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2649. *knew = alc880_control_templates[type];
  2650. knew->name = kstrdup(name, GFP_KERNEL);
  2651. if (!knew->name)
  2652. return -ENOMEM;
  2653. knew->private_value = val;
  2654. spec->num_kctl_used++;
  2655. return 0;
  2656. }
  2657. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2658. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2659. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2660. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2661. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2662. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2663. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2664. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2665. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2666. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2667. #define ALC880_PIN_CD_NID 0x1c
  2668. /* fill in the dac_nids table from the parsed pin configuration */
  2669. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2670. const struct auto_pin_cfg *cfg)
  2671. {
  2672. hda_nid_t nid;
  2673. int assigned[4];
  2674. int i, j;
  2675. memset(assigned, 0, sizeof(assigned));
  2676. spec->multiout.dac_nids = spec->private_dac_nids;
  2677. /* check the pins hardwired to audio widget */
  2678. for (i = 0; i < cfg->line_outs; i++) {
  2679. nid = cfg->line_out_pins[i];
  2680. if (alc880_is_fixed_pin(nid)) {
  2681. int idx = alc880_fixed_pin_idx(nid);
  2682. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2683. assigned[idx] = 1;
  2684. }
  2685. }
  2686. /* left pins can be connect to any audio widget */
  2687. for (i = 0; i < cfg->line_outs; i++) {
  2688. nid = cfg->line_out_pins[i];
  2689. if (alc880_is_fixed_pin(nid))
  2690. continue;
  2691. /* search for an empty channel */
  2692. for (j = 0; j < cfg->line_outs; j++) {
  2693. if (!assigned[j]) {
  2694. spec->multiout.dac_nids[i] =
  2695. alc880_idx_to_dac(j);
  2696. assigned[j] = 1;
  2697. break;
  2698. }
  2699. }
  2700. }
  2701. spec->multiout.num_dacs = cfg->line_outs;
  2702. return 0;
  2703. }
  2704. /* add playback controls from the parsed DAC table */
  2705. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2706. const struct auto_pin_cfg *cfg)
  2707. {
  2708. char name[32];
  2709. static const char *chname[4] = {
  2710. "Front", "Surround", NULL /*CLFE*/, "Side"
  2711. };
  2712. hda_nid_t nid;
  2713. int i, err;
  2714. for (i = 0; i < cfg->line_outs; i++) {
  2715. if (!spec->multiout.dac_nids[i])
  2716. continue;
  2717. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2718. if (i == 2) {
  2719. /* Center/LFE */
  2720. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2721. "Center Playback Volume",
  2722. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2723. HDA_OUTPUT));
  2724. if (err < 0)
  2725. return err;
  2726. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2727. "LFE Playback Volume",
  2728. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2729. HDA_OUTPUT));
  2730. if (err < 0)
  2731. return err;
  2732. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2733. "Center Playback Switch",
  2734. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2735. HDA_INPUT));
  2736. if (err < 0)
  2737. return err;
  2738. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2739. "LFE Playback Switch",
  2740. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2741. HDA_INPUT));
  2742. if (err < 0)
  2743. return err;
  2744. } else {
  2745. sprintf(name, "%s Playback Volume", chname[i]);
  2746. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2747. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2748. HDA_OUTPUT));
  2749. if (err < 0)
  2750. return err;
  2751. sprintf(name, "%s Playback Switch", chname[i]);
  2752. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2753. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2754. HDA_INPUT));
  2755. if (err < 0)
  2756. return err;
  2757. }
  2758. }
  2759. return 0;
  2760. }
  2761. /* add playback controls for speaker and HP outputs */
  2762. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2763. const char *pfx)
  2764. {
  2765. hda_nid_t nid;
  2766. int err;
  2767. char name[32];
  2768. if (!pin)
  2769. return 0;
  2770. if (alc880_is_fixed_pin(pin)) {
  2771. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2772. /* specify the DAC as the extra output */
  2773. if (!spec->multiout.hp_nid)
  2774. spec->multiout.hp_nid = nid;
  2775. else
  2776. spec->multiout.extra_out_nid[0] = nid;
  2777. /* control HP volume/switch on the output mixer amp */
  2778. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2779. sprintf(name, "%s Playback Volume", pfx);
  2780. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2781. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2782. if (err < 0)
  2783. return err;
  2784. sprintf(name, "%s Playback Switch", pfx);
  2785. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2786. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2787. if (err < 0)
  2788. return err;
  2789. } else if (alc880_is_multi_pin(pin)) {
  2790. /* set manual connection */
  2791. /* we have only a switch on HP-out PIN */
  2792. sprintf(name, "%s Playback Switch", pfx);
  2793. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2794. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2795. if (err < 0)
  2796. return err;
  2797. }
  2798. return 0;
  2799. }
  2800. /* create input playback/capture controls for the given pin */
  2801. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2802. const char *ctlname,
  2803. int idx, hda_nid_t mix_nid)
  2804. {
  2805. char name[32];
  2806. int err;
  2807. sprintf(name, "%s Playback Volume", ctlname);
  2808. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2809. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2810. if (err < 0)
  2811. return err;
  2812. sprintf(name, "%s Playback Switch", ctlname);
  2813. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2814. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2815. if (err < 0)
  2816. return err;
  2817. return 0;
  2818. }
  2819. /* create playback/capture controls for input pins */
  2820. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2821. const struct auto_pin_cfg *cfg)
  2822. {
  2823. struct hda_input_mux *imux = &spec->private_imux;
  2824. int i, err, idx;
  2825. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2826. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2827. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2828. err = new_analog_input(spec, cfg->input_pins[i],
  2829. auto_pin_cfg_labels[i],
  2830. idx, 0x0b);
  2831. if (err < 0)
  2832. return err;
  2833. imux->items[imux->num_items].label =
  2834. auto_pin_cfg_labels[i];
  2835. imux->items[imux->num_items].index =
  2836. alc880_input_pin_idx(cfg->input_pins[i]);
  2837. imux->num_items++;
  2838. }
  2839. }
  2840. return 0;
  2841. }
  2842. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2843. hda_nid_t nid, int pin_type,
  2844. int dac_idx)
  2845. {
  2846. /* set as output */
  2847. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2848. pin_type);
  2849. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2850. AMP_OUT_UNMUTE);
  2851. /* need the manual connection? */
  2852. if (alc880_is_multi_pin(nid)) {
  2853. struct alc_spec *spec = codec->spec;
  2854. int idx = alc880_multi_pin_idx(nid);
  2855. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2856. AC_VERB_SET_CONNECT_SEL,
  2857. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2858. }
  2859. }
  2860. static int get_pin_type(int line_out_type)
  2861. {
  2862. if (line_out_type == AUTO_PIN_HP_OUT)
  2863. return PIN_HP;
  2864. else
  2865. return PIN_OUT;
  2866. }
  2867. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2868. {
  2869. struct alc_spec *spec = codec->spec;
  2870. int i;
  2871. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2872. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2873. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2874. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2875. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2876. }
  2877. }
  2878. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2879. {
  2880. struct alc_spec *spec = codec->spec;
  2881. hda_nid_t pin;
  2882. pin = spec->autocfg.speaker_pins[0];
  2883. if (pin) /* connect to front */
  2884. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2885. pin = spec->autocfg.hp_pins[0];
  2886. if (pin) /* connect to front */
  2887. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2888. }
  2889. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2890. {
  2891. struct alc_spec *spec = codec->spec;
  2892. int i;
  2893. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2894. hda_nid_t nid = spec->autocfg.input_pins[i];
  2895. if (alc880_is_input_pin(nid)) {
  2896. snd_hda_codec_write(codec, nid, 0,
  2897. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2898. i <= AUTO_PIN_FRONT_MIC ?
  2899. PIN_VREF80 : PIN_IN);
  2900. if (nid != ALC880_PIN_CD_NID)
  2901. snd_hda_codec_write(codec, nid, 0,
  2902. AC_VERB_SET_AMP_GAIN_MUTE,
  2903. AMP_OUT_MUTE);
  2904. }
  2905. }
  2906. }
  2907. /* parse the BIOS configuration and set up the alc_spec */
  2908. /* return 1 if successful, 0 if the proper config is not found,
  2909. * or a negative error code
  2910. */
  2911. static int alc880_parse_auto_config(struct hda_codec *codec)
  2912. {
  2913. struct alc_spec *spec = codec->spec;
  2914. int err;
  2915. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2916. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2917. alc880_ignore);
  2918. if (err < 0)
  2919. return err;
  2920. if (!spec->autocfg.line_outs)
  2921. return 0; /* can't find valid BIOS pin config */
  2922. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2923. if (err < 0)
  2924. return err;
  2925. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2926. if (err < 0)
  2927. return err;
  2928. err = alc880_auto_create_extra_out(spec,
  2929. spec->autocfg.speaker_pins[0],
  2930. "Speaker");
  2931. if (err < 0)
  2932. return err;
  2933. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2934. "Headphone");
  2935. if (err < 0)
  2936. return err;
  2937. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2938. if (err < 0)
  2939. return err;
  2940. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2941. if (spec->autocfg.dig_out_pin)
  2942. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2943. if (spec->autocfg.dig_in_pin)
  2944. spec->dig_in_nid = ALC880_DIGIN_NID;
  2945. if (spec->kctl_alloc)
  2946. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2947. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2948. spec->num_mux_defs = 1;
  2949. spec->input_mux = &spec->private_imux;
  2950. return 1;
  2951. }
  2952. /* additional initialization for auto-configuration model */
  2953. static void alc880_auto_init(struct hda_codec *codec)
  2954. {
  2955. alc880_auto_init_multi_out(codec);
  2956. alc880_auto_init_extra_out(codec);
  2957. alc880_auto_init_analog_input(codec);
  2958. }
  2959. /*
  2960. * OK, here we have finally the patch for ALC880
  2961. */
  2962. static int patch_alc880(struct hda_codec *codec)
  2963. {
  2964. struct alc_spec *spec;
  2965. int board_config;
  2966. int err;
  2967. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2968. if (spec == NULL)
  2969. return -ENOMEM;
  2970. codec->spec = spec;
  2971. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2972. alc880_models,
  2973. alc880_cfg_tbl);
  2974. if (board_config < 0) {
  2975. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2976. "trying auto-probe from BIOS...\n");
  2977. board_config = ALC880_AUTO;
  2978. }
  2979. if (board_config == ALC880_AUTO) {
  2980. /* automatic parse from the BIOS config */
  2981. err = alc880_parse_auto_config(codec);
  2982. if (err < 0) {
  2983. alc_free(codec);
  2984. return err;
  2985. } else if (!err) {
  2986. printk(KERN_INFO
  2987. "hda_codec: Cannot set up configuration "
  2988. "from BIOS. Using 3-stack mode...\n");
  2989. board_config = ALC880_3ST;
  2990. }
  2991. }
  2992. if (board_config != ALC880_AUTO)
  2993. setup_preset(spec, &alc880_presets[board_config]);
  2994. spec->stream_name_analog = "ALC880 Analog";
  2995. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2996. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2997. spec->stream_name_digital = "ALC880 Digital";
  2998. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2999. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3000. if (!spec->adc_nids && spec->input_mux) {
  3001. /* check whether NID 0x07 is valid */
  3002. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3003. /* get type */
  3004. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3005. if (wcap != AC_WID_AUD_IN) {
  3006. spec->adc_nids = alc880_adc_nids_alt;
  3007. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3008. spec->mixers[spec->num_mixers] =
  3009. alc880_capture_alt_mixer;
  3010. spec->num_mixers++;
  3011. } else {
  3012. spec->adc_nids = alc880_adc_nids;
  3013. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3014. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3015. spec->num_mixers++;
  3016. }
  3017. }
  3018. codec->patch_ops = alc_patch_ops;
  3019. if (board_config == ALC880_AUTO)
  3020. spec->init_hook = alc880_auto_init;
  3021. return 0;
  3022. }
  3023. /*
  3024. * ALC260 support
  3025. */
  3026. static hda_nid_t alc260_dac_nids[1] = {
  3027. /* front */
  3028. 0x02,
  3029. };
  3030. static hda_nid_t alc260_adc_nids[1] = {
  3031. /* ADC0 */
  3032. 0x04,
  3033. };
  3034. static hda_nid_t alc260_adc_nids_alt[1] = {
  3035. /* ADC1 */
  3036. 0x05,
  3037. };
  3038. static hda_nid_t alc260_hp_adc_nids[2] = {
  3039. /* ADC1, 0 */
  3040. 0x05, 0x04
  3041. };
  3042. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3043. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3044. */
  3045. static hda_nid_t alc260_dual_adc_nids[2] = {
  3046. /* ADC0, ADC1 */
  3047. 0x04, 0x05
  3048. };
  3049. #define ALC260_DIGOUT_NID 0x03
  3050. #define ALC260_DIGIN_NID 0x06
  3051. static struct hda_input_mux alc260_capture_source = {
  3052. .num_items = 4,
  3053. .items = {
  3054. { "Mic", 0x0 },
  3055. { "Front Mic", 0x1 },
  3056. { "Line", 0x2 },
  3057. { "CD", 0x4 },
  3058. },
  3059. };
  3060. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3061. * headphone jack and the internal CD lines since these are the only pins at
  3062. * which audio can appear. For flexibility, also allow the option of
  3063. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3064. * connection to the mixer output).
  3065. */
  3066. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3067. {
  3068. .num_items = 3,
  3069. .items = {
  3070. { "Mic/Line", 0x0 },
  3071. { "CD", 0x4 },
  3072. { "Headphone", 0x2 },
  3073. },
  3074. },
  3075. {
  3076. .num_items = 4,
  3077. .items = {
  3078. { "Mic/Line", 0x0 },
  3079. { "CD", 0x4 },
  3080. { "Headphone", 0x2 },
  3081. { "Mixer", 0x5 },
  3082. },
  3083. },
  3084. };
  3085. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3086. * the Fujitsu S702x, but jacks are marked differently.
  3087. */
  3088. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3089. {
  3090. .num_items = 4,
  3091. .items = {
  3092. { "Mic", 0x0 },
  3093. { "Line", 0x2 },
  3094. { "CD", 0x4 },
  3095. { "Headphone", 0x5 },
  3096. },
  3097. },
  3098. {
  3099. .num_items = 5,
  3100. .items = {
  3101. { "Mic", 0x0 },
  3102. { "Line", 0x2 },
  3103. { "CD", 0x4 },
  3104. { "Headphone", 0x6 },
  3105. { "Mixer", 0x5 },
  3106. },
  3107. },
  3108. };
  3109. /*
  3110. * This is just place-holder, so there's something for alc_build_pcms to look
  3111. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3112. * element which allows changing the channel mode, so the verb list is
  3113. * never used.
  3114. */
  3115. static struct hda_channel_mode alc260_modes[1] = {
  3116. { 2, NULL },
  3117. };
  3118. /* Mixer combinations
  3119. *
  3120. * basic: base_output + input + pc_beep + capture
  3121. * HP: base_output + input + capture_alt
  3122. * HP_3013: hp_3013 + input + capture
  3123. * fujitsu: fujitsu + capture
  3124. * acer: acer + capture
  3125. */
  3126. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3127. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3128. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3129. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3130. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3131. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3132. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3133. { } /* end */
  3134. };
  3135. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3136. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3137. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3138. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3139. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3140. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3141. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3142. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3143. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3144. { } /* end */
  3145. };
  3146. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3147. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3148. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3149. { } /* end */
  3150. };
  3151. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3152. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3153. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3154. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3155. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3156. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3157. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3158. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3159. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3160. { } /* end */
  3161. };
  3162. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3163. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3164. */
  3165. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3166. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3167. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3168. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3169. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3170. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3171. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3172. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3173. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3174. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3175. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3176. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3177. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3178. { } /* end */
  3179. };
  3180. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3181. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3182. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3183. * datasheet doesn't mention this restriction. At this stage it's not clear
  3184. * whether this behaviour is intentional or is a hardware bug in chip
  3185. * revisions available in early 2006. Therefore for now allow the
  3186. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3187. * that the lack of mic bias for this NID is intentional we could change the
  3188. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3189. *
  3190. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3191. * don't appear to make the mic bias available from the "line" jack, even
  3192. * though the NID used for this jack (0x14) can supply it. The theory is
  3193. * that perhaps Acer have included blocking capacitors between the ALC260
  3194. * and the output jack. If this turns out to be the case for all such
  3195. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3196. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3197. *
  3198. * The C20x Tablet series have a mono internal speaker which is controlled
  3199. * via the chip's Mono sum widget and pin complex, so include the necessary
  3200. * controls for such models. On models without a "mono speaker" the control
  3201. * won't do anything.
  3202. */
  3203. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3204. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3205. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3206. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3207. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3208. HDA_OUTPUT),
  3209. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3210. HDA_INPUT),
  3211. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3212. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3213. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3214. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3215. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3216. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3217. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3218. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3219. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3220. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3221. { } /* end */
  3222. };
  3223. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3224. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3225. */
  3226. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3227. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3228. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3229. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3230. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3231. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3232. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3233. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3234. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3235. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3236. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3237. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3238. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3239. { } /* end */
  3240. };
  3241. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3242. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3243. */
  3244. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3245. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3246. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3247. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3248. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3249. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3250. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3251. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3252. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3253. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3254. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3255. { } /* end */
  3256. };
  3257. /* capture mixer elements */
  3258. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3259. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3260. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3261. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3262. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3263. {
  3264. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3265. /* The multiple "Capture Source" controls confuse alsamixer
  3266. * So call somewhat different..
  3267. * FIXME: the controls appear in the "playback" view!
  3268. */
  3269. /* .name = "Capture Source", */
  3270. .name = "Input Source",
  3271. .count = 2,
  3272. .info = alc_mux_enum_info,
  3273. .get = alc_mux_enum_get,
  3274. .put = alc_mux_enum_put,
  3275. },
  3276. { } /* end */
  3277. };
  3278. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3279. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3280. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3281. {
  3282. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3283. /* The multiple "Capture Source" controls confuse alsamixer
  3284. * So call somewhat different..
  3285. * FIXME: the controls appear in the "playback" view!
  3286. */
  3287. /* .name = "Capture Source", */
  3288. .name = "Input Source",
  3289. .count = 1,
  3290. .info = alc_mux_enum_info,
  3291. .get = alc_mux_enum_get,
  3292. .put = alc_mux_enum_put,
  3293. },
  3294. { } /* end */
  3295. };
  3296. /*
  3297. * initialization verbs
  3298. */
  3299. static struct hda_verb alc260_init_verbs[] = {
  3300. /* Line In pin widget for input */
  3301. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3302. /* CD pin widget for input */
  3303. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3304. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3305. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3306. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3307. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3308. /* LINE-2 is used for line-out in rear */
  3309. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3310. /* select line-out */
  3311. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3312. /* LINE-OUT pin */
  3313. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3314. /* enable HP */
  3315. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3316. /* enable Mono */
  3317. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3318. /* mute capture amp left and right */
  3319. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3320. /* set connection select to line in (default select for this ADC) */
  3321. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3322. /* mute capture amp left and right */
  3323. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3324. /* set connection select to line in (default select for this ADC) */
  3325. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3326. /* set vol=0 Line-Out mixer amp left and right */
  3327. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3328. /* unmute pin widget amp left and right (no gain on this amp) */
  3329. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3330. /* set vol=0 HP mixer amp left and right */
  3331. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3332. /* unmute pin widget amp left and right (no gain on this amp) */
  3333. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3334. /* set vol=0 Mono mixer amp left and right */
  3335. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3336. /* unmute pin widget amp left and right (no gain on this amp) */
  3337. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3338. /* unmute LINE-2 out pin */
  3339. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3340. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3341. * Line In 2 = 0x03
  3342. */
  3343. /* mute CD */
  3344. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3345. /* mute Line In */
  3346. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3347. /* mute Mic */
  3348. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3349. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3350. /* mute Front out path */
  3351. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3352. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3353. /* mute Headphone out path */
  3354. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3355. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3356. /* mute Mono out path */
  3357. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3358. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3359. { }
  3360. };
  3361. #if 0 /* should be identical with alc260_init_verbs? */
  3362. static struct hda_verb alc260_hp_init_verbs[] = {
  3363. /* Headphone and output */
  3364. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3365. /* mono output */
  3366. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3367. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3368. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3369. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3370. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3371. /* Line In pin widget for input */
  3372. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3373. /* Line-2 pin widget for output */
  3374. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3375. /* CD pin widget for input */
  3376. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3377. /* unmute amp left and right */
  3378. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3379. /* set connection select to line in (default select for this ADC) */
  3380. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3381. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3382. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3383. /* mute pin widget amp left and right (no gain on this amp) */
  3384. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3385. /* unmute HP mixer amp left and right (volume = 0) */
  3386. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3387. /* mute pin widget amp left and right (no gain on this amp) */
  3388. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3389. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3390. * Line In 2 = 0x03
  3391. */
  3392. /* unmute CD */
  3393. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3394. /* unmute Line In */
  3395. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3396. /* unmute Mic */
  3397. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3398. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3399. /* Unmute Front out path */
  3400. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3401. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3402. /* Unmute Headphone out path */
  3403. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3404. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3405. /* Unmute Mono out path */
  3406. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3407. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3408. { }
  3409. };
  3410. #endif
  3411. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3412. /* Line out and output */
  3413. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3414. /* mono output */
  3415. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3416. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3417. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3418. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3419. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3420. /* Line In pin widget for input */
  3421. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3422. /* Headphone pin widget for output */
  3423. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3424. /* CD pin widget for input */
  3425. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3426. /* unmute amp left and right */
  3427. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3428. /* set connection select to line in (default select for this ADC) */
  3429. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3430. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3431. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3432. /* mute pin widget amp left and right (no gain on this amp) */
  3433. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3434. /* unmute HP mixer amp left and right (volume = 0) */
  3435. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3436. /* mute pin widget amp left and right (no gain on this amp) */
  3437. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3438. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3439. * Line In 2 = 0x03
  3440. */
  3441. /* unmute CD */
  3442. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3443. /* unmute Line In */
  3444. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3445. /* unmute Mic */
  3446. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3447. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3448. /* Unmute Front out path */
  3449. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3450. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3451. /* Unmute Headphone out path */
  3452. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3453. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3454. /* Unmute Mono out path */
  3455. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3456. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3457. { }
  3458. };
  3459. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3460. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3461. * audio = 0x16, internal speaker = 0x10.
  3462. */
  3463. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3464. /* Disable all GPIOs */
  3465. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3466. /* Internal speaker is connected to headphone pin */
  3467. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3468. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3469. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3470. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3471. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3472. /* Ensure all other unused pins are disabled and muted. */
  3473. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3474. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3475. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3476. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3477. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3478. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3479. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3480. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3481. /* Disable digital (SPDIF) pins */
  3482. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3483. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3484. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3485. * when acting as an output.
  3486. */
  3487. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3488. /* Start with output sum widgets muted and their output gains at min */
  3489. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3490. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3491. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3492. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3493. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3494. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3495. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3496. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3497. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3498. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3499. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3500. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3501. * If the pin mode is changed by the user the pin mode control will
  3502. * take care of enabling the pin's input/output buffers as needed.
  3503. * Therefore there's no need to enable the input buffer at this
  3504. * stage.
  3505. */
  3506. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3507. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3508. * mixer ctrl)
  3509. */
  3510. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3511. /* Mute capture amp left and right */
  3512. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3513. /* Set ADC connection select to match default mixer setting - line
  3514. * in (on mic1 pin)
  3515. */
  3516. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3517. /* Do the same for the second ADC: mute capture input amp and
  3518. * set ADC connection to line in (on mic1 pin)
  3519. */
  3520. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3521. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3522. /* Mute all inputs to mixer widget (even unconnected ones) */
  3523. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3524. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3525. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3526. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3527. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3528. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3529. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3530. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3531. { }
  3532. };
  3533. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3534. * similar laptops (adapted from Fujitsu init verbs).
  3535. */
  3536. static struct hda_verb alc260_acer_init_verbs[] = {
  3537. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3538. * the headphone jack. Turn this on and rely on the standard mute
  3539. * methods whenever the user wants to turn these outputs off.
  3540. */
  3541. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3542. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3543. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3544. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3545. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3546. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3547. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3548. /* Line In jack is connected to Line1 pin */
  3549. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3550. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3551. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3552. /* Ensure all other unused pins are disabled and muted. */
  3553. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3554. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3555. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3556. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3557. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3558. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3559. /* Disable digital (SPDIF) pins */
  3560. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3561. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3562. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3563. * bus when acting as outputs.
  3564. */
  3565. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3566. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3567. /* Start with output sum widgets muted and their output gains at min */
  3568. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3569. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3570. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3571. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3572. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3573. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3574. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3575. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3576. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3577. /* Unmute Line-out pin widget amp left and right
  3578. * (no equiv mixer ctrl)
  3579. */
  3580. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3581. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3582. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3583. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3584. * inputs. If the pin mode is changed by the user the pin mode control
  3585. * will take care of enabling the pin's input/output buffers as needed.
  3586. * Therefore there's no need to enable the input buffer at this
  3587. * stage.
  3588. */
  3589. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3590. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3591. /* Mute capture amp left and right */
  3592. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3593. /* Set ADC connection select to match default mixer setting - mic
  3594. * (on mic1 pin)
  3595. */
  3596. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3597. /* Do similar with the second ADC: mute capture input amp and
  3598. * set ADC connection to mic to match ALSA's default state.
  3599. */
  3600. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3601. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3602. /* Mute all inputs to mixer widget (even unconnected ones) */
  3603. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3604. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3605. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3606. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3607. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3608. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3609. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3610. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3611. { }
  3612. };
  3613. static struct hda_verb alc260_will_verbs[] = {
  3614. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3615. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3616. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3617. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3618. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3619. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3620. {}
  3621. };
  3622. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3623. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3624. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3625. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3626. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3627. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3628. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3629. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3630. {}
  3631. };
  3632. /* toggle speaker-output according to the hp-jack state */
  3633. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3634. {
  3635. unsigned int present;
  3636. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3637. present = snd_hda_codec_read(codec, 0x0f, 0,
  3638. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3639. if (present) {
  3640. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3641. snd_hda_codec_write(codec, 0x0f, 0,
  3642. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3643. } else {
  3644. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3645. snd_hda_codec_write(codec, 0x0f, 0,
  3646. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3647. }
  3648. }
  3649. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3650. unsigned int res)
  3651. {
  3652. if ((res >> 26) == ALC880_HP_EVENT)
  3653. alc260_replacer_672v_automute(codec);
  3654. }
  3655. /* Test configuration for debugging, modelled after the ALC880 test
  3656. * configuration.
  3657. */
  3658. #ifdef CONFIG_SND_DEBUG
  3659. static hda_nid_t alc260_test_dac_nids[1] = {
  3660. 0x02,
  3661. };
  3662. static hda_nid_t alc260_test_adc_nids[2] = {
  3663. 0x04, 0x05,
  3664. };
  3665. /* For testing the ALC260, each input MUX needs its own definition since
  3666. * the signal assignments are different. This assumes that the first ADC
  3667. * is NID 0x04.
  3668. */
  3669. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3670. {
  3671. .num_items = 7,
  3672. .items = {
  3673. { "MIC1 pin", 0x0 },
  3674. { "MIC2 pin", 0x1 },
  3675. { "LINE1 pin", 0x2 },
  3676. { "LINE2 pin", 0x3 },
  3677. { "CD pin", 0x4 },
  3678. { "LINE-OUT pin", 0x5 },
  3679. { "HP-OUT pin", 0x6 },
  3680. },
  3681. },
  3682. {
  3683. .num_items = 8,
  3684. .items = {
  3685. { "MIC1 pin", 0x0 },
  3686. { "MIC2 pin", 0x1 },
  3687. { "LINE1 pin", 0x2 },
  3688. { "LINE2 pin", 0x3 },
  3689. { "CD pin", 0x4 },
  3690. { "Mixer", 0x5 },
  3691. { "LINE-OUT pin", 0x6 },
  3692. { "HP-OUT pin", 0x7 },
  3693. },
  3694. },
  3695. };
  3696. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3697. /* Output driver widgets */
  3698. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3699. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3700. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3701. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3702. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3703. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3704. /* Modes for retasking pin widgets
  3705. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3706. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3707. * mention this restriction. At this stage it's not clear whether
  3708. * this behaviour is intentional or is a hardware bug in chip
  3709. * revisions available at least up until early 2006. Therefore for
  3710. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3711. * choices, but if it turns out that the lack of mic bias for these
  3712. * NIDs is intentional we could change their modes from
  3713. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3714. */
  3715. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3716. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3717. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3718. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3719. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3720. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3721. /* Loopback mixer controls */
  3722. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3723. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3724. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3725. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3726. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3727. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3728. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3729. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3730. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3731. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3732. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3733. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3734. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3735. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3736. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3737. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3738. /* Controls for GPIO pins, assuming they are configured as outputs */
  3739. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3740. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3741. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3742. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3743. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3744. * is ambigious as to which NID is which; testing on laptops which
  3745. * make this output available should provide clarification.
  3746. */
  3747. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3748. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3749. { } /* end */
  3750. };
  3751. static struct hda_verb alc260_test_init_verbs[] = {
  3752. /* Enable all GPIOs as outputs with an initial value of 0 */
  3753. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3754. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3755. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3756. /* Enable retasking pins as output, initially without power amp */
  3757. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3758. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3759. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3760. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3761. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3762. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3763. /* Disable digital (SPDIF) pins initially, but users can enable
  3764. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3765. * payload also sets the generation to 0, output to be in "consumer"
  3766. * PCM format, copyright asserted, no pre-emphasis and no validity
  3767. * control.
  3768. */
  3769. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3770. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3771. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3772. * OUT1 sum bus when acting as an output.
  3773. */
  3774. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3775. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3776. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3777. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3778. /* Start with output sum widgets muted and their output gains at min */
  3779. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3780. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3781. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3782. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3783. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3784. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3785. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3786. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3787. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3788. /* Unmute retasking pin widget output buffers since the default
  3789. * state appears to be output. As the pin mode is changed by the
  3790. * user the pin mode control will take care of enabling the pin's
  3791. * input/output buffers as needed.
  3792. */
  3793. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3794. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3795. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3796. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3797. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3798. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3799. /* Also unmute the mono-out pin widget */
  3800. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3801. /* Mute capture amp left and right */
  3802. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3803. /* Set ADC connection select to match default mixer setting (mic1
  3804. * pin)
  3805. */
  3806. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3807. /* Do the same for the second ADC: mute capture input amp and
  3808. * set ADC connection to mic1 pin
  3809. */
  3810. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3811. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3812. /* Mute all inputs to mixer widget (even unconnected ones) */
  3813. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3814. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3815. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3816. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3817. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3818. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3819. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3820. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3821. { }
  3822. };
  3823. #endif
  3824. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3825. .substreams = 1,
  3826. .channels_min = 2,
  3827. .channels_max = 2,
  3828. };
  3829. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3830. .substreams = 1,
  3831. .channels_min = 2,
  3832. .channels_max = 2,
  3833. };
  3834. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3835. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3836. /*
  3837. * for BIOS auto-configuration
  3838. */
  3839. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3840. const char *pfx)
  3841. {
  3842. hda_nid_t nid_vol;
  3843. unsigned long vol_val, sw_val;
  3844. char name[32];
  3845. int err;
  3846. if (nid >= 0x0f && nid < 0x11) {
  3847. nid_vol = nid - 0x7;
  3848. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3849. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3850. } else if (nid == 0x11) {
  3851. nid_vol = nid - 0x7;
  3852. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3853. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3854. } else if (nid >= 0x12 && nid <= 0x15) {
  3855. nid_vol = 0x08;
  3856. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3857. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3858. } else
  3859. return 0; /* N/A */
  3860. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3861. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3862. if (err < 0)
  3863. return err;
  3864. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3865. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3866. if (err < 0)
  3867. return err;
  3868. return 1;
  3869. }
  3870. /* add playback controls from the parsed DAC table */
  3871. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3872. const struct auto_pin_cfg *cfg)
  3873. {
  3874. hda_nid_t nid;
  3875. int err;
  3876. spec->multiout.num_dacs = 1;
  3877. spec->multiout.dac_nids = spec->private_dac_nids;
  3878. spec->multiout.dac_nids[0] = 0x02;
  3879. nid = cfg->line_out_pins[0];
  3880. if (nid) {
  3881. err = alc260_add_playback_controls(spec, nid, "Front");
  3882. if (err < 0)
  3883. return err;
  3884. }
  3885. nid = cfg->speaker_pins[0];
  3886. if (nid) {
  3887. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3888. if (err < 0)
  3889. return err;
  3890. }
  3891. nid = cfg->hp_pins[0];
  3892. if (nid) {
  3893. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3894. if (err < 0)
  3895. return err;
  3896. }
  3897. return 0;
  3898. }
  3899. /* create playback/capture controls for input pins */
  3900. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3901. const struct auto_pin_cfg *cfg)
  3902. {
  3903. struct hda_input_mux *imux = &spec->private_imux;
  3904. int i, err, idx;
  3905. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3906. if (cfg->input_pins[i] >= 0x12) {
  3907. idx = cfg->input_pins[i] - 0x12;
  3908. err = new_analog_input(spec, cfg->input_pins[i],
  3909. auto_pin_cfg_labels[i], idx,
  3910. 0x07);
  3911. if (err < 0)
  3912. return err;
  3913. imux->items[imux->num_items].label =
  3914. auto_pin_cfg_labels[i];
  3915. imux->items[imux->num_items].index = idx;
  3916. imux->num_items++;
  3917. }
  3918. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3919. idx = cfg->input_pins[i] - 0x09;
  3920. err = new_analog_input(spec, cfg->input_pins[i],
  3921. auto_pin_cfg_labels[i], idx,
  3922. 0x07);
  3923. if (err < 0)
  3924. return err;
  3925. imux->items[imux->num_items].label =
  3926. auto_pin_cfg_labels[i];
  3927. imux->items[imux->num_items].index = idx;
  3928. imux->num_items++;
  3929. }
  3930. }
  3931. return 0;
  3932. }
  3933. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3934. hda_nid_t nid, int pin_type,
  3935. int sel_idx)
  3936. {
  3937. /* set as output */
  3938. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3939. pin_type);
  3940. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3941. AMP_OUT_UNMUTE);
  3942. /* need the manual connection? */
  3943. if (nid >= 0x12) {
  3944. int idx = nid - 0x12;
  3945. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3946. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3947. }
  3948. }
  3949. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3950. {
  3951. struct alc_spec *spec = codec->spec;
  3952. hda_nid_t nid;
  3953. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  3954. nid = spec->autocfg.line_out_pins[0];
  3955. if (nid) {
  3956. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3957. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  3958. }
  3959. nid = spec->autocfg.speaker_pins[0];
  3960. if (nid)
  3961. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3962. nid = spec->autocfg.hp_pins[0];
  3963. if (nid)
  3964. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  3965. }
  3966. #define ALC260_PIN_CD_NID 0x16
  3967. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3968. {
  3969. struct alc_spec *spec = codec->spec;
  3970. int i;
  3971. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3972. hda_nid_t nid = spec->autocfg.input_pins[i];
  3973. if (nid >= 0x12) {
  3974. snd_hda_codec_write(codec, nid, 0,
  3975. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3976. i <= AUTO_PIN_FRONT_MIC ?
  3977. PIN_VREF80 : PIN_IN);
  3978. if (nid != ALC260_PIN_CD_NID)
  3979. snd_hda_codec_write(codec, nid, 0,
  3980. AC_VERB_SET_AMP_GAIN_MUTE,
  3981. AMP_OUT_MUTE);
  3982. }
  3983. }
  3984. }
  3985. /*
  3986. * generic initialization of ADC, input mixers and output mixers
  3987. */
  3988. static struct hda_verb alc260_volume_init_verbs[] = {
  3989. /*
  3990. * Unmute ADC0-1 and set the default input to mic-in
  3991. */
  3992. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3993. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3994. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3995. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3996. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3997. * mixer widget
  3998. * Note: PASD motherboards uses the Line In 2 as the input for
  3999. * front panel mic (mic 2)
  4000. */
  4001. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4002. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4003. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4004. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4005. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4006. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4007. /*
  4008. * Set up output mixers (0x08 - 0x0a)
  4009. */
  4010. /* set vol=0 to output mixers */
  4011. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4012. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4013. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4014. /* set up input amps for analog loopback */
  4015. /* Amp Indices: DAC = 0, mixer = 1 */
  4016. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4017. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4018. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4019. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4020. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4021. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4022. { }
  4023. };
  4024. static int alc260_parse_auto_config(struct hda_codec *codec)
  4025. {
  4026. struct alc_spec *spec = codec->spec;
  4027. unsigned int wcap;
  4028. int err;
  4029. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4030. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4031. alc260_ignore);
  4032. if (err < 0)
  4033. return err;
  4034. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4035. if (err < 0)
  4036. return err;
  4037. if (!spec->kctl_alloc)
  4038. return 0; /* can't find valid BIOS pin config */
  4039. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4040. if (err < 0)
  4041. return err;
  4042. spec->multiout.max_channels = 2;
  4043. if (spec->autocfg.dig_out_pin)
  4044. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4045. if (spec->kctl_alloc)
  4046. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4047. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4048. spec->num_mux_defs = 1;
  4049. spec->input_mux = &spec->private_imux;
  4050. /* check whether NID 0x04 is valid */
  4051. wcap = get_wcaps(codec, 0x04);
  4052. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4053. if (wcap != AC_WID_AUD_IN) {
  4054. spec->adc_nids = alc260_adc_nids_alt;
  4055. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4056. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4057. } else {
  4058. spec->adc_nids = alc260_adc_nids;
  4059. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4060. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4061. }
  4062. spec->num_mixers++;
  4063. return 1;
  4064. }
  4065. /* additional initialization for auto-configuration model */
  4066. static void alc260_auto_init(struct hda_codec *codec)
  4067. {
  4068. alc260_auto_init_multi_out(codec);
  4069. alc260_auto_init_analog_input(codec);
  4070. }
  4071. /*
  4072. * ALC260 configurations
  4073. */
  4074. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4075. [ALC260_BASIC] = "basic",
  4076. [ALC260_HP] = "hp",
  4077. [ALC260_HP_3013] = "hp-3013",
  4078. [ALC260_FUJITSU_S702X] = "fujitsu",
  4079. [ALC260_ACER] = "acer",
  4080. [ALC260_WILL] = "will",
  4081. [ALC260_REPLACER_672V] = "replacer",
  4082. #ifdef CONFIG_SND_DEBUG
  4083. [ALC260_TEST] = "test",
  4084. #endif
  4085. [ALC260_AUTO] = "auto",
  4086. };
  4087. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4088. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4089. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4090. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4091. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4092. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4093. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4094. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4095. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4096. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4097. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4098. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4099. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4100. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4101. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4102. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4103. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4104. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4105. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4106. {}
  4107. };
  4108. static struct alc_config_preset alc260_presets[] = {
  4109. [ALC260_BASIC] = {
  4110. .mixers = { alc260_base_output_mixer,
  4111. alc260_input_mixer,
  4112. alc260_pc_beep_mixer,
  4113. alc260_capture_mixer },
  4114. .init_verbs = { alc260_init_verbs },
  4115. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4116. .dac_nids = alc260_dac_nids,
  4117. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4118. .adc_nids = alc260_adc_nids,
  4119. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4120. .channel_mode = alc260_modes,
  4121. .input_mux = &alc260_capture_source,
  4122. },
  4123. [ALC260_HP] = {
  4124. .mixers = { alc260_base_output_mixer,
  4125. alc260_input_mixer,
  4126. alc260_capture_alt_mixer },
  4127. .init_verbs = { alc260_init_verbs },
  4128. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4129. .dac_nids = alc260_dac_nids,
  4130. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4131. .adc_nids = alc260_hp_adc_nids,
  4132. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4133. .channel_mode = alc260_modes,
  4134. .input_mux = &alc260_capture_source,
  4135. },
  4136. [ALC260_HP_3013] = {
  4137. .mixers = { alc260_hp_3013_mixer,
  4138. alc260_input_mixer,
  4139. alc260_capture_alt_mixer },
  4140. .init_verbs = { alc260_hp_3013_init_verbs },
  4141. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4142. .dac_nids = alc260_dac_nids,
  4143. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4144. .adc_nids = alc260_hp_adc_nids,
  4145. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4146. .channel_mode = alc260_modes,
  4147. .input_mux = &alc260_capture_source,
  4148. },
  4149. [ALC260_FUJITSU_S702X] = {
  4150. .mixers = { alc260_fujitsu_mixer,
  4151. alc260_capture_mixer },
  4152. .init_verbs = { alc260_fujitsu_init_verbs },
  4153. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4154. .dac_nids = alc260_dac_nids,
  4155. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4156. .adc_nids = alc260_dual_adc_nids,
  4157. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4158. .channel_mode = alc260_modes,
  4159. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4160. .input_mux = alc260_fujitsu_capture_sources,
  4161. },
  4162. [ALC260_ACER] = {
  4163. .mixers = { alc260_acer_mixer,
  4164. alc260_capture_mixer },
  4165. .init_verbs = { alc260_acer_init_verbs },
  4166. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4167. .dac_nids = alc260_dac_nids,
  4168. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4169. .adc_nids = alc260_dual_adc_nids,
  4170. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4171. .channel_mode = alc260_modes,
  4172. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4173. .input_mux = alc260_acer_capture_sources,
  4174. },
  4175. [ALC260_WILL] = {
  4176. .mixers = { alc260_will_mixer,
  4177. alc260_capture_mixer },
  4178. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4179. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4180. .dac_nids = alc260_dac_nids,
  4181. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4182. .adc_nids = alc260_adc_nids,
  4183. .dig_out_nid = ALC260_DIGOUT_NID,
  4184. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4185. .channel_mode = alc260_modes,
  4186. .input_mux = &alc260_capture_source,
  4187. },
  4188. [ALC260_REPLACER_672V] = {
  4189. .mixers = { alc260_replacer_672v_mixer,
  4190. alc260_capture_mixer },
  4191. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4192. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4193. .dac_nids = alc260_dac_nids,
  4194. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4195. .adc_nids = alc260_adc_nids,
  4196. .dig_out_nid = ALC260_DIGOUT_NID,
  4197. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4198. .channel_mode = alc260_modes,
  4199. .input_mux = &alc260_capture_source,
  4200. .unsol_event = alc260_replacer_672v_unsol_event,
  4201. .init_hook = alc260_replacer_672v_automute,
  4202. },
  4203. #ifdef CONFIG_SND_DEBUG
  4204. [ALC260_TEST] = {
  4205. .mixers = { alc260_test_mixer,
  4206. alc260_capture_mixer },
  4207. .init_verbs = { alc260_test_init_verbs },
  4208. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4209. .dac_nids = alc260_test_dac_nids,
  4210. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4211. .adc_nids = alc260_test_adc_nids,
  4212. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4213. .channel_mode = alc260_modes,
  4214. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4215. .input_mux = alc260_test_capture_sources,
  4216. },
  4217. #endif
  4218. };
  4219. static int patch_alc260(struct hda_codec *codec)
  4220. {
  4221. struct alc_spec *spec;
  4222. int err, board_config;
  4223. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4224. if (spec == NULL)
  4225. return -ENOMEM;
  4226. codec->spec = spec;
  4227. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4228. alc260_models,
  4229. alc260_cfg_tbl);
  4230. if (board_config < 0) {
  4231. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4232. "trying auto-probe from BIOS...\n");
  4233. board_config = ALC260_AUTO;
  4234. }
  4235. if (board_config == ALC260_AUTO) {
  4236. /* automatic parse from the BIOS config */
  4237. err = alc260_parse_auto_config(codec);
  4238. if (err < 0) {
  4239. alc_free(codec);
  4240. return err;
  4241. } else if (!err) {
  4242. printk(KERN_INFO
  4243. "hda_codec: Cannot set up configuration "
  4244. "from BIOS. Using base mode...\n");
  4245. board_config = ALC260_BASIC;
  4246. }
  4247. }
  4248. if (board_config != ALC260_AUTO)
  4249. setup_preset(spec, &alc260_presets[board_config]);
  4250. spec->stream_name_analog = "ALC260 Analog";
  4251. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4252. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4253. spec->stream_name_digital = "ALC260 Digital";
  4254. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4255. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4256. codec->patch_ops = alc_patch_ops;
  4257. if (board_config == ALC260_AUTO)
  4258. spec->init_hook = alc260_auto_init;
  4259. return 0;
  4260. }
  4261. /*
  4262. * ALC882 support
  4263. *
  4264. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4265. * configuration. Each pin widget can choose any input DACs and a mixer.
  4266. * Each ADC is connected from a mixer of all inputs. This makes possible
  4267. * 6-channel independent captures.
  4268. *
  4269. * In addition, an independent DAC for the multi-playback (not used in this
  4270. * driver yet).
  4271. */
  4272. #define ALC882_DIGOUT_NID 0x06
  4273. #define ALC882_DIGIN_NID 0x0a
  4274. static struct hda_channel_mode alc882_ch_modes[1] = {
  4275. { 8, NULL }
  4276. };
  4277. static hda_nid_t alc882_dac_nids[4] = {
  4278. /* front, rear, clfe, rear_surr */
  4279. 0x02, 0x03, 0x04, 0x05
  4280. };
  4281. /* identical with ALC880 */
  4282. #define alc882_adc_nids alc880_adc_nids
  4283. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4284. /* input MUX */
  4285. /* FIXME: should be a matrix-type input source selection */
  4286. static struct hda_input_mux alc882_capture_source = {
  4287. .num_items = 4,
  4288. .items = {
  4289. { "Mic", 0x0 },
  4290. { "Front Mic", 0x1 },
  4291. { "Line", 0x2 },
  4292. { "CD", 0x4 },
  4293. },
  4294. };
  4295. #define alc882_mux_enum_info alc_mux_enum_info
  4296. #define alc882_mux_enum_get alc_mux_enum_get
  4297. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4298. struct snd_ctl_elem_value *ucontrol)
  4299. {
  4300. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4301. struct alc_spec *spec = codec->spec;
  4302. const struct hda_input_mux *imux = spec->input_mux;
  4303. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4304. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4305. hda_nid_t nid = capture_mixers[adc_idx];
  4306. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4307. unsigned int i, idx;
  4308. idx = ucontrol->value.enumerated.item[0];
  4309. if (idx >= imux->num_items)
  4310. idx = imux->num_items - 1;
  4311. if (*cur_val == idx && !codec->in_resume)
  4312. return 0;
  4313. for (i = 0; i < imux->num_items; i++) {
  4314. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4315. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4316. v | (imux->items[i].index << 8));
  4317. }
  4318. *cur_val = idx;
  4319. return 1;
  4320. }
  4321. /*
  4322. * 2ch mode
  4323. */
  4324. static struct hda_verb alc882_3ST_ch2_init[] = {
  4325. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4326. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4327. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4328. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4329. { } /* end */
  4330. };
  4331. /*
  4332. * 6ch mode
  4333. */
  4334. static struct hda_verb alc882_3ST_ch6_init[] = {
  4335. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4336. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4337. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4338. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4339. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4340. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4341. { } /* end */
  4342. };
  4343. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4344. { 2, alc882_3ST_ch2_init },
  4345. { 6, alc882_3ST_ch6_init },
  4346. };
  4347. /*
  4348. * 6ch mode
  4349. */
  4350. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4351. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4352. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4353. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4354. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4355. { } /* end */
  4356. };
  4357. /*
  4358. * 8ch mode
  4359. */
  4360. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4361. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4362. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4363. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4364. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4365. { } /* end */
  4366. };
  4367. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4368. { 6, alc882_sixstack_ch6_init },
  4369. { 8, alc882_sixstack_ch8_init },
  4370. };
  4371. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4372. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4373. */
  4374. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4375. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4376. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4377. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4378. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4379. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4380. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4381. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4382. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4383. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4384. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4385. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4386. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4387. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4388. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4389. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4390. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4391. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4392. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4393. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4394. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4395. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4396. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4397. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4398. { } /* end */
  4399. };
  4400. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4401. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4402. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4403. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4404. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4405. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4406. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4407. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4408. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4409. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4410. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4411. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4412. { } /* end */
  4413. };
  4414. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4415. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4416. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4417. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4418. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4419. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4420. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4421. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4422. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4423. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4424. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4425. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4426. { } /* end */
  4427. };
  4428. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4429. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4430. */
  4431. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4432. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4433. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4434. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4435. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4436. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4437. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4438. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4439. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4440. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4441. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4442. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4443. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4444. { } /* end */
  4445. };
  4446. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4447. {
  4448. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4449. .name = "Channel Mode",
  4450. .info = alc_ch_mode_info,
  4451. .get = alc_ch_mode_get,
  4452. .put = alc_ch_mode_put,
  4453. },
  4454. { } /* end */
  4455. };
  4456. static struct hda_verb alc882_init_verbs[] = {
  4457. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4458. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4459. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4460. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4461. /* Rear mixer */
  4462. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4463. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4464. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4465. /* CLFE mixer */
  4466. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4467. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4468. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4469. /* Side mixer */
  4470. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4471. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4472. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4473. /* Front Pin: output 0 (0x0c) */
  4474. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4475. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4476. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4477. /* Rear Pin: output 1 (0x0d) */
  4478. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4479. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4480. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4481. /* CLFE Pin: output 2 (0x0e) */
  4482. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4483. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4484. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4485. /* Side Pin: output 3 (0x0f) */
  4486. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4487. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4488. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4489. /* Mic (rear) pin: input vref at 80% */
  4490. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4491. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4492. /* Front Mic pin: input vref at 80% */
  4493. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4494. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4495. /* Line In pin: input */
  4496. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4497. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4498. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4499. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4500. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4501. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4502. /* CD pin widget for input */
  4503. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4504. /* FIXME: use matrix-type input source selection */
  4505. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4506. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4507. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4508. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4509. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4510. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4511. /* Input mixer2 */
  4512. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4513. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4514. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4515. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4516. /* Input mixer3 */
  4517. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4518. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4519. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4520. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4521. /* ADC1: mute amp left and right */
  4522. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4523. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4524. /* ADC2: mute amp left and right */
  4525. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4526. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4527. /* ADC3: mute amp left and right */
  4528. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4529. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4530. { }
  4531. };
  4532. static struct hda_verb alc882_eapd_verbs[] = {
  4533. /* change to EAPD mode */
  4534. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4535. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4536. { }
  4537. };
  4538. /* Mac Pro test */
  4539. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4540. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4541. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4542. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4543. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4544. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4545. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4546. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4547. { } /* end */
  4548. };
  4549. static struct hda_verb alc882_macpro_init_verbs[] = {
  4550. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4551. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4552. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4553. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4554. /* Front Pin: output 0 (0x0c) */
  4555. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4556. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4557. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4558. /* Front Mic pin: input vref at 80% */
  4559. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4560. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4561. /* Speaker: output */
  4562. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4563. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4564. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4565. /* Headphone output (output 0 - 0x0c) */
  4566. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4567. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4568. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4569. /* FIXME: use matrix-type input source selection */
  4570. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4571. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4572. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4573. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4574. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4575. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4576. /* Input mixer2 */
  4577. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4578. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4579. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4580. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4581. /* Input mixer3 */
  4582. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4583. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4584. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4585. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4586. /* ADC1: mute amp left and right */
  4587. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4588. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4589. /* ADC2: mute amp left and right */
  4590. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4591. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4592. /* ADC3: mute amp left and right */
  4593. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4594. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4595. { }
  4596. };
  4597. static struct hda_verb alc882_targa_verbs[] = {
  4598. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4599. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4600. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4601. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4602. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4603. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4604. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4605. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4606. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4607. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4608. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4609. { } /* end */
  4610. };
  4611. /* toggle speaker-output according to the hp-jack state */
  4612. static void alc882_targa_automute(struct hda_codec *codec)
  4613. {
  4614. unsigned int present;
  4615. present = snd_hda_codec_read(codec, 0x14, 0,
  4616. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4617. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4618. 0x80, present ? 0x80 : 0);
  4619. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4620. 0x80, present ? 0x80 : 0);
  4621. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4622. }
  4623. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4624. {
  4625. /* Looks like the unsol event is incompatible with the standard
  4626. * definition. 4bit tag is placed at 26 bit!
  4627. */
  4628. if (((res >> 26) == ALC880_HP_EVENT)) {
  4629. alc882_targa_automute(codec);
  4630. }
  4631. }
  4632. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4633. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4634. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4635. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4636. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4637. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4638. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4639. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4640. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4641. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4642. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4643. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4644. { } /* end */
  4645. };
  4646. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4647. {
  4648. unsigned int gpiostate, gpiomask, gpiodir;
  4649. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4650. AC_VERB_GET_GPIO_DATA, 0);
  4651. if (!muted)
  4652. gpiostate |= (1 << pin);
  4653. else
  4654. gpiostate &= ~(1 << pin);
  4655. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4656. AC_VERB_GET_GPIO_MASK, 0);
  4657. gpiomask |= (1 << pin);
  4658. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4659. AC_VERB_GET_GPIO_DIRECTION, 0);
  4660. gpiodir |= (1 << pin);
  4661. snd_hda_codec_write(codec, codec->afg, 0,
  4662. AC_VERB_SET_GPIO_MASK, gpiomask);
  4663. snd_hda_codec_write(codec, codec->afg, 0,
  4664. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4665. msleep(1);
  4666. snd_hda_codec_write(codec, codec->afg, 0,
  4667. AC_VERB_SET_GPIO_DATA, gpiostate);
  4668. }
  4669. /*
  4670. * generic initialization of ADC, input mixers and output mixers
  4671. */
  4672. static struct hda_verb alc882_auto_init_verbs[] = {
  4673. /*
  4674. * Unmute ADC0-2 and set the default input to mic-in
  4675. */
  4676. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4677. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4678. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4679. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4680. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4681. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4682. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4683. * mixer widget
  4684. * Note: PASD motherboards uses the Line In 2 as the input for
  4685. * front panel mic (mic 2)
  4686. */
  4687. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4688. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4689. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4690. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4691. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4692. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4693. /*
  4694. * Set up output mixers (0x0c - 0x0f)
  4695. */
  4696. /* set vol=0 to output mixers */
  4697. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4698. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4699. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4700. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4701. /* set up input amps for analog loopback */
  4702. /* Amp Indices: DAC = 0, mixer = 1 */
  4703. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4704. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4705. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4706. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4707. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4708. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4709. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4710. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4711. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4712. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4713. /* FIXME: use matrix-type input source selection */
  4714. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4715. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4716. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4717. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4718. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4719. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4720. /* Input mixer2 */
  4721. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4722. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4723. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4724. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4725. /* Input mixer3 */
  4726. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4727. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4728. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4729. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4730. { }
  4731. };
  4732. /* capture mixer elements */
  4733. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4734. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4735. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4736. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4737. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4738. {
  4739. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4740. /* The multiple "Capture Source" controls confuse alsamixer
  4741. * So call somewhat different..
  4742. * FIXME: the controls appear in the "playback" view!
  4743. */
  4744. /* .name = "Capture Source", */
  4745. .name = "Input Source",
  4746. .count = 2,
  4747. .info = alc882_mux_enum_info,
  4748. .get = alc882_mux_enum_get,
  4749. .put = alc882_mux_enum_put,
  4750. },
  4751. { } /* end */
  4752. };
  4753. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4754. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4755. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4756. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4757. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4758. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4759. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4760. {
  4761. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4762. /* The multiple "Capture Source" controls confuse alsamixer
  4763. * So call somewhat different..
  4764. * FIXME: the controls appear in the "playback" view!
  4765. */
  4766. /* .name = "Capture Source", */
  4767. .name = "Input Source",
  4768. .count = 3,
  4769. .info = alc882_mux_enum_info,
  4770. .get = alc882_mux_enum_get,
  4771. .put = alc882_mux_enum_put,
  4772. },
  4773. { } /* end */
  4774. };
  4775. /* pcm configuration: identiacal with ALC880 */
  4776. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4777. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4778. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4779. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4780. /*
  4781. * configuration and preset
  4782. */
  4783. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4784. [ALC882_3ST_DIG] = "3stack-dig",
  4785. [ALC882_6ST_DIG] = "6stack-dig",
  4786. [ALC882_ARIMA] = "arima",
  4787. [ALC882_W2JC] = "w2jc",
  4788. [ALC885_MACPRO] = "macpro",
  4789. [ALC882_AUTO] = "auto",
  4790. };
  4791. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4792. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4793. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4794. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4795. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4796. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4797. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4798. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4799. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4800. {}
  4801. };
  4802. static struct alc_config_preset alc882_presets[] = {
  4803. [ALC882_3ST_DIG] = {
  4804. .mixers = { alc882_base_mixer },
  4805. .init_verbs = { alc882_init_verbs },
  4806. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4807. .dac_nids = alc882_dac_nids,
  4808. .dig_out_nid = ALC882_DIGOUT_NID,
  4809. .dig_in_nid = ALC882_DIGIN_NID,
  4810. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4811. .channel_mode = alc882_ch_modes,
  4812. .need_dac_fix = 1,
  4813. .input_mux = &alc882_capture_source,
  4814. },
  4815. [ALC882_6ST_DIG] = {
  4816. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4817. .init_verbs = { alc882_init_verbs },
  4818. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4819. .dac_nids = alc882_dac_nids,
  4820. .dig_out_nid = ALC882_DIGOUT_NID,
  4821. .dig_in_nid = ALC882_DIGIN_NID,
  4822. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4823. .channel_mode = alc882_sixstack_modes,
  4824. .input_mux = &alc882_capture_source,
  4825. },
  4826. [ALC882_ARIMA] = {
  4827. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4828. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4829. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4830. .dac_nids = alc882_dac_nids,
  4831. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4832. .channel_mode = alc882_sixstack_modes,
  4833. .input_mux = &alc882_capture_source,
  4834. },
  4835. [ALC882_W2JC] = {
  4836. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4837. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4838. alc880_gpio1_init_verbs },
  4839. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4840. .dac_nids = alc882_dac_nids,
  4841. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4842. .channel_mode = alc880_threestack_modes,
  4843. .need_dac_fix = 1,
  4844. .input_mux = &alc882_capture_source,
  4845. .dig_out_nid = ALC882_DIGOUT_NID,
  4846. },
  4847. [ALC885_MACPRO] = {
  4848. .mixers = { alc882_macpro_mixer },
  4849. .init_verbs = { alc882_macpro_init_verbs },
  4850. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4851. .dac_nids = alc882_dac_nids,
  4852. .dig_out_nid = ALC882_DIGOUT_NID,
  4853. .dig_in_nid = ALC882_DIGIN_NID,
  4854. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4855. .channel_mode = alc882_ch_modes,
  4856. .input_mux = &alc882_capture_source,
  4857. },
  4858. [ALC882_TARGA] = {
  4859. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4860. alc882_capture_mixer },
  4861. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4862. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4863. .dac_nids = alc882_dac_nids,
  4864. .dig_out_nid = ALC882_DIGOUT_NID,
  4865. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4866. .adc_nids = alc882_adc_nids,
  4867. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4868. .channel_mode = alc882_3ST_6ch_modes,
  4869. .need_dac_fix = 1,
  4870. .input_mux = &alc882_capture_source,
  4871. .unsol_event = alc882_targa_unsol_event,
  4872. .init_hook = alc882_targa_automute,
  4873. },
  4874. [ALC882_ASUS_A7J] = {
  4875. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4876. alc882_capture_mixer },
  4877. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4878. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4879. .dac_nids = alc882_dac_nids,
  4880. .dig_out_nid = ALC882_DIGOUT_NID,
  4881. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4882. .adc_nids = alc882_adc_nids,
  4883. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4884. .channel_mode = alc882_3ST_6ch_modes,
  4885. .need_dac_fix = 1,
  4886. .input_mux = &alc882_capture_source,
  4887. },
  4888. };
  4889. /*
  4890. * BIOS auto configuration
  4891. */
  4892. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4893. hda_nid_t nid, int pin_type,
  4894. int dac_idx)
  4895. {
  4896. /* set as output */
  4897. struct alc_spec *spec = codec->spec;
  4898. int idx;
  4899. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4900. idx = 4;
  4901. else
  4902. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4903. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4904. pin_type);
  4905. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4906. AMP_OUT_UNMUTE);
  4907. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4908. }
  4909. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4910. {
  4911. struct alc_spec *spec = codec->spec;
  4912. int i;
  4913. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4914. for (i = 0; i <= HDA_SIDE; i++) {
  4915. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4916. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4917. if (nid)
  4918. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  4919. i);
  4920. }
  4921. }
  4922. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4923. {
  4924. struct alc_spec *spec = codec->spec;
  4925. hda_nid_t pin;
  4926. pin = spec->autocfg.hp_pins[0];
  4927. if (pin) /* connect to front */
  4928. /* use dac 0 */
  4929. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4930. }
  4931. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4932. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4933. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4934. {
  4935. struct alc_spec *spec = codec->spec;
  4936. int i;
  4937. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4938. hda_nid_t nid = spec->autocfg.input_pins[i];
  4939. if (alc882_is_input_pin(nid)) {
  4940. snd_hda_codec_write(codec, nid, 0,
  4941. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4942. i <= AUTO_PIN_FRONT_MIC ?
  4943. PIN_VREF80 : PIN_IN);
  4944. if (nid != ALC882_PIN_CD_NID)
  4945. snd_hda_codec_write(codec, nid, 0,
  4946. AC_VERB_SET_AMP_GAIN_MUTE,
  4947. AMP_OUT_MUTE);
  4948. }
  4949. }
  4950. }
  4951. /* almost identical with ALC880 parser... */
  4952. static int alc882_parse_auto_config(struct hda_codec *codec)
  4953. {
  4954. struct alc_spec *spec = codec->spec;
  4955. int err = alc880_parse_auto_config(codec);
  4956. if (err < 0)
  4957. return err;
  4958. else if (err > 0)
  4959. /* hack - override the init verbs */
  4960. spec->init_verbs[0] = alc882_auto_init_verbs;
  4961. return err;
  4962. }
  4963. /* additional initialization for auto-configuration model */
  4964. static void alc882_auto_init(struct hda_codec *codec)
  4965. {
  4966. alc882_auto_init_multi_out(codec);
  4967. alc882_auto_init_hp_out(codec);
  4968. alc882_auto_init_analog_input(codec);
  4969. }
  4970. static int patch_alc882(struct hda_codec *codec)
  4971. {
  4972. struct alc_spec *spec;
  4973. int err, board_config;
  4974. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4975. if (spec == NULL)
  4976. return -ENOMEM;
  4977. codec->spec = spec;
  4978. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4979. alc882_models,
  4980. alc882_cfg_tbl);
  4981. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4982. /* Pick up systems that don't supply PCI SSID */
  4983. switch (codec->subsystem_id) {
  4984. case 0x106b0c00: /* Mac Pro */
  4985. board_config = ALC885_MACPRO;
  4986. break;
  4987. default:
  4988. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4989. "trying auto-probe from BIOS...\n");
  4990. board_config = ALC882_AUTO;
  4991. }
  4992. }
  4993. if (board_config == ALC882_AUTO) {
  4994. /* automatic parse from the BIOS config */
  4995. err = alc882_parse_auto_config(codec);
  4996. if (err < 0) {
  4997. alc_free(codec);
  4998. return err;
  4999. } else if (!err) {
  5000. printk(KERN_INFO
  5001. "hda_codec: Cannot set up configuration "
  5002. "from BIOS. Using base mode...\n");
  5003. board_config = ALC882_3ST_DIG;
  5004. }
  5005. }
  5006. if (board_config != ALC882_AUTO)
  5007. setup_preset(spec, &alc882_presets[board_config]);
  5008. if (board_config == ALC885_MACPRO) {
  5009. alc882_gpio_mute(codec, 0, 0);
  5010. alc882_gpio_mute(codec, 1, 0);
  5011. }
  5012. spec->stream_name_analog = "ALC882 Analog";
  5013. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5014. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5015. spec->stream_name_digital = "ALC882 Digital";
  5016. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5017. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5018. if (!spec->adc_nids && spec->input_mux) {
  5019. /* check whether NID 0x07 is valid */
  5020. unsigned int wcap = get_wcaps(codec, 0x07);
  5021. /* get type */
  5022. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5023. if (wcap != AC_WID_AUD_IN) {
  5024. spec->adc_nids = alc882_adc_nids_alt;
  5025. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5026. spec->mixers[spec->num_mixers] =
  5027. alc882_capture_alt_mixer;
  5028. spec->num_mixers++;
  5029. } else {
  5030. spec->adc_nids = alc882_adc_nids;
  5031. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5032. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5033. spec->num_mixers++;
  5034. }
  5035. }
  5036. codec->patch_ops = alc_patch_ops;
  5037. if (board_config == ALC882_AUTO)
  5038. spec->init_hook = alc882_auto_init;
  5039. return 0;
  5040. }
  5041. /*
  5042. * ALC883 support
  5043. *
  5044. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5045. * configuration. Each pin widget can choose any input DACs and a mixer.
  5046. * Each ADC is connected from a mixer of all inputs. This makes possible
  5047. * 6-channel independent captures.
  5048. *
  5049. * In addition, an independent DAC for the multi-playback (not used in this
  5050. * driver yet).
  5051. */
  5052. #define ALC883_DIGOUT_NID 0x06
  5053. #define ALC883_DIGIN_NID 0x0a
  5054. static hda_nid_t alc883_dac_nids[4] = {
  5055. /* front, rear, clfe, rear_surr */
  5056. 0x02, 0x04, 0x03, 0x05
  5057. };
  5058. static hda_nid_t alc883_adc_nids[2] = {
  5059. /* ADC1-2 */
  5060. 0x08, 0x09,
  5061. };
  5062. /* input MUX */
  5063. /* FIXME: should be a matrix-type input source selection */
  5064. static struct hda_input_mux alc883_capture_source = {
  5065. .num_items = 4,
  5066. .items = {
  5067. { "Mic", 0x0 },
  5068. { "Front Mic", 0x1 },
  5069. { "Line", 0x2 },
  5070. { "CD", 0x4 },
  5071. },
  5072. };
  5073. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5074. .num_items = 2,
  5075. .items = {
  5076. { "Mic", 0x1 },
  5077. { "Line", 0x2 },
  5078. },
  5079. };
  5080. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5081. .num_items = 4,
  5082. .items = {
  5083. { "Mic", 0x0 },
  5084. { "iMic", 0x1 },
  5085. { "Line", 0x2 },
  5086. { "CD", 0x4 },
  5087. },
  5088. };
  5089. #define alc883_mux_enum_info alc_mux_enum_info
  5090. #define alc883_mux_enum_get alc_mux_enum_get
  5091. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5092. struct snd_ctl_elem_value *ucontrol)
  5093. {
  5094. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5095. struct alc_spec *spec = codec->spec;
  5096. const struct hda_input_mux *imux = spec->input_mux;
  5097. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5098. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5099. hda_nid_t nid = capture_mixers[adc_idx];
  5100. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5101. unsigned int i, idx;
  5102. idx = ucontrol->value.enumerated.item[0];
  5103. if (idx >= imux->num_items)
  5104. idx = imux->num_items - 1;
  5105. if (*cur_val == idx && !codec->in_resume)
  5106. return 0;
  5107. for (i = 0; i < imux->num_items; i++) {
  5108. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5109. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5110. v | (imux->items[i].index << 8));
  5111. }
  5112. *cur_val = idx;
  5113. return 1;
  5114. }
  5115. /*
  5116. * 2ch mode
  5117. */
  5118. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5119. { 2, NULL }
  5120. };
  5121. /*
  5122. * 2ch mode
  5123. */
  5124. static struct hda_verb alc883_3ST_ch2_init[] = {
  5125. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5126. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5127. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5128. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5129. { } /* end */
  5130. };
  5131. /*
  5132. * 6ch mode
  5133. */
  5134. static struct hda_verb alc883_3ST_ch6_init[] = {
  5135. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5136. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5137. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5138. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5139. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5140. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5141. { } /* end */
  5142. };
  5143. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5144. { 2, alc883_3ST_ch2_init },
  5145. { 6, alc883_3ST_ch6_init },
  5146. };
  5147. /*
  5148. * 6ch mode
  5149. */
  5150. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5151. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5152. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5153. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5154. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5155. { } /* end */
  5156. };
  5157. /*
  5158. * 8ch mode
  5159. */
  5160. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5161. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5162. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5163. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5164. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5165. { } /* end */
  5166. };
  5167. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5168. { 6, alc883_sixstack_ch6_init },
  5169. { 8, alc883_sixstack_ch8_init },
  5170. };
  5171. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5172. /* eanable EAPD on medion laptop */
  5173. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5174. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5175. { }
  5176. };
  5177. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5178. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5179. */
  5180. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5181. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5182. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5183. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5184. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5185. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5186. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5187. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5188. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5189. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5190. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5191. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5192. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5193. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5194. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5195. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5196. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5197. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5198. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5199. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5200. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5201. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5202. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5203. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5204. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5205. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5206. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5207. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5208. {
  5209. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5210. /* .name = "Capture Source", */
  5211. .name = "Input Source",
  5212. .count = 2,
  5213. .info = alc883_mux_enum_info,
  5214. .get = alc883_mux_enum_get,
  5215. .put = alc883_mux_enum_put,
  5216. },
  5217. { } /* end */
  5218. };
  5219. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5220. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5221. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5222. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5223. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5224. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5225. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5226. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5227. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5228. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5229. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5230. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5231. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5232. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5233. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5234. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5235. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5236. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5237. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5238. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5239. {
  5240. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5241. /* .name = "Capture Source", */
  5242. .name = "Input Source",
  5243. .count = 2,
  5244. .info = alc883_mux_enum_info,
  5245. .get = alc883_mux_enum_get,
  5246. .put = alc883_mux_enum_put,
  5247. },
  5248. { } /* end */
  5249. };
  5250. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5251. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5252. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5253. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5254. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5255. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5256. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5257. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5258. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5259. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5260. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5261. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5262. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5263. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5264. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5265. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5266. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5267. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5268. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5269. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5270. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5271. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5272. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5273. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5274. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5275. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5276. {
  5277. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5278. /* .name = "Capture Source", */
  5279. .name = "Input Source",
  5280. .count = 2,
  5281. .info = alc883_mux_enum_info,
  5282. .get = alc883_mux_enum_get,
  5283. .put = alc883_mux_enum_put,
  5284. },
  5285. { } /* end */
  5286. };
  5287. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5288. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5289. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5290. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5291. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5292. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5293. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5294. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5295. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5296. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5297. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5298. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5299. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5300. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5301. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5302. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5303. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5304. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5305. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5306. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5307. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5308. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5309. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5310. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5311. {
  5312. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5313. /* .name = "Capture Source", */
  5314. .name = "Input Source",
  5315. .count = 1,
  5316. .info = alc883_mux_enum_info,
  5317. .get = alc883_mux_enum_get,
  5318. .put = alc883_mux_enum_put,
  5319. },
  5320. { } /* end */
  5321. };
  5322. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5323. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5324. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5325. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5326. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5327. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5328. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5329. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5330. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5331. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5332. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5333. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5334. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5335. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5336. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5337. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5338. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5339. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5340. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5341. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5342. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5343. {
  5344. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5345. /* .name = "Capture Source", */
  5346. .name = "Input Source",
  5347. .count = 2,
  5348. .info = alc883_mux_enum_info,
  5349. .get = alc883_mux_enum_get,
  5350. .put = alc883_mux_enum_put,
  5351. },
  5352. { } /* end */
  5353. };
  5354. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5355. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5356. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5357. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5358. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5359. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5360. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5361. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5362. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5363. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5364. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5365. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5366. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5367. {
  5368. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5369. /* .name = "Capture Source", */
  5370. .name = "Input Source",
  5371. .count = 2,
  5372. .info = alc883_mux_enum_info,
  5373. .get = alc883_mux_enum_get,
  5374. .put = alc883_mux_enum_put,
  5375. },
  5376. { } /* end */
  5377. };
  5378. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5379. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5380. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5381. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5382. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5383. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5384. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5385. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5386. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5387. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5388. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5389. {
  5390. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5391. /* .name = "Capture Source", */
  5392. .name = "Input Source",
  5393. .count = 1,
  5394. .info = alc883_mux_enum_info,
  5395. .get = alc883_mux_enum_get,
  5396. .put = alc883_mux_enum_put,
  5397. },
  5398. { } /* end */
  5399. };
  5400. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5401. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5402. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5403. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5404. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5405. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5406. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5407. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5408. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5409. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5410. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5411. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5412. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5413. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5414. {
  5415. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5416. /* .name = "Capture Source", */
  5417. .name = "Input Source",
  5418. .count = 2,
  5419. .info = alc883_mux_enum_info,
  5420. .get = alc883_mux_enum_get,
  5421. .put = alc883_mux_enum_put,
  5422. },
  5423. { } /* end */
  5424. };
  5425. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5426. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5427. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5428. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5429. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5430. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5431. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5432. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5433. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5434. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5435. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5436. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5437. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5438. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5439. {
  5440. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5441. /* .name = "Capture Source", */
  5442. .name = "Input Source",
  5443. .count = 2,
  5444. .info = alc883_mux_enum_info,
  5445. .get = alc883_mux_enum_get,
  5446. .put = alc883_mux_enum_put,
  5447. },
  5448. { } /* end */
  5449. };
  5450. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5451. {
  5452. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5453. .name = "Channel Mode",
  5454. .info = alc_ch_mode_info,
  5455. .get = alc_ch_mode_get,
  5456. .put = alc_ch_mode_put,
  5457. },
  5458. { } /* end */
  5459. };
  5460. static struct hda_verb alc883_init_verbs[] = {
  5461. /* ADC1: mute amp left and right */
  5462. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5463. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5464. /* ADC2: mute amp left and right */
  5465. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5466. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5467. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5468. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5469. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5470. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5471. /* Rear mixer */
  5472. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5473. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5474. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5475. /* CLFE mixer */
  5476. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5477. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5478. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5479. /* Side mixer */
  5480. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5481. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5482. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5483. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5484. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5485. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5486. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5487. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5488. /* Front Pin: output 0 (0x0c) */
  5489. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5490. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5491. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5492. /* Rear Pin: output 1 (0x0d) */
  5493. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5494. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5495. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5496. /* CLFE Pin: output 2 (0x0e) */
  5497. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5498. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5499. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5500. /* Side Pin: output 3 (0x0f) */
  5501. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5502. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5503. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5504. /* Mic (rear) pin: input vref at 80% */
  5505. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5506. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5507. /* Front Mic pin: input vref at 80% */
  5508. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5509. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5510. /* Line In pin: input */
  5511. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5512. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5513. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5514. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5515. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5516. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5517. /* CD pin widget for input */
  5518. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5519. /* FIXME: use matrix-type input source selection */
  5520. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5521. /* Input mixer2 */
  5522. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5523. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5524. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5525. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5526. /* Input mixer3 */
  5527. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5528. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5529. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5530. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5531. { }
  5532. };
  5533. static struct hda_verb alc883_tagra_verbs[] = {
  5534. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5535. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5536. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5537. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5538. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5539. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5540. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5541. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5542. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5543. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5544. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5545. { } /* end */
  5546. };
  5547. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5548. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5549. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5550. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5551. { } /* end */
  5552. };
  5553. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5554. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5555. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5556. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5557. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5558. { } /* end */
  5559. };
  5560. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5561. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5562. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5563. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5564. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5565. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5566. { } /* end */
  5567. };
  5568. /* toggle front-jack and RCA according to the hp-jack state */
  5569. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5570. {
  5571. unsigned int present;
  5572. present = snd_hda_codec_read(codec, 0x1b, 0,
  5573. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5574. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5575. 0x80, present ? 0x80 : 0);
  5576. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5577. 0x80, present ? 0x80 : 0);
  5578. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5579. 0x80, present ? 0x80 : 0);
  5580. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5581. 0x80, present ? 0x80 : 0);
  5582. }
  5583. /* toggle RCA according to the front-jack state */
  5584. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5585. {
  5586. unsigned int present;
  5587. present = snd_hda_codec_read(codec, 0x14, 0,
  5588. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5589. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5590. 0x80, present ? 0x80 : 0);
  5591. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5592. 0x80, present ? 0x80 : 0);
  5593. }
  5594. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5595. unsigned int res)
  5596. {
  5597. if ((res >> 26) == ALC880_HP_EVENT)
  5598. alc888_lenovo_ms7195_front_automute(codec);
  5599. if ((res >> 26) == ALC880_FRONT_EVENT)
  5600. alc888_lenovo_ms7195_rca_automute(codec);
  5601. }
  5602. static struct hda_verb alc883_medion_md2_verbs[] = {
  5603. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5604. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5605. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5606. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5607. { } /* end */
  5608. };
  5609. /* toggle speaker-output according to the hp-jack state */
  5610. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5611. {
  5612. unsigned int present;
  5613. present = snd_hda_codec_read(codec, 0x14, 0,
  5614. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5615. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5616. 0x80, present ? 0x80 : 0);
  5617. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5618. 0x80, present ? 0x80 : 0);
  5619. }
  5620. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5621. unsigned int res)
  5622. {
  5623. if ((res >> 26) == ALC880_HP_EVENT)
  5624. alc883_medion_md2_automute(codec);
  5625. }
  5626. /* toggle speaker-output according to the hp-jack state */
  5627. static void alc883_tagra_automute(struct hda_codec *codec)
  5628. {
  5629. unsigned int present;
  5630. unsigned char bits;
  5631. present = snd_hda_codec_read(codec, 0x14, 0,
  5632. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5633. bits = present ? 0x80 : 0;
  5634. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5635. 0x80, bits);
  5636. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5637. 0x80, bits);
  5638. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5639. present ? 1 : 3);
  5640. }
  5641. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5642. {
  5643. if ((res >> 26) == ALC880_HP_EVENT)
  5644. alc883_tagra_automute(codec);
  5645. }
  5646. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5647. {
  5648. unsigned int present;
  5649. unsigned char bits;
  5650. present = snd_hda_codec_read(codec, 0x14, 0,
  5651. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5652. bits = present ? 0x80 : 0;
  5653. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5654. 0x80, bits);
  5655. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5656. 0x80, bits);
  5657. }
  5658. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5659. {
  5660. unsigned int present;
  5661. unsigned char bits;
  5662. present = snd_hda_codec_read(codec, 0x1b, 0,
  5663. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5664. bits = present ? 0x80 : 0;
  5665. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5666. 0x80, bits);
  5667. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5668. 0x80, bits);
  5669. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5670. 0x80, bits);
  5671. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5672. 0x80, bits);
  5673. }
  5674. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5675. unsigned int res)
  5676. {
  5677. if ((res >> 26) == ALC880_HP_EVENT)
  5678. alc883_lenovo_101e_all_automute(codec);
  5679. if ((res >> 26) == ALC880_FRONT_EVENT)
  5680. alc883_lenovo_101e_ispeaker_automute(codec);
  5681. }
  5682. /*
  5683. * generic initialization of ADC, input mixers and output mixers
  5684. */
  5685. static struct hda_verb alc883_auto_init_verbs[] = {
  5686. /*
  5687. * Unmute ADC0-2 and set the default input to mic-in
  5688. */
  5689. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5690. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5691. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5692. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5693. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5694. * mixer widget
  5695. * Note: PASD motherboards uses the Line In 2 as the input for
  5696. * front panel mic (mic 2)
  5697. */
  5698. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5699. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5700. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5701. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5702. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5703. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5704. /*
  5705. * Set up output mixers (0x0c - 0x0f)
  5706. */
  5707. /* set vol=0 to output mixers */
  5708. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5709. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5710. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5711. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5712. /* set up input amps for analog loopback */
  5713. /* Amp Indices: DAC = 0, mixer = 1 */
  5714. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5715. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5716. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5717. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5718. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5719. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5720. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5721. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5722. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5723. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5724. /* FIXME: use matrix-type input source selection */
  5725. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5726. /* Input mixer1 */
  5727. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5728. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5729. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5730. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5731. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5732. /* Input mixer2 */
  5733. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5734. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5735. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5736. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5737. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5738. { }
  5739. };
  5740. /* capture mixer elements */
  5741. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5742. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5743. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5744. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5745. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5746. {
  5747. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5748. /* The multiple "Capture Source" controls confuse alsamixer
  5749. * So call somewhat different..
  5750. * FIXME: the controls appear in the "playback" view!
  5751. */
  5752. /* .name = "Capture Source", */
  5753. .name = "Input Source",
  5754. .count = 2,
  5755. .info = alc882_mux_enum_info,
  5756. .get = alc882_mux_enum_get,
  5757. .put = alc882_mux_enum_put,
  5758. },
  5759. { } /* end */
  5760. };
  5761. /* pcm configuration: identiacal with ALC880 */
  5762. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5763. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5764. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5765. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5766. /*
  5767. * configuration and preset
  5768. */
  5769. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5770. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5771. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5772. [ALC883_3ST_6ch] = "3stack-6ch",
  5773. [ALC883_6ST_DIG] = "6stack-dig",
  5774. [ALC883_TARGA_DIG] = "targa-dig",
  5775. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5776. [ALC883_ACER] = "acer",
  5777. [ALC883_MEDION] = "medion",
  5778. [ALC883_MEDION_MD2] = "medion-md2",
  5779. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5780. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5781. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  5782. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  5783. [ALC883_AUTO] = "auto",
  5784. };
  5785. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5786. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5787. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5788. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5789. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5790. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5791. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5792. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5793. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  5794. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5795. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  5796. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5797. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  5798. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5799. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5800. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5801. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5802. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5803. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5804. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5805. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5806. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5807. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5808. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  5809. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5810. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5811. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5812. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  5813. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5814. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5815. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  5816. {}
  5817. };
  5818. static struct alc_config_preset alc883_presets[] = {
  5819. [ALC883_3ST_2ch_DIG] = {
  5820. .mixers = { alc883_3ST_2ch_mixer },
  5821. .init_verbs = { alc883_init_verbs },
  5822. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5823. .dac_nids = alc883_dac_nids,
  5824. .dig_out_nid = ALC883_DIGOUT_NID,
  5825. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5826. .adc_nids = alc883_adc_nids,
  5827. .dig_in_nid = ALC883_DIGIN_NID,
  5828. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5829. .channel_mode = alc883_3ST_2ch_modes,
  5830. .input_mux = &alc883_capture_source,
  5831. },
  5832. [ALC883_3ST_6ch_DIG] = {
  5833. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5834. .init_verbs = { alc883_init_verbs },
  5835. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5836. .dac_nids = alc883_dac_nids,
  5837. .dig_out_nid = ALC883_DIGOUT_NID,
  5838. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5839. .adc_nids = alc883_adc_nids,
  5840. .dig_in_nid = ALC883_DIGIN_NID,
  5841. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5842. .channel_mode = alc883_3ST_6ch_modes,
  5843. .need_dac_fix = 1,
  5844. .input_mux = &alc883_capture_source,
  5845. },
  5846. [ALC883_3ST_6ch] = {
  5847. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5848. .init_verbs = { alc883_init_verbs },
  5849. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5850. .dac_nids = alc883_dac_nids,
  5851. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5852. .adc_nids = alc883_adc_nids,
  5853. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5854. .channel_mode = alc883_3ST_6ch_modes,
  5855. .need_dac_fix = 1,
  5856. .input_mux = &alc883_capture_source,
  5857. },
  5858. [ALC883_6ST_DIG] = {
  5859. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5860. .init_verbs = { alc883_init_verbs },
  5861. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5862. .dac_nids = alc883_dac_nids,
  5863. .dig_out_nid = ALC883_DIGOUT_NID,
  5864. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5865. .adc_nids = alc883_adc_nids,
  5866. .dig_in_nid = ALC883_DIGIN_NID,
  5867. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5868. .channel_mode = alc883_sixstack_modes,
  5869. .input_mux = &alc883_capture_source,
  5870. },
  5871. [ALC883_TARGA_DIG] = {
  5872. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5873. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5874. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5875. .dac_nids = alc883_dac_nids,
  5876. .dig_out_nid = ALC883_DIGOUT_NID,
  5877. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5878. .adc_nids = alc883_adc_nids,
  5879. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5880. .channel_mode = alc883_3ST_6ch_modes,
  5881. .need_dac_fix = 1,
  5882. .input_mux = &alc883_capture_source,
  5883. .unsol_event = alc883_tagra_unsol_event,
  5884. .init_hook = alc883_tagra_automute,
  5885. },
  5886. [ALC883_TARGA_2ch_DIG] = {
  5887. .mixers = { alc883_tagra_2ch_mixer},
  5888. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5889. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5890. .dac_nids = alc883_dac_nids,
  5891. .dig_out_nid = ALC883_DIGOUT_NID,
  5892. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5893. .adc_nids = alc883_adc_nids,
  5894. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5895. .channel_mode = alc883_3ST_2ch_modes,
  5896. .input_mux = &alc883_capture_source,
  5897. .unsol_event = alc883_tagra_unsol_event,
  5898. .init_hook = alc883_tagra_automute,
  5899. },
  5900. [ALC883_ACER] = {
  5901. .mixers = { alc883_base_mixer,
  5902. alc883_chmode_mixer },
  5903. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5904. * and the headphone jack. Turn this on and rely on the
  5905. * standard mute methods whenever the user wants to turn
  5906. * these outputs off.
  5907. */
  5908. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5909. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5910. .dac_nids = alc883_dac_nids,
  5911. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5912. .adc_nids = alc883_adc_nids,
  5913. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5914. .channel_mode = alc883_3ST_2ch_modes,
  5915. .input_mux = &alc883_capture_source,
  5916. },
  5917. [ALC883_MEDION] = {
  5918. .mixers = { alc883_fivestack_mixer,
  5919. alc883_chmode_mixer },
  5920. .init_verbs = { alc883_init_verbs,
  5921. alc883_medion_eapd_verbs },
  5922. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5923. .dac_nids = alc883_dac_nids,
  5924. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5925. .adc_nids = alc883_adc_nids,
  5926. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5927. .channel_mode = alc883_sixstack_modes,
  5928. .input_mux = &alc883_capture_source,
  5929. },
  5930. [ALC883_MEDION_MD2] = {
  5931. .mixers = { alc883_medion_md2_mixer},
  5932. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  5933. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5934. .dac_nids = alc883_dac_nids,
  5935. .dig_out_nid = ALC883_DIGOUT_NID,
  5936. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5937. .adc_nids = alc883_adc_nids,
  5938. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5939. .channel_mode = alc883_3ST_2ch_modes,
  5940. .input_mux = &alc883_capture_source,
  5941. .unsol_event = alc883_medion_md2_unsol_event,
  5942. .init_hook = alc883_medion_md2_automute,
  5943. },
  5944. [ALC883_LAPTOP_EAPD] = {
  5945. .mixers = { alc883_base_mixer,
  5946. alc883_chmode_mixer },
  5947. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5948. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5949. .dac_nids = alc883_dac_nids,
  5950. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5951. .adc_nids = alc883_adc_nids,
  5952. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5953. .channel_mode = alc883_3ST_2ch_modes,
  5954. .input_mux = &alc883_capture_source,
  5955. },
  5956. [ALC883_LENOVO_101E_2ch] = {
  5957. .mixers = { alc883_lenovo_101e_2ch_mixer},
  5958. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  5959. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5960. .dac_nids = alc883_dac_nids,
  5961. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5962. .adc_nids = alc883_adc_nids,
  5963. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5964. .channel_mode = alc883_3ST_2ch_modes,
  5965. .input_mux = &alc883_lenovo_101e_capture_source,
  5966. .unsol_event = alc883_lenovo_101e_unsol_event,
  5967. .init_hook = alc883_lenovo_101e_all_automute,
  5968. },
  5969. [ALC883_LENOVO_NB0763] = {
  5970. .mixers = { alc883_lenovo_nb0763_mixer },
  5971. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  5972. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5973. .dac_nids = alc883_dac_nids,
  5974. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5975. .adc_nids = alc883_adc_nids,
  5976. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5977. .channel_mode = alc883_3ST_2ch_modes,
  5978. .need_dac_fix = 1,
  5979. .input_mux = &alc883_lenovo_nb0763_capture_source,
  5980. .unsol_event = alc883_medion_md2_unsol_event,
  5981. .init_hook = alc883_medion_md2_automute,
  5982. },
  5983. [ALC888_LENOVO_MS7195_DIG] = {
  5984. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5985. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  5986. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5987. .dac_nids = alc883_dac_nids,
  5988. .dig_out_nid = ALC883_DIGOUT_NID,
  5989. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5990. .adc_nids = alc883_adc_nids,
  5991. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5992. .channel_mode = alc883_3ST_6ch_modes,
  5993. .need_dac_fix = 1,
  5994. .input_mux = &alc883_capture_source,
  5995. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  5996. .init_hook = alc888_lenovo_ms7195_front_automute,
  5997. },
  5998. };
  5999. /*
  6000. * BIOS auto configuration
  6001. */
  6002. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6003. hda_nid_t nid, int pin_type,
  6004. int dac_idx)
  6005. {
  6006. /* set as output */
  6007. struct alc_spec *spec = codec->spec;
  6008. int idx;
  6009. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6010. idx = 4;
  6011. else
  6012. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6013. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6014. pin_type);
  6015. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6016. AMP_OUT_UNMUTE);
  6017. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6018. }
  6019. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6020. {
  6021. struct alc_spec *spec = codec->spec;
  6022. int i;
  6023. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6024. for (i = 0; i <= HDA_SIDE; i++) {
  6025. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6026. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6027. if (nid)
  6028. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6029. i);
  6030. }
  6031. }
  6032. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6033. {
  6034. struct alc_spec *spec = codec->spec;
  6035. hda_nid_t pin;
  6036. pin = spec->autocfg.hp_pins[0];
  6037. if (pin) /* connect to front */
  6038. /* use dac 0 */
  6039. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6040. }
  6041. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6042. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6043. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6044. {
  6045. struct alc_spec *spec = codec->spec;
  6046. int i;
  6047. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6048. hda_nid_t nid = spec->autocfg.input_pins[i];
  6049. if (alc883_is_input_pin(nid)) {
  6050. snd_hda_codec_write(codec, nid, 0,
  6051. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6052. (i <= AUTO_PIN_FRONT_MIC ?
  6053. PIN_VREF80 : PIN_IN));
  6054. if (nid != ALC883_PIN_CD_NID)
  6055. snd_hda_codec_write(codec, nid, 0,
  6056. AC_VERB_SET_AMP_GAIN_MUTE,
  6057. AMP_OUT_MUTE);
  6058. }
  6059. }
  6060. }
  6061. /* almost identical with ALC880 parser... */
  6062. static int alc883_parse_auto_config(struct hda_codec *codec)
  6063. {
  6064. struct alc_spec *spec = codec->spec;
  6065. int err = alc880_parse_auto_config(codec);
  6066. if (err < 0)
  6067. return err;
  6068. else if (err > 0)
  6069. /* hack - override the init verbs */
  6070. spec->init_verbs[0] = alc883_auto_init_verbs;
  6071. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6072. spec->num_mixers++;
  6073. return err;
  6074. }
  6075. /* additional initialization for auto-configuration model */
  6076. static void alc883_auto_init(struct hda_codec *codec)
  6077. {
  6078. alc883_auto_init_multi_out(codec);
  6079. alc883_auto_init_hp_out(codec);
  6080. alc883_auto_init_analog_input(codec);
  6081. }
  6082. static int patch_alc883(struct hda_codec *codec)
  6083. {
  6084. struct alc_spec *spec;
  6085. int err, board_config;
  6086. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6087. if (spec == NULL)
  6088. return -ENOMEM;
  6089. codec->spec = spec;
  6090. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6091. alc883_models,
  6092. alc883_cfg_tbl);
  6093. if (board_config < 0) {
  6094. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6095. "trying auto-probe from BIOS...\n");
  6096. board_config = ALC883_AUTO;
  6097. }
  6098. if (board_config == ALC883_AUTO) {
  6099. /* automatic parse from the BIOS config */
  6100. err = alc883_parse_auto_config(codec);
  6101. if (err < 0) {
  6102. alc_free(codec);
  6103. return err;
  6104. } else if (!err) {
  6105. printk(KERN_INFO
  6106. "hda_codec: Cannot set up configuration "
  6107. "from BIOS. Using base mode...\n");
  6108. board_config = ALC883_3ST_2ch_DIG;
  6109. }
  6110. }
  6111. if (board_config != ALC883_AUTO)
  6112. setup_preset(spec, &alc883_presets[board_config]);
  6113. spec->stream_name_analog = "ALC883 Analog";
  6114. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6115. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6116. spec->stream_name_digital = "ALC883 Digital";
  6117. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6118. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6119. if (!spec->adc_nids && spec->input_mux) {
  6120. spec->adc_nids = alc883_adc_nids;
  6121. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6122. }
  6123. codec->patch_ops = alc_patch_ops;
  6124. if (board_config == ALC883_AUTO)
  6125. spec->init_hook = alc883_auto_init;
  6126. return 0;
  6127. }
  6128. /*
  6129. * ALC262 support
  6130. */
  6131. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6132. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6133. #define alc262_dac_nids alc260_dac_nids
  6134. #define alc262_adc_nids alc882_adc_nids
  6135. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6136. #define alc262_modes alc260_modes
  6137. #define alc262_capture_source alc882_capture_source
  6138. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6139. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6140. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6141. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6142. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6143. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6144. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6145. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6146. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6147. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6148. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6149. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6150. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6151. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6152. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6153. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6154. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6155. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6156. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6157. { } /* end */
  6158. };
  6159. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6160. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6161. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6162. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6163. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6164. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6165. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6166. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6167. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6168. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6169. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6170. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6171. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6172. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6173. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6174. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6175. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6176. { } /* end */
  6177. };
  6178. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6179. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6180. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6181. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6182. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6183. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6184. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6185. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6186. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6187. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6188. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6189. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6190. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6191. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6192. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6193. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6194. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6195. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6196. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6197. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6198. { } /* end */
  6199. };
  6200. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6201. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6202. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6203. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6204. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6205. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6206. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6207. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6208. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6209. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6210. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6211. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6212. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6213. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6214. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6215. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6216. { } /* end */
  6217. };
  6218. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6219. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6220. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6221. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6222. { } /* end */
  6223. };
  6224. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6225. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6226. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6227. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6228. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6229. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6230. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6231. { } /* end */
  6232. };
  6233. #define alc262_capture_mixer alc882_capture_mixer
  6234. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6235. /*
  6236. * generic initialization of ADC, input mixers and output mixers
  6237. */
  6238. static struct hda_verb alc262_init_verbs[] = {
  6239. /*
  6240. * Unmute ADC0-2 and set the default input to mic-in
  6241. */
  6242. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6243. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6244. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6245. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6246. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6247. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6248. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6249. * mixer widget
  6250. * Note: PASD motherboards uses the Line In 2 as the input for
  6251. * front panel mic (mic 2)
  6252. */
  6253. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6254. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6255. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6256. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6257. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6258. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6259. /*
  6260. * Set up output mixers (0x0c - 0x0e)
  6261. */
  6262. /* set vol=0 to output mixers */
  6263. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6264. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6265. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6266. /* set up input amps for analog loopback */
  6267. /* Amp Indices: DAC = 0, mixer = 1 */
  6268. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6269. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6270. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6271. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6272. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6273. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6274. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6275. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6276. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6277. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6278. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6279. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6280. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6281. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6282. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6283. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6284. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6285. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6286. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6287. /* FIXME: use matrix-type input source selection */
  6288. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6289. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6290. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6291. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6292. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6293. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6294. /* Input mixer2 */
  6295. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6296. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6297. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6298. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6299. /* Input mixer3 */
  6300. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6301. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6302. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6303. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6304. { }
  6305. };
  6306. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6307. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6308. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6309. {}
  6310. };
  6311. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6312. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6313. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6314. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6315. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6316. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6317. {}
  6318. };
  6319. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6320. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6321. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6322. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6323. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6324. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6325. };
  6326. /* mute/unmute internal speaker according to the hp jack and mute state */
  6327. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  6328. {
  6329. struct alc_spec *spec = codec->spec;
  6330. unsigned int mute;
  6331. if (force || !spec->sense_updated) {
  6332. unsigned int present;
  6333. /* need to execute and sync at first */
  6334. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6335. present = snd_hda_codec_read(codec, 0x15, 0,
  6336. AC_VERB_GET_PIN_SENSE, 0);
  6337. spec->jack_present = (present & 0x80000000) != 0;
  6338. spec->sense_updated = 1;
  6339. }
  6340. if (spec->jack_present) {
  6341. /* mute internal speaker */
  6342. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6343. 0x80, 0x80);
  6344. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6345. 0x80, 0x80);
  6346. } else {
  6347. /* unmute internal speaker if necessary */
  6348. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6349. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6350. 0x80, mute & 0x80);
  6351. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6352. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6353. 0x80, mute & 0x80);
  6354. }
  6355. }
  6356. /* unsolicited event for HP jack sensing */
  6357. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6358. unsigned int res)
  6359. {
  6360. if ((res >> 26) != ALC880_HP_EVENT)
  6361. return;
  6362. alc262_hippo_automute(codec, 1);
  6363. }
  6364. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  6365. {
  6366. struct alc_spec *spec = codec->spec;
  6367. unsigned int mute;
  6368. if (force || !spec->sense_updated) {
  6369. unsigned int present;
  6370. /* need to execute and sync at first */
  6371. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6372. present = snd_hda_codec_read(codec, 0x1b, 0,
  6373. AC_VERB_GET_PIN_SENSE, 0);
  6374. spec->jack_present = (present & 0x80000000) != 0;
  6375. spec->sense_updated = 1;
  6376. }
  6377. if (spec->jack_present) {
  6378. /* mute internal speaker */
  6379. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6380. 0x80, 0x80);
  6381. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6382. 0x80, 0x80);
  6383. } else {
  6384. /* unmute internal speaker if necessary */
  6385. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6386. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6387. 0x80, mute & 0x80);
  6388. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6389. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6390. 0x80, mute & 0x80);
  6391. }
  6392. }
  6393. /* unsolicited event for HP jack sensing */
  6394. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6395. unsigned int res)
  6396. {
  6397. if ((res >> 26) != ALC880_HP_EVENT)
  6398. return;
  6399. alc262_hippo1_automute(codec, 1);
  6400. }
  6401. /*
  6402. * fujitsu model
  6403. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6404. */
  6405. #define ALC_HP_EVENT 0x37
  6406. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6407. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6408. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6409. {}
  6410. };
  6411. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6412. .num_items = 2,
  6413. .items = {
  6414. { "Mic", 0x0 },
  6415. { "CD", 0x4 },
  6416. },
  6417. };
  6418. static struct hda_input_mux alc262_HP_capture_source = {
  6419. .num_items = 5,
  6420. .items = {
  6421. { "Mic", 0x0 },
  6422. { "Front Mic", 0x3 },
  6423. { "Line", 0x2 },
  6424. { "CD", 0x4 },
  6425. { "AUX IN", 0x6 },
  6426. },
  6427. };
  6428. /* mute/unmute internal speaker according to the hp jack and mute state */
  6429. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6430. {
  6431. struct alc_spec *spec = codec->spec;
  6432. unsigned int mute;
  6433. if (force || !spec->sense_updated) {
  6434. unsigned int present;
  6435. /* need to execute and sync at first */
  6436. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6437. present = snd_hda_codec_read(codec, 0x14, 0,
  6438. AC_VERB_GET_PIN_SENSE, 0);
  6439. spec->jack_present = (present & 0x80000000) != 0;
  6440. spec->sense_updated = 1;
  6441. }
  6442. if (spec->jack_present) {
  6443. /* mute internal speaker */
  6444. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6445. 0x80, 0x80);
  6446. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6447. 0x80, 0x80);
  6448. } else {
  6449. /* unmute internal speaker if necessary */
  6450. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6451. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6452. 0x80, mute & 0x80);
  6453. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6454. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6455. 0x80, mute & 0x80);
  6456. }
  6457. }
  6458. /* unsolicited event for HP jack sensing */
  6459. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6460. unsigned int res)
  6461. {
  6462. if ((res >> 26) != ALC_HP_EVENT)
  6463. return;
  6464. alc262_fujitsu_automute(codec, 1);
  6465. }
  6466. /* bind volumes of both NID 0x0c and 0x0d */
  6467. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6468. struct snd_ctl_elem_value *ucontrol)
  6469. {
  6470. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6471. long *valp = ucontrol->value.integer.value;
  6472. int change;
  6473. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6474. 0x7f, valp[0] & 0x7f);
  6475. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6476. 0x7f, valp[1] & 0x7f);
  6477. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6478. 0x7f, valp[0] & 0x7f);
  6479. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6480. 0x7f, valp[1] & 0x7f);
  6481. return change;
  6482. }
  6483. /* bind hp and internal speaker mute (with plug check) */
  6484. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6485. struct snd_ctl_elem_value *ucontrol)
  6486. {
  6487. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6488. long *valp = ucontrol->value.integer.value;
  6489. int change;
  6490. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6491. 0x80, valp[0] ? 0 : 0x80);
  6492. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6493. 0x80, valp[1] ? 0 : 0x80);
  6494. if (change || codec->in_resume)
  6495. alc262_fujitsu_automute(codec, codec->in_resume);
  6496. return change;
  6497. }
  6498. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6499. {
  6500. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6501. .name = "Master Playback Volume",
  6502. .info = snd_hda_mixer_amp_volume_info,
  6503. .get = snd_hda_mixer_amp_volume_get,
  6504. .put = alc262_fujitsu_master_vol_put,
  6505. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6506. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6507. },
  6508. {
  6509. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6510. .name = "Master Playback Switch",
  6511. .info = snd_hda_mixer_amp_switch_info,
  6512. .get = snd_hda_mixer_amp_switch_get,
  6513. .put = alc262_fujitsu_master_sw_put,
  6514. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6515. },
  6516. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6517. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6518. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6519. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6520. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6521. { } /* end */
  6522. };
  6523. /* additional init verbs for Benq laptops */
  6524. static struct hda_verb alc262_EAPD_verbs[] = {
  6525. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6526. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6527. {}
  6528. };
  6529. /* add playback controls from the parsed DAC table */
  6530. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6531. const struct auto_pin_cfg *cfg)
  6532. {
  6533. hda_nid_t nid;
  6534. int err;
  6535. spec->multiout.num_dacs = 1; /* only use one dac */
  6536. spec->multiout.dac_nids = spec->private_dac_nids;
  6537. spec->multiout.dac_nids[0] = 2;
  6538. nid = cfg->line_out_pins[0];
  6539. if (nid) {
  6540. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6541. "Front Playback Volume",
  6542. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6543. if (err < 0)
  6544. return err;
  6545. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6546. "Front Playback Switch",
  6547. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6548. if (err < 0)
  6549. return err;
  6550. }
  6551. nid = cfg->speaker_pins[0];
  6552. if (nid) {
  6553. if (nid == 0x16) {
  6554. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6555. "Speaker Playback Volume",
  6556. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6557. HDA_OUTPUT));
  6558. if (err < 0)
  6559. return err;
  6560. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6561. "Speaker Playback Switch",
  6562. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6563. HDA_OUTPUT));
  6564. if (err < 0)
  6565. return err;
  6566. } else {
  6567. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6568. "Speaker Playback Switch",
  6569. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6570. HDA_OUTPUT));
  6571. if (err < 0)
  6572. return err;
  6573. }
  6574. }
  6575. nid = cfg->hp_pins[0];
  6576. if (nid) {
  6577. /* spec->multiout.hp_nid = 2; */
  6578. if (nid == 0x16) {
  6579. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6580. "Headphone Playback Volume",
  6581. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6582. HDA_OUTPUT));
  6583. if (err < 0)
  6584. return err;
  6585. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6586. "Headphone Playback Switch",
  6587. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6588. HDA_OUTPUT));
  6589. if (err < 0)
  6590. return err;
  6591. } else {
  6592. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6593. "Headphone Playback Switch",
  6594. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6595. HDA_OUTPUT));
  6596. if (err < 0)
  6597. return err;
  6598. }
  6599. }
  6600. return 0;
  6601. }
  6602. /* identical with ALC880 */
  6603. #define alc262_auto_create_analog_input_ctls \
  6604. alc880_auto_create_analog_input_ctls
  6605. /*
  6606. * generic initialization of ADC, input mixers and output mixers
  6607. */
  6608. static struct hda_verb alc262_volume_init_verbs[] = {
  6609. /*
  6610. * Unmute ADC0-2 and set the default input to mic-in
  6611. */
  6612. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6613. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6614. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6615. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6616. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6617. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6618. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6619. * mixer widget
  6620. * Note: PASD motherboards uses the Line In 2 as the input for
  6621. * front panel mic (mic 2)
  6622. */
  6623. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6624. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6625. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6626. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6627. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6628. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6629. /*
  6630. * Set up output mixers (0x0c - 0x0f)
  6631. */
  6632. /* set vol=0 to output mixers */
  6633. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6634. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6635. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6636. /* set up input amps for analog loopback */
  6637. /* Amp Indices: DAC = 0, mixer = 1 */
  6638. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6639. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6640. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6641. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6642. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6643. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6644. /* FIXME: use matrix-type input source selection */
  6645. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6646. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6647. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6648. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6649. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6650. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6651. /* Input mixer2 */
  6652. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6653. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6654. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6655. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6656. /* Input mixer3 */
  6657. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6658. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6659. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6660. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6661. { }
  6662. };
  6663. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6664. /*
  6665. * Unmute ADC0-2 and set the default input to mic-in
  6666. */
  6667. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6668. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6669. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6670. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6671. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6672. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6673. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6674. * mixer widget
  6675. * Note: PASD motherboards uses the Line In 2 as the input for
  6676. * front panel mic (mic 2)
  6677. */
  6678. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6679. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6680. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6681. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6682. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6683. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6684. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6685. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6686. /*
  6687. * Set up output mixers (0x0c - 0x0e)
  6688. */
  6689. /* set vol=0 to output mixers */
  6690. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6691. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6692. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6693. /* set up input amps for analog loopback */
  6694. /* Amp Indices: DAC = 0, mixer = 1 */
  6695. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6696. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6697. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6698. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6699. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6700. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6701. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6702. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6703. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6704. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6705. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6706. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6707. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6708. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6709. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6710. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6711. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6712. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6713. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6714. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6715. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6716. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6717. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6718. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6719. /* FIXME: use matrix-type input source selection */
  6720. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6721. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6722. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6723. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6724. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6725. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6726. /* Input mixer2 */
  6727. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6728. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6729. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6730. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6731. /* Input mixer3 */
  6732. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6733. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6734. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6735. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6736. { }
  6737. };
  6738. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6739. /*
  6740. * Unmute ADC0-2 and set the default input to mic-in
  6741. */
  6742. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6743. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6744. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6745. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6746. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6747. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6748. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6749. * mixer widget
  6750. * Note: PASD motherboards uses the Line In 2 as the input for front
  6751. * panel mic (mic 2)
  6752. */
  6753. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6754. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6755. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6756. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6757. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6758. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6759. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6760. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6761. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6762. /*
  6763. * Set up output mixers (0x0c - 0x0e)
  6764. */
  6765. /* set vol=0 to output mixers */
  6766. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6767. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6768. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6769. /* set up input amps for analog loopback */
  6770. /* Amp Indices: DAC = 0, mixer = 1 */
  6771. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6772. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6773. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6774. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6775. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6776. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6777. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  6778. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  6779. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  6780. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  6781. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  6782. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  6783. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  6784. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6785. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6786. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6787. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6788. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  6789. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6790. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6791. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6792. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6793. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6794. /* FIXME: use matrix-type input source selection */
  6795. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6796. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6797. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  6798. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  6799. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  6800. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  6801. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  6802. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6803. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  6804. /* Input mixer2 */
  6805. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6806. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6807. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6808. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6809. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6810. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6811. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6812. /* Input mixer3 */
  6813. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6814. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6815. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6816. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6817. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6818. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6819. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6820. { }
  6821. };
  6822. /* pcm configuration: identiacal with ALC880 */
  6823. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  6824. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  6825. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  6826. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  6827. /*
  6828. * BIOS auto configuration
  6829. */
  6830. static int alc262_parse_auto_config(struct hda_codec *codec)
  6831. {
  6832. struct alc_spec *spec = codec->spec;
  6833. int err;
  6834. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  6835. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6836. alc262_ignore);
  6837. if (err < 0)
  6838. return err;
  6839. if (!spec->autocfg.line_outs)
  6840. return 0; /* can't find valid BIOS pin config */
  6841. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  6842. if (err < 0)
  6843. return err;
  6844. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  6845. if (err < 0)
  6846. return err;
  6847. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6848. if (spec->autocfg.dig_out_pin)
  6849. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  6850. if (spec->autocfg.dig_in_pin)
  6851. spec->dig_in_nid = ALC262_DIGIN_NID;
  6852. if (spec->kctl_alloc)
  6853. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6854. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  6855. spec->num_mux_defs = 1;
  6856. spec->input_mux = &spec->private_imux;
  6857. return 1;
  6858. }
  6859. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  6860. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  6861. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  6862. /* init callback for auto-configuration model -- overriding the default init */
  6863. static void alc262_auto_init(struct hda_codec *codec)
  6864. {
  6865. alc262_auto_init_multi_out(codec);
  6866. alc262_auto_init_hp_out(codec);
  6867. alc262_auto_init_analog_input(codec);
  6868. }
  6869. /*
  6870. * configuration and preset
  6871. */
  6872. static const char *alc262_models[ALC262_MODEL_LAST] = {
  6873. [ALC262_BASIC] = "basic",
  6874. [ALC262_HIPPO] = "hippo",
  6875. [ALC262_HIPPO_1] = "hippo_1",
  6876. [ALC262_FUJITSU] = "fujitsu",
  6877. [ALC262_HP_BPC] = "hp-bpc",
  6878. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  6879. [ALC262_BENQ_ED8] = "benq",
  6880. [ALC262_BENQ_ED8] = "sony-assamd",
  6881. [ALC262_AUTO] = "auto",
  6882. };
  6883. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  6884. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  6885. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  6886. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  6887. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  6888. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  6889. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  6890. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  6891. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  6892. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  6893. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6894. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6895. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6896. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6897. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6898. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6899. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6900. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6901. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  6902. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  6903. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  6904. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  6905. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  6906. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6907. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6908. {}
  6909. };
  6910. static struct alc_config_preset alc262_presets[] = {
  6911. [ALC262_BASIC] = {
  6912. .mixers = { alc262_base_mixer },
  6913. .init_verbs = { alc262_init_verbs },
  6914. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6915. .dac_nids = alc262_dac_nids,
  6916. .hp_nid = 0x03,
  6917. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6918. .channel_mode = alc262_modes,
  6919. .input_mux = &alc262_capture_source,
  6920. },
  6921. [ALC262_HIPPO] = {
  6922. .mixers = { alc262_base_mixer },
  6923. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  6924. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6925. .dac_nids = alc262_dac_nids,
  6926. .hp_nid = 0x03,
  6927. .dig_out_nid = ALC262_DIGOUT_NID,
  6928. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6929. .channel_mode = alc262_modes,
  6930. .input_mux = &alc262_capture_source,
  6931. .unsol_event = alc262_hippo_unsol_event,
  6932. },
  6933. [ALC262_HIPPO_1] = {
  6934. .mixers = { alc262_hippo1_mixer },
  6935. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  6936. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6937. .dac_nids = alc262_dac_nids,
  6938. .hp_nid = 0x02,
  6939. .dig_out_nid = ALC262_DIGOUT_NID,
  6940. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6941. .channel_mode = alc262_modes,
  6942. .input_mux = &alc262_capture_source,
  6943. .unsol_event = alc262_hippo1_unsol_event,
  6944. },
  6945. [ALC262_FUJITSU] = {
  6946. .mixers = { alc262_fujitsu_mixer },
  6947. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  6948. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6949. .dac_nids = alc262_dac_nids,
  6950. .hp_nid = 0x03,
  6951. .dig_out_nid = ALC262_DIGOUT_NID,
  6952. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6953. .channel_mode = alc262_modes,
  6954. .input_mux = &alc262_fujitsu_capture_source,
  6955. .unsol_event = alc262_fujitsu_unsol_event,
  6956. },
  6957. [ALC262_HP_BPC] = {
  6958. .mixers = { alc262_HP_BPC_mixer },
  6959. .init_verbs = { alc262_HP_BPC_init_verbs },
  6960. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6961. .dac_nids = alc262_dac_nids,
  6962. .hp_nid = 0x03,
  6963. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6964. .channel_mode = alc262_modes,
  6965. .input_mux = &alc262_HP_capture_source,
  6966. },
  6967. [ALC262_HP_BPC_D7000_WF] = {
  6968. .mixers = { alc262_HP_BPC_WildWest_mixer },
  6969. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6970. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6971. .dac_nids = alc262_dac_nids,
  6972. .hp_nid = 0x03,
  6973. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6974. .channel_mode = alc262_modes,
  6975. .input_mux = &alc262_HP_capture_source,
  6976. },
  6977. [ALC262_HP_BPC_D7000_WL] = {
  6978. .mixers = { alc262_HP_BPC_WildWest_mixer,
  6979. alc262_HP_BPC_WildWest_option_mixer },
  6980. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6981. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6982. .dac_nids = alc262_dac_nids,
  6983. .hp_nid = 0x03,
  6984. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6985. .channel_mode = alc262_modes,
  6986. .input_mux = &alc262_HP_capture_source,
  6987. },
  6988. [ALC262_BENQ_ED8] = {
  6989. .mixers = { alc262_base_mixer },
  6990. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  6991. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6992. .dac_nids = alc262_dac_nids,
  6993. .hp_nid = 0x03,
  6994. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6995. .channel_mode = alc262_modes,
  6996. .input_mux = &alc262_capture_source,
  6997. },
  6998. [ALC262_SONY_ASSAMD] = {
  6999. .mixers = { alc262_sony_mixer },
  7000. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7001. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7002. .dac_nids = alc262_dac_nids,
  7003. .hp_nid = 0x02,
  7004. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7005. .channel_mode = alc262_modes,
  7006. .input_mux = &alc262_capture_source,
  7007. .unsol_event = alc262_hippo_unsol_event,
  7008. },
  7009. };
  7010. static int patch_alc262(struct hda_codec *codec)
  7011. {
  7012. struct alc_spec *spec;
  7013. int board_config;
  7014. int err;
  7015. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7016. if (spec == NULL)
  7017. return -ENOMEM;
  7018. codec->spec = spec;
  7019. #if 0
  7020. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7021. * under-run
  7022. */
  7023. {
  7024. int tmp;
  7025. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7026. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7027. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7028. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7029. }
  7030. #endif
  7031. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7032. alc262_models,
  7033. alc262_cfg_tbl);
  7034. if (board_config < 0) {
  7035. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7036. "trying auto-probe from BIOS...\n");
  7037. board_config = ALC262_AUTO;
  7038. }
  7039. if (board_config == ALC262_AUTO) {
  7040. /* automatic parse from the BIOS config */
  7041. err = alc262_parse_auto_config(codec);
  7042. if (err < 0) {
  7043. alc_free(codec);
  7044. return err;
  7045. } else if (!err) {
  7046. printk(KERN_INFO
  7047. "hda_codec: Cannot set up configuration "
  7048. "from BIOS. Using base mode...\n");
  7049. board_config = ALC262_BASIC;
  7050. }
  7051. }
  7052. if (board_config != ALC262_AUTO)
  7053. setup_preset(spec, &alc262_presets[board_config]);
  7054. spec->stream_name_analog = "ALC262 Analog";
  7055. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7056. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7057. spec->stream_name_digital = "ALC262 Digital";
  7058. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7059. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7060. if (!spec->adc_nids && spec->input_mux) {
  7061. /* check whether NID 0x07 is valid */
  7062. unsigned int wcap = get_wcaps(codec, 0x07);
  7063. /* get type */
  7064. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7065. if (wcap != AC_WID_AUD_IN) {
  7066. spec->adc_nids = alc262_adc_nids_alt;
  7067. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7068. spec->mixers[spec->num_mixers] =
  7069. alc262_capture_alt_mixer;
  7070. spec->num_mixers++;
  7071. } else {
  7072. spec->adc_nids = alc262_adc_nids;
  7073. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7074. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7075. spec->num_mixers++;
  7076. }
  7077. }
  7078. codec->patch_ops = alc_patch_ops;
  7079. if (board_config == ALC262_AUTO)
  7080. spec->init_hook = alc262_auto_init;
  7081. return 0;
  7082. }
  7083. /*
  7084. * ALC268 channel source setting (2 channel)
  7085. */
  7086. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7087. #define alc268_modes alc260_modes
  7088. static hda_nid_t alc268_dac_nids[2] = {
  7089. /* front, hp */
  7090. 0x02, 0x03
  7091. };
  7092. static hda_nid_t alc268_adc_nids[2] = {
  7093. /* ADC0-1 */
  7094. 0x08, 0x07
  7095. };
  7096. static hda_nid_t alc268_adc_nids_alt[1] = {
  7097. /* ADC0 */
  7098. 0x08
  7099. };
  7100. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7101. /* output mixer control */
  7102. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7103. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7104. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7105. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7106. { }
  7107. };
  7108. /*
  7109. * generic initialization of ADC, input mixers and output mixers
  7110. */
  7111. static struct hda_verb alc268_base_init_verbs[] = {
  7112. /* Unmute DAC0-1 and set vol = 0 */
  7113. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7114. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7115. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7116. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7117. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7118. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7119. /*
  7120. * Set up output mixers (0x0c - 0x0e)
  7121. */
  7122. /* set vol=0 to output mixers */
  7123. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7124. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7125. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7126. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7127. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7128. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7129. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7130. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7131. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7132. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7133. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7134. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7135. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7136. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7137. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7138. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7139. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7140. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7141. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7142. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7143. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7144. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7145. /* FIXME: use matrix-type input source selection */
  7146. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7147. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7148. /* Input mixer2 */
  7149. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7150. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7151. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7152. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7153. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7154. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7155. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7156. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7157. { }
  7158. };
  7159. /*
  7160. * generic initialization of ADC, input mixers and output mixers
  7161. */
  7162. static struct hda_verb alc268_volume_init_verbs[] = {
  7163. /* set output DAC */
  7164. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7165. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7166. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7167. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7168. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7169. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7170. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7171. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7172. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7173. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7174. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7175. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7176. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7177. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7178. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7179. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7180. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7181. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7182. /* set PCBEEP vol = 0 */
  7183. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7184. { }
  7185. };
  7186. #define alc268_mux_enum_info alc_mux_enum_info
  7187. #define alc268_mux_enum_get alc_mux_enum_get
  7188. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7189. struct snd_ctl_elem_value *ucontrol)
  7190. {
  7191. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7192. struct alc_spec *spec = codec->spec;
  7193. const struct hda_input_mux *imux = spec->input_mux;
  7194. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7195. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7196. hda_nid_t nid = capture_mixers[adc_idx];
  7197. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7198. unsigned int i, idx;
  7199. idx = ucontrol->value.enumerated.item[0];
  7200. if (idx >= imux->num_items)
  7201. idx = imux->num_items - 1;
  7202. if (*cur_val == idx && !codec->in_resume)
  7203. return 0;
  7204. for (i = 0; i < imux->num_items; i++) {
  7205. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7206. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7207. v | (imux->items[i].index << 8));
  7208. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
  7209. idx );
  7210. }
  7211. *cur_val = idx;
  7212. return 1;
  7213. }
  7214. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7215. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7216. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7217. {
  7218. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7219. /* The multiple "Capture Source" controls confuse alsamixer
  7220. * So call somewhat different..
  7221. * FIXME: the controls appear in the "playback" view!
  7222. */
  7223. /* .name = "Capture Source", */
  7224. .name = "Input Source",
  7225. .count = 1,
  7226. .info = alc268_mux_enum_info,
  7227. .get = alc268_mux_enum_get,
  7228. .put = alc268_mux_enum_put,
  7229. },
  7230. { } /* end */
  7231. };
  7232. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7233. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7234. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7235. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7236. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7237. {
  7238. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7239. /* The multiple "Capture Source" controls confuse alsamixer
  7240. * So call somewhat different..
  7241. * FIXME: the controls appear in the "playback" view!
  7242. */
  7243. /* .name = "Capture Source", */
  7244. .name = "Input Source",
  7245. .count = 2,
  7246. .info = alc268_mux_enum_info,
  7247. .get = alc268_mux_enum_get,
  7248. .put = alc268_mux_enum_put,
  7249. },
  7250. { } /* end */
  7251. };
  7252. static struct hda_input_mux alc268_capture_source = {
  7253. .num_items = 4,
  7254. .items = {
  7255. { "Mic", 0x0 },
  7256. { "Front Mic", 0x1 },
  7257. { "Line", 0x2 },
  7258. { "CD", 0x3 },
  7259. },
  7260. };
  7261. /* create input playback/capture controls for the given pin */
  7262. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7263. const char *ctlname, int idx)
  7264. {
  7265. char name[32];
  7266. int err;
  7267. sprintf(name, "%s Playback Volume", ctlname);
  7268. if (nid == 0x14) {
  7269. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7270. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7271. HDA_OUTPUT));
  7272. if (err < 0)
  7273. return err;
  7274. } else if (nid == 0x15) {
  7275. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7276. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7277. HDA_OUTPUT));
  7278. if (err < 0)
  7279. return err;
  7280. } else
  7281. return -1;
  7282. sprintf(name, "%s Playback Switch", ctlname);
  7283. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7284. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7285. if (err < 0)
  7286. return err;
  7287. return 0;
  7288. }
  7289. /* add playback controls from the parsed DAC table */
  7290. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7291. const struct auto_pin_cfg *cfg)
  7292. {
  7293. hda_nid_t nid;
  7294. int err;
  7295. spec->multiout.num_dacs = 2; /* only use one dac */
  7296. spec->multiout.dac_nids = spec->private_dac_nids;
  7297. spec->multiout.dac_nids[0] = 2;
  7298. spec->multiout.dac_nids[1] = 3;
  7299. nid = cfg->line_out_pins[0];
  7300. if (nid)
  7301. alc268_new_analog_output(spec, nid, "Front", 0);
  7302. nid = cfg->speaker_pins[0];
  7303. if (nid == 0x1d) {
  7304. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7305. "Speaker Playback Volume",
  7306. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7307. if (err < 0)
  7308. return err;
  7309. }
  7310. nid = cfg->hp_pins[0];
  7311. if (nid)
  7312. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7313. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7314. if (nid == 0x16) {
  7315. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7316. "Mono Playback Switch",
  7317. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7318. if (err < 0)
  7319. return err;
  7320. }
  7321. return 0;
  7322. }
  7323. /* create playback/capture controls for input pins */
  7324. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7325. const struct auto_pin_cfg *cfg)
  7326. {
  7327. struct hda_input_mux *imux = &spec->private_imux;
  7328. int i, idx1;
  7329. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7330. switch(cfg->input_pins[i]) {
  7331. case 0x18:
  7332. idx1 = 0; /* Mic 1 */
  7333. break;
  7334. case 0x19:
  7335. idx1 = 1; /* Mic 2 */
  7336. break;
  7337. case 0x1a:
  7338. idx1 = 2; /* Line In */
  7339. break;
  7340. case 0x1c:
  7341. idx1 = 3; /* CD */
  7342. break;
  7343. default:
  7344. continue;
  7345. }
  7346. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7347. imux->items[imux->num_items].index = idx1;
  7348. imux->num_items++;
  7349. }
  7350. return 0;
  7351. }
  7352. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7353. {
  7354. struct alc_spec *spec = codec->spec;
  7355. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7356. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7357. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7358. unsigned int dac_vol1, dac_vol2;
  7359. if (speaker_nid) {
  7360. snd_hda_codec_write(codec, speaker_nid, 0,
  7361. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7362. snd_hda_codec_write(codec, 0x0f, 0,
  7363. AC_VERB_SET_AMP_GAIN_MUTE,
  7364. AMP_IN_UNMUTE(1));
  7365. snd_hda_codec_write(codec, 0x10, 0,
  7366. AC_VERB_SET_AMP_GAIN_MUTE,
  7367. AMP_IN_UNMUTE(1));
  7368. } else {
  7369. snd_hda_codec_write(codec, 0x0f, 0,
  7370. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7371. snd_hda_codec_write(codec, 0x10, 0,
  7372. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7373. }
  7374. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7375. if (line_nid == 0x14)
  7376. dac_vol2 = AMP_OUT_ZERO;
  7377. else if (line_nid == 0x15)
  7378. dac_vol1 = AMP_OUT_ZERO;
  7379. if (hp_nid == 0x14)
  7380. dac_vol2 = AMP_OUT_ZERO;
  7381. else if (hp_nid == 0x15)
  7382. dac_vol1 = AMP_OUT_ZERO;
  7383. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7384. spec->autocfg.line_out_pins[1] != 0x16 ||
  7385. spec->autocfg.line_out_pins[2] != 0x16)
  7386. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7387. snd_hda_codec_write(codec, 0x02, 0,
  7388. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7389. snd_hda_codec_write(codec, 0x03, 0,
  7390. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7391. }
  7392. /* pcm configuration: identiacal with ALC880 */
  7393. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7394. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7395. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7396. /*
  7397. * BIOS auto configuration
  7398. */
  7399. static int alc268_parse_auto_config(struct hda_codec *codec)
  7400. {
  7401. struct alc_spec *spec = codec->spec;
  7402. int err;
  7403. static hda_nid_t alc268_ignore[] = { 0 };
  7404. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7405. alc268_ignore);
  7406. if (err < 0)
  7407. return err;
  7408. if (!spec->autocfg.line_outs)
  7409. return 0; /* can't find valid BIOS pin config */
  7410. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7411. if (err < 0)
  7412. return err;
  7413. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7414. if (err < 0)
  7415. return err;
  7416. spec->multiout.max_channels = 2;
  7417. /* digital only support output */
  7418. if (spec->autocfg.dig_out_pin)
  7419. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7420. if (spec->kctl_alloc)
  7421. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7422. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7423. spec->num_mux_defs = 1;
  7424. spec->input_mux = &spec->private_imux;
  7425. return 1;
  7426. }
  7427. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7428. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7429. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7430. /* init callback for auto-configuration model -- overriding the default init */
  7431. static void alc268_auto_init(struct hda_codec *codec)
  7432. {
  7433. alc268_auto_init_multi_out(codec);
  7434. alc268_auto_init_hp_out(codec);
  7435. alc268_auto_init_mono_speaker_out(codec);
  7436. alc268_auto_init_analog_input(codec);
  7437. }
  7438. /*
  7439. * configuration and preset
  7440. */
  7441. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7442. [ALC268_3ST] = "3stack",
  7443. [ALC268_AUTO] = "auto",
  7444. };
  7445. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7446. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7447. {}
  7448. };
  7449. static struct alc_config_preset alc268_presets[] = {
  7450. [ALC268_3ST] = {
  7451. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7452. .init_verbs = { alc268_base_init_verbs },
  7453. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7454. .dac_nids = alc268_dac_nids,
  7455. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7456. .adc_nids = alc268_adc_nids_alt,
  7457. .hp_nid = 0x03,
  7458. .dig_out_nid = ALC268_DIGOUT_NID,
  7459. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7460. .channel_mode = alc268_modes,
  7461. .input_mux = &alc268_capture_source,
  7462. },
  7463. };
  7464. static int patch_alc268(struct hda_codec *codec)
  7465. {
  7466. struct alc_spec *spec;
  7467. int board_config;
  7468. int err;
  7469. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7470. if (spec == NULL)
  7471. return -ENOMEM;
  7472. codec->spec = spec;
  7473. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7474. alc268_models,
  7475. alc268_cfg_tbl);
  7476. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7477. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7478. "trying auto-probe from BIOS...\n");
  7479. board_config = ALC268_AUTO;
  7480. }
  7481. if (board_config == ALC268_AUTO) {
  7482. /* automatic parse from the BIOS config */
  7483. err = alc268_parse_auto_config(codec);
  7484. if (err < 0) {
  7485. alc_free(codec);
  7486. return err;
  7487. } else if (!err) {
  7488. printk(KERN_INFO
  7489. "hda_codec: Cannot set up configuration "
  7490. "from BIOS. Using base mode...\n");
  7491. board_config = ALC268_3ST;
  7492. }
  7493. }
  7494. if (board_config != ALC268_AUTO)
  7495. setup_preset(spec, &alc268_presets[board_config]);
  7496. spec->stream_name_analog = "ALC268 Analog";
  7497. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7498. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7499. spec->stream_name_digital = "ALC268 Digital";
  7500. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7501. if (board_config == ALC268_AUTO) {
  7502. if (!spec->adc_nids && spec->input_mux) {
  7503. /* check whether NID 0x07 is valid */
  7504. unsigned int wcap = get_wcaps(codec, 0x07);
  7505. /* get type */
  7506. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7507. if (wcap != AC_WID_AUD_IN) {
  7508. spec->adc_nids = alc268_adc_nids_alt;
  7509. spec->num_adc_nids =
  7510. ARRAY_SIZE(alc268_adc_nids_alt);
  7511. spec->mixers[spec->num_mixers] =
  7512. alc268_capture_alt_mixer;
  7513. spec->num_mixers++;
  7514. } else {
  7515. spec->adc_nids = alc268_adc_nids;
  7516. spec->num_adc_nids =
  7517. ARRAY_SIZE(alc268_adc_nids);
  7518. spec->mixers[spec->num_mixers] =
  7519. alc268_capture_mixer;
  7520. spec->num_mixers++;
  7521. }
  7522. }
  7523. }
  7524. codec->patch_ops = alc_patch_ops;
  7525. if (board_config == ALC268_AUTO)
  7526. spec->init_hook = alc268_auto_init;
  7527. return 0;
  7528. }
  7529. /*
  7530. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7531. */
  7532. /*
  7533. * set the path ways for 2 channel output
  7534. * need to set the codec line out and mic 1 pin widgets to inputs
  7535. */
  7536. static struct hda_verb alc861_threestack_ch2_init[] = {
  7537. /* set pin widget 1Ah (line in) for input */
  7538. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7539. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7540. * the vref
  7541. */
  7542. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7543. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7544. #if 0
  7545. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7546. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7547. #endif
  7548. { } /* end */
  7549. };
  7550. /*
  7551. * 6ch mode
  7552. * need to set the codec line out and mic 1 pin widgets to outputs
  7553. */
  7554. static struct hda_verb alc861_threestack_ch6_init[] = {
  7555. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7556. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7557. /* set pin widget 18h (mic1) for output (CLFE)*/
  7558. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7559. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7560. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7561. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7562. #if 0
  7563. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7564. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7565. #endif
  7566. { } /* end */
  7567. };
  7568. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7569. { 2, alc861_threestack_ch2_init },
  7570. { 6, alc861_threestack_ch6_init },
  7571. };
  7572. /* Set mic1 as input and unmute the mixer */
  7573. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7574. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7575. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7576. { } /* end */
  7577. };
  7578. /* Set mic1 as output and mute mixer */
  7579. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7580. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7581. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7582. { } /* end */
  7583. };
  7584. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7585. { 2, alc861_uniwill_m31_ch2_init },
  7586. { 4, alc861_uniwill_m31_ch4_init },
  7587. };
  7588. /* Set mic1 and line-in as input and unmute the mixer */
  7589. static struct hda_verb alc861_asus_ch2_init[] = {
  7590. /* set pin widget 1Ah (line in) for input */
  7591. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7592. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7593. * the vref
  7594. */
  7595. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7596. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7597. #if 0
  7598. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7599. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7600. #endif
  7601. { } /* end */
  7602. };
  7603. /* Set mic1 nad line-in as output and mute mixer */
  7604. static struct hda_verb alc861_asus_ch6_init[] = {
  7605. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7606. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7607. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7608. /* set pin widget 18h (mic1) for output (CLFE)*/
  7609. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7610. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7611. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7612. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7613. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7614. #if 0
  7615. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7616. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7617. #endif
  7618. { } /* end */
  7619. };
  7620. static struct hda_channel_mode alc861_asus_modes[2] = {
  7621. { 2, alc861_asus_ch2_init },
  7622. { 6, alc861_asus_ch6_init },
  7623. };
  7624. /* patch-ALC861 */
  7625. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7626. /* output mixer control */
  7627. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7628. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7629. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7630. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7631. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7632. /*Input mixer control */
  7633. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7634. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7635. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7636. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7637. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7638. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7639. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7640. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7641. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7642. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7643. /* Capture mixer control */
  7644. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7645. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7646. {
  7647. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7648. .name = "Capture Source",
  7649. .count = 1,
  7650. .info = alc_mux_enum_info,
  7651. .get = alc_mux_enum_get,
  7652. .put = alc_mux_enum_put,
  7653. },
  7654. { } /* end */
  7655. };
  7656. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7657. /* output mixer control */
  7658. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7659. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7660. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7661. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7662. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7663. /* Input mixer control */
  7664. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7665. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7666. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7667. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7668. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7669. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7670. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7671. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7672. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7673. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7674. /* Capture mixer control */
  7675. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7676. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7677. {
  7678. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7679. .name = "Capture Source",
  7680. .count = 1,
  7681. .info = alc_mux_enum_info,
  7682. .get = alc_mux_enum_get,
  7683. .put = alc_mux_enum_put,
  7684. },
  7685. {
  7686. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7687. .name = "Channel Mode",
  7688. .info = alc_ch_mode_info,
  7689. .get = alc_ch_mode_get,
  7690. .put = alc_ch_mode_put,
  7691. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7692. },
  7693. { } /* end */
  7694. };
  7695. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  7696. /* output mixer control */
  7697. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7698. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7699. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7700. /*Capture mixer control */
  7701. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7702. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7703. {
  7704. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7705. .name = "Capture Source",
  7706. .count = 1,
  7707. .info = alc_mux_enum_info,
  7708. .get = alc_mux_enum_get,
  7709. .put = alc_mux_enum_put,
  7710. },
  7711. { } /* end */
  7712. };
  7713. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  7714. /* output mixer control */
  7715. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7716. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7717. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7718. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7719. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7720. /* Input mixer control */
  7721. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7722. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7723. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7724. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7725. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7726. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7727. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7728. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7729. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7730. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7731. /* Capture mixer control */
  7732. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7733. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7734. {
  7735. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7736. .name = "Capture Source",
  7737. .count = 1,
  7738. .info = alc_mux_enum_info,
  7739. .get = alc_mux_enum_get,
  7740. .put = alc_mux_enum_put,
  7741. },
  7742. {
  7743. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7744. .name = "Channel Mode",
  7745. .info = alc_ch_mode_info,
  7746. .get = alc_ch_mode_get,
  7747. .put = alc_ch_mode_put,
  7748. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7749. },
  7750. { } /* end */
  7751. };
  7752. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  7753. /* output mixer control */
  7754. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7755. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7756. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7757. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7758. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7759. /* Input mixer control */
  7760. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7761. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7762. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7763. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7764. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7765. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7766. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7767. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7768. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7769. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  7770. /* Capture mixer control */
  7771. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7772. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7773. {
  7774. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7775. .name = "Capture Source",
  7776. .count = 1,
  7777. .info = alc_mux_enum_info,
  7778. .get = alc_mux_enum_get,
  7779. .put = alc_mux_enum_put,
  7780. },
  7781. {
  7782. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7783. .name = "Channel Mode",
  7784. .info = alc_ch_mode_info,
  7785. .get = alc_ch_mode_get,
  7786. .put = alc_ch_mode_put,
  7787. .private_value = ARRAY_SIZE(alc861_asus_modes),
  7788. },
  7789. { }
  7790. };
  7791. /* additional mixer */
  7792. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  7793. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7794. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7795. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  7796. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  7797. { }
  7798. };
  7799. /*
  7800. * generic initialization of ADC, input mixers and output mixers
  7801. */
  7802. static struct hda_verb alc861_base_init_verbs[] = {
  7803. /*
  7804. * Unmute ADC0 and set the default input to mic-in
  7805. */
  7806. /* port-A for surround (rear panel) */
  7807. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7808. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7809. /* port-B for mic-in (rear panel) with vref */
  7810. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7811. /* port-C for line-in (rear panel) */
  7812. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7813. /* port-D for Front */
  7814. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7815. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7816. /* port-E for HP out (front panel) */
  7817. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7818. /* route front PCM to HP */
  7819. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7820. /* port-F for mic-in (front panel) with vref */
  7821. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7822. /* port-G for CLFE (rear panel) */
  7823. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7824. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7825. /* port-H for side (rear panel) */
  7826. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7827. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7828. /* CD-in */
  7829. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7830. /* route front mic to ADC1*/
  7831. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7832. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7833. /* Unmute DAC0~3 & spdif out*/
  7834. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7835. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7836. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7837. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7838. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7839. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7840. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7841. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7842. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7843. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7844. /* Unmute Stereo Mixer 15 */
  7845. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7846. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7847. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7848. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7849. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7850. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7851. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7852. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7853. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7854. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7855. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7856. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7857. /* hp used DAC 3 (Front) */
  7858. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7859. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7860. { }
  7861. };
  7862. static struct hda_verb alc861_threestack_init_verbs[] = {
  7863. /*
  7864. * Unmute ADC0 and set the default input to mic-in
  7865. */
  7866. /* port-A for surround (rear panel) */
  7867. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7868. /* port-B for mic-in (rear panel) with vref */
  7869. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7870. /* port-C for line-in (rear panel) */
  7871. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7872. /* port-D for Front */
  7873. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7874. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7875. /* port-E for HP out (front panel) */
  7876. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7877. /* route front PCM to HP */
  7878. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7879. /* port-F for mic-in (front panel) with vref */
  7880. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7881. /* port-G for CLFE (rear panel) */
  7882. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7883. /* port-H for side (rear panel) */
  7884. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7885. /* CD-in */
  7886. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7887. /* route front mic to ADC1*/
  7888. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7889. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7890. /* Unmute DAC0~3 & spdif out*/
  7891. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7892. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7893. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7894. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7895. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7896. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7897. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7898. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7899. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7900. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7901. /* Unmute Stereo Mixer 15 */
  7902. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7903. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7904. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7905. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7906. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7907. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7908. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7909. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7910. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7911. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7912. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7913. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7914. /* hp used DAC 3 (Front) */
  7915. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7916. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7917. { }
  7918. };
  7919. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  7920. /*
  7921. * Unmute ADC0 and set the default input to mic-in
  7922. */
  7923. /* port-A for surround (rear panel) */
  7924. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7925. /* port-B for mic-in (rear panel) with vref */
  7926. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7927. /* port-C for line-in (rear panel) */
  7928. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7929. /* port-D for Front */
  7930. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7931. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7932. /* port-E for HP out (front panel) */
  7933. /* this has to be set to VREF80 */
  7934. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7935. /* route front PCM to HP */
  7936. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7937. /* port-F for mic-in (front panel) with vref */
  7938. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7939. /* port-G for CLFE (rear panel) */
  7940. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7941. /* port-H for side (rear panel) */
  7942. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7943. /* CD-in */
  7944. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7945. /* route front mic to ADC1*/
  7946. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7947. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7948. /* Unmute DAC0~3 & spdif out*/
  7949. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7950. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7951. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7952. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7953. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7954. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7955. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7956. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7957. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7958. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7959. /* Unmute Stereo Mixer 15 */
  7960. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7961. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7962. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7963. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7964. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7965. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7966. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7967. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7968. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7969. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7970. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7971. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7972. /* hp used DAC 3 (Front) */
  7973. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7974. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7975. { }
  7976. };
  7977. static struct hda_verb alc861_asus_init_verbs[] = {
  7978. /*
  7979. * Unmute ADC0 and set the default input to mic-in
  7980. */
  7981. /* port-A for surround (rear panel)
  7982. * according to codec#0 this is the HP jack
  7983. */
  7984. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  7985. /* route front PCM to HP */
  7986. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  7987. /* port-B for mic-in (rear panel) with vref */
  7988. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7989. /* port-C for line-in (rear panel) */
  7990. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7991. /* port-D for Front */
  7992. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7993. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7994. /* port-E for HP out (front panel) */
  7995. /* this has to be set to VREF80 */
  7996. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7997. /* route front PCM to HP */
  7998. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7999. /* port-F for mic-in (front panel) with vref */
  8000. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8001. /* port-G for CLFE (rear panel) */
  8002. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8003. /* port-H for side (rear panel) */
  8004. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8005. /* CD-in */
  8006. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8007. /* route front mic to ADC1*/
  8008. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8009. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8010. /* Unmute DAC0~3 & spdif out*/
  8011. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8012. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8013. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8014. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8015. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8016. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8017. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8018. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8019. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8020. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8021. /* Unmute Stereo Mixer 15 */
  8022. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8023. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8024. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8025. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8026. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8027. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8028. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8029. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8030. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8031. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8032. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8033. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8034. /* hp used DAC 3 (Front) */
  8035. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8036. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8037. { }
  8038. };
  8039. /* additional init verbs for ASUS laptops */
  8040. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8041. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8042. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8043. { }
  8044. };
  8045. /*
  8046. * generic initialization of ADC, input mixers and output mixers
  8047. */
  8048. static struct hda_verb alc861_auto_init_verbs[] = {
  8049. /*
  8050. * Unmute ADC0 and set the default input to mic-in
  8051. */
  8052. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8053. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8054. /* Unmute DAC0~3 & spdif out*/
  8055. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8056. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8057. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8058. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8059. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8060. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8061. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8062. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8063. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8064. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8065. /* Unmute Stereo Mixer 15 */
  8066. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8067. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8068. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8069. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8070. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8071. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8072. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8073. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8074. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8075. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8076. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8077. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8078. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8079. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8080. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8081. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8082. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8083. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8084. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8085. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8086. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8087. { }
  8088. };
  8089. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8090. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8091. { }
  8092. };
  8093. /* toggle speaker-output according to the hp-jack state */
  8094. static void alc861_toshiba_automute(struct hda_codec *codec)
  8095. {
  8096. unsigned int present;
  8097. present = snd_hda_codec_read(codec, 0x0f, 0,
  8098. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8099. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  8100. 0x80, present ? 0x80 : 0);
  8101. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  8102. 0x80, present ? 0x80 : 0);
  8103. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  8104. 0x80, present ? 0 : 0x80);
  8105. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  8106. 0x80, present ? 0 : 0x80);
  8107. }
  8108. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8109. unsigned int res)
  8110. {
  8111. if ((res >> 26) == ALC880_HP_EVENT)
  8112. alc861_toshiba_automute(codec);
  8113. }
  8114. /* pcm configuration: identiacal with ALC880 */
  8115. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8116. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8117. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8118. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8119. #define ALC861_DIGOUT_NID 0x07
  8120. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8121. { 8, NULL }
  8122. };
  8123. static hda_nid_t alc861_dac_nids[4] = {
  8124. /* front, surround, clfe, side */
  8125. 0x03, 0x06, 0x05, 0x04
  8126. };
  8127. static hda_nid_t alc660_dac_nids[3] = {
  8128. /* front, clfe, surround */
  8129. 0x03, 0x05, 0x06
  8130. };
  8131. static hda_nid_t alc861_adc_nids[1] = {
  8132. /* ADC0-2 */
  8133. 0x08,
  8134. };
  8135. static struct hda_input_mux alc861_capture_source = {
  8136. .num_items = 5,
  8137. .items = {
  8138. { "Mic", 0x0 },
  8139. { "Front Mic", 0x3 },
  8140. { "Line", 0x1 },
  8141. { "CD", 0x4 },
  8142. { "Mixer", 0x5 },
  8143. },
  8144. };
  8145. /* fill in the dac_nids table from the parsed pin configuration */
  8146. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8147. const struct auto_pin_cfg *cfg)
  8148. {
  8149. int i;
  8150. hda_nid_t nid;
  8151. spec->multiout.dac_nids = spec->private_dac_nids;
  8152. for (i = 0; i < cfg->line_outs; i++) {
  8153. nid = cfg->line_out_pins[i];
  8154. if (nid) {
  8155. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8156. continue;
  8157. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8158. }
  8159. }
  8160. spec->multiout.num_dacs = cfg->line_outs;
  8161. return 0;
  8162. }
  8163. /* add playback controls from the parsed DAC table */
  8164. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8165. const struct auto_pin_cfg *cfg)
  8166. {
  8167. char name[32];
  8168. static const char *chname[4] = {
  8169. "Front", "Surround", NULL /*CLFE*/, "Side"
  8170. };
  8171. hda_nid_t nid;
  8172. int i, idx, err;
  8173. for (i = 0; i < cfg->line_outs; i++) {
  8174. nid = spec->multiout.dac_nids[i];
  8175. if (!nid)
  8176. continue;
  8177. if (nid == 0x05) {
  8178. /* Center/LFE */
  8179. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8180. "Center Playback Switch",
  8181. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8182. HDA_OUTPUT));
  8183. if (err < 0)
  8184. return err;
  8185. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8186. "LFE Playback Switch",
  8187. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8188. HDA_OUTPUT));
  8189. if (err < 0)
  8190. return err;
  8191. } else {
  8192. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8193. idx++)
  8194. if (nid == alc861_dac_nids[idx])
  8195. break;
  8196. sprintf(name, "%s Playback Switch", chname[idx]);
  8197. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8198. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8199. HDA_OUTPUT));
  8200. if (err < 0)
  8201. return err;
  8202. }
  8203. }
  8204. return 0;
  8205. }
  8206. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8207. {
  8208. int err;
  8209. hda_nid_t nid;
  8210. if (!pin)
  8211. return 0;
  8212. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8213. nid = 0x03;
  8214. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8215. "Headphone Playback Switch",
  8216. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8217. if (err < 0)
  8218. return err;
  8219. spec->multiout.hp_nid = nid;
  8220. }
  8221. return 0;
  8222. }
  8223. /* create playback/capture controls for input pins */
  8224. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8225. const struct auto_pin_cfg *cfg)
  8226. {
  8227. struct hda_input_mux *imux = &spec->private_imux;
  8228. int i, err, idx, idx1;
  8229. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8230. switch (cfg->input_pins[i]) {
  8231. case 0x0c:
  8232. idx1 = 1;
  8233. idx = 2; /* Line In */
  8234. break;
  8235. case 0x0f:
  8236. idx1 = 2;
  8237. idx = 2; /* Line In */
  8238. break;
  8239. case 0x0d:
  8240. idx1 = 0;
  8241. idx = 1; /* Mic In */
  8242. break;
  8243. case 0x10:
  8244. idx1 = 3;
  8245. idx = 1; /* Mic In */
  8246. break;
  8247. case 0x11:
  8248. idx1 = 4;
  8249. idx = 0; /* CD */
  8250. break;
  8251. default:
  8252. continue;
  8253. }
  8254. err = new_analog_input(spec, cfg->input_pins[i],
  8255. auto_pin_cfg_labels[i], idx, 0x15);
  8256. if (err < 0)
  8257. return err;
  8258. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8259. imux->items[imux->num_items].index = idx1;
  8260. imux->num_items++;
  8261. }
  8262. return 0;
  8263. }
  8264. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8265. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8266. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8267. {
  8268. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8269. /* The multiple "Capture Source" controls confuse alsamixer
  8270. * So call somewhat different..
  8271. *FIXME: the controls appear in the "playback" view!
  8272. */
  8273. /* .name = "Capture Source", */
  8274. .name = "Input Source",
  8275. .count = 1,
  8276. .info = alc_mux_enum_info,
  8277. .get = alc_mux_enum_get,
  8278. .put = alc_mux_enum_put,
  8279. },
  8280. { } /* end */
  8281. };
  8282. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8283. hda_nid_t nid,
  8284. int pin_type, int dac_idx)
  8285. {
  8286. /* set as output */
  8287. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8288. pin_type);
  8289. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8290. AMP_OUT_UNMUTE);
  8291. }
  8292. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8293. {
  8294. struct alc_spec *spec = codec->spec;
  8295. int i;
  8296. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8297. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8298. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8299. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8300. if (nid)
  8301. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8302. spec->multiout.dac_nids[i]);
  8303. }
  8304. }
  8305. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8306. {
  8307. struct alc_spec *spec = codec->spec;
  8308. hda_nid_t pin;
  8309. pin = spec->autocfg.hp_pins[0];
  8310. if (pin) /* connect to front */
  8311. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8312. spec->multiout.dac_nids[0]);
  8313. }
  8314. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8315. {
  8316. struct alc_spec *spec = codec->spec;
  8317. int i;
  8318. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8319. hda_nid_t nid = spec->autocfg.input_pins[i];
  8320. if (nid >= 0x0c && nid <= 0x11) {
  8321. snd_hda_codec_write(codec, nid, 0,
  8322. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8323. i <= AUTO_PIN_FRONT_MIC ?
  8324. PIN_VREF80 : PIN_IN);
  8325. }
  8326. }
  8327. }
  8328. /* parse the BIOS configuration and set up the alc_spec */
  8329. /* return 1 if successful, 0 if the proper config is not found,
  8330. * or a negative error code
  8331. */
  8332. static int alc861_parse_auto_config(struct hda_codec *codec)
  8333. {
  8334. struct alc_spec *spec = codec->spec;
  8335. int err;
  8336. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8337. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8338. alc861_ignore);
  8339. if (err < 0)
  8340. return err;
  8341. if (!spec->autocfg.line_outs)
  8342. return 0; /* can't find valid BIOS pin config */
  8343. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8344. if (err < 0)
  8345. return err;
  8346. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8347. if (err < 0)
  8348. return err;
  8349. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8350. if (err < 0)
  8351. return err;
  8352. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8353. if (err < 0)
  8354. return err;
  8355. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8356. if (spec->autocfg.dig_out_pin)
  8357. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8358. if (spec->kctl_alloc)
  8359. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8360. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8361. spec->num_mux_defs = 1;
  8362. spec->input_mux = &spec->private_imux;
  8363. spec->adc_nids = alc861_adc_nids;
  8364. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8365. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8366. spec->num_mixers++;
  8367. return 1;
  8368. }
  8369. /* additional initialization for auto-configuration model */
  8370. static void alc861_auto_init(struct hda_codec *codec)
  8371. {
  8372. alc861_auto_init_multi_out(codec);
  8373. alc861_auto_init_hp_out(codec);
  8374. alc861_auto_init_analog_input(codec);
  8375. }
  8376. /*
  8377. * configuration and preset
  8378. */
  8379. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8380. [ALC861_3ST] = "3stack",
  8381. [ALC660_3ST] = "3stack-660",
  8382. [ALC861_3ST_DIG] = "3stack-dig",
  8383. [ALC861_6ST_DIG] = "6stack-dig",
  8384. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8385. [ALC861_TOSHIBA] = "toshiba",
  8386. [ALC861_ASUS] = "asus",
  8387. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8388. [ALC861_AUTO] = "auto",
  8389. };
  8390. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8391. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8392. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8393. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8394. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8395. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8396. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8397. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  8398. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8399. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8400. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8401. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8402. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8403. {}
  8404. };
  8405. static struct alc_config_preset alc861_presets[] = {
  8406. [ALC861_3ST] = {
  8407. .mixers = { alc861_3ST_mixer },
  8408. .init_verbs = { alc861_threestack_init_verbs },
  8409. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8410. .dac_nids = alc861_dac_nids,
  8411. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8412. .channel_mode = alc861_threestack_modes,
  8413. .need_dac_fix = 1,
  8414. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8415. .adc_nids = alc861_adc_nids,
  8416. .input_mux = &alc861_capture_source,
  8417. },
  8418. [ALC861_3ST_DIG] = {
  8419. .mixers = { alc861_base_mixer },
  8420. .init_verbs = { alc861_threestack_init_verbs },
  8421. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8422. .dac_nids = alc861_dac_nids,
  8423. .dig_out_nid = ALC861_DIGOUT_NID,
  8424. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8425. .channel_mode = alc861_threestack_modes,
  8426. .need_dac_fix = 1,
  8427. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8428. .adc_nids = alc861_adc_nids,
  8429. .input_mux = &alc861_capture_source,
  8430. },
  8431. [ALC861_6ST_DIG] = {
  8432. .mixers = { alc861_base_mixer },
  8433. .init_verbs = { alc861_base_init_verbs },
  8434. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8435. .dac_nids = alc861_dac_nids,
  8436. .dig_out_nid = ALC861_DIGOUT_NID,
  8437. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8438. .channel_mode = alc861_8ch_modes,
  8439. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8440. .adc_nids = alc861_adc_nids,
  8441. .input_mux = &alc861_capture_source,
  8442. },
  8443. [ALC660_3ST] = {
  8444. .mixers = { alc861_3ST_mixer },
  8445. .init_verbs = { alc861_threestack_init_verbs },
  8446. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8447. .dac_nids = alc660_dac_nids,
  8448. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8449. .channel_mode = alc861_threestack_modes,
  8450. .need_dac_fix = 1,
  8451. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8452. .adc_nids = alc861_adc_nids,
  8453. .input_mux = &alc861_capture_source,
  8454. },
  8455. [ALC861_UNIWILL_M31] = {
  8456. .mixers = { alc861_uniwill_m31_mixer },
  8457. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8458. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8459. .dac_nids = alc861_dac_nids,
  8460. .dig_out_nid = ALC861_DIGOUT_NID,
  8461. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8462. .channel_mode = alc861_uniwill_m31_modes,
  8463. .need_dac_fix = 1,
  8464. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8465. .adc_nids = alc861_adc_nids,
  8466. .input_mux = &alc861_capture_source,
  8467. },
  8468. [ALC861_TOSHIBA] = {
  8469. .mixers = { alc861_toshiba_mixer },
  8470. .init_verbs = { alc861_base_init_verbs,
  8471. alc861_toshiba_init_verbs },
  8472. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8473. .dac_nids = alc861_dac_nids,
  8474. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8475. .channel_mode = alc883_3ST_2ch_modes,
  8476. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8477. .adc_nids = alc861_adc_nids,
  8478. .input_mux = &alc861_capture_source,
  8479. .unsol_event = alc861_toshiba_unsol_event,
  8480. .init_hook = alc861_toshiba_automute,
  8481. },
  8482. [ALC861_ASUS] = {
  8483. .mixers = { alc861_asus_mixer },
  8484. .init_verbs = { alc861_asus_init_verbs },
  8485. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8486. .dac_nids = alc861_dac_nids,
  8487. .dig_out_nid = ALC861_DIGOUT_NID,
  8488. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8489. .channel_mode = alc861_asus_modes,
  8490. .need_dac_fix = 1,
  8491. .hp_nid = 0x06,
  8492. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8493. .adc_nids = alc861_adc_nids,
  8494. .input_mux = &alc861_capture_source,
  8495. },
  8496. [ALC861_ASUS_LAPTOP] = {
  8497. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8498. .init_verbs = { alc861_asus_init_verbs,
  8499. alc861_asus_laptop_init_verbs },
  8500. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8501. .dac_nids = alc861_dac_nids,
  8502. .dig_out_nid = ALC861_DIGOUT_NID,
  8503. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8504. .channel_mode = alc883_3ST_2ch_modes,
  8505. .need_dac_fix = 1,
  8506. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8507. .adc_nids = alc861_adc_nids,
  8508. .input_mux = &alc861_capture_source,
  8509. },
  8510. };
  8511. static int patch_alc861(struct hda_codec *codec)
  8512. {
  8513. struct alc_spec *spec;
  8514. int board_config;
  8515. int err;
  8516. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8517. if (spec == NULL)
  8518. return -ENOMEM;
  8519. codec->spec = spec;
  8520. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8521. alc861_models,
  8522. alc861_cfg_tbl);
  8523. if (board_config < 0) {
  8524. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8525. "trying auto-probe from BIOS...\n");
  8526. board_config = ALC861_AUTO;
  8527. }
  8528. if (board_config == ALC861_AUTO) {
  8529. /* automatic parse from the BIOS config */
  8530. err = alc861_parse_auto_config(codec);
  8531. if (err < 0) {
  8532. alc_free(codec);
  8533. return err;
  8534. } else if (!err) {
  8535. printk(KERN_INFO
  8536. "hda_codec: Cannot set up configuration "
  8537. "from BIOS. Using base mode...\n");
  8538. board_config = ALC861_3ST_DIG;
  8539. }
  8540. }
  8541. if (board_config != ALC861_AUTO)
  8542. setup_preset(spec, &alc861_presets[board_config]);
  8543. spec->stream_name_analog = "ALC861 Analog";
  8544. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8545. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8546. spec->stream_name_digital = "ALC861 Digital";
  8547. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8548. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8549. codec->patch_ops = alc_patch_ops;
  8550. if (board_config == ALC861_AUTO)
  8551. spec->init_hook = alc861_auto_init;
  8552. return 0;
  8553. }
  8554. /*
  8555. * ALC861-VD support
  8556. *
  8557. * Based on ALC882
  8558. *
  8559. * In addition, an independent DAC
  8560. */
  8561. #define ALC861VD_DIGOUT_NID 0x06
  8562. static hda_nid_t alc861vd_dac_nids[4] = {
  8563. /* front, surr, clfe, side surr */
  8564. 0x02, 0x03, 0x04, 0x05
  8565. };
  8566. /* dac_nids for ALC660vd are in a different order - according to
  8567. * Realtek's driver.
  8568. * This should probably tesult in a different mixer for 6stack models
  8569. * of ALC660vd codecs, but for now there is only 3stack mixer
  8570. * - and it is the same as in 861vd.
  8571. * adc_nids in ALC660vd are (is) the same as in 861vd
  8572. */
  8573. static hda_nid_t alc660vd_dac_nids[3] = {
  8574. /* front, rear, clfe, rear_surr */
  8575. 0x02, 0x04, 0x03
  8576. };
  8577. static hda_nid_t alc861vd_adc_nids[1] = {
  8578. /* ADC0 */
  8579. 0x09,
  8580. };
  8581. /* input MUX */
  8582. /* FIXME: should be a matrix-type input source selection */
  8583. static struct hda_input_mux alc861vd_capture_source = {
  8584. .num_items = 4,
  8585. .items = {
  8586. { "Mic", 0x0 },
  8587. { "Front Mic", 0x1 },
  8588. { "Line", 0x2 },
  8589. { "CD", 0x4 },
  8590. },
  8591. };
  8592. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8593. .num_items = 3,
  8594. .items = {
  8595. { "Front Mic", 0x0 },
  8596. { "ATAPI Mic", 0x1 },
  8597. { "Line In", 0x5 },
  8598. },
  8599. };
  8600. #define alc861vd_mux_enum_info alc_mux_enum_info
  8601. #define alc861vd_mux_enum_get alc_mux_enum_get
  8602. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8603. struct snd_ctl_elem_value *ucontrol)
  8604. {
  8605. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8606. struct alc_spec *spec = codec->spec;
  8607. const struct hda_input_mux *imux = spec->input_mux;
  8608. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8609. static hda_nid_t capture_mixers[1] = { 0x22 };
  8610. hda_nid_t nid = capture_mixers[adc_idx];
  8611. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8612. unsigned int i, idx;
  8613. idx = ucontrol->value.enumerated.item[0];
  8614. if (idx >= imux->num_items)
  8615. idx = imux->num_items - 1;
  8616. if (*cur_val == idx && !codec->in_resume)
  8617. return 0;
  8618. for (i = 0; i < imux->num_items; i++) {
  8619. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8620. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8621. v | (imux->items[i].index << 8));
  8622. }
  8623. *cur_val = idx;
  8624. return 1;
  8625. }
  8626. /*
  8627. * 2ch mode
  8628. */
  8629. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8630. { 2, NULL }
  8631. };
  8632. /*
  8633. * 6ch mode
  8634. */
  8635. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8636. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8637. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8638. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8639. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8640. { } /* end */
  8641. };
  8642. /*
  8643. * 8ch mode
  8644. */
  8645. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8646. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8647. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8648. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8649. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8650. { } /* end */
  8651. };
  8652. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8653. { 6, alc861vd_6stack_ch6_init },
  8654. { 8, alc861vd_6stack_ch8_init },
  8655. };
  8656. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8657. {
  8658. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8659. .name = "Channel Mode",
  8660. .info = alc_ch_mode_info,
  8661. .get = alc_ch_mode_get,
  8662. .put = alc_ch_mode_put,
  8663. },
  8664. { } /* end */
  8665. };
  8666. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8667. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8668. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8669. {
  8670. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8671. /* The multiple "Capture Source" controls confuse alsamixer
  8672. * So call somewhat different..
  8673. *FIXME: the controls appear in the "playback" view!
  8674. */
  8675. /* .name = "Capture Source", */
  8676. .name = "Input Source",
  8677. .count = 1,
  8678. .info = alc861vd_mux_enum_info,
  8679. .get = alc861vd_mux_enum_get,
  8680. .put = alc861vd_mux_enum_put,
  8681. },
  8682. { } /* end */
  8683. };
  8684. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8685. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8686. */
  8687. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  8688. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8689. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8690. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8691. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  8692. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  8693. HDA_OUTPUT),
  8694. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  8695. HDA_OUTPUT),
  8696. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  8697. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  8698. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  8699. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  8700. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8701. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8702. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8703. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8704. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8705. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8706. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8707. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8708. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8709. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8710. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8711. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8712. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8713. { } /* end */
  8714. };
  8715. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  8716. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8717. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8718. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8719. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8720. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8721. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8722. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8723. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8724. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8725. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8726. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8727. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8728. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8729. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8730. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8731. { } /* end */
  8732. };
  8733. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  8734. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8735. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  8736. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8737. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8738. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8739. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8740. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8741. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8742. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8743. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8744. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8745. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8746. { } /* end */
  8747. };
  8748. /* Pin assignment: Front=0x14, HP = 0x15,
  8749. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  8750. */
  8751. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  8752. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8753. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8754. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8755. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  8756. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8757. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8758. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8759. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8760. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8761. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8762. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8763. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8764. {
  8765. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8766. /* .name = "Capture Source", */
  8767. .name = "Input Source",
  8768. .count = 1,
  8769. .info = alc882_mux_enum_info,
  8770. .get = alc882_mux_enum_get,
  8771. .put = alc882_mux_enum_put,
  8772. },
  8773. { } /* end */
  8774. };
  8775. /*
  8776. * generic initialization of ADC, input mixers and output mixers
  8777. */
  8778. static struct hda_verb alc861vd_volume_init_verbs[] = {
  8779. /*
  8780. * Unmute ADC0 and set the default input to mic-in
  8781. */
  8782. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8783. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8784. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  8785. * the analog-loopback mixer widget
  8786. */
  8787. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  8788. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8789. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8790. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8791. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8792. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8793. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  8794. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8795. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8796. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8797. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8798. /*
  8799. * Set up output mixers (0x02 - 0x05)
  8800. */
  8801. /* set vol=0 to output mixers */
  8802. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8803. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8804. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8805. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8806. /* set up input amps for analog loopback */
  8807. /* Amp Indices: DAC = 0, mixer = 1 */
  8808. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8809. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8810. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8811. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8812. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8813. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8814. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8815. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8816. { }
  8817. };
  8818. /*
  8819. * 3-stack pin configuration:
  8820. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  8821. */
  8822. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  8823. /*
  8824. * Set pin mode and muting
  8825. */
  8826. /* set front pin widgets 0x14 for output */
  8827. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8828. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8829. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8830. /* Mic (rear) pin: input vref at 80% */
  8831. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8832. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8833. /* Front Mic pin: input vref at 80% */
  8834. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8835. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8836. /* Line In pin: input */
  8837. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8838. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8839. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8840. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8841. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8842. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8843. /* CD pin widget for input */
  8844. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8845. { }
  8846. };
  8847. /*
  8848. * 6-stack pin configuration:
  8849. */
  8850. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  8851. /*
  8852. * Set pin mode and muting
  8853. */
  8854. /* set front pin widgets 0x14 for output */
  8855. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8856. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8857. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8858. /* Rear Pin: output 1 (0x0d) */
  8859. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8860. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8861. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  8862. /* CLFE Pin: output 2 (0x0e) */
  8863. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8864. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8865. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  8866. /* Side Pin: output 3 (0x0f) */
  8867. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8868. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8869. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  8870. /* Mic (rear) pin: input vref at 80% */
  8871. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8872. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8873. /* Front Mic pin: input vref at 80% */
  8874. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8875. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8876. /* Line In pin: input */
  8877. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8878. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8879. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8880. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8881. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8882. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8883. /* CD pin widget for input */
  8884. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8885. { }
  8886. };
  8887. static struct hda_verb alc861vd_eapd_verbs[] = {
  8888. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8889. { }
  8890. };
  8891. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  8892. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8893. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8894. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  8895. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8896. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  8897. {}
  8898. };
  8899. /* toggle speaker-output according to the hp-jack state */
  8900. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  8901. {
  8902. unsigned int present;
  8903. unsigned char bits;
  8904. present = snd_hda_codec_read(codec, 0x1b, 0,
  8905. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8906. bits = present ? 0x80 : 0;
  8907. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8908. 0x80, bits);
  8909. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8910. 0x80, bits);
  8911. }
  8912. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  8913. {
  8914. unsigned int present;
  8915. unsigned char bits;
  8916. present = snd_hda_codec_read(codec, 0x18, 0,
  8917. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8918. bits = present ? 0x80 : 0;
  8919. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  8920. 0x80, bits);
  8921. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  8922. 0x80, bits);
  8923. }
  8924. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  8925. {
  8926. alc861vd_lenovo_hp_automute(codec);
  8927. alc861vd_lenovo_mic_automute(codec);
  8928. }
  8929. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  8930. unsigned int res)
  8931. {
  8932. switch (res >> 26) {
  8933. case ALC880_HP_EVENT:
  8934. alc861vd_lenovo_hp_automute(codec);
  8935. break;
  8936. case ALC880_MIC_EVENT:
  8937. alc861vd_lenovo_mic_automute(codec);
  8938. break;
  8939. }
  8940. }
  8941. static struct hda_verb alc861vd_dallas_verbs[] = {
  8942. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8943. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8944. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8945. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8946. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8947. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8948. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8949. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8950. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8951. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8952. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8953. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8954. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8955. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8956. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8957. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8958. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8959. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8960. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8961. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8962. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8963. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8964. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8965. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8966. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8967. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8968. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8969. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8970. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8971. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  8972. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  8973. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  8974. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8975. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8976. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8977. { } /* end */
  8978. };
  8979. /* toggle speaker-output according to the hp-jack state */
  8980. static void alc861vd_dallas_automute(struct hda_codec *codec)
  8981. {
  8982. unsigned int present;
  8983. present = snd_hda_codec_read(codec, 0x15, 0,
  8984. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8985. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8986. 0x80, present ? 0x80 : 0);
  8987. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8988. 0x80, present ? 0x80 : 0);
  8989. }
  8990. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  8991. {
  8992. if ((res >> 26) == ALC880_HP_EVENT)
  8993. alc861vd_dallas_automute(codec);
  8994. }
  8995. /* pcm configuration: identiacal with ALC880 */
  8996. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  8997. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  8998. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  8999. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9000. /*
  9001. * configuration and preset
  9002. */
  9003. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9004. [ALC660VD_3ST] = "3stack-660",
  9005. [ALC861VD_3ST] = "3stack",
  9006. [ALC861VD_3ST_DIG] = "3stack-digout",
  9007. [ALC861VD_6ST_DIG] = "6stack-digout",
  9008. [ALC861VD_LENOVO] = "lenovo",
  9009. [ALC861VD_DALLAS] = "dallas",
  9010. [ALC861VD_AUTO] = "auto",
  9011. };
  9012. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9013. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9014. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9015. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST),
  9016. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9017. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9018. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9019. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9020. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9021. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9022. {}
  9023. };
  9024. static struct alc_config_preset alc861vd_presets[] = {
  9025. [ALC660VD_3ST] = {
  9026. .mixers = { alc861vd_3st_mixer },
  9027. .init_verbs = { alc861vd_volume_init_verbs,
  9028. alc861vd_3stack_init_verbs },
  9029. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9030. .dac_nids = alc660vd_dac_nids,
  9031. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9032. .adc_nids = alc861vd_adc_nids,
  9033. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9034. .channel_mode = alc861vd_3stack_2ch_modes,
  9035. .input_mux = &alc861vd_capture_source,
  9036. },
  9037. [ALC861VD_3ST] = {
  9038. .mixers = { alc861vd_3st_mixer },
  9039. .init_verbs = { alc861vd_volume_init_verbs,
  9040. alc861vd_3stack_init_verbs },
  9041. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9042. .dac_nids = alc861vd_dac_nids,
  9043. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9044. .channel_mode = alc861vd_3stack_2ch_modes,
  9045. .input_mux = &alc861vd_capture_source,
  9046. },
  9047. [ALC861VD_3ST_DIG] = {
  9048. .mixers = { alc861vd_3st_mixer },
  9049. .init_verbs = { alc861vd_volume_init_verbs,
  9050. alc861vd_3stack_init_verbs },
  9051. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9052. .dac_nids = alc861vd_dac_nids,
  9053. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9054. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9055. .channel_mode = alc861vd_3stack_2ch_modes,
  9056. .input_mux = &alc861vd_capture_source,
  9057. },
  9058. [ALC861VD_6ST_DIG] = {
  9059. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9060. .init_verbs = { alc861vd_volume_init_verbs,
  9061. alc861vd_6stack_init_verbs },
  9062. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9063. .dac_nids = alc861vd_dac_nids,
  9064. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9065. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9066. .channel_mode = alc861vd_6stack_modes,
  9067. .input_mux = &alc861vd_capture_source,
  9068. },
  9069. [ALC861VD_LENOVO] = {
  9070. .mixers = { alc861vd_lenovo_mixer },
  9071. .init_verbs = { alc861vd_volume_init_verbs,
  9072. alc861vd_3stack_init_verbs,
  9073. alc861vd_eapd_verbs,
  9074. alc861vd_lenovo_unsol_verbs },
  9075. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9076. .dac_nids = alc660vd_dac_nids,
  9077. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9078. .adc_nids = alc861vd_adc_nids,
  9079. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9080. .channel_mode = alc861vd_3stack_2ch_modes,
  9081. .input_mux = &alc861vd_capture_source,
  9082. .unsol_event = alc861vd_lenovo_unsol_event,
  9083. .init_hook = alc861vd_lenovo_automute,
  9084. },
  9085. [ALC861VD_DALLAS] = {
  9086. .mixers = { alc861vd_dallas_mixer },
  9087. .init_verbs = { alc861vd_dallas_verbs },
  9088. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9089. .dac_nids = alc861vd_dac_nids,
  9090. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9091. .adc_nids = alc861vd_adc_nids,
  9092. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9093. .channel_mode = alc861vd_3stack_2ch_modes,
  9094. .input_mux = &alc861vd_dallas_capture_source,
  9095. .unsol_event = alc861vd_dallas_unsol_event,
  9096. .init_hook = alc861vd_dallas_automute,
  9097. },
  9098. };
  9099. /*
  9100. * BIOS auto configuration
  9101. */
  9102. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9103. hda_nid_t nid, int pin_type, int dac_idx)
  9104. {
  9105. /* set as output */
  9106. snd_hda_codec_write(codec, nid, 0,
  9107. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9108. snd_hda_codec_write(codec, nid, 0,
  9109. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9110. }
  9111. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9112. {
  9113. struct alc_spec *spec = codec->spec;
  9114. int i;
  9115. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9116. for (i = 0; i <= HDA_SIDE; i++) {
  9117. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9118. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9119. if (nid)
  9120. alc861vd_auto_set_output_and_unmute(codec, nid,
  9121. pin_type, i);
  9122. }
  9123. }
  9124. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9125. {
  9126. struct alc_spec *spec = codec->spec;
  9127. hda_nid_t pin;
  9128. pin = spec->autocfg.hp_pins[0];
  9129. if (pin) /* connect to front and use dac 0 */
  9130. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9131. }
  9132. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9133. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9134. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9135. {
  9136. struct alc_spec *spec = codec->spec;
  9137. int i;
  9138. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9139. hda_nid_t nid = spec->autocfg.input_pins[i];
  9140. if (alc861vd_is_input_pin(nid)) {
  9141. snd_hda_codec_write(codec, nid, 0,
  9142. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9143. i <= AUTO_PIN_FRONT_MIC ?
  9144. PIN_VREF80 : PIN_IN);
  9145. if (nid != ALC861VD_PIN_CD_NID)
  9146. snd_hda_codec_write(codec, nid, 0,
  9147. AC_VERB_SET_AMP_GAIN_MUTE,
  9148. AMP_OUT_MUTE);
  9149. }
  9150. }
  9151. }
  9152. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9153. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9154. /* add playback controls from the parsed DAC table */
  9155. /* Based on ALC880 version. But ALC861VD has separate,
  9156. * different NIDs for mute/unmute switch and volume control */
  9157. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9158. const struct auto_pin_cfg *cfg)
  9159. {
  9160. char name[32];
  9161. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9162. hda_nid_t nid_v, nid_s;
  9163. int i, err;
  9164. for (i = 0; i < cfg->line_outs; i++) {
  9165. if (!spec->multiout.dac_nids[i])
  9166. continue;
  9167. nid_v = alc861vd_idx_to_mixer_vol(
  9168. alc880_dac_to_idx(
  9169. spec->multiout.dac_nids[i]));
  9170. nid_s = alc861vd_idx_to_mixer_switch(
  9171. alc880_dac_to_idx(
  9172. spec->multiout.dac_nids[i]));
  9173. if (i == 2) {
  9174. /* Center/LFE */
  9175. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9176. "Center Playback Volume",
  9177. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9178. HDA_OUTPUT));
  9179. if (err < 0)
  9180. return err;
  9181. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9182. "LFE Playback Volume",
  9183. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9184. HDA_OUTPUT));
  9185. if (err < 0)
  9186. return err;
  9187. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9188. "Center Playback Switch",
  9189. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9190. HDA_INPUT));
  9191. if (err < 0)
  9192. return err;
  9193. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9194. "LFE Playback Switch",
  9195. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9196. HDA_INPUT));
  9197. if (err < 0)
  9198. return err;
  9199. } else {
  9200. sprintf(name, "%s Playback Volume", chname[i]);
  9201. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9202. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9203. HDA_OUTPUT));
  9204. if (err < 0)
  9205. return err;
  9206. sprintf(name, "%s Playback Switch", chname[i]);
  9207. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9208. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9209. HDA_INPUT));
  9210. if (err < 0)
  9211. return err;
  9212. }
  9213. }
  9214. return 0;
  9215. }
  9216. /* add playback controls for speaker and HP outputs */
  9217. /* Based on ALC880 version. But ALC861VD has separate,
  9218. * different NIDs for mute/unmute switch and volume control */
  9219. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9220. hda_nid_t pin, const char *pfx)
  9221. {
  9222. hda_nid_t nid_v, nid_s;
  9223. int err;
  9224. char name[32];
  9225. if (!pin)
  9226. return 0;
  9227. if (alc880_is_fixed_pin(pin)) {
  9228. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9229. /* specify the DAC as the extra output */
  9230. if (!spec->multiout.hp_nid)
  9231. spec->multiout.hp_nid = nid_v;
  9232. else
  9233. spec->multiout.extra_out_nid[0] = nid_v;
  9234. /* control HP volume/switch on the output mixer amp */
  9235. nid_v = alc861vd_idx_to_mixer_vol(
  9236. alc880_fixed_pin_idx(pin));
  9237. nid_s = alc861vd_idx_to_mixer_switch(
  9238. alc880_fixed_pin_idx(pin));
  9239. sprintf(name, "%s Playback Volume", pfx);
  9240. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9241. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9242. if (err < 0)
  9243. return err;
  9244. sprintf(name, "%s Playback Switch", pfx);
  9245. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9246. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9247. if (err < 0)
  9248. return err;
  9249. } else if (alc880_is_multi_pin(pin)) {
  9250. /* set manual connection */
  9251. /* we have only a switch on HP-out PIN */
  9252. sprintf(name, "%s Playback Switch", pfx);
  9253. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9254. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9255. if (err < 0)
  9256. return err;
  9257. }
  9258. return 0;
  9259. }
  9260. /* parse the BIOS configuration and set up the alc_spec
  9261. * return 1 if successful, 0 if the proper config is not found,
  9262. * or a negative error code
  9263. * Based on ALC880 version - had to change it to override
  9264. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9265. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9266. {
  9267. struct alc_spec *spec = codec->spec;
  9268. int err;
  9269. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9270. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9271. alc861vd_ignore);
  9272. if (err < 0)
  9273. return err;
  9274. if (!spec->autocfg.line_outs)
  9275. return 0; /* can't find valid BIOS pin config */
  9276. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9277. if (err < 0)
  9278. return err;
  9279. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9280. if (err < 0)
  9281. return err;
  9282. err = alc861vd_auto_create_extra_out(spec,
  9283. spec->autocfg.speaker_pins[0],
  9284. "Speaker");
  9285. if (err < 0)
  9286. return err;
  9287. err = alc861vd_auto_create_extra_out(spec,
  9288. spec->autocfg.hp_pins[0],
  9289. "Headphone");
  9290. if (err < 0)
  9291. return err;
  9292. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9293. if (err < 0)
  9294. return err;
  9295. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9296. if (spec->autocfg.dig_out_pin)
  9297. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9298. if (spec->kctl_alloc)
  9299. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9300. spec->init_verbs[spec->num_init_verbs++]
  9301. = alc861vd_volume_init_verbs;
  9302. spec->num_mux_defs = 1;
  9303. spec->input_mux = &spec->private_imux;
  9304. return 1;
  9305. }
  9306. /* additional initialization for auto-configuration model */
  9307. static void alc861vd_auto_init(struct hda_codec *codec)
  9308. {
  9309. alc861vd_auto_init_multi_out(codec);
  9310. alc861vd_auto_init_hp_out(codec);
  9311. alc861vd_auto_init_analog_input(codec);
  9312. }
  9313. static int patch_alc861vd(struct hda_codec *codec)
  9314. {
  9315. struct alc_spec *spec;
  9316. int err, board_config;
  9317. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9318. if (spec == NULL)
  9319. return -ENOMEM;
  9320. codec->spec = spec;
  9321. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9322. alc861vd_models,
  9323. alc861vd_cfg_tbl);
  9324. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9325. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9326. "ALC861VD, trying auto-probe from BIOS...\n");
  9327. board_config = ALC861VD_AUTO;
  9328. }
  9329. if (board_config == ALC861VD_AUTO) {
  9330. /* automatic parse from the BIOS config */
  9331. err = alc861vd_parse_auto_config(codec);
  9332. if (err < 0) {
  9333. alc_free(codec);
  9334. return err;
  9335. } else if (!err) {
  9336. printk(KERN_INFO
  9337. "hda_codec: Cannot set up configuration "
  9338. "from BIOS. Using base mode...\n");
  9339. board_config = ALC861VD_3ST;
  9340. }
  9341. }
  9342. if (board_config != ALC861VD_AUTO)
  9343. setup_preset(spec, &alc861vd_presets[board_config]);
  9344. spec->stream_name_analog = "ALC861VD Analog";
  9345. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9346. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9347. spec->stream_name_digital = "ALC861VD Digital";
  9348. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9349. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9350. spec->adc_nids = alc861vd_adc_nids;
  9351. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9352. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9353. spec->num_mixers++;
  9354. codec->patch_ops = alc_patch_ops;
  9355. if (board_config == ALC861VD_AUTO)
  9356. spec->init_hook = alc861vd_auto_init;
  9357. return 0;
  9358. }
  9359. /*
  9360. * ALC662 support
  9361. *
  9362. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9363. * configuration. Each pin widget can choose any input DACs and a mixer.
  9364. * Each ADC is connected from a mixer of all inputs. This makes possible
  9365. * 6-channel independent captures.
  9366. *
  9367. * In addition, an independent DAC for the multi-playback (not used in this
  9368. * driver yet).
  9369. */
  9370. #define ALC662_DIGOUT_NID 0x06
  9371. #define ALC662_DIGIN_NID 0x0a
  9372. static hda_nid_t alc662_dac_nids[4] = {
  9373. /* front, rear, clfe, rear_surr */
  9374. 0x02, 0x03, 0x04
  9375. };
  9376. static hda_nid_t alc662_adc_nids[1] = {
  9377. /* ADC1-2 */
  9378. 0x09,
  9379. };
  9380. /* input MUX */
  9381. /* FIXME: should be a matrix-type input source selection */
  9382. static struct hda_input_mux alc662_capture_source = {
  9383. .num_items = 4,
  9384. .items = {
  9385. { "Mic", 0x0 },
  9386. { "Front Mic", 0x1 },
  9387. { "Line", 0x2 },
  9388. { "CD", 0x4 },
  9389. },
  9390. };
  9391. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9392. .num_items = 2,
  9393. .items = {
  9394. { "Mic", 0x1 },
  9395. { "Line", 0x2 },
  9396. },
  9397. };
  9398. #define alc662_mux_enum_info alc_mux_enum_info
  9399. #define alc662_mux_enum_get alc_mux_enum_get
  9400. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9401. struct snd_ctl_elem_value *ucontrol)
  9402. {
  9403. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9404. struct alc_spec *spec = codec->spec;
  9405. const struct hda_input_mux *imux = spec->input_mux;
  9406. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9407. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9408. hda_nid_t nid = capture_mixers[adc_idx];
  9409. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9410. unsigned int i, idx;
  9411. idx = ucontrol->value.enumerated.item[0];
  9412. if (idx >= imux->num_items)
  9413. idx = imux->num_items - 1;
  9414. if (*cur_val == idx && !codec->in_resume)
  9415. return 0;
  9416. for (i = 0; i < imux->num_items; i++) {
  9417. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  9418. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9419. v | (imux->items[i].index << 8));
  9420. }
  9421. *cur_val = idx;
  9422. return 1;
  9423. }
  9424. /*
  9425. * 2ch mode
  9426. */
  9427. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9428. { 2, NULL }
  9429. };
  9430. /*
  9431. * 2ch mode
  9432. */
  9433. static struct hda_verb alc662_3ST_ch2_init[] = {
  9434. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9435. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9436. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9437. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9438. { } /* end */
  9439. };
  9440. /*
  9441. * 6ch mode
  9442. */
  9443. static struct hda_verb alc662_3ST_ch6_init[] = {
  9444. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9445. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9446. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9447. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9448. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9449. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9450. { } /* end */
  9451. };
  9452. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9453. { 2, alc662_3ST_ch2_init },
  9454. { 6, alc662_3ST_ch6_init },
  9455. };
  9456. /*
  9457. * 2ch mode
  9458. */
  9459. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9460. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9461. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9462. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9463. { } /* end */
  9464. };
  9465. /*
  9466. * 6ch mode
  9467. */
  9468. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9469. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9470. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9471. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9472. { } /* end */
  9473. };
  9474. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9475. { 2, alc662_sixstack_ch6_init },
  9476. { 6, alc662_sixstack_ch8_init },
  9477. };
  9478. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9479. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9480. */
  9481. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9482. /* output mixer control */
  9483. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9484. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9485. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9486. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9487. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9488. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9489. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9490. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9491. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9492. /*Input mixer control */
  9493. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9494. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9495. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9496. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9497. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9498. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9499. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9500. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9501. /* Capture mixer control */
  9502. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9503. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9504. {
  9505. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9506. .name = "Capture Source",
  9507. .count = 1,
  9508. .info = alc_mux_enum_info,
  9509. .get = alc_mux_enum_get,
  9510. .put = alc_mux_enum_put,
  9511. },
  9512. { } /* end */
  9513. };
  9514. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9515. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9516. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9517. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9518. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9519. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9520. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9521. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9522. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9523. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9524. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9525. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9526. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9527. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9528. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9529. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9530. {
  9531. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9532. /* .name = "Capture Source", */
  9533. .name = "Input Source",
  9534. .count = 1,
  9535. .info = alc662_mux_enum_info,
  9536. .get = alc662_mux_enum_get,
  9537. .put = alc662_mux_enum_put,
  9538. },
  9539. { } /* end */
  9540. };
  9541. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9542. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9543. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9544. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9545. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9546. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9547. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9548. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9549. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9550. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9551. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9552. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9553. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9554. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9555. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9556. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9557. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9558. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9559. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9560. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9561. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9562. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9563. {
  9564. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9565. /* .name = "Capture Source", */
  9566. .name = "Input Source",
  9567. .count = 1,
  9568. .info = alc662_mux_enum_info,
  9569. .get = alc662_mux_enum_get,
  9570. .put = alc662_mux_enum_put,
  9571. },
  9572. { } /* end */
  9573. };
  9574. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9575. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9576. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9577. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9578. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9579. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9580. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9581. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9582. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9583. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9584. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9585. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9586. {
  9587. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9588. /* .name = "Capture Source", */
  9589. .name = "Input Source",
  9590. .count = 1,
  9591. .info = alc662_mux_enum_info,
  9592. .get = alc662_mux_enum_get,
  9593. .put = alc662_mux_enum_put,
  9594. },
  9595. { } /* end */
  9596. };
  9597. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9598. {
  9599. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9600. .name = "Channel Mode",
  9601. .info = alc_ch_mode_info,
  9602. .get = alc_ch_mode_get,
  9603. .put = alc_ch_mode_put,
  9604. },
  9605. { } /* end */
  9606. };
  9607. static struct hda_verb alc662_init_verbs[] = {
  9608. /* ADC: mute amp left and right */
  9609. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9610. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9611. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9612. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9613. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9614. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9615. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9616. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9617. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9618. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9619. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9620. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9621. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9622. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9623. /* Front Pin: output 0 (0x0c) */
  9624. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9625. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9626. /* Rear Pin: output 1 (0x0d) */
  9627. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9628. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9629. /* CLFE Pin: output 2 (0x0e) */
  9630. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9631. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9632. /* Mic (rear) pin: input vref at 80% */
  9633. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9634. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9635. /* Front Mic pin: input vref at 80% */
  9636. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9637. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9638. /* Line In pin: input */
  9639. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9640. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9641. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9642. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9643. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9644. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9645. /* CD pin widget for input */
  9646. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9647. /* FIXME: use matrix-type input source selection */
  9648. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9649. /* Input mixer */
  9650. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9651. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9652. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9653. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9654. { }
  9655. };
  9656. static struct hda_verb alc662_sue_init_verbs[] = {
  9657. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9658. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9659. {}
  9660. };
  9661. /*
  9662. * generic initialization of ADC, input mixers and output mixers
  9663. */
  9664. static struct hda_verb alc662_auto_init_verbs[] = {
  9665. /*
  9666. * Unmute ADC and set the default input to mic-in
  9667. */
  9668. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9669. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9670. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  9671. * mixer widget
  9672. * Note: PASD motherboards uses the Line In 2 as the input for front
  9673. * panel mic (mic 2)
  9674. */
  9675. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9676. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9677. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9678. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9679. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9680. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9681. /*
  9682. * Set up output mixers (0x0c - 0x0f)
  9683. */
  9684. /* set vol=0 to output mixers */
  9685. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9686. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9687. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9688. /* set up input amps for analog loopback */
  9689. /* Amp Indices: DAC = 0, mixer = 1 */
  9690. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9691. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9692. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9693. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9694. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9695. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9696. /* FIXME: use matrix-type input source selection */
  9697. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9698. /* Input mixer */
  9699. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9700. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9701. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9702. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  9703. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9704. { }
  9705. };
  9706. /* capture mixer elements */
  9707. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  9708. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9709. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9710. {
  9711. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9712. /* The multiple "Capture Source" controls confuse alsamixer
  9713. * So call somewhat different..
  9714. * FIXME: the controls appear in the "playback" view!
  9715. */
  9716. /* .name = "Capture Source", */
  9717. .name = "Input Source",
  9718. .count = 1,
  9719. .info = alc882_mux_enum_info,
  9720. .get = alc882_mux_enum_get,
  9721. .put = alc882_mux_enum_put,
  9722. },
  9723. { } /* end */
  9724. };
  9725. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  9726. {
  9727. unsigned int present;
  9728. unsigned char bits;
  9729. present = snd_hda_codec_read(codec, 0x14, 0,
  9730. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9731. bits = present ? 0x80 : 0;
  9732. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9733. 0x80, bits);
  9734. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9735. 0x80, bits);
  9736. }
  9737. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  9738. {
  9739. unsigned int present;
  9740. unsigned char bits;
  9741. present = snd_hda_codec_read(codec, 0x1b, 0,
  9742. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9743. bits = present ? 0x80 : 0;
  9744. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9745. 0x80, bits);
  9746. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9747. 0x80, bits);
  9748. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9749. 0x80, bits);
  9750. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9751. 0x80, bits);
  9752. }
  9753. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  9754. unsigned int res)
  9755. {
  9756. if ((res >> 26) == ALC880_HP_EVENT)
  9757. alc662_lenovo_101e_all_automute(codec);
  9758. if ((res >> 26) == ALC880_FRONT_EVENT)
  9759. alc662_lenovo_101e_ispeaker_automute(codec);
  9760. }
  9761. /* pcm configuration: identiacal with ALC880 */
  9762. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  9763. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  9764. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  9765. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  9766. /*
  9767. * configuration and preset
  9768. */
  9769. static const char *alc662_models[ALC662_MODEL_LAST] = {
  9770. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  9771. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  9772. [ALC662_3ST_6ch] = "3stack-6ch",
  9773. [ALC662_5ST_DIG] = "6stack-dig",
  9774. [ALC662_LENOVO_101E] = "lenovo-101e",
  9775. [ALC662_AUTO] = "auto",
  9776. };
  9777. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  9778. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  9779. {}
  9780. };
  9781. static struct alc_config_preset alc662_presets[] = {
  9782. [ALC662_3ST_2ch_DIG] = {
  9783. .mixers = { alc662_3ST_2ch_mixer },
  9784. .init_verbs = { alc662_init_verbs },
  9785. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9786. .dac_nids = alc662_dac_nids,
  9787. .dig_out_nid = ALC662_DIGOUT_NID,
  9788. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9789. .adc_nids = alc662_adc_nids,
  9790. .dig_in_nid = ALC662_DIGIN_NID,
  9791. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9792. .channel_mode = alc662_3ST_2ch_modes,
  9793. .input_mux = &alc662_capture_source,
  9794. },
  9795. [ALC662_3ST_6ch_DIG] = {
  9796. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9797. .init_verbs = { alc662_init_verbs },
  9798. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9799. .dac_nids = alc662_dac_nids,
  9800. .dig_out_nid = ALC662_DIGOUT_NID,
  9801. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9802. .adc_nids = alc662_adc_nids,
  9803. .dig_in_nid = ALC662_DIGIN_NID,
  9804. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9805. .channel_mode = alc662_3ST_6ch_modes,
  9806. .need_dac_fix = 1,
  9807. .input_mux = &alc662_capture_source,
  9808. },
  9809. [ALC662_3ST_6ch] = {
  9810. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9811. .init_verbs = { alc662_init_verbs },
  9812. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9813. .dac_nids = alc662_dac_nids,
  9814. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9815. .adc_nids = alc662_adc_nids,
  9816. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9817. .channel_mode = alc662_3ST_6ch_modes,
  9818. .need_dac_fix = 1,
  9819. .input_mux = &alc662_capture_source,
  9820. },
  9821. [ALC662_5ST_DIG] = {
  9822. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  9823. .init_verbs = { alc662_init_verbs },
  9824. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9825. .dac_nids = alc662_dac_nids,
  9826. .dig_out_nid = ALC662_DIGOUT_NID,
  9827. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9828. .adc_nids = alc662_adc_nids,
  9829. .dig_in_nid = ALC662_DIGIN_NID,
  9830. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  9831. .channel_mode = alc662_5stack_modes,
  9832. .input_mux = &alc662_capture_source,
  9833. },
  9834. [ALC662_LENOVO_101E] = {
  9835. .mixers = { alc662_lenovo_101e_mixer },
  9836. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  9837. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9838. .dac_nids = alc662_dac_nids,
  9839. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9840. .adc_nids = alc662_adc_nids,
  9841. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9842. .channel_mode = alc662_3ST_2ch_modes,
  9843. .input_mux = &alc662_lenovo_101e_capture_source,
  9844. .unsol_event = alc662_lenovo_101e_unsol_event,
  9845. .init_hook = alc662_lenovo_101e_all_automute,
  9846. },
  9847. };
  9848. /*
  9849. * BIOS auto configuration
  9850. */
  9851. /* add playback controls from the parsed DAC table */
  9852. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  9853. const struct auto_pin_cfg *cfg)
  9854. {
  9855. char name[32];
  9856. static const char *chname[4] = {
  9857. "Front", "Surround", NULL /*CLFE*/, "Side"
  9858. };
  9859. hda_nid_t nid;
  9860. int i, err;
  9861. for (i = 0; i < cfg->line_outs; i++) {
  9862. if (!spec->multiout.dac_nids[i])
  9863. continue;
  9864. nid = alc880_idx_to_dac(i);
  9865. if (i == 2) {
  9866. /* Center/LFE */
  9867. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9868. "Center Playback Volume",
  9869. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9870. HDA_OUTPUT));
  9871. if (err < 0)
  9872. return err;
  9873. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9874. "LFE Playback Volume",
  9875. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9876. HDA_OUTPUT));
  9877. if (err < 0)
  9878. return err;
  9879. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9880. "Center Playback Switch",
  9881. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  9882. HDA_INPUT));
  9883. if (err < 0)
  9884. return err;
  9885. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9886. "LFE Playback Switch",
  9887. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  9888. HDA_INPUT));
  9889. if (err < 0)
  9890. return err;
  9891. } else {
  9892. sprintf(name, "%s Playback Volume", chname[i]);
  9893. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9894. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9895. HDA_OUTPUT));
  9896. if (err < 0)
  9897. return err;
  9898. sprintf(name, "%s Playback Switch", chname[i]);
  9899. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9900. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  9901. HDA_INPUT));
  9902. if (err < 0)
  9903. return err;
  9904. }
  9905. }
  9906. return 0;
  9907. }
  9908. /* add playback controls for speaker and HP outputs */
  9909. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  9910. const char *pfx)
  9911. {
  9912. hda_nid_t nid;
  9913. int err;
  9914. char name[32];
  9915. if (!pin)
  9916. return 0;
  9917. if (alc880_is_fixed_pin(pin)) {
  9918. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9919. /* printk("DAC nid=%x\n",nid); */
  9920. /* specify the DAC as the extra output */
  9921. if (!spec->multiout.hp_nid)
  9922. spec->multiout.hp_nid = nid;
  9923. else
  9924. spec->multiout.extra_out_nid[0] = nid;
  9925. /* control HP volume/switch on the output mixer amp */
  9926. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9927. sprintf(name, "%s Playback Volume", pfx);
  9928. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9929. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9930. if (err < 0)
  9931. return err;
  9932. sprintf(name, "%s Playback Switch", pfx);
  9933. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9934. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  9935. if (err < 0)
  9936. return err;
  9937. } else if (alc880_is_multi_pin(pin)) {
  9938. /* set manual connection */
  9939. /* we have only a switch on HP-out PIN */
  9940. sprintf(name, "%s Playback Switch", pfx);
  9941. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9942. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9943. if (err < 0)
  9944. return err;
  9945. }
  9946. return 0;
  9947. }
  9948. /* create playback/capture controls for input pins */
  9949. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  9950. const struct auto_pin_cfg *cfg)
  9951. {
  9952. struct hda_input_mux *imux = &spec->private_imux;
  9953. int i, err, idx;
  9954. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9955. if (alc880_is_input_pin(cfg->input_pins[i])) {
  9956. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  9957. err = new_analog_input(spec, cfg->input_pins[i],
  9958. auto_pin_cfg_labels[i],
  9959. idx, 0x0b);
  9960. if (err < 0)
  9961. return err;
  9962. imux->items[imux->num_items].label =
  9963. auto_pin_cfg_labels[i];
  9964. imux->items[imux->num_items].index =
  9965. alc880_input_pin_idx(cfg->input_pins[i]);
  9966. imux->num_items++;
  9967. }
  9968. }
  9969. return 0;
  9970. }
  9971. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  9972. hda_nid_t nid, int pin_type,
  9973. int dac_idx)
  9974. {
  9975. /* set as output */
  9976. snd_hda_codec_write(codec, nid, 0,
  9977. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9978. snd_hda_codec_write(codec, nid, 0,
  9979. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9980. /* need the manual connection? */
  9981. if (alc880_is_multi_pin(nid)) {
  9982. struct alc_spec *spec = codec->spec;
  9983. int idx = alc880_multi_pin_idx(nid);
  9984. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  9985. AC_VERB_SET_CONNECT_SEL,
  9986. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  9987. }
  9988. }
  9989. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  9990. {
  9991. struct alc_spec *spec = codec->spec;
  9992. int i;
  9993. for (i = 0; i <= HDA_SIDE; i++) {
  9994. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9995. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9996. if (nid)
  9997. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  9998. i);
  9999. }
  10000. }
  10001. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10002. {
  10003. struct alc_spec *spec = codec->spec;
  10004. hda_nid_t pin;
  10005. pin = spec->autocfg.hp_pins[0];
  10006. if (pin) /* connect to front */
  10007. /* use dac 0 */
  10008. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10009. }
  10010. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10011. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10012. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10013. {
  10014. struct alc_spec *spec = codec->spec;
  10015. int i;
  10016. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10017. hda_nid_t nid = spec->autocfg.input_pins[i];
  10018. if (alc662_is_input_pin(nid)) {
  10019. snd_hda_codec_write(codec, nid, 0,
  10020. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10021. (i <= AUTO_PIN_FRONT_MIC ?
  10022. PIN_VREF80 : PIN_IN));
  10023. if (nid != ALC662_PIN_CD_NID)
  10024. snd_hda_codec_write(codec, nid, 0,
  10025. AC_VERB_SET_AMP_GAIN_MUTE,
  10026. AMP_OUT_MUTE);
  10027. }
  10028. }
  10029. }
  10030. static int alc662_parse_auto_config(struct hda_codec *codec)
  10031. {
  10032. struct alc_spec *spec = codec->spec;
  10033. int err;
  10034. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10035. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10036. alc662_ignore);
  10037. if (err < 0)
  10038. return err;
  10039. if (!spec->autocfg.line_outs)
  10040. return 0; /* can't find valid BIOS pin config */
  10041. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10042. if (err < 0)
  10043. return err;
  10044. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10045. if (err < 0)
  10046. return err;
  10047. err = alc662_auto_create_extra_out(spec,
  10048. spec->autocfg.speaker_pins[0],
  10049. "Speaker");
  10050. if (err < 0)
  10051. return err;
  10052. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10053. "Headphone");
  10054. if (err < 0)
  10055. return err;
  10056. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10057. if (err < 0)
  10058. return err;
  10059. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10060. if (spec->autocfg.dig_out_pin)
  10061. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10062. if (spec->kctl_alloc)
  10063. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10064. spec->num_mux_defs = 1;
  10065. spec->input_mux = &spec->private_imux;
  10066. if (err < 0)
  10067. return err;
  10068. else if (err > 0)
  10069. /* hack - override the init verbs */
  10070. spec->init_verbs[0] = alc662_auto_init_verbs;
  10071. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10072. spec->num_mixers++;
  10073. return err;
  10074. }
  10075. /* additional initialization for auto-configuration model */
  10076. static void alc662_auto_init(struct hda_codec *codec)
  10077. {
  10078. alc662_auto_init_multi_out(codec);
  10079. alc662_auto_init_hp_out(codec);
  10080. alc662_auto_init_analog_input(codec);
  10081. }
  10082. static int patch_alc662(struct hda_codec *codec)
  10083. {
  10084. struct alc_spec *spec;
  10085. int err, board_config;
  10086. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10087. if (!spec)
  10088. return -ENOMEM;
  10089. codec->spec = spec;
  10090. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10091. alc662_models,
  10092. alc662_cfg_tbl);
  10093. if (board_config < 0) {
  10094. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10095. "trying auto-probe from BIOS...\n");
  10096. board_config = ALC662_AUTO;
  10097. }
  10098. if (board_config == ALC662_AUTO) {
  10099. /* automatic parse from the BIOS config */
  10100. err = alc662_parse_auto_config(codec);
  10101. if (err < 0) {
  10102. alc_free(codec);
  10103. return err;
  10104. } else if (err) {
  10105. printk(KERN_INFO
  10106. "hda_codec: Cannot set up configuration "
  10107. "from BIOS. Using base mode...\n");
  10108. board_config = ALC662_3ST_2ch_DIG;
  10109. }
  10110. }
  10111. if (board_config != ALC662_AUTO)
  10112. setup_preset(spec, &alc662_presets[board_config]);
  10113. spec->stream_name_analog = "ALC662 Analog";
  10114. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10115. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10116. spec->stream_name_digital = "ALC662 Digital";
  10117. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10118. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10119. if (!spec->adc_nids && spec->input_mux) {
  10120. spec->adc_nids = alc662_adc_nids;
  10121. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10122. }
  10123. codec->patch_ops = alc_patch_ops;
  10124. if (board_config == ALC662_AUTO)
  10125. spec->init_hook = alc662_auto_init;
  10126. return 0;
  10127. }
  10128. /*
  10129. * patch entries
  10130. */
  10131. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10132. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10133. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10134. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10135. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10136. .patch = patch_alc861 },
  10137. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10138. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10139. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10140. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10141. .patch = patch_alc883 },
  10142. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10143. .patch = patch_alc662 },
  10144. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10145. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10146. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10147. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10148. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10149. {} /* terminator */
  10150. };