patch_realtek.c 372 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280
  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. ALC660VD_3ST_DIG,
  118. ALC861VD_3ST,
  119. ALC861VD_3ST_DIG,
  120. ALC861VD_6ST_DIG,
  121. ALC861VD_LENOVO,
  122. ALC861VD_DALLAS,
  123. ALC861VD_AUTO,
  124. ALC861VD_MODEL_LAST,
  125. };
  126. /* ALC662 models */
  127. enum {
  128. ALC662_3ST_2ch_DIG,
  129. ALC662_3ST_6ch_DIG,
  130. ALC662_3ST_6ch,
  131. ALC662_5ST_DIG,
  132. ALC662_LENOVO_101E,
  133. ALC662_AUTO,
  134. ALC662_MODEL_LAST,
  135. };
  136. /* ALC882 models */
  137. enum {
  138. ALC882_3ST_DIG,
  139. ALC882_6ST_DIG,
  140. ALC882_ARIMA,
  141. ALC882_W2JC,
  142. ALC882_TARGA,
  143. ALC882_ASUS_A7J,
  144. ALC885_MACPRO,
  145. ALC882_AUTO,
  146. ALC882_MODEL_LAST,
  147. };
  148. /* ALC883 models */
  149. enum {
  150. ALC883_3ST_2ch_DIG,
  151. ALC883_3ST_6ch_DIG,
  152. ALC883_3ST_6ch,
  153. ALC883_6ST_DIG,
  154. ALC883_TARGA_DIG,
  155. ALC883_TARGA_2ch_DIG,
  156. ALC883_ACER,
  157. ALC883_MEDION,
  158. ALC883_MEDION_MD2,
  159. ALC883_LAPTOP_EAPD,
  160. ALC883_LENOVO_101E_2ch,
  161. ALC883_LENOVO_NB0763,
  162. ALC888_LENOVO_MS7195_DIG,
  163. ALC883_AUTO,
  164. ALC883_MODEL_LAST,
  165. };
  166. /* for GPIO Poll */
  167. #define GPIO_MASK 0x03
  168. struct alc_spec {
  169. /* codec parameterization */
  170. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  171. unsigned int num_mixers;
  172. const struct hda_verb *init_verbs[5]; /* initialization verbs
  173. * don't forget NULL
  174. * termination!
  175. */
  176. unsigned int num_init_verbs;
  177. char *stream_name_analog; /* analog PCM stream */
  178. struct hda_pcm_stream *stream_analog_playback;
  179. struct hda_pcm_stream *stream_analog_capture;
  180. char *stream_name_digital; /* digital PCM stream */
  181. struct hda_pcm_stream *stream_digital_playback;
  182. struct hda_pcm_stream *stream_digital_capture;
  183. /* playback */
  184. struct hda_multi_out multiout; /* playback set-up
  185. * max_channels, dacs must be set
  186. * dig_out_nid and hp_nid are optional
  187. */
  188. /* capture */
  189. unsigned int num_adc_nids;
  190. hda_nid_t *adc_nids;
  191. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  192. /* capture source */
  193. unsigned int num_mux_defs;
  194. const struct hda_input_mux *input_mux;
  195. unsigned int cur_mux[3];
  196. /* channel model */
  197. const struct hda_channel_mode *channel_mode;
  198. int num_channel_mode;
  199. int need_dac_fix;
  200. /* PCM information */
  201. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  202. /* dynamic controls, init_verbs and input_mux */
  203. struct auto_pin_cfg autocfg;
  204. unsigned int num_kctl_alloc, num_kctl_used;
  205. struct snd_kcontrol_new *kctl_alloc;
  206. struct hda_input_mux private_imux;
  207. hda_nid_t private_dac_nids[5];
  208. /* hooks */
  209. void (*init_hook)(struct hda_codec *codec);
  210. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  211. /* for pin sensing */
  212. unsigned int sense_updated: 1;
  213. unsigned int jack_present: 1;
  214. };
  215. /*
  216. * configuration template - to be copied to the spec instance
  217. */
  218. struct alc_config_preset {
  219. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  220. * with spec
  221. */
  222. const struct hda_verb *init_verbs[5];
  223. unsigned int num_dacs;
  224. hda_nid_t *dac_nids;
  225. hda_nid_t dig_out_nid; /* optional */
  226. hda_nid_t hp_nid; /* optional */
  227. unsigned int num_adc_nids;
  228. hda_nid_t *adc_nids;
  229. hda_nid_t dig_in_nid;
  230. unsigned int num_channel_mode;
  231. const struct hda_channel_mode *channel_mode;
  232. int need_dac_fix;
  233. unsigned int num_mux_defs;
  234. const struct hda_input_mux *input_mux;
  235. void (*unsol_event)(struct hda_codec *, unsigned int);
  236. void (*init_hook)(struct hda_codec *);
  237. };
  238. /*
  239. * input MUX handling
  240. */
  241. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  242. struct snd_ctl_elem_info *uinfo)
  243. {
  244. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  245. struct alc_spec *spec = codec->spec;
  246. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  247. if (mux_idx >= spec->num_mux_defs)
  248. mux_idx = 0;
  249. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  250. }
  251. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  252. struct snd_ctl_elem_value *ucontrol)
  253. {
  254. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  255. struct alc_spec *spec = codec->spec;
  256. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  257. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  258. return 0;
  259. }
  260. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  261. struct snd_ctl_elem_value *ucontrol)
  262. {
  263. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  264. struct alc_spec *spec = codec->spec;
  265. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  266. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  267. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  268. spec->adc_nids[adc_idx],
  269. &spec->cur_mux[adc_idx]);
  270. }
  271. /*
  272. * channel mode setting
  273. */
  274. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  275. struct snd_ctl_elem_info *uinfo)
  276. {
  277. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  278. struct alc_spec *spec = codec->spec;
  279. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  280. spec->num_channel_mode);
  281. }
  282. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  283. struct snd_ctl_elem_value *ucontrol)
  284. {
  285. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  286. struct alc_spec *spec = codec->spec;
  287. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  288. spec->num_channel_mode,
  289. spec->multiout.max_channels);
  290. }
  291. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  292. struct snd_ctl_elem_value *ucontrol)
  293. {
  294. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  295. struct alc_spec *spec = codec->spec;
  296. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  297. spec->num_channel_mode,
  298. &spec->multiout.max_channels);
  299. if (err >= 0 && spec->need_dac_fix)
  300. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  301. return err;
  302. }
  303. /*
  304. * Control the mode of pin widget settings via the mixer. "pc" is used
  305. * instead of "%" to avoid consequences of accidently treating the % as
  306. * being part of a format specifier. Maximum allowed length of a value is
  307. * 63 characters plus NULL terminator.
  308. *
  309. * Note: some retasking pin complexes seem to ignore requests for input
  310. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  311. * are requested. Therefore order this list so that this behaviour will not
  312. * cause problems when mixer clients move through the enum sequentially.
  313. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  314. * March 2006.
  315. */
  316. static char *alc_pin_mode_names[] = {
  317. "Mic 50pc bias", "Mic 80pc bias",
  318. "Line in", "Line out", "Headphone out",
  319. };
  320. static unsigned char alc_pin_mode_values[] = {
  321. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  322. };
  323. /* The control can present all 5 options, or it can limit the options based
  324. * in the pin being assumed to be exclusively an input or an output pin. In
  325. * addition, "input" pins may or may not process the mic bias option
  326. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  327. * accept requests for bias as of chip versions up to March 2006) and/or
  328. * wiring in the computer.
  329. */
  330. #define ALC_PIN_DIR_IN 0x00
  331. #define ALC_PIN_DIR_OUT 0x01
  332. #define ALC_PIN_DIR_INOUT 0x02
  333. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  334. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  335. /* Info about the pin modes supported by the different pin direction modes.
  336. * For each direction the minimum and maximum values are given.
  337. */
  338. static signed char alc_pin_mode_dir_info[5][2] = {
  339. { 0, 2 }, /* ALC_PIN_DIR_IN */
  340. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  341. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  342. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  343. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  344. };
  345. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  346. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  347. #define alc_pin_mode_n_items(_dir) \
  348. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  349. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  350. struct snd_ctl_elem_info *uinfo)
  351. {
  352. unsigned int item_num = uinfo->value.enumerated.item;
  353. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  354. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  355. uinfo->count = 1;
  356. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  357. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  358. item_num = alc_pin_mode_min(dir);
  359. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  360. return 0;
  361. }
  362. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  363. struct snd_ctl_elem_value *ucontrol)
  364. {
  365. unsigned int i;
  366. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  367. hda_nid_t nid = kcontrol->private_value & 0xffff;
  368. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  369. long *valp = ucontrol->value.integer.value;
  370. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  371. AC_VERB_GET_PIN_WIDGET_CONTROL,
  372. 0x00);
  373. /* Find enumerated value for current pinctl setting */
  374. i = alc_pin_mode_min(dir);
  375. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  376. i++;
  377. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  378. return 0;
  379. }
  380. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  381. struct snd_ctl_elem_value *ucontrol)
  382. {
  383. signed int change;
  384. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  385. hda_nid_t nid = kcontrol->private_value & 0xffff;
  386. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  387. long val = *ucontrol->value.integer.value;
  388. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  389. AC_VERB_GET_PIN_WIDGET_CONTROL,
  390. 0x00);
  391. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  392. val = alc_pin_mode_min(dir);
  393. change = pinctl != alc_pin_mode_values[val];
  394. if (change) {
  395. /* Set pin mode to that requested */
  396. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  397. alc_pin_mode_values[val]);
  398. /* Also enable the retasking pin's input/output as required
  399. * for the requested pin mode. Enum values of 2 or less are
  400. * input modes.
  401. *
  402. * Dynamically switching the input/output buffers probably
  403. * reduces noise slightly (particularly on input) so we'll
  404. * do it. However, having both input and output buffers
  405. * enabled simultaneously doesn't seem to be problematic if
  406. * this turns out to be necessary in the future.
  407. */
  408. if (val <= 2) {
  409. snd_hda_codec_write(codec, nid, 0,
  410. AC_VERB_SET_AMP_GAIN_MUTE,
  411. AMP_OUT_MUTE);
  412. snd_hda_codec_write(codec, nid, 0,
  413. AC_VERB_SET_AMP_GAIN_MUTE,
  414. AMP_IN_UNMUTE(0));
  415. } else {
  416. snd_hda_codec_write(codec, nid, 0,
  417. AC_VERB_SET_AMP_GAIN_MUTE,
  418. AMP_IN_MUTE(0));
  419. snd_hda_codec_write(codec, nid, 0,
  420. AC_VERB_SET_AMP_GAIN_MUTE,
  421. AMP_OUT_UNMUTE);
  422. }
  423. }
  424. return change;
  425. }
  426. #define ALC_PIN_MODE(xname, nid, dir) \
  427. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  428. .info = alc_pin_mode_info, \
  429. .get = alc_pin_mode_get, \
  430. .put = alc_pin_mode_put, \
  431. .private_value = nid | (dir<<16) }
  432. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  433. * together using a mask with more than one bit set. This control is
  434. * currently used only by the ALC260 test model. At this stage they are not
  435. * needed for any "production" models.
  436. */
  437. #ifdef CONFIG_SND_DEBUG
  438. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  439. struct snd_ctl_elem_info *uinfo)
  440. {
  441. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  442. uinfo->count = 1;
  443. uinfo->value.integer.min = 0;
  444. uinfo->value.integer.max = 1;
  445. return 0;
  446. }
  447. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  448. struct snd_ctl_elem_value *ucontrol)
  449. {
  450. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  451. hda_nid_t nid = kcontrol->private_value & 0xffff;
  452. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  453. long *valp = ucontrol->value.integer.value;
  454. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  455. AC_VERB_GET_GPIO_DATA, 0x00);
  456. *valp = (val & mask) != 0;
  457. return 0;
  458. }
  459. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  460. struct snd_ctl_elem_value *ucontrol)
  461. {
  462. signed int change;
  463. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  464. hda_nid_t nid = kcontrol->private_value & 0xffff;
  465. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  466. long val = *ucontrol->value.integer.value;
  467. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  468. AC_VERB_GET_GPIO_DATA,
  469. 0x00);
  470. /* Set/unset the masked GPIO bit(s) as needed */
  471. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  472. if (val == 0)
  473. gpio_data &= ~mask;
  474. else
  475. gpio_data |= mask;
  476. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  477. return change;
  478. }
  479. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  480. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  481. .info = alc_gpio_data_info, \
  482. .get = alc_gpio_data_get, \
  483. .put = alc_gpio_data_put, \
  484. .private_value = nid | (mask<<16) }
  485. #endif /* CONFIG_SND_DEBUG */
  486. /* A switch control to allow the enabling of the digital IO pins on the
  487. * ALC260. This is incredibly simplistic; the intention of this control is
  488. * to provide something in the test model allowing digital outputs to be
  489. * identified if present. If models are found which can utilise these
  490. * outputs a more complete mixer control can be devised for those models if
  491. * necessary.
  492. */
  493. #ifdef CONFIG_SND_DEBUG
  494. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  495. struct snd_ctl_elem_info *uinfo)
  496. {
  497. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  498. uinfo->count = 1;
  499. uinfo->value.integer.min = 0;
  500. uinfo->value.integer.max = 1;
  501. return 0;
  502. }
  503. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  504. struct snd_ctl_elem_value *ucontrol)
  505. {
  506. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  507. hda_nid_t nid = kcontrol->private_value & 0xffff;
  508. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  509. long *valp = ucontrol->value.integer.value;
  510. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  511. AC_VERB_GET_DIGI_CONVERT, 0x00);
  512. *valp = (val & mask) != 0;
  513. return 0;
  514. }
  515. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  516. struct snd_ctl_elem_value *ucontrol)
  517. {
  518. signed int change;
  519. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  520. hda_nid_t nid = kcontrol->private_value & 0xffff;
  521. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  522. long val = *ucontrol->value.integer.value;
  523. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  524. AC_VERB_GET_DIGI_CONVERT,
  525. 0x00);
  526. /* Set/unset the masked control bit(s) as needed */
  527. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  528. if (val==0)
  529. ctrl_data &= ~mask;
  530. else
  531. ctrl_data |= mask;
  532. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  533. ctrl_data);
  534. return change;
  535. }
  536. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  537. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  538. .info = alc_spdif_ctrl_info, \
  539. .get = alc_spdif_ctrl_get, \
  540. .put = alc_spdif_ctrl_put, \
  541. .private_value = nid | (mask<<16) }
  542. #endif /* CONFIG_SND_DEBUG */
  543. /*
  544. * set up from the preset table
  545. */
  546. static void setup_preset(struct alc_spec *spec,
  547. const struct alc_config_preset *preset)
  548. {
  549. int i;
  550. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  551. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  552. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  553. i++)
  554. spec->init_verbs[spec->num_init_verbs++] =
  555. preset->init_verbs[i];
  556. spec->channel_mode = preset->channel_mode;
  557. spec->num_channel_mode = preset->num_channel_mode;
  558. spec->need_dac_fix = preset->need_dac_fix;
  559. spec->multiout.max_channels = spec->channel_mode[0].channels;
  560. spec->multiout.num_dacs = preset->num_dacs;
  561. spec->multiout.dac_nids = preset->dac_nids;
  562. spec->multiout.dig_out_nid = preset->dig_out_nid;
  563. spec->multiout.hp_nid = preset->hp_nid;
  564. spec->num_mux_defs = preset->num_mux_defs;
  565. if (!spec->num_mux_defs)
  566. spec->num_mux_defs = 1;
  567. spec->input_mux = preset->input_mux;
  568. spec->num_adc_nids = preset->num_adc_nids;
  569. spec->adc_nids = preset->adc_nids;
  570. spec->dig_in_nid = preset->dig_in_nid;
  571. spec->unsol_event = preset->unsol_event;
  572. spec->init_hook = preset->init_hook;
  573. }
  574. /* Enable GPIO mask and set output */
  575. static struct hda_verb alc_gpio1_init_verbs[] = {
  576. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  577. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  578. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  579. { }
  580. };
  581. static struct hda_verb alc_gpio2_init_verbs[] = {
  582. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  583. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  584. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  585. { }
  586. };
  587. static struct hda_verb alc_gpio3_init_verbs[] = {
  588. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  589. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  590. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  591. { }
  592. };
  593. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  594. * 31 ~ 16 : Manufacture ID
  595. * 15 ~ 8 : SKU ID
  596. * 7 ~ 0 : Assembly ID
  597. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  598. */
  599. static void alc_subsystem_id(struct hda_codec *codec,
  600. unsigned int porta, unsigned int porte,
  601. unsigned int portd)
  602. {
  603. unsigned int ass, tmp;
  604. ass = codec->subsystem_id;
  605. if (!(ass & 1))
  606. return;
  607. /* Override */
  608. tmp = (ass & 0x38) >> 3; /* external Amp control */
  609. switch (tmp) {
  610. case 1:
  611. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  612. break;
  613. case 3:
  614. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  615. break;
  616. case 7:
  617. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  618. break;
  619. case 5:
  620. switch (codec->vendor_id) {
  621. case 0x10ec0862:
  622. case 0x10ec0660:
  623. case 0x10ec0662:
  624. case 0x10ec0267:
  625. case 0x10ec0268:
  626. snd_hda_codec_write(codec, 0x14, 0,
  627. AC_VERB_SET_EAPD_BTLENABLE, 2);
  628. snd_hda_codec_write(codec, 0x15, 0,
  629. AC_VERB_SET_EAPD_BTLENABLE, 2);
  630. return;
  631. }
  632. case 6:
  633. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  634. hda_nid_t port = 0;
  635. tmp = (ass & 0x1800) >> 11;
  636. switch (tmp) {
  637. case 0: port = porta; break;
  638. case 1: port = porte; break;
  639. case 2: port = portd; break;
  640. }
  641. if (port)
  642. snd_hda_codec_write(codec, port, 0,
  643. AC_VERB_SET_EAPD_BTLENABLE,
  644. 2);
  645. }
  646. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  647. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  648. (tmp == 5 ? 0x3040 : 0x3050));
  649. break;
  650. }
  651. }
  652. /*
  653. * ALC880 3-stack model
  654. *
  655. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  656. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  657. * F-Mic = 0x1b, HP = 0x19
  658. */
  659. static hda_nid_t alc880_dac_nids[4] = {
  660. /* front, rear, clfe, rear_surr */
  661. 0x02, 0x05, 0x04, 0x03
  662. };
  663. static hda_nid_t alc880_adc_nids[3] = {
  664. /* ADC0-2 */
  665. 0x07, 0x08, 0x09,
  666. };
  667. /* The datasheet says the node 0x07 is connected from inputs,
  668. * but it shows zero connection in the real implementation on some devices.
  669. * Note: this is a 915GAV bug, fixed on 915GLV
  670. */
  671. static hda_nid_t alc880_adc_nids_alt[2] = {
  672. /* ADC1-2 */
  673. 0x08, 0x09,
  674. };
  675. #define ALC880_DIGOUT_NID 0x06
  676. #define ALC880_DIGIN_NID 0x0a
  677. static struct hda_input_mux alc880_capture_source = {
  678. .num_items = 4,
  679. .items = {
  680. { "Mic", 0x0 },
  681. { "Front Mic", 0x3 },
  682. { "Line", 0x2 },
  683. { "CD", 0x4 },
  684. },
  685. };
  686. /* channel source setting (2/6 channel selection for 3-stack) */
  687. /* 2ch mode */
  688. static struct hda_verb alc880_threestack_ch2_init[] = {
  689. /* set line-in to input, mute it */
  690. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  691. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  692. /* set mic-in to input vref 80%, mute it */
  693. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  694. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  695. { } /* end */
  696. };
  697. /* 6ch mode */
  698. static struct hda_verb alc880_threestack_ch6_init[] = {
  699. /* set line-in to output, unmute it */
  700. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  701. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  702. /* set mic-in to output, unmute it */
  703. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  704. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  705. { } /* end */
  706. };
  707. static struct hda_channel_mode alc880_threestack_modes[2] = {
  708. { 2, alc880_threestack_ch2_init },
  709. { 6, alc880_threestack_ch6_init },
  710. };
  711. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  712. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  713. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  714. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  715. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  716. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  717. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  718. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  719. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  720. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  721. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  722. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  723. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  724. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  725. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  726. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  727. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  728. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  729. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  730. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  731. {
  732. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  733. .name = "Channel Mode",
  734. .info = alc_ch_mode_info,
  735. .get = alc_ch_mode_get,
  736. .put = alc_ch_mode_put,
  737. },
  738. { } /* end */
  739. };
  740. /* capture mixer elements */
  741. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  742. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  743. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  744. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  745. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  746. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  747. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  748. {
  749. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  750. /* The multiple "Capture Source" controls confuse alsamixer
  751. * So call somewhat different..
  752. * FIXME: the controls appear in the "playback" view!
  753. */
  754. /* .name = "Capture Source", */
  755. .name = "Input Source",
  756. .count = 3,
  757. .info = alc_mux_enum_info,
  758. .get = alc_mux_enum_get,
  759. .put = alc_mux_enum_put,
  760. },
  761. { } /* end */
  762. };
  763. /* capture mixer elements (in case NID 0x07 not available) */
  764. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  765. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  766. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  767. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  768. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  769. {
  770. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  771. /* The multiple "Capture Source" controls confuse alsamixer
  772. * So call somewhat different..
  773. * FIXME: the controls appear in the "playback" view!
  774. */
  775. /* .name = "Capture Source", */
  776. .name = "Input Source",
  777. .count = 2,
  778. .info = alc_mux_enum_info,
  779. .get = alc_mux_enum_get,
  780. .put = alc_mux_enum_put,
  781. },
  782. { } /* end */
  783. };
  784. /*
  785. * ALC880 5-stack model
  786. *
  787. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  788. * Side = 0x02 (0xd)
  789. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  790. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  791. */
  792. /* additional mixers to alc880_three_stack_mixer */
  793. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  794. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  795. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  796. { } /* end */
  797. };
  798. /* channel source setting (6/8 channel selection for 5-stack) */
  799. /* 6ch mode */
  800. static struct hda_verb alc880_fivestack_ch6_init[] = {
  801. /* set line-in to input, mute it */
  802. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  803. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  804. { } /* end */
  805. };
  806. /* 8ch mode */
  807. static struct hda_verb alc880_fivestack_ch8_init[] = {
  808. /* set line-in to output, unmute it */
  809. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  810. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  811. { } /* end */
  812. };
  813. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  814. { 6, alc880_fivestack_ch6_init },
  815. { 8, alc880_fivestack_ch8_init },
  816. };
  817. /*
  818. * ALC880 6-stack model
  819. *
  820. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  821. * Side = 0x05 (0x0f)
  822. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  823. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  824. */
  825. static hda_nid_t alc880_6st_dac_nids[4] = {
  826. /* front, rear, clfe, rear_surr */
  827. 0x02, 0x03, 0x04, 0x05
  828. };
  829. static struct hda_input_mux alc880_6stack_capture_source = {
  830. .num_items = 4,
  831. .items = {
  832. { "Mic", 0x0 },
  833. { "Front Mic", 0x1 },
  834. { "Line", 0x2 },
  835. { "CD", 0x4 },
  836. },
  837. };
  838. /* fixed 8-channels */
  839. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  840. { 8, NULL },
  841. };
  842. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  843. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  844. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  845. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  846. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  847. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  848. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  849. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  850. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  851. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  852. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  853. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  854. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  855. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  856. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  857. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  858. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  859. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  860. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  861. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  862. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  863. {
  864. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  865. .name = "Channel Mode",
  866. .info = alc_ch_mode_info,
  867. .get = alc_ch_mode_get,
  868. .put = alc_ch_mode_put,
  869. },
  870. { } /* end */
  871. };
  872. /*
  873. * ALC880 W810 model
  874. *
  875. * W810 has rear IO for:
  876. * Front (DAC 02)
  877. * Surround (DAC 03)
  878. * Center/LFE (DAC 04)
  879. * Digital out (06)
  880. *
  881. * The system also has a pair of internal speakers, and a headphone jack.
  882. * These are both connected to Line2 on the codec, hence to DAC 02.
  883. *
  884. * There is a variable resistor to control the speaker or headphone
  885. * volume. This is a hardware-only device without a software API.
  886. *
  887. * Plugging headphones in will disable the internal speakers. This is
  888. * implemented in hardware, not via the driver using jack sense. In
  889. * a similar fashion, plugging into the rear socket marked "front" will
  890. * disable both the speakers and headphones.
  891. *
  892. * For input, there's a microphone jack, and an "audio in" jack.
  893. * These may not do anything useful with this driver yet, because I
  894. * haven't setup any initialization verbs for these yet...
  895. */
  896. static hda_nid_t alc880_w810_dac_nids[3] = {
  897. /* front, rear/surround, clfe */
  898. 0x02, 0x03, 0x04
  899. };
  900. /* fixed 6 channels */
  901. static struct hda_channel_mode alc880_w810_modes[1] = {
  902. { 6, NULL }
  903. };
  904. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  905. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  906. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  907. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  908. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  909. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  910. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  911. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  912. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  913. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  914. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  915. { } /* end */
  916. };
  917. /*
  918. * Z710V model
  919. *
  920. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  921. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  922. * Line = 0x1a
  923. */
  924. static hda_nid_t alc880_z71v_dac_nids[1] = {
  925. 0x02
  926. };
  927. #define ALC880_Z71V_HP_DAC 0x03
  928. /* fixed 2 channels */
  929. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  930. { 2, NULL }
  931. };
  932. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  933. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  934. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  935. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  936. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  937. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  938. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  939. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  940. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  941. { } /* end */
  942. };
  943. /* FIXME! */
  944. /*
  945. * ALC880 F1734 model
  946. *
  947. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  948. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  949. */
  950. static hda_nid_t alc880_f1734_dac_nids[1] = {
  951. 0x03
  952. };
  953. #define ALC880_F1734_HP_DAC 0x02
  954. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  955. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  956. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  957. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  958. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  959. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  960. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  961. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  962. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  963. { } /* end */
  964. };
  965. /* FIXME! */
  966. /*
  967. * ALC880 ASUS model
  968. *
  969. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  970. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  971. * Mic = 0x18, Line = 0x1a
  972. */
  973. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  974. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  975. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  976. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  977. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  978. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  979. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  980. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  981. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  982. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  983. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  984. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  985. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  986. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  987. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  988. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  989. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  990. {
  991. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  992. .name = "Channel Mode",
  993. .info = alc_ch_mode_info,
  994. .get = alc_ch_mode_get,
  995. .put = alc_ch_mode_put,
  996. },
  997. { } /* end */
  998. };
  999. /* FIXME! */
  1000. /*
  1001. * ALC880 ASUS W1V model
  1002. *
  1003. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1004. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1005. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1006. */
  1007. /* additional mixers to alc880_asus_mixer */
  1008. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1009. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1010. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1011. { } /* end */
  1012. };
  1013. /* additional mixers to alc880_asus_mixer */
  1014. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1015. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1016. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1017. { } /* end */
  1018. };
  1019. /* TCL S700 */
  1020. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1021. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1022. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1023. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1024. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1025. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1026. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1027. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1028. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1029. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1030. {
  1031. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1032. /* The multiple "Capture Source" controls confuse alsamixer
  1033. * So call somewhat different..
  1034. * FIXME: the controls appear in the "playback" view!
  1035. */
  1036. /* .name = "Capture Source", */
  1037. .name = "Input Source",
  1038. .count = 1,
  1039. .info = alc_mux_enum_info,
  1040. .get = alc_mux_enum_get,
  1041. .put = alc_mux_enum_put,
  1042. },
  1043. { } /* end */
  1044. };
  1045. /* Uniwill */
  1046. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1047. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1048. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1049. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1050. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1051. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1052. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1053. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1054. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1055. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1056. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1057. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1058. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1059. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1060. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1061. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1062. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1063. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1064. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1065. {
  1066. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1067. .name = "Channel Mode",
  1068. .info = alc_ch_mode_info,
  1069. .get = alc_ch_mode_get,
  1070. .put = alc_ch_mode_put,
  1071. },
  1072. { } /* end */
  1073. };
  1074. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1075. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1076. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1077. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1078. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1079. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1080. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1081. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1082. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1083. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1084. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1085. { } /* end */
  1086. };
  1087. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1088. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1089. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1090. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1091. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1092. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1093. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1094. { } /* end */
  1095. };
  1096. /*
  1097. * build control elements
  1098. */
  1099. static int alc_build_controls(struct hda_codec *codec)
  1100. {
  1101. struct alc_spec *spec = codec->spec;
  1102. int err;
  1103. int i;
  1104. for (i = 0; i < spec->num_mixers; i++) {
  1105. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1106. if (err < 0)
  1107. return err;
  1108. }
  1109. if (spec->multiout.dig_out_nid) {
  1110. err = snd_hda_create_spdif_out_ctls(codec,
  1111. spec->multiout.dig_out_nid);
  1112. if (err < 0)
  1113. return err;
  1114. }
  1115. if (spec->dig_in_nid) {
  1116. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1117. if (err < 0)
  1118. return err;
  1119. }
  1120. return 0;
  1121. }
  1122. /*
  1123. * initialize the codec volumes, etc
  1124. */
  1125. /*
  1126. * generic initialization of ADC, input mixers and output mixers
  1127. */
  1128. static struct hda_verb alc880_volume_init_verbs[] = {
  1129. /*
  1130. * Unmute ADC0-2 and set the default input to mic-in
  1131. */
  1132. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1133. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1134. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1135. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1136. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1137. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1138. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1139. * mixer widget
  1140. * Note: PASD motherboards uses the Line In 2 as the input for front
  1141. * panel mic (mic 2)
  1142. */
  1143. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1144. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1145. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1146. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1147. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1148. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1149. /*
  1150. * Set up output mixers (0x0c - 0x0f)
  1151. */
  1152. /* set vol=0 to output mixers */
  1153. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1154. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1155. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1156. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1157. /* set up input amps for analog loopback */
  1158. /* Amp Indices: DAC = 0, mixer = 1 */
  1159. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1160. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1161. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1162. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1163. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1164. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1165. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1166. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1167. { }
  1168. };
  1169. /*
  1170. * 3-stack pin configuration:
  1171. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1172. */
  1173. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1174. /*
  1175. * preset connection lists of input pins
  1176. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1177. */
  1178. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1179. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1180. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1181. /*
  1182. * Set pin mode and muting
  1183. */
  1184. /* set front pin widgets 0x14 for output */
  1185. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1186. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1187. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1188. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1189. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1190. /* Mic2 (as headphone out) for HP output */
  1191. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1192. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1193. /* Line In pin widget for input */
  1194. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1195. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1196. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1197. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1198. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1199. /* CD pin widget for input */
  1200. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1201. { }
  1202. };
  1203. /*
  1204. * 5-stack pin configuration:
  1205. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1206. * line-in/side = 0x1a, f-mic = 0x1b
  1207. */
  1208. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1209. /*
  1210. * preset connection lists of input pins
  1211. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1212. */
  1213. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1214. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1215. /*
  1216. * Set pin mode and muting
  1217. */
  1218. /* set pin widgets 0x14-0x17 for output */
  1219. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1220. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1221. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1222. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1223. /* unmute pins for output (no gain on this amp) */
  1224. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1225. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1226. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1227. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1228. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1229. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1230. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1231. /* Mic2 (as headphone out) for HP output */
  1232. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1233. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1234. /* Line In pin widget for input */
  1235. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1236. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1237. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1238. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1239. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1240. /* CD pin widget for input */
  1241. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1242. { }
  1243. };
  1244. /*
  1245. * W810 pin configuration:
  1246. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1247. */
  1248. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1249. /* hphone/speaker input selector: front DAC */
  1250. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1251. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1253. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1254. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1255. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1256. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1258. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1259. { }
  1260. };
  1261. /*
  1262. * Z71V pin configuration:
  1263. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1264. */
  1265. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1266. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1267. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1268. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1269. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1270. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1271. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1272. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1273. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1274. { }
  1275. };
  1276. /*
  1277. * 6-stack pin configuration:
  1278. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1279. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1280. */
  1281. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1282. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1283. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1284. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1285. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1286. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1287. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1288. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1289. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1290. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1291. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1292. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1293. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1294. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1295. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1296. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1297. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1298. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1299. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1300. { }
  1301. };
  1302. /*
  1303. * Uniwill pin configuration:
  1304. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1305. * line = 0x1a
  1306. */
  1307. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1308. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1309. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1310. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1311. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1312. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1313. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1314. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1315. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1316. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1318. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1319. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1320. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1321. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1322. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1323. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1324. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1325. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1326. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1327. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1328. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1329. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1330. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1331. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1332. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1333. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1334. { }
  1335. };
  1336. /*
  1337. * Uniwill P53
  1338. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1339. */
  1340. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1341. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1342. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1343. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1344. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1345. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1346. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1347. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1349. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1351. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1353. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1354. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1355. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1356. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1357. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1358. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1359. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1360. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1361. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1362. { }
  1363. };
  1364. static struct hda_verb alc880_beep_init_verbs[] = {
  1365. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1366. { }
  1367. };
  1368. /* toggle speaker-output according to the hp-jack state */
  1369. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1370. {
  1371. unsigned int present;
  1372. unsigned char bits;
  1373. present = snd_hda_codec_read(codec, 0x14, 0,
  1374. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1375. bits = present ? 0x80 : 0;
  1376. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1377. 0x80, bits);
  1378. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1379. 0x80, bits);
  1380. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1381. 0x80, bits);
  1382. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1383. 0x80, bits);
  1384. }
  1385. /* auto-toggle front mic */
  1386. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1387. {
  1388. unsigned int present;
  1389. unsigned char bits;
  1390. present = snd_hda_codec_read(codec, 0x18, 0,
  1391. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1392. bits = present ? 0x80 : 0;
  1393. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1394. 0x80, bits);
  1395. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1396. 0x80, bits);
  1397. }
  1398. static void alc880_uniwill_automute(struct hda_codec *codec)
  1399. {
  1400. alc880_uniwill_hp_automute(codec);
  1401. alc880_uniwill_mic_automute(codec);
  1402. }
  1403. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1404. unsigned int res)
  1405. {
  1406. /* Looks like the unsol event is incompatible with the standard
  1407. * definition. 4bit tag is placed at 28 bit!
  1408. */
  1409. switch (res >> 28) {
  1410. case ALC880_HP_EVENT:
  1411. alc880_uniwill_hp_automute(codec);
  1412. break;
  1413. case ALC880_MIC_EVENT:
  1414. alc880_uniwill_mic_automute(codec);
  1415. break;
  1416. }
  1417. }
  1418. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1419. {
  1420. unsigned int present;
  1421. unsigned char bits;
  1422. present = snd_hda_codec_read(codec, 0x14, 0,
  1423. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1424. bits = present ? 0x80 : 0;
  1425. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1426. 0x80, bits);
  1427. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1428. 0x80, bits);
  1429. }
  1430. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1431. {
  1432. unsigned int present;
  1433. present = snd_hda_codec_read(codec, 0x21, 0,
  1434. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1435. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1436. 0x7f, present);
  1437. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1438. 0x7f, present);
  1439. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1440. 0x7f, present);
  1441. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1442. 0x7f, present);
  1443. }
  1444. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1445. unsigned int res)
  1446. {
  1447. /* Looks like the unsol event is incompatible with the standard
  1448. * definition. 4bit tag is placed at 28 bit!
  1449. */
  1450. if ((res >> 28) == ALC880_HP_EVENT)
  1451. alc880_uniwill_p53_hp_automute(codec);
  1452. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1453. alc880_uniwill_p53_dcvol_automute(codec);
  1454. }
  1455. /* FIXME! */
  1456. /*
  1457. * F1734 pin configuration:
  1458. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1459. */
  1460. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1461. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1462. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1463. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1464. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1465. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1466. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1467. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1468. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1469. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1470. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1471. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1472. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1473. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1474. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1475. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1476. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1477. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1478. { }
  1479. };
  1480. /* FIXME! */
  1481. /*
  1482. * ASUS pin configuration:
  1483. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1484. */
  1485. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1486. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1487. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1488. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1489. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1490. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1491. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1492. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1493. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1494. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1495. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1496. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1497. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1498. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1499. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1500. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1501. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1502. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1503. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1504. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1505. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1506. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1507. { }
  1508. };
  1509. /* Enable GPIO mask and set output */
  1510. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1511. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1512. /* Clevo m520g init */
  1513. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1514. /* headphone output */
  1515. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1516. /* line-out */
  1517. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1518. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1519. /* Line-in */
  1520. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1521. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1522. /* CD */
  1523. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1524. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1525. /* Mic1 (rear panel) */
  1526. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1527. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1528. /* Mic2 (front panel) */
  1529. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1530. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1531. /* headphone */
  1532. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1533. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1534. /* change to EAPD mode */
  1535. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1536. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1537. { }
  1538. };
  1539. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1540. /* change to EAPD mode */
  1541. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1542. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1543. /* Headphone output */
  1544. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1545. /* Front output*/
  1546. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1547. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1548. /* Line In pin widget for input */
  1549. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1550. /* CD pin widget for input */
  1551. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1552. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1553. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1554. /* change to EAPD mode */
  1555. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1556. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1557. { }
  1558. };
  1559. /*
  1560. * LG m1 express dual
  1561. *
  1562. * Pin assignment:
  1563. * Rear Line-In/Out (blue): 0x14
  1564. * Build-in Mic-In: 0x15
  1565. * Speaker-out: 0x17
  1566. * HP-Out (green): 0x1b
  1567. * Mic-In/Out (red): 0x19
  1568. * SPDIF-Out: 0x1e
  1569. */
  1570. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1571. static hda_nid_t alc880_lg_dac_nids[3] = {
  1572. 0x05, 0x02, 0x03
  1573. };
  1574. /* seems analog CD is not working */
  1575. static struct hda_input_mux alc880_lg_capture_source = {
  1576. .num_items = 3,
  1577. .items = {
  1578. { "Mic", 0x1 },
  1579. { "Line", 0x5 },
  1580. { "Internal Mic", 0x6 },
  1581. },
  1582. };
  1583. /* 2,4,6 channel modes */
  1584. static struct hda_verb alc880_lg_ch2_init[] = {
  1585. /* set line-in and mic-in to input */
  1586. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1587. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1588. { }
  1589. };
  1590. static struct hda_verb alc880_lg_ch4_init[] = {
  1591. /* set line-in to out and mic-in to input */
  1592. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1593. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1594. { }
  1595. };
  1596. static struct hda_verb alc880_lg_ch6_init[] = {
  1597. /* set line-in and mic-in to output */
  1598. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1599. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1600. { }
  1601. };
  1602. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1603. { 2, alc880_lg_ch2_init },
  1604. { 4, alc880_lg_ch4_init },
  1605. { 6, alc880_lg_ch6_init },
  1606. };
  1607. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1608. /* FIXME: it's not really "master" but front channels */
  1609. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1610. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1611. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1612. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1613. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1614. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1615. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1616. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1617. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1618. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1619. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1620. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1621. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1622. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1623. {
  1624. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1625. .name = "Channel Mode",
  1626. .info = alc_ch_mode_info,
  1627. .get = alc_ch_mode_get,
  1628. .put = alc_ch_mode_put,
  1629. },
  1630. { } /* end */
  1631. };
  1632. static struct hda_verb alc880_lg_init_verbs[] = {
  1633. /* set capture source to mic-in */
  1634. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1635. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1636. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1637. /* mute all amp mixer inputs */
  1638. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1639. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1640. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1641. /* line-in to input */
  1642. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1643. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1644. /* built-in mic */
  1645. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1646. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1647. /* speaker-out */
  1648. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1649. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1650. /* mic-in to input */
  1651. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1652. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1653. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1654. /* HP-out */
  1655. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1656. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1657. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1658. /* jack sense */
  1659. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1660. { }
  1661. };
  1662. /* toggle speaker-output according to the hp-jack state */
  1663. static void alc880_lg_automute(struct hda_codec *codec)
  1664. {
  1665. unsigned int present;
  1666. unsigned char bits;
  1667. present = snd_hda_codec_read(codec, 0x1b, 0,
  1668. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1669. bits = present ? 0x80 : 0;
  1670. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1671. 0x80, bits);
  1672. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1673. 0x80, bits);
  1674. }
  1675. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1676. {
  1677. /* Looks like the unsol event is incompatible with the standard
  1678. * definition. 4bit tag is placed at 28 bit!
  1679. */
  1680. if ((res >> 28) == 0x01)
  1681. alc880_lg_automute(codec);
  1682. }
  1683. /*
  1684. * LG LW20
  1685. *
  1686. * Pin assignment:
  1687. * Speaker-out: 0x14
  1688. * Mic-In: 0x18
  1689. * Built-in Mic-In: 0x19 (?)
  1690. * HP-Out: 0x1b
  1691. * SPDIF-Out: 0x1e
  1692. */
  1693. /* seems analog CD is not working */
  1694. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1695. .num_items = 2,
  1696. .items = {
  1697. { "Mic", 0x0 },
  1698. { "Internal Mic", 0x1 },
  1699. },
  1700. };
  1701. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1702. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1703. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1704. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1705. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1706. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1707. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1708. { } /* end */
  1709. };
  1710. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1711. /* set capture source to mic-in */
  1712. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1713. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1714. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1715. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1716. /* speaker-out */
  1717. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1718. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1719. /* HP-out */
  1720. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1721. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1722. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1723. /* mic-in to input */
  1724. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1725. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1726. /* built-in mic */
  1727. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1728. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1729. /* jack sense */
  1730. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1731. { }
  1732. };
  1733. /* toggle speaker-output according to the hp-jack state */
  1734. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1735. {
  1736. unsigned int present;
  1737. unsigned char bits;
  1738. present = snd_hda_codec_read(codec, 0x1b, 0,
  1739. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1740. bits = present ? 0x80 : 0;
  1741. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1742. 0x80, bits);
  1743. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1744. 0x80, bits);
  1745. }
  1746. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1747. {
  1748. /* Looks like the unsol event is incompatible with the standard
  1749. * definition. 4bit tag is placed at 28 bit!
  1750. */
  1751. if ((res >> 28) == 0x01)
  1752. alc880_lg_lw_automute(codec);
  1753. }
  1754. /*
  1755. * Common callbacks
  1756. */
  1757. static int alc_init(struct hda_codec *codec)
  1758. {
  1759. struct alc_spec *spec = codec->spec;
  1760. unsigned int i;
  1761. for (i = 0; i < spec->num_init_verbs; i++)
  1762. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1763. if (spec->init_hook)
  1764. spec->init_hook(codec);
  1765. return 0;
  1766. }
  1767. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1768. {
  1769. struct alc_spec *spec = codec->spec;
  1770. if (spec->unsol_event)
  1771. spec->unsol_event(codec, res);
  1772. }
  1773. #ifdef CONFIG_PM
  1774. /*
  1775. * resume
  1776. */
  1777. static int alc_resume(struct hda_codec *codec)
  1778. {
  1779. struct alc_spec *spec = codec->spec;
  1780. int i;
  1781. alc_init(codec);
  1782. for (i = 0; i < spec->num_mixers; i++)
  1783. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1784. if (spec->multiout.dig_out_nid)
  1785. snd_hda_resume_spdif_out(codec);
  1786. if (spec->dig_in_nid)
  1787. snd_hda_resume_spdif_in(codec);
  1788. return 0;
  1789. }
  1790. #endif
  1791. /*
  1792. * Analog playback callbacks
  1793. */
  1794. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1795. struct hda_codec *codec,
  1796. struct snd_pcm_substream *substream)
  1797. {
  1798. struct alc_spec *spec = codec->spec;
  1799. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1800. }
  1801. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1802. struct hda_codec *codec,
  1803. unsigned int stream_tag,
  1804. unsigned int format,
  1805. struct snd_pcm_substream *substream)
  1806. {
  1807. struct alc_spec *spec = codec->spec;
  1808. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1809. stream_tag, format, substream);
  1810. }
  1811. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1812. struct hda_codec *codec,
  1813. struct snd_pcm_substream *substream)
  1814. {
  1815. struct alc_spec *spec = codec->spec;
  1816. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1817. }
  1818. /*
  1819. * Digital out
  1820. */
  1821. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1822. struct hda_codec *codec,
  1823. struct snd_pcm_substream *substream)
  1824. {
  1825. struct alc_spec *spec = codec->spec;
  1826. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1827. }
  1828. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1829. struct hda_codec *codec,
  1830. unsigned int stream_tag,
  1831. unsigned int format,
  1832. struct snd_pcm_substream *substream)
  1833. {
  1834. struct alc_spec *spec = codec->spec;
  1835. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1836. stream_tag, format, substream);
  1837. }
  1838. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1839. struct hda_codec *codec,
  1840. struct snd_pcm_substream *substream)
  1841. {
  1842. struct alc_spec *spec = codec->spec;
  1843. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1844. }
  1845. /*
  1846. * Analog capture
  1847. */
  1848. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1849. struct hda_codec *codec,
  1850. unsigned int stream_tag,
  1851. unsigned int format,
  1852. struct snd_pcm_substream *substream)
  1853. {
  1854. struct alc_spec *spec = codec->spec;
  1855. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1856. stream_tag, 0, format);
  1857. return 0;
  1858. }
  1859. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1860. struct hda_codec *codec,
  1861. struct snd_pcm_substream *substream)
  1862. {
  1863. struct alc_spec *spec = codec->spec;
  1864. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1865. 0, 0, 0);
  1866. return 0;
  1867. }
  1868. /*
  1869. */
  1870. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1871. .substreams = 1,
  1872. .channels_min = 2,
  1873. .channels_max = 8,
  1874. /* NID is set in alc_build_pcms */
  1875. .ops = {
  1876. .open = alc880_playback_pcm_open,
  1877. .prepare = alc880_playback_pcm_prepare,
  1878. .cleanup = alc880_playback_pcm_cleanup
  1879. },
  1880. };
  1881. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1882. .substreams = 2,
  1883. .channels_min = 2,
  1884. .channels_max = 2,
  1885. /* NID is set in alc_build_pcms */
  1886. .ops = {
  1887. .prepare = alc880_capture_pcm_prepare,
  1888. .cleanup = alc880_capture_pcm_cleanup
  1889. },
  1890. };
  1891. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1892. .substreams = 1,
  1893. .channels_min = 2,
  1894. .channels_max = 2,
  1895. /* NID is set in alc_build_pcms */
  1896. .ops = {
  1897. .open = alc880_dig_playback_pcm_open,
  1898. .close = alc880_dig_playback_pcm_close,
  1899. .prepare = alc880_dig_playback_pcm_prepare
  1900. },
  1901. };
  1902. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1903. .substreams = 1,
  1904. .channels_min = 2,
  1905. .channels_max = 2,
  1906. /* NID is set in alc_build_pcms */
  1907. };
  1908. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1909. static struct hda_pcm_stream alc_pcm_null_playback = {
  1910. .substreams = 0,
  1911. .channels_min = 0,
  1912. .channels_max = 0,
  1913. };
  1914. static int alc_build_pcms(struct hda_codec *codec)
  1915. {
  1916. struct alc_spec *spec = codec->spec;
  1917. struct hda_pcm *info = spec->pcm_rec;
  1918. int i;
  1919. codec->num_pcms = 1;
  1920. codec->pcm_info = info;
  1921. info->name = spec->stream_name_analog;
  1922. if (spec->stream_analog_playback) {
  1923. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1924. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1925. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1926. }
  1927. if (spec->stream_analog_capture) {
  1928. snd_assert(spec->adc_nids, return -EINVAL);
  1929. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1930. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1931. }
  1932. if (spec->channel_mode) {
  1933. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1934. for (i = 0; i < spec->num_channel_mode; i++) {
  1935. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1936. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1937. }
  1938. }
  1939. }
  1940. /* SPDIF for stream index #1 */
  1941. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1942. codec->num_pcms = 2;
  1943. info = spec->pcm_rec + 1;
  1944. info->name = spec->stream_name_digital;
  1945. if (spec->multiout.dig_out_nid &&
  1946. spec->stream_digital_playback) {
  1947. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1948. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1949. }
  1950. if (spec->dig_in_nid &&
  1951. spec->stream_digital_capture) {
  1952. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1953. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1954. }
  1955. }
  1956. /* If the use of more than one ADC is requested for the current
  1957. * model, configure a second analog capture-only PCM.
  1958. */
  1959. /* Additional Analaog capture for index #2 */
  1960. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1961. spec->adc_nids) {
  1962. codec->num_pcms = 3;
  1963. info = spec->pcm_rec + 2;
  1964. info->name = spec->stream_name_analog;
  1965. /* No playback stream for second PCM */
  1966. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1967. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1968. if (spec->stream_analog_capture) {
  1969. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1970. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1971. }
  1972. }
  1973. return 0;
  1974. }
  1975. static void alc_free(struct hda_codec *codec)
  1976. {
  1977. struct alc_spec *spec = codec->spec;
  1978. unsigned int i;
  1979. if (!spec)
  1980. return;
  1981. if (spec->kctl_alloc) {
  1982. for (i = 0; i < spec->num_kctl_used; i++)
  1983. kfree(spec->kctl_alloc[i].name);
  1984. kfree(spec->kctl_alloc);
  1985. }
  1986. kfree(spec);
  1987. }
  1988. /*
  1989. */
  1990. static struct hda_codec_ops alc_patch_ops = {
  1991. .build_controls = alc_build_controls,
  1992. .build_pcms = alc_build_pcms,
  1993. .init = alc_init,
  1994. .free = alc_free,
  1995. .unsol_event = alc_unsol_event,
  1996. #ifdef CONFIG_PM
  1997. .resume = alc_resume,
  1998. #endif
  1999. };
  2000. /*
  2001. * Test configuration for debugging
  2002. *
  2003. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2004. * enum controls.
  2005. */
  2006. #ifdef CONFIG_SND_DEBUG
  2007. static hda_nid_t alc880_test_dac_nids[4] = {
  2008. 0x02, 0x03, 0x04, 0x05
  2009. };
  2010. static struct hda_input_mux alc880_test_capture_source = {
  2011. .num_items = 7,
  2012. .items = {
  2013. { "In-1", 0x0 },
  2014. { "In-2", 0x1 },
  2015. { "In-3", 0x2 },
  2016. { "In-4", 0x3 },
  2017. { "CD", 0x4 },
  2018. { "Front", 0x5 },
  2019. { "Surround", 0x6 },
  2020. },
  2021. };
  2022. static struct hda_channel_mode alc880_test_modes[4] = {
  2023. { 2, NULL },
  2024. { 4, NULL },
  2025. { 6, NULL },
  2026. { 8, NULL },
  2027. };
  2028. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2029. struct snd_ctl_elem_info *uinfo)
  2030. {
  2031. static char *texts[] = {
  2032. "N/A", "Line Out", "HP Out",
  2033. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2034. };
  2035. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2036. uinfo->count = 1;
  2037. uinfo->value.enumerated.items = 8;
  2038. if (uinfo->value.enumerated.item >= 8)
  2039. uinfo->value.enumerated.item = 7;
  2040. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2041. return 0;
  2042. }
  2043. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2044. struct snd_ctl_elem_value *ucontrol)
  2045. {
  2046. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2047. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2048. unsigned int pin_ctl, item = 0;
  2049. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2050. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2051. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2052. if (pin_ctl & AC_PINCTL_HP_EN)
  2053. item = 2;
  2054. else
  2055. item = 1;
  2056. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2057. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2058. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2059. case AC_PINCTL_VREF_50: item = 4; break;
  2060. case AC_PINCTL_VREF_GRD: item = 5; break;
  2061. case AC_PINCTL_VREF_80: item = 6; break;
  2062. case AC_PINCTL_VREF_100: item = 7; break;
  2063. }
  2064. }
  2065. ucontrol->value.enumerated.item[0] = item;
  2066. return 0;
  2067. }
  2068. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2069. struct snd_ctl_elem_value *ucontrol)
  2070. {
  2071. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2072. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2073. static unsigned int ctls[] = {
  2074. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2075. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2076. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2077. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2078. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2079. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2080. };
  2081. unsigned int old_ctl, new_ctl;
  2082. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2083. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2084. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2085. if (old_ctl != new_ctl) {
  2086. snd_hda_codec_write(codec, nid, 0,
  2087. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2088. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2089. (ucontrol->value.enumerated.item[0] >= 3 ?
  2090. 0xb080 : 0xb000));
  2091. return 1;
  2092. }
  2093. return 0;
  2094. }
  2095. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2096. struct snd_ctl_elem_info *uinfo)
  2097. {
  2098. static char *texts[] = {
  2099. "Front", "Surround", "CLFE", "Side"
  2100. };
  2101. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2102. uinfo->count = 1;
  2103. uinfo->value.enumerated.items = 4;
  2104. if (uinfo->value.enumerated.item >= 4)
  2105. uinfo->value.enumerated.item = 3;
  2106. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2107. return 0;
  2108. }
  2109. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2110. struct snd_ctl_elem_value *ucontrol)
  2111. {
  2112. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2113. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2114. unsigned int sel;
  2115. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2116. ucontrol->value.enumerated.item[0] = sel & 3;
  2117. return 0;
  2118. }
  2119. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2120. struct snd_ctl_elem_value *ucontrol)
  2121. {
  2122. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2123. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2124. unsigned int sel;
  2125. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2126. if (ucontrol->value.enumerated.item[0] != sel) {
  2127. sel = ucontrol->value.enumerated.item[0] & 3;
  2128. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2129. return 1;
  2130. }
  2131. return 0;
  2132. }
  2133. #define PIN_CTL_TEST(xname,nid) { \
  2134. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2135. .name = xname, \
  2136. .info = alc_test_pin_ctl_info, \
  2137. .get = alc_test_pin_ctl_get, \
  2138. .put = alc_test_pin_ctl_put, \
  2139. .private_value = nid \
  2140. }
  2141. #define PIN_SRC_TEST(xname,nid) { \
  2142. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2143. .name = xname, \
  2144. .info = alc_test_pin_src_info, \
  2145. .get = alc_test_pin_src_get, \
  2146. .put = alc_test_pin_src_put, \
  2147. .private_value = nid \
  2148. }
  2149. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2150. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2151. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2152. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2153. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2154. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2155. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2156. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2157. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2158. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2159. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2160. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2161. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2162. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2163. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2164. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2165. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2166. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2167. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2168. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2169. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2170. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2171. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2172. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2173. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2174. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2175. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2176. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2177. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2178. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2179. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2180. {
  2181. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2182. .name = "Channel Mode",
  2183. .info = alc_ch_mode_info,
  2184. .get = alc_ch_mode_get,
  2185. .put = alc_ch_mode_put,
  2186. },
  2187. { } /* end */
  2188. };
  2189. static struct hda_verb alc880_test_init_verbs[] = {
  2190. /* Unmute inputs of 0x0c - 0x0f */
  2191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2192. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2194. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2196. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2197. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2198. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2199. /* Vol output for 0x0c-0x0f */
  2200. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2201. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2202. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2203. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2204. /* Set output pins 0x14-0x17 */
  2205. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2206. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2207. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2208. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2209. /* Unmute output pins 0x14-0x17 */
  2210. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2211. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2212. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2213. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2214. /* Set input pins 0x18-0x1c */
  2215. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2216. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2217. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2218. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2219. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2220. /* Mute input pins 0x18-0x1b */
  2221. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2222. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2223. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2224. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2225. /* ADC set up */
  2226. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2227. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2228. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2229. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2230. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2231. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2232. /* Analog input/passthru */
  2233. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2234. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2235. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2236. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2237. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2238. { }
  2239. };
  2240. #endif
  2241. /*
  2242. */
  2243. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2244. [ALC880_3ST] = "3stack",
  2245. [ALC880_TCL_S700] = "tcl",
  2246. [ALC880_3ST_DIG] = "3stack-digout",
  2247. [ALC880_CLEVO] = "clevo",
  2248. [ALC880_5ST] = "5stack",
  2249. [ALC880_5ST_DIG] = "5stack-digout",
  2250. [ALC880_W810] = "w810",
  2251. [ALC880_Z71V] = "z71v",
  2252. [ALC880_6ST] = "6stack",
  2253. [ALC880_6ST_DIG] = "6stack-digout",
  2254. [ALC880_ASUS] = "asus",
  2255. [ALC880_ASUS_W1V] = "asus-w1v",
  2256. [ALC880_ASUS_DIG] = "asus-dig",
  2257. [ALC880_ASUS_DIG2] = "asus-dig2",
  2258. [ALC880_UNIWILL_DIG] = "uniwill",
  2259. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2260. [ALC880_FUJITSU] = "fujitsu",
  2261. [ALC880_F1734] = "F1734",
  2262. [ALC880_LG] = "lg",
  2263. [ALC880_LG_LW] = "lg-lw",
  2264. #ifdef CONFIG_SND_DEBUG
  2265. [ALC880_TEST] = "test",
  2266. #endif
  2267. [ALC880_AUTO] = "auto",
  2268. };
  2269. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2270. /* Broken BIOS configuration */
  2271. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2272. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2273. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2274. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2275. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2276. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2277. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2278. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2279. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2280. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2281. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2282. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2283. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2284. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2285. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2286. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2287. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2288. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2289. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2290. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2291. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2292. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2293. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2294. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2295. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2296. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2297. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2298. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2299. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2300. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2301. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2302. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2303. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2304. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2305. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2306. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2307. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2308. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2309. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2310. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2311. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2312. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2313. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2314. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2315. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2316. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2317. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2318. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2319. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2320. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2321. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2322. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2323. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2324. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2325. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2326. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2327. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2328. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2329. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2330. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2331. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2332. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2333. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2334. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2335. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2336. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2337. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2338. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2339. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2340. {}
  2341. };
  2342. /*
  2343. * ALC880 codec presets
  2344. */
  2345. static struct alc_config_preset alc880_presets[] = {
  2346. [ALC880_3ST] = {
  2347. .mixers = { alc880_three_stack_mixer },
  2348. .init_verbs = { alc880_volume_init_verbs,
  2349. alc880_pin_3stack_init_verbs },
  2350. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2351. .dac_nids = alc880_dac_nids,
  2352. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2353. .channel_mode = alc880_threestack_modes,
  2354. .need_dac_fix = 1,
  2355. .input_mux = &alc880_capture_source,
  2356. },
  2357. [ALC880_3ST_DIG] = {
  2358. .mixers = { alc880_three_stack_mixer },
  2359. .init_verbs = { alc880_volume_init_verbs,
  2360. alc880_pin_3stack_init_verbs },
  2361. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2362. .dac_nids = alc880_dac_nids,
  2363. .dig_out_nid = ALC880_DIGOUT_NID,
  2364. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2365. .channel_mode = alc880_threestack_modes,
  2366. .need_dac_fix = 1,
  2367. .input_mux = &alc880_capture_source,
  2368. },
  2369. [ALC880_TCL_S700] = {
  2370. .mixers = { alc880_tcl_s700_mixer },
  2371. .init_verbs = { alc880_volume_init_verbs,
  2372. alc880_pin_tcl_S700_init_verbs,
  2373. alc880_gpio2_init_verbs },
  2374. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2375. .dac_nids = alc880_dac_nids,
  2376. .hp_nid = 0x03,
  2377. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2378. .channel_mode = alc880_2_jack_modes,
  2379. .input_mux = &alc880_capture_source,
  2380. },
  2381. [ALC880_5ST] = {
  2382. .mixers = { alc880_three_stack_mixer,
  2383. alc880_five_stack_mixer},
  2384. .init_verbs = { alc880_volume_init_verbs,
  2385. alc880_pin_5stack_init_verbs },
  2386. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2387. .dac_nids = alc880_dac_nids,
  2388. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2389. .channel_mode = alc880_fivestack_modes,
  2390. .input_mux = &alc880_capture_source,
  2391. },
  2392. [ALC880_5ST_DIG] = {
  2393. .mixers = { alc880_three_stack_mixer,
  2394. alc880_five_stack_mixer },
  2395. .init_verbs = { alc880_volume_init_verbs,
  2396. alc880_pin_5stack_init_verbs },
  2397. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2398. .dac_nids = alc880_dac_nids,
  2399. .dig_out_nid = ALC880_DIGOUT_NID,
  2400. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2401. .channel_mode = alc880_fivestack_modes,
  2402. .input_mux = &alc880_capture_source,
  2403. },
  2404. [ALC880_6ST] = {
  2405. .mixers = { alc880_six_stack_mixer },
  2406. .init_verbs = { alc880_volume_init_verbs,
  2407. alc880_pin_6stack_init_verbs },
  2408. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2409. .dac_nids = alc880_6st_dac_nids,
  2410. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2411. .channel_mode = alc880_sixstack_modes,
  2412. .input_mux = &alc880_6stack_capture_source,
  2413. },
  2414. [ALC880_6ST_DIG] = {
  2415. .mixers = { alc880_six_stack_mixer },
  2416. .init_verbs = { alc880_volume_init_verbs,
  2417. alc880_pin_6stack_init_verbs },
  2418. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2419. .dac_nids = alc880_6st_dac_nids,
  2420. .dig_out_nid = ALC880_DIGOUT_NID,
  2421. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2422. .channel_mode = alc880_sixstack_modes,
  2423. .input_mux = &alc880_6stack_capture_source,
  2424. },
  2425. [ALC880_W810] = {
  2426. .mixers = { alc880_w810_base_mixer },
  2427. .init_verbs = { alc880_volume_init_verbs,
  2428. alc880_pin_w810_init_verbs,
  2429. alc880_gpio2_init_verbs },
  2430. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2431. .dac_nids = alc880_w810_dac_nids,
  2432. .dig_out_nid = ALC880_DIGOUT_NID,
  2433. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2434. .channel_mode = alc880_w810_modes,
  2435. .input_mux = &alc880_capture_source,
  2436. },
  2437. [ALC880_Z71V] = {
  2438. .mixers = { alc880_z71v_mixer },
  2439. .init_verbs = { alc880_volume_init_verbs,
  2440. alc880_pin_z71v_init_verbs },
  2441. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2442. .dac_nids = alc880_z71v_dac_nids,
  2443. .dig_out_nid = ALC880_DIGOUT_NID,
  2444. .hp_nid = 0x03,
  2445. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2446. .channel_mode = alc880_2_jack_modes,
  2447. .input_mux = &alc880_capture_source,
  2448. },
  2449. [ALC880_F1734] = {
  2450. .mixers = { alc880_f1734_mixer },
  2451. .init_verbs = { alc880_volume_init_verbs,
  2452. alc880_pin_f1734_init_verbs },
  2453. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2454. .dac_nids = alc880_f1734_dac_nids,
  2455. .hp_nid = 0x02,
  2456. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2457. .channel_mode = alc880_2_jack_modes,
  2458. .input_mux = &alc880_capture_source,
  2459. },
  2460. [ALC880_ASUS] = {
  2461. .mixers = { alc880_asus_mixer },
  2462. .init_verbs = { alc880_volume_init_verbs,
  2463. alc880_pin_asus_init_verbs,
  2464. alc880_gpio1_init_verbs },
  2465. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2466. .dac_nids = alc880_asus_dac_nids,
  2467. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2468. .channel_mode = alc880_asus_modes,
  2469. .need_dac_fix = 1,
  2470. .input_mux = &alc880_capture_source,
  2471. },
  2472. [ALC880_ASUS_DIG] = {
  2473. .mixers = { alc880_asus_mixer },
  2474. .init_verbs = { alc880_volume_init_verbs,
  2475. alc880_pin_asus_init_verbs,
  2476. alc880_gpio1_init_verbs },
  2477. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2478. .dac_nids = alc880_asus_dac_nids,
  2479. .dig_out_nid = ALC880_DIGOUT_NID,
  2480. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2481. .channel_mode = alc880_asus_modes,
  2482. .need_dac_fix = 1,
  2483. .input_mux = &alc880_capture_source,
  2484. },
  2485. [ALC880_ASUS_DIG2] = {
  2486. .mixers = { alc880_asus_mixer },
  2487. .init_verbs = { alc880_volume_init_verbs,
  2488. alc880_pin_asus_init_verbs,
  2489. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2490. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2491. .dac_nids = alc880_asus_dac_nids,
  2492. .dig_out_nid = ALC880_DIGOUT_NID,
  2493. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2494. .channel_mode = alc880_asus_modes,
  2495. .need_dac_fix = 1,
  2496. .input_mux = &alc880_capture_source,
  2497. },
  2498. [ALC880_ASUS_W1V] = {
  2499. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2500. .init_verbs = { alc880_volume_init_verbs,
  2501. alc880_pin_asus_init_verbs,
  2502. alc880_gpio1_init_verbs },
  2503. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2504. .dac_nids = alc880_asus_dac_nids,
  2505. .dig_out_nid = ALC880_DIGOUT_NID,
  2506. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2507. .channel_mode = alc880_asus_modes,
  2508. .need_dac_fix = 1,
  2509. .input_mux = &alc880_capture_source,
  2510. },
  2511. [ALC880_UNIWILL_DIG] = {
  2512. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2513. .init_verbs = { alc880_volume_init_verbs,
  2514. alc880_pin_asus_init_verbs },
  2515. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2516. .dac_nids = alc880_asus_dac_nids,
  2517. .dig_out_nid = ALC880_DIGOUT_NID,
  2518. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2519. .channel_mode = alc880_asus_modes,
  2520. .need_dac_fix = 1,
  2521. .input_mux = &alc880_capture_source,
  2522. },
  2523. [ALC880_UNIWILL] = {
  2524. .mixers = { alc880_uniwill_mixer },
  2525. .init_verbs = { alc880_volume_init_verbs,
  2526. alc880_uniwill_init_verbs },
  2527. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2528. .dac_nids = alc880_asus_dac_nids,
  2529. .dig_out_nid = ALC880_DIGOUT_NID,
  2530. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2531. .channel_mode = alc880_threestack_modes,
  2532. .need_dac_fix = 1,
  2533. .input_mux = &alc880_capture_source,
  2534. .unsol_event = alc880_uniwill_unsol_event,
  2535. .init_hook = alc880_uniwill_automute,
  2536. },
  2537. [ALC880_UNIWILL_P53] = {
  2538. .mixers = { alc880_uniwill_p53_mixer },
  2539. .init_verbs = { alc880_volume_init_verbs,
  2540. alc880_uniwill_p53_init_verbs },
  2541. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2542. .dac_nids = alc880_asus_dac_nids,
  2543. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2544. .channel_mode = alc880_threestack_modes,
  2545. .input_mux = &alc880_capture_source,
  2546. .unsol_event = alc880_uniwill_p53_unsol_event,
  2547. .init_hook = alc880_uniwill_p53_hp_automute,
  2548. },
  2549. [ALC880_FUJITSU] = {
  2550. .mixers = { alc880_fujitsu_mixer,
  2551. alc880_pcbeep_mixer, },
  2552. .init_verbs = { alc880_volume_init_verbs,
  2553. alc880_uniwill_p53_init_verbs,
  2554. alc880_beep_init_verbs },
  2555. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2556. .dac_nids = alc880_dac_nids,
  2557. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2558. .channel_mode = alc880_2_jack_modes,
  2559. .input_mux = &alc880_capture_source,
  2560. .unsol_event = alc880_uniwill_p53_unsol_event,
  2561. .init_hook = alc880_uniwill_p53_hp_automute,
  2562. },
  2563. [ALC880_CLEVO] = {
  2564. .mixers = { alc880_three_stack_mixer },
  2565. .init_verbs = { alc880_volume_init_verbs,
  2566. alc880_pin_clevo_init_verbs },
  2567. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2568. .dac_nids = alc880_dac_nids,
  2569. .hp_nid = 0x03,
  2570. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2571. .channel_mode = alc880_threestack_modes,
  2572. .need_dac_fix = 1,
  2573. .input_mux = &alc880_capture_source,
  2574. },
  2575. [ALC880_LG] = {
  2576. .mixers = { alc880_lg_mixer },
  2577. .init_verbs = { alc880_volume_init_verbs,
  2578. alc880_lg_init_verbs },
  2579. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2580. .dac_nids = alc880_lg_dac_nids,
  2581. .dig_out_nid = ALC880_DIGOUT_NID,
  2582. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2583. .channel_mode = alc880_lg_ch_modes,
  2584. .need_dac_fix = 1,
  2585. .input_mux = &alc880_lg_capture_source,
  2586. .unsol_event = alc880_lg_unsol_event,
  2587. .init_hook = alc880_lg_automute,
  2588. },
  2589. [ALC880_LG_LW] = {
  2590. .mixers = { alc880_lg_lw_mixer },
  2591. .init_verbs = { alc880_volume_init_verbs,
  2592. alc880_lg_lw_init_verbs },
  2593. .num_dacs = 1,
  2594. .dac_nids = alc880_dac_nids,
  2595. .dig_out_nid = ALC880_DIGOUT_NID,
  2596. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2597. .channel_mode = alc880_2_jack_modes,
  2598. .input_mux = &alc880_lg_lw_capture_source,
  2599. .unsol_event = alc880_lg_lw_unsol_event,
  2600. .init_hook = alc880_lg_lw_automute,
  2601. },
  2602. #ifdef CONFIG_SND_DEBUG
  2603. [ALC880_TEST] = {
  2604. .mixers = { alc880_test_mixer },
  2605. .init_verbs = { alc880_test_init_verbs },
  2606. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2607. .dac_nids = alc880_test_dac_nids,
  2608. .dig_out_nid = ALC880_DIGOUT_NID,
  2609. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2610. .channel_mode = alc880_test_modes,
  2611. .input_mux = &alc880_test_capture_source,
  2612. },
  2613. #endif
  2614. };
  2615. /*
  2616. * Automatic parse of I/O pins from the BIOS configuration
  2617. */
  2618. #define NUM_CONTROL_ALLOC 32
  2619. #define NUM_VERB_ALLOC 32
  2620. enum {
  2621. ALC_CTL_WIDGET_VOL,
  2622. ALC_CTL_WIDGET_MUTE,
  2623. ALC_CTL_BIND_MUTE,
  2624. };
  2625. static struct snd_kcontrol_new alc880_control_templates[] = {
  2626. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2627. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2628. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2629. };
  2630. /* add dynamic controls */
  2631. static int add_control(struct alc_spec *spec, int type, const char *name,
  2632. unsigned long val)
  2633. {
  2634. struct snd_kcontrol_new *knew;
  2635. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2636. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2637. /* array + terminator */
  2638. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2639. if (!knew)
  2640. return -ENOMEM;
  2641. if (spec->kctl_alloc) {
  2642. memcpy(knew, spec->kctl_alloc,
  2643. sizeof(*knew) * spec->num_kctl_alloc);
  2644. kfree(spec->kctl_alloc);
  2645. }
  2646. spec->kctl_alloc = knew;
  2647. spec->num_kctl_alloc = num;
  2648. }
  2649. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2650. *knew = alc880_control_templates[type];
  2651. knew->name = kstrdup(name, GFP_KERNEL);
  2652. if (!knew->name)
  2653. return -ENOMEM;
  2654. knew->private_value = val;
  2655. spec->num_kctl_used++;
  2656. return 0;
  2657. }
  2658. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2659. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2660. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2661. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2662. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2663. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2664. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2665. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2666. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2667. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2668. #define ALC880_PIN_CD_NID 0x1c
  2669. /* fill in the dac_nids table from the parsed pin configuration */
  2670. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2671. const struct auto_pin_cfg *cfg)
  2672. {
  2673. hda_nid_t nid;
  2674. int assigned[4];
  2675. int i, j;
  2676. memset(assigned, 0, sizeof(assigned));
  2677. spec->multiout.dac_nids = spec->private_dac_nids;
  2678. /* check the pins hardwired to audio widget */
  2679. for (i = 0; i < cfg->line_outs; i++) {
  2680. nid = cfg->line_out_pins[i];
  2681. if (alc880_is_fixed_pin(nid)) {
  2682. int idx = alc880_fixed_pin_idx(nid);
  2683. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2684. assigned[idx] = 1;
  2685. }
  2686. }
  2687. /* left pins can be connect to any audio widget */
  2688. for (i = 0; i < cfg->line_outs; i++) {
  2689. nid = cfg->line_out_pins[i];
  2690. if (alc880_is_fixed_pin(nid))
  2691. continue;
  2692. /* search for an empty channel */
  2693. for (j = 0; j < cfg->line_outs; j++) {
  2694. if (!assigned[j]) {
  2695. spec->multiout.dac_nids[i] =
  2696. alc880_idx_to_dac(j);
  2697. assigned[j] = 1;
  2698. break;
  2699. }
  2700. }
  2701. }
  2702. spec->multiout.num_dacs = cfg->line_outs;
  2703. return 0;
  2704. }
  2705. /* add playback controls from the parsed DAC table */
  2706. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2707. const struct auto_pin_cfg *cfg)
  2708. {
  2709. char name[32];
  2710. static const char *chname[4] = {
  2711. "Front", "Surround", NULL /*CLFE*/, "Side"
  2712. };
  2713. hda_nid_t nid;
  2714. int i, err;
  2715. for (i = 0; i < cfg->line_outs; i++) {
  2716. if (!spec->multiout.dac_nids[i])
  2717. continue;
  2718. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2719. if (i == 2) {
  2720. /* Center/LFE */
  2721. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2722. "Center Playback Volume",
  2723. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2724. HDA_OUTPUT));
  2725. if (err < 0)
  2726. return err;
  2727. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2728. "LFE Playback Volume",
  2729. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2730. HDA_OUTPUT));
  2731. if (err < 0)
  2732. return err;
  2733. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2734. "Center Playback Switch",
  2735. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2736. HDA_INPUT));
  2737. if (err < 0)
  2738. return err;
  2739. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2740. "LFE Playback Switch",
  2741. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2742. HDA_INPUT));
  2743. if (err < 0)
  2744. return err;
  2745. } else {
  2746. sprintf(name, "%s Playback Volume", chname[i]);
  2747. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2748. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2749. HDA_OUTPUT));
  2750. if (err < 0)
  2751. return err;
  2752. sprintf(name, "%s Playback Switch", chname[i]);
  2753. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2754. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2755. HDA_INPUT));
  2756. if (err < 0)
  2757. return err;
  2758. }
  2759. }
  2760. return 0;
  2761. }
  2762. /* add playback controls for speaker and HP outputs */
  2763. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2764. const char *pfx)
  2765. {
  2766. hda_nid_t nid;
  2767. int err;
  2768. char name[32];
  2769. if (!pin)
  2770. return 0;
  2771. if (alc880_is_fixed_pin(pin)) {
  2772. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2773. /* specify the DAC as the extra output */
  2774. if (!spec->multiout.hp_nid)
  2775. spec->multiout.hp_nid = nid;
  2776. else
  2777. spec->multiout.extra_out_nid[0] = nid;
  2778. /* control HP volume/switch on the output mixer amp */
  2779. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2780. sprintf(name, "%s Playback Volume", pfx);
  2781. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2782. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2783. if (err < 0)
  2784. return err;
  2785. sprintf(name, "%s Playback Switch", pfx);
  2786. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2787. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2788. if (err < 0)
  2789. return err;
  2790. } else if (alc880_is_multi_pin(pin)) {
  2791. /* set manual connection */
  2792. /* we have only a switch on HP-out PIN */
  2793. sprintf(name, "%s Playback Switch", pfx);
  2794. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2795. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2796. if (err < 0)
  2797. return err;
  2798. }
  2799. return 0;
  2800. }
  2801. /* create input playback/capture controls for the given pin */
  2802. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2803. const char *ctlname,
  2804. int idx, hda_nid_t mix_nid)
  2805. {
  2806. char name[32];
  2807. int err;
  2808. sprintf(name, "%s Playback Volume", ctlname);
  2809. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2810. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2811. if (err < 0)
  2812. return err;
  2813. sprintf(name, "%s Playback Switch", ctlname);
  2814. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2815. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2816. if (err < 0)
  2817. return err;
  2818. return 0;
  2819. }
  2820. /* create playback/capture controls for input pins */
  2821. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2822. const struct auto_pin_cfg *cfg)
  2823. {
  2824. struct hda_input_mux *imux = &spec->private_imux;
  2825. int i, err, idx;
  2826. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2827. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2828. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2829. err = new_analog_input(spec, cfg->input_pins[i],
  2830. auto_pin_cfg_labels[i],
  2831. idx, 0x0b);
  2832. if (err < 0)
  2833. return err;
  2834. imux->items[imux->num_items].label =
  2835. auto_pin_cfg_labels[i];
  2836. imux->items[imux->num_items].index =
  2837. alc880_input_pin_idx(cfg->input_pins[i]);
  2838. imux->num_items++;
  2839. }
  2840. }
  2841. return 0;
  2842. }
  2843. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2844. hda_nid_t nid, int pin_type,
  2845. int dac_idx)
  2846. {
  2847. /* set as output */
  2848. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2849. pin_type);
  2850. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2851. AMP_OUT_UNMUTE);
  2852. /* need the manual connection? */
  2853. if (alc880_is_multi_pin(nid)) {
  2854. struct alc_spec *spec = codec->spec;
  2855. int idx = alc880_multi_pin_idx(nid);
  2856. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2857. AC_VERB_SET_CONNECT_SEL,
  2858. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2859. }
  2860. }
  2861. static int get_pin_type(int line_out_type)
  2862. {
  2863. if (line_out_type == AUTO_PIN_HP_OUT)
  2864. return PIN_HP;
  2865. else
  2866. return PIN_OUT;
  2867. }
  2868. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2869. {
  2870. struct alc_spec *spec = codec->spec;
  2871. int i;
  2872. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2873. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2874. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2875. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2876. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2877. }
  2878. }
  2879. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2880. {
  2881. struct alc_spec *spec = codec->spec;
  2882. hda_nid_t pin;
  2883. pin = spec->autocfg.speaker_pins[0];
  2884. if (pin) /* connect to front */
  2885. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2886. pin = spec->autocfg.hp_pins[0];
  2887. if (pin) /* connect to front */
  2888. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2889. }
  2890. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2891. {
  2892. struct alc_spec *spec = codec->spec;
  2893. int i;
  2894. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2895. hda_nid_t nid = spec->autocfg.input_pins[i];
  2896. if (alc880_is_input_pin(nid)) {
  2897. snd_hda_codec_write(codec, nid, 0,
  2898. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2899. i <= AUTO_PIN_FRONT_MIC ?
  2900. PIN_VREF80 : PIN_IN);
  2901. if (nid != ALC880_PIN_CD_NID)
  2902. snd_hda_codec_write(codec, nid, 0,
  2903. AC_VERB_SET_AMP_GAIN_MUTE,
  2904. AMP_OUT_MUTE);
  2905. }
  2906. }
  2907. }
  2908. /* parse the BIOS configuration and set up the alc_spec */
  2909. /* return 1 if successful, 0 if the proper config is not found,
  2910. * or a negative error code
  2911. */
  2912. static int alc880_parse_auto_config(struct hda_codec *codec)
  2913. {
  2914. struct alc_spec *spec = codec->spec;
  2915. int err;
  2916. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2917. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2918. alc880_ignore);
  2919. if (err < 0)
  2920. return err;
  2921. if (!spec->autocfg.line_outs)
  2922. return 0; /* can't find valid BIOS pin config */
  2923. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2924. if (err < 0)
  2925. return err;
  2926. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2927. if (err < 0)
  2928. return err;
  2929. err = alc880_auto_create_extra_out(spec,
  2930. spec->autocfg.speaker_pins[0],
  2931. "Speaker");
  2932. if (err < 0)
  2933. return err;
  2934. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2935. "Headphone");
  2936. if (err < 0)
  2937. return err;
  2938. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2939. if (err < 0)
  2940. return err;
  2941. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2942. if (spec->autocfg.dig_out_pin)
  2943. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2944. if (spec->autocfg.dig_in_pin)
  2945. spec->dig_in_nid = ALC880_DIGIN_NID;
  2946. if (spec->kctl_alloc)
  2947. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2948. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2949. spec->num_mux_defs = 1;
  2950. spec->input_mux = &spec->private_imux;
  2951. return 1;
  2952. }
  2953. /* additional initialization for auto-configuration model */
  2954. static void alc880_auto_init(struct hda_codec *codec)
  2955. {
  2956. alc880_auto_init_multi_out(codec);
  2957. alc880_auto_init_extra_out(codec);
  2958. alc880_auto_init_analog_input(codec);
  2959. }
  2960. /*
  2961. * OK, here we have finally the patch for ALC880
  2962. */
  2963. static int patch_alc880(struct hda_codec *codec)
  2964. {
  2965. struct alc_spec *spec;
  2966. int board_config;
  2967. int err;
  2968. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2969. if (spec == NULL)
  2970. return -ENOMEM;
  2971. codec->spec = spec;
  2972. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2973. alc880_models,
  2974. alc880_cfg_tbl);
  2975. if (board_config < 0) {
  2976. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2977. "trying auto-probe from BIOS...\n");
  2978. board_config = ALC880_AUTO;
  2979. }
  2980. if (board_config == ALC880_AUTO) {
  2981. /* automatic parse from the BIOS config */
  2982. err = alc880_parse_auto_config(codec);
  2983. if (err < 0) {
  2984. alc_free(codec);
  2985. return err;
  2986. } else if (!err) {
  2987. printk(KERN_INFO
  2988. "hda_codec: Cannot set up configuration "
  2989. "from BIOS. Using 3-stack mode...\n");
  2990. board_config = ALC880_3ST;
  2991. }
  2992. }
  2993. if (board_config != ALC880_AUTO)
  2994. setup_preset(spec, &alc880_presets[board_config]);
  2995. spec->stream_name_analog = "ALC880 Analog";
  2996. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2997. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2998. spec->stream_name_digital = "ALC880 Digital";
  2999. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3000. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3001. if (!spec->adc_nids && spec->input_mux) {
  3002. /* check whether NID 0x07 is valid */
  3003. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3004. /* get type */
  3005. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3006. if (wcap != AC_WID_AUD_IN) {
  3007. spec->adc_nids = alc880_adc_nids_alt;
  3008. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3009. spec->mixers[spec->num_mixers] =
  3010. alc880_capture_alt_mixer;
  3011. spec->num_mixers++;
  3012. } else {
  3013. spec->adc_nids = alc880_adc_nids;
  3014. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3015. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3016. spec->num_mixers++;
  3017. }
  3018. }
  3019. codec->patch_ops = alc_patch_ops;
  3020. if (board_config == ALC880_AUTO)
  3021. spec->init_hook = alc880_auto_init;
  3022. return 0;
  3023. }
  3024. /*
  3025. * ALC260 support
  3026. */
  3027. static hda_nid_t alc260_dac_nids[1] = {
  3028. /* front */
  3029. 0x02,
  3030. };
  3031. static hda_nid_t alc260_adc_nids[1] = {
  3032. /* ADC0 */
  3033. 0x04,
  3034. };
  3035. static hda_nid_t alc260_adc_nids_alt[1] = {
  3036. /* ADC1 */
  3037. 0x05,
  3038. };
  3039. static hda_nid_t alc260_hp_adc_nids[2] = {
  3040. /* ADC1, 0 */
  3041. 0x05, 0x04
  3042. };
  3043. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3044. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3045. */
  3046. static hda_nid_t alc260_dual_adc_nids[2] = {
  3047. /* ADC0, ADC1 */
  3048. 0x04, 0x05
  3049. };
  3050. #define ALC260_DIGOUT_NID 0x03
  3051. #define ALC260_DIGIN_NID 0x06
  3052. static struct hda_input_mux alc260_capture_source = {
  3053. .num_items = 4,
  3054. .items = {
  3055. { "Mic", 0x0 },
  3056. { "Front Mic", 0x1 },
  3057. { "Line", 0x2 },
  3058. { "CD", 0x4 },
  3059. },
  3060. };
  3061. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3062. * headphone jack and the internal CD lines since these are the only pins at
  3063. * which audio can appear. For flexibility, also allow the option of
  3064. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3065. * connection to the mixer output).
  3066. */
  3067. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3068. {
  3069. .num_items = 3,
  3070. .items = {
  3071. { "Mic/Line", 0x0 },
  3072. { "CD", 0x4 },
  3073. { "Headphone", 0x2 },
  3074. },
  3075. },
  3076. {
  3077. .num_items = 4,
  3078. .items = {
  3079. { "Mic/Line", 0x0 },
  3080. { "CD", 0x4 },
  3081. { "Headphone", 0x2 },
  3082. { "Mixer", 0x5 },
  3083. },
  3084. },
  3085. };
  3086. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3087. * the Fujitsu S702x, but jacks are marked differently.
  3088. */
  3089. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3090. {
  3091. .num_items = 4,
  3092. .items = {
  3093. { "Mic", 0x0 },
  3094. { "Line", 0x2 },
  3095. { "CD", 0x4 },
  3096. { "Headphone", 0x5 },
  3097. },
  3098. },
  3099. {
  3100. .num_items = 5,
  3101. .items = {
  3102. { "Mic", 0x0 },
  3103. { "Line", 0x2 },
  3104. { "CD", 0x4 },
  3105. { "Headphone", 0x6 },
  3106. { "Mixer", 0x5 },
  3107. },
  3108. },
  3109. };
  3110. /*
  3111. * This is just place-holder, so there's something for alc_build_pcms to look
  3112. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3113. * element which allows changing the channel mode, so the verb list is
  3114. * never used.
  3115. */
  3116. static struct hda_channel_mode alc260_modes[1] = {
  3117. { 2, NULL },
  3118. };
  3119. /* Mixer combinations
  3120. *
  3121. * basic: base_output + input + pc_beep + capture
  3122. * HP: base_output + input + capture_alt
  3123. * HP_3013: hp_3013 + input + capture
  3124. * fujitsu: fujitsu + capture
  3125. * acer: acer + capture
  3126. */
  3127. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3128. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3129. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3130. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3131. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3132. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3133. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3134. { } /* end */
  3135. };
  3136. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3137. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3138. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3139. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3140. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3141. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3142. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3143. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3144. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3145. { } /* end */
  3146. };
  3147. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3148. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3149. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3150. { } /* end */
  3151. };
  3152. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3153. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3154. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3155. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3156. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3157. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3158. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3159. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3160. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3161. { } /* end */
  3162. };
  3163. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3164. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3165. */
  3166. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3167. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3168. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3169. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3170. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3171. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3172. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3173. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3174. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3175. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3176. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3177. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3178. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3179. { } /* end */
  3180. };
  3181. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3182. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3183. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3184. * datasheet doesn't mention this restriction. At this stage it's not clear
  3185. * whether this behaviour is intentional or is a hardware bug in chip
  3186. * revisions available in early 2006. Therefore for now allow the
  3187. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3188. * that the lack of mic bias for this NID is intentional we could change the
  3189. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3190. *
  3191. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3192. * don't appear to make the mic bias available from the "line" jack, even
  3193. * though the NID used for this jack (0x14) can supply it. The theory is
  3194. * that perhaps Acer have included blocking capacitors between the ALC260
  3195. * and the output jack. If this turns out to be the case for all such
  3196. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3197. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3198. *
  3199. * The C20x Tablet series have a mono internal speaker which is controlled
  3200. * via the chip's Mono sum widget and pin complex, so include the necessary
  3201. * controls for such models. On models without a "mono speaker" the control
  3202. * won't do anything.
  3203. */
  3204. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3205. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3206. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3207. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3208. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3209. HDA_OUTPUT),
  3210. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3211. HDA_INPUT),
  3212. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3213. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3214. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3215. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3216. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3217. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3218. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3219. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3220. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3221. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3222. { } /* end */
  3223. };
  3224. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3225. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3226. */
  3227. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3228. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3229. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3230. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3231. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3232. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3233. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3234. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3235. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3236. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3237. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3238. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3239. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3240. { } /* end */
  3241. };
  3242. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3243. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3244. */
  3245. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3246. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3247. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3248. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3249. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3250. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3251. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3252. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3253. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3254. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3255. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3256. { } /* end */
  3257. };
  3258. /* capture mixer elements */
  3259. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3260. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3261. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3262. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3263. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3264. {
  3265. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3266. /* The multiple "Capture Source" controls confuse alsamixer
  3267. * So call somewhat different..
  3268. * FIXME: the controls appear in the "playback" view!
  3269. */
  3270. /* .name = "Capture Source", */
  3271. .name = "Input Source",
  3272. .count = 2,
  3273. .info = alc_mux_enum_info,
  3274. .get = alc_mux_enum_get,
  3275. .put = alc_mux_enum_put,
  3276. },
  3277. { } /* end */
  3278. };
  3279. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3280. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3281. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3282. {
  3283. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3284. /* The multiple "Capture Source" controls confuse alsamixer
  3285. * So call somewhat different..
  3286. * FIXME: the controls appear in the "playback" view!
  3287. */
  3288. /* .name = "Capture Source", */
  3289. .name = "Input Source",
  3290. .count = 1,
  3291. .info = alc_mux_enum_info,
  3292. .get = alc_mux_enum_get,
  3293. .put = alc_mux_enum_put,
  3294. },
  3295. { } /* end */
  3296. };
  3297. /*
  3298. * initialization verbs
  3299. */
  3300. static struct hda_verb alc260_init_verbs[] = {
  3301. /* Line In pin widget for input */
  3302. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3303. /* CD pin widget for input */
  3304. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3305. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3306. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3307. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3308. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3309. /* LINE-2 is used for line-out in rear */
  3310. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3311. /* select line-out */
  3312. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3313. /* LINE-OUT pin */
  3314. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3315. /* enable HP */
  3316. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3317. /* enable Mono */
  3318. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3319. /* mute capture amp left and right */
  3320. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3321. /* set connection select to line in (default select for this ADC) */
  3322. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3323. /* mute capture amp left and right */
  3324. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3325. /* set connection select to line in (default select for this ADC) */
  3326. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3327. /* set vol=0 Line-Out mixer amp left and right */
  3328. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3329. /* unmute pin widget amp left and right (no gain on this amp) */
  3330. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3331. /* set vol=0 HP mixer amp left and right */
  3332. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3333. /* unmute pin widget amp left and right (no gain on this amp) */
  3334. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3335. /* set vol=0 Mono mixer amp left and right */
  3336. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3337. /* unmute pin widget amp left and right (no gain on this amp) */
  3338. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3339. /* unmute LINE-2 out pin */
  3340. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3341. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3342. * Line In 2 = 0x03
  3343. */
  3344. /* mute CD */
  3345. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3346. /* mute Line In */
  3347. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3348. /* mute Mic */
  3349. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3350. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3351. /* mute Front out path */
  3352. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3353. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3354. /* mute Headphone out path */
  3355. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3356. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3357. /* mute Mono out path */
  3358. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3359. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3360. { }
  3361. };
  3362. #if 0 /* should be identical with alc260_init_verbs? */
  3363. static struct hda_verb alc260_hp_init_verbs[] = {
  3364. /* Headphone and output */
  3365. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3366. /* mono output */
  3367. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3368. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3369. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3370. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3371. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3372. /* Line In pin widget for input */
  3373. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3374. /* Line-2 pin widget for output */
  3375. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3376. /* CD pin widget for input */
  3377. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3378. /* unmute amp left and right */
  3379. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3380. /* set connection select to line in (default select for this ADC) */
  3381. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3382. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3383. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3384. /* mute pin widget amp left and right (no gain on this amp) */
  3385. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3386. /* unmute HP mixer amp left and right (volume = 0) */
  3387. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3388. /* mute pin widget amp left and right (no gain on this amp) */
  3389. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3390. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3391. * Line In 2 = 0x03
  3392. */
  3393. /* unmute CD */
  3394. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3395. /* unmute Line In */
  3396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3397. /* unmute Mic */
  3398. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3399. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3400. /* Unmute Front out path */
  3401. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3402. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3403. /* Unmute Headphone out path */
  3404. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3405. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3406. /* Unmute Mono out path */
  3407. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3408. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3409. { }
  3410. };
  3411. #endif
  3412. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3413. /* Line out and output */
  3414. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3415. /* mono output */
  3416. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3417. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3418. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3419. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3420. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3421. /* Line In pin widget for input */
  3422. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3423. /* Headphone pin widget for output */
  3424. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3425. /* CD pin widget for input */
  3426. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3427. /* unmute amp left and right */
  3428. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3429. /* set connection select to line in (default select for this ADC) */
  3430. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3431. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3432. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3433. /* mute pin widget amp left and right (no gain on this amp) */
  3434. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3435. /* unmute HP mixer amp left and right (volume = 0) */
  3436. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3437. /* mute pin widget amp left and right (no gain on this amp) */
  3438. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3439. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3440. * Line In 2 = 0x03
  3441. */
  3442. /* unmute CD */
  3443. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3444. /* unmute Line In */
  3445. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3446. /* unmute Mic */
  3447. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3448. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3449. /* Unmute Front out path */
  3450. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3451. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3452. /* Unmute Headphone out path */
  3453. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3454. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3455. /* Unmute Mono out path */
  3456. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3457. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3458. { }
  3459. };
  3460. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3461. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3462. * audio = 0x16, internal speaker = 0x10.
  3463. */
  3464. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3465. /* Disable all GPIOs */
  3466. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3467. /* Internal speaker is connected to headphone pin */
  3468. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3469. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3470. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3471. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3472. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3473. /* Ensure all other unused pins are disabled and muted. */
  3474. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3475. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3476. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3477. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3478. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3479. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3480. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3481. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3482. /* Disable digital (SPDIF) pins */
  3483. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3484. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3485. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3486. * when acting as an output.
  3487. */
  3488. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3489. /* Start with output sum widgets muted and their output gains at min */
  3490. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3491. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3492. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3493. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3494. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3495. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3496. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3497. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3498. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3499. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3500. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3501. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3502. * If the pin mode is changed by the user the pin mode control will
  3503. * take care of enabling the pin's input/output buffers as needed.
  3504. * Therefore there's no need to enable the input buffer at this
  3505. * stage.
  3506. */
  3507. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3508. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3509. * mixer ctrl)
  3510. */
  3511. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3512. /* Mute capture amp left and right */
  3513. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3514. /* Set ADC connection select to match default mixer setting - line
  3515. * in (on mic1 pin)
  3516. */
  3517. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3518. /* Do the same for the second ADC: mute capture input amp and
  3519. * set ADC connection to line in (on mic1 pin)
  3520. */
  3521. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3522. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3523. /* Mute all inputs to mixer widget (even unconnected ones) */
  3524. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3525. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3526. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3527. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3528. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3529. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3530. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3531. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3532. { }
  3533. };
  3534. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3535. * similar laptops (adapted from Fujitsu init verbs).
  3536. */
  3537. static struct hda_verb alc260_acer_init_verbs[] = {
  3538. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3539. * the headphone jack. Turn this on and rely on the standard mute
  3540. * methods whenever the user wants to turn these outputs off.
  3541. */
  3542. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3543. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3544. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3545. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3546. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3547. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3548. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3549. /* Line In jack is connected to Line1 pin */
  3550. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3551. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3552. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3553. /* Ensure all other unused pins are disabled and muted. */
  3554. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3555. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3556. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3557. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3558. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3559. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3560. /* Disable digital (SPDIF) pins */
  3561. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3562. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3563. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3564. * bus when acting as outputs.
  3565. */
  3566. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3567. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3568. /* Start with output sum widgets muted and their output gains at min */
  3569. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3570. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3571. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3572. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3573. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3574. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3575. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3576. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3577. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3578. /* Unmute Line-out pin widget amp left and right
  3579. * (no equiv mixer ctrl)
  3580. */
  3581. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3582. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3583. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3584. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3585. * inputs. If the pin mode is changed by the user the pin mode control
  3586. * will take care of enabling the pin's input/output buffers as needed.
  3587. * Therefore there's no need to enable the input buffer at this
  3588. * stage.
  3589. */
  3590. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3591. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3592. /* Mute capture amp left and right */
  3593. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3594. /* Set ADC connection select to match default mixer setting - mic
  3595. * (on mic1 pin)
  3596. */
  3597. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3598. /* Do similar with the second ADC: mute capture input amp and
  3599. * set ADC connection to mic to match ALSA's default state.
  3600. */
  3601. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3602. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3603. /* Mute all inputs to mixer widget (even unconnected ones) */
  3604. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3605. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3606. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3607. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3608. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3609. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3610. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3611. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3612. { }
  3613. };
  3614. static struct hda_verb alc260_will_verbs[] = {
  3615. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3616. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3617. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3618. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3619. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3620. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3621. {}
  3622. };
  3623. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3624. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3625. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3626. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3627. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3628. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3629. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3630. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3631. {}
  3632. };
  3633. /* toggle speaker-output according to the hp-jack state */
  3634. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3635. {
  3636. unsigned int present;
  3637. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3638. present = snd_hda_codec_read(codec, 0x0f, 0,
  3639. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3640. if (present) {
  3641. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3642. snd_hda_codec_write(codec, 0x0f, 0,
  3643. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3644. } else {
  3645. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3646. snd_hda_codec_write(codec, 0x0f, 0,
  3647. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3648. }
  3649. }
  3650. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3651. unsigned int res)
  3652. {
  3653. if ((res >> 26) == ALC880_HP_EVENT)
  3654. alc260_replacer_672v_automute(codec);
  3655. }
  3656. /* Test configuration for debugging, modelled after the ALC880 test
  3657. * configuration.
  3658. */
  3659. #ifdef CONFIG_SND_DEBUG
  3660. static hda_nid_t alc260_test_dac_nids[1] = {
  3661. 0x02,
  3662. };
  3663. static hda_nid_t alc260_test_adc_nids[2] = {
  3664. 0x04, 0x05,
  3665. };
  3666. /* For testing the ALC260, each input MUX needs its own definition since
  3667. * the signal assignments are different. This assumes that the first ADC
  3668. * is NID 0x04.
  3669. */
  3670. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3671. {
  3672. .num_items = 7,
  3673. .items = {
  3674. { "MIC1 pin", 0x0 },
  3675. { "MIC2 pin", 0x1 },
  3676. { "LINE1 pin", 0x2 },
  3677. { "LINE2 pin", 0x3 },
  3678. { "CD pin", 0x4 },
  3679. { "LINE-OUT pin", 0x5 },
  3680. { "HP-OUT pin", 0x6 },
  3681. },
  3682. },
  3683. {
  3684. .num_items = 8,
  3685. .items = {
  3686. { "MIC1 pin", 0x0 },
  3687. { "MIC2 pin", 0x1 },
  3688. { "LINE1 pin", 0x2 },
  3689. { "LINE2 pin", 0x3 },
  3690. { "CD pin", 0x4 },
  3691. { "Mixer", 0x5 },
  3692. { "LINE-OUT pin", 0x6 },
  3693. { "HP-OUT pin", 0x7 },
  3694. },
  3695. },
  3696. };
  3697. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3698. /* Output driver widgets */
  3699. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3700. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3701. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3702. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3703. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3704. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3705. /* Modes for retasking pin widgets
  3706. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3707. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3708. * mention this restriction. At this stage it's not clear whether
  3709. * this behaviour is intentional or is a hardware bug in chip
  3710. * revisions available at least up until early 2006. Therefore for
  3711. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3712. * choices, but if it turns out that the lack of mic bias for these
  3713. * NIDs is intentional we could change their modes from
  3714. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3715. */
  3716. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3717. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3718. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3719. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3720. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3721. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3722. /* Loopback mixer controls */
  3723. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3724. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3725. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3726. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3727. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3728. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3729. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3730. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3731. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3732. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3733. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3734. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3735. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3736. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3737. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3738. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3739. /* Controls for GPIO pins, assuming they are configured as outputs */
  3740. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3741. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3742. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3743. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3744. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3745. * is ambigious as to which NID is which; testing on laptops which
  3746. * make this output available should provide clarification.
  3747. */
  3748. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3749. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3750. { } /* end */
  3751. };
  3752. static struct hda_verb alc260_test_init_verbs[] = {
  3753. /* Enable all GPIOs as outputs with an initial value of 0 */
  3754. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3755. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3756. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3757. /* Enable retasking pins as output, initially without power amp */
  3758. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3759. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3760. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3761. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3762. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3763. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3764. /* Disable digital (SPDIF) pins initially, but users can enable
  3765. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3766. * payload also sets the generation to 0, output to be in "consumer"
  3767. * PCM format, copyright asserted, no pre-emphasis and no validity
  3768. * control.
  3769. */
  3770. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3771. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3772. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3773. * OUT1 sum bus when acting as an output.
  3774. */
  3775. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3776. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3777. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3778. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3779. /* Start with output sum widgets muted and their output gains at min */
  3780. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3781. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3782. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3783. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3784. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3785. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3786. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3787. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3788. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3789. /* Unmute retasking pin widget output buffers since the default
  3790. * state appears to be output. As the pin mode is changed by the
  3791. * user the pin mode control will take care of enabling the pin's
  3792. * input/output buffers as needed.
  3793. */
  3794. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3795. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3796. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3797. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3798. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3799. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3800. /* Also unmute the mono-out pin widget */
  3801. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3802. /* Mute capture amp left and right */
  3803. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3804. /* Set ADC connection select to match default mixer setting (mic1
  3805. * pin)
  3806. */
  3807. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3808. /* Do the same for the second ADC: mute capture input amp and
  3809. * set ADC connection to mic1 pin
  3810. */
  3811. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3812. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3813. /* Mute all inputs to mixer widget (even unconnected ones) */
  3814. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3815. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3816. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3817. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3818. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3819. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3820. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3821. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3822. { }
  3823. };
  3824. #endif
  3825. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3826. .substreams = 1,
  3827. .channels_min = 2,
  3828. .channels_max = 2,
  3829. };
  3830. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3831. .substreams = 1,
  3832. .channels_min = 2,
  3833. .channels_max = 2,
  3834. };
  3835. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3836. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3837. /*
  3838. * for BIOS auto-configuration
  3839. */
  3840. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3841. const char *pfx)
  3842. {
  3843. hda_nid_t nid_vol;
  3844. unsigned long vol_val, sw_val;
  3845. char name[32];
  3846. int err;
  3847. if (nid >= 0x0f && nid < 0x11) {
  3848. nid_vol = nid - 0x7;
  3849. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3850. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3851. } else if (nid == 0x11) {
  3852. nid_vol = nid - 0x7;
  3853. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3854. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3855. } else if (nid >= 0x12 && nid <= 0x15) {
  3856. nid_vol = 0x08;
  3857. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3858. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3859. } else
  3860. return 0; /* N/A */
  3861. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3862. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3863. if (err < 0)
  3864. return err;
  3865. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3866. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3867. if (err < 0)
  3868. return err;
  3869. return 1;
  3870. }
  3871. /* add playback controls from the parsed DAC table */
  3872. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3873. const struct auto_pin_cfg *cfg)
  3874. {
  3875. hda_nid_t nid;
  3876. int err;
  3877. spec->multiout.num_dacs = 1;
  3878. spec->multiout.dac_nids = spec->private_dac_nids;
  3879. spec->multiout.dac_nids[0] = 0x02;
  3880. nid = cfg->line_out_pins[0];
  3881. if (nid) {
  3882. err = alc260_add_playback_controls(spec, nid, "Front");
  3883. if (err < 0)
  3884. return err;
  3885. }
  3886. nid = cfg->speaker_pins[0];
  3887. if (nid) {
  3888. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3889. if (err < 0)
  3890. return err;
  3891. }
  3892. nid = cfg->hp_pins[0];
  3893. if (nid) {
  3894. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3895. if (err < 0)
  3896. return err;
  3897. }
  3898. return 0;
  3899. }
  3900. /* create playback/capture controls for input pins */
  3901. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3902. const struct auto_pin_cfg *cfg)
  3903. {
  3904. struct hda_input_mux *imux = &spec->private_imux;
  3905. int i, err, idx;
  3906. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3907. if (cfg->input_pins[i] >= 0x12) {
  3908. idx = cfg->input_pins[i] - 0x12;
  3909. err = new_analog_input(spec, cfg->input_pins[i],
  3910. auto_pin_cfg_labels[i], idx,
  3911. 0x07);
  3912. if (err < 0)
  3913. return err;
  3914. imux->items[imux->num_items].label =
  3915. auto_pin_cfg_labels[i];
  3916. imux->items[imux->num_items].index = idx;
  3917. imux->num_items++;
  3918. }
  3919. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3920. idx = cfg->input_pins[i] - 0x09;
  3921. err = new_analog_input(spec, cfg->input_pins[i],
  3922. auto_pin_cfg_labels[i], idx,
  3923. 0x07);
  3924. if (err < 0)
  3925. return err;
  3926. imux->items[imux->num_items].label =
  3927. auto_pin_cfg_labels[i];
  3928. imux->items[imux->num_items].index = idx;
  3929. imux->num_items++;
  3930. }
  3931. }
  3932. return 0;
  3933. }
  3934. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3935. hda_nid_t nid, int pin_type,
  3936. int sel_idx)
  3937. {
  3938. /* set as output */
  3939. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3940. pin_type);
  3941. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3942. AMP_OUT_UNMUTE);
  3943. /* need the manual connection? */
  3944. if (nid >= 0x12) {
  3945. int idx = nid - 0x12;
  3946. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3947. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3948. }
  3949. }
  3950. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3951. {
  3952. struct alc_spec *spec = codec->spec;
  3953. hda_nid_t nid;
  3954. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  3955. nid = spec->autocfg.line_out_pins[0];
  3956. if (nid) {
  3957. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3958. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  3959. }
  3960. nid = spec->autocfg.speaker_pins[0];
  3961. if (nid)
  3962. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3963. nid = spec->autocfg.hp_pins[0];
  3964. if (nid)
  3965. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  3966. }
  3967. #define ALC260_PIN_CD_NID 0x16
  3968. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3969. {
  3970. struct alc_spec *spec = codec->spec;
  3971. int i;
  3972. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3973. hda_nid_t nid = spec->autocfg.input_pins[i];
  3974. if (nid >= 0x12) {
  3975. snd_hda_codec_write(codec, nid, 0,
  3976. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3977. i <= AUTO_PIN_FRONT_MIC ?
  3978. PIN_VREF80 : PIN_IN);
  3979. if (nid != ALC260_PIN_CD_NID)
  3980. snd_hda_codec_write(codec, nid, 0,
  3981. AC_VERB_SET_AMP_GAIN_MUTE,
  3982. AMP_OUT_MUTE);
  3983. }
  3984. }
  3985. }
  3986. /*
  3987. * generic initialization of ADC, input mixers and output mixers
  3988. */
  3989. static struct hda_verb alc260_volume_init_verbs[] = {
  3990. /*
  3991. * Unmute ADC0-1 and set the default input to mic-in
  3992. */
  3993. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3994. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3995. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3996. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3997. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3998. * mixer widget
  3999. * Note: PASD motherboards uses the Line In 2 as the input for
  4000. * front panel mic (mic 2)
  4001. */
  4002. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4003. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4004. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4005. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4006. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4007. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4008. /*
  4009. * Set up output mixers (0x08 - 0x0a)
  4010. */
  4011. /* set vol=0 to output mixers */
  4012. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4013. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4014. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4015. /* set up input amps for analog loopback */
  4016. /* Amp Indices: DAC = 0, mixer = 1 */
  4017. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4018. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4019. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4020. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4021. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4022. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4023. { }
  4024. };
  4025. static int alc260_parse_auto_config(struct hda_codec *codec)
  4026. {
  4027. struct alc_spec *spec = codec->spec;
  4028. unsigned int wcap;
  4029. int err;
  4030. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4031. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4032. alc260_ignore);
  4033. if (err < 0)
  4034. return err;
  4035. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4036. if (err < 0)
  4037. return err;
  4038. if (!spec->kctl_alloc)
  4039. return 0; /* can't find valid BIOS pin config */
  4040. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4041. if (err < 0)
  4042. return err;
  4043. spec->multiout.max_channels = 2;
  4044. if (spec->autocfg.dig_out_pin)
  4045. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4046. if (spec->kctl_alloc)
  4047. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4048. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4049. spec->num_mux_defs = 1;
  4050. spec->input_mux = &spec->private_imux;
  4051. /* check whether NID 0x04 is valid */
  4052. wcap = get_wcaps(codec, 0x04);
  4053. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4054. if (wcap != AC_WID_AUD_IN) {
  4055. spec->adc_nids = alc260_adc_nids_alt;
  4056. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4057. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4058. } else {
  4059. spec->adc_nids = alc260_adc_nids;
  4060. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4061. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4062. }
  4063. spec->num_mixers++;
  4064. return 1;
  4065. }
  4066. /* additional initialization for auto-configuration model */
  4067. static void alc260_auto_init(struct hda_codec *codec)
  4068. {
  4069. alc260_auto_init_multi_out(codec);
  4070. alc260_auto_init_analog_input(codec);
  4071. }
  4072. /*
  4073. * ALC260 configurations
  4074. */
  4075. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4076. [ALC260_BASIC] = "basic",
  4077. [ALC260_HP] = "hp",
  4078. [ALC260_HP_3013] = "hp-3013",
  4079. [ALC260_FUJITSU_S702X] = "fujitsu",
  4080. [ALC260_ACER] = "acer",
  4081. [ALC260_WILL] = "will",
  4082. [ALC260_REPLACER_672V] = "replacer",
  4083. #ifdef CONFIG_SND_DEBUG
  4084. [ALC260_TEST] = "test",
  4085. #endif
  4086. [ALC260_AUTO] = "auto",
  4087. };
  4088. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4089. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4090. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4091. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4092. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4093. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4094. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4095. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4096. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4097. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4098. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4099. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4100. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4101. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4102. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4103. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4104. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4105. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4106. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4107. {}
  4108. };
  4109. static struct alc_config_preset alc260_presets[] = {
  4110. [ALC260_BASIC] = {
  4111. .mixers = { alc260_base_output_mixer,
  4112. alc260_input_mixer,
  4113. alc260_pc_beep_mixer,
  4114. alc260_capture_mixer },
  4115. .init_verbs = { alc260_init_verbs },
  4116. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4117. .dac_nids = alc260_dac_nids,
  4118. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4119. .adc_nids = alc260_adc_nids,
  4120. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4121. .channel_mode = alc260_modes,
  4122. .input_mux = &alc260_capture_source,
  4123. },
  4124. [ALC260_HP] = {
  4125. .mixers = { alc260_base_output_mixer,
  4126. alc260_input_mixer,
  4127. alc260_capture_alt_mixer },
  4128. .init_verbs = { alc260_init_verbs },
  4129. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4130. .dac_nids = alc260_dac_nids,
  4131. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4132. .adc_nids = alc260_hp_adc_nids,
  4133. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4134. .channel_mode = alc260_modes,
  4135. .input_mux = &alc260_capture_source,
  4136. },
  4137. [ALC260_HP_3013] = {
  4138. .mixers = { alc260_hp_3013_mixer,
  4139. alc260_input_mixer,
  4140. alc260_capture_alt_mixer },
  4141. .init_verbs = { alc260_hp_3013_init_verbs },
  4142. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4143. .dac_nids = alc260_dac_nids,
  4144. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4145. .adc_nids = alc260_hp_adc_nids,
  4146. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4147. .channel_mode = alc260_modes,
  4148. .input_mux = &alc260_capture_source,
  4149. },
  4150. [ALC260_FUJITSU_S702X] = {
  4151. .mixers = { alc260_fujitsu_mixer,
  4152. alc260_capture_mixer },
  4153. .init_verbs = { alc260_fujitsu_init_verbs },
  4154. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4155. .dac_nids = alc260_dac_nids,
  4156. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4157. .adc_nids = alc260_dual_adc_nids,
  4158. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4159. .channel_mode = alc260_modes,
  4160. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4161. .input_mux = alc260_fujitsu_capture_sources,
  4162. },
  4163. [ALC260_ACER] = {
  4164. .mixers = { alc260_acer_mixer,
  4165. alc260_capture_mixer },
  4166. .init_verbs = { alc260_acer_init_verbs },
  4167. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4168. .dac_nids = alc260_dac_nids,
  4169. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4170. .adc_nids = alc260_dual_adc_nids,
  4171. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4172. .channel_mode = alc260_modes,
  4173. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4174. .input_mux = alc260_acer_capture_sources,
  4175. },
  4176. [ALC260_WILL] = {
  4177. .mixers = { alc260_will_mixer,
  4178. alc260_capture_mixer },
  4179. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4180. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4181. .dac_nids = alc260_dac_nids,
  4182. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4183. .adc_nids = alc260_adc_nids,
  4184. .dig_out_nid = ALC260_DIGOUT_NID,
  4185. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4186. .channel_mode = alc260_modes,
  4187. .input_mux = &alc260_capture_source,
  4188. },
  4189. [ALC260_REPLACER_672V] = {
  4190. .mixers = { alc260_replacer_672v_mixer,
  4191. alc260_capture_mixer },
  4192. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4193. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4194. .dac_nids = alc260_dac_nids,
  4195. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4196. .adc_nids = alc260_adc_nids,
  4197. .dig_out_nid = ALC260_DIGOUT_NID,
  4198. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4199. .channel_mode = alc260_modes,
  4200. .input_mux = &alc260_capture_source,
  4201. .unsol_event = alc260_replacer_672v_unsol_event,
  4202. .init_hook = alc260_replacer_672v_automute,
  4203. },
  4204. #ifdef CONFIG_SND_DEBUG
  4205. [ALC260_TEST] = {
  4206. .mixers = { alc260_test_mixer,
  4207. alc260_capture_mixer },
  4208. .init_verbs = { alc260_test_init_verbs },
  4209. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4210. .dac_nids = alc260_test_dac_nids,
  4211. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4212. .adc_nids = alc260_test_adc_nids,
  4213. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4214. .channel_mode = alc260_modes,
  4215. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4216. .input_mux = alc260_test_capture_sources,
  4217. },
  4218. #endif
  4219. };
  4220. static int patch_alc260(struct hda_codec *codec)
  4221. {
  4222. struct alc_spec *spec;
  4223. int err, board_config;
  4224. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4225. if (spec == NULL)
  4226. return -ENOMEM;
  4227. codec->spec = spec;
  4228. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4229. alc260_models,
  4230. alc260_cfg_tbl);
  4231. if (board_config < 0) {
  4232. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4233. "trying auto-probe from BIOS...\n");
  4234. board_config = ALC260_AUTO;
  4235. }
  4236. if (board_config == ALC260_AUTO) {
  4237. /* automatic parse from the BIOS config */
  4238. err = alc260_parse_auto_config(codec);
  4239. if (err < 0) {
  4240. alc_free(codec);
  4241. return err;
  4242. } else if (!err) {
  4243. printk(KERN_INFO
  4244. "hda_codec: Cannot set up configuration "
  4245. "from BIOS. Using base mode...\n");
  4246. board_config = ALC260_BASIC;
  4247. }
  4248. }
  4249. if (board_config != ALC260_AUTO)
  4250. setup_preset(spec, &alc260_presets[board_config]);
  4251. spec->stream_name_analog = "ALC260 Analog";
  4252. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4253. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4254. spec->stream_name_digital = "ALC260 Digital";
  4255. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4256. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4257. codec->patch_ops = alc_patch_ops;
  4258. if (board_config == ALC260_AUTO)
  4259. spec->init_hook = alc260_auto_init;
  4260. return 0;
  4261. }
  4262. /*
  4263. * ALC882 support
  4264. *
  4265. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4266. * configuration. Each pin widget can choose any input DACs and a mixer.
  4267. * Each ADC is connected from a mixer of all inputs. This makes possible
  4268. * 6-channel independent captures.
  4269. *
  4270. * In addition, an independent DAC for the multi-playback (not used in this
  4271. * driver yet).
  4272. */
  4273. #define ALC882_DIGOUT_NID 0x06
  4274. #define ALC882_DIGIN_NID 0x0a
  4275. static struct hda_channel_mode alc882_ch_modes[1] = {
  4276. { 8, NULL }
  4277. };
  4278. static hda_nid_t alc882_dac_nids[4] = {
  4279. /* front, rear, clfe, rear_surr */
  4280. 0x02, 0x03, 0x04, 0x05
  4281. };
  4282. /* identical with ALC880 */
  4283. #define alc882_adc_nids alc880_adc_nids
  4284. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4285. /* input MUX */
  4286. /* FIXME: should be a matrix-type input source selection */
  4287. static struct hda_input_mux alc882_capture_source = {
  4288. .num_items = 4,
  4289. .items = {
  4290. { "Mic", 0x0 },
  4291. { "Front Mic", 0x1 },
  4292. { "Line", 0x2 },
  4293. { "CD", 0x4 },
  4294. },
  4295. };
  4296. #define alc882_mux_enum_info alc_mux_enum_info
  4297. #define alc882_mux_enum_get alc_mux_enum_get
  4298. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4299. struct snd_ctl_elem_value *ucontrol)
  4300. {
  4301. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4302. struct alc_spec *spec = codec->spec;
  4303. const struct hda_input_mux *imux = spec->input_mux;
  4304. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4305. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4306. hda_nid_t nid = capture_mixers[adc_idx];
  4307. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4308. unsigned int i, idx;
  4309. idx = ucontrol->value.enumerated.item[0];
  4310. if (idx >= imux->num_items)
  4311. idx = imux->num_items - 1;
  4312. if (*cur_val == idx && !codec->in_resume)
  4313. return 0;
  4314. for (i = 0; i < imux->num_items; i++) {
  4315. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4316. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4317. v | (imux->items[i].index << 8));
  4318. }
  4319. *cur_val = idx;
  4320. return 1;
  4321. }
  4322. /*
  4323. * 2ch mode
  4324. */
  4325. static struct hda_verb alc882_3ST_ch2_init[] = {
  4326. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4327. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4328. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4329. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4330. { } /* end */
  4331. };
  4332. /*
  4333. * 6ch mode
  4334. */
  4335. static struct hda_verb alc882_3ST_ch6_init[] = {
  4336. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4337. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4338. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4339. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4340. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4341. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4342. { } /* end */
  4343. };
  4344. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4345. { 2, alc882_3ST_ch2_init },
  4346. { 6, alc882_3ST_ch6_init },
  4347. };
  4348. /*
  4349. * 6ch mode
  4350. */
  4351. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4352. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4353. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4354. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4355. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4356. { } /* end */
  4357. };
  4358. /*
  4359. * 8ch mode
  4360. */
  4361. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4362. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4363. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4364. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4365. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4366. { } /* end */
  4367. };
  4368. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4369. { 6, alc882_sixstack_ch6_init },
  4370. { 8, alc882_sixstack_ch8_init },
  4371. };
  4372. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4373. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4374. */
  4375. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4376. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4377. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4378. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4379. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4380. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4381. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4382. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4383. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4384. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4385. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4386. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4387. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4388. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4389. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4390. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4391. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4392. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4393. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4394. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4395. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4396. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4397. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4398. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4399. { } /* end */
  4400. };
  4401. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4402. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4403. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4404. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4405. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4406. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4407. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4408. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4409. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4410. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4411. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4412. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4413. { } /* end */
  4414. };
  4415. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4416. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4417. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4418. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4419. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4420. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4421. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4422. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4423. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4424. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4425. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4426. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4427. { } /* end */
  4428. };
  4429. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4430. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4431. */
  4432. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4433. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4434. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4435. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4436. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4437. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4438. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4439. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4440. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4441. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4442. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4443. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4444. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4445. { } /* end */
  4446. };
  4447. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4448. {
  4449. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4450. .name = "Channel Mode",
  4451. .info = alc_ch_mode_info,
  4452. .get = alc_ch_mode_get,
  4453. .put = alc_ch_mode_put,
  4454. },
  4455. { } /* end */
  4456. };
  4457. static struct hda_verb alc882_init_verbs[] = {
  4458. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4459. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4460. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4461. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4462. /* Rear mixer */
  4463. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4464. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4465. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4466. /* CLFE mixer */
  4467. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4468. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4469. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4470. /* Side mixer */
  4471. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4472. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4473. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4474. /* Front Pin: output 0 (0x0c) */
  4475. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4476. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4477. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4478. /* Rear Pin: output 1 (0x0d) */
  4479. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4480. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4481. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4482. /* CLFE Pin: output 2 (0x0e) */
  4483. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4484. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4485. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4486. /* Side Pin: output 3 (0x0f) */
  4487. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4488. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4489. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4490. /* Mic (rear) pin: input vref at 80% */
  4491. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4492. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4493. /* Front Mic pin: input vref at 80% */
  4494. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4495. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4496. /* Line In pin: input */
  4497. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4498. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4499. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4500. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4501. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4502. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4503. /* CD pin widget for input */
  4504. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4505. /* FIXME: use matrix-type input source selection */
  4506. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4507. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4508. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4509. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4510. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4511. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4512. /* Input mixer2 */
  4513. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4514. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4515. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4516. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4517. /* Input mixer3 */
  4518. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4519. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4520. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4521. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4522. /* ADC1: mute amp left and right */
  4523. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4524. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4525. /* ADC2: mute amp left and right */
  4526. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4527. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4528. /* ADC3: mute amp left and right */
  4529. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4530. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4531. { }
  4532. };
  4533. static struct hda_verb alc882_eapd_verbs[] = {
  4534. /* change to EAPD mode */
  4535. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4536. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4537. { }
  4538. };
  4539. /* Mac Pro test */
  4540. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4541. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4542. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4543. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4544. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4545. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4546. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4547. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4548. { } /* end */
  4549. };
  4550. static struct hda_verb alc882_macpro_init_verbs[] = {
  4551. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4552. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4553. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4554. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4555. /* Front Pin: output 0 (0x0c) */
  4556. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4557. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4558. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4559. /* Front Mic pin: input vref at 80% */
  4560. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4561. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4562. /* Speaker: output */
  4563. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4564. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4565. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4566. /* Headphone output (output 0 - 0x0c) */
  4567. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4568. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4569. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4570. /* FIXME: use matrix-type input source selection */
  4571. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4572. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4573. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4574. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4575. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4576. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4577. /* Input mixer2 */
  4578. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4579. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4580. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4581. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4582. /* Input mixer3 */
  4583. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4584. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4585. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4586. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4587. /* ADC1: mute amp left and right */
  4588. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4589. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4590. /* ADC2: mute amp left and right */
  4591. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4592. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4593. /* ADC3: mute amp left and right */
  4594. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4595. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4596. { }
  4597. };
  4598. static struct hda_verb alc882_targa_verbs[] = {
  4599. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4600. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4601. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4602. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4603. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4604. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4605. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4606. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4607. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4608. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4609. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4610. { } /* end */
  4611. };
  4612. /* toggle speaker-output according to the hp-jack state */
  4613. static void alc882_targa_automute(struct hda_codec *codec)
  4614. {
  4615. unsigned int present;
  4616. present = snd_hda_codec_read(codec, 0x14, 0,
  4617. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4618. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4619. 0x80, present ? 0x80 : 0);
  4620. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4621. 0x80, present ? 0x80 : 0);
  4622. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4623. }
  4624. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4625. {
  4626. /* Looks like the unsol event is incompatible with the standard
  4627. * definition. 4bit tag is placed at 26 bit!
  4628. */
  4629. if (((res >> 26) == ALC880_HP_EVENT)) {
  4630. alc882_targa_automute(codec);
  4631. }
  4632. }
  4633. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4634. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4635. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4636. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4637. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4638. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4639. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4640. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4641. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4642. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4643. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4644. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4645. { } /* end */
  4646. };
  4647. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4648. {
  4649. unsigned int gpiostate, gpiomask, gpiodir;
  4650. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4651. AC_VERB_GET_GPIO_DATA, 0);
  4652. if (!muted)
  4653. gpiostate |= (1 << pin);
  4654. else
  4655. gpiostate &= ~(1 << pin);
  4656. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4657. AC_VERB_GET_GPIO_MASK, 0);
  4658. gpiomask |= (1 << pin);
  4659. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4660. AC_VERB_GET_GPIO_DIRECTION, 0);
  4661. gpiodir |= (1 << pin);
  4662. snd_hda_codec_write(codec, codec->afg, 0,
  4663. AC_VERB_SET_GPIO_MASK, gpiomask);
  4664. snd_hda_codec_write(codec, codec->afg, 0,
  4665. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4666. msleep(1);
  4667. snd_hda_codec_write(codec, codec->afg, 0,
  4668. AC_VERB_SET_GPIO_DATA, gpiostate);
  4669. }
  4670. /*
  4671. * generic initialization of ADC, input mixers and output mixers
  4672. */
  4673. static struct hda_verb alc882_auto_init_verbs[] = {
  4674. /*
  4675. * Unmute ADC0-2 and set the default input to mic-in
  4676. */
  4677. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4678. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4679. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4680. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4681. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4682. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4683. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4684. * mixer widget
  4685. * Note: PASD motherboards uses the Line In 2 as the input for
  4686. * front panel mic (mic 2)
  4687. */
  4688. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4689. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4690. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4691. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4692. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4693. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4694. /*
  4695. * Set up output mixers (0x0c - 0x0f)
  4696. */
  4697. /* set vol=0 to output mixers */
  4698. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4699. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4700. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4701. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4702. /* set up input amps for analog loopback */
  4703. /* Amp Indices: DAC = 0, mixer = 1 */
  4704. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4705. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4706. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4707. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4708. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4709. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4710. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4711. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4712. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4713. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4714. /* FIXME: use matrix-type input source selection */
  4715. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4716. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4717. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4718. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4719. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4720. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4721. /* Input mixer2 */
  4722. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4723. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4724. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4725. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4726. /* Input mixer3 */
  4727. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4728. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4729. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4730. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4731. { }
  4732. };
  4733. /* capture mixer elements */
  4734. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4735. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4736. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4737. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4738. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4739. {
  4740. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4741. /* The multiple "Capture Source" controls confuse alsamixer
  4742. * So call somewhat different..
  4743. * FIXME: the controls appear in the "playback" view!
  4744. */
  4745. /* .name = "Capture Source", */
  4746. .name = "Input Source",
  4747. .count = 2,
  4748. .info = alc882_mux_enum_info,
  4749. .get = alc882_mux_enum_get,
  4750. .put = alc882_mux_enum_put,
  4751. },
  4752. { } /* end */
  4753. };
  4754. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4755. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4756. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4757. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4758. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4759. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4760. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4761. {
  4762. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4763. /* The multiple "Capture Source" controls confuse alsamixer
  4764. * So call somewhat different..
  4765. * FIXME: the controls appear in the "playback" view!
  4766. */
  4767. /* .name = "Capture Source", */
  4768. .name = "Input Source",
  4769. .count = 3,
  4770. .info = alc882_mux_enum_info,
  4771. .get = alc882_mux_enum_get,
  4772. .put = alc882_mux_enum_put,
  4773. },
  4774. { } /* end */
  4775. };
  4776. /* pcm configuration: identiacal with ALC880 */
  4777. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4778. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4779. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4780. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4781. /*
  4782. * configuration and preset
  4783. */
  4784. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4785. [ALC882_3ST_DIG] = "3stack-dig",
  4786. [ALC882_6ST_DIG] = "6stack-dig",
  4787. [ALC882_ARIMA] = "arima",
  4788. [ALC882_W2JC] = "w2jc",
  4789. [ALC885_MACPRO] = "macpro",
  4790. [ALC882_AUTO] = "auto",
  4791. };
  4792. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4793. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4794. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4795. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4796. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4797. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4798. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4799. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4800. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4801. {}
  4802. };
  4803. static struct alc_config_preset alc882_presets[] = {
  4804. [ALC882_3ST_DIG] = {
  4805. .mixers = { alc882_base_mixer },
  4806. .init_verbs = { alc882_init_verbs },
  4807. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4808. .dac_nids = alc882_dac_nids,
  4809. .dig_out_nid = ALC882_DIGOUT_NID,
  4810. .dig_in_nid = ALC882_DIGIN_NID,
  4811. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4812. .channel_mode = alc882_ch_modes,
  4813. .need_dac_fix = 1,
  4814. .input_mux = &alc882_capture_source,
  4815. },
  4816. [ALC882_6ST_DIG] = {
  4817. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4818. .init_verbs = { alc882_init_verbs },
  4819. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4820. .dac_nids = alc882_dac_nids,
  4821. .dig_out_nid = ALC882_DIGOUT_NID,
  4822. .dig_in_nid = ALC882_DIGIN_NID,
  4823. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4824. .channel_mode = alc882_sixstack_modes,
  4825. .input_mux = &alc882_capture_source,
  4826. },
  4827. [ALC882_ARIMA] = {
  4828. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4829. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4830. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4831. .dac_nids = alc882_dac_nids,
  4832. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4833. .channel_mode = alc882_sixstack_modes,
  4834. .input_mux = &alc882_capture_source,
  4835. },
  4836. [ALC882_W2JC] = {
  4837. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4838. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4839. alc880_gpio1_init_verbs },
  4840. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4841. .dac_nids = alc882_dac_nids,
  4842. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4843. .channel_mode = alc880_threestack_modes,
  4844. .need_dac_fix = 1,
  4845. .input_mux = &alc882_capture_source,
  4846. .dig_out_nid = ALC882_DIGOUT_NID,
  4847. },
  4848. [ALC885_MACPRO] = {
  4849. .mixers = { alc882_macpro_mixer },
  4850. .init_verbs = { alc882_macpro_init_verbs },
  4851. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4852. .dac_nids = alc882_dac_nids,
  4853. .dig_out_nid = ALC882_DIGOUT_NID,
  4854. .dig_in_nid = ALC882_DIGIN_NID,
  4855. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4856. .channel_mode = alc882_ch_modes,
  4857. .input_mux = &alc882_capture_source,
  4858. },
  4859. [ALC882_TARGA] = {
  4860. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4861. alc882_capture_mixer },
  4862. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4863. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4864. .dac_nids = alc882_dac_nids,
  4865. .dig_out_nid = ALC882_DIGOUT_NID,
  4866. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4867. .adc_nids = alc882_adc_nids,
  4868. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4869. .channel_mode = alc882_3ST_6ch_modes,
  4870. .need_dac_fix = 1,
  4871. .input_mux = &alc882_capture_source,
  4872. .unsol_event = alc882_targa_unsol_event,
  4873. .init_hook = alc882_targa_automute,
  4874. },
  4875. [ALC882_ASUS_A7J] = {
  4876. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4877. alc882_capture_mixer },
  4878. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4879. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4880. .dac_nids = alc882_dac_nids,
  4881. .dig_out_nid = ALC882_DIGOUT_NID,
  4882. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4883. .adc_nids = alc882_adc_nids,
  4884. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4885. .channel_mode = alc882_3ST_6ch_modes,
  4886. .need_dac_fix = 1,
  4887. .input_mux = &alc882_capture_source,
  4888. },
  4889. };
  4890. /*
  4891. * BIOS auto configuration
  4892. */
  4893. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4894. hda_nid_t nid, int pin_type,
  4895. int dac_idx)
  4896. {
  4897. /* set as output */
  4898. struct alc_spec *spec = codec->spec;
  4899. int idx;
  4900. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4901. idx = 4;
  4902. else
  4903. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4904. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4905. pin_type);
  4906. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4907. AMP_OUT_UNMUTE);
  4908. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4909. }
  4910. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4911. {
  4912. struct alc_spec *spec = codec->spec;
  4913. int i;
  4914. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4915. for (i = 0; i <= HDA_SIDE; i++) {
  4916. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4917. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4918. if (nid)
  4919. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  4920. i);
  4921. }
  4922. }
  4923. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4924. {
  4925. struct alc_spec *spec = codec->spec;
  4926. hda_nid_t pin;
  4927. pin = spec->autocfg.hp_pins[0];
  4928. if (pin) /* connect to front */
  4929. /* use dac 0 */
  4930. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4931. }
  4932. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4933. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4934. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4935. {
  4936. struct alc_spec *spec = codec->spec;
  4937. int i;
  4938. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4939. hda_nid_t nid = spec->autocfg.input_pins[i];
  4940. if (alc882_is_input_pin(nid)) {
  4941. snd_hda_codec_write(codec, nid, 0,
  4942. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4943. i <= AUTO_PIN_FRONT_MIC ?
  4944. PIN_VREF80 : PIN_IN);
  4945. if (nid != ALC882_PIN_CD_NID)
  4946. snd_hda_codec_write(codec, nid, 0,
  4947. AC_VERB_SET_AMP_GAIN_MUTE,
  4948. AMP_OUT_MUTE);
  4949. }
  4950. }
  4951. }
  4952. /* almost identical with ALC880 parser... */
  4953. static int alc882_parse_auto_config(struct hda_codec *codec)
  4954. {
  4955. struct alc_spec *spec = codec->spec;
  4956. int err = alc880_parse_auto_config(codec);
  4957. if (err < 0)
  4958. return err;
  4959. else if (err > 0)
  4960. /* hack - override the init verbs */
  4961. spec->init_verbs[0] = alc882_auto_init_verbs;
  4962. return err;
  4963. }
  4964. /* additional initialization for auto-configuration model */
  4965. static void alc882_auto_init(struct hda_codec *codec)
  4966. {
  4967. alc882_auto_init_multi_out(codec);
  4968. alc882_auto_init_hp_out(codec);
  4969. alc882_auto_init_analog_input(codec);
  4970. }
  4971. static int patch_alc882(struct hda_codec *codec)
  4972. {
  4973. struct alc_spec *spec;
  4974. int err, board_config;
  4975. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4976. if (spec == NULL)
  4977. return -ENOMEM;
  4978. codec->spec = spec;
  4979. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4980. alc882_models,
  4981. alc882_cfg_tbl);
  4982. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4983. /* Pick up systems that don't supply PCI SSID */
  4984. switch (codec->subsystem_id) {
  4985. case 0x106b0c00: /* Mac Pro */
  4986. board_config = ALC885_MACPRO;
  4987. break;
  4988. default:
  4989. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4990. "trying auto-probe from BIOS...\n");
  4991. board_config = ALC882_AUTO;
  4992. }
  4993. }
  4994. if (board_config == ALC882_AUTO) {
  4995. /* automatic parse from the BIOS config */
  4996. err = alc882_parse_auto_config(codec);
  4997. if (err < 0) {
  4998. alc_free(codec);
  4999. return err;
  5000. } else if (!err) {
  5001. printk(KERN_INFO
  5002. "hda_codec: Cannot set up configuration "
  5003. "from BIOS. Using base mode...\n");
  5004. board_config = ALC882_3ST_DIG;
  5005. }
  5006. }
  5007. if (board_config != ALC882_AUTO)
  5008. setup_preset(spec, &alc882_presets[board_config]);
  5009. if (board_config == ALC885_MACPRO) {
  5010. alc882_gpio_mute(codec, 0, 0);
  5011. alc882_gpio_mute(codec, 1, 0);
  5012. }
  5013. spec->stream_name_analog = "ALC882 Analog";
  5014. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5015. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5016. spec->stream_name_digital = "ALC882 Digital";
  5017. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5018. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5019. if (!spec->adc_nids && spec->input_mux) {
  5020. /* check whether NID 0x07 is valid */
  5021. unsigned int wcap = get_wcaps(codec, 0x07);
  5022. /* get type */
  5023. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5024. if (wcap != AC_WID_AUD_IN) {
  5025. spec->adc_nids = alc882_adc_nids_alt;
  5026. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5027. spec->mixers[spec->num_mixers] =
  5028. alc882_capture_alt_mixer;
  5029. spec->num_mixers++;
  5030. } else {
  5031. spec->adc_nids = alc882_adc_nids;
  5032. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5033. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5034. spec->num_mixers++;
  5035. }
  5036. }
  5037. codec->patch_ops = alc_patch_ops;
  5038. if (board_config == ALC882_AUTO)
  5039. spec->init_hook = alc882_auto_init;
  5040. return 0;
  5041. }
  5042. /*
  5043. * ALC883 support
  5044. *
  5045. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5046. * configuration. Each pin widget can choose any input DACs and a mixer.
  5047. * Each ADC is connected from a mixer of all inputs. This makes possible
  5048. * 6-channel independent captures.
  5049. *
  5050. * In addition, an independent DAC for the multi-playback (not used in this
  5051. * driver yet).
  5052. */
  5053. #define ALC883_DIGOUT_NID 0x06
  5054. #define ALC883_DIGIN_NID 0x0a
  5055. static hda_nid_t alc883_dac_nids[4] = {
  5056. /* front, rear, clfe, rear_surr */
  5057. 0x02, 0x04, 0x03, 0x05
  5058. };
  5059. static hda_nid_t alc883_adc_nids[2] = {
  5060. /* ADC1-2 */
  5061. 0x08, 0x09,
  5062. };
  5063. /* input MUX */
  5064. /* FIXME: should be a matrix-type input source selection */
  5065. static struct hda_input_mux alc883_capture_source = {
  5066. .num_items = 4,
  5067. .items = {
  5068. { "Mic", 0x0 },
  5069. { "Front Mic", 0x1 },
  5070. { "Line", 0x2 },
  5071. { "CD", 0x4 },
  5072. },
  5073. };
  5074. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5075. .num_items = 2,
  5076. .items = {
  5077. { "Mic", 0x1 },
  5078. { "Line", 0x2 },
  5079. },
  5080. };
  5081. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5082. .num_items = 4,
  5083. .items = {
  5084. { "Mic", 0x0 },
  5085. { "iMic", 0x1 },
  5086. { "Line", 0x2 },
  5087. { "CD", 0x4 },
  5088. },
  5089. };
  5090. #define alc883_mux_enum_info alc_mux_enum_info
  5091. #define alc883_mux_enum_get alc_mux_enum_get
  5092. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5093. struct snd_ctl_elem_value *ucontrol)
  5094. {
  5095. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5096. struct alc_spec *spec = codec->spec;
  5097. const struct hda_input_mux *imux = spec->input_mux;
  5098. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5099. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5100. hda_nid_t nid = capture_mixers[adc_idx];
  5101. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5102. unsigned int i, idx;
  5103. idx = ucontrol->value.enumerated.item[0];
  5104. if (idx >= imux->num_items)
  5105. idx = imux->num_items - 1;
  5106. if (*cur_val == idx && !codec->in_resume)
  5107. return 0;
  5108. for (i = 0; i < imux->num_items; i++) {
  5109. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5110. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5111. v | (imux->items[i].index << 8));
  5112. }
  5113. *cur_val = idx;
  5114. return 1;
  5115. }
  5116. /*
  5117. * 2ch mode
  5118. */
  5119. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5120. { 2, NULL }
  5121. };
  5122. /*
  5123. * 2ch mode
  5124. */
  5125. static struct hda_verb alc883_3ST_ch2_init[] = {
  5126. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5127. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5128. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5129. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5130. { } /* end */
  5131. };
  5132. /*
  5133. * 6ch mode
  5134. */
  5135. static struct hda_verb alc883_3ST_ch6_init[] = {
  5136. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5137. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5138. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5139. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5140. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5141. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5142. { } /* end */
  5143. };
  5144. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5145. { 2, alc883_3ST_ch2_init },
  5146. { 6, alc883_3ST_ch6_init },
  5147. };
  5148. /*
  5149. * 6ch mode
  5150. */
  5151. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5152. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5153. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5154. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5155. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5156. { } /* end */
  5157. };
  5158. /*
  5159. * 8ch mode
  5160. */
  5161. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5162. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5163. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5164. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5165. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5166. { } /* end */
  5167. };
  5168. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5169. { 6, alc883_sixstack_ch6_init },
  5170. { 8, alc883_sixstack_ch8_init },
  5171. };
  5172. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5173. /* eanable EAPD on medion laptop */
  5174. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5175. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5176. { }
  5177. };
  5178. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5179. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5180. */
  5181. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5182. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5183. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5184. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5185. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5186. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5187. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5188. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5189. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5190. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5191. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5192. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5193. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5194. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5195. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5196. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5197. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5198. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5199. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5200. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5201. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5202. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5203. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5204. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5205. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5206. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5207. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5208. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5209. {
  5210. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5211. /* .name = "Capture Source", */
  5212. .name = "Input Source",
  5213. .count = 2,
  5214. .info = alc883_mux_enum_info,
  5215. .get = alc883_mux_enum_get,
  5216. .put = alc883_mux_enum_put,
  5217. },
  5218. { } /* end */
  5219. };
  5220. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5221. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5222. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5223. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5224. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5225. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5226. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5227. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5228. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5229. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5230. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5231. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5232. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5233. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5234. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5235. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5236. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5237. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5238. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5239. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5240. {
  5241. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5242. /* .name = "Capture Source", */
  5243. .name = "Input Source",
  5244. .count = 2,
  5245. .info = alc883_mux_enum_info,
  5246. .get = alc883_mux_enum_get,
  5247. .put = alc883_mux_enum_put,
  5248. },
  5249. { } /* end */
  5250. };
  5251. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5252. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5253. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5254. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5255. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5256. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5257. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5258. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5259. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5260. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5261. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5262. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5263. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5264. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5265. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5266. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5267. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5268. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5269. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5270. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5271. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5272. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5273. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5274. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5275. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5276. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5277. {
  5278. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5279. /* .name = "Capture Source", */
  5280. .name = "Input Source",
  5281. .count = 2,
  5282. .info = alc883_mux_enum_info,
  5283. .get = alc883_mux_enum_get,
  5284. .put = alc883_mux_enum_put,
  5285. },
  5286. { } /* end */
  5287. };
  5288. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5289. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5290. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5291. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5292. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5293. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5294. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5295. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5296. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5297. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5298. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5299. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5300. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5301. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5302. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5303. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5304. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5305. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5306. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5307. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5308. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5309. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5310. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5311. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5312. {
  5313. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5314. /* .name = "Capture Source", */
  5315. .name = "Input Source",
  5316. .count = 1,
  5317. .info = alc883_mux_enum_info,
  5318. .get = alc883_mux_enum_get,
  5319. .put = alc883_mux_enum_put,
  5320. },
  5321. { } /* end */
  5322. };
  5323. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5324. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5325. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5326. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5327. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5328. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5329. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5330. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5331. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5332. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5333. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5334. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5335. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5336. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5337. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5338. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5339. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5340. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5341. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5342. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5343. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5344. {
  5345. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5346. /* .name = "Capture Source", */
  5347. .name = "Input Source",
  5348. .count = 2,
  5349. .info = alc883_mux_enum_info,
  5350. .get = alc883_mux_enum_get,
  5351. .put = alc883_mux_enum_put,
  5352. },
  5353. { } /* end */
  5354. };
  5355. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5356. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5357. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5358. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5359. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5360. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5361. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5362. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5363. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5364. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5365. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5366. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5367. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5368. {
  5369. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5370. /* .name = "Capture Source", */
  5371. .name = "Input Source",
  5372. .count = 2,
  5373. .info = alc883_mux_enum_info,
  5374. .get = alc883_mux_enum_get,
  5375. .put = alc883_mux_enum_put,
  5376. },
  5377. { } /* end */
  5378. };
  5379. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5380. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5381. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5382. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5383. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5384. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5385. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5386. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5387. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5388. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5389. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5390. {
  5391. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5392. /* .name = "Capture Source", */
  5393. .name = "Input Source",
  5394. .count = 1,
  5395. .info = alc883_mux_enum_info,
  5396. .get = alc883_mux_enum_get,
  5397. .put = alc883_mux_enum_put,
  5398. },
  5399. { } /* end */
  5400. };
  5401. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5402. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5403. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5404. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5405. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5406. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5407. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5408. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5409. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5410. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5411. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5412. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5413. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5414. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5415. {
  5416. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5417. /* .name = "Capture Source", */
  5418. .name = "Input Source",
  5419. .count = 2,
  5420. .info = alc883_mux_enum_info,
  5421. .get = alc883_mux_enum_get,
  5422. .put = alc883_mux_enum_put,
  5423. },
  5424. { } /* end */
  5425. };
  5426. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5427. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5428. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5429. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5430. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5431. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5432. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5433. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5434. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5435. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5436. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5437. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5438. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5439. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5440. {
  5441. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5442. /* .name = "Capture Source", */
  5443. .name = "Input Source",
  5444. .count = 2,
  5445. .info = alc883_mux_enum_info,
  5446. .get = alc883_mux_enum_get,
  5447. .put = alc883_mux_enum_put,
  5448. },
  5449. { } /* end */
  5450. };
  5451. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5452. {
  5453. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5454. .name = "Channel Mode",
  5455. .info = alc_ch_mode_info,
  5456. .get = alc_ch_mode_get,
  5457. .put = alc_ch_mode_put,
  5458. },
  5459. { } /* end */
  5460. };
  5461. static struct hda_verb alc883_init_verbs[] = {
  5462. /* ADC1: mute amp left and right */
  5463. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5464. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5465. /* ADC2: mute amp left and right */
  5466. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5467. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5468. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5469. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5470. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5471. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5472. /* Rear mixer */
  5473. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5474. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5475. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5476. /* CLFE mixer */
  5477. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5478. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5479. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5480. /* Side mixer */
  5481. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5482. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5483. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5484. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5485. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5486. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5487. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5488. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5489. /* Front Pin: output 0 (0x0c) */
  5490. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5491. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5492. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5493. /* Rear Pin: output 1 (0x0d) */
  5494. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5495. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5496. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5497. /* CLFE Pin: output 2 (0x0e) */
  5498. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5499. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5500. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5501. /* Side Pin: output 3 (0x0f) */
  5502. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5503. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5504. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5505. /* Mic (rear) pin: input vref at 80% */
  5506. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5507. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5508. /* Front Mic pin: input vref at 80% */
  5509. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5510. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5511. /* Line In pin: input */
  5512. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5513. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5514. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5515. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5516. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5517. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5518. /* CD pin widget for input */
  5519. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5520. /* FIXME: use matrix-type input source selection */
  5521. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5522. /* Input mixer2 */
  5523. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5524. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5525. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5526. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5527. /* Input mixer3 */
  5528. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5529. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5530. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5531. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5532. { }
  5533. };
  5534. static struct hda_verb alc883_tagra_verbs[] = {
  5535. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5536. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5537. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5538. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5539. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5540. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5541. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5542. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5543. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5544. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5545. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5546. { } /* end */
  5547. };
  5548. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5549. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5550. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5551. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5552. { } /* end */
  5553. };
  5554. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5555. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5556. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5557. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5558. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5559. { } /* end */
  5560. };
  5561. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5562. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5563. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5564. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5565. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5566. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5567. { } /* end */
  5568. };
  5569. /* toggle front-jack and RCA according to the hp-jack state */
  5570. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5571. {
  5572. unsigned int present;
  5573. present = snd_hda_codec_read(codec, 0x1b, 0,
  5574. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5575. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5576. 0x80, present ? 0x80 : 0);
  5577. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5578. 0x80, present ? 0x80 : 0);
  5579. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5580. 0x80, present ? 0x80 : 0);
  5581. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5582. 0x80, present ? 0x80 : 0);
  5583. }
  5584. /* toggle RCA according to the front-jack state */
  5585. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5586. {
  5587. unsigned int present;
  5588. present = snd_hda_codec_read(codec, 0x14, 0,
  5589. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5590. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5591. 0x80, present ? 0x80 : 0);
  5592. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5593. 0x80, present ? 0x80 : 0);
  5594. }
  5595. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5596. unsigned int res)
  5597. {
  5598. if ((res >> 26) == ALC880_HP_EVENT)
  5599. alc888_lenovo_ms7195_front_automute(codec);
  5600. if ((res >> 26) == ALC880_FRONT_EVENT)
  5601. alc888_lenovo_ms7195_rca_automute(codec);
  5602. }
  5603. static struct hda_verb alc883_medion_md2_verbs[] = {
  5604. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5605. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5606. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5607. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5608. { } /* end */
  5609. };
  5610. /* toggle speaker-output according to the hp-jack state */
  5611. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5612. {
  5613. unsigned int present;
  5614. present = snd_hda_codec_read(codec, 0x14, 0,
  5615. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5616. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5617. 0x80, present ? 0x80 : 0);
  5618. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5619. 0x80, present ? 0x80 : 0);
  5620. }
  5621. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5622. unsigned int res)
  5623. {
  5624. if ((res >> 26) == ALC880_HP_EVENT)
  5625. alc883_medion_md2_automute(codec);
  5626. }
  5627. /* toggle speaker-output according to the hp-jack state */
  5628. static void alc883_tagra_automute(struct hda_codec *codec)
  5629. {
  5630. unsigned int present;
  5631. unsigned char bits;
  5632. present = snd_hda_codec_read(codec, 0x14, 0,
  5633. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5634. bits = present ? 0x80 : 0;
  5635. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5636. 0x80, bits);
  5637. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5638. 0x80, bits);
  5639. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5640. present ? 1 : 3);
  5641. }
  5642. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5643. {
  5644. if ((res >> 26) == ALC880_HP_EVENT)
  5645. alc883_tagra_automute(codec);
  5646. }
  5647. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5648. {
  5649. unsigned int present;
  5650. unsigned char bits;
  5651. present = snd_hda_codec_read(codec, 0x14, 0,
  5652. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5653. bits = present ? 0x80 : 0;
  5654. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5655. 0x80, bits);
  5656. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5657. 0x80, bits);
  5658. }
  5659. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5660. {
  5661. unsigned int present;
  5662. unsigned char bits;
  5663. present = snd_hda_codec_read(codec, 0x1b, 0,
  5664. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5665. bits = present ? 0x80 : 0;
  5666. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5667. 0x80, bits);
  5668. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5669. 0x80, bits);
  5670. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5671. 0x80, bits);
  5672. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5673. 0x80, bits);
  5674. }
  5675. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5676. unsigned int res)
  5677. {
  5678. if ((res >> 26) == ALC880_HP_EVENT)
  5679. alc883_lenovo_101e_all_automute(codec);
  5680. if ((res >> 26) == ALC880_FRONT_EVENT)
  5681. alc883_lenovo_101e_ispeaker_automute(codec);
  5682. }
  5683. /*
  5684. * generic initialization of ADC, input mixers and output mixers
  5685. */
  5686. static struct hda_verb alc883_auto_init_verbs[] = {
  5687. /*
  5688. * Unmute ADC0-2 and set the default input to mic-in
  5689. */
  5690. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5691. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5692. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5693. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5694. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5695. * mixer widget
  5696. * Note: PASD motherboards uses the Line In 2 as the input for
  5697. * front panel mic (mic 2)
  5698. */
  5699. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5700. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5701. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5702. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5703. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5704. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5705. /*
  5706. * Set up output mixers (0x0c - 0x0f)
  5707. */
  5708. /* set vol=0 to output mixers */
  5709. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5710. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5711. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5712. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5713. /* set up input amps for analog loopback */
  5714. /* Amp Indices: DAC = 0, mixer = 1 */
  5715. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5716. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5717. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5718. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5719. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5720. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5721. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5722. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5723. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5724. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5725. /* FIXME: use matrix-type input source selection */
  5726. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5727. /* Input mixer1 */
  5728. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5729. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5730. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5731. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5732. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5733. /* Input mixer2 */
  5734. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5735. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5736. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5737. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5738. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5739. { }
  5740. };
  5741. /* capture mixer elements */
  5742. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5743. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5744. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5745. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5746. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5747. {
  5748. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5749. /* The multiple "Capture Source" controls confuse alsamixer
  5750. * So call somewhat different..
  5751. * FIXME: the controls appear in the "playback" view!
  5752. */
  5753. /* .name = "Capture Source", */
  5754. .name = "Input Source",
  5755. .count = 2,
  5756. .info = alc882_mux_enum_info,
  5757. .get = alc882_mux_enum_get,
  5758. .put = alc882_mux_enum_put,
  5759. },
  5760. { } /* end */
  5761. };
  5762. /* pcm configuration: identiacal with ALC880 */
  5763. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5764. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5765. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5766. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5767. /*
  5768. * configuration and preset
  5769. */
  5770. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5771. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5772. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5773. [ALC883_3ST_6ch] = "3stack-6ch",
  5774. [ALC883_6ST_DIG] = "6stack-dig",
  5775. [ALC883_TARGA_DIG] = "targa-dig",
  5776. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5777. [ALC883_ACER] = "acer",
  5778. [ALC883_MEDION] = "medion",
  5779. [ALC883_MEDION_MD2] = "medion-md2",
  5780. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5781. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5782. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  5783. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  5784. [ALC883_AUTO] = "auto",
  5785. };
  5786. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5787. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5788. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  5789. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5790. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5791. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5792. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5793. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5794. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5795. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  5796. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5797. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  5798. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5799. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  5800. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5801. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5802. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5803. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5804. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5805. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5806. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5807. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5808. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5809. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5810. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  5811. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5812. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5813. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5814. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  5815. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5816. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5817. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  5818. {}
  5819. };
  5820. static struct alc_config_preset alc883_presets[] = {
  5821. [ALC883_3ST_2ch_DIG] = {
  5822. .mixers = { alc883_3ST_2ch_mixer },
  5823. .init_verbs = { alc883_init_verbs },
  5824. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5825. .dac_nids = alc883_dac_nids,
  5826. .dig_out_nid = ALC883_DIGOUT_NID,
  5827. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5828. .adc_nids = alc883_adc_nids,
  5829. .dig_in_nid = ALC883_DIGIN_NID,
  5830. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5831. .channel_mode = alc883_3ST_2ch_modes,
  5832. .input_mux = &alc883_capture_source,
  5833. },
  5834. [ALC883_3ST_6ch_DIG] = {
  5835. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5836. .init_verbs = { alc883_init_verbs },
  5837. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5838. .dac_nids = alc883_dac_nids,
  5839. .dig_out_nid = ALC883_DIGOUT_NID,
  5840. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5841. .adc_nids = alc883_adc_nids,
  5842. .dig_in_nid = ALC883_DIGIN_NID,
  5843. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5844. .channel_mode = alc883_3ST_6ch_modes,
  5845. .need_dac_fix = 1,
  5846. .input_mux = &alc883_capture_source,
  5847. },
  5848. [ALC883_3ST_6ch] = {
  5849. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5850. .init_verbs = { alc883_init_verbs },
  5851. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5852. .dac_nids = alc883_dac_nids,
  5853. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5854. .adc_nids = alc883_adc_nids,
  5855. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5856. .channel_mode = alc883_3ST_6ch_modes,
  5857. .need_dac_fix = 1,
  5858. .input_mux = &alc883_capture_source,
  5859. },
  5860. [ALC883_6ST_DIG] = {
  5861. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5862. .init_verbs = { alc883_init_verbs },
  5863. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5864. .dac_nids = alc883_dac_nids,
  5865. .dig_out_nid = ALC883_DIGOUT_NID,
  5866. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5867. .adc_nids = alc883_adc_nids,
  5868. .dig_in_nid = ALC883_DIGIN_NID,
  5869. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5870. .channel_mode = alc883_sixstack_modes,
  5871. .input_mux = &alc883_capture_source,
  5872. },
  5873. [ALC883_TARGA_DIG] = {
  5874. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5875. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5876. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5877. .dac_nids = alc883_dac_nids,
  5878. .dig_out_nid = ALC883_DIGOUT_NID,
  5879. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5880. .adc_nids = alc883_adc_nids,
  5881. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5882. .channel_mode = alc883_3ST_6ch_modes,
  5883. .need_dac_fix = 1,
  5884. .input_mux = &alc883_capture_source,
  5885. .unsol_event = alc883_tagra_unsol_event,
  5886. .init_hook = alc883_tagra_automute,
  5887. },
  5888. [ALC883_TARGA_2ch_DIG] = {
  5889. .mixers = { alc883_tagra_2ch_mixer},
  5890. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5891. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5892. .dac_nids = alc883_dac_nids,
  5893. .dig_out_nid = ALC883_DIGOUT_NID,
  5894. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5895. .adc_nids = alc883_adc_nids,
  5896. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5897. .channel_mode = alc883_3ST_2ch_modes,
  5898. .input_mux = &alc883_capture_source,
  5899. .unsol_event = alc883_tagra_unsol_event,
  5900. .init_hook = alc883_tagra_automute,
  5901. },
  5902. [ALC883_ACER] = {
  5903. .mixers = { alc883_base_mixer,
  5904. alc883_chmode_mixer },
  5905. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5906. * and the headphone jack. Turn this on and rely on the
  5907. * standard mute methods whenever the user wants to turn
  5908. * these outputs off.
  5909. */
  5910. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5911. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5912. .dac_nids = alc883_dac_nids,
  5913. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5914. .adc_nids = alc883_adc_nids,
  5915. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5916. .channel_mode = alc883_3ST_2ch_modes,
  5917. .input_mux = &alc883_capture_source,
  5918. },
  5919. [ALC883_MEDION] = {
  5920. .mixers = { alc883_fivestack_mixer,
  5921. alc883_chmode_mixer },
  5922. .init_verbs = { alc883_init_verbs,
  5923. alc883_medion_eapd_verbs },
  5924. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5925. .dac_nids = alc883_dac_nids,
  5926. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5927. .adc_nids = alc883_adc_nids,
  5928. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5929. .channel_mode = alc883_sixstack_modes,
  5930. .input_mux = &alc883_capture_source,
  5931. },
  5932. [ALC883_MEDION_MD2] = {
  5933. .mixers = { alc883_medion_md2_mixer},
  5934. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  5935. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5936. .dac_nids = alc883_dac_nids,
  5937. .dig_out_nid = ALC883_DIGOUT_NID,
  5938. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5939. .adc_nids = alc883_adc_nids,
  5940. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5941. .channel_mode = alc883_3ST_2ch_modes,
  5942. .input_mux = &alc883_capture_source,
  5943. .unsol_event = alc883_medion_md2_unsol_event,
  5944. .init_hook = alc883_medion_md2_automute,
  5945. },
  5946. [ALC883_LAPTOP_EAPD] = {
  5947. .mixers = { alc883_base_mixer,
  5948. alc883_chmode_mixer },
  5949. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5950. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5951. .dac_nids = alc883_dac_nids,
  5952. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5953. .adc_nids = alc883_adc_nids,
  5954. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5955. .channel_mode = alc883_3ST_2ch_modes,
  5956. .input_mux = &alc883_capture_source,
  5957. },
  5958. [ALC883_LENOVO_101E_2ch] = {
  5959. .mixers = { alc883_lenovo_101e_2ch_mixer},
  5960. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  5961. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5962. .dac_nids = alc883_dac_nids,
  5963. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5964. .adc_nids = alc883_adc_nids,
  5965. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5966. .channel_mode = alc883_3ST_2ch_modes,
  5967. .input_mux = &alc883_lenovo_101e_capture_source,
  5968. .unsol_event = alc883_lenovo_101e_unsol_event,
  5969. .init_hook = alc883_lenovo_101e_all_automute,
  5970. },
  5971. [ALC883_LENOVO_NB0763] = {
  5972. .mixers = { alc883_lenovo_nb0763_mixer },
  5973. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  5974. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5975. .dac_nids = alc883_dac_nids,
  5976. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5977. .adc_nids = alc883_adc_nids,
  5978. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5979. .channel_mode = alc883_3ST_2ch_modes,
  5980. .need_dac_fix = 1,
  5981. .input_mux = &alc883_lenovo_nb0763_capture_source,
  5982. .unsol_event = alc883_medion_md2_unsol_event,
  5983. .init_hook = alc883_medion_md2_automute,
  5984. },
  5985. [ALC888_LENOVO_MS7195_DIG] = {
  5986. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5987. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  5988. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5989. .dac_nids = alc883_dac_nids,
  5990. .dig_out_nid = ALC883_DIGOUT_NID,
  5991. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5992. .adc_nids = alc883_adc_nids,
  5993. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5994. .channel_mode = alc883_3ST_6ch_modes,
  5995. .need_dac_fix = 1,
  5996. .input_mux = &alc883_capture_source,
  5997. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  5998. .init_hook = alc888_lenovo_ms7195_front_automute,
  5999. },
  6000. };
  6001. /*
  6002. * BIOS auto configuration
  6003. */
  6004. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6005. hda_nid_t nid, int pin_type,
  6006. int dac_idx)
  6007. {
  6008. /* set as output */
  6009. struct alc_spec *spec = codec->spec;
  6010. int idx;
  6011. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6012. idx = 4;
  6013. else
  6014. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6015. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6016. pin_type);
  6017. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6018. AMP_OUT_UNMUTE);
  6019. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6020. }
  6021. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6022. {
  6023. struct alc_spec *spec = codec->spec;
  6024. int i;
  6025. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6026. for (i = 0; i <= HDA_SIDE; i++) {
  6027. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6028. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6029. if (nid)
  6030. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6031. i);
  6032. }
  6033. }
  6034. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6035. {
  6036. struct alc_spec *spec = codec->spec;
  6037. hda_nid_t pin;
  6038. pin = spec->autocfg.hp_pins[0];
  6039. if (pin) /* connect to front */
  6040. /* use dac 0 */
  6041. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6042. }
  6043. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6044. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6045. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6046. {
  6047. struct alc_spec *spec = codec->spec;
  6048. int i;
  6049. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6050. hda_nid_t nid = spec->autocfg.input_pins[i];
  6051. if (alc883_is_input_pin(nid)) {
  6052. snd_hda_codec_write(codec, nid, 0,
  6053. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6054. (i <= AUTO_PIN_FRONT_MIC ?
  6055. PIN_VREF80 : PIN_IN));
  6056. if (nid != ALC883_PIN_CD_NID)
  6057. snd_hda_codec_write(codec, nid, 0,
  6058. AC_VERB_SET_AMP_GAIN_MUTE,
  6059. AMP_OUT_MUTE);
  6060. }
  6061. }
  6062. }
  6063. /* almost identical with ALC880 parser... */
  6064. static int alc883_parse_auto_config(struct hda_codec *codec)
  6065. {
  6066. struct alc_spec *spec = codec->spec;
  6067. int err = alc880_parse_auto_config(codec);
  6068. if (err < 0)
  6069. return err;
  6070. else if (err > 0)
  6071. /* hack - override the init verbs */
  6072. spec->init_verbs[0] = alc883_auto_init_verbs;
  6073. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6074. spec->num_mixers++;
  6075. return err;
  6076. }
  6077. /* additional initialization for auto-configuration model */
  6078. static void alc883_auto_init(struct hda_codec *codec)
  6079. {
  6080. alc883_auto_init_multi_out(codec);
  6081. alc883_auto_init_hp_out(codec);
  6082. alc883_auto_init_analog_input(codec);
  6083. }
  6084. static int patch_alc883(struct hda_codec *codec)
  6085. {
  6086. struct alc_spec *spec;
  6087. int err, board_config;
  6088. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6089. if (spec == NULL)
  6090. return -ENOMEM;
  6091. codec->spec = spec;
  6092. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6093. alc883_models,
  6094. alc883_cfg_tbl);
  6095. if (board_config < 0) {
  6096. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6097. "trying auto-probe from BIOS...\n");
  6098. board_config = ALC883_AUTO;
  6099. }
  6100. if (board_config == ALC883_AUTO) {
  6101. /* automatic parse from the BIOS config */
  6102. err = alc883_parse_auto_config(codec);
  6103. if (err < 0) {
  6104. alc_free(codec);
  6105. return err;
  6106. } else if (!err) {
  6107. printk(KERN_INFO
  6108. "hda_codec: Cannot set up configuration "
  6109. "from BIOS. Using base mode...\n");
  6110. board_config = ALC883_3ST_2ch_DIG;
  6111. }
  6112. }
  6113. if (board_config != ALC883_AUTO)
  6114. setup_preset(spec, &alc883_presets[board_config]);
  6115. spec->stream_name_analog = "ALC883 Analog";
  6116. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6117. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6118. spec->stream_name_digital = "ALC883 Digital";
  6119. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6120. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6121. if (!spec->adc_nids && spec->input_mux) {
  6122. spec->adc_nids = alc883_adc_nids;
  6123. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6124. }
  6125. codec->patch_ops = alc_patch_ops;
  6126. if (board_config == ALC883_AUTO)
  6127. spec->init_hook = alc883_auto_init;
  6128. return 0;
  6129. }
  6130. /*
  6131. * ALC262 support
  6132. */
  6133. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6134. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6135. #define alc262_dac_nids alc260_dac_nids
  6136. #define alc262_adc_nids alc882_adc_nids
  6137. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6138. #define alc262_modes alc260_modes
  6139. #define alc262_capture_source alc882_capture_source
  6140. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6141. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6142. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6143. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6144. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6145. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6146. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6147. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6148. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6149. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6150. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6151. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6152. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6153. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6154. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6155. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6156. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6157. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6158. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6159. { } /* end */
  6160. };
  6161. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6162. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6163. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6164. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6165. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6166. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6167. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6168. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6169. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6170. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6171. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6172. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6173. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6174. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6175. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6176. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6177. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6178. { } /* end */
  6179. };
  6180. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6181. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6182. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6183. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6184. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6185. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6186. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6187. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6188. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6189. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6190. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6191. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6192. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6193. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6194. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6195. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6196. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6197. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6198. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6199. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6200. { } /* end */
  6201. };
  6202. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6203. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6204. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6205. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6206. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6207. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6208. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6209. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6210. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6211. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6212. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6213. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6214. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6215. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6216. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6217. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6218. { } /* end */
  6219. };
  6220. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6221. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6222. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6223. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6224. { } /* end */
  6225. };
  6226. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6227. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6228. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6229. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6230. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6231. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6232. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6233. { } /* end */
  6234. };
  6235. #define alc262_capture_mixer alc882_capture_mixer
  6236. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6237. /*
  6238. * generic initialization of ADC, input mixers and output mixers
  6239. */
  6240. static struct hda_verb alc262_init_verbs[] = {
  6241. /*
  6242. * Unmute ADC0-2 and set the default input to mic-in
  6243. */
  6244. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6245. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6246. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6247. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6248. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6249. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6250. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6251. * mixer widget
  6252. * Note: PASD motherboards uses the Line In 2 as the input for
  6253. * front panel mic (mic 2)
  6254. */
  6255. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6256. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6257. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6258. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6259. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6260. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6261. /*
  6262. * Set up output mixers (0x0c - 0x0e)
  6263. */
  6264. /* set vol=0 to output mixers */
  6265. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6266. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6267. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6268. /* set up input amps for analog loopback */
  6269. /* Amp Indices: DAC = 0, mixer = 1 */
  6270. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6271. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6272. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6273. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6274. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6275. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6276. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6277. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6278. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6279. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6280. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6281. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6282. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6283. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6284. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6285. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6286. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6287. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6288. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6289. /* FIXME: use matrix-type input source selection */
  6290. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6291. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6292. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6293. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6294. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6295. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6296. /* Input mixer2 */
  6297. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6298. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6299. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6300. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6301. /* Input mixer3 */
  6302. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6303. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6304. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6305. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6306. { }
  6307. };
  6308. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6309. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6310. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6311. {}
  6312. };
  6313. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6314. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6315. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6316. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6317. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6318. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6319. {}
  6320. };
  6321. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6322. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6323. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6324. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6325. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6326. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6327. };
  6328. /* mute/unmute internal speaker according to the hp jack and mute state */
  6329. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  6330. {
  6331. struct alc_spec *spec = codec->spec;
  6332. unsigned int mute;
  6333. if (force || !spec->sense_updated) {
  6334. unsigned int present;
  6335. /* need to execute and sync at first */
  6336. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6337. present = snd_hda_codec_read(codec, 0x15, 0,
  6338. AC_VERB_GET_PIN_SENSE, 0);
  6339. spec->jack_present = (present & 0x80000000) != 0;
  6340. spec->sense_updated = 1;
  6341. }
  6342. if (spec->jack_present) {
  6343. /* mute internal speaker */
  6344. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6345. 0x80, 0x80);
  6346. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6347. 0x80, 0x80);
  6348. } else {
  6349. /* unmute internal speaker if necessary */
  6350. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6351. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6352. 0x80, mute & 0x80);
  6353. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6354. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6355. 0x80, mute & 0x80);
  6356. }
  6357. }
  6358. /* unsolicited event for HP jack sensing */
  6359. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6360. unsigned int res)
  6361. {
  6362. if ((res >> 26) != ALC880_HP_EVENT)
  6363. return;
  6364. alc262_hippo_automute(codec, 1);
  6365. }
  6366. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  6367. {
  6368. struct alc_spec *spec = codec->spec;
  6369. unsigned int mute;
  6370. if (force || !spec->sense_updated) {
  6371. unsigned int present;
  6372. /* need to execute and sync at first */
  6373. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6374. present = snd_hda_codec_read(codec, 0x1b, 0,
  6375. AC_VERB_GET_PIN_SENSE, 0);
  6376. spec->jack_present = (present & 0x80000000) != 0;
  6377. spec->sense_updated = 1;
  6378. }
  6379. if (spec->jack_present) {
  6380. /* mute internal speaker */
  6381. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6382. 0x80, 0x80);
  6383. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6384. 0x80, 0x80);
  6385. } else {
  6386. /* unmute internal speaker if necessary */
  6387. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6388. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6389. 0x80, mute & 0x80);
  6390. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6391. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6392. 0x80, mute & 0x80);
  6393. }
  6394. }
  6395. /* unsolicited event for HP jack sensing */
  6396. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6397. unsigned int res)
  6398. {
  6399. if ((res >> 26) != ALC880_HP_EVENT)
  6400. return;
  6401. alc262_hippo1_automute(codec, 1);
  6402. }
  6403. /*
  6404. * fujitsu model
  6405. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6406. */
  6407. #define ALC_HP_EVENT 0x37
  6408. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6409. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6410. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6411. {}
  6412. };
  6413. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6414. .num_items = 2,
  6415. .items = {
  6416. { "Mic", 0x0 },
  6417. { "CD", 0x4 },
  6418. },
  6419. };
  6420. static struct hda_input_mux alc262_HP_capture_source = {
  6421. .num_items = 5,
  6422. .items = {
  6423. { "Mic", 0x0 },
  6424. { "Front Mic", 0x3 },
  6425. { "Line", 0x2 },
  6426. { "CD", 0x4 },
  6427. { "AUX IN", 0x6 },
  6428. },
  6429. };
  6430. /* mute/unmute internal speaker according to the hp jack and mute state */
  6431. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6432. {
  6433. struct alc_spec *spec = codec->spec;
  6434. unsigned int mute;
  6435. if (force || !spec->sense_updated) {
  6436. unsigned int present;
  6437. /* need to execute and sync at first */
  6438. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6439. present = snd_hda_codec_read(codec, 0x14, 0,
  6440. AC_VERB_GET_PIN_SENSE, 0);
  6441. spec->jack_present = (present & 0x80000000) != 0;
  6442. spec->sense_updated = 1;
  6443. }
  6444. if (spec->jack_present) {
  6445. /* mute internal speaker */
  6446. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6447. 0x80, 0x80);
  6448. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6449. 0x80, 0x80);
  6450. } else {
  6451. /* unmute internal speaker if necessary */
  6452. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6453. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6454. 0x80, mute & 0x80);
  6455. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6456. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6457. 0x80, mute & 0x80);
  6458. }
  6459. }
  6460. /* unsolicited event for HP jack sensing */
  6461. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6462. unsigned int res)
  6463. {
  6464. if ((res >> 26) != ALC_HP_EVENT)
  6465. return;
  6466. alc262_fujitsu_automute(codec, 1);
  6467. }
  6468. /* bind volumes of both NID 0x0c and 0x0d */
  6469. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6470. struct snd_ctl_elem_value *ucontrol)
  6471. {
  6472. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6473. long *valp = ucontrol->value.integer.value;
  6474. int change;
  6475. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6476. 0x7f, valp[0] & 0x7f);
  6477. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6478. 0x7f, valp[1] & 0x7f);
  6479. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6480. 0x7f, valp[0] & 0x7f);
  6481. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6482. 0x7f, valp[1] & 0x7f);
  6483. return change;
  6484. }
  6485. /* bind hp and internal speaker mute (with plug check) */
  6486. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6487. struct snd_ctl_elem_value *ucontrol)
  6488. {
  6489. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6490. long *valp = ucontrol->value.integer.value;
  6491. int change;
  6492. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6493. 0x80, valp[0] ? 0 : 0x80);
  6494. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6495. 0x80, valp[1] ? 0 : 0x80);
  6496. if (change || codec->in_resume)
  6497. alc262_fujitsu_automute(codec, codec->in_resume);
  6498. return change;
  6499. }
  6500. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6501. {
  6502. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6503. .name = "Master Playback Volume",
  6504. .info = snd_hda_mixer_amp_volume_info,
  6505. .get = snd_hda_mixer_amp_volume_get,
  6506. .put = alc262_fujitsu_master_vol_put,
  6507. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6508. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6509. },
  6510. {
  6511. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6512. .name = "Master Playback Switch",
  6513. .info = snd_hda_mixer_amp_switch_info,
  6514. .get = snd_hda_mixer_amp_switch_get,
  6515. .put = alc262_fujitsu_master_sw_put,
  6516. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6517. },
  6518. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6519. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6520. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6521. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6522. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6523. { } /* end */
  6524. };
  6525. /* additional init verbs for Benq laptops */
  6526. static struct hda_verb alc262_EAPD_verbs[] = {
  6527. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6528. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6529. {}
  6530. };
  6531. /* add playback controls from the parsed DAC table */
  6532. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6533. const struct auto_pin_cfg *cfg)
  6534. {
  6535. hda_nid_t nid;
  6536. int err;
  6537. spec->multiout.num_dacs = 1; /* only use one dac */
  6538. spec->multiout.dac_nids = spec->private_dac_nids;
  6539. spec->multiout.dac_nids[0] = 2;
  6540. nid = cfg->line_out_pins[0];
  6541. if (nid) {
  6542. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6543. "Front Playback Volume",
  6544. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6545. if (err < 0)
  6546. return err;
  6547. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6548. "Front Playback Switch",
  6549. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6550. if (err < 0)
  6551. return err;
  6552. }
  6553. nid = cfg->speaker_pins[0];
  6554. if (nid) {
  6555. if (nid == 0x16) {
  6556. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6557. "Speaker Playback Volume",
  6558. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6559. HDA_OUTPUT));
  6560. if (err < 0)
  6561. return err;
  6562. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6563. "Speaker Playback Switch",
  6564. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6565. HDA_OUTPUT));
  6566. if (err < 0)
  6567. return err;
  6568. } else {
  6569. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6570. "Speaker Playback Switch",
  6571. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6572. HDA_OUTPUT));
  6573. if (err < 0)
  6574. return err;
  6575. }
  6576. }
  6577. nid = cfg->hp_pins[0];
  6578. if (nid) {
  6579. /* spec->multiout.hp_nid = 2; */
  6580. if (nid == 0x16) {
  6581. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6582. "Headphone Playback Volume",
  6583. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6584. HDA_OUTPUT));
  6585. if (err < 0)
  6586. return err;
  6587. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6588. "Headphone Playback Switch",
  6589. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6590. HDA_OUTPUT));
  6591. if (err < 0)
  6592. return err;
  6593. } else {
  6594. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6595. "Headphone Playback Switch",
  6596. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6597. HDA_OUTPUT));
  6598. if (err < 0)
  6599. return err;
  6600. }
  6601. }
  6602. return 0;
  6603. }
  6604. /* identical with ALC880 */
  6605. #define alc262_auto_create_analog_input_ctls \
  6606. alc880_auto_create_analog_input_ctls
  6607. /*
  6608. * generic initialization of ADC, input mixers and output mixers
  6609. */
  6610. static struct hda_verb alc262_volume_init_verbs[] = {
  6611. /*
  6612. * Unmute ADC0-2 and set the default input to mic-in
  6613. */
  6614. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6615. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6616. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6617. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6618. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6619. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6620. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6621. * mixer widget
  6622. * Note: PASD motherboards uses the Line In 2 as the input for
  6623. * front panel mic (mic 2)
  6624. */
  6625. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6626. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6627. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6628. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6629. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6630. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6631. /*
  6632. * Set up output mixers (0x0c - 0x0f)
  6633. */
  6634. /* set vol=0 to output mixers */
  6635. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6636. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6637. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6638. /* set up input amps for analog loopback */
  6639. /* Amp Indices: DAC = 0, mixer = 1 */
  6640. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6641. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6642. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6643. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6644. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6645. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6646. /* FIXME: use matrix-type input source selection */
  6647. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6648. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6649. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6650. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6651. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6652. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6653. /* Input mixer2 */
  6654. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6655. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6656. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6657. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6658. /* Input mixer3 */
  6659. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6660. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6661. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6662. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6663. { }
  6664. };
  6665. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6666. /*
  6667. * Unmute ADC0-2 and set the default input to mic-in
  6668. */
  6669. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6670. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6671. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6672. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6673. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6674. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6675. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6676. * mixer widget
  6677. * Note: PASD motherboards uses the Line In 2 as the input for
  6678. * front panel mic (mic 2)
  6679. */
  6680. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6681. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6682. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6683. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6684. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6685. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6686. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6687. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6688. /*
  6689. * Set up output mixers (0x0c - 0x0e)
  6690. */
  6691. /* set vol=0 to output mixers */
  6692. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6693. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6694. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6695. /* set up input amps for analog loopback */
  6696. /* Amp Indices: DAC = 0, mixer = 1 */
  6697. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6698. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6699. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6700. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6701. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6702. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6703. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6704. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6705. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6706. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6707. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6708. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6709. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6710. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6711. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6712. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6713. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6714. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6715. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6716. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6717. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6718. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6719. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6720. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6721. /* FIXME: use matrix-type input source selection */
  6722. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6723. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6724. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6725. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6726. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6727. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6728. /* Input mixer2 */
  6729. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6730. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6731. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6732. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6733. /* Input mixer3 */
  6734. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6735. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6736. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6737. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6738. { }
  6739. };
  6740. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6741. /*
  6742. * Unmute ADC0-2 and set the default input to mic-in
  6743. */
  6744. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6745. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6746. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6747. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6748. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6749. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6750. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6751. * mixer widget
  6752. * Note: PASD motherboards uses the Line In 2 as the input for front
  6753. * panel mic (mic 2)
  6754. */
  6755. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6756. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6757. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6758. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6759. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6760. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6761. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6762. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6763. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6764. /*
  6765. * Set up output mixers (0x0c - 0x0e)
  6766. */
  6767. /* set vol=0 to output mixers */
  6768. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6769. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6770. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6771. /* set up input amps for analog loopback */
  6772. /* Amp Indices: DAC = 0, mixer = 1 */
  6773. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6774. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6775. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6776. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6777. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6778. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6779. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  6780. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  6781. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  6782. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  6783. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  6784. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  6785. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  6786. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6787. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6788. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6789. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6790. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  6791. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6792. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6793. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6794. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6795. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6796. /* FIXME: use matrix-type input source selection */
  6797. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6798. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6799. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  6800. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  6801. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  6802. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  6803. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  6804. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6805. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  6806. /* Input mixer2 */
  6807. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6808. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6809. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6810. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6811. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6812. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6813. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6814. /* Input mixer3 */
  6815. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6816. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6817. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6818. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6819. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6820. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6821. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6822. { }
  6823. };
  6824. /* pcm configuration: identiacal with ALC880 */
  6825. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  6826. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  6827. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  6828. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  6829. /*
  6830. * BIOS auto configuration
  6831. */
  6832. static int alc262_parse_auto_config(struct hda_codec *codec)
  6833. {
  6834. struct alc_spec *spec = codec->spec;
  6835. int err;
  6836. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  6837. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6838. alc262_ignore);
  6839. if (err < 0)
  6840. return err;
  6841. if (!spec->autocfg.line_outs)
  6842. return 0; /* can't find valid BIOS pin config */
  6843. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  6844. if (err < 0)
  6845. return err;
  6846. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  6847. if (err < 0)
  6848. return err;
  6849. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6850. if (spec->autocfg.dig_out_pin)
  6851. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  6852. if (spec->autocfg.dig_in_pin)
  6853. spec->dig_in_nid = ALC262_DIGIN_NID;
  6854. if (spec->kctl_alloc)
  6855. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6856. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  6857. spec->num_mux_defs = 1;
  6858. spec->input_mux = &spec->private_imux;
  6859. return 1;
  6860. }
  6861. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  6862. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  6863. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  6864. /* init callback for auto-configuration model -- overriding the default init */
  6865. static void alc262_auto_init(struct hda_codec *codec)
  6866. {
  6867. alc262_auto_init_multi_out(codec);
  6868. alc262_auto_init_hp_out(codec);
  6869. alc262_auto_init_analog_input(codec);
  6870. }
  6871. /*
  6872. * configuration and preset
  6873. */
  6874. static const char *alc262_models[ALC262_MODEL_LAST] = {
  6875. [ALC262_BASIC] = "basic",
  6876. [ALC262_HIPPO] = "hippo",
  6877. [ALC262_HIPPO_1] = "hippo_1",
  6878. [ALC262_FUJITSU] = "fujitsu",
  6879. [ALC262_HP_BPC] = "hp-bpc",
  6880. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  6881. [ALC262_BENQ_ED8] = "benq",
  6882. [ALC262_BENQ_ED8] = "sony-assamd",
  6883. [ALC262_AUTO] = "auto",
  6884. };
  6885. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  6886. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  6887. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  6888. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  6889. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  6890. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  6891. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  6892. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  6893. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  6894. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  6895. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6896. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6897. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6898. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6899. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6900. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6901. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6902. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6903. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  6904. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  6905. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  6906. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  6907. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  6908. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6909. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  6910. {}
  6911. };
  6912. static struct alc_config_preset alc262_presets[] = {
  6913. [ALC262_BASIC] = {
  6914. .mixers = { alc262_base_mixer },
  6915. .init_verbs = { alc262_init_verbs },
  6916. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6917. .dac_nids = alc262_dac_nids,
  6918. .hp_nid = 0x03,
  6919. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6920. .channel_mode = alc262_modes,
  6921. .input_mux = &alc262_capture_source,
  6922. },
  6923. [ALC262_HIPPO] = {
  6924. .mixers = { alc262_base_mixer },
  6925. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  6926. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6927. .dac_nids = alc262_dac_nids,
  6928. .hp_nid = 0x03,
  6929. .dig_out_nid = ALC262_DIGOUT_NID,
  6930. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6931. .channel_mode = alc262_modes,
  6932. .input_mux = &alc262_capture_source,
  6933. .unsol_event = alc262_hippo_unsol_event,
  6934. },
  6935. [ALC262_HIPPO_1] = {
  6936. .mixers = { alc262_hippo1_mixer },
  6937. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  6938. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6939. .dac_nids = alc262_dac_nids,
  6940. .hp_nid = 0x02,
  6941. .dig_out_nid = ALC262_DIGOUT_NID,
  6942. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6943. .channel_mode = alc262_modes,
  6944. .input_mux = &alc262_capture_source,
  6945. .unsol_event = alc262_hippo1_unsol_event,
  6946. },
  6947. [ALC262_FUJITSU] = {
  6948. .mixers = { alc262_fujitsu_mixer },
  6949. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  6950. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6951. .dac_nids = alc262_dac_nids,
  6952. .hp_nid = 0x03,
  6953. .dig_out_nid = ALC262_DIGOUT_NID,
  6954. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6955. .channel_mode = alc262_modes,
  6956. .input_mux = &alc262_fujitsu_capture_source,
  6957. .unsol_event = alc262_fujitsu_unsol_event,
  6958. },
  6959. [ALC262_HP_BPC] = {
  6960. .mixers = { alc262_HP_BPC_mixer },
  6961. .init_verbs = { alc262_HP_BPC_init_verbs },
  6962. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6963. .dac_nids = alc262_dac_nids,
  6964. .hp_nid = 0x03,
  6965. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6966. .channel_mode = alc262_modes,
  6967. .input_mux = &alc262_HP_capture_source,
  6968. },
  6969. [ALC262_HP_BPC_D7000_WF] = {
  6970. .mixers = { alc262_HP_BPC_WildWest_mixer },
  6971. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6972. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6973. .dac_nids = alc262_dac_nids,
  6974. .hp_nid = 0x03,
  6975. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6976. .channel_mode = alc262_modes,
  6977. .input_mux = &alc262_HP_capture_source,
  6978. },
  6979. [ALC262_HP_BPC_D7000_WL] = {
  6980. .mixers = { alc262_HP_BPC_WildWest_mixer,
  6981. alc262_HP_BPC_WildWest_option_mixer },
  6982. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6983. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6984. .dac_nids = alc262_dac_nids,
  6985. .hp_nid = 0x03,
  6986. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6987. .channel_mode = alc262_modes,
  6988. .input_mux = &alc262_HP_capture_source,
  6989. },
  6990. [ALC262_BENQ_ED8] = {
  6991. .mixers = { alc262_base_mixer },
  6992. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  6993. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6994. .dac_nids = alc262_dac_nids,
  6995. .hp_nid = 0x03,
  6996. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6997. .channel_mode = alc262_modes,
  6998. .input_mux = &alc262_capture_source,
  6999. },
  7000. [ALC262_SONY_ASSAMD] = {
  7001. .mixers = { alc262_sony_mixer },
  7002. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7003. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7004. .dac_nids = alc262_dac_nids,
  7005. .hp_nid = 0x02,
  7006. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7007. .channel_mode = alc262_modes,
  7008. .input_mux = &alc262_capture_source,
  7009. .unsol_event = alc262_hippo_unsol_event,
  7010. },
  7011. };
  7012. static int patch_alc262(struct hda_codec *codec)
  7013. {
  7014. struct alc_spec *spec;
  7015. int board_config;
  7016. int err;
  7017. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7018. if (spec == NULL)
  7019. return -ENOMEM;
  7020. codec->spec = spec;
  7021. #if 0
  7022. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7023. * under-run
  7024. */
  7025. {
  7026. int tmp;
  7027. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7028. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7029. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7030. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7031. }
  7032. #endif
  7033. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7034. alc262_models,
  7035. alc262_cfg_tbl);
  7036. if (board_config < 0) {
  7037. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7038. "trying auto-probe from BIOS...\n");
  7039. board_config = ALC262_AUTO;
  7040. }
  7041. if (board_config == ALC262_AUTO) {
  7042. /* automatic parse from the BIOS config */
  7043. err = alc262_parse_auto_config(codec);
  7044. if (err < 0) {
  7045. alc_free(codec);
  7046. return err;
  7047. } else if (!err) {
  7048. printk(KERN_INFO
  7049. "hda_codec: Cannot set up configuration "
  7050. "from BIOS. Using base mode...\n");
  7051. board_config = ALC262_BASIC;
  7052. }
  7053. }
  7054. if (board_config != ALC262_AUTO)
  7055. setup_preset(spec, &alc262_presets[board_config]);
  7056. spec->stream_name_analog = "ALC262 Analog";
  7057. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7058. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7059. spec->stream_name_digital = "ALC262 Digital";
  7060. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7061. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7062. if (!spec->adc_nids && spec->input_mux) {
  7063. /* check whether NID 0x07 is valid */
  7064. unsigned int wcap = get_wcaps(codec, 0x07);
  7065. /* get type */
  7066. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7067. if (wcap != AC_WID_AUD_IN) {
  7068. spec->adc_nids = alc262_adc_nids_alt;
  7069. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7070. spec->mixers[spec->num_mixers] =
  7071. alc262_capture_alt_mixer;
  7072. spec->num_mixers++;
  7073. } else {
  7074. spec->adc_nids = alc262_adc_nids;
  7075. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7076. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7077. spec->num_mixers++;
  7078. }
  7079. }
  7080. codec->patch_ops = alc_patch_ops;
  7081. if (board_config == ALC262_AUTO)
  7082. spec->init_hook = alc262_auto_init;
  7083. return 0;
  7084. }
  7085. /*
  7086. * ALC268 channel source setting (2 channel)
  7087. */
  7088. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7089. #define alc268_modes alc260_modes
  7090. static hda_nid_t alc268_dac_nids[2] = {
  7091. /* front, hp */
  7092. 0x02, 0x03
  7093. };
  7094. static hda_nid_t alc268_adc_nids[2] = {
  7095. /* ADC0-1 */
  7096. 0x08, 0x07
  7097. };
  7098. static hda_nid_t alc268_adc_nids_alt[1] = {
  7099. /* ADC0 */
  7100. 0x08
  7101. };
  7102. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7103. /* output mixer control */
  7104. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7105. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7106. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7107. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7108. { }
  7109. };
  7110. /*
  7111. * generic initialization of ADC, input mixers and output mixers
  7112. */
  7113. static struct hda_verb alc268_base_init_verbs[] = {
  7114. /* Unmute DAC0-1 and set vol = 0 */
  7115. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7116. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7117. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7118. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7119. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7120. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7121. /*
  7122. * Set up output mixers (0x0c - 0x0e)
  7123. */
  7124. /* set vol=0 to output mixers */
  7125. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7126. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7127. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7128. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7129. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7130. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7131. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7132. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7133. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7134. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7135. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7136. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7137. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7138. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7139. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7140. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7141. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7142. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7143. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7144. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7145. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7146. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7147. /* FIXME: use matrix-type input source selection */
  7148. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7149. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7150. /* Input mixer2 */
  7151. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7152. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7153. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7154. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7155. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7156. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7157. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7158. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7159. { }
  7160. };
  7161. /*
  7162. * generic initialization of ADC, input mixers and output mixers
  7163. */
  7164. static struct hda_verb alc268_volume_init_verbs[] = {
  7165. /* set output DAC */
  7166. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7167. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7168. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7169. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7170. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7171. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7172. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7173. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7174. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7175. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7176. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7177. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7178. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7179. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7180. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7181. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7182. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7183. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7184. /* set PCBEEP vol = 0 */
  7185. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7186. { }
  7187. };
  7188. #define alc268_mux_enum_info alc_mux_enum_info
  7189. #define alc268_mux_enum_get alc_mux_enum_get
  7190. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7191. struct snd_ctl_elem_value *ucontrol)
  7192. {
  7193. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7194. struct alc_spec *spec = codec->spec;
  7195. const struct hda_input_mux *imux = spec->input_mux;
  7196. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7197. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7198. hda_nid_t nid = capture_mixers[adc_idx];
  7199. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7200. unsigned int i, idx;
  7201. idx = ucontrol->value.enumerated.item[0];
  7202. if (idx >= imux->num_items)
  7203. idx = imux->num_items - 1;
  7204. if (*cur_val == idx && !codec->in_resume)
  7205. return 0;
  7206. for (i = 0; i < imux->num_items; i++) {
  7207. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7208. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7209. v | (imux->items[i].index << 8));
  7210. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
  7211. idx );
  7212. }
  7213. *cur_val = idx;
  7214. return 1;
  7215. }
  7216. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7217. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7218. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7219. {
  7220. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7221. /* The multiple "Capture Source" controls confuse alsamixer
  7222. * So call somewhat different..
  7223. * FIXME: the controls appear in the "playback" view!
  7224. */
  7225. /* .name = "Capture Source", */
  7226. .name = "Input Source",
  7227. .count = 1,
  7228. .info = alc268_mux_enum_info,
  7229. .get = alc268_mux_enum_get,
  7230. .put = alc268_mux_enum_put,
  7231. },
  7232. { } /* end */
  7233. };
  7234. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7235. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7236. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7237. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7238. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7239. {
  7240. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7241. /* The multiple "Capture Source" controls confuse alsamixer
  7242. * So call somewhat different..
  7243. * FIXME: the controls appear in the "playback" view!
  7244. */
  7245. /* .name = "Capture Source", */
  7246. .name = "Input Source",
  7247. .count = 2,
  7248. .info = alc268_mux_enum_info,
  7249. .get = alc268_mux_enum_get,
  7250. .put = alc268_mux_enum_put,
  7251. },
  7252. { } /* end */
  7253. };
  7254. static struct hda_input_mux alc268_capture_source = {
  7255. .num_items = 4,
  7256. .items = {
  7257. { "Mic", 0x0 },
  7258. { "Front Mic", 0x1 },
  7259. { "Line", 0x2 },
  7260. { "CD", 0x3 },
  7261. },
  7262. };
  7263. /* create input playback/capture controls for the given pin */
  7264. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7265. const char *ctlname, int idx)
  7266. {
  7267. char name[32];
  7268. int err;
  7269. sprintf(name, "%s Playback Volume", ctlname);
  7270. if (nid == 0x14) {
  7271. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7272. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7273. HDA_OUTPUT));
  7274. if (err < 0)
  7275. return err;
  7276. } else if (nid == 0x15) {
  7277. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7278. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7279. HDA_OUTPUT));
  7280. if (err < 0)
  7281. return err;
  7282. } else
  7283. return -1;
  7284. sprintf(name, "%s Playback Switch", ctlname);
  7285. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7286. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7287. if (err < 0)
  7288. return err;
  7289. return 0;
  7290. }
  7291. /* add playback controls from the parsed DAC table */
  7292. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7293. const struct auto_pin_cfg *cfg)
  7294. {
  7295. hda_nid_t nid;
  7296. int err;
  7297. spec->multiout.num_dacs = 2; /* only use one dac */
  7298. spec->multiout.dac_nids = spec->private_dac_nids;
  7299. spec->multiout.dac_nids[0] = 2;
  7300. spec->multiout.dac_nids[1] = 3;
  7301. nid = cfg->line_out_pins[0];
  7302. if (nid)
  7303. alc268_new_analog_output(spec, nid, "Front", 0);
  7304. nid = cfg->speaker_pins[0];
  7305. if (nid == 0x1d) {
  7306. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7307. "Speaker Playback Volume",
  7308. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7309. if (err < 0)
  7310. return err;
  7311. }
  7312. nid = cfg->hp_pins[0];
  7313. if (nid)
  7314. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7315. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7316. if (nid == 0x16) {
  7317. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7318. "Mono Playback Switch",
  7319. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7320. if (err < 0)
  7321. return err;
  7322. }
  7323. return 0;
  7324. }
  7325. /* create playback/capture controls for input pins */
  7326. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7327. const struct auto_pin_cfg *cfg)
  7328. {
  7329. struct hda_input_mux *imux = &spec->private_imux;
  7330. int i, idx1;
  7331. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7332. switch(cfg->input_pins[i]) {
  7333. case 0x18:
  7334. idx1 = 0; /* Mic 1 */
  7335. break;
  7336. case 0x19:
  7337. idx1 = 1; /* Mic 2 */
  7338. break;
  7339. case 0x1a:
  7340. idx1 = 2; /* Line In */
  7341. break;
  7342. case 0x1c:
  7343. idx1 = 3; /* CD */
  7344. break;
  7345. default:
  7346. continue;
  7347. }
  7348. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7349. imux->items[imux->num_items].index = idx1;
  7350. imux->num_items++;
  7351. }
  7352. return 0;
  7353. }
  7354. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7355. {
  7356. struct alc_spec *spec = codec->spec;
  7357. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7358. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7359. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7360. unsigned int dac_vol1, dac_vol2;
  7361. if (speaker_nid) {
  7362. snd_hda_codec_write(codec, speaker_nid, 0,
  7363. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7364. snd_hda_codec_write(codec, 0x0f, 0,
  7365. AC_VERB_SET_AMP_GAIN_MUTE,
  7366. AMP_IN_UNMUTE(1));
  7367. snd_hda_codec_write(codec, 0x10, 0,
  7368. AC_VERB_SET_AMP_GAIN_MUTE,
  7369. AMP_IN_UNMUTE(1));
  7370. } else {
  7371. snd_hda_codec_write(codec, 0x0f, 0,
  7372. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7373. snd_hda_codec_write(codec, 0x10, 0,
  7374. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7375. }
  7376. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7377. if (line_nid == 0x14)
  7378. dac_vol2 = AMP_OUT_ZERO;
  7379. else if (line_nid == 0x15)
  7380. dac_vol1 = AMP_OUT_ZERO;
  7381. if (hp_nid == 0x14)
  7382. dac_vol2 = AMP_OUT_ZERO;
  7383. else if (hp_nid == 0x15)
  7384. dac_vol1 = AMP_OUT_ZERO;
  7385. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7386. spec->autocfg.line_out_pins[1] != 0x16 ||
  7387. spec->autocfg.line_out_pins[2] != 0x16)
  7388. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7389. snd_hda_codec_write(codec, 0x02, 0,
  7390. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7391. snd_hda_codec_write(codec, 0x03, 0,
  7392. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7393. }
  7394. /* pcm configuration: identiacal with ALC880 */
  7395. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7396. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7397. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7398. /*
  7399. * BIOS auto configuration
  7400. */
  7401. static int alc268_parse_auto_config(struct hda_codec *codec)
  7402. {
  7403. struct alc_spec *spec = codec->spec;
  7404. int err;
  7405. static hda_nid_t alc268_ignore[] = { 0 };
  7406. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7407. alc268_ignore);
  7408. if (err < 0)
  7409. return err;
  7410. if (!spec->autocfg.line_outs)
  7411. return 0; /* can't find valid BIOS pin config */
  7412. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7413. if (err < 0)
  7414. return err;
  7415. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7416. if (err < 0)
  7417. return err;
  7418. spec->multiout.max_channels = 2;
  7419. /* digital only support output */
  7420. if (spec->autocfg.dig_out_pin)
  7421. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7422. if (spec->kctl_alloc)
  7423. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7424. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7425. spec->num_mux_defs = 1;
  7426. spec->input_mux = &spec->private_imux;
  7427. return 1;
  7428. }
  7429. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7430. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7431. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7432. /* init callback for auto-configuration model -- overriding the default init */
  7433. static void alc268_auto_init(struct hda_codec *codec)
  7434. {
  7435. alc268_auto_init_multi_out(codec);
  7436. alc268_auto_init_hp_out(codec);
  7437. alc268_auto_init_mono_speaker_out(codec);
  7438. alc268_auto_init_analog_input(codec);
  7439. }
  7440. /*
  7441. * configuration and preset
  7442. */
  7443. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7444. [ALC268_3ST] = "3stack",
  7445. [ALC268_AUTO] = "auto",
  7446. };
  7447. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7448. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7449. {}
  7450. };
  7451. static struct alc_config_preset alc268_presets[] = {
  7452. [ALC268_3ST] = {
  7453. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7454. .init_verbs = { alc268_base_init_verbs },
  7455. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7456. .dac_nids = alc268_dac_nids,
  7457. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7458. .adc_nids = alc268_adc_nids_alt,
  7459. .hp_nid = 0x03,
  7460. .dig_out_nid = ALC268_DIGOUT_NID,
  7461. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7462. .channel_mode = alc268_modes,
  7463. .input_mux = &alc268_capture_source,
  7464. },
  7465. };
  7466. static int patch_alc268(struct hda_codec *codec)
  7467. {
  7468. struct alc_spec *spec;
  7469. int board_config;
  7470. int err;
  7471. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7472. if (spec == NULL)
  7473. return -ENOMEM;
  7474. codec->spec = spec;
  7475. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7476. alc268_models,
  7477. alc268_cfg_tbl);
  7478. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7479. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7480. "trying auto-probe from BIOS...\n");
  7481. board_config = ALC268_AUTO;
  7482. }
  7483. if (board_config == ALC268_AUTO) {
  7484. /* automatic parse from the BIOS config */
  7485. err = alc268_parse_auto_config(codec);
  7486. if (err < 0) {
  7487. alc_free(codec);
  7488. return err;
  7489. } else if (!err) {
  7490. printk(KERN_INFO
  7491. "hda_codec: Cannot set up configuration "
  7492. "from BIOS. Using base mode...\n");
  7493. board_config = ALC268_3ST;
  7494. }
  7495. }
  7496. if (board_config != ALC268_AUTO)
  7497. setup_preset(spec, &alc268_presets[board_config]);
  7498. spec->stream_name_analog = "ALC268 Analog";
  7499. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7500. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7501. spec->stream_name_digital = "ALC268 Digital";
  7502. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7503. if (board_config == ALC268_AUTO) {
  7504. if (!spec->adc_nids && spec->input_mux) {
  7505. /* check whether NID 0x07 is valid */
  7506. unsigned int wcap = get_wcaps(codec, 0x07);
  7507. /* get type */
  7508. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7509. if (wcap != AC_WID_AUD_IN) {
  7510. spec->adc_nids = alc268_adc_nids_alt;
  7511. spec->num_adc_nids =
  7512. ARRAY_SIZE(alc268_adc_nids_alt);
  7513. spec->mixers[spec->num_mixers] =
  7514. alc268_capture_alt_mixer;
  7515. spec->num_mixers++;
  7516. } else {
  7517. spec->adc_nids = alc268_adc_nids;
  7518. spec->num_adc_nids =
  7519. ARRAY_SIZE(alc268_adc_nids);
  7520. spec->mixers[spec->num_mixers] =
  7521. alc268_capture_mixer;
  7522. spec->num_mixers++;
  7523. }
  7524. }
  7525. }
  7526. codec->patch_ops = alc_patch_ops;
  7527. if (board_config == ALC268_AUTO)
  7528. spec->init_hook = alc268_auto_init;
  7529. return 0;
  7530. }
  7531. /*
  7532. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7533. */
  7534. /*
  7535. * set the path ways for 2 channel output
  7536. * need to set the codec line out and mic 1 pin widgets to inputs
  7537. */
  7538. static struct hda_verb alc861_threestack_ch2_init[] = {
  7539. /* set pin widget 1Ah (line in) for input */
  7540. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7541. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7542. * the vref
  7543. */
  7544. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7545. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7546. #if 0
  7547. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7548. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7549. #endif
  7550. { } /* end */
  7551. };
  7552. /*
  7553. * 6ch mode
  7554. * need to set the codec line out and mic 1 pin widgets to outputs
  7555. */
  7556. static struct hda_verb alc861_threestack_ch6_init[] = {
  7557. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7558. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7559. /* set pin widget 18h (mic1) for output (CLFE)*/
  7560. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7561. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7562. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7563. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7564. #if 0
  7565. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7566. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7567. #endif
  7568. { } /* end */
  7569. };
  7570. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7571. { 2, alc861_threestack_ch2_init },
  7572. { 6, alc861_threestack_ch6_init },
  7573. };
  7574. /* Set mic1 as input and unmute the mixer */
  7575. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7576. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7577. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7578. { } /* end */
  7579. };
  7580. /* Set mic1 as output and mute mixer */
  7581. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7582. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7583. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7584. { } /* end */
  7585. };
  7586. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7587. { 2, alc861_uniwill_m31_ch2_init },
  7588. { 4, alc861_uniwill_m31_ch4_init },
  7589. };
  7590. /* Set mic1 and line-in as input and unmute the mixer */
  7591. static struct hda_verb alc861_asus_ch2_init[] = {
  7592. /* set pin widget 1Ah (line in) for input */
  7593. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7594. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7595. * the vref
  7596. */
  7597. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7598. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7599. #if 0
  7600. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7601. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7602. #endif
  7603. { } /* end */
  7604. };
  7605. /* Set mic1 nad line-in as output and mute mixer */
  7606. static struct hda_verb alc861_asus_ch6_init[] = {
  7607. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7608. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7609. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7610. /* set pin widget 18h (mic1) for output (CLFE)*/
  7611. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7612. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7613. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7614. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7615. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7616. #if 0
  7617. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7618. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7619. #endif
  7620. { } /* end */
  7621. };
  7622. static struct hda_channel_mode alc861_asus_modes[2] = {
  7623. { 2, alc861_asus_ch2_init },
  7624. { 6, alc861_asus_ch6_init },
  7625. };
  7626. /* patch-ALC861 */
  7627. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7628. /* output mixer control */
  7629. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7630. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7631. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7632. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7633. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7634. /*Input mixer control */
  7635. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7636. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7637. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7638. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7639. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7640. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7641. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7642. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7643. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7644. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7645. /* Capture mixer control */
  7646. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7647. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7648. {
  7649. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7650. .name = "Capture Source",
  7651. .count = 1,
  7652. .info = alc_mux_enum_info,
  7653. .get = alc_mux_enum_get,
  7654. .put = alc_mux_enum_put,
  7655. },
  7656. { } /* end */
  7657. };
  7658. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7659. /* output mixer control */
  7660. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7661. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7662. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7663. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7664. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7665. /* Input mixer control */
  7666. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7667. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7668. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7669. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7670. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7671. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7672. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7673. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7674. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7675. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7676. /* Capture mixer control */
  7677. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7678. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7679. {
  7680. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7681. .name = "Capture Source",
  7682. .count = 1,
  7683. .info = alc_mux_enum_info,
  7684. .get = alc_mux_enum_get,
  7685. .put = alc_mux_enum_put,
  7686. },
  7687. {
  7688. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7689. .name = "Channel Mode",
  7690. .info = alc_ch_mode_info,
  7691. .get = alc_ch_mode_get,
  7692. .put = alc_ch_mode_put,
  7693. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7694. },
  7695. { } /* end */
  7696. };
  7697. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  7698. /* output mixer control */
  7699. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7700. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7701. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7702. /*Capture mixer control */
  7703. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7704. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7705. {
  7706. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7707. .name = "Capture Source",
  7708. .count = 1,
  7709. .info = alc_mux_enum_info,
  7710. .get = alc_mux_enum_get,
  7711. .put = alc_mux_enum_put,
  7712. },
  7713. { } /* end */
  7714. };
  7715. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  7716. /* output mixer control */
  7717. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7718. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7719. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7720. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7721. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7722. /* Input mixer control */
  7723. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7724. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7725. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7726. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7727. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7728. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7729. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7730. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7731. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7732. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7733. /* Capture mixer control */
  7734. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7735. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7736. {
  7737. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7738. .name = "Capture Source",
  7739. .count = 1,
  7740. .info = alc_mux_enum_info,
  7741. .get = alc_mux_enum_get,
  7742. .put = alc_mux_enum_put,
  7743. },
  7744. {
  7745. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7746. .name = "Channel Mode",
  7747. .info = alc_ch_mode_info,
  7748. .get = alc_ch_mode_get,
  7749. .put = alc_ch_mode_put,
  7750. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7751. },
  7752. { } /* end */
  7753. };
  7754. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  7755. /* output mixer control */
  7756. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7757. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7758. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7759. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7760. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7761. /* Input mixer control */
  7762. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7763. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7764. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7765. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7766. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7767. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7768. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7769. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7770. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7771. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  7772. /* Capture mixer control */
  7773. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7774. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7775. {
  7776. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7777. .name = "Capture Source",
  7778. .count = 1,
  7779. .info = alc_mux_enum_info,
  7780. .get = alc_mux_enum_get,
  7781. .put = alc_mux_enum_put,
  7782. },
  7783. {
  7784. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7785. .name = "Channel Mode",
  7786. .info = alc_ch_mode_info,
  7787. .get = alc_ch_mode_get,
  7788. .put = alc_ch_mode_put,
  7789. .private_value = ARRAY_SIZE(alc861_asus_modes),
  7790. },
  7791. { }
  7792. };
  7793. /* additional mixer */
  7794. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  7795. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7796. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7797. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  7798. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  7799. { }
  7800. };
  7801. /*
  7802. * generic initialization of ADC, input mixers and output mixers
  7803. */
  7804. static struct hda_verb alc861_base_init_verbs[] = {
  7805. /*
  7806. * Unmute ADC0 and set the default input to mic-in
  7807. */
  7808. /* port-A for surround (rear panel) */
  7809. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7810. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7811. /* port-B for mic-in (rear panel) with vref */
  7812. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7813. /* port-C for line-in (rear panel) */
  7814. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7815. /* port-D for Front */
  7816. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7817. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7818. /* port-E for HP out (front panel) */
  7819. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7820. /* route front PCM to HP */
  7821. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7822. /* port-F for mic-in (front panel) with vref */
  7823. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7824. /* port-G for CLFE (rear panel) */
  7825. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7826. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7827. /* port-H for side (rear panel) */
  7828. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7829. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7830. /* CD-in */
  7831. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7832. /* route front mic to ADC1*/
  7833. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7834. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7835. /* Unmute DAC0~3 & spdif out*/
  7836. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7837. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7838. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7839. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7840. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7841. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7842. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7843. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7844. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7845. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7846. /* Unmute Stereo Mixer 15 */
  7847. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7848. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7849. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7850. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7851. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7852. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7853. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7854. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7855. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7856. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7857. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7858. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7859. /* hp used DAC 3 (Front) */
  7860. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7861. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7862. { }
  7863. };
  7864. static struct hda_verb alc861_threestack_init_verbs[] = {
  7865. /*
  7866. * Unmute ADC0 and set the default input to mic-in
  7867. */
  7868. /* port-A for surround (rear panel) */
  7869. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7870. /* port-B for mic-in (rear panel) with vref */
  7871. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7872. /* port-C for line-in (rear panel) */
  7873. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7874. /* port-D for Front */
  7875. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7876. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7877. /* port-E for HP out (front panel) */
  7878. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7879. /* route front PCM to HP */
  7880. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7881. /* port-F for mic-in (front panel) with vref */
  7882. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7883. /* port-G for CLFE (rear panel) */
  7884. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7885. /* port-H for side (rear panel) */
  7886. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7887. /* CD-in */
  7888. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7889. /* route front mic to ADC1*/
  7890. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7891. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7892. /* Unmute DAC0~3 & spdif out*/
  7893. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7894. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7895. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7896. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7897. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7898. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7899. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7900. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7901. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7902. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7903. /* Unmute Stereo Mixer 15 */
  7904. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7905. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7906. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7907. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7908. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7909. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7910. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7911. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7912. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7913. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7914. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7915. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7916. /* hp used DAC 3 (Front) */
  7917. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7918. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7919. { }
  7920. };
  7921. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  7922. /*
  7923. * Unmute ADC0 and set the default input to mic-in
  7924. */
  7925. /* port-A for surround (rear panel) */
  7926. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7927. /* port-B for mic-in (rear panel) with vref */
  7928. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7929. /* port-C for line-in (rear panel) */
  7930. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7931. /* port-D for Front */
  7932. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7933. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7934. /* port-E for HP out (front panel) */
  7935. /* this has to be set to VREF80 */
  7936. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7937. /* route front PCM to HP */
  7938. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7939. /* port-F for mic-in (front panel) with vref */
  7940. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7941. /* port-G for CLFE (rear panel) */
  7942. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7943. /* port-H for side (rear panel) */
  7944. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7945. /* CD-in */
  7946. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7947. /* route front mic to ADC1*/
  7948. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7949. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7950. /* Unmute DAC0~3 & spdif out*/
  7951. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7952. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7953. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7954. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7955. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7956. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7957. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7958. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7959. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7960. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7961. /* Unmute Stereo Mixer 15 */
  7962. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7963. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7964. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7965. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7966. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7967. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7968. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7969. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7970. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7971. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7972. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7973. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7974. /* hp used DAC 3 (Front) */
  7975. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7976. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7977. { }
  7978. };
  7979. static struct hda_verb alc861_asus_init_verbs[] = {
  7980. /*
  7981. * Unmute ADC0 and set the default input to mic-in
  7982. */
  7983. /* port-A for surround (rear panel)
  7984. * according to codec#0 this is the HP jack
  7985. */
  7986. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  7987. /* route front PCM to HP */
  7988. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  7989. /* port-B for mic-in (rear panel) with vref */
  7990. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7991. /* port-C for line-in (rear panel) */
  7992. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7993. /* port-D for Front */
  7994. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7995. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7996. /* port-E for HP out (front panel) */
  7997. /* this has to be set to VREF80 */
  7998. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7999. /* route front PCM to HP */
  8000. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8001. /* port-F for mic-in (front panel) with vref */
  8002. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8003. /* port-G for CLFE (rear panel) */
  8004. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8005. /* port-H for side (rear panel) */
  8006. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8007. /* CD-in */
  8008. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8009. /* route front mic to ADC1*/
  8010. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8011. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8012. /* Unmute DAC0~3 & spdif out*/
  8013. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8014. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8015. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8016. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8017. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8018. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8019. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8020. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8021. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8022. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8023. /* Unmute Stereo Mixer 15 */
  8024. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8025. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8026. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8027. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8028. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8029. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8030. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8031. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8032. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8033. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8034. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8035. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8036. /* hp used DAC 3 (Front) */
  8037. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8038. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8039. { }
  8040. };
  8041. /* additional init verbs for ASUS laptops */
  8042. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8043. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8044. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8045. { }
  8046. };
  8047. /*
  8048. * generic initialization of ADC, input mixers and output mixers
  8049. */
  8050. static struct hda_verb alc861_auto_init_verbs[] = {
  8051. /*
  8052. * Unmute ADC0 and set the default input to mic-in
  8053. */
  8054. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8055. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8056. /* Unmute DAC0~3 & spdif out*/
  8057. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8058. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8059. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8060. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8062. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8063. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8064. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8065. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8066. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8067. /* Unmute Stereo Mixer 15 */
  8068. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8069. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8070. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8071. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8072. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8073. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8074. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8075. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8076. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8077. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8078. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8079. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8080. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8081. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8082. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8083. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8084. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8085. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8086. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8087. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8088. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8089. { }
  8090. };
  8091. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8092. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8093. { }
  8094. };
  8095. /* toggle speaker-output according to the hp-jack state */
  8096. static void alc861_toshiba_automute(struct hda_codec *codec)
  8097. {
  8098. unsigned int present;
  8099. present = snd_hda_codec_read(codec, 0x0f, 0,
  8100. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8101. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  8102. 0x80, present ? 0x80 : 0);
  8103. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  8104. 0x80, present ? 0x80 : 0);
  8105. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  8106. 0x80, present ? 0 : 0x80);
  8107. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  8108. 0x80, present ? 0 : 0x80);
  8109. }
  8110. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8111. unsigned int res)
  8112. {
  8113. if ((res >> 26) == ALC880_HP_EVENT)
  8114. alc861_toshiba_automute(codec);
  8115. }
  8116. /* pcm configuration: identiacal with ALC880 */
  8117. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8118. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8119. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8120. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8121. #define ALC861_DIGOUT_NID 0x07
  8122. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8123. { 8, NULL }
  8124. };
  8125. static hda_nid_t alc861_dac_nids[4] = {
  8126. /* front, surround, clfe, side */
  8127. 0x03, 0x06, 0x05, 0x04
  8128. };
  8129. static hda_nid_t alc660_dac_nids[3] = {
  8130. /* front, clfe, surround */
  8131. 0x03, 0x05, 0x06
  8132. };
  8133. static hda_nid_t alc861_adc_nids[1] = {
  8134. /* ADC0-2 */
  8135. 0x08,
  8136. };
  8137. static struct hda_input_mux alc861_capture_source = {
  8138. .num_items = 5,
  8139. .items = {
  8140. { "Mic", 0x0 },
  8141. { "Front Mic", 0x3 },
  8142. { "Line", 0x1 },
  8143. { "CD", 0x4 },
  8144. { "Mixer", 0x5 },
  8145. },
  8146. };
  8147. /* fill in the dac_nids table from the parsed pin configuration */
  8148. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8149. const struct auto_pin_cfg *cfg)
  8150. {
  8151. int i;
  8152. hda_nid_t nid;
  8153. spec->multiout.dac_nids = spec->private_dac_nids;
  8154. for (i = 0; i < cfg->line_outs; i++) {
  8155. nid = cfg->line_out_pins[i];
  8156. if (nid) {
  8157. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8158. continue;
  8159. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8160. }
  8161. }
  8162. spec->multiout.num_dacs = cfg->line_outs;
  8163. return 0;
  8164. }
  8165. /* add playback controls from the parsed DAC table */
  8166. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8167. const struct auto_pin_cfg *cfg)
  8168. {
  8169. char name[32];
  8170. static const char *chname[4] = {
  8171. "Front", "Surround", NULL /*CLFE*/, "Side"
  8172. };
  8173. hda_nid_t nid;
  8174. int i, idx, err;
  8175. for (i = 0; i < cfg->line_outs; i++) {
  8176. nid = spec->multiout.dac_nids[i];
  8177. if (!nid)
  8178. continue;
  8179. if (nid == 0x05) {
  8180. /* Center/LFE */
  8181. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8182. "Center Playback Switch",
  8183. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8184. HDA_OUTPUT));
  8185. if (err < 0)
  8186. return err;
  8187. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8188. "LFE Playback Switch",
  8189. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8190. HDA_OUTPUT));
  8191. if (err < 0)
  8192. return err;
  8193. } else {
  8194. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8195. idx++)
  8196. if (nid == alc861_dac_nids[idx])
  8197. break;
  8198. sprintf(name, "%s Playback Switch", chname[idx]);
  8199. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8200. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8201. HDA_OUTPUT));
  8202. if (err < 0)
  8203. return err;
  8204. }
  8205. }
  8206. return 0;
  8207. }
  8208. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8209. {
  8210. int err;
  8211. hda_nid_t nid;
  8212. if (!pin)
  8213. return 0;
  8214. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8215. nid = 0x03;
  8216. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8217. "Headphone Playback Switch",
  8218. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8219. if (err < 0)
  8220. return err;
  8221. spec->multiout.hp_nid = nid;
  8222. }
  8223. return 0;
  8224. }
  8225. /* create playback/capture controls for input pins */
  8226. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8227. const struct auto_pin_cfg *cfg)
  8228. {
  8229. struct hda_input_mux *imux = &spec->private_imux;
  8230. int i, err, idx, idx1;
  8231. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8232. switch (cfg->input_pins[i]) {
  8233. case 0x0c:
  8234. idx1 = 1;
  8235. idx = 2; /* Line In */
  8236. break;
  8237. case 0x0f:
  8238. idx1 = 2;
  8239. idx = 2; /* Line In */
  8240. break;
  8241. case 0x0d:
  8242. idx1 = 0;
  8243. idx = 1; /* Mic In */
  8244. break;
  8245. case 0x10:
  8246. idx1 = 3;
  8247. idx = 1; /* Mic In */
  8248. break;
  8249. case 0x11:
  8250. idx1 = 4;
  8251. idx = 0; /* CD */
  8252. break;
  8253. default:
  8254. continue;
  8255. }
  8256. err = new_analog_input(spec, cfg->input_pins[i],
  8257. auto_pin_cfg_labels[i], idx, 0x15);
  8258. if (err < 0)
  8259. return err;
  8260. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8261. imux->items[imux->num_items].index = idx1;
  8262. imux->num_items++;
  8263. }
  8264. return 0;
  8265. }
  8266. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8267. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8268. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8269. {
  8270. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8271. /* The multiple "Capture Source" controls confuse alsamixer
  8272. * So call somewhat different..
  8273. *FIXME: the controls appear in the "playback" view!
  8274. */
  8275. /* .name = "Capture Source", */
  8276. .name = "Input Source",
  8277. .count = 1,
  8278. .info = alc_mux_enum_info,
  8279. .get = alc_mux_enum_get,
  8280. .put = alc_mux_enum_put,
  8281. },
  8282. { } /* end */
  8283. };
  8284. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8285. hda_nid_t nid,
  8286. int pin_type, int dac_idx)
  8287. {
  8288. /* set as output */
  8289. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8290. pin_type);
  8291. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8292. AMP_OUT_UNMUTE);
  8293. }
  8294. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8295. {
  8296. struct alc_spec *spec = codec->spec;
  8297. int i;
  8298. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8299. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8300. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8301. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8302. if (nid)
  8303. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8304. spec->multiout.dac_nids[i]);
  8305. }
  8306. }
  8307. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8308. {
  8309. struct alc_spec *spec = codec->spec;
  8310. hda_nid_t pin;
  8311. pin = spec->autocfg.hp_pins[0];
  8312. if (pin) /* connect to front */
  8313. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8314. spec->multiout.dac_nids[0]);
  8315. }
  8316. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8317. {
  8318. struct alc_spec *spec = codec->spec;
  8319. int i;
  8320. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8321. hda_nid_t nid = spec->autocfg.input_pins[i];
  8322. if (nid >= 0x0c && nid <= 0x11) {
  8323. snd_hda_codec_write(codec, nid, 0,
  8324. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8325. i <= AUTO_PIN_FRONT_MIC ?
  8326. PIN_VREF80 : PIN_IN);
  8327. }
  8328. }
  8329. }
  8330. /* parse the BIOS configuration and set up the alc_spec */
  8331. /* return 1 if successful, 0 if the proper config is not found,
  8332. * or a negative error code
  8333. */
  8334. static int alc861_parse_auto_config(struct hda_codec *codec)
  8335. {
  8336. struct alc_spec *spec = codec->spec;
  8337. int err;
  8338. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8339. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8340. alc861_ignore);
  8341. if (err < 0)
  8342. return err;
  8343. if (!spec->autocfg.line_outs)
  8344. return 0; /* can't find valid BIOS pin config */
  8345. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8346. if (err < 0)
  8347. return err;
  8348. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8349. if (err < 0)
  8350. return err;
  8351. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8352. if (err < 0)
  8353. return err;
  8354. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8355. if (err < 0)
  8356. return err;
  8357. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8358. if (spec->autocfg.dig_out_pin)
  8359. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8360. if (spec->kctl_alloc)
  8361. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8362. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8363. spec->num_mux_defs = 1;
  8364. spec->input_mux = &spec->private_imux;
  8365. spec->adc_nids = alc861_adc_nids;
  8366. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8367. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8368. spec->num_mixers++;
  8369. return 1;
  8370. }
  8371. /* additional initialization for auto-configuration model */
  8372. static void alc861_auto_init(struct hda_codec *codec)
  8373. {
  8374. alc861_auto_init_multi_out(codec);
  8375. alc861_auto_init_hp_out(codec);
  8376. alc861_auto_init_analog_input(codec);
  8377. }
  8378. /*
  8379. * configuration and preset
  8380. */
  8381. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8382. [ALC861_3ST] = "3stack",
  8383. [ALC660_3ST] = "3stack-660",
  8384. [ALC861_3ST_DIG] = "3stack-dig",
  8385. [ALC861_6ST_DIG] = "6stack-dig",
  8386. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8387. [ALC861_TOSHIBA] = "toshiba",
  8388. [ALC861_ASUS] = "asus",
  8389. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8390. [ALC861_AUTO] = "auto",
  8391. };
  8392. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8393. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8394. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8395. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8396. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8397. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8398. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8399. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  8400. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8401. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8402. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8403. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8404. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8405. {}
  8406. };
  8407. static struct alc_config_preset alc861_presets[] = {
  8408. [ALC861_3ST] = {
  8409. .mixers = { alc861_3ST_mixer },
  8410. .init_verbs = { alc861_threestack_init_verbs },
  8411. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8412. .dac_nids = alc861_dac_nids,
  8413. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8414. .channel_mode = alc861_threestack_modes,
  8415. .need_dac_fix = 1,
  8416. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8417. .adc_nids = alc861_adc_nids,
  8418. .input_mux = &alc861_capture_source,
  8419. },
  8420. [ALC861_3ST_DIG] = {
  8421. .mixers = { alc861_base_mixer },
  8422. .init_verbs = { alc861_threestack_init_verbs },
  8423. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8424. .dac_nids = alc861_dac_nids,
  8425. .dig_out_nid = ALC861_DIGOUT_NID,
  8426. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8427. .channel_mode = alc861_threestack_modes,
  8428. .need_dac_fix = 1,
  8429. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8430. .adc_nids = alc861_adc_nids,
  8431. .input_mux = &alc861_capture_source,
  8432. },
  8433. [ALC861_6ST_DIG] = {
  8434. .mixers = { alc861_base_mixer },
  8435. .init_verbs = { alc861_base_init_verbs },
  8436. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8437. .dac_nids = alc861_dac_nids,
  8438. .dig_out_nid = ALC861_DIGOUT_NID,
  8439. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8440. .channel_mode = alc861_8ch_modes,
  8441. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8442. .adc_nids = alc861_adc_nids,
  8443. .input_mux = &alc861_capture_source,
  8444. },
  8445. [ALC660_3ST] = {
  8446. .mixers = { alc861_3ST_mixer },
  8447. .init_verbs = { alc861_threestack_init_verbs },
  8448. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8449. .dac_nids = alc660_dac_nids,
  8450. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8451. .channel_mode = alc861_threestack_modes,
  8452. .need_dac_fix = 1,
  8453. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8454. .adc_nids = alc861_adc_nids,
  8455. .input_mux = &alc861_capture_source,
  8456. },
  8457. [ALC861_UNIWILL_M31] = {
  8458. .mixers = { alc861_uniwill_m31_mixer },
  8459. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8460. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8461. .dac_nids = alc861_dac_nids,
  8462. .dig_out_nid = ALC861_DIGOUT_NID,
  8463. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8464. .channel_mode = alc861_uniwill_m31_modes,
  8465. .need_dac_fix = 1,
  8466. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8467. .adc_nids = alc861_adc_nids,
  8468. .input_mux = &alc861_capture_source,
  8469. },
  8470. [ALC861_TOSHIBA] = {
  8471. .mixers = { alc861_toshiba_mixer },
  8472. .init_verbs = { alc861_base_init_verbs,
  8473. alc861_toshiba_init_verbs },
  8474. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8475. .dac_nids = alc861_dac_nids,
  8476. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8477. .channel_mode = alc883_3ST_2ch_modes,
  8478. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8479. .adc_nids = alc861_adc_nids,
  8480. .input_mux = &alc861_capture_source,
  8481. .unsol_event = alc861_toshiba_unsol_event,
  8482. .init_hook = alc861_toshiba_automute,
  8483. },
  8484. [ALC861_ASUS] = {
  8485. .mixers = { alc861_asus_mixer },
  8486. .init_verbs = { alc861_asus_init_verbs },
  8487. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8488. .dac_nids = alc861_dac_nids,
  8489. .dig_out_nid = ALC861_DIGOUT_NID,
  8490. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8491. .channel_mode = alc861_asus_modes,
  8492. .need_dac_fix = 1,
  8493. .hp_nid = 0x06,
  8494. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8495. .adc_nids = alc861_adc_nids,
  8496. .input_mux = &alc861_capture_source,
  8497. },
  8498. [ALC861_ASUS_LAPTOP] = {
  8499. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8500. .init_verbs = { alc861_asus_init_verbs,
  8501. alc861_asus_laptop_init_verbs },
  8502. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8503. .dac_nids = alc861_dac_nids,
  8504. .dig_out_nid = ALC861_DIGOUT_NID,
  8505. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8506. .channel_mode = alc883_3ST_2ch_modes,
  8507. .need_dac_fix = 1,
  8508. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8509. .adc_nids = alc861_adc_nids,
  8510. .input_mux = &alc861_capture_source,
  8511. },
  8512. };
  8513. static int patch_alc861(struct hda_codec *codec)
  8514. {
  8515. struct alc_spec *spec;
  8516. int board_config;
  8517. int err;
  8518. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8519. if (spec == NULL)
  8520. return -ENOMEM;
  8521. codec->spec = spec;
  8522. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8523. alc861_models,
  8524. alc861_cfg_tbl);
  8525. if (board_config < 0) {
  8526. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8527. "trying auto-probe from BIOS...\n");
  8528. board_config = ALC861_AUTO;
  8529. }
  8530. if (board_config == ALC861_AUTO) {
  8531. /* automatic parse from the BIOS config */
  8532. err = alc861_parse_auto_config(codec);
  8533. if (err < 0) {
  8534. alc_free(codec);
  8535. return err;
  8536. } else if (!err) {
  8537. printk(KERN_INFO
  8538. "hda_codec: Cannot set up configuration "
  8539. "from BIOS. Using base mode...\n");
  8540. board_config = ALC861_3ST_DIG;
  8541. }
  8542. }
  8543. if (board_config != ALC861_AUTO)
  8544. setup_preset(spec, &alc861_presets[board_config]);
  8545. spec->stream_name_analog = "ALC861 Analog";
  8546. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8547. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8548. spec->stream_name_digital = "ALC861 Digital";
  8549. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8550. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8551. codec->patch_ops = alc_patch_ops;
  8552. if (board_config == ALC861_AUTO)
  8553. spec->init_hook = alc861_auto_init;
  8554. return 0;
  8555. }
  8556. /*
  8557. * ALC861-VD support
  8558. *
  8559. * Based on ALC882
  8560. *
  8561. * In addition, an independent DAC
  8562. */
  8563. #define ALC861VD_DIGOUT_NID 0x06
  8564. static hda_nid_t alc861vd_dac_nids[4] = {
  8565. /* front, surr, clfe, side surr */
  8566. 0x02, 0x03, 0x04, 0x05
  8567. };
  8568. /* dac_nids for ALC660vd are in a different order - according to
  8569. * Realtek's driver.
  8570. * This should probably tesult in a different mixer for 6stack models
  8571. * of ALC660vd codecs, but for now there is only 3stack mixer
  8572. * - and it is the same as in 861vd.
  8573. * adc_nids in ALC660vd are (is) the same as in 861vd
  8574. */
  8575. static hda_nid_t alc660vd_dac_nids[3] = {
  8576. /* front, rear, clfe, rear_surr */
  8577. 0x02, 0x04, 0x03
  8578. };
  8579. static hda_nid_t alc861vd_adc_nids[1] = {
  8580. /* ADC0 */
  8581. 0x09,
  8582. };
  8583. /* input MUX */
  8584. /* FIXME: should be a matrix-type input source selection */
  8585. static struct hda_input_mux alc861vd_capture_source = {
  8586. .num_items = 4,
  8587. .items = {
  8588. { "Mic", 0x0 },
  8589. { "Front Mic", 0x1 },
  8590. { "Line", 0x2 },
  8591. { "CD", 0x4 },
  8592. },
  8593. };
  8594. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8595. .num_items = 3,
  8596. .items = {
  8597. { "Front Mic", 0x0 },
  8598. { "ATAPI Mic", 0x1 },
  8599. { "Line In", 0x5 },
  8600. },
  8601. };
  8602. #define alc861vd_mux_enum_info alc_mux_enum_info
  8603. #define alc861vd_mux_enum_get alc_mux_enum_get
  8604. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8605. struct snd_ctl_elem_value *ucontrol)
  8606. {
  8607. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8608. struct alc_spec *spec = codec->spec;
  8609. const struct hda_input_mux *imux = spec->input_mux;
  8610. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8611. static hda_nid_t capture_mixers[1] = { 0x22 };
  8612. hda_nid_t nid = capture_mixers[adc_idx];
  8613. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8614. unsigned int i, idx;
  8615. idx = ucontrol->value.enumerated.item[0];
  8616. if (idx >= imux->num_items)
  8617. idx = imux->num_items - 1;
  8618. if (*cur_val == idx && !codec->in_resume)
  8619. return 0;
  8620. for (i = 0; i < imux->num_items; i++) {
  8621. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8622. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8623. v | (imux->items[i].index << 8));
  8624. }
  8625. *cur_val = idx;
  8626. return 1;
  8627. }
  8628. /*
  8629. * 2ch mode
  8630. */
  8631. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8632. { 2, NULL }
  8633. };
  8634. /*
  8635. * 6ch mode
  8636. */
  8637. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8638. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8639. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8640. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8641. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8642. { } /* end */
  8643. };
  8644. /*
  8645. * 8ch mode
  8646. */
  8647. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8648. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8649. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8650. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8651. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8652. { } /* end */
  8653. };
  8654. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8655. { 6, alc861vd_6stack_ch6_init },
  8656. { 8, alc861vd_6stack_ch8_init },
  8657. };
  8658. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8659. {
  8660. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8661. .name = "Channel Mode",
  8662. .info = alc_ch_mode_info,
  8663. .get = alc_ch_mode_get,
  8664. .put = alc_ch_mode_put,
  8665. },
  8666. { } /* end */
  8667. };
  8668. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8669. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8670. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8671. {
  8672. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8673. /* The multiple "Capture Source" controls confuse alsamixer
  8674. * So call somewhat different..
  8675. *FIXME: the controls appear in the "playback" view!
  8676. */
  8677. /* .name = "Capture Source", */
  8678. .name = "Input Source",
  8679. .count = 1,
  8680. .info = alc861vd_mux_enum_info,
  8681. .get = alc861vd_mux_enum_get,
  8682. .put = alc861vd_mux_enum_put,
  8683. },
  8684. { } /* end */
  8685. };
  8686. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8687. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8688. */
  8689. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  8690. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8691. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8692. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8693. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  8694. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  8695. HDA_OUTPUT),
  8696. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  8697. HDA_OUTPUT),
  8698. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  8699. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  8700. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  8701. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  8702. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8703. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8704. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8705. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8706. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8707. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8708. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8709. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8710. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8711. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8712. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8713. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8714. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8715. { } /* end */
  8716. };
  8717. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  8718. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8719. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8720. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8721. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8722. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8723. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8724. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8725. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8726. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8727. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8728. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8729. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8730. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8731. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8732. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8733. { } /* end */
  8734. };
  8735. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  8736. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8737. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  8738. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8739. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8740. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8741. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8742. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8743. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8744. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8745. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8746. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8747. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8748. { } /* end */
  8749. };
  8750. /* Pin assignment: Front=0x14, HP = 0x15,
  8751. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  8752. */
  8753. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  8754. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8755. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8756. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8757. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  8758. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8759. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8760. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8761. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8762. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8763. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8764. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8765. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8766. {
  8767. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8768. /* .name = "Capture Source", */
  8769. .name = "Input Source",
  8770. .count = 1,
  8771. .info = alc882_mux_enum_info,
  8772. .get = alc882_mux_enum_get,
  8773. .put = alc882_mux_enum_put,
  8774. },
  8775. { } /* end */
  8776. };
  8777. /*
  8778. * generic initialization of ADC, input mixers and output mixers
  8779. */
  8780. static struct hda_verb alc861vd_volume_init_verbs[] = {
  8781. /*
  8782. * Unmute ADC0 and set the default input to mic-in
  8783. */
  8784. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8785. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8786. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  8787. * the analog-loopback mixer widget
  8788. */
  8789. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  8790. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8791. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8792. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8793. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8794. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8795. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  8796. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8797. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8798. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8799. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8800. /*
  8801. * Set up output mixers (0x02 - 0x05)
  8802. */
  8803. /* set vol=0 to output mixers */
  8804. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8805. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8806. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8807. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8808. /* set up input amps for analog loopback */
  8809. /* Amp Indices: DAC = 0, mixer = 1 */
  8810. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8811. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8812. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8813. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8814. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8815. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8816. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8817. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8818. { }
  8819. };
  8820. /*
  8821. * 3-stack pin configuration:
  8822. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  8823. */
  8824. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  8825. /*
  8826. * Set pin mode and muting
  8827. */
  8828. /* set front pin widgets 0x14 for output */
  8829. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8830. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8831. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8832. /* Mic (rear) pin: input vref at 80% */
  8833. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8834. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8835. /* Front Mic pin: input vref at 80% */
  8836. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8837. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8838. /* Line In pin: input */
  8839. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8840. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8841. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8842. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8843. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8844. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8845. /* CD pin widget for input */
  8846. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8847. { }
  8848. };
  8849. /*
  8850. * 6-stack pin configuration:
  8851. */
  8852. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  8853. /*
  8854. * Set pin mode and muting
  8855. */
  8856. /* set front pin widgets 0x14 for output */
  8857. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8858. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8859. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8860. /* Rear Pin: output 1 (0x0d) */
  8861. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8862. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8863. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  8864. /* CLFE Pin: output 2 (0x0e) */
  8865. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8866. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8867. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  8868. /* Side Pin: output 3 (0x0f) */
  8869. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8870. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8871. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  8872. /* Mic (rear) pin: input vref at 80% */
  8873. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8874. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8875. /* Front Mic pin: input vref at 80% */
  8876. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8877. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8878. /* Line In pin: input */
  8879. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8880. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8881. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8882. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8883. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8884. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8885. /* CD pin widget for input */
  8886. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8887. { }
  8888. };
  8889. static struct hda_verb alc861vd_eapd_verbs[] = {
  8890. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8891. { }
  8892. };
  8893. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  8894. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8895. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8896. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  8897. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8898. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  8899. {}
  8900. };
  8901. /* toggle speaker-output according to the hp-jack state */
  8902. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  8903. {
  8904. unsigned int present;
  8905. unsigned char bits;
  8906. present = snd_hda_codec_read(codec, 0x1b, 0,
  8907. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8908. bits = present ? 0x80 : 0;
  8909. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8910. 0x80, bits);
  8911. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8912. 0x80, bits);
  8913. }
  8914. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  8915. {
  8916. unsigned int present;
  8917. unsigned char bits;
  8918. present = snd_hda_codec_read(codec, 0x18, 0,
  8919. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8920. bits = present ? 0x80 : 0;
  8921. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  8922. 0x80, bits);
  8923. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  8924. 0x80, bits);
  8925. }
  8926. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  8927. {
  8928. alc861vd_lenovo_hp_automute(codec);
  8929. alc861vd_lenovo_mic_automute(codec);
  8930. }
  8931. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  8932. unsigned int res)
  8933. {
  8934. switch (res >> 26) {
  8935. case ALC880_HP_EVENT:
  8936. alc861vd_lenovo_hp_automute(codec);
  8937. break;
  8938. case ALC880_MIC_EVENT:
  8939. alc861vd_lenovo_mic_automute(codec);
  8940. break;
  8941. }
  8942. }
  8943. static struct hda_verb alc861vd_dallas_verbs[] = {
  8944. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8945. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8946. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8947. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8948. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8949. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8950. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8951. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8952. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8953. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8954. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8955. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8956. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8957. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8958. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8959. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8960. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8961. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8962. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8963. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8964. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8965. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8966. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  8967. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8968. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8969. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8970. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8971. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8972. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8973. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  8974. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  8975. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  8976. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8977. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8978. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8979. { } /* end */
  8980. };
  8981. /* toggle speaker-output according to the hp-jack state */
  8982. static void alc861vd_dallas_automute(struct hda_codec *codec)
  8983. {
  8984. unsigned int present;
  8985. present = snd_hda_codec_read(codec, 0x15, 0,
  8986. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8987. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8988. 0x80, present ? 0x80 : 0);
  8989. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8990. 0x80, present ? 0x80 : 0);
  8991. }
  8992. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  8993. {
  8994. if ((res >> 26) == ALC880_HP_EVENT)
  8995. alc861vd_dallas_automute(codec);
  8996. }
  8997. /* pcm configuration: identiacal with ALC880 */
  8998. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  8999. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9000. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9001. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9002. /*
  9003. * configuration and preset
  9004. */
  9005. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9006. [ALC660VD_3ST] = "3stack-660",
  9007. [ALC660VD_3ST_DIG]= "3stack-660-digout",
  9008. [ALC861VD_3ST] = "3stack",
  9009. [ALC861VD_3ST_DIG] = "3stack-digout",
  9010. [ALC861VD_6ST_DIG] = "6stack-digout",
  9011. [ALC861VD_LENOVO] = "lenovo",
  9012. [ALC861VD_DALLAS] = "dallas",
  9013. [ALC861VD_AUTO] = "auto",
  9014. };
  9015. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9016. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9017. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9018. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9019. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9020. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9021. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9022. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9023. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9024. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9025. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9026. {}
  9027. };
  9028. static struct alc_config_preset alc861vd_presets[] = {
  9029. [ALC660VD_3ST] = {
  9030. .mixers = { alc861vd_3st_mixer },
  9031. .init_verbs = { alc861vd_volume_init_verbs,
  9032. alc861vd_3stack_init_verbs },
  9033. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9034. .dac_nids = alc660vd_dac_nids,
  9035. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9036. .adc_nids = alc861vd_adc_nids,
  9037. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9038. .channel_mode = alc861vd_3stack_2ch_modes,
  9039. .input_mux = &alc861vd_capture_source,
  9040. },
  9041. [ALC660VD_3ST_DIG] = {
  9042. .mixers = { alc861vd_3st_mixer },
  9043. .init_verbs = { alc861vd_volume_init_verbs,
  9044. alc861vd_3stack_init_verbs },
  9045. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9046. .dac_nids = alc660vd_dac_nids,
  9047. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9048. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9049. .adc_nids = alc861vd_adc_nids,
  9050. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9051. .channel_mode = alc861vd_3stack_2ch_modes,
  9052. .input_mux = &alc861vd_capture_source,
  9053. },
  9054. [ALC861VD_3ST] = {
  9055. .mixers = { alc861vd_3st_mixer },
  9056. .init_verbs = { alc861vd_volume_init_verbs,
  9057. alc861vd_3stack_init_verbs },
  9058. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9059. .dac_nids = alc861vd_dac_nids,
  9060. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9061. .channel_mode = alc861vd_3stack_2ch_modes,
  9062. .input_mux = &alc861vd_capture_source,
  9063. },
  9064. [ALC861VD_3ST_DIG] = {
  9065. .mixers = { alc861vd_3st_mixer },
  9066. .init_verbs = { alc861vd_volume_init_verbs,
  9067. alc861vd_3stack_init_verbs },
  9068. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9069. .dac_nids = alc861vd_dac_nids,
  9070. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9071. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9072. .channel_mode = alc861vd_3stack_2ch_modes,
  9073. .input_mux = &alc861vd_capture_source,
  9074. },
  9075. [ALC861VD_6ST_DIG] = {
  9076. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9077. .init_verbs = { alc861vd_volume_init_verbs,
  9078. alc861vd_6stack_init_verbs },
  9079. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9080. .dac_nids = alc861vd_dac_nids,
  9081. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9082. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9083. .channel_mode = alc861vd_6stack_modes,
  9084. .input_mux = &alc861vd_capture_source,
  9085. },
  9086. [ALC861VD_LENOVO] = {
  9087. .mixers = { alc861vd_lenovo_mixer },
  9088. .init_verbs = { alc861vd_volume_init_verbs,
  9089. alc861vd_3stack_init_verbs,
  9090. alc861vd_eapd_verbs,
  9091. alc861vd_lenovo_unsol_verbs },
  9092. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9093. .dac_nids = alc660vd_dac_nids,
  9094. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9095. .adc_nids = alc861vd_adc_nids,
  9096. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9097. .channel_mode = alc861vd_3stack_2ch_modes,
  9098. .input_mux = &alc861vd_capture_source,
  9099. .unsol_event = alc861vd_lenovo_unsol_event,
  9100. .init_hook = alc861vd_lenovo_automute,
  9101. },
  9102. [ALC861VD_DALLAS] = {
  9103. .mixers = { alc861vd_dallas_mixer },
  9104. .init_verbs = { alc861vd_dallas_verbs },
  9105. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9106. .dac_nids = alc861vd_dac_nids,
  9107. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9108. .adc_nids = alc861vd_adc_nids,
  9109. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9110. .channel_mode = alc861vd_3stack_2ch_modes,
  9111. .input_mux = &alc861vd_dallas_capture_source,
  9112. .unsol_event = alc861vd_dallas_unsol_event,
  9113. .init_hook = alc861vd_dallas_automute,
  9114. },
  9115. };
  9116. /*
  9117. * BIOS auto configuration
  9118. */
  9119. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9120. hda_nid_t nid, int pin_type, int dac_idx)
  9121. {
  9122. /* set as output */
  9123. snd_hda_codec_write(codec, nid, 0,
  9124. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9125. snd_hda_codec_write(codec, nid, 0,
  9126. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9127. }
  9128. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9129. {
  9130. struct alc_spec *spec = codec->spec;
  9131. int i;
  9132. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9133. for (i = 0; i <= HDA_SIDE; i++) {
  9134. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9135. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9136. if (nid)
  9137. alc861vd_auto_set_output_and_unmute(codec, nid,
  9138. pin_type, i);
  9139. }
  9140. }
  9141. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9142. {
  9143. struct alc_spec *spec = codec->spec;
  9144. hda_nid_t pin;
  9145. pin = spec->autocfg.hp_pins[0];
  9146. if (pin) /* connect to front and use dac 0 */
  9147. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9148. }
  9149. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9150. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9151. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9152. {
  9153. struct alc_spec *spec = codec->spec;
  9154. int i;
  9155. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9156. hda_nid_t nid = spec->autocfg.input_pins[i];
  9157. if (alc861vd_is_input_pin(nid)) {
  9158. snd_hda_codec_write(codec, nid, 0,
  9159. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9160. i <= AUTO_PIN_FRONT_MIC ?
  9161. PIN_VREF80 : PIN_IN);
  9162. if (nid != ALC861VD_PIN_CD_NID)
  9163. snd_hda_codec_write(codec, nid, 0,
  9164. AC_VERB_SET_AMP_GAIN_MUTE,
  9165. AMP_OUT_MUTE);
  9166. }
  9167. }
  9168. }
  9169. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9170. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9171. /* add playback controls from the parsed DAC table */
  9172. /* Based on ALC880 version. But ALC861VD has separate,
  9173. * different NIDs for mute/unmute switch and volume control */
  9174. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9175. const struct auto_pin_cfg *cfg)
  9176. {
  9177. char name[32];
  9178. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9179. hda_nid_t nid_v, nid_s;
  9180. int i, err;
  9181. for (i = 0; i < cfg->line_outs; i++) {
  9182. if (!spec->multiout.dac_nids[i])
  9183. continue;
  9184. nid_v = alc861vd_idx_to_mixer_vol(
  9185. alc880_dac_to_idx(
  9186. spec->multiout.dac_nids[i]));
  9187. nid_s = alc861vd_idx_to_mixer_switch(
  9188. alc880_dac_to_idx(
  9189. spec->multiout.dac_nids[i]));
  9190. if (i == 2) {
  9191. /* Center/LFE */
  9192. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9193. "Center Playback Volume",
  9194. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9195. HDA_OUTPUT));
  9196. if (err < 0)
  9197. return err;
  9198. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9199. "LFE Playback Volume",
  9200. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9201. HDA_OUTPUT));
  9202. if (err < 0)
  9203. return err;
  9204. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9205. "Center Playback Switch",
  9206. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9207. HDA_INPUT));
  9208. if (err < 0)
  9209. return err;
  9210. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9211. "LFE Playback Switch",
  9212. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9213. HDA_INPUT));
  9214. if (err < 0)
  9215. return err;
  9216. } else {
  9217. sprintf(name, "%s Playback Volume", chname[i]);
  9218. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9219. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9220. HDA_OUTPUT));
  9221. if (err < 0)
  9222. return err;
  9223. sprintf(name, "%s Playback Switch", chname[i]);
  9224. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9225. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9226. HDA_INPUT));
  9227. if (err < 0)
  9228. return err;
  9229. }
  9230. }
  9231. return 0;
  9232. }
  9233. /* add playback controls for speaker and HP outputs */
  9234. /* Based on ALC880 version. But ALC861VD has separate,
  9235. * different NIDs for mute/unmute switch and volume control */
  9236. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9237. hda_nid_t pin, const char *pfx)
  9238. {
  9239. hda_nid_t nid_v, nid_s;
  9240. int err;
  9241. char name[32];
  9242. if (!pin)
  9243. return 0;
  9244. if (alc880_is_fixed_pin(pin)) {
  9245. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9246. /* specify the DAC as the extra output */
  9247. if (!spec->multiout.hp_nid)
  9248. spec->multiout.hp_nid = nid_v;
  9249. else
  9250. spec->multiout.extra_out_nid[0] = nid_v;
  9251. /* control HP volume/switch on the output mixer amp */
  9252. nid_v = alc861vd_idx_to_mixer_vol(
  9253. alc880_fixed_pin_idx(pin));
  9254. nid_s = alc861vd_idx_to_mixer_switch(
  9255. alc880_fixed_pin_idx(pin));
  9256. sprintf(name, "%s Playback Volume", pfx);
  9257. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9258. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9259. if (err < 0)
  9260. return err;
  9261. sprintf(name, "%s Playback Switch", pfx);
  9262. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9263. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9264. if (err < 0)
  9265. return err;
  9266. } else if (alc880_is_multi_pin(pin)) {
  9267. /* set manual connection */
  9268. /* we have only a switch on HP-out PIN */
  9269. sprintf(name, "%s Playback Switch", pfx);
  9270. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9271. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9272. if (err < 0)
  9273. return err;
  9274. }
  9275. return 0;
  9276. }
  9277. /* parse the BIOS configuration and set up the alc_spec
  9278. * return 1 if successful, 0 if the proper config is not found,
  9279. * or a negative error code
  9280. * Based on ALC880 version - had to change it to override
  9281. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9282. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9283. {
  9284. struct alc_spec *spec = codec->spec;
  9285. int err;
  9286. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9287. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9288. alc861vd_ignore);
  9289. if (err < 0)
  9290. return err;
  9291. if (!spec->autocfg.line_outs)
  9292. return 0; /* can't find valid BIOS pin config */
  9293. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9294. if (err < 0)
  9295. return err;
  9296. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9297. if (err < 0)
  9298. return err;
  9299. err = alc861vd_auto_create_extra_out(spec,
  9300. spec->autocfg.speaker_pins[0],
  9301. "Speaker");
  9302. if (err < 0)
  9303. return err;
  9304. err = alc861vd_auto_create_extra_out(spec,
  9305. spec->autocfg.hp_pins[0],
  9306. "Headphone");
  9307. if (err < 0)
  9308. return err;
  9309. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9310. if (err < 0)
  9311. return err;
  9312. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9313. if (spec->autocfg.dig_out_pin)
  9314. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9315. if (spec->kctl_alloc)
  9316. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9317. spec->init_verbs[spec->num_init_verbs++]
  9318. = alc861vd_volume_init_verbs;
  9319. spec->num_mux_defs = 1;
  9320. spec->input_mux = &spec->private_imux;
  9321. return 1;
  9322. }
  9323. /* additional initialization for auto-configuration model */
  9324. static void alc861vd_auto_init(struct hda_codec *codec)
  9325. {
  9326. alc861vd_auto_init_multi_out(codec);
  9327. alc861vd_auto_init_hp_out(codec);
  9328. alc861vd_auto_init_analog_input(codec);
  9329. }
  9330. static int patch_alc861vd(struct hda_codec *codec)
  9331. {
  9332. struct alc_spec *spec;
  9333. int err, board_config;
  9334. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9335. if (spec == NULL)
  9336. return -ENOMEM;
  9337. codec->spec = spec;
  9338. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9339. alc861vd_models,
  9340. alc861vd_cfg_tbl);
  9341. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9342. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9343. "ALC861VD, trying auto-probe from BIOS...\n");
  9344. board_config = ALC861VD_AUTO;
  9345. }
  9346. if (board_config == ALC861VD_AUTO) {
  9347. /* automatic parse from the BIOS config */
  9348. err = alc861vd_parse_auto_config(codec);
  9349. if (err < 0) {
  9350. alc_free(codec);
  9351. return err;
  9352. } else if (!err) {
  9353. printk(KERN_INFO
  9354. "hda_codec: Cannot set up configuration "
  9355. "from BIOS. Using base mode...\n");
  9356. board_config = ALC861VD_3ST;
  9357. }
  9358. }
  9359. if (board_config != ALC861VD_AUTO)
  9360. setup_preset(spec, &alc861vd_presets[board_config]);
  9361. spec->stream_name_analog = "ALC861VD Analog";
  9362. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9363. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9364. spec->stream_name_digital = "ALC861VD Digital";
  9365. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9366. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9367. spec->adc_nids = alc861vd_adc_nids;
  9368. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9369. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9370. spec->num_mixers++;
  9371. codec->patch_ops = alc_patch_ops;
  9372. if (board_config == ALC861VD_AUTO)
  9373. spec->init_hook = alc861vd_auto_init;
  9374. return 0;
  9375. }
  9376. /*
  9377. * ALC662 support
  9378. *
  9379. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9380. * configuration. Each pin widget can choose any input DACs and a mixer.
  9381. * Each ADC is connected from a mixer of all inputs. This makes possible
  9382. * 6-channel independent captures.
  9383. *
  9384. * In addition, an independent DAC for the multi-playback (not used in this
  9385. * driver yet).
  9386. */
  9387. #define ALC662_DIGOUT_NID 0x06
  9388. #define ALC662_DIGIN_NID 0x0a
  9389. static hda_nid_t alc662_dac_nids[4] = {
  9390. /* front, rear, clfe, rear_surr */
  9391. 0x02, 0x03, 0x04
  9392. };
  9393. static hda_nid_t alc662_adc_nids[1] = {
  9394. /* ADC1-2 */
  9395. 0x09,
  9396. };
  9397. /* input MUX */
  9398. /* FIXME: should be a matrix-type input source selection */
  9399. static struct hda_input_mux alc662_capture_source = {
  9400. .num_items = 4,
  9401. .items = {
  9402. { "Mic", 0x0 },
  9403. { "Front Mic", 0x1 },
  9404. { "Line", 0x2 },
  9405. { "CD", 0x4 },
  9406. },
  9407. };
  9408. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9409. .num_items = 2,
  9410. .items = {
  9411. { "Mic", 0x1 },
  9412. { "Line", 0x2 },
  9413. },
  9414. };
  9415. #define alc662_mux_enum_info alc_mux_enum_info
  9416. #define alc662_mux_enum_get alc_mux_enum_get
  9417. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9418. struct snd_ctl_elem_value *ucontrol)
  9419. {
  9420. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9421. struct alc_spec *spec = codec->spec;
  9422. const struct hda_input_mux *imux = spec->input_mux;
  9423. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9424. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9425. hda_nid_t nid = capture_mixers[adc_idx];
  9426. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9427. unsigned int i, idx;
  9428. idx = ucontrol->value.enumerated.item[0];
  9429. if (idx >= imux->num_items)
  9430. idx = imux->num_items - 1;
  9431. if (*cur_val == idx && !codec->in_resume)
  9432. return 0;
  9433. for (i = 0; i < imux->num_items; i++) {
  9434. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  9435. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9436. v | (imux->items[i].index << 8));
  9437. }
  9438. *cur_val = idx;
  9439. return 1;
  9440. }
  9441. /*
  9442. * 2ch mode
  9443. */
  9444. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9445. { 2, NULL }
  9446. };
  9447. /*
  9448. * 2ch mode
  9449. */
  9450. static struct hda_verb alc662_3ST_ch2_init[] = {
  9451. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9452. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9453. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9454. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9455. { } /* end */
  9456. };
  9457. /*
  9458. * 6ch mode
  9459. */
  9460. static struct hda_verb alc662_3ST_ch6_init[] = {
  9461. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9462. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9463. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9464. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9465. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9466. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9467. { } /* end */
  9468. };
  9469. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9470. { 2, alc662_3ST_ch2_init },
  9471. { 6, alc662_3ST_ch6_init },
  9472. };
  9473. /*
  9474. * 2ch mode
  9475. */
  9476. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9477. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9478. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9479. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9480. { } /* end */
  9481. };
  9482. /*
  9483. * 6ch mode
  9484. */
  9485. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9486. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9487. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9488. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9489. { } /* end */
  9490. };
  9491. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9492. { 2, alc662_sixstack_ch6_init },
  9493. { 6, alc662_sixstack_ch8_init },
  9494. };
  9495. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9496. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9497. */
  9498. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9499. /* output mixer control */
  9500. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9501. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9502. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9503. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9504. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9505. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9506. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9507. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9508. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9509. /*Input mixer control */
  9510. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9511. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9512. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9513. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9514. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9515. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9516. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9517. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9518. /* Capture mixer control */
  9519. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9520. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9521. {
  9522. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9523. .name = "Capture Source",
  9524. .count = 1,
  9525. .info = alc_mux_enum_info,
  9526. .get = alc_mux_enum_get,
  9527. .put = alc_mux_enum_put,
  9528. },
  9529. { } /* end */
  9530. };
  9531. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9532. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9533. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9534. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9535. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9536. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9537. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9538. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9539. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9540. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9541. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9542. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9543. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9544. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9545. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9546. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9547. {
  9548. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9549. /* .name = "Capture Source", */
  9550. .name = "Input Source",
  9551. .count = 1,
  9552. .info = alc662_mux_enum_info,
  9553. .get = alc662_mux_enum_get,
  9554. .put = alc662_mux_enum_put,
  9555. },
  9556. { } /* end */
  9557. };
  9558. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9559. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9560. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9561. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9562. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9563. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9564. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9565. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9566. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9567. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9568. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9569. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9570. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9571. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9572. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9573. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9574. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9575. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9576. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9577. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9578. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9579. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9580. {
  9581. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9582. /* .name = "Capture Source", */
  9583. .name = "Input Source",
  9584. .count = 1,
  9585. .info = alc662_mux_enum_info,
  9586. .get = alc662_mux_enum_get,
  9587. .put = alc662_mux_enum_put,
  9588. },
  9589. { } /* end */
  9590. };
  9591. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9592. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9593. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9594. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9595. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9596. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9597. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9598. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9599. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9600. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9601. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9602. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9603. {
  9604. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9605. /* .name = "Capture Source", */
  9606. .name = "Input Source",
  9607. .count = 1,
  9608. .info = alc662_mux_enum_info,
  9609. .get = alc662_mux_enum_get,
  9610. .put = alc662_mux_enum_put,
  9611. },
  9612. { } /* end */
  9613. };
  9614. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9615. {
  9616. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9617. .name = "Channel Mode",
  9618. .info = alc_ch_mode_info,
  9619. .get = alc_ch_mode_get,
  9620. .put = alc_ch_mode_put,
  9621. },
  9622. { } /* end */
  9623. };
  9624. static struct hda_verb alc662_init_verbs[] = {
  9625. /* ADC: mute amp left and right */
  9626. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9627. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9628. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9629. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9630. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9631. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9632. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9633. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9634. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9635. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9636. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9637. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9638. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9639. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9640. /* Front Pin: output 0 (0x0c) */
  9641. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9642. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9643. /* Rear Pin: output 1 (0x0d) */
  9644. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9645. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9646. /* CLFE Pin: output 2 (0x0e) */
  9647. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9648. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9649. /* Mic (rear) pin: input vref at 80% */
  9650. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9651. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9652. /* Front Mic pin: input vref at 80% */
  9653. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9654. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9655. /* Line In pin: input */
  9656. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9657. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9658. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9659. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9660. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9661. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9662. /* CD pin widget for input */
  9663. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9664. /* FIXME: use matrix-type input source selection */
  9665. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9666. /* Input mixer */
  9667. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9668. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9669. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9670. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9671. { }
  9672. };
  9673. static struct hda_verb alc662_sue_init_verbs[] = {
  9674. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9675. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9676. {}
  9677. };
  9678. /*
  9679. * generic initialization of ADC, input mixers and output mixers
  9680. */
  9681. static struct hda_verb alc662_auto_init_verbs[] = {
  9682. /*
  9683. * Unmute ADC and set the default input to mic-in
  9684. */
  9685. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9686. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9687. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  9688. * mixer widget
  9689. * Note: PASD motherboards uses the Line In 2 as the input for front
  9690. * panel mic (mic 2)
  9691. */
  9692. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9693. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9694. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9695. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9696. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9697. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9698. /*
  9699. * Set up output mixers (0x0c - 0x0f)
  9700. */
  9701. /* set vol=0 to output mixers */
  9702. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9703. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9704. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9705. /* set up input amps for analog loopback */
  9706. /* Amp Indices: DAC = 0, mixer = 1 */
  9707. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9708. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9709. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9710. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9711. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9712. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9713. /* FIXME: use matrix-type input source selection */
  9714. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9715. /* Input mixer */
  9716. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9717. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9718. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9719. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  9720. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9721. { }
  9722. };
  9723. /* capture mixer elements */
  9724. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  9725. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9726. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9727. {
  9728. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9729. /* The multiple "Capture Source" controls confuse alsamixer
  9730. * So call somewhat different..
  9731. * FIXME: the controls appear in the "playback" view!
  9732. */
  9733. /* .name = "Capture Source", */
  9734. .name = "Input Source",
  9735. .count = 1,
  9736. .info = alc882_mux_enum_info,
  9737. .get = alc882_mux_enum_get,
  9738. .put = alc882_mux_enum_put,
  9739. },
  9740. { } /* end */
  9741. };
  9742. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  9743. {
  9744. unsigned int present;
  9745. unsigned char bits;
  9746. present = snd_hda_codec_read(codec, 0x14, 0,
  9747. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9748. bits = present ? 0x80 : 0;
  9749. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9750. 0x80, bits);
  9751. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9752. 0x80, bits);
  9753. }
  9754. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  9755. {
  9756. unsigned int present;
  9757. unsigned char bits;
  9758. present = snd_hda_codec_read(codec, 0x1b, 0,
  9759. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9760. bits = present ? 0x80 : 0;
  9761. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9762. 0x80, bits);
  9763. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9764. 0x80, bits);
  9765. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9766. 0x80, bits);
  9767. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9768. 0x80, bits);
  9769. }
  9770. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  9771. unsigned int res)
  9772. {
  9773. if ((res >> 26) == ALC880_HP_EVENT)
  9774. alc662_lenovo_101e_all_automute(codec);
  9775. if ((res >> 26) == ALC880_FRONT_EVENT)
  9776. alc662_lenovo_101e_ispeaker_automute(codec);
  9777. }
  9778. /* pcm configuration: identiacal with ALC880 */
  9779. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  9780. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  9781. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  9782. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  9783. /*
  9784. * configuration and preset
  9785. */
  9786. static const char *alc662_models[ALC662_MODEL_LAST] = {
  9787. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  9788. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  9789. [ALC662_3ST_6ch] = "3stack-6ch",
  9790. [ALC662_5ST_DIG] = "6stack-dig",
  9791. [ALC662_LENOVO_101E] = "lenovo-101e",
  9792. [ALC662_AUTO] = "auto",
  9793. };
  9794. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  9795. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  9796. {}
  9797. };
  9798. static struct alc_config_preset alc662_presets[] = {
  9799. [ALC662_3ST_2ch_DIG] = {
  9800. .mixers = { alc662_3ST_2ch_mixer },
  9801. .init_verbs = { alc662_init_verbs },
  9802. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9803. .dac_nids = alc662_dac_nids,
  9804. .dig_out_nid = ALC662_DIGOUT_NID,
  9805. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9806. .adc_nids = alc662_adc_nids,
  9807. .dig_in_nid = ALC662_DIGIN_NID,
  9808. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9809. .channel_mode = alc662_3ST_2ch_modes,
  9810. .input_mux = &alc662_capture_source,
  9811. },
  9812. [ALC662_3ST_6ch_DIG] = {
  9813. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9814. .init_verbs = { alc662_init_verbs },
  9815. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9816. .dac_nids = alc662_dac_nids,
  9817. .dig_out_nid = ALC662_DIGOUT_NID,
  9818. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9819. .adc_nids = alc662_adc_nids,
  9820. .dig_in_nid = ALC662_DIGIN_NID,
  9821. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9822. .channel_mode = alc662_3ST_6ch_modes,
  9823. .need_dac_fix = 1,
  9824. .input_mux = &alc662_capture_source,
  9825. },
  9826. [ALC662_3ST_6ch] = {
  9827. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  9828. .init_verbs = { alc662_init_verbs },
  9829. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9830. .dac_nids = alc662_dac_nids,
  9831. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9832. .adc_nids = alc662_adc_nids,
  9833. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  9834. .channel_mode = alc662_3ST_6ch_modes,
  9835. .need_dac_fix = 1,
  9836. .input_mux = &alc662_capture_source,
  9837. },
  9838. [ALC662_5ST_DIG] = {
  9839. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  9840. .init_verbs = { alc662_init_verbs },
  9841. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9842. .dac_nids = alc662_dac_nids,
  9843. .dig_out_nid = ALC662_DIGOUT_NID,
  9844. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9845. .adc_nids = alc662_adc_nids,
  9846. .dig_in_nid = ALC662_DIGIN_NID,
  9847. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  9848. .channel_mode = alc662_5stack_modes,
  9849. .input_mux = &alc662_capture_source,
  9850. },
  9851. [ALC662_LENOVO_101E] = {
  9852. .mixers = { alc662_lenovo_101e_mixer },
  9853. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  9854. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9855. .dac_nids = alc662_dac_nids,
  9856. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9857. .adc_nids = alc662_adc_nids,
  9858. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  9859. .channel_mode = alc662_3ST_2ch_modes,
  9860. .input_mux = &alc662_lenovo_101e_capture_source,
  9861. .unsol_event = alc662_lenovo_101e_unsol_event,
  9862. .init_hook = alc662_lenovo_101e_all_automute,
  9863. },
  9864. };
  9865. /*
  9866. * BIOS auto configuration
  9867. */
  9868. /* add playback controls from the parsed DAC table */
  9869. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  9870. const struct auto_pin_cfg *cfg)
  9871. {
  9872. char name[32];
  9873. static const char *chname[4] = {
  9874. "Front", "Surround", NULL /*CLFE*/, "Side"
  9875. };
  9876. hda_nid_t nid;
  9877. int i, err;
  9878. for (i = 0; i < cfg->line_outs; i++) {
  9879. if (!spec->multiout.dac_nids[i])
  9880. continue;
  9881. nid = alc880_idx_to_dac(i);
  9882. if (i == 2) {
  9883. /* Center/LFE */
  9884. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9885. "Center Playback Volume",
  9886. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9887. HDA_OUTPUT));
  9888. if (err < 0)
  9889. return err;
  9890. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9891. "LFE Playback Volume",
  9892. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9893. HDA_OUTPUT));
  9894. if (err < 0)
  9895. return err;
  9896. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9897. "Center Playback Switch",
  9898. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  9899. HDA_INPUT));
  9900. if (err < 0)
  9901. return err;
  9902. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9903. "LFE Playback Switch",
  9904. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  9905. HDA_INPUT));
  9906. if (err < 0)
  9907. return err;
  9908. } else {
  9909. sprintf(name, "%s Playback Volume", chname[i]);
  9910. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9911. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9912. HDA_OUTPUT));
  9913. if (err < 0)
  9914. return err;
  9915. sprintf(name, "%s Playback Switch", chname[i]);
  9916. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9917. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  9918. HDA_INPUT));
  9919. if (err < 0)
  9920. return err;
  9921. }
  9922. }
  9923. return 0;
  9924. }
  9925. /* add playback controls for speaker and HP outputs */
  9926. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  9927. const char *pfx)
  9928. {
  9929. hda_nid_t nid;
  9930. int err;
  9931. char name[32];
  9932. if (!pin)
  9933. return 0;
  9934. if (alc880_is_fixed_pin(pin)) {
  9935. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9936. /* printk("DAC nid=%x\n",nid); */
  9937. /* specify the DAC as the extra output */
  9938. if (!spec->multiout.hp_nid)
  9939. spec->multiout.hp_nid = nid;
  9940. else
  9941. spec->multiout.extra_out_nid[0] = nid;
  9942. /* control HP volume/switch on the output mixer amp */
  9943. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9944. sprintf(name, "%s Playback Volume", pfx);
  9945. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9946. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9947. if (err < 0)
  9948. return err;
  9949. sprintf(name, "%s Playback Switch", pfx);
  9950. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9951. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  9952. if (err < 0)
  9953. return err;
  9954. } else if (alc880_is_multi_pin(pin)) {
  9955. /* set manual connection */
  9956. /* we have only a switch on HP-out PIN */
  9957. sprintf(name, "%s Playback Switch", pfx);
  9958. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9959. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9960. if (err < 0)
  9961. return err;
  9962. }
  9963. return 0;
  9964. }
  9965. /* create playback/capture controls for input pins */
  9966. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  9967. const struct auto_pin_cfg *cfg)
  9968. {
  9969. struct hda_input_mux *imux = &spec->private_imux;
  9970. int i, err, idx;
  9971. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9972. if (alc880_is_input_pin(cfg->input_pins[i])) {
  9973. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  9974. err = new_analog_input(spec, cfg->input_pins[i],
  9975. auto_pin_cfg_labels[i],
  9976. idx, 0x0b);
  9977. if (err < 0)
  9978. return err;
  9979. imux->items[imux->num_items].label =
  9980. auto_pin_cfg_labels[i];
  9981. imux->items[imux->num_items].index =
  9982. alc880_input_pin_idx(cfg->input_pins[i]);
  9983. imux->num_items++;
  9984. }
  9985. }
  9986. return 0;
  9987. }
  9988. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  9989. hda_nid_t nid, int pin_type,
  9990. int dac_idx)
  9991. {
  9992. /* set as output */
  9993. snd_hda_codec_write(codec, nid, 0,
  9994. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9995. snd_hda_codec_write(codec, nid, 0,
  9996. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9997. /* need the manual connection? */
  9998. if (alc880_is_multi_pin(nid)) {
  9999. struct alc_spec *spec = codec->spec;
  10000. int idx = alc880_multi_pin_idx(nid);
  10001. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10002. AC_VERB_SET_CONNECT_SEL,
  10003. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10004. }
  10005. }
  10006. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10007. {
  10008. struct alc_spec *spec = codec->spec;
  10009. int i;
  10010. for (i = 0; i <= HDA_SIDE; i++) {
  10011. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10012. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10013. if (nid)
  10014. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10015. i);
  10016. }
  10017. }
  10018. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10019. {
  10020. struct alc_spec *spec = codec->spec;
  10021. hda_nid_t pin;
  10022. pin = spec->autocfg.hp_pins[0];
  10023. if (pin) /* connect to front */
  10024. /* use dac 0 */
  10025. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10026. }
  10027. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10028. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10029. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10030. {
  10031. struct alc_spec *spec = codec->spec;
  10032. int i;
  10033. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10034. hda_nid_t nid = spec->autocfg.input_pins[i];
  10035. if (alc662_is_input_pin(nid)) {
  10036. snd_hda_codec_write(codec, nid, 0,
  10037. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10038. (i <= AUTO_PIN_FRONT_MIC ?
  10039. PIN_VREF80 : PIN_IN));
  10040. if (nid != ALC662_PIN_CD_NID)
  10041. snd_hda_codec_write(codec, nid, 0,
  10042. AC_VERB_SET_AMP_GAIN_MUTE,
  10043. AMP_OUT_MUTE);
  10044. }
  10045. }
  10046. }
  10047. static int alc662_parse_auto_config(struct hda_codec *codec)
  10048. {
  10049. struct alc_spec *spec = codec->spec;
  10050. int err;
  10051. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10052. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10053. alc662_ignore);
  10054. if (err < 0)
  10055. return err;
  10056. if (!spec->autocfg.line_outs)
  10057. return 0; /* can't find valid BIOS pin config */
  10058. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10059. if (err < 0)
  10060. return err;
  10061. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10062. if (err < 0)
  10063. return err;
  10064. err = alc662_auto_create_extra_out(spec,
  10065. spec->autocfg.speaker_pins[0],
  10066. "Speaker");
  10067. if (err < 0)
  10068. return err;
  10069. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10070. "Headphone");
  10071. if (err < 0)
  10072. return err;
  10073. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10074. if (err < 0)
  10075. return err;
  10076. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10077. if (spec->autocfg.dig_out_pin)
  10078. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10079. if (spec->kctl_alloc)
  10080. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10081. spec->num_mux_defs = 1;
  10082. spec->input_mux = &spec->private_imux;
  10083. if (err < 0)
  10084. return err;
  10085. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10086. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10087. spec->num_mixers++;
  10088. return 1;
  10089. }
  10090. /* additional initialization for auto-configuration model */
  10091. static void alc662_auto_init(struct hda_codec *codec)
  10092. {
  10093. alc662_auto_init_multi_out(codec);
  10094. alc662_auto_init_hp_out(codec);
  10095. alc662_auto_init_analog_input(codec);
  10096. }
  10097. static int patch_alc662(struct hda_codec *codec)
  10098. {
  10099. struct alc_spec *spec;
  10100. int err, board_config;
  10101. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10102. if (!spec)
  10103. return -ENOMEM;
  10104. codec->spec = spec;
  10105. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10106. alc662_models,
  10107. alc662_cfg_tbl);
  10108. if (board_config < 0) {
  10109. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10110. "trying auto-probe from BIOS...\n");
  10111. board_config = ALC662_AUTO;
  10112. }
  10113. if (board_config == ALC662_AUTO) {
  10114. /* automatic parse from the BIOS config */
  10115. err = alc662_parse_auto_config(codec);
  10116. if (err < 0) {
  10117. alc_free(codec);
  10118. return err;
  10119. } else if (!err) {
  10120. printk(KERN_INFO
  10121. "hda_codec: Cannot set up configuration "
  10122. "from BIOS. Using base mode...\n");
  10123. board_config = ALC662_3ST_2ch_DIG;
  10124. }
  10125. }
  10126. if (board_config != ALC662_AUTO)
  10127. setup_preset(spec, &alc662_presets[board_config]);
  10128. spec->stream_name_analog = "ALC662 Analog";
  10129. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10130. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10131. spec->stream_name_digital = "ALC662 Digital";
  10132. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10133. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10134. if (!spec->adc_nids && spec->input_mux) {
  10135. spec->adc_nids = alc662_adc_nids;
  10136. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10137. }
  10138. codec->patch_ops = alc_patch_ops;
  10139. if (board_config == ALC662_AUTO)
  10140. spec->init_hook = alc662_auto_init;
  10141. return 0;
  10142. }
  10143. /*
  10144. * patch entries
  10145. */
  10146. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10147. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10148. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10149. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10150. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10151. .patch = patch_alc861 },
  10152. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10153. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10154. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10155. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10156. .patch = patch_alc883 },
  10157. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10158. .patch = patch_alc662 },
  10159. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10160. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10161. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10162. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10163. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10164. {} /* terminator */
  10165. };