patch_realtek.c 264 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674
  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_UNIWILL_DIG,
  53. ALC880_UNIWILL,
  54. ALC880_UNIWILL_P53,
  55. ALC880_CLEVO,
  56. ALC880_TCL_S700,
  57. ALC880_LG,
  58. ALC880_LG_LW,
  59. #ifdef CONFIG_SND_DEBUG
  60. ALC880_TEST,
  61. #endif
  62. ALC880_AUTO,
  63. ALC880_MODEL_LAST /* last tag */
  64. };
  65. /* ALC260 models */
  66. enum {
  67. ALC260_BASIC,
  68. ALC260_HP,
  69. ALC260_HP_3013,
  70. ALC260_FUJITSU_S702X,
  71. ALC260_ACER,
  72. #ifdef CONFIG_SND_DEBUG
  73. ALC260_TEST,
  74. #endif
  75. ALC260_AUTO,
  76. ALC260_MODEL_LAST /* last tag */
  77. };
  78. /* ALC262 models */
  79. enum {
  80. ALC262_BASIC,
  81. ALC262_HIPPO,
  82. ALC262_HIPPO_1,
  83. ALC262_FUJITSU,
  84. ALC262_HP_BPC,
  85. ALC262_BENQ_ED8,
  86. ALC262_AUTO,
  87. ALC262_MODEL_LAST /* last tag */
  88. };
  89. /* ALC861 models */
  90. enum {
  91. ALC861_3ST,
  92. ALC660_3ST,
  93. ALC861_3ST_DIG,
  94. ALC861_6ST_DIG,
  95. ALC861_UNIWILL_M31,
  96. ALC861_TOSHIBA,
  97. ALC861_ASUS,
  98. ALC861_AUTO,
  99. ALC861_MODEL_LAST,
  100. };
  101. /* ALC882 models */
  102. enum {
  103. ALC882_3ST_DIG,
  104. ALC882_6ST_DIG,
  105. ALC882_ARIMA,
  106. ALC882_AUTO,
  107. ALC882_MODEL_LAST,
  108. };
  109. /* ALC883 models */
  110. enum {
  111. ALC883_3ST_2ch_DIG,
  112. ALC883_3ST_6ch_DIG,
  113. ALC883_3ST_6ch,
  114. ALC883_6ST_DIG,
  115. ALC883_TARGA_DIG,
  116. ALC883_TARGA_2ch_DIG,
  117. ALC888_DEMO_BOARD,
  118. ALC883_ACER,
  119. ALC883_MEDION,
  120. ALC883_AUTO,
  121. ALC883_MODEL_LAST,
  122. };
  123. /* for GPIO Poll */
  124. #define GPIO_MASK 0x03
  125. struct alc_spec {
  126. /* codec parameterization */
  127. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  128. unsigned int num_mixers;
  129. const struct hda_verb *init_verbs[5]; /* initialization verbs
  130. * don't forget NULL
  131. * termination!
  132. */
  133. unsigned int num_init_verbs;
  134. char *stream_name_analog; /* analog PCM stream */
  135. struct hda_pcm_stream *stream_analog_playback;
  136. struct hda_pcm_stream *stream_analog_capture;
  137. char *stream_name_digital; /* digital PCM stream */
  138. struct hda_pcm_stream *stream_digital_playback;
  139. struct hda_pcm_stream *stream_digital_capture;
  140. /* playback */
  141. struct hda_multi_out multiout; /* playback set-up
  142. * max_channels, dacs must be set
  143. * dig_out_nid and hp_nid are optional
  144. */
  145. /* capture */
  146. unsigned int num_adc_nids;
  147. hda_nid_t *adc_nids;
  148. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  149. /* capture source */
  150. unsigned int num_mux_defs;
  151. const struct hda_input_mux *input_mux;
  152. unsigned int cur_mux[3];
  153. /* channel model */
  154. const struct hda_channel_mode *channel_mode;
  155. int num_channel_mode;
  156. int need_dac_fix;
  157. /* PCM information */
  158. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  159. /* dynamic controls, init_verbs and input_mux */
  160. struct auto_pin_cfg autocfg;
  161. unsigned int num_kctl_alloc, num_kctl_used;
  162. struct snd_kcontrol_new *kctl_alloc;
  163. struct hda_input_mux private_imux;
  164. hda_nid_t private_dac_nids[5];
  165. /* hooks */
  166. void (*init_hook)(struct hda_codec *codec);
  167. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  168. /* for pin sensing */
  169. unsigned int sense_updated: 1;
  170. unsigned int jack_present: 1;
  171. };
  172. /*
  173. * configuration template - to be copied to the spec instance
  174. */
  175. struct alc_config_preset {
  176. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  177. * with spec
  178. */
  179. const struct hda_verb *init_verbs[5];
  180. unsigned int num_dacs;
  181. hda_nid_t *dac_nids;
  182. hda_nid_t dig_out_nid; /* optional */
  183. hda_nid_t hp_nid; /* optional */
  184. unsigned int num_adc_nids;
  185. hda_nid_t *adc_nids;
  186. hda_nid_t dig_in_nid;
  187. unsigned int num_channel_mode;
  188. const struct hda_channel_mode *channel_mode;
  189. int need_dac_fix;
  190. unsigned int num_mux_defs;
  191. const struct hda_input_mux *input_mux;
  192. void (*unsol_event)(struct hda_codec *, unsigned int);
  193. void (*init_hook)(struct hda_codec *);
  194. };
  195. /*
  196. * input MUX handling
  197. */
  198. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  199. struct snd_ctl_elem_info *uinfo)
  200. {
  201. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  202. struct alc_spec *spec = codec->spec;
  203. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  204. if (mux_idx >= spec->num_mux_defs)
  205. mux_idx = 0;
  206. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  207. }
  208. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  209. struct snd_ctl_elem_value *ucontrol)
  210. {
  211. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  212. struct alc_spec *spec = codec->spec;
  213. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  214. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  215. return 0;
  216. }
  217. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  218. struct snd_ctl_elem_value *ucontrol)
  219. {
  220. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  221. struct alc_spec *spec = codec->spec;
  222. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  223. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  224. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  225. spec->adc_nids[adc_idx],
  226. &spec->cur_mux[adc_idx]);
  227. }
  228. /*
  229. * channel mode setting
  230. */
  231. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  232. struct snd_ctl_elem_info *uinfo)
  233. {
  234. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  235. struct alc_spec *spec = codec->spec;
  236. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  237. spec->num_channel_mode);
  238. }
  239. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  240. struct snd_ctl_elem_value *ucontrol)
  241. {
  242. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  243. struct alc_spec *spec = codec->spec;
  244. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  245. spec->num_channel_mode,
  246. spec->multiout.max_channels);
  247. }
  248. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  249. struct snd_ctl_elem_value *ucontrol)
  250. {
  251. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  252. struct alc_spec *spec = codec->spec;
  253. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  254. spec->num_channel_mode,
  255. &spec->multiout.max_channels);
  256. if (err >= 0 && spec->need_dac_fix)
  257. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  258. return err;
  259. }
  260. /*
  261. * Control the mode of pin widget settings via the mixer. "pc" is used
  262. * instead of "%" to avoid consequences of accidently treating the % as
  263. * being part of a format specifier. Maximum allowed length of a value is
  264. * 63 characters plus NULL terminator.
  265. *
  266. * Note: some retasking pin complexes seem to ignore requests for input
  267. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  268. * are requested. Therefore order this list so that this behaviour will not
  269. * cause problems when mixer clients move through the enum sequentially.
  270. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  271. * March 2006.
  272. */
  273. static char *alc_pin_mode_names[] = {
  274. "Mic 50pc bias", "Mic 80pc bias",
  275. "Line in", "Line out", "Headphone out",
  276. };
  277. static unsigned char alc_pin_mode_values[] = {
  278. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  279. };
  280. /* The control can present all 5 options, or it can limit the options based
  281. * in the pin being assumed to be exclusively an input or an output pin. In
  282. * addition, "input" pins may or may not process the mic bias option
  283. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  284. * accept requests for bias as of chip versions up to March 2006) and/or
  285. * wiring in the computer.
  286. */
  287. #define ALC_PIN_DIR_IN 0x00
  288. #define ALC_PIN_DIR_OUT 0x01
  289. #define ALC_PIN_DIR_INOUT 0x02
  290. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  291. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  292. /* Info about the pin modes supported by the different pin direction modes.
  293. * For each direction the minimum and maximum values are given.
  294. */
  295. static signed char alc_pin_mode_dir_info[5][2] = {
  296. { 0, 2 }, /* ALC_PIN_DIR_IN */
  297. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  298. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  299. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  300. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  301. };
  302. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  303. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  304. #define alc_pin_mode_n_items(_dir) \
  305. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  306. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  307. struct snd_ctl_elem_info *uinfo)
  308. {
  309. unsigned int item_num = uinfo->value.enumerated.item;
  310. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  311. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  312. uinfo->count = 1;
  313. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  314. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  315. item_num = alc_pin_mode_min(dir);
  316. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  317. return 0;
  318. }
  319. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  320. struct snd_ctl_elem_value *ucontrol)
  321. {
  322. unsigned int i;
  323. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  324. hda_nid_t nid = kcontrol->private_value & 0xffff;
  325. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  326. long *valp = ucontrol->value.integer.value;
  327. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  328. AC_VERB_GET_PIN_WIDGET_CONTROL,
  329. 0x00);
  330. /* Find enumerated value for current pinctl setting */
  331. i = alc_pin_mode_min(dir);
  332. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  333. i++;
  334. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  335. return 0;
  336. }
  337. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  338. struct snd_ctl_elem_value *ucontrol)
  339. {
  340. signed int change;
  341. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  342. hda_nid_t nid = kcontrol->private_value & 0xffff;
  343. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  344. long val = *ucontrol->value.integer.value;
  345. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  346. AC_VERB_GET_PIN_WIDGET_CONTROL,
  347. 0x00);
  348. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  349. val = alc_pin_mode_min(dir);
  350. change = pinctl != alc_pin_mode_values[val];
  351. if (change) {
  352. /* Set pin mode to that requested */
  353. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  354. alc_pin_mode_values[val]);
  355. /* Also enable the retasking pin's input/output as required
  356. * for the requested pin mode. Enum values of 2 or less are
  357. * input modes.
  358. *
  359. * Dynamically switching the input/output buffers probably
  360. * reduces noise slightly (particularly on input) so we'll
  361. * do it. However, having both input and output buffers
  362. * enabled simultaneously doesn't seem to be problematic if
  363. * this turns out to be necessary in the future.
  364. */
  365. if (val <= 2) {
  366. snd_hda_codec_write(codec, nid, 0,
  367. AC_VERB_SET_AMP_GAIN_MUTE,
  368. AMP_OUT_MUTE);
  369. snd_hda_codec_write(codec, nid, 0,
  370. AC_VERB_SET_AMP_GAIN_MUTE,
  371. AMP_IN_UNMUTE(0));
  372. } else {
  373. snd_hda_codec_write(codec, nid, 0,
  374. AC_VERB_SET_AMP_GAIN_MUTE,
  375. AMP_IN_MUTE(0));
  376. snd_hda_codec_write(codec, nid, 0,
  377. AC_VERB_SET_AMP_GAIN_MUTE,
  378. AMP_OUT_UNMUTE);
  379. }
  380. }
  381. return change;
  382. }
  383. #define ALC_PIN_MODE(xname, nid, dir) \
  384. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  385. .info = alc_pin_mode_info, \
  386. .get = alc_pin_mode_get, \
  387. .put = alc_pin_mode_put, \
  388. .private_value = nid | (dir<<16) }
  389. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  390. * together using a mask with more than one bit set. This control is
  391. * currently used only by the ALC260 test model. At this stage they are not
  392. * needed for any "production" models.
  393. */
  394. #ifdef CONFIG_SND_DEBUG
  395. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  396. struct snd_ctl_elem_info *uinfo)
  397. {
  398. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  399. uinfo->count = 1;
  400. uinfo->value.integer.min = 0;
  401. uinfo->value.integer.max = 1;
  402. return 0;
  403. }
  404. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  405. struct snd_ctl_elem_value *ucontrol)
  406. {
  407. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  408. hda_nid_t nid = kcontrol->private_value & 0xffff;
  409. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  410. long *valp = ucontrol->value.integer.value;
  411. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  412. AC_VERB_GET_GPIO_DATA, 0x00);
  413. *valp = (val & mask) != 0;
  414. return 0;
  415. }
  416. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  417. struct snd_ctl_elem_value *ucontrol)
  418. {
  419. signed int change;
  420. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  421. hda_nid_t nid = kcontrol->private_value & 0xffff;
  422. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  423. long val = *ucontrol->value.integer.value;
  424. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  425. AC_VERB_GET_GPIO_DATA,
  426. 0x00);
  427. /* Set/unset the masked GPIO bit(s) as needed */
  428. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  429. if (val == 0)
  430. gpio_data &= ~mask;
  431. else
  432. gpio_data |= mask;
  433. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  434. return change;
  435. }
  436. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  437. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  438. .info = alc_gpio_data_info, \
  439. .get = alc_gpio_data_get, \
  440. .put = alc_gpio_data_put, \
  441. .private_value = nid | (mask<<16) }
  442. #endif /* CONFIG_SND_DEBUG */
  443. /* A switch control to allow the enabling of the digital IO pins on the
  444. * ALC260. This is incredibly simplistic; the intention of this control is
  445. * to provide something in the test model allowing digital outputs to be
  446. * identified if present. If models are found which can utilise these
  447. * outputs a more complete mixer control can be devised for those models if
  448. * necessary.
  449. */
  450. #ifdef CONFIG_SND_DEBUG
  451. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  452. struct snd_ctl_elem_info *uinfo)
  453. {
  454. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  455. uinfo->count = 1;
  456. uinfo->value.integer.min = 0;
  457. uinfo->value.integer.max = 1;
  458. return 0;
  459. }
  460. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  461. struct snd_ctl_elem_value *ucontrol)
  462. {
  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 *valp = ucontrol->value.integer.value;
  467. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  468. AC_VERB_GET_DIGI_CONVERT, 0x00);
  469. *valp = (val & mask) != 0;
  470. return 0;
  471. }
  472. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  473. struct snd_ctl_elem_value *ucontrol)
  474. {
  475. signed int change;
  476. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  477. hda_nid_t nid = kcontrol->private_value & 0xffff;
  478. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  479. long val = *ucontrol->value.integer.value;
  480. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  481. AC_VERB_GET_DIGI_CONVERT,
  482. 0x00);
  483. /* Set/unset the masked control bit(s) as needed */
  484. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  485. if (val==0)
  486. ctrl_data &= ~mask;
  487. else
  488. ctrl_data |= mask;
  489. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  490. ctrl_data);
  491. return change;
  492. }
  493. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  494. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  495. .info = alc_spdif_ctrl_info, \
  496. .get = alc_spdif_ctrl_get, \
  497. .put = alc_spdif_ctrl_put, \
  498. .private_value = nid | (mask<<16) }
  499. #endif /* CONFIG_SND_DEBUG */
  500. /*
  501. * set up from the preset table
  502. */
  503. static void setup_preset(struct alc_spec *spec,
  504. const struct alc_config_preset *preset)
  505. {
  506. int i;
  507. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  508. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  509. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  510. i++)
  511. spec->init_verbs[spec->num_init_verbs++] =
  512. preset->init_verbs[i];
  513. spec->channel_mode = preset->channel_mode;
  514. spec->num_channel_mode = preset->num_channel_mode;
  515. spec->need_dac_fix = preset->need_dac_fix;
  516. spec->multiout.max_channels = spec->channel_mode[0].channels;
  517. spec->multiout.num_dacs = preset->num_dacs;
  518. spec->multiout.dac_nids = preset->dac_nids;
  519. spec->multiout.dig_out_nid = preset->dig_out_nid;
  520. spec->multiout.hp_nid = preset->hp_nid;
  521. spec->num_mux_defs = preset->num_mux_defs;
  522. if (! spec->num_mux_defs)
  523. spec->num_mux_defs = 1;
  524. spec->input_mux = preset->input_mux;
  525. spec->num_adc_nids = preset->num_adc_nids;
  526. spec->adc_nids = preset->adc_nids;
  527. spec->dig_in_nid = preset->dig_in_nid;
  528. spec->unsol_event = preset->unsol_event;
  529. spec->init_hook = preset->init_hook;
  530. }
  531. /*
  532. * ALC880 3-stack model
  533. *
  534. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  535. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  536. * F-Mic = 0x1b, HP = 0x19
  537. */
  538. static hda_nid_t alc880_dac_nids[4] = {
  539. /* front, rear, clfe, rear_surr */
  540. 0x02, 0x05, 0x04, 0x03
  541. };
  542. static hda_nid_t alc880_adc_nids[3] = {
  543. /* ADC0-2 */
  544. 0x07, 0x08, 0x09,
  545. };
  546. /* The datasheet says the node 0x07 is connected from inputs,
  547. * but it shows zero connection in the real implementation on some devices.
  548. * Note: this is a 915GAV bug, fixed on 915GLV
  549. */
  550. static hda_nid_t alc880_adc_nids_alt[2] = {
  551. /* ADC1-2 */
  552. 0x08, 0x09,
  553. };
  554. #define ALC880_DIGOUT_NID 0x06
  555. #define ALC880_DIGIN_NID 0x0a
  556. static struct hda_input_mux alc880_capture_source = {
  557. .num_items = 4,
  558. .items = {
  559. { "Mic", 0x0 },
  560. { "Front Mic", 0x3 },
  561. { "Line", 0x2 },
  562. { "CD", 0x4 },
  563. },
  564. };
  565. /* channel source setting (2/6 channel selection for 3-stack) */
  566. /* 2ch mode */
  567. static struct hda_verb alc880_threestack_ch2_init[] = {
  568. /* set line-in to input, mute it */
  569. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  570. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  571. /* set mic-in to input vref 80%, mute it */
  572. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  573. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  574. { } /* end */
  575. };
  576. /* 6ch mode */
  577. static struct hda_verb alc880_threestack_ch6_init[] = {
  578. /* set line-in to output, unmute it */
  579. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  580. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  581. /* set mic-in to output, unmute it */
  582. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  583. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  584. { } /* end */
  585. };
  586. static struct hda_channel_mode alc880_threestack_modes[2] = {
  587. { 2, alc880_threestack_ch2_init },
  588. { 6, alc880_threestack_ch6_init },
  589. };
  590. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  591. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  592. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  593. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  594. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  595. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  596. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  597. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  598. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  599. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  600. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  601. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  602. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  603. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  604. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  605. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  606. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  607. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  608. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  609. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  610. {
  611. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  612. .name = "Channel Mode",
  613. .info = alc_ch_mode_info,
  614. .get = alc_ch_mode_get,
  615. .put = alc_ch_mode_put,
  616. },
  617. { } /* end */
  618. };
  619. /* capture mixer elements */
  620. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  621. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  622. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  623. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  624. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  625. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  626. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  627. {
  628. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  629. /* The multiple "Capture Source" controls confuse alsamixer
  630. * So call somewhat different..
  631. * FIXME: the controls appear in the "playback" view!
  632. */
  633. /* .name = "Capture Source", */
  634. .name = "Input Source",
  635. .count = 3,
  636. .info = alc_mux_enum_info,
  637. .get = alc_mux_enum_get,
  638. .put = alc_mux_enum_put,
  639. },
  640. { } /* end */
  641. };
  642. /* capture mixer elements (in case NID 0x07 not available) */
  643. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  644. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  645. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  646. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  647. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  648. {
  649. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  650. /* The multiple "Capture Source" controls confuse alsamixer
  651. * So call somewhat different..
  652. * FIXME: the controls appear in the "playback" view!
  653. */
  654. /* .name = "Capture Source", */
  655. .name = "Input Source",
  656. .count = 2,
  657. .info = alc_mux_enum_info,
  658. .get = alc_mux_enum_get,
  659. .put = alc_mux_enum_put,
  660. },
  661. { } /* end */
  662. };
  663. /*
  664. * ALC880 5-stack model
  665. *
  666. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  667. * Side = 0x02 (0xd)
  668. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  669. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  670. */
  671. /* additional mixers to alc880_three_stack_mixer */
  672. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  673. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  674. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  675. { } /* end */
  676. };
  677. /* channel source setting (6/8 channel selection for 5-stack) */
  678. /* 6ch mode */
  679. static struct hda_verb alc880_fivestack_ch6_init[] = {
  680. /* set line-in to input, mute it */
  681. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  682. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  683. { } /* end */
  684. };
  685. /* 8ch mode */
  686. static struct hda_verb alc880_fivestack_ch8_init[] = {
  687. /* set line-in to output, unmute it */
  688. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  689. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  690. { } /* end */
  691. };
  692. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  693. { 6, alc880_fivestack_ch6_init },
  694. { 8, alc880_fivestack_ch8_init },
  695. };
  696. /*
  697. * ALC880 6-stack model
  698. *
  699. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  700. * Side = 0x05 (0x0f)
  701. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  702. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  703. */
  704. static hda_nid_t alc880_6st_dac_nids[4] = {
  705. /* front, rear, clfe, rear_surr */
  706. 0x02, 0x03, 0x04, 0x05
  707. };
  708. static struct hda_input_mux alc880_6stack_capture_source = {
  709. .num_items = 4,
  710. .items = {
  711. { "Mic", 0x0 },
  712. { "Front Mic", 0x1 },
  713. { "Line", 0x2 },
  714. { "CD", 0x4 },
  715. },
  716. };
  717. /* fixed 8-channels */
  718. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  719. { 8, NULL },
  720. };
  721. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  722. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  723. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  724. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  725. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  726. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  727. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  728. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  729. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  730. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  731. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  732. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  733. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  734. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  735. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  736. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  737. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  738. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  739. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  740. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  741. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  742. {
  743. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  744. .name = "Channel Mode",
  745. .info = alc_ch_mode_info,
  746. .get = alc_ch_mode_get,
  747. .put = alc_ch_mode_put,
  748. },
  749. { } /* end */
  750. };
  751. /*
  752. * ALC880 W810 model
  753. *
  754. * W810 has rear IO for:
  755. * Front (DAC 02)
  756. * Surround (DAC 03)
  757. * Center/LFE (DAC 04)
  758. * Digital out (06)
  759. *
  760. * The system also has a pair of internal speakers, and a headphone jack.
  761. * These are both connected to Line2 on the codec, hence to DAC 02.
  762. *
  763. * There is a variable resistor to control the speaker or headphone
  764. * volume. This is a hardware-only device without a software API.
  765. *
  766. * Plugging headphones in will disable the internal speakers. This is
  767. * implemented in hardware, not via the driver using jack sense. In
  768. * a similar fashion, plugging into the rear socket marked "front" will
  769. * disable both the speakers and headphones.
  770. *
  771. * For input, there's a microphone jack, and an "audio in" jack.
  772. * These may not do anything useful with this driver yet, because I
  773. * haven't setup any initialization verbs for these yet...
  774. */
  775. static hda_nid_t alc880_w810_dac_nids[3] = {
  776. /* front, rear/surround, clfe */
  777. 0x02, 0x03, 0x04
  778. };
  779. /* fixed 6 channels */
  780. static struct hda_channel_mode alc880_w810_modes[1] = {
  781. { 6, NULL }
  782. };
  783. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  784. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  785. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  786. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  787. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  788. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  789. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  790. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  791. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  792. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  793. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  794. { } /* end */
  795. };
  796. /*
  797. * Z710V model
  798. *
  799. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  800. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  801. * Line = 0x1a
  802. */
  803. static hda_nid_t alc880_z71v_dac_nids[1] = {
  804. 0x02
  805. };
  806. #define ALC880_Z71V_HP_DAC 0x03
  807. /* fixed 2 channels */
  808. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  809. { 2, NULL }
  810. };
  811. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  812. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  813. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  814. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  815. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  816. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  817. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  818. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  819. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  820. { } /* end */
  821. };
  822. /* FIXME! */
  823. /*
  824. * ALC880 F1734 model
  825. *
  826. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  827. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  828. */
  829. static hda_nid_t alc880_f1734_dac_nids[1] = {
  830. 0x03
  831. };
  832. #define ALC880_F1734_HP_DAC 0x02
  833. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  834. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  835. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  836. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  837. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  838. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  839. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  840. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  841. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  842. { } /* end */
  843. };
  844. /* FIXME! */
  845. /*
  846. * ALC880 ASUS model
  847. *
  848. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  849. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  850. * Mic = 0x18, Line = 0x1a
  851. */
  852. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  853. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  854. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  855. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  856. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  857. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  858. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  859. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  860. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  861. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  862. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  863. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  864. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  865. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  866. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  867. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  868. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  869. {
  870. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  871. .name = "Channel Mode",
  872. .info = alc_ch_mode_info,
  873. .get = alc_ch_mode_get,
  874. .put = alc_ch_mode_put,
  875. },
  876. { } /* end */
  877. };
  878. /* FIXME! */
  879. /*
  880. * ALC880 ASUS W1V model
  881. *
  882. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  883. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  884. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  885. */
  886. /* additional mixers to alc880_asus_mixer */
  887. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  888. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  889. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  890. { } /* end */
  891. };
  892. /* additional mixers to alc880_asus_mixer */
  893. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  894. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  895. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  896. { } /* end */
  897. };
  898. /* TCL S700 */
  899. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  900. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  901. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  902. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  903. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  904. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  905. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  906. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  907. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  908. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  909. {
  910. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  911. /* The multiple "Capture Source" controls confuse alsamixer
  912. * So call somewhat different..
  913. * FIXME: the controls appear in the "playback" view!
  914. */
  915. /* .name = "Capture Source", */
  916. .name = "Input Source",
  917. .count = 1,
  918. .info = alc_mux_enum_info,
  919. .get = alc_mux_enum_get,
  920. .put = alc_mux_enum_put,
  921. },
  922. { } /* end */
  923. };
  924. /* Uniwill */
  925. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  926. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  927. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  928. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  929. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  930. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  931. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  932. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  933. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  934. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  935. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  936. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  937. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  938. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  939. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  940. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  941. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  942. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  943. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  944. {
  945. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  946. .name = "Channel Mode",
  947. .info = alc_ch_mode_info,
  948. .get = alc_ch_mode_get,
  949. .put = alc_ch_mode_put,
  950. },
  951. { } /* end */
  952. };
  953. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  954. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  955. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  956. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  957. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  958. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  959. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  960. { } /* end */
  961. };
  962. /*
  963. * build control elements
  964. */
  965. static int alc_build_controls(struct hda_codec *codec)
  966. {
  967. struct alc_spec *spec = codec->spec;
  968. int err;
  969. int i;
  970. for (i = 0; i < spec->num_mixers; i++) {
  971. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  972. if (err < 0)
  973. return err;
  974. }
  975. if (spec->multiout.dig_out_nid) {
  976. err = snd_hda_create_spdif_out_ctls(codec,
  977. spec->multiout.dig_out_nid);
  978. if (err < 0)
  979. return err;
  980. }
  981. if (spec->dig_in_nid) {
  982. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  983. if (err < 0)
  984. return err;
  985. }
  986. return 0;
  987. }
  988. /*
  989. * initialize the codec volumes, etc
  990. */
  991. /*
  992. * generic initialization of ADC, input mixers and output mixers
  993. */
  994. static struct hda_verb alc880_volume_init_verbs[] = {
  995. /*
  996. * Unmute ADC0-2 and set the default input to mic-in
  997. */
  998. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  999. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1000. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1001. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1002. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1003. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1004. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1005. * mixer widget
  1006. * Note: PASD motherboards uses the Line In 2 as the input for front
  1007. * panel mic (mic 2)
  1008. */
  1009. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1010. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1011. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1012. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1013. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1014. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1015. /*
  1016. * Set up output mixers (0x0c - 0x0f)
  1017. */
  1018. /* set vol=0 to output mixers */
  1019. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1020. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1021. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1022. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1023. /* set up input amps for analog loopback */
  1024. /* Amp Indices: DAC = 0, mixer = 1 */
  1025. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1026. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1027. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1028. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1029. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1030. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1031. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1032. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1033. { }
  1034. };
  1035. /*
  1036. * 3-stack pin configuration:
  1037. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1038. */
  1039. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1040. /*
  1041. * preset connection lists of input pins
  1042. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1043. */
  1044. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1045. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1046. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1047. /*
  1048. * Set pin mode and muting
  1049. */
  1050. /* set front pin widgets 0x14 for output */
  1051. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1052. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1053. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1054. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1055. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1056. /* Mic2 (as headphone out) for HP output */
  1057. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1058. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1059. /* Line In pin widget for input */
  1060. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1061. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1062. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1063. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1064. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1065. /* CD pin widget for input */
  1066. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1067. { }
  1068. };
  1069. /*
  1070. * 5-stack pin configuration:
  1071. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1072. * line-in/side = 0x1a, f-mic = 0x1b
  1073. */
  1074. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1075. /*
  1076. * preset connection lists of input pins
  1077. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1078. */
  1079. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1080. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1081. /*
  1082. * Set pin mode and muting
  1083. */
  1084. /* set pin widgets 0x14-0x17 for output */
  1085. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1086. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1087. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1088. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1089. /* unmute pins for output (no gain on this amp) */
  1090. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1091. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1092. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1093. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1094. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1095. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1096. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1097. /* Mic2 (as headphone out) for HP output */
  1098. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1099. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1100. /* Line In pin widget for input */
  1101. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1102. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1103. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1104. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1105. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1106. /* CD pin widget for input */
  1107. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1108. { }
  1109. };
  1110. /*
  1111. * W810 pin configuration:
  1112. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1113. */
  1114. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1115. /* hphone/speaker input selector: front DAC */
  1116. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1117. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1118. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1119. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1120. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1121. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1122. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1123. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1124. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1125. { }
  1126. };
  1127. /*
  1128. * Z71V pin configuration:
  1129. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1130. */
  1131. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1132. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1133. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1134. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1135. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1136. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1137. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1138. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1139. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1140. { }
  1141. };
  1142. /*
  1143. * 6-stack pin configuration:
  1144. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1145. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1146. */
  1147. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1148. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1149. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1150. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1151. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1152. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1153. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1154. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1155. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1156. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1157. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1158. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1159. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1160. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1161. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1162. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1163. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1164. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1165. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1166. { }
  1167. };
  1168. /*
  1169. * Uniwill pin configuration:
  1170. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1171. * line = 0x1a
  1172. */
  1173. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1174. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1175. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1176. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1177. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1178. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1179. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1180. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1181. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1182. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1183. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1184. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1185. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1186. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1187. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1188. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1189. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1190. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1191. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1192. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1193. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1194. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1195. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1196. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1197. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1198. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1199. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1200. { }
  1201. };
  1202. /*
  1203. * Uniwill P53
  1204. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1205. */
  1206. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1207. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1208. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1209. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1210. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1211. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1212. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1213. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1214. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1215. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1216. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1217. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1218. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1219. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1220. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1221. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1222. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1223. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1224. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1225. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1226. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1227. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1228. { }
  1229. };
  1230. /* toggle speaker-output according to the hp-jack state */
  1231. static void alc880_uniwill_automute(struct hda_codec *codec)
  1232. {
  1233. unsigned int present;
  1234. present = snd_hda_codec_read(codec, 0x14, 0,
  1235. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1236. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1237. 0x80, present ? 0x80 : 0);
  1238. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1239. 0x80, present ? 0x80 : 0);
  1240. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1241. 0x80, present ? 0x80 : 0);
  1242. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1243. 0x80, present ? 0x80 : 0);
  1244. present = snd_hda_codec_read(codec, 0x18, 0,
  1245. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1246. snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1247. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  1248. }
  1249. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1250. unsigned int res)
  1251. {
  1252. /* Looks like the unsol event is incompatible with the standard
  1253. * definition. 4bit tag is placed at 28 bit!
  1254. */
  1255. if ((res >> 28) == ALC880_HP_EVENT ||
  1256. (res >> 28) == ALC880_MIC_EVENT)
  1257. alc880_uniwill_automute(codec);
  1258. }
  1259. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1260. {
  1261. unsigned int present;
  1262. present = snd_hda_codec_read(codec, 0x14, 0,
  1263. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1264. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1265. 0x80, present ? 0x80 : 0);
  1266. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1267. 0x80, present ? 0x80 : 0);
  1268. }
  1269. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1270. {
  1271. unsigned int present;
  1272. present = snd_hda_codec_read(codec, 0x21, 0,
  1273. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1274. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1275. 0x7f, present);
  1276. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1277. 0x7f, present);
  1278. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1279. 0x7f, present);
  1280. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1281. 0x7f, present);
  1282. }
  1283. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1284. unsigned int res)
  1285. {
  1286. /* Looks like the unsol event is incompatible with the standard
  1287. * definition. 4bit tag is placed at 28 bit!
  1288. */
  1289. if ((res >> 28) == ALC880_HP_EVENT)
  1290. alc880_uniwill_p53_hp_automute(codec);
  1291. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1292. alc880_uniwill_p53_dcvol_automute(codec);
  1293. }
  1294. /* FIXME! */
  1295. /*
  1296. * F1734 pin configuration:
  1297. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1298. */
  1299. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1300. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1301. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1302. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1303. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1304. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1305. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1306. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1307. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1308. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1309. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1310. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1311. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1312. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1313. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1314. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1315. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1316. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1317. { }
  1318. };
  1319. /* FIXME! */
  1320. /*
  1321. * ASUS pin configuration:
  1322. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1323. */
  1324. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1325. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1326. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1327. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1328. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1329. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1330. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1331. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1332. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1333. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1334. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1335. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1336. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1337. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1338. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1339. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1340. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1341. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1342. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1343. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1344. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1345. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1346. { }
  1347. };
  1348. /* Enable GPIO mask and set output */
  1349. static struct hda_verb alc880_gpio1_init_verbs[] = {
  1350. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  1351. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  1352. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  1353. { }
  1354. };
  1355. /* Enable GPIO mask and set output */
  1356. static struct hda_verb alc880_gpio2_init_verbs[] = {
  1357. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  1358. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  1359. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  1360. { }
  1361. };
  1362. /* Clevo m520g init */
  1363. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1364. /* headphone output */
  1365. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1366. /* line-out */
  1367. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1368. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1369. /* Line-in */
  1370. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1371. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1372. /* CD */
  1373. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1374. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1375. /* Mic1 (rear panel) */
  1376. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1377. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1378. /* Mic2 (front panel) */
  1379. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1380. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1381. /* headphone */
  1382. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1383. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1384. /* change to EAPD mode */
  1385. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1386. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1387. { }
  1388. };
  1389. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1390. /* change to EAPD mode */
  1391. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1392. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1393. /* Headphone output */
  1394. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1395. /* Front output*/
  1396. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1397. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1398. /* Line In pin widget for input */
  1399. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1400. /* CD pin widget for input */
  1401. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1402. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1403. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1404. /* change to EAPD mode */
  1405. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1406. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1407. { }
  1408. };
  1409. /*
  1410. * LG m1 express dual
  1411. *
  1412. * Pin assignment:
  1413. * Rear Line-In/Out (blue): 0x14
  1414. * Build-in Mic-In: 0x15
  1415. * Speaker-out: 0x17
  1416. * HP-Out (green): 0x1b
  1417. * Mic-In/Out (red): 0x19
  1418. * SPDIF-Out: 0x1e
  1419. */
  1420. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1421. static hda_nid_t alc880_lg_dac_nids[3] = {
  1422. 0x05, 0x02, 0x03
  1423. };
  1424. /* seems analog CD is not working */
  1425. static struct hda_input_mux alc880_lg_capture_source = {
  1426. .num_items = 3,
  1427. .items = {
  1428. { "Mic", 0x1 },
  1429. { "Line", 0x5 },
  1430. { "Internal Mic", 0x6 },
  1431. },
  1432. };
  1433. /* 2,4,6 channel modes */
  1434. static struct hda_verb alc880_lg_ch2_init[] = {
  1435. /* set line-in and mic-in to input */
  1436. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1437. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1438. { }
  1439. };
  1440. static struct hda_verb alc880_lg_ch4_init[] = {
  1441. /* set line-in to out and mic-in to input */
  1442. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1443. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1444. { }
  1445. };
  1446. static struct hda_verb alc880_lg_ch6_init[] = {
  1447. /* set line-in and mic-in to output */
  1448. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1449. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1450. { }
  1451. };
  1452. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1453. { 2, alc880_lg_ch2_init },
  1454. { 4, alc880_lg_ch4_init },
  1455. { 6, alc880_lg_ch6_init },
  1456. };
  1457. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1458. /* FIXME: it's not really "master" but front channels */
  1459. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1460. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1461. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1462. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1463. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1464. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1465. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1466. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1467. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1468. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1469. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1470. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1471. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1472. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1473. {
  1474. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1475. .name = "Channel Mode",
  1476. .info = alc_ch_mode_info,
  1477. .get = alc_ch_mode_get,
  1478. .put = alc_ch_mode_put,
  1479. },
  1480. { } /* end */
  1481. };
  1482. static struct hda_verb alc880_lg_init_verbs[] = {
  1483. /* set capture source to mic-in */
  1484. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1485. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1486. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1487. /* mute all amp mixer inputs */
  1488. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1489. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1490. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1491. /* line-in to input */
  1492. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1493. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1494. /* built-in mic */
  1495. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1496. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1497. /* speaker-out */
  1498. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1499. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1500. /* mic-in to input */
  1501. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1502. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1503. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1504. /* HP-out */
  1505. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1506. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1507. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1508. /* jack sense */
  1509. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1510. { }
  1511. };
  1512. /* toggle speaker-output according to the hp-jack state */
  1513. static void alc880_lg_automute(struct hda_codec *codec)
  1514. {
  1515. unsigned int present;
  1516. present = snd_hda_codec_read(codec, 0x1b, 0,
  1517. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1518. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1519. 0x80, present ? 0x80 : 0);
  1520. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1521. 0x80, present ? 0x80 : 0);
  1522. }
  1523. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1524. {
  1525. /* Looks like the unsol event is incompatible with the standard
  1526. * definition. 4bit tag is placed at 28 bit!
  1527. */
  1528. if ((res >> 28) == 0x01)
  1529. alc880_lg_automute(codec);
  1530. }
  1531. /*
  1532. * LG LW20
  1533. *
  1534. * Pin assignment:
  1535. * Speaker-out: 0x14
  1536. * Mic-In: 0x18
  1537. * Built-in Mic-In: 0x19 (?)
  1538. * HP-Out: 0x1b
  1539. * SPDIF-Out: 0x1e
  1540. */
  1541. /* seems analog CD is not working */
  1542. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1543. .num_items = 2,
  1544. .items = {
  1545. { "Mic", 0x0 },
  1546. { "Internal Mic", 0x1 },
  1547. },
  1548. };
  1549. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1550. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1551. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1552. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1553. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1554. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1555. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1556. { } /* end */
  1557. };
  1558. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1559. /* set capture source to mic-in */
  1560. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1561. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1562. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1563. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1564. /* speaker-out */
  1565. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1566. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1567. /* HP-out */
  1568. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1569. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1570. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1571. /* mic-in to input */
  1572. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1573. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1574. /* built-in mic */
  1575. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1576. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1577. /* jack sense */
  1578. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1579. { }
  1580. };
  1581. /* toggle speaker-output according to the hp-jack state */
  1582. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1583. {
  1584. unsigned int present;
  1585. present = snd_hda_codec_read(codec, 0x1b, 0,
  1586. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1587. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1588. 0x80, present ? 0x80 : 0);
  1589. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1590. 0x80, present ? 0x80 : 0);
  1591. }
  1592. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1593. {
  1594. /* Looks like the unsol event is incompatible with the standard
  1595. * definition. 4bit tag is placed at 28 bit!
  1596. */
  1597. if ((res >> 28) == 0x01)
  1598. alc880_lg_lw_automute(codec);
  1599. }
  1600. /*
  1601. * Common callbacks
  1602. */
  1603. static int alc_init(struct hda_codec *codec)
  1604. {
  1605. struct alc_spec *spec = codec->spec;
  1606. unsigned int i;
  1607. for (i = 0; i < spec->num_init_verbs; i++)
  1608. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1609. if (spec->init_hook)
  1610. spec->init_hook(codec);
  1611. return 0;
  1612. }
  1613. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1614. {
  1615. struct alc_spec *spec = codec->spec;
  1616. if (spec->unsol_event)
  1617. spec->unsol_event(codec, res);
  1618. }
  1619. #ifdef CONFIG_PM
  1620. /*
  1621. * resume
  1622. */
  1623. static int alc_resume(struct hda_codec *codec)
  1624. {
  1625. struct alc_spec *spec = codec->spec;
  1626. int i;
  1627. alc_init(codec);
  1628. for (i = 0; i < spec->num_mixers; i++)
  1629. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1630. if (spec->multiout.dig_out_nid)
  1631. snd_hda_resume_spdif_out(codec);
  1632. if (spec->dig_in_nid)
  1633. snd_hda_resume_spdif_in(codec);
  1634. return 0;
  1635. }
  1636. #endif
  1637. /*
  1638. * Analog playback callbacks
  1639. */
  1640. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1641. struct hda_codec *codec,
  1642. struct snd_pcm_substream *substream)
  1643. {
  1644. struct alc_spec *spec = codec->spec;
  1645. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1646. }
  1647. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1648. struct hda_codec *codec,
  1649. unsigned int stream_tag,
  1650. unsigned int format,
  1651. struct snd_pcm_substream *substream)
  1652. {
  1653. struct alc_spec *spec = codec->spec;
  1654. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1655. stream_tag, format, substream);
  1656. }
  1657. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1658. struct hda_codec *codec,
  1659. struct snd_pcm_substream *substream)
  1660. {
  1661. struct alc_spec *spec = codec->spec;
  1662. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1663. }
  1664. /*
  1665. * Digital out
  1666. */
  1667. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1668. struct hda_codec *codec,
  1669. struct snd_pcm_substream *substream)
  1670. {
  1671. struct alc_spec *spec = codec->spec;
  1672. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1673. }
  1674. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1675. struct hda_codec *codec,
  1676. struct snd_pcm_substream *substream)
  1677. {
  1678. struct alc_spec *spec = codec->spec;
  1679. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1680. }
  1681. /*
  1682. * Analog capture
  1683. */
  1684. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1685. struct hda_codec *codec,
  1686. unsigned int stream_tag,
  1687. unsigned int format,
  1688. struct snd_pcm_substream *substream)
  1689. {
  1690. struct alc_spec *spec = codec->spec;
  1691. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1692. stream_tag, 0, format);
  1693. return 0;
  1694. }
  1695. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1696. struct hda_codec *codec,
  1697. struct snd_pcm_substream *substream)
  1698. {
  1699. struct alc_spec *spec = codec->spec;
  1700. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1701. 0, 0, 0);
  1702. return 0;
  1703. }
  1704. /*
  1705. */
  1706. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1707. .substreams = 1,
  1708. .channels_min = 2,
  1709. .channels_max = 8,
  1710. /* NID is set in alc_build_pcms */
  1711. .ops = {
  1712. .open = alc880_playback_pcm_open,
  1713. .prepare = alc880_playback_pcm_prepare,
  1714. .cleanup = alc880_playback_pcm_cleanup
  1715. },
  1716. };
  1717. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1718. .substreams = 2,
  1719. .channels_min = 2,
  1720. .channels_max = 2,
  1721. /* NID is set in alc_build_pcms */
  1722. .ops = {
  1723. .prepare = alc880_capture_pcm_prepare,
  1724. .cleanup = alc880_capture_pcm_cleanup
  1725. },
  1726. };
  1727. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1728. .substreams = 1,
  1729. .channels_min = 2,
  1730. .channels_max = 2,
  1731. /* NID is set in alc_build_pcms */
  1732. .ops = {
  1733. .open = alc880_dig_playback_pcm_open,
  1734. .close = alc880_dig_playback_pcm_close
  1735. },
  1736. };
  1737. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1738. .substreams = 1,
  1739. .channels_min = 2,
  1740. .channels_max = 2,
  1741. /* NID is set in alc_build_pcms */
  1742. };
  1743. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1744. static struct hda_pcm_stream alc_pcm_null_playback = {
  1745. .substreams = 0,
  1746. .channels_min = 0,
  1747. .channels_max = 0,
  1748. };
  1749. static int alc_build_pcms(struct hda_codec *codec)
  1750. {
  1751. struct alc_spec *spec = codec->spec;
  1752. struct hda_pcm *info = spec->pcm_rec;
  1753. int i;
  1754. codec->num_pcms = 1;
  1755. codec->pcm_info = info;
  1756. info->name = spec->stream_name_analog;
  1757. if (spec->stream_analog_playback) {
  1758. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1759. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1760. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1761. }
  1762. if (spec->stream_analog_capture) {
  1763. snd_assert(spec->adc_nids, return -EINVAL);
  1764. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1765. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1766. }
  1767. if (spec->channel_mode) {
  1768. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1769. for (i = 0; i < spec->num_channel_mode; i++) {
  1770. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1771. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1772. }
  1773. }
  1774. }
  1775. /* SPDIF for stream index #1 */
  1776. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1777. codec->num_pcms = 2;
  1778. info = spec->pcm_rec + 1;
  1779. info->name = spec->stream_name_digital;
  1780. if (spec->multiout.dig_out_nid &&
  1781. spec->stream_digital_playback) {
  1782. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1783. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1784. }
  1785. if (spec->dig_in_nid &&
  1786. spec->stream_digital_capture) {
  1787. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1788. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1789. }
  1790. }
  1791. /* If the use of more than one ADC is requested for the current
  1792. * model, configure a second analog capture-only PCM.
  1793. */
  1794. /* Additional Analaog capture for index #2 */
  1795. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1796. spec->adc_nids) {
  1797. codec->num_pcms = 3;
  1798. info = spec->pcm_rec + 2;
  1799. info->name = spec->stream_name_analog;
  1800. /* No playback stream for second PCM */
  1801. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1802. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1803. if (spec->stream_analog_capture) {
  1804. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1805. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1806. }
  1807. }
  1808. return 0;
  1809. }
  1810. static void alc_free(struct hda_codec *codec)
  1811. {
  1812. struct alc_spec *spec = codec->spec;
  1813. unsigned int i;
  1814. if (! spec)
  1815. return;
  1816. if (spec->kctl_alloc) {
  1817. for (i = 0; i < spec->num_kctl_used; i++)
  1818. kfree(spec->kctl_alloc[i].name);
  1819. kfree(spec->kctl_alloc);
  1820. }
  1821. kfree(spec);
  1822. }
  1823. /*
  1824. */
  1825. static struct hda_codec_ops alc_patch_ops = {
  1826. .build_controls = alc_build_controls,
  1827. .build_pcms = alc_build_pcms,
  1828. .init = alc_init,
  1829. .free = alc_free,
  1830. .unsol_event = alc_unsol_event,
  1831. #ifdef CONFIG_PM
  1832. .resume = alc_resume,
  1833. #endif
  1834. };
  1835. /*
  1836. * Test configuration for debugging
  1837. *
  1838. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1839. * enum controls.
  1840. */
  1841. #ifdef CONFIG_SND_DEBUG
  1842. static hda_nid_t alc880_test_dac_nids[4] = {
  1843. 0x02, 0x03, 0x04, 0x05
  1844. };
  1845. static struct hda_input_mux alc880_test_capture_source = {
  1846. .num_items = 7,
  1847. .items = {
  1848. { "In-1", 0x0 },
  1849. { "In-2", 0x1 },
  1850. { "In-3", 0x2 },
  1851. { "In-4", 0x3 },
  1852. { "CD", 0x4 },
  1853. { "Front", 0x5 },
  1854. { "Surround", 0x6 },
  1855. },
  1856. };
  1857. static struct hda_channel_mode alc880_test_modes[4] = {
  1858. { 2, NULL },
  1859. { 4, NULL },
  1860. { 6, NULL },
  1861. { 8, NULL },
  1862. };
  1863. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  1864. struct snd_ctl_elem_info *uinfo)
  1865. {
  1866. static char *texts[] = {
  1867. "N/A", "Line Out", "HP Out",
  1868. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1869. };
  1870. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1871. uinfo->count = 1;
  1872. uinfo->value.enumerated.items = 8;
  1873. if (uinfo->value.enumerated.item >= 8)
  1874. uinfo->value.enumerated.item = 7;
  1875. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1876. return 0;
  1877. }
  1878. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  1879. struct snd_ctl_elem_value *ucontrol)
  1880. {
  1881. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1882. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1883. unsigned int pin_ctl, item = 0;
  1884. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1885. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1886. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1887. if (pin_ctl & AC_PINCTL_HP_EN)
  1888. item = 2;
  1889. else
  1890. item = 1;
  1891. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1892. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1893. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1894. case AC_PINCTL_VREF_50: item = 4; break;
  1895. case AC_PINCTL_VREF_GRD: item = 5; break;
  1896. case AC_PINCTL_VREF_80: item = 6; break;
  1897. case AC_PINCTL_VREF_100: item = 7; break;
  1898. }
  1899. }
  1900. ucontrol->value.enumerated.item[0] = item;
  1901. return 0;
  1902. }
  1903. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  1904. struct snd_ctl_elem_value *ucontrol)
  1905. {
  1906. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1907. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1908. static unsigned int ctls[] = {
  1909. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1910. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1911. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1912. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1913. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1914. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1915. };
  1916. unsigned int old_ctl, new_ctl;
  1917. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1918. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1919. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1920. if (old_ctl != new_ctl) {
  1921. snd_hda_codec_write(codec, nid, 0,
  1922. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1923. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1924. (ucontrol->value.enumerated.item[0] >= 3 ?
  1925. 0xb080 : 0xb000));
  1926. return 1;
  1927. }
  1928. return 0;
  1929. }
  1930. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  1931. struct snd_ctl_elem_info *uinfo)
  1932. {
  1933. static char *texts[] = {
  1934. "Front", "Surround", "CLFE", "Side"
  1935. };
  1936. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1937. uinfo->count = 1;
  1938. uinfo->value.enumerated.items = 4;
  1939. if (uinfo->value.enumerated.item >= 4)
  1940. uinfo->value.enumerated.item = 3;
  1941. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1942. return 0;
  1943. }
  1944. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  1945. struct snd_ctl_elem_value *ucontrol)
  1946. {
  1947. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1948. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1949. unsigned int sel;
  1950. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1951. ucontrol->value.enumerated.item[0] = sel & 3;
  1952. return 0;
  1953. }
  1954. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  1955. struct snd_ctl_elem_value *ucontrol)
  1956. {
  1957. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1958. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1959. unsigned int sel;
  1960. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1961. if (ucontrol->value.enumerated.item[0] != sel) {
  1962. sel = ucontrol->value.enumerated.item[0] & 3;
  1963. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1964. return 1;
  1965. }
  1966. return 0;
  1967. }
  1968. #define PIN_CTL_TEST(xname,nid) { \
  1969. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1970. .name = xname, \
  1971. .info = alc_test_pin_ctl_info, \
  1972. .get = alc_test_pin_ctl_get, \
  1973. .put = alc_test_pin_ctl_put, \
  1974. .private_value = nid \
  1975. }
  1976. #define PIN_SRC_TEST(xname,nid) { \
  1977. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1978. .name = xname, \
  1979. .info = alc_test_pin_src_info, \
  1980. .get = alc_test_pin_src_get, \
  1981. .put = alc_test_pin_src_put, \
  1982. .private_value = nid \
  1983. }
  1984. static struct snd_kcontrol_new alc880_test_mixer[] = {
  1985. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1986. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1987. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  1988. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1989. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1990. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1991. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  1992. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1993. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1994. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1995. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1996. PIN_CTL_TEST("Side Pin Mode", 0x17),
  1997. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  1998. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  1999. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2000. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2001. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2002. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2003. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2004. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2005. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2006. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2007. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2008. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2009. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2010. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2011. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2012. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2013. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2014. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2015. {
  2016. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2017. .name = "Channel Mode",
  2018. .info = alc_ch_mode_info,
  2019. .get = alc_ch_mode_get,
  2020. .put = alc_ch_mode_put,
  2021. },
  2022. { } /* end */
  2023. };
  2024. static struct hda_verb alc880_test_init_verbs[] = {
  2025. /* Unmute inputs of 0x0c - 0x0f */
  2026. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2027. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2028. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2029. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2030. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2031. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2032. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2033. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2034. /* Vol output for 0x0c-0x0f */
  2035. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2036. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2037. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2038. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2039. /* Set output pins 0x14-0x17 */
  2040. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2041. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2042. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2043. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2044. /* Unmute output pins 0x14-0x17 */
  2045. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2046. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2047. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2048. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2049. /* Set input pins 0x18-0x1c */
  2050. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2051. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2052. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2053. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2054. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2055. /* Mute input pins 0x18-0x1b */
  2056. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2057. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2058. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2059. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2060. /* ADC set up */
  2061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2062. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2063. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2064. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2065. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2066. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2067. /* Analog input/passthru */
  2068. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2069. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2070. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2071. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2072. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2073. { }
  2074. };
  2075. #endif
  2076. /*
  2077. */
  2078. static struct hda_board_config alc880_cfg_tbl[] = {
  2079. /* Back 3 jack, front 2 jack */
  2080. { .modelname = "3stack", .config = ALC880_3ST },
  2081. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
  2082. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
  2083. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
  2084. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
  2085. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
  2086. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
  2087. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
  2088. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
  2089. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
  2090. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
  2091. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
  2092. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
  2093. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
  2094. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
  2095. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
  2096. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
  2097. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
  2098. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
  2099. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe212, .config = ALC880_3ST },
  2100. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe213, .config = ALC880_3ST },
  2101. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
  2102. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe234, .config = ALC880_3ST },
  2103. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
  2104. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
  2105. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
  2106. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
  2107. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
  2108. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
  2109. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
  2110. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
  2111. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
  2112. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
  2113. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
  2114. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
  2115. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
  2116. /* TCL S700 */
  2117. { .modelname = "tcl", .config = ALC880_TCL_S700 },
  2118. { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
  2119. /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  2120. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
  2121. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
  2122. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
  2123. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
  2124. { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  2125. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
  2126. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
  2127. /* Clevo laptops */
  2128. { .modelname = "clevo", .config = ALC880_CLEVO },
  2129. { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520,
  2130. .config = ALC880_CLEVO }, /* Clevo m520G NB */
  2131. { .pci_subvendor = 0x1558, .pci_subdevice = 0x0660,
  2132. .config = ALC880_CLEVO }, /* Clevo m665n */
  2133. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  2134. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
  2135. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
  2136. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
  2137. /* Back 5 jack, front 2 jack */
  2138. { .modelname = "5stack", .config = ALC880_5ST },
  2139. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
  2140. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
  2141. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
  2142. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
  2143. { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
  2144. /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
  2145. { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
  2146. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
  2147. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
  2148. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
  2149. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
  2150. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
  2151. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
  2152. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
  2153. { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
  2154. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
  2155. { .pci_subvendor = 0xa0a0, .pci_subdevice = 0x0560,
  2156. .config = ALC880_5ST_DIG }, /* Aopen i915GMm-HFS */
  2157. /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
  2158. { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
  2159. /* note subvendor = 0 below */
  2160. /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
  2161. { .modelname = "w810", .config = ALC880_W810 },
  2162. { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
  2163. { .modelname = "z71v", .config = ALC880_Z71V },
  2164. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
  2165. { .modelname = "6stack", .config = ALC880_6ST },
  2166. { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
  2167. { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
  2168. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
  2169. { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
  2170. { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
  2171. { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
  2172. { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
  2173. { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
  2174. { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
  2175. { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
  2176. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
  2177. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
  2178. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
  2179. { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
  2180. { .pci_subvendor = 0x1509, .pci_subdevice = 0x925d, .config = ALC880_6ST_DIG }, /* FIC P4M-915GD1 */
  2181. { .pci_subvendor = 0x1695, .pci_subdevice = 0x4012, .config = ALC880_5ST_DIG }, /* Epox EP-5LDA+ GLi */
  2182. { .modelname = "asus", .config = ALC880_ASUS },
  2183. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
  2184. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
  2185. { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
  2186. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
  2187. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
  2188. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
  2189. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c2, .config = ALC880_ASUS_DIG }, /* Asus W6A */
  2190. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
  2191. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
  2192. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
  2193. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
  2194. { .modelname = "asus-w1v", .config = ALC880_ASUS_W1V },
  2195. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
  2196. { .modelname = "asus-dig", .config = ALC880_ASUS_DIG },
  2197. { .pci_subvendor = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
  2198. { .modelname = "asus-dig2", .config = ALC880_ASUS_DIG2 },
  2199. { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
  2200. { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
  2201. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
  2202. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9070, .config = ALC880_UNIWILL },
  2203. { .pci_subvendor = 0x1734, .pci_subdevice = 0x10ac, .config = ALC880_UNIWILL },
  2204. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9077, .config = ALC880_UNIWILL_P53 },
  2205. { .modelname = "F1734", .config = ALC880_F1734 },
  2206. { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
  2207. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
  2208. { .modelname = "lg", .config = ALC880_LG },
  2209. { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
  2210. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0068, .config = ALC880_LG },
  2211. { .modelname = "lg-lw", .config = ALC880_LG_LW },
  2212. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0018, .config = ALC880_LG_LW },
  2213. { .pci_subvendor = 0x1854, .pci_subdevice = 0x0077, .config = ALC880_LG_LW },
  2214. #ifdef CONFIG_SND_DEBUG
  2215. { .modelname = "test", .config = ALC880_TEST },
  2216. #endif
  2217. { .modelname = "auto", .config = ALC880_AUTO },
  2218. {}
  2219. };
  2220. /*
  2221. * ALC880 codec presets
  2222. */
  2223. static struct alc_config_preset alc880_presets[] = {
  2224. [ALC880_3ST] = {
  2225. .mixers = { alc880_three_stack_mixer },
  2226. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2227. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2228. .dac_nids = alc880_dac_nids,
  2229. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2230. .channel_mode = alc880_threestack_modes,
  2231. .need_dac_fix = 1,
  2232. .input_mux = &alc880_capture_source,
  2233. },
  2234. [ALC880_3ST_DIG] = {
  2235. .mixers = { alc880_three_stack_mixer },
  2236. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2237. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2238. .dac_nids = alc880_dac_nids,
  2239. .dig_out_nid = ALC880_DIGOUT_NID,
  2240. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2241. .channel_mode = alc880_threestack_modes,
  2242. .need_dac_fix = 1,
  2243. .input_mux = &alc880_capture_source,
  2244. },
  2245. [ALC880_TCL_S700] = {
  2246. .mixers = { alc880_tcl_s700_mixer },
  2247. .init_verbs = { alc880_volume_init_verbs,
  2248. alc880_pin_tcl_S700_init_verbs,
  2249. alc880_gpio2_init_verbs },
  2250. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2251. .dac_nids = alc880_dac_nids,
  2252. .hp_nid = 0x03,
  2253. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2254. .channel_mode = alc880_2_jack_modes,
  2255. .input_mux = &alc880_capture_source,
  2256. },
  2257. [ALC880_5ST] = {
  2258. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  2259. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2260. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2261. .dac_nids = alc880_dac_nids,
  2262. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2263. .channel_mode = alc880_fivestack_modes,
  2264. .input_mux = &alc880_capture_source,
  2265. },
  2266. [ALC880_5ST_DIG] = {
  2267. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  2268. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2269. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2270. .dac_nids = alc880_dac_nids,
  2271. .dig_out_nid = ALC880_DIGOUT_NID,
  2272. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2273. .channel_mode = alc880_fivestack_modes,
  2274. .input_mux = &alc880_capture_source,
  2275. },
  2276. [ALC880_6ST] = {
  2277. .mixers = { alc880_six_stack_mixer },
  2278. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2279. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2280. .dac_nids = alc880_6st_dac_nids,
  2281. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2282. .channel_mode = alc880_sixstack_modes,
  2283. .input_mux = &alc880_6stack_capture_source,
  2284. },
  2285. [ALC880_6ST_DIG] = {
  2286. .mixers = { alc880_six_stack_mixer },
  2287. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2288. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2289. .dac_nids = alc880_6st_dac_nids,
  2290. .dig_out_nid = ALC880_DIGOUT_NID,
  2291. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2292. .channel_mode = alc880_sixstack_modes,
  2293. .input_mux = &alc880_6stack_capture_source,
  2294. },
  2295. [ALC880_W810] = {
  2296. .mixers = { alc880_w810_base_mixer },
  2297. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  2298. alc880_gpio2_init_verbs },
  2299. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2300. .dac_nids = alc880_w810_dac_nids,
  2301. .dig_out_nid = ALC880_DIGOUT_NID,
  2302. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2303. .channel_mode = alc880_w810_modes,
  2304. .input_mux = &alc880_capture_source,
  2305. },
  2306. [ALC880_Z71V] = {
  2307. .mixers = { alc880_z71v_mixer },
  2308. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  2309. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2310. .dac_nids = alc880_z71v_dac_nids,
  2311. .dig_out_nid = ALC880_DIGOUT_NID,
  2312. .hp_nid = 0x03,
  2313. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2314. .channel_mode = alc880_2_jack_modes,
  2315. .input_mux = &alc880_capture_source,
  2316. },
  2317. [ALC880_F1734] = {
  2318. .mixers = { alc880_f1734_mixer },
  2319. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  2320. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2321. .dac_nids = alc880_f1734_dac_nids,
  2322. .hp_nid = 0x02,
  2323. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2324. .channel_mode = alc880_2_jack_modes,
  2325. .input_mux = &alc880_capture_source,
  2326. },
  2327. [ALC880_ASUS] = {
  2328. .mixers = { alc880_asus_mixer },
  2329. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2330. alc880_gpio1_init_verbs },
  2331. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2332. .dac_nids = alc880_asus_dac_nids,
  2333. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2334. .channel_mode = alc880_asus_modes,
  2335. .need_dac_fix = 1,
  2336. .input_mux = &alc880_capture_source,
  2337. },
  2338. [ALC880_ASUS_DIG] = {
  2339. .mixers = { alc880_asus_mixer },
  2340. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2341. alc880_gpio1_init_verbs },
  2342. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2343. .dac_nids = alc880_asus_dac_nids,
  2344. .dig_out_nid = ALC880_DIGOUT_NID,
  2345. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2346. .channel_mode = alc880_asus_modes,
  2347. .need_dac_fix = 1,
  2348. .input_mux = &alc880_capture_source,
  2349. },
  2350. [ALC880_ASUS_DIG2] = {
  2351. .mixers = { alc880_asus_mixer },
  2352. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2353. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2354. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2355. .dac_nids = alc880_asus_dac_nids,
  2356. .dig_out_nid = ALC880_DIGOUT_NID,
  2357. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2358. .channel_mode = alc880_asus_modes,
  2359. .need_dac_fix = 1,
  2360. .input_mux = &alc880_capture_source,
  2361. },
  2362. [ALC880_ASUS_W1V] = {
  2363. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2364. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2365. alc880_gpio1_init_verbs },
  2366. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2367. .dac_nids = alc880_asus_dac_nids,
  2368. .dig_out_nid = ALC880_DIGOUT_NID,
  2369. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2370. .channel_mode = alc880_asus_modes,
  2371. .need_dac_fix = 1,
  2372. .input_mux = &alc880_capture_source,
  2373. },
  2374. [ALC880_UNIWILL_DIG] = {
  2375. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2376. .init_verbs = { alc880_volume_init_verbs,
  2377. alc880_pin_asus_init_verbs },
  2378. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2379. .dac_nids = alc880_asus_dac_nids,
  2380. .dig_out_nid = ALC880_DIGOUT_NID,
  2381. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2382. .channel_mode = alc880_asus_modes,
  2383. .need_dac_fix = 1,
  2384. .input_mux = &alc880_capture_source,
  2385. },
  2386. [ALC880_UNIWILL] = {
  2387. .mixers = { alc880_uniwill_mixer },
  2388. .init_verbs = { alc880_volume_init_verbs,
  2389. alc880_uniwill_init_verbs },
  2390. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2391. .dac_nids = alc880_asus_dac_nids,
  2392. .dig_out_nid = ALC880_DIGOUT_NID,
  2393. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2394. .channel_mode = alc880_threestack_modes,
  2395. .need_dac_fix = 1,
  2396. .input_mux = &alc880_capture_source,
  2397. .unsol_event = alc880_uniwill_unsol_event,
  2398. .init_hook = alc880_uniwill_automute,
  2399. },
  2400. [ALC880_UNIWILL_P53] = {
  2401. .mixers = { alc880_uniwill_p53_mixer },
  2402. .init_verbs = { alc880_volume_init_verbs,
  2403. alc880_uniwill_p53_init_verbs },
  2404. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2405. .dac_nids = alc880_asus_dac_nids,
  2406. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2407. .channel_mode = alc880_w810_modes,
  2408. .input_mux = &alc880_capture_source,
  2409. .unsol_event = alc880_uniwill_p53_unsol_event,
  2410. .init_hook = alc880_uniwill_p53_hp_automute,
  2411. },
  2412. [ALC880_CLEVO] = {
  2413. .mixers = { alc880_three_stack_mixer },
  2414. .init_verbs = { alc880_volume_init_verbs,
  2415. alc880_pin_clevo_init_verbs },
  2416. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2417. .dac_nids = alc880_dac_nids,
  2418. .hp_nid = 0x03,
  2419. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2420. .channel_mode = alc880_threestack_modes,
  2421. .need_dac_fix = 1,
  2422. .input_mux = &alc880_capture_source,
  2423. },
  2424. [ALC880_LG] = {
  2425. .mixers = { alc880_lg_mixer },
  2426. .init_verbs = { alc880_volume_init_verbs,
  2427. alc880_lg_init_verbs },
  2428. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2429. .dac_nids = alc880_lg_dac_nids,
  2430. .dig_out_nid = ALC880_DIGOUT_NID,
  2431. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2432. .channel_mode = alc880_lg_ch_modes,
  2433. .need_dac_fix = 1,
  2434. .input_mux = &alc880_lg_capture_source,
  2435. .unsol_event = alc880_lg_unsol_event,
  2436. .init_hook = alc880_lg_automute,
  2437. },
  2438. [ALC880_LG_LW] = {
  2439. .mixers = { alc880_lg_lw_mixer },
  2440. .init_verbs = { alc880_volume_init_verbs,
  2441. alc880_lg_lw_init_verbs },
  2442. .num_dacs = 1,
  2443. .dac_nids = alc880_dac_nids,
  2444. .dig_out_nid = ALC880_DIGOUT_NID,
  2445. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2446. .channel_mode = alc880_2_jack_modes,
  2447. .input_mux = &alc880_lg_lw_capture_source,
  2448. .unsol_event = alc880_lg_lw_unsol_event,
  2449. .init_hook = alc880_lg_lw_automute,
  2450. },
  2451. #ifdef CONFIG_SND_DEBUG
  2452. [ALC880_TEST] = {
  2453. .mixers = { alc880_test_mixer },
  2454. .init_verbs = { alc880_test_init_verbs },
  2455. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2456. .dac_nids = alc880_test_dac_nids,
  2457. .dig_out_nid = ALC880_DIGOUT_NID,
  2458. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2459. .channel_mode = alc880_test_modes,
  2460. .input_mux = &alc880_test_capture_source,
  2461. },
  2462. #endif
  2463. };
  2464. /*
  2465. * Automatic parse of I/O pins from the BIOS configuration
  2466. */
  2467. #define NUM_CONTROL_ALLOC 32
  2468. #define NUM_VERB_ALLOC 32
  2469. enum {
  2470. ALC_CTL_WIDGET_VOL,
  2471. ALC_CTL_WIDGET_MUTE,
  2472. ALC_CTL_BIND_MUTE,
  2473. };
  2474. static struct snd_kcontrol_new alc880_control_templates[] = {
  2475. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2476. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2477. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2478. };
  2479. /* add dynamic controls */
  2480. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  2481. {
  2482. struct snd_kcontrol_new *knew;
  2483. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2484. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2485. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  2486. if (! knew)
  2487. return -ENOMEM;
  2488. if (spec->kctl_alloc) {
  2489. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  2490. kfree(spec->kctl_alloc);
  2491. }
  2492. spec->kctl_alloc = knew;
  2493. spec->num_kctl_alloc = num;
  2494. }
  2495. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2496. *knew = alc880_control_templates[type];
  2497. knew->name = kstrdup(name, GFP_KERNEL);
  2498. if (! knew->name)
  2499. return -ENOMEM;
  2500. knew->private_value = val;
  2501. spec->num_kctl_used++;
  2502. return 0;
  2503. }
  2504. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2505. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2506. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2507. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2508. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2509. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2510. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2511. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2512. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2513. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2514. #define ALC880_PIN_CD_NID 0x1c
  2515. /* fill in the dac_nids table from the parsed pin configuration */
  2516. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  2517. {
  2518. hda_nid_t nid;
  2519. int assigned[4];
  2520. int i, j;
  2521. memset(assigned, 0, sizeof(assigned));
  2522. spec->multiout.dac_nids = spec->private_dac_nids;
  2523. /* check the pins hardwired to audio widget */
  2524. for (i = 0; i < cfg->line_outs; i++) {
  2525. nid = cfg->line_out_pins[i];
  2526. if (alc880_is_fixed_pin(nid)) {
  2527. int idx = alc880_fixed_pin_idx(nid);
  2528. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2529. assigned[idx] = 1;
  2530. }
  2531. }
  2532. /* left pins can be connect to any audio widget */
  2533. for (i = 0; i < cfg->line_outs; i++) {
  2534. nid = cfg->line_out_pins[i];
  2535. if (alc880_is_fixed_pin(nid))
  2536. continue;
  2537. /* search for an empty channel */
  2538. for (j = 0; j < cfg->line_outs; j++) {
  2539. if (! assigned[j]) {
  2540. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  2541. assigned[j] = 1;
  2542. break;
  2543. }
  2544. }
  2545. }
  2546. spec->multiout.num_dacs = cfg->line_outs;
  2547. return 0;
  2548. }
  2549. /* add playback controls from the parsed DAC table */
  2550. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2551. const struct auto_pin_cfg *cfg)
  2552. {
  2553. char name[32];
  2554. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  2555. hda_nid_t nid;
  2556. int i, err;
  2557. for (i = 0; i < cfg->line_outs; i++) {
  2558. if (! spec->multiout.dac_nids[i])
  2559. continue;
  2560. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2561. if (i == 2) {
  2562. /* Center/LFE */
  2563. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  2564. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  2565. return err;
  2566. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  2567. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  2568. return err;
  2569. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  2570. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  2571. return err;
  2572. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  2573. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  2574. return err;
  2575. } else {
  2576. sprintf(name, "%s Playback Volume", chname[i]);
  2577. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2578. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2579. return err;
  2580. sprintf(name, "%s Playback Switch", chname[i]);
  2581. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2582. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2583. return err;
  2584. }
  2585. }
  2586. return 0;
  2587. }
  2588. /* add playback controls for speaker and HP outputs */
  2589. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2590. const char *pfx)
  2591. {
  2592. hda_nid_t nid;
  2593. int err;
  2594. char name[32];
  2595. if (! pin)
  2596. return 0;
  2597. if (alc880_is_fixed_pin(pin)) {
  2598. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2599. /* specify the DAC as the extra output */
  2600. if (! spec->multiout.hp_nid)
  2601. spec->multiout.hp_nid = nid;
  2602. else
  2603. spec->multiout.extra_out_nid[0] = nid;
  2604. /* control HP volume/switch on the output mixer amp */
  2605. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2606. sprintf(name, "%s Playback Volume", pfx);
  2607. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2608. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2609. return err;
  2610. sprintf(name, "%s Playback Switch", pfx);
  2611. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2612. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2613. return err;
  2614. } else if (alc880_is_multi_pin(pin)) {
  2615. /* set manual connection */
  2616. /* we have only a switch on HP-out PIN */
  2617. sprintf(name, "%s Playback Switch", pfx);
  2618. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2619. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  2620. return err;
  2621. }
  2622. return 0;
  2623. }
  2624. /* create input playback/capture controls for the given pin */
  2625. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  2626. int idx, hda_nid_t mix_nid)
  2627. {
  2628. char name[32];
  2629. int err;
  2630. sprintf(name, "%s Playback Volume", ctlname);
  2631. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2632. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2633. return err;
  2634. sprintf(name, "%s Playback Switch", ctlname);
  2635. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2636. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2637. return err;
  2638. return 0;
  2639. }
  2640. /* create playback/capture controls for input pins */
  2641. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2642. const struct auto_pin_cfg *cfg)
  2643. {
  2644. struct hda_input_mux *imux = &spec->private_imux;
  2645. int i, err, idx;
  2646. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2647. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2648. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2649. err = new_analog_input(spec, cfg->input_pins[i],
  2650. auto_pin_cfg_labels[i],
  2651. idx, 0x0b);
  2652. if (err < 0)
  2653. return err;
  2654. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2655. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  2656. imux->num_items++;
  2657. }
  2658. }
  2659. return 0;
  2660. }
  2661. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2662. hda_nid_t nid, int pin_type,
  2663. int dac_idx)
  2664. {
  2665. /* set as output */
  2666. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2667. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2668. /* need the manual connection? */
  2669. if (alc880_is_multi_pin(nid)) {
  2670. struct alc_spec *spec = codec->spec;
  2671. int idx = alc880_multi_pin_idx(nid);
  2672. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2673. AC_VERB_SET_CONNECT_SEL,
  2674. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2675. }
  2676. }
  2677. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2678. {
  2679. struct alc_spec *spec = codec->spec;
  2680. int i;
  2681. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2682. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2683. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  2684. }
  2685. }
  2686. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2687. {
  2688. struct alc_spec *spec = codec->spec;
  2689. hda_nid_t pin;
  2690. pin = spec->autocfg.speaker_pins[0];
  2691. if (pin) /* connect to front */
  2692. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2693. pin = spec->autocfg.hp_pins[0];
  2694. if (pin) /* connect to front */
  2695. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2696. }
  2697. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2698. {
  2699. struct alc_spec *spec = codec->spec;
  2700. int i;
  2701. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2702. hda_nid_t nid = spec->autocfg.input_pins[i];
  2703. if (alc880_is_input_pin(nid)) {
  2704. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2705. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2706. if (nid != ALC880_PIN_CD_NID)
  2707. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2708. AMP_OUT_MUTE);
  2709. }
  2710. }
  2711. }
  2712. /* parse the BIOS configuration and set up the alc_spec */
  2713. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  2714. static int alc880_parse_auto_config(struct hda_codec *codec)
  2715. {
  2716. struct alc_spec *spec = codec->spec;
  2717. int err;
  2718. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2719. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2720. alc880_ignore)) < 0)
  2721. return err;
  2722. if (! spec->autocfg.line_outs)
  2723. return 0; /* can't find valid BIOS pin config */
  2724. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  2725. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  2726. (err = alc880_auto_create_extra_out(spec,
  2727. spec->autocfg.speaker_pins[0],
  2728. "Speaker")) < 0 ||
  2729. (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2730. "Headphone")) < 0 ||
  2731. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2732. return err;
  2733. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2734. if (spec->autocfg.dig_out_pin)
  2735. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2736. if (spec->autocfg.dig_in_pin)
  2737. spec->dig_in_nid = ALC880_DIGIN_NID;
  2738. if (spec->kctl_alloc)
  2739. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2740. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2741. spec->num_mux_defs = 1;
  2742. spec->input_mux = &spec->private_imux;
  2743. return 1;
  2744. }
  2745. /* additional initialization for auto-configuration model */
  2746. static void alc880_auto_init(struct hda_codec *codec)
  2747. {
  2748. alc880_auto_init_multi_out(codec);
  2749. alc880_auto_init_extra_out(codec);
  2750. alc880_auto_init_analog_input(codec);
  2751. }
  2752. /*
  2753. * OK, here we have finally the patch for ALC880
  2754. */
  2755. static int patch_alc880(struct hda_codec *codec)
  2756. {
  2757. struct alc_spec *spec;
  2758. int board_config;
  2759. int err;
  2760. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2761. if (spec == NULL)
  2762. return -ENOMEM;
  2763. codec->spec = spec;
  2764. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  2765. if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
  2766. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2767. "trying auto-probe from BIOS...\n");
  2768. board_config = ALC880_AUTO;
  2769. }
  2770. if (board_config == ALC880_AUTO) {
  2771. /* automatic parse from the BIOS config */
  2772. err = alc880_parse_auto_config(codec);
  2773. if (err < 0) {
  2774. alc_free(codec);
  2775. return err;
  2776. } else if (! err) {
  2777. printk(KERN_INFO
  2778. "hda_codec: Cannot set up configuration "
  2779. "from BIOS. Using 3-stack mode...\n");
  2780. board_config = ALC880_3ST;
  2781. }
  2782. }
  2783. if (board_config != ALC880_AUTO)
  2784. setup_preset(spec, &alc880_presets[board_config]);
  2785. spec->stream_name_analog = "ALC880 Analog";
  2786. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2787. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2788. spec->stream_name_digital = "ALC880 Digital";
  2789. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2790. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2791. if (! spec->adc_nids && spec->input_mux) {
  2792. /* check whether NID 0x07 is valid */
  2793. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2794. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2795. if (wcap != AC_WID_AUD_IN) {
  2796. spec->adc_nids = alc880_adc_nids_alt;
  2797. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2798. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2799. spec->num_mixers++;
  2800. } else {
  2801. spec->adc_nids = alc880_adc_nids;
  2802. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2803. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2804. spec->num_mixers++;
  2805. }
  2806. }
  2807. codec->patch_ops = alc_patch_ops;
  2808. if (board_config == ALC880_AUTO)
  2809. spec->init_hook = alc880_auto_init;
  2810. return 0;
  2811. }
  2812. /*
  2813. * ALC260 support
  2814. */
  2815. static hda_nid_t alc260_dac_nids[1] = {
  2816. /* front */
  2817. 0x02,
  2818. };
  2819. static hda_nid_t alc260_adc_nids[1] = {
  2820. /* ADC0 */
  2821. 0x04,
  2822. };
  2823. static hda_nid_t alc260_adc_nids_alt[1] = {
  2824. /* ADC1 */
  2825. 0x05,
  2826. };
  2827. static hda_nid_t alc260_hp_adc_nids[2] = {
  2828. /* ADC1, 0 */
  2829. 0x05, 0x04
  2830. };
  2831. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2832. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2833. */
  2834. static hda_nid_t alc260_dual_adc_nids[2] = {
  2835. /* ADC0, ADC1 */
  2836. 0x04, 0x05
  2837. };
  2838. #define ALC260_DIGOUT_NID 0x03
  2839. #define ALC260_DIGIN_NID 0x06
  2840. static struct hda_input_mux alc260_capture_source = {
  2841. .num_items = 4,
  2842. .items = {
  2843. { "Mic", 0x0 },
  2844. { "Front Mic", 0x1 },
  2845. { "Line", 0x2 },
  2846. { "CD", 0x4 },
  2847. },
  2848. };
  2849. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2850. * headphone jack and the internal CD lines since these are the only pins at
  2851. * which audio can appear. For flexibility, also allow the option of
  2852. * recording the mixer output on the second ADC (ADC0 doesn't have a
  2853. * connection to the mixer output).
  2854. */
  2855. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  2856. {
  2857. .num_items = 3,
  2858. .items = {
  2859. { "Mic/Line", 0x0 },
  2860. { "CD", 0x4 },
  2861. { "Headphone", 0x2 },
  2862. },
  2863. },
  2864. {
  2865. .num_items = 4,
  2866. .items = {
  2867. { "Mic/Line", 0x0 },
  2868. { "CD", 0x4 },
  2869. { "Headphone", 0x2 },
  2870. { "Mixer", 0x5 },
  2871. },
  2872. },
  2873. };
  2874. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  2875. * the Fujitsu S702x, but jacks are marked differently.
  2876. */
  2877. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  2878. {
  2879. .num_items = 4,
  2880. .items = {
  2881. { "Mic", 0x0 },
  2882. { "Line", 0x2 },
  2883. { "CD", 0x4 },
  2884. { "Headphone", 0x5 },
  2885. },
  2886. },
  2887. {
  2888. .num_items = 5,
  2889. .items = {
  2890. { "Mic", 0x0 },
  2891. { "Line", 0x2 },
  2892. { "CD", 0x4 },
  2893. { "Headphone", 0x6 },
  2894. { "Mixer", 0x5 },
  2895. },
  2896. },
  2897. };
  2898. /*
  2899. * This is just place-holder, so there's something for alc_build_pcms to look
  2900. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2901. * element which allows changing the channel mode, so the verb list is
  2902. * never used.
  2903. */
  2904. static struct hda_channel_mode alc260_modes[1] = {
  2905. { 2, NULL },
  2906. };
  2907. /* Mixer combinations
  2908. *
  2909. * basic: base_output + input + pc_beep + capture
  2910. * HP: base_output + input + capture_alt
  2911. * HP_3013: hp_3013 + input + capture
  2912. * fujitsu: fujitsu + capture
  2913. * acer: acer + capture
  2914. */
  2915. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2916. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2917. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2918. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2919. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2920. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2921. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2922. { } /* end */
  2923. };
  2924. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2925. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2926. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2927. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2928. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2929. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2930. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2931. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2932. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2933. { } /* end */
  2934. };
  2935. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2936. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2937. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2938. { } /* end */
  2939. };
  2940. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2941. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2942. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2943. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2944. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2945. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2946. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2947. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2948. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2949. { } /* end */
  2950. };
  2951. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  2952. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  2953. */
  2954. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2955. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2956. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2957. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2958. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2959. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2960. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2961. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2962. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2963. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2964. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2965. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2966. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2967. { } /* end */
  2968. };
  2969. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  2970. * versions of the ALC260 don't act on requests to enable mic bias from NID
  2971. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  2972. * datasheet doesn't mention this restriction. At this stage it's not clear
  2973. * whether this behaviour is intentional or is a hardware bug in chip
  2974. * revisions available in early 2006. Therefore for now allow the
  2975. * "Headphone Jack Mode" control to span all choices, but if it turns out
  2976. * that the lack of mic bias for this NID is intentional we could change the
  2977. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2978. *
  2979. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  2980. * don't appear to make the mic bias available from the "line" jack, even
  2981. * though the NID used for this jack (0x14) can supply it. The theory is
  2982. * that perhaps Acer have included blocking capacitors between the ALC260
  2983. * and the output jack. If this turns out to be the case for all such
  2984. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  2985. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2986. */
  2987. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  2988. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2989. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  2990. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  2991. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2992. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2993. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2994. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2995. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2996. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2997. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2998. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2999. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3000. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3001. { } /* end */
  3002. };
  3003. /* capture mixer elements */
  3004. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3005. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3006. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3007. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3008. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3009. {
  3010. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3011. /* The multiple "Capture Source" controls confuse alsamixer
  3012. * So call somewhat different..
  3013. * FIXME: the controls appear in the "playback" view!
  3014. */
  3015. /* .name = "Capture Source", */
  3016. .name = "Input Source",
  3017. .count = 2,
  3018. .info = alc_mux_enum_info,
  3019. .get = alc_mux_enum_get,
  3020. .put = alc_mux_enum_put,
  3021. },
  3022. { } /* end */
  3023. };
  3024. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3025. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3026. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3027. {
  3028. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3029. /* The multiple "Capture Source" controls confuse alsamixer
  3030. * So call somewhat different..
  3031. * FIXME: the controls appear in the "playback" view!
  3032. */
  3033. /* .name = "Capture Source", */
  3034. .name = "Input Source",
  3035. .count = 1,
  3036. .info = alc_mux_enum_info,
  3037. .get = alc_mux_enum_get,
  3038. .put = alc_mux_enum_put,
  3039. },
  3040. { } /* end */
  3041. };
  3042. /*
  3043. * initialization verbs
  3044. */
  3045. static struct hda_verb alc260_init_verbs[] = {
  3046. /* Line In pin widget for input */
  3047. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3048. /* CD pin widget for input */
  3049. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3050. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3051. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3052. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3053. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3054. /* LINE-2 is used for line-out in rear */
  3055. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3056. /* select line-out */
  3057. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3058. /* LINE-OUT pin */
  3059. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3060. /* enable HP */
  3061. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3062. /* enable Mono */
  3063. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3064. /* mute capture amp left and right */
  3065. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3066. /* set connection select to line in (default select for this ADC) */
  3067. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3068. /* mute capture amp left and right */
  3069. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3070. /* set connection select to line in (default select for this ADC) */
  3071. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3072. /* set vol=0 Line-Out mixer amp left and right */
  3073. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3074. /* unmute pin widget amp left and right (no gain on this amp) */
  3075. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3076. /* set vol=0 HP mixer amp left and right */
  3077. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3078. /* unmute pin widget amp left and right (no gain on this amp) */
  3079. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3080. /* set vol=0 Mono mixer amp left and right */
  3081. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3082. /* unmute pin widget amp left and right (no gain on this amp) */
  3083. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3084. /* unmute LINE-2 out pin */
  3085. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3086. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3087. /* mute CD */
  3088. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3089. /* mute Line In */
  3090. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3091. /* mute Mic */
  3092. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3093. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3094. /* mute Front out path */
  3095. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3096. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3097. /* mute Headphone out path */
  3098. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3099. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3100. /* mute Mono out path */
  3101. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3102. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3103. { }
  3104. };
  3105. #if 0 /* should be identical with alc260_init_verbs? */
  3106. static struct hda_verb alc260_hp_init_verbs[] = {
  3107. /* Headphone and output */
  3108. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3109. /* mono output */
  3110. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3111. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3112. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3113. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3114. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3115. /* Line In pin widget for input */
  3116. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3117. /* Line-2 pin widget for output */
  3118. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3119. /* CD pin widget for input */
  3120. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3121. /* unmute amp left and right */
  3122. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3123. /* set connection select to line in (default select for this ADC) */
  3124. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3125. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3126. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3127. /* mute pin widget amp left and right (no gain on this amp) */
  3128. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3129. /* unmute HP mixer amp left and right (volume = 0) */
  3130. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3131. /* mute pin widget amp left and right (no gain on this amp) */
  3132. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3133. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3134. /* unmute CD */
  3135. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3136. /* unmute Line In */
  3137. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3138. /* unmute Mic */
  3139. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3140. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3141. /* Unmute Front out path */
  3142. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3143. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3144. /* Unmute Headphone out path */
  3145. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3146. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3147. /* Unmute Mono out path */
  3148. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3149. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3150. { }
  3151. };
  3152. #endif
  3153. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3154. /* Line out and output */
  3155. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3156. /* mono output */
  3157. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3158. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3159. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3160. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3161. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3162. /* Line In pin widget for input */
  3163. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3164. /* Headphone pin widget for output */
  3165. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3166. /* CD pin widget for input */
  3167. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3168. /* unmute amp left and right */
  3169. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3170. /* set connection select to line in (default select for this ADC) */
  3171. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3172. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3173. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3174. /* mute pin widget amp left and right (no gain on this amp) */
  3175. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3176. /* unmute HP mixer amp left and right (volume = 0) */
  3177. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3178. /* mute pin widget amp left and right (no gain on this amp) */
  3179. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3180. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3181. /* unmute CD */
  3182. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3183. /* unmute Line In */
  3184. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3185. /* unmute Mic */
  3186. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3187. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3188. /* Unmute Front out path */
  3189. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3190. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3191. /* Unmute Headphone out path */
  3192. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3193. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3194. /* Unmute Mono out path */
  3195. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3196. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3197. { }
  3198. };
  3199. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3200. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3201. * audio = 0x16, internal speaker = 0x10.
  3202. */
  3203. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3204. /* Disable all GPIOs */
  3205. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3206. /* Internal speaker is connected to headphone pin */
  3207. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3208. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3209. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3210. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3211. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3212. /* Ensure all other unused pins are disabled and muted. */
  3213. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3214. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3215. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3216. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3217. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3218. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3219. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3220. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3221. /* Disable digital (SPDIF) pins */
  3222. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3223. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3224. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3225. * when acting as an output.
  3226. */
  3227. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3228. /* Start with output sum widgets muted and their output gains at min */
  3229. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3230. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3231. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3232. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3233. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3234. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3235. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3236. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3237. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3238. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3239. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3240. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3241. * If the pin mode is changed by the user the pin mode control will
  3242. * take care of enabling the pin's input/output buffers as needed.
  3243. * Therefore there's no need to enable the input buffer at this
  3244. * stage.
  3245. */
  3246. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3247. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3248. * mixer ctrl)
  3249. */
  3250. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3251. /* Mute capture amp left and right */
  3252. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3253. /* Set ADC connection select to match default mixer setting - line
  3254. * in (on mic1 pin)
  3255. */
  3256. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3257. /* Do the same for the second ADC: mute capture input amp and
  3258. * set ADC connection to line in (on mic1 pin)
  3259. */
  3260. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3261. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3262. /* Mute all inputs to mixer widget (even unconnected ones) */
  3263. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3264. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3265. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3266. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3267. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3268. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3269. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3270. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3271. { }
  3272. };
  3273. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3274. * similar laptops (adapted from Fujitsu init verbs).
  3275. */
  3276. static struct hda_verb alc260_acer_init_verbs[] = {
  3277. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3278. * the headphone jack. Turn this on and rely on the standard mute
  3279. * methods whenever the user wants to turn these outputs off.
  3280. */
  3281. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3282. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3283. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3284. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3285. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3286. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3287. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3288. /* Line In jack is connected to Line1 pin */
  3289. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3290. /* Ensure all other unused pins are disabled and muted. */
  3291. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3292. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3293. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3294. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3295. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3296. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3297. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3298. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3299. /* Disable digital (SPDIF) pins */
  3300. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3301. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3302. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3303. * bus when acting as outputs.
  3304. */
  3305. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3306. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3307. /* Start with output sum widgets muted and their output gains at min */
  3308. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3309. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3310. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3311. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3312. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3313. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3314. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3315. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3316. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3317. /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
  3318. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3319. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3320. * inputs. If the pin mode is changed by the user the pin mode control
  3321. * will take care of enabling the pin's input/output buffers as needed.
  3322. * Therefore there's no need to enable the input buffer at this
  3323. * stage.
  3324. */
  3325. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3326. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3327. /* Mute capture amp left and right */
  3328. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3329. /* Set ADC connection select to match default mixer setting - mic
  3330. * (on mic1 pin)
  3331. */
  3332. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3333. /* Do similar with the second ADC: mute capture input amp and
  3334. * set ADC connection to mic to match ALSA's default state.
  3335. */
  3336. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3337. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3338. /* Mute all inputs to mixer widget (even unconnected ones) */
  3339. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3340. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3341. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3342. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3343. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3344. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3345. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3346. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3347. { }
  3348. };
  3349. /* Test configuration for debugging, modelled after the ALC880 test
  3350. * configuration.
  3351. */
  3352. #ifdef CONFIG_SND_DEBUG
  3353. static hda_nid_t alc260_test_dac_nids[1] = {
  3354. 0x02,
  3355. };
  3356. static hda_nid_t alc260_test_adc_nids[2] = {
  3357. 0x04, 0x05,
  3358. };
  3359. /* For testing the ALC260, each input MUX needs its own definition since
  3360. * the signal assignments are different. This assumes that the first ADC
  3361. * is NID 0x04.
  3362. */
  3363. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3364. {
  3365. .num_items = 7,
  3366. .items = {
  3367. { "MIC1 pin", 0x0 },
  3368. { "MIC2 pin", 0x1 },
  3369. { "LINE1 pin", 0x2 },
  3370. { "LINE2 pin", 0x3 },
  3371. { "CD pin", 0x4 },
  3372. { "LINE-OUT pin", 0x5 },
  3373. { "HP-OUT pin", 0x6 },
  3374. },
  3375. },
  3376. {
  3377. .num_items = 8,
  3378. .items = {
  3379. { "MIC1 pin", 0x0 },
  3380. { "MIC2 pin", 0x1 },
  3381. { "LINE1 pin", 0x2 },
  3382. { "LINE2 pin", 0x3 },
  3383. { "CD pin", 0x4 },
  3384. { "Mixer", 0x5 },
  3385. { "LINE-OUT pin", 0x6 },
  3386. { "HP-OUT pin", 0x7 },
  3387. },
  3388. },
  3389. };
  3390. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3391. /* Output driver widgets */
  3392. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3393. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3394. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3395. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3396. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3397. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3398. /* Modes for retasking pin widgets
  3399. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3400. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3401. * mention this restriction. At this stage it's not clear whether
  3402. * this behaviour is intentional or is a hardware bug in chip
  3403. * revisions available at least up until early 2006. Therefore for
  3404. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3405. * choices, but if it turns out that the lack of mic bias for these
  3406. * NIDs is intentional we could change their modes from
  3407. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3408. */
  3409. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3410. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3411. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3412. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3413. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3414. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3415. /* Loopback mixer controls */
  3416. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3417. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3418. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3419. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3420. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3421. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3422. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3423. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3424. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3425. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3426. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3427. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3428. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3429. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3430. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3431. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3432. /* Controls for GPIO pins, assuming they are configured as outputs */
  3433. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3434. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3435. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3436. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3437. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3438. * is ambigious as to which NID is which; testing on laptops which
  3439. * make this output available should provide clarification.
  3440. */
  3441. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3442. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3443. { } /* end */
  3444. };
  3445. static struct hda_verb alc260_test_init_verbs[] = {
  3446. /* Enable all GPIOs as outputs with an initial value of 0 */
  3447. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3448. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3449. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3450. /* Enable retasking pins as output, initially without power amp */
  3451. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3452. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3453. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3454. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3455. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3456. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3457. /* Disable digital (SPDIF) pins initially, but users can enable
  3458. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3459. * payload also sets the generation to 0, output to be in "consumer"
  3460. * PCM format, copyright asserted, no pre-emphasis and no validity
  3461. * control.
  3462. */
  3463. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3464. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3465. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3466. * OUT1 sum bus when acting as an output.
  3467. */
  3468. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3469. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3470. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3471. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3472. /* Start with output sum widgets muted and their output gains at min */
  3473. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3474. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3475. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3476. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3477. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3478. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3479. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3480. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3481. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3482. /* Unmute retasking pin widget output buffers since the default
  3483. * state appears to be output. As the pin mode is changed by the
  3484. * user the pin mode control will take care of enabling the pin's
  3485. * input/output buffers as needed.
  3486. */
  3487. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3488. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3489. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3490. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3491. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3492. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3493. /* Also unmute the mono-out pin widget */
  3494. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3495. /* Mute capture amp left and right */
  3496. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3497. /* Set ADC connection select to match default mixer setting (mic1
  3498. * pin)
  3499. */
  3500. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3501. /* Do the same for the second ADC: mute capture input amp and
  3502. * set ADC connection to mic1 pin
  3503. */
  3504. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3505. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3506. /* Mute all inputs to mixer widget (even unconnected ones) */
  3507. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3508. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3509. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3510. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3511. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3512. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3513. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3514. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3515. { }
  3516. };
  3517. #endif
  3518. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3519. .substreams = 1,
  3520. .channels_min = 2,
  3521. .channels_max = 2,
  3522. };
  3523. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3524. .substreams = 1,
  3525. .channels_min = 2,
  3526. .channels_max = 2,
  3527. };
  3528. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3529. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3530. /*
  3531. * for BIOS auto-configuration
  3532. */
  3533. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3534. const char *pfx)
  3535. {
  3536. hda_nid_t nid_vol;
  3537. unsigned long vol_val, sw_val;
  3538. char name[32];
  3539. int err;
  3540. if (nid >= 0x0f && nid < 0x11) {
  3541. nid_vol = nid - 0x7;
  3542. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3543. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3544. } else if (nid == 0x11) {
  3545. nid_vol = nid - 0x7;
  3546. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3547. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3548. } else if (nid >= 0x12 && nid <= 0x15) {
  3549. nid_vol = 0x08;
  3550. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3551. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3552. } else
  3553. return 0; /* N/A */
  3554. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3555. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  3556. return err;
  3557. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3558. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  3559. return err;
  3560. return 1;
  3561. }
  3562. /* add playback controls from the parsed DAC table */
  3563. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3564. const struct auto_pin_cfg *cfg)
  3565. {
  3566. hda_nid_t nid;
  3567. int err;
  3568. spec->multiout.num_dacs = 1;
  3569. spec->multiout.dac_nids = spec->private_dac_nids;
  3570. spec->multiout.dac_nids[0] = 0x02;
  3571. nid = cfg->line_out_pins[0];
  3572. if (nid) {
  3573. err = alc260_add_playback_controls(spec, nid, "Front");
  3574. if (err < 0)
  3575. return err;
  3576. }
  3577. nid = cfg->speaker_pins[0];
  3578. if (nid) {
  3579. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3580. if (err < 0)
  3581. return err;
  3582. }
  3583. nid = cfg->hp_pins[0];
  3584. if (nid) {
  3585. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3586. if (err < 0)
  3587. return err;
  3588. }
  3589. return 0;
  3590. }
  3591. /* create playback/capture controls for input pins */
  3592. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3593. const struct auto_pin_cfg *cfg)
  3594. {
  3595. struct hda_input_mux *imux = &spec->private_imux;
  3596. int i, err, idx;
  3597. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3598. if (cfg->input_pins[i] >= 0x12) {
  3599. idx = cfg->input_pins[i] - 0x12;
  3600. err = new_analog_input(spec, cfg->input_pins[i],
  3601. auto_pin_cfg_labels[i], idx, 0x07);
  3602. if (err < 0)
  3603. return err;
  3604. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3605. imux->items[imux->num_items].index = idx;
  3606. imux->num_items++;
  3607. }
  3608. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  3609. idx = cfg->input_pins[i] - 0x09;
  3610. err = new_analog_input(spec, cfg->input_pins[i],
  3611. auto_pin_cfg_labels[i], idx, 0x07);
  3612. if (err < 0)
  3613. return err;
  3614. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3615. imux->items[imux->num_items].index = idx;
  3616. imux->num_items++;
  3617. }
  3618. }
  3619. return 0;
  3620. }
  3621. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3622. hda_nid_t nid, int pin_type,
  3623. int sel_idx)
  3624. {
  3625. /* set as output */
  3626. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3627. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3628. /* need the manual connection? */
  3629. if (nid >= 0x12) {
  3630. int idx = nid - 0x12;
  3631. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3632. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3633. }
  3634. }
  3635. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3636. {
  3637. struct alc_spec *spec = codec->spec;
  3638. hda_nid_t nid;
  3639. nid = spec->autocfg.line_out_pins[0];
  3640. if (nid)
  3641. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3642. nid = spec->autocfg.speaker_pins[0];
  3643. if (nid)
  3644. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3645. nid = spec->autocfg.hp_pins[0];
  3646. if (nid)
  3647. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3648. }
  3649. #define ALC260_PIN_CD_NID 0x16
  3650. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3651. {
  3652. struct alc_spec *spec = codec->spec;
  3653. int i;
  3654. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3655. hda_nid_t nid = spec->autocfg.input_pins[i];
  3656. if (nid >= 0x12) {
  3657. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3658. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3659. if (nid != ALC260_PIN_CD_NID)
  3660. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3661. AMP_OUT_MUTE);
  3662. }
  3663. }
  3664. }
  3665. /*
  3666. * generic initialization of ADC, input mixers and output mixers
  3667. */
  3668. static struct hda_verb alc260_volume_init_verbs[] = {
  3669. /*
  3670. * Unmute ADC0-1 and set the default input to mic-in
  3671. */
  3672. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3673. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3674. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3675. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3676. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3677. * mixer widget
  3678. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3679. * mic (mic 2)
  3680. */
  3681. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3682. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3683. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3684. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3685. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3686. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3687. /*
  3688. * Set up output mixers (0x08 - 0x0a)
  3689. */
  3690. /* set vol=0 to output mixers */
  3691. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3692. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3693. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3694. /* set up input amps for analog loopback */
  3695. /* Amp Indices: DAC = 0, mixer = 1 */
  3696. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3697. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3698. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3699. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3700. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3701. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3702. { }
  3703. };
  3704. static int alc260_parse_auto_config(struct hda_codec *codec)
  3705. {
  3706. struct alc_spec *spec = codec->spec;
  3707. unsigned int wcap;
  3708. int err;
  3709. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3710. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3711. alc260_ignore)) < 0)
  3712. return err;
  3713. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  3714. return err;
  3715. if (! spec->kctl_alloc)
  3716. return 0; /* can't find valid BIOS pin config */
  3717. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3718. return err;
  3719. spec->multiout.max_channels = 2;
  3720. if (spec->autocfg.dig_out_pin)
  3721. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3722. if (spec->kctl_alloc)
  3723. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3724. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3725. spec->num_mux_defs = 1;
  3726. spec->input_mux = &spec->private_imux;
  3727. /* check whether NID 0x04 is valid */
  3728. wcap = get_wcaps(codec, 0x04);
  3729. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3730. if (wcap != AC_WID_AUD_IN) {
  3731. spec->adc_nids = alc260_adc_nids_alt;
  3732. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  3733. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  3734. } else {
  3735. spec->adc_nids = alc260_adc_nids;
  3736. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  3737. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  3738. }
  3739. spec->num_mixers++;
  3740. return 1;
  3741. }
  3742. /* additional initialization for auto-configuration model */
  3743. static void alc260_auto_init(struct hda_codec *codec)
  3744. {
  3745. alc260_auto_init_multi_out(codec);
  3746. alc260_auto_init_analog_input(codec);
  3747. }
  3748. /*
  3749. * ALC260 configurations
  3750. */
  3751. static struct hda_board_config alc260_cfg_tbl[] = {
  3752. { .modelname = "basic", .config = ALC260_BASIC },
  3753. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
  3754. .config = ALC260_BASIC }, /* Sony VAIO */
  3755. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cc,
  3756. .config = ALC260_BASIC }, /* Sony VAIO VGN-S3HP */
  3757. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81cd,
  3758. .config = ALC260_BASIC }, /* Sony VAIO */
  3759. { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
  3760. .config = ALC260_BASIC }, /* CTL Travel Master U553W */
  3761. { .modelname = "hp", .config = ALC260_HP },
  3762. { .modelname = "hp-3013", .config = ALC260_HP_3013 },
  3763. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP_3013 },
  3764. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
  3765. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP_3013 },
  3766. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
  3767. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
  3768. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
  3769. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
  3770. { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
  3771. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
  3772. { .modelname = "acer", .config = ALC260_ACER },
  3773. { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
  3774. #ifdef CONFIG_SND_DEBUG
  3775. { .modelname = "test", .config = ALC260_TEST },
  3776. #endif
  3777. { .modelname = "auto", .config = ALC260_AUTO },
  3778. {}
  3779. };
  3780. static struct alc_config_preset alc260_presets[] = {
  3781. [ALC260_BASIC] = {
  3782. .mixers = { alc260_base_output_mixer,
  3783. alc260_input_mixer,
  3784. alc260_pc_beep_mixer,
  3785. alc260_capture_mixer },
  3786. .init_verbs = { alc260_init_verbs },
  3787. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3788. .dac_nids = alc260_dac_nids,
  3789. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  3790. .adc_nids = alc260_adc_nids,
  3791. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3792. .channel_mode = alc260_modes,
  3793. .input_mux = &alc260_capture_source,
  3794. },
  3795. [ALC260_HP] = {
  3796. .mixers = { alc260_base_output_mixer,
  3797. alc260_input_mixer,
  3798. alc260_capture_alt_mixer },
  3799. .init_verbs = { alc260_init_verbs },
  3800. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3801. .dac_nids = alc260_dac_nids,
  3802. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3803. .adc_nids = alc260_hp_adc_nids,
  3804. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3805. .channel_mode = alc260_modes,
  3806. .input_mux = &alc260_capture_source,
  3807. },
  3808. [ALC260_HP_3013] = {
  3809. .mixers = { alc260_hp_3013_mixer,
  3810. alc260_input_mixer,
  3811. alc260_capture_alt_mixer },
  3812. .init_verbs = { alc260_hp_3013_init_verbs },
  3813. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3814. .dac_nids = alc260_dac_nids,
  3815. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3816. .adc_nids = alc260_hp_adc_nids,
  3817. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3818. .channel_mode = alc260_modes,
  3819. .input_mux = &alc260_capture_source,
  3820. },
  3821. [ALC260_FUJITSU_S702X] = {
  3822. .mixers = { alc260_fujitsu_mixer,
  3823. alc260_capture_mixer },
  3824. .init_verbs = { alc260_fujitsu_init_verbs },
  3825. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3826. .dac_nids = alc260_dac_nids,
  3827. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3828. .adc_nids = alc260_dual_adc_nids,
  3829. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3830. .channel_mode = alc260_modes,
  3831. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  3832. .input_mux = alc260_fujitsu_capture_sources,
  3833. },
  3834. [ALC260_ACER] = {
  3835. .mixers = { alc260_acer_mixer,
  3836. alc260_capture_mixer },
  3837. .init_verbs = { alc260_acer_init_verbs },
  3838. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3839. .dac_nids = alc260_dac_nids,
  3840. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3841. .adc_nids = alc260_dual_adc_nids,
  3842. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3843. .channel_mode = alc260_modes,
  3844. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  3845. .input_mux = alc260_acer_capture_sources,
  3846. },
  3847. #ifdef CONFIG_SND_DEBUG
  3848. [ALC260_TEST] = {
  3849. .mixers = { alc260_test_mixer,
  3850. alc260_capture_mixer },
  3851. .init_verbs = { alc260_test_init_verbs },
  3852. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  3853. .dac_nids = alc260_test_dac_nids,
  3854. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  3855. .adc_nids = alc260_test_adc_nids,
  3856. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3857. .channel_mode = alc260_modes,
  3858. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  3859. .input_mux = alc260_test_capture_sources,
  3860. },
  3861. #endif
  3862. };
  3863. static int patch_alc260(struct hda_codec *codec)
  3864. {
  3865. struct alc_spec *spec;
  3866. int err, board_config;
  3867. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3868. if (spec == NULL)
  3869. return -ENOMEM;
  3870. codec->spec = spec;
  3871. board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
  3872. if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
  3873. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  3874. "trying auto-probe from BIOS...\n");
  3875. board_config = ALC260_AUTO;
  3876. }
  3877. if (board_config == ALC260_AUTO) {
  3878. /* automatic parse from the BIOS config */
  3879. err = alc260_parse_auto_config(codec);
  3880. if (err < 0) {
  3881. alc_free(codec);
  3882. return err;
  3883. } else if (! err) {
  3884. printk(KERN_INFO
  3885. "hda_codec: Cannot set up configuration "
  3886. "from BIOS. Using base mode...\n");
  3887. board_config = ALC260_BASIC;
  3888. }
  3889. }
  3890. if (board_config != ALC260_AUTO)
  3891. setup_preset(spec, &alc260_presets[board_config]);
  3892. spec->stream_name_analog = "ALC260 Analog";
  3893. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  3894. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  3895. spec->stream_name_digital = "ALC260 Digital";
  3896. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  3897. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  3898. codec->patch_ops = alc_patch_ops;
  3899. if (board_config == ALC260_AUTO)
  3900. spec->init_hook = alc260_auto_init;
  3901. return 0;
  3902. }
  3903. /*
  3904. * ALC882 support
  3905. *
  3906. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  3907. * configuration. Each pin widget can choose any input DACs and a mixer.
  3908. * Each ADC is connected from a mixer of all inputs. This makes possible
  3909. * 6-channel independent captures.
  3910. *
  3911. * In addition, an independent DAC for the multi-playback (not used in this
  3912. * driver yet).
  3913. */
  3914. #define ALC882_DIGOUT_NID 0x06
  3915. #define ALC882_DIGIN_NID 0x0a
  3916. static struct hda_channel_mode alc882_ch_modes[1] = {
  3917. { 8, NULL }
  3918. };
  3919. static hda_nid_t alc882_dac_nids[4] = {
  3920. /* front, rear, clfe, rear_surr */
  3921. 0x02, 0x03, 0x04, 0x05
  3922. };
  3923. /* identical with ALC880 */
  3924. #define alc882_adc_nids alc880_adc_nids
  3925. #define alc882_adc_nids_alt alc880_adc_nids_alt
  3926. /* input MUX */
  3927. /* FIXME: should be a matrix-type input source selection */
  3928. static struct hda_input_mux alc882_capture_source = {
  3929. .num_items = 4,
  3930. .items = {
  3931. { "Mic", 0x0 },
  3932. { "Front Mic", 0x1 },
  3933. { "Line", 0x2 },
  3934. { "CD", 0x4 },
  3935. },
  3936. };
  3937. #define alc882_mux_enum_info alc_mux_enum_info
  3938. #define alc882_mux_enum_get alc_mux_enum_get
  3939. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  3940. {
  3941. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  3942. struct alc_spec *spec = codec->spec;
  3943. const struct hda_input_mux *imux = spec->input_mux;
  3944. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  3945. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  3946. hda_nid_t nid = capture_mixers[adc_idx];
  3947. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  3948. unsigned int i, idx;
  3949. idx = ucontrol->value.enumerated.item[0];
  3950. if (idx >= imux->num_items)
  3951. idx = imux->num_items - 1;
  3952. if (*cur_val == idx && ! codec->in_resume)
  3953. return 0;
  3954. for (i = 0; i < imux->num_items; i++) {
  3955. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  3956. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3957. v | (imux->items[i].index << 8));
  3958. }
  3959. *cur_val = idx;
  3960. return 1;
  3961. }
  3962. /*
  3963. * 6ch mode
  3964. */
  3965. static struct hda_verb alc882_sixstack_ch6_init[] = {
  3966. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3967. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3968. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3969. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3970. { } /* end */
  3971. };
  3972. /*
  3973. * 8ch mode
  3974. */
  3975. static struct hda_verb alc882_sixstack_ch8_init[] = {
  3976. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3977. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3978. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3979. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3980. { } /* end */
  3981. };
  3982. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  3983. { 6, alc882_sixstack_ch6_init },
  3984. { 8, alc882_sixstack_ch8_init },
  3985. };
  3986. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  3987. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  3988. */
  3989. static struct snd_kcontrol_new alc882_base_mixer[] = {
  3990. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3991. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  3992. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  3993. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  3994. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  3995. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3996. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  3997. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  3998. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  3999. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4000. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4001. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4002. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4003. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4004. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4005. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4006. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4007. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4008. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4009. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4010. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4011. { } /* end */
  4012. };
  4013. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4014. {
  4015. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4016. .name = "Channel Mode",
  4017. .info = alc_ch_mode_info,
  4018. .get = alc_ch_mode_get,
  4019. .put = alc_ch_mode_put,
  4020. },
  4021. { } /* end */
  4022. };
  4023. static struct hda_verb alc882_init_verbs[] = {
  4024. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4025. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4026. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4027. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4028. /* Rear mixer */
  4029. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4030. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4031. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4032. /* CLFE mixer */
  4033. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4034. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4035. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4036. /* Side mixer */
  4037. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4038. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4039. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4040. /* Front Pin: output 0 (0x0c) */
  4041. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4042. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4043. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4044. /* Rear Pin: output 1 (0x0d) */
  4045. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4046. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4047. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4048. /* CLFE Pin: output 2 (0x0e) */
  4049. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4050. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4051. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4052. /* Side Pin: output 3 (0x0f) */
  4053. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4054. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4055. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4056. /* Mic (rear) pin: input vref at 80% */
  4057. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4058. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4059. /* Front Mic pin: input vref at 80% */
  4060. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4061. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4062. /* Line In pin: input */
  4063. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4064. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4065. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4066. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4067. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4068. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4069. /* CD pin widget for input */
  4070. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4071. /* FIXME: use matrix-type input source selection */
  4072. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4073. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4074. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4075. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4076. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4077. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4078. /* Input mixer2 */
  4079. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4080. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4081. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4082. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4083. /* Input mixer3 */
  4084. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4085. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4086. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4087. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4088. /* ADC1: mute amp left and right */
  4089. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4090. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4091. /* ADC2: mute amp left and right */
  4092. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4093. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4094. /* ADC3: mute amp left and right */
  4095. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4096. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4097. { }
  4098. };
  4099. static struct hda_verb alc882_eapd_verbs[] = {
  4100. /* change to EAPD mode */
  4101. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4102. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  4103. { }
  4104. };
  4105. /*
  4106. * generic initialization of ADC, input mixers and output mixers
  4107. */
  4108. static struct hda_verb alc882_auto_init_verbs[] = {
  4109. /*
  4110. * Unmute ADC0-2 and set the default input to mic-in
  4111. */
  4112. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4113. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4114. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4115. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4116. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4117. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4118. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4119. * mixer widget
  4120. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4121. * mic (mic 2)
  4122. */
  4123. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4124. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4125. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4126. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4127. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4128. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4129. /*
  4130. * Set up output mixers (0x0c - 0x0f)
  4131. */
  4132. /* set vol=0 to output mixers */
  4133. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4134. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4135. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4136. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4137. /* set up input amps for analog loopback */
  4138. /* Amp Indices: DAC = 0, mixer = 1 */
  4139. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4140. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4141. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4142. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4143. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4144. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4145. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4146. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4147. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4148. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4149. /* FIXME: use matrix-type input source selection */
  4150. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4151. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4152. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4153. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4154. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4155. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4156. /* Input mixer2 */
  4157. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4158. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4159. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4160. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4161. /* Input mixer3 */
  4162. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4163. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4164. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4165. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4166. { }
  4167. };
  4168. /* capture mixer elements */
  4169. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4170. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4171. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4172. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4173. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4174. {
  4175. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4176. /* The multiple "Capture Source" controls confuse alsamixer
  4177. * So call somewhat different..
  4178. * FIXME: the controls appear in the "playback" view!
  4179. */
  4180. /* .name = "Capture Source", */
  4181. .name = "Input Source",
  4182. .count = 2,
  4183. .info = alc882_mux_enum_info,
  4184. .get = alc882_mux_enum_get,
  4185. .put = alc882_mux_enum_put,
  4186. },
  4187. { } /* end */
  4188. };
  4189. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4190. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4191. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4192. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4193. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4194. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4195. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4196. {
  4197. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4198. /* The multiple "Capture Source" controls confuse alsamixer
  4199. * So call somewhat different..
  4200. * FIXME: the controls appear in the "playback" view!
  4201. */
  4202. /* .name = "Capture Source", */
  4203. .name = "Input Source",
  4204. .count = 3,
  4205. .info = alc882_mux_enum_info,
  4206. .get = alc882_mux_enum_get,
  4207. .put = alc882_mux_enum_put,
  4208. },
  4209. { } /* end */
  4210. };
  4211. /* pcm configuration: identiacal with ALC880 */
  4212. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4213. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4214. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4215. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4216. /*
  4217. * configuration and preset
  4218. */
  4219. static struct hda_board_config alc882_cfg_tbl[] = {
  4220. { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
  4221. { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
  4222. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
  4223. .config = ALC882_6ST_DIG }, /* MSI */
  4224. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
  4225. .config = ALC882_6ST_DIG }, /* Foxconn */
  4226. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
  4227. .config = ALC882_6ST_DIG }, /* ECS to Intel*/
  4228. { .modelname = "arima", .config = ALC882_ARIMA },
  4229. { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
  4230. .config = ALC882_ARIMA }, /* Arima W820Di1 */
  4231. { .modelname = "auto", .config = ALC882_AUTO },
  4232. {}
  4233. };
  4234. static struct alc_config_preset alc882_presets[] = {
  4235. [ALC882_3ST_DIG] = {
  4236. .mixers = { alc882_base_mixer },
  4237. .init_verbs = { alc882_init_verbs },
  4238. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4239. .dac_nids = alc882_dac_nids,
  4240. .dig_out_nid = ALC882_DIGOUT_NID,
  4241. .dig_in_nid = ALC882_DIGIN_NID,
  4242. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4243. .channel_mode = alc882_ch_modes,
  4244. .need_dac_fix = 1,
  4245. .input_mux = &alc882_capture_source,
  4246. },
  4247. [ALC882_6ST_DIG] = {
  4248. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4249. .init_verbs = { alc882_init_verbs },
  4250. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4251. .dac_nids = alc882_dac_nids,
  4252. .dig_out_nid = ALC882_DIGOUT_NID,
  4253. .dig_in_nid = ALC882_DIGIN_NID,
  4254. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4255. .channel_mode = alc882_sixstack_modes,
  4256. .input_mux = &alc882_capture_source,
  4257. },
  4258. [ALC882_ARIMA] = {
  4259. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4260. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4261. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4262. .dac_nids = alc882_dac_nids,
  4263. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4264. .channel_mode = alc882_sixstack_modes,
  4265. .input_mux = &alc882_capture_source,
  4266. },
  4267. };
  4268. /*
  4269. * BIOS auto configuration
  4270. */
  4271. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4272. hda_nid_t nid, int pin_type,
  4273. int dac_idx)
  4274. {
  4275. /* set as output */
  4276. struct alc_spec *spec = codec->spec;
  4277. int idx;
  4278. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4279. idx = 4;
  4280. else
  4281. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4282. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4283. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4284. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4285. }
  4286. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4287. {
  4288. struct alc_spec *spec = codec->spec;
  4289. int i;
  4290. for (i = 0; i <= HDA_SIDE; i++) {
  4291. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4292. if (nid)
  4293. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  4294. }
  4295. }
  4296. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4297. {
  4298. struct alc_spec *spec = codec->spec;
  4299. hda_nid_t pin;
  4300. pin = spec->autocfg.hp_pins[0];
  4301. if (pin) /* connect to front */
  4302. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  4303. }
  4304. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4305. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4306. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4307. {
  4308. struct alc_spec *spec = codec->spec;
  4309. int i;
  4310. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4311. hda_nid_t nid = spec->autocfg.input_pins[i];
  4312. if (alc882_is_input_pin(nid)) {
  4313. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4314. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4315. if (nid != ALC882_PIN_CD_NID)
  4316. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4317. AMP_OUT_MUTE);
  4318. }
  4319. }
  4320. }
  4321. /* almost identical with ALC880 parser... */
  4322. static int alc882_parse_auto_config(struct hda_codec *codec)
  4323. {
  4324. struct alc_spec *spec = codec->spec;
  4325. int err = alc880_parse_auto_config(codec);
  4326. if (err < 0)
  4327. return err;
  4328. else if (err > 0)
  4329. /* hack - override the init verbs */
  4330. spec->init_verbs[0] = alc882_auto_init_verbs;
  4331. return err;
  4332. }
  4333. /* additional initialization for auto-configuration model */
  4334. static void alc882_auto_init(struct hda_codec *codec)
  4335. {
  4336. alc882_auto_init_multi_out(codec);
  4337. alc882_auto_init_hp_out(codec);
  4338. alc882_auto_init_analog_input(codec);
  4339. }
  4340. static int patch_alc882(struct hda_codec *codec)
  4341. {
  4342. struct alc_spec *spec;
  4343. int err, board_config;
  4344. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4345. if (spec == NULL)
  4346. return -ENOMEM;
  4347. codec->spec = spec;
  4348. board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
  4349. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4350. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4351. "trying auto-probe from BIOS...\n");
  4352. board_config = ALC882_AUTO;
  4353. }
  4354. if (board_config == ALC882_AUTO) {
  4355. /* automatic parse from the BIOS config */
  4356. err = alc882_parse_auto_config(codec);
  4357. if (err < 0) {
  4358. alc_free(codec);
  4359. return err;
  4360. } else if (! err) {
  4361. printk(KERN_INFO
  4362. "hda_codec: Cannot set up configuration "
  4363. "from BIOS. Using base mode...\n");
  4364. board_config = ALC882_3ST_DIG;
  4365. }
  4366. }
  4367. if (board_config != ALC882_AUTO)
  4368. setup_preset(spec, &alc882_presets[board_config]);
  4369. spec->stream_name_analog = "ALC882 Analog";
  4370. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  4371. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  4372. spec->stream_name_digital = "ALC882 Digital";
  4373. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  4374. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  4375. if (! spec->adc_nids && spec->input_mux) {
  4376. /* check whether NID 0x07 is valid */
  4377. unsigned int wcap = get_wcaps(codec, 0x07);
  4378. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4379. if (wcap != AC_WID_AUD_IN) {
  4380. spec->adc_nids = alc882_adc_nids_alt;
  4381. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  4382. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  4383. spec->num_mixers++;
  4384. } else {
  4385. spec->adc_nids = alc882_adc_nids;
  4386. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  4387. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  4388. spec->num_mixers++;
  4389. }
  4390. }
  4391. codec->patch_ops = alc_patch_ops;
  4392. if (board_config == ALC882_AUTO)
  4393. spec->init_hook = alc882_auto_init;
  4394. return 0;
  4395. }
  4396. /*
  4397. * ALC883 support
  4398. *
  4399. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  4400. * configuration. Each pin widget can choose any input DACs and a mixer.
  4401. * Each ADC is connected from a mixer of all inputs. This makes possible
  4402. * 6-channel independent captures.
  4403. *
  4404. * In addition, an independent DAC for the multi-playback (not used in this
  4405. * driver yet).
  4406. */
  4407. #define ALC883_DIGOUT_NID 0x06
  4408. #define ALC883_DIGIN_NID 0x0a
  4409. static hda_nid_t alc883_dac_nids[4] = {
  4410. /* front, rear, clfe, rear_surr */
  4411. 0x02, 0x04, 0x03, 0x05
  4412. };
  4413. static hda_nid_t alc883_adc_nids[2] = {
  4414. /* ADC1-2 */
  4415. 0x08, 0x09,
  4416. };
  4417. /* input MUX */
  4418. /* FIXME: should be a matrix-type input source selection */
  4419. static struct hda_input_mux alc883_capture_source = {
  4420. .num_items = 4,
  4421. .items = {
  4422. { "Mic", 0x0 },
  4423. { "Front Mic", 0x1 },
  4424. { "Line", 0x2 },
  4425. { "CD", 0x4 },
  4426. },
  4427. };
  4428. #define alc883_mux_enum_info alc_mux_enum_info
  4429. #define alc883_mux_enum_get alc_mux_enum_get
  4430. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  4431. struct snd_ctl_elem_value *ucontrol)
  4432. {
  4433. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4434. struct alc_spec *spec = codec->spec;
  4435. const struct hda_input_mux *imux = spec->input_mux;
  4436. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4437. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4438. hda_nid_t nid = capture_mixers[adc_idx];
  4439. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4440. unsigned int i, idx;
  4441. idx = ucontrol->value.enumerated.item[0];
  4442. if (idx >= imux->num_items)
  4443. idx = imux->num_items - 1;
  4444. if (*cur_val == idx && ! codec->in_resume)
  4445. return 0;
  4446. for (i = 0; i < imux->num_items; i++) {
  4447. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4448. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4449. v | (imux->items[i].index << 8));
  4450. }
  4451. *cur_val = idx;
  4452. return 1;
  4453. }
  4454. /*
  4455. * 2ch mode
  4456. */
  4457. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  4458. { 2, NULL }
  4459. };
  4460. /*
  4461. * 2ch mode
  4462. */
  4463. static struct hda_verb alc883_3ST_ch2_init[] = {
  4464. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4465. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4466. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4467. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4468. { } /* end */
  4469. };
  4470. /*
  4471. * 6ch mode
  4472. */
  4473. static struct hda_verb alc883_3ST_ch6_init[] = {
  4474. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4475. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4476. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4477. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4478. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4479. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4480. { } /* end */
  4481. };
  4482. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  4483. { 2, alc883_3ST_ch2_init },
  4484. { 6, alc883_3ST_ch6_init },
  4485. };
  4486. /*
  4487. * 6ch mode
  4488. */
  4489. static struct hda_verb alc883_sixstack_ch6_init[] = {
  4490. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4491. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4492. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4493. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4494. { } /* end */
  4495. };
  4496. /*
  4497. * 8ch mode
  4498. */
  4499. static struct hda_verb alc883_sixstack_ch8_init[] = {
  4500. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4501. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4502. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4503. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4504. { } /* end */
  4505. };
  4506. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  4507. { 6, alc883_sixstack_ch6_init },
  4508. { 8, alc883_sixstack_ch8_init },
  4509. };
  4510. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4511. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4512. */
  4513. static struct snd_kcontrol_new alc883_base_mixer[] = {
  4514. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4515. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4516. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4517. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4518. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4519. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4520. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4521. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4522. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4523. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4524. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4525. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4526. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4527. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4528. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4529. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4530. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4531. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4532. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4533. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4534. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4535. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4536. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4537. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4538. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4539. {
  4540. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4541. /* .name = "Capture Source", */
  4542. .name = "Input Source",
  4543. .count = 2,
  4544. .info = alc883_mux_enum_info,
  4545. .get = alc883_mux_enum_get,
  4546. .put = alc883_mux_enum_put,
  4547. },
  4548. { } /* end */
  4549. };
  4550. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  4551. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4552. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4553. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4554. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4555. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4556. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4557. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4558. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4559. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4560. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4561. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4562. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4563. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4564. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4565. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4566. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4567. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4568. {
  4569. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4570. /* .name = "Capture Source", */
  4571. .name = "Input Source",
  4572. .count = 2,
  4573. .info = alc883_mux_enum_info,
  4574. .get = alc883_mux_enum_get,
  4575. .put = alc883_mux_enum_put,
  4576. },
  4577. { } /* end */
  4578. };
  4579. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  4580. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4581. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4582. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4583. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4584. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4585. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4586. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4587. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4588. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4589. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4590. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4591. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4592. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4593. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4594. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4595. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4596. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4597. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4598. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4599. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4600. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4601. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4602. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4603. {
  4604. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4605. /* .name = "Capture Source", */
  4606. .name = "Input Source",
  4607. .count = 2,
  4608. .info = alc883_mux_enum_info,
  4609. .get = alc883_mux_enum_get,
  4610. .put = alc883_mux_enum_put,
  4611. },
  4612. { } /* end */
  4613. };
  4614. static snd_kcontrol_new_t alc883_fivestack_mixer[] = {
  4615. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4616. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4617. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4618. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4619. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4620. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4621. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  4622. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4623. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4624. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4625. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4626. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4627. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4628. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4629. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4630. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4631. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4632. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4633. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4634. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4635. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4636. {
  4637. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4638. /* .name = "Capture Source", */
  4639. .name = "Input Source",
  4640. .count = 1,
  4641. .info = alc883_mux_enum_info,
  4642. .get = alc883_mux_enum_get,
  4643. .put = alc883_mux_enum_put,
  4644. },
  4645. { } /* end */
  4646. };
  4647. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  4648. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4649. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4650. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4651. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4652. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4653. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4654. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4655. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4656. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4657. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4658. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4659. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4660. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4661. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4662. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4663. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4664. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4665. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4666. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4667. {
  4668. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4669. /* .name = "Capture Source", */
  4670. .name = "Input Source",
  4671. .count = 2,
  4672. .info = alc883_mux_enum_info,
  4673. .get = alc883_mux_enum_get,
  4674. .put = alc883_mux_enum_put,
  4675. },
  4676. { } /* end */
  4677. };
  4678. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  4679. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4680. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4681. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4682. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4683. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4684. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4685. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4686. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4687. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4688. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4689. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4690. {
  4691. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4692. /* .name = "Capture Source", */
  4693. .name = "Input Source",
  4694. .count = 2,
  4695. .info = alc883_mux_enum_info,
  4696. .get = alc883_mux_enum_get,
  4697. .put = alc883_mux_enum_put,
  4698. },
  4699. { } /* end */
  4700. };
  4701. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  4702. {
  4703. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4704. .name = "Channel Mode",
  4705. .info = alc_ch_mode_info,
  4706. .get = alc_ch_mode_get,
  4707. .put = alc_ch_mode_put,
  4708. },
  4709. { } /* end */
  4710. };
  4711. static struct hda_verb alc883_init_verbs[] = {
  4712. /* ADC1: mute amp left and right */
  4713. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4714. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4715. /* ADC2: mute amp left and right */
  4716. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4717. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4718. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4719. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4720. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4721. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4722. /* Rear mixer */
  4723. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4724. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4725. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4726. /* CLFE mixer */
  4727. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4728. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4729. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4730. /* Side mixer */
  4731. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4732. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4733. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4734. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4735. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4736. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4737. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4738. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4739. /* Front Pin: output 0 (0x0c) */
  4740. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4741. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4742. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4743. /* Rear Pin: output 1 (0x0d) */
  4744. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4745. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4746. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4747. /* CLFE Pin: output 2 (0x0e) */
  4748. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4749. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4750. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4751. /* Side Pin: output 3 (0x0f) */
  4752. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4753. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4754. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4755. /* Mic (rear) pin: input vref at 80% */
  4756. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4757. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4758. /* Front Mic pin: input vref at 80% */
  4759. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4760. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4761. /* Line In pin: input */
  4762. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4763. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4764. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4765. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4766. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4767. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4768. /* CD pin widget for input */
  4769. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4770. /* FIXME: use matrix-type input source selection */
  4771. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4772. /* Input mixer2 */
  4773. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4774. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4775. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4776. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4777. /* Input mixer3 */
  4778. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4779. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4780. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4781. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4782. { }
  4783. };
  4784. static struct hda_verb alc883_tagra_verbs[] = {
  4785. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4786. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4787. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4788. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4789. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4790. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4791. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4792. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4793. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4794. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4795. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4796. { } /* end */
  4797. };
  4798. /* toggle speaker-output according to the hp-jack state */
  4799. static void alc883_tagra_automute(struct hda_codec *codec)
  4800. {
  4801. unsigned int present;
  4802. present = snd_hda_codec_read(codec, 0x14, 0,
  4803. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4804. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4805. 0x80, present ? 0x80 : 0);
  4806. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4807. 0x80, present ? 0x80 : 0);
  4808. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4809. }
  4810. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  4811. {
  4812. if ((res >> 26) == ALC880_HP_EVENT)
  4813. alc883_tagra_automute(codec);
  4814. }
  4815. /*
  4816. * generic initialization of ADC, input mixers and output mixers
  4817. */
  4818. static struct hda_verb alc883_auto_init_verbs[] = {
  4819. /*
  4820. * Unmute ADC0-2 and set the default input to mic-in
  4821. */
  4822. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4823. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4824. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4825. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4826. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4827. * mixer widget
  4828. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4829. * mic (mic 2)
  4830. */
  4831. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4832. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4833. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4834. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4835. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4836. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4837. /*
  4838. * Set up output mixers (0x0c - 0x0f)
  4839. */
  4840. /* set vol=0 to output mixers */
  4841. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4842. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4843. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4844. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4845. /* set up input amps for analog loopback */
  4846. /* Amp Indices: DAC = 0, mixer = 1 */
  4847. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4848. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4849. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4850. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4851. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4852. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4853. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4854. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4855. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4856. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4857. /* FIXME: use matrix-type input source selection */
  4858. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4859. /* Input mixer1 */
  4860. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4861. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4862. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4863. //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4864. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4865. /* Input mixer2 */
  4866. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4867. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4868. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4869. //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4870. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4871. { }
  4872. };
  4873. /* capture mixer elements */
  4874. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  4875. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4876. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4877. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4878. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4879. {
  4880. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4881. /* The multiple "Capture Source" controls confuse alsamixer
  4882. * So call somewhat different..
  4883. * FIXME: the controls appear in the "playback" view!
  4884. */
  4885. /* .name = "Capture Source", */
  4886. .name = "Input Source",
  4887. .count = 2,
  4888. .info = alc882_mux_enum_info,
  4889. .get = alc882_mux_enum_get,
  4890. .put = alc882_mux_enum_put,
  4891. },
  4892. { } /* end */
  4893. };
  4894. /* pcm configuration: identiacal with ALC880 */
  4895. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  4896. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  4897. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  4898. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  4899. /*
  4900. * configuration and preset
  4901. */
  4902. static struct hda_board_config alc883_cfg_tbl[] = {
  4903. { .modelname = "3stack-dig", .config = ALC883_3ST_2ch_DIG },
  4904. { .modelname = "3stack-6ch-dig", .config = ALC883_3ST_6ch_DIG },
  4905. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668,
  4906. .config = ALC883_3ST_6ch_DIG }, /* ECS to Intel*/
  4907. { .modelname = "3stack-6ch", .config = ALC883_3ST_6ch },
  4908. { .pci_subvendor = 0x108e, .pci_subdevice = 0x534d,
  4909. .config = ALC883_3ST_6ch },
  4910. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd601,
  4911. .config = ALC883_3ST_6ch }, /* D102GGC */
  4912. { .modelname = "6stack-dig", .config = ALC883_6ST_DIG },
  4913. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668,
  4914. .config = ALC883_6ST_DIG }, /* MSI */
  4915. { .pci_subvendor = 0x1462, .pci_subdevice = 0x7280,
  4916. .config = ALC883_6ST_DIG }, /* MSI K9A Platinum (MS-7280) */
  4917. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668,
  4918. .config = ALC883_6ST_DIG }, /* Foxconn */
  4919. { .pci_subvendor = 0x1462, .pci_subdevice = 0x7187,
  4920. .config = ALC883_6ST_DIG }, /* MSI */
  4921. { .modelname = "targa-dig", .config = ALC883_TARGA_DIG },
  4922. { .pci_subvendor = 0x1462, .pci_subdevice = 0x4314,
  4923. .config = ALC883_TARGA_DIG }, /* MSI */
  4924. { .pci_subvendor = 0x1462, .pci_subdevice = 0x3fcc,
  4925. .config = ALC883_TARGA_DIG }, /* MSI */
  4926. { .pci_subvendor = 0x1462, .pci_subdevice = 0x3fc1,
  4927. .config = ALC883_TARGA_DIG }, /* MSI */
  4928. { .pci_subvendor = 0x1462, .pci_subdevice = 0x3fc3,
  4929. .config = ALC883_TARGA_DIG }, /* MSI */
  4930. { .pci_subvendor = 0x1462, .pci_subdevice = 0x4314,
  4931. .config = ALC883_TARGA_DIG }, /* MSI */
  4932. { .pci_subvendor = 0x1462, .pci_subdevice = 0x4319,
  4933. .config = ALC883_TARGA_DIG }, /* MSI */
  4934. { .pci_subvendor = 0x1462, .pci_subdevice = 0x3ef9,
  4935. .config = ALC883_TARGA_DIG }, /* MSI */
  4936. { .pci_subvendor = 0x1462, .pci_subdevice = 0x4324,
  4937. .config = ALC883_TARGA_DIG }, /* MSI */
  4938. { .modelname = "targa-2ch-dig", .config = ALC883_TARGA_2ch_DIG },
  4939. { .pci_subvendor = 0x1462, .pci_subdevice = 0x0579,
  4940. .config = ALC883_TARGA_2ch_DIG }, /* MSI */
  4941. { .pci_subvendor = 0x1462, .pci_subdevice = 0xa422,
  4942. .config = ALC883_TARGA_2ch_DIG }, /* MSI */
  4943. { .pci_subvendor = 0x1462, .pci_subdevice = 0x3b7f,
  4944. .config = ALC883_TARGA_2ch_DIG }, /* MSI */
  4945. { .modelname = "6stack-dig-demo", .config = ALC888_DEMO_BOARD },
  4946. { .modelname = "acer", .config = ALC883_ACER },
  4947. { .pci_subvendor = 0x1025, .pci_subdevice = 0/*0x0102*/,
  4948. .config = ALC883_ACER },
  4949. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0102,
  4950. .config = ALC883_ACER },
  4951. { .pci_subvendor = 0x1025, .pci_subdevice = 0x009f,
  4952. .config = ALC883_ACER },
  4953. { .pci_subvendor = 0x161f, .pci_subdevice = 0x2054,
  4954. .modelname = "medion", .config = ALC883_MEDION },
  4955. { .modelname = "auto", .config = ALC883_AUTO },
  4956. {}
  4957. };
  4958. static struct alc_config_preset alc883_presets[] = {
  4959. [ALC883_3ST_2ch_DIG] = {
  4960. .mixers = { alc883_3ST_2ch_mixer },
  4961. .init_verbs = { alc883_init_verbs },
  4962. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4963. .dac_nids = alc883_dac_nids,
  4964. .dig_out_nid = ALC883_DIGOUT_NID,
  4965. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4966. .adc_nids = alc883_adc_nids,
  4967. .dig_in_nid = ALC883_DIGIN_NID,
  4968. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  4969. .channel_mode = alc883_3ST_2ch_modes,
  4970. .input_mux = &alc883_capture_source,
  4971. },
  4972. [ALC883_3ST_6ch_DIG] = {
  4973. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  4974. .init_verbs = { alc883_init_verbs },
  4975. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4976. .dac_nids = alc883_dac_nids,
  4977. .dig_out_nid = ALC883_DIGOUT_NID,
  4978. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4979. .adc_nids = alc883_adc_nids,
  4980. .dig_in_nid = ALC883_DIGIN_NID,
  4981. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  4982. .channel_mode = alc883_3ST_6ch_modes,
  4983. .need_dac_fix = 1,
  4984. .input_mux = &alc883_capture_source,
  4985. },
  4986. [ALC883_3ST_6ch] = {
  4987. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  4988. .init_verbs = { alc883_init_verbs },
  4989. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  4990. .dac_nids = alc883_dac_nids,
  4991. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  4992. .adc_nids = alc883_adc_nids,
  4993. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  4994. .channel_mode = alc883_3ST_6ch_modes,
  4995. .need_dac_fix = 1,
  4996. .input_mux = &alc883_capture_source,
  4997. },
  4998. [ALC883_6ST_DIG] = {
  4999. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5000. .init_verbs = { alc883_init_verbs },
  5001. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5002. .dac_nids = alc883_dac_nids,
  5003. .dig_out_nid = ALC883_DIGOUT_NID,
  5004. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5005. .adc_nids = alc883_adc_nids,
  5006. .dig_in_nid = ALC883_DIGIN_NID,
  5007. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5008. .channel_mode = alc883_sixstack_modes,
  5009. .input_mux = &alc883_capture_source,
  5010. },
  5011. [ALC883_TARGA_DIG] = {
  5012. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5013. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5014. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5015. .dac_nids = alc883_dac_nids,
  5016. .dig_out_nid = ALC883_DIGOUT_NID,
  5017. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5018. .adc_nids = alc883_adc_nids,
  5019. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5020. .channel_mode = alc883_3ST_6ch_modes,
  5021. .need_dac_fix = 1,
  5022. .input_mux = &alc883_capture_source,
  5023. .unsol_event = alc883_tagra_unsol_event,
  5024. .init_hook = alc883_tagra_automute,
  5025. },
  5026. [ALC883_TARGA_2ch_DIG] = {
  5027. .mixers = { alc883_tagra_2ch_mixer},
  5028. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5029. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5030. .dac_nids = alc883_dac_nids,
  5031. .dig_out_nid = ALC883_DIGOUT_NID,
  5032. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5033. .adc_nids = alc883_adc_nids,
  5034. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5035. .channel_mode = alc883_3ST_2ch_modes,
  5036. .input_mux = &alc883_capture_source,
  5037. .unsol_event = alc883_tagra_unsol_event,
  5038. .init_hook = alc883_tagra_automute,
  5039. },
  5040. [ALC888_DEMO_BOARD] = {
  5041. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5042. .init_verbs = { alc883_init_verbs },
  5043. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5044. .dac_nids = alc883_dac_nids,
  5045. .dig_out_nid = ALC883_DIGOUT_NID,
  5046. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5047. .adc_nids = alc883_adc_nids,
  5048. .dig_in_nid = ALC883_DIGIN_NID,
  5049. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5050. .channel_mode = alc883_sixstack_modes,
  5051. .input_mux = &alc883_capture_source,
  5052. },
  5053. [ALC883_ACER] = {
  5054. .mixers = { alc883_base_mixer,
  5055. alc883_chmode_mixer },
  5056. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5057. * and the headphone jack. Turn this on and rely on the
  5058. * standard mute methods whenever the user wants to turn
  5059. * these outputs off.
  5060. */
  5061. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5062. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5063. .dac_nids = alc883_dac_nids,
  5064. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5065. .adc_nids = alc883_adc_nids,
  5066. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5067. .channel_mode = alc883_3ST_2ch_modes,
  5068. .input_mux = &alc883_capture_source,
  5069. },
  5070. [ALC883_MEDION] = {
  5071. .mixers = { alc883_fivestack_mixer,
  5072. alc883_chmode_mixer },
  5073. .init_verbs = { alc883_init_verbs,
  5074. alc882_eapd_verbs },
  5075. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5076. .dac_nids = alc883_dac_nids,
  5077. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5078. .adc_nids = alc883_adc_nids,
  5079. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5080. .channel_mode = alc883_sixstack_modes,
  5081. .input_mux = &alc883_capture_source,
  5082. }
  5083. };
  5084. /*
  5085. * BIOS auto configuration
  5086. */
  5087. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  5088. hda_nid_t nid, int pin_type,
  5089. int dac_idx)
  5090. {
  5091. /* set as output */
  5092. struct alc_spec *spec = codec->spec;
  5093. int idx;
  5094. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5095. idx = 4;
  5096. else
  5097. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5098. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5099. pin_type);
  5100. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5101. AMP_OUT_UNMUTE);
  5102. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5103. }
  5104. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  5105. {
  5106. struct alc_spec *spec = codec->spec;
  5107. int i;
  5108. for (i = 0; i <= HDA_SIDE; i++) {
  5109. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5110. if (nid)
  5111. alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  5112. }
  5113. }
  5114. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  5115. {
  5116. struct alc_spec *spec = codec->spec;
  5117. hda_nid_t pin;
  5118. pin = spec->autocfg.hp_pins[0];
  5119. if (pin) /* connect to front */
  5120. /* use dac 0 */
  5121. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5122. }
  5123. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  5124. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  5125. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  5126. {
  5127. struct alc_spec *spec = codec->spec;
  5128. int i;
  5129. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5130. hda_nid_t nid = spec->autocfg.input_pins[i];
  5131. if (alc883_is_input_pin(nid)) {
  5132. snd_hda_codec_write(codec, nid, 0,
  5133. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5134. (i <= AUTO_PIN_FRONT_MIC ?
  5135. PIN_VREF80 : PIN_IN));
  5136. if (nid != ALC883_PIN_CD_NID)
  5137. snd_hda_codec_write(codec, nid, 0,
  5138. AC_VERB_SET_AMP_GAIN_MUTE,
  5139. AMP_OUT_MUTE);
  5140. }
  5141. }
  5142. }
  5143. /* almost identical with ALC880 parser... */
  5144. static int alc883_parse_auto_config(struct hda_codec *codec)
  5145. {
  5146. struct alc_spec *spec = codec->spec;
  5147. int err = alc880_parse_auto_config(codec);
  5148. if (err < 0)
  5149. return err;
  5150. else if (err > 0)
  5151. /* hack - override the init verbs */
  5152. spec->init_verbs[0] = alc883_auto_init_verbs;
  5153. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  5154. spec->num_mixers++;
  5155. return err;
  5156. }
  5157. /* additional initialization for auto-configuration model */
  5158. static void alc883_auto_init(struct hda_codec *codec)
  5159. {
  5160. alc883_auto_init_multi_out(codec);
  5161. alc883_auto_init_hp_out(codec);
  5162. alc883_auto_init_analog_input(codec);
  5163. }
  5164. static int patch_alc883(struct hda_codec *codec)
  5165. {
  5166. struct alc_spec *spec;
  5167. int err, board_config;
  5168. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5169. if (spec == NULL)
  5170. return -ENOMEM;
  5171. codec->spec = spec;
  5172. board_config = snd_hda_check_board_config(codec, alc883_cfg_tbl);
  5173. if (board_config < 0 || board_config >= ALC883_MODEL_LAST) {
  5174. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  5175. "trying auto-probe from BIOS...\n");
  5176. board_config = ALC883_AUTO;
  5177. }
  5178. if (board_config == ALC883_AUTO) {
  5179. /* automatic parse from the BIOS config */
  5180. err = alc883_parse_auto_config(codec);
  5181. if (err < 0) {
  5182. alc_free(codec);
  5183. return err;
  5184. } else if (! err) {
  5185. printk(KERN_INFO
  5186. "hda_codec: Cannot set up configuration "
  5187. "from BIOS. Using base mode...\n");
  5188. board_config = ALC883_3ST_2ch_DIG;
  5189. }
  5190. }
  5191. if (board_config != ALC883_AUTO)
  5192. setup_preset(spec, &alc883_presets[board_config]);
  5193. spec->stream_name_analog = "ALC883 Analog";
  5194. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  5195. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  5196. spec->stream_name_digital = "ALC883 Digital";
  5197. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  5198. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  5199. if (! spec->adc_nids && spec->input_mux) {
  5200. spec->adc_nids = alc883_adc_nids;
  5201. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  5202. }
  5203. codec->patch_ops = alc_patch_ops;
  5204. if (board_config == ALC883_AUTO)
  5205. spec->init_hook = alc883_auto_init;
  5206. return 0;
  5207. }
  5208. /*
  5209. * ALC262 support
  5210. */
  5211. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  5212. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  5213. #define alc262_dac_nids alc260_dac_nids
  5214. #define alc262_adc_nids alc882_adc_nids
  5215. #define alc262_adc_nids_alt alc882_adc_nids_alt
  5216. #define alc262_modes alc260_modes
  5217. #define alc262_capture_source alc882_capture_source
  5218. static struct snd_kcontrol_new alc262_base_mixer[] = {
  5219. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5220. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5221. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5222. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5223. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5224. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5225. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5226. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5227. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5228. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5229. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5230. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5231. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  5232. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5233. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5234. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5235. { } /* end */
  5236. };
  5237. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  5238. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5239. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5240. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5241. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5242. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5243. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5244. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5245. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5246. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5247. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5248. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5249. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5250. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  5251. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5252. { } /* end */
  5253. };
  5254. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  5255. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5256. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5257. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5258. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5259. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5260. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5261. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5262. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5263. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5264. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5265. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5266. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5267. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5268. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5269. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5270. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  5271. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  5272. { } /* end */
  5273. };
  5274. #define alc262_capture_mixer alc882_capture_mixer
  5275. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  5276. /*
  5277. * generic initialization of ADC, input mixers and output mixers
  5278. */
  5279. static struct hda_verb alc262_init_verbs[] = {
  5280. /*
  5281. * Unmute ADC0-2 and set the default input to mic-in
  5282. */
  5283. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5284. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5285. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5286. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5287. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5288. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5289. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5290. * mixer widget
  5291. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5292. * mic (mic 2)
  5293. */
  5294. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5295. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5296. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5297. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5298. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5299. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5300. /*
  5301. * Set up output mixers (0x0c - 0x0e)
  5302. */
  5303. /* set vol=0 to output mixers */
  5304. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5305. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5306. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5307. /* set up input amps for analog loopback */
  5308. /* Amp Indices: DAC = 0, mixer = 1 */
  5309. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5310. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5311. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5312. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5313. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5314. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5315. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5316. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5317. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5318. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5319. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5320. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5321. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5322. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5323. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5324. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5325. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5326. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5327. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5328. /* FIXME: use matrix-type input source selection */
  5329. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5330. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5331. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5332. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5333. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5334. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5335. /* Input mixer2 */
  5336. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5337. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5338. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5339. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5340. /* Input mixer3 */
  5341. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5342. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5343. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5344. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5345. { }
  5346. };
  5347. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  5348. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5349. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5350. {}
  5351. };
  5352. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  5353. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5354. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5355. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5356. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5357. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5358. {}
  5359. };
  5360. /* mute/unmute internal speaker according to the hp jack and mute state */
  5361. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  5362. {
  5363. struct alc_spec *spec = codec->spec;
  5364. unsigned int mute;
  5365. if (force || ! spec->sense_updated) {
  5366. unsigned int present;
  5367. /* need to execute and sync at first */
  5368. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  5369. present = snd_hda_codec_read(codec, 0x15, 0,
  5370. AC_VERB_GET_PIN_SENSE, 0);
  5371. spec->jack_present = (present & 0x80000000) != 0;
  5372. spec->sense_updated = 1;
  5373. }
  5374. if (spec->jack_present) {
  5375. /* mute internal speaker */
  5376. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5377. 0x80, 0x80);
  5378. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5379. 0x80, 0x80);
  5380. } else {
  5381. /* unmute internal speaker if necessary */
  5382. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  5383. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5384. 0x80, mute & 0x80);
  5385. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  5386. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5387. 0x80, mute & 0x80);
  5388. }
  5389. }
  5390. /* unsolicited event for HP jack sensing */
  5391. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  5392. unsigned int res)
  5393. {
  5394. if ((res >> 26) != ALC880_HP_EVENT)
  5395. return;
  5396. alc262_hippo_automute(codec, 1);
  5397. }
  5398. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  5399. {
  5400. struct alc_spec *spec = codec->spec;
  5401. unsigned int mute;
  5402. if (force || ! spec->sense_updated) {
  5403. unsigned int present;
  5404. /* need to execute and sync at first */
  5405. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  5406. present = snd_hda_codec_read(codec, 0x1b, 0,
  5407. AC_VERB_GET_PIN_SENSE, 0);
  5408. spec->jack_present = (present & 0x80000000) != 0;
  5409. spec->sense_updated = 1;
  5410. }
  5411. if (spec->jack_present) {
  5412. /* mute internal speaker */
  5413. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5414. 0x80, 0x80);
  5415. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5416. 0x80, 0x80);
  5417. } else {
  5418. /* unmute internal speaker if necessary */
  5419. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  5420. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5421. 0x80, mute & 0x80);
  5422. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  5423. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5424. 0x80, mute & 0x80);
  5425. }
  5426. }
  5427. /* unsolicited event for HP jack sensing */
  5428. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  5429. unsigned int res)
  5430. {
  5431. if ((res >> 26) != ALC880_HP_EVENT)
  5432. return;
  5433. alc262_hippo1_automute(codec, 1);
  5434. }
  5435. /*
  5436. * fujitsu model
  5437. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  5438. */
  5439. #define ALC_HP_EVENT 0x37
  5440. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  5441. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  5442. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5443. {}
  5444. };
  5445. static struct hda_input_mux alc262_fujitsu_capture_source = {
  5446. .num_items = 2,
  5447. .items = {
  5448. { "Mic", 0x0 },
  5449. { "CD", 0x4 },
  5450. },
  5451. };
  5452. static struct hda_input_mux alc262_HP_capture_source = {
  5453. .num_items = 5,
  5454. .items = {
  5455. { "Mic", 0x0 },
  5456. { "Front Mic", 0x3 },
  5457. { "Line", 0x2 },
  5458. { "CD", 0x4 },
  5459. { "AUX IN", 0x6 },
  5460. },
  5461. };
  5462. /* mute/unmute internal speaker according to the hp jack and mute state */
  5463. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  5464. {
  5465. struct alc_spec *spec = codec->spec;
  5466. unsigned int mute;
  5467. if (force || ! spec->sense_updated) {
  5468. unsigned int present;
  5469. /* need to execute and sync at first */
  5470. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  5471. present = snd_hda_codec_read(codec, 0x14, 0,
  5472. AC_VERB_GET_PIN_SENSE, 0);
  5473. spec->jack_present = (present & 0x80000000) != 0;
  5474. spec->sense_updated = 1;
  5475. }
  5476. if (spec->jack_present) {
  5477. /* mute internal speaker */
  5478. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5479. 0x80, 0x80);
  5480. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5481. 0x80, 0x80);
  5482. } else {
  5483. /* unmute internal speaker if necessary */
  5484. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  5485. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5486. 0x80, mute & 0x80);
  5487. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  5488. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5489. 0x80, mute & 0x80);
  5490. }
  5491. }
  5492. /* unsolicited event for HP jack sensing */
  5493. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  5494. unsigned int res)
  5495. {
  5496. if ((res >> 26) != ALC_HP_EVENT)
  5497. return;
  5498. alc262_fujitsu_automute(codec, 1);
  5499. }
  5500. /* bind volumes of both NID 0x0c and 0x0d */
  5501. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  5502. struct snd_ctl_elem_value *ucontrol)
  5503. {
  5504. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5505. long *valp = ucontrol->value.integer.value;
  5506. int change;
  5507. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  5508. 0x7f, valp[0] & 0x7f);
  5509. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  5510. 0x7f, valp[1] & 0x7f);
  5511. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  5512. 0x7f, valp[0] & 0x7f);
  5513. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  5514. 0x7f, valp[1] & 0x7f);
  5515. return change;
  5516. }
  5517. /* bind hp and internal speaker mute (with plug check) */
  5518. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  5519. struct snd_ctl_elem_value *ucontrol)
  5520. {
  5521. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5522. long *valp = ucontrol->value.integer.value;
  5523. int change;
  5524. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5525. 0x80, valp[0] ? 0 : 0x80);
  5526. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5527. 0x80, valp[1] ? 0 : 0x80);
  5528. if (change || codec->in_resume)
  5529. alc262_fujitsu_automute(codec, codec->in_resume);
  5530. return change;
  5531. }
  5532. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  5533. {
  5534. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5535. .name = "Master Playback Volume",
  5536. .info = snd_hda_mixer_amp_volume_info,
  5537. .get = snd_hda_mixer_amp_volume_get,
  5538. .put = alc262_fujitsu_master_vol_put,
  5539. .tlv = { .c = snd_hda_mixer_amp_tlv },
  5540. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  5541. },
  5542. {
  5543. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5544. .name = "Master Playback Switch",
  5545. .info = snd_hda_mixer_amp_switch_info,
  5546. .get = snd_hda_mixer_amp_switch_get,
  5547. .put = alc262_fujitsu_master_sw_put,
  5548. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  5549. },
  5550. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5551. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5552. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5553. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5554. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5555. { } /* end */
  5556. };
  5557. /* additional init verbs for Benq laptops */
  5558. static struct hda_verb alc262_EAPD_verbs[] = {
  5559. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5560. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5561. {}
  5562. };
  5563. /* add playback controls from the parsed DAC table */
  5564. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5565. {
  5566. hda_nid_t nid;
  5567. int err;
  5568. spec->multiout.num_dacs = 1; /* only use one dac */
  5569. spec->multiout.dac_nids = spec->private_dac_nids;
  5570. spec->multiout.dac_nids[0] = 2;
  5571. nid = cfg->line_out_pins[0];
  5572. if (nid) {
  5573. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  5574. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  5575. return err;
  5576. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  5577. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5578. return err;
  5579. }
  5580. nid = cfg->speaker_pins[0];
  5581. if (nid) {
  5582. if (nid == 0x16) {
  5583. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  5584. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5585. return err;
  5586. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5587. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5588. return err;
  5589. } else {
  5590. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5591. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5592. return err;
  5593. }
  5594. }
  5595. nid = cfg->hp_pins[0];
  5596. if (nid) {
  5597. /* spec->multiout.hp_nid = 2; */
  5598. if (nid == 0x16) {
  5599. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  5600. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5601. return err;
  5602. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5603. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5604. return err;
  5605. } else {
  5606. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5607. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5608. return err;
  5609. }
  5610. }
  5611. return 0;
  5612. }
  5613. /* identical with ALC880 */
  5614. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  5615. /*
  5616. * generic initialization of ADC, input mixers and output mixers
  5617. */
  5618. static struct hda_verb alc262_volume_init_verbs[] = {
  5619. /*
  5620. * Unmute ADC0-2 and set the default input to mic-in
  5621. */
  5622. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5623. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5624. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5625. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5626. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5627. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5628. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5629. * mixer widget
  5630. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5631. * mic (mic 2)
  5632. */
  5633. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5634. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5635. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5636. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5637. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5638. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5639. /*
  5640. * Set up output mixers (0x0c - 0x0f)
  5641. */
  5642. /* set vol=0 to output mixers */
  5643. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5644. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5645. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5646. /* set up input amps for analog loopback */
  5647. /* Amp Indices: DAC = 0, mixer = 1 */
  5648. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5649. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5650. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5651. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5652. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5653. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5654. /* FIXME: use matrix-type input source selection */
  5655. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5656. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5657. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5658. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5659. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5660. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5661. /* Input mixer2 */
  5662. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5663. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5664. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5665. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5666. /* Input mixer3 */
  5667. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5668. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5669. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5670. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5671. { }
  5672. };
  5673. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  5674. /*
  5675. * Unmute ADC0-2 and set the default input to mic-in
  5676. */
  5677. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5678. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5679. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5680. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5681. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5682. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5683. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5684. * mixer widget
  5685. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5686. * mic (mic 2)
  5687. */
  5688. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5689. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5690. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5691. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5692. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5693. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5694. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  5695. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  5696. /*
  5697. * Set up output mixers (0x0c - 0x0e)
  5698. */
  5699. /* set vol=0 to output mixers */
  5700. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5701. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5702. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5703. /* set up input amps for analog loopback */
  5704. /* Amp Indices: DAC = 0, mixer = 1 */
  5705. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5706. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5707. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5708. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5709. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5710. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5711. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5712. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5713. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5714. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5715. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5716. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5717. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5718. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5719. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5720. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5721. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5722. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5723. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5724. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5725. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5726. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5727. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5728. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5729. /* FIXME: use matrix-type input source selection */
  5730. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5731. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5732. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5733. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5734. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5735. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5736. /* Input mixer2 */
  5737. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5738. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5739. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5740. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5741. /* Input mixer3 */
  5742. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5743. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5744. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5745. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5746. { }
  5747. };
  5748. /* pcm configuration: identiacal with ALC880 */
  5749. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  5750. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  5751. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  5752. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  5753. /*
  5754. * BIOS auto configuration
  5755. */
  5756. static int alc262_parse_auto_config(struct hda_codec *codec)
  5757. {
  5758. struct alc_spec *spec = codec->spec;
  5759. int err;
  5760. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  5761. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  5762. alc262_ignore)) < 0)
  5763. return err;
  5764. if (! spec->autocfg.line_outs)
  5765. return 0; /* can't find valid BIOS pin config */
  5766. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  5767. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  5768. return err;
  5769. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  5770. if (spec->autocfg.dig_out_pin)
  5771. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  5772. if (spec->autocfg.dig_in_pin)
  5773. spec->dig_in_nid = ALC262_DIGIN_NID;
  5774. if (spec->kctl_alloc)
  5775. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  5776. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  5777. spec->num_mux_defs = 1;
  5778. spec->input_mux = &spec->private_imux;
  5779. return 1;
  5780. }
  5781. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  5782. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  5783. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  5784. /* init callback for auto-configuration model -- overriding the default init */
  5785. static void alc262_auto_init(struct hda_codec *codec)
  5786. {
  5787. alc262_auto_init_multi_out(codec);
  5788. alc262_auto_init_hp_out(codec);
  5789. alc262_auto_init_analog_input(codec);
  5790. }
  5791. /*
  5792. * configuration and preset
  5793. */
  5794. static struct hda_board_config alc262_cfg_tbl[] = {
  5795. { .modelname = "basic", .config = ALC262_BASIC },
  5796. { .modelname = "hippo",
  5797. .pci_subvendor =0x1002, .pci_subdevice = 0x437b,
  5798. .config = ALC262_HIPPO},
  5799. { .modelname = "hippo_1",
  5800. .pci_subvendor =0x17ff, .pci_subdevice = 0x058f,
  5801. .config = ALC262_HIPPO_1},
  5802. { .modelname = "fujitsu", .config = ALC262_FUJITSU },
  5803. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397,
  5804. .config = ALC262_FUJITSU },
  5805. { .modelname = "hp-bpc", .config = ALC262_HP_BPC },
  5806. { .pci_subvendor = 0x103c, .pci_subdevice = 0x280c,
  5807. .config = ALC262_HP_BPC }, /* xw4400 */
  5808. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2801,
  5809. .config = ALC262_HP_BPC }, /* q965 */
  5810. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014,
  5811. .config = ALC262_HP_BPC }, /* xw6400 */
  5812. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015,
  5813. .config = ALC262_HP_BPC }, /* xw8400 */
  5814. { .pci_subvendor = 0x103c, .pci_subdevice = 0x12fe,
  5815. .config = ALC262_HP_BPC }, /* xw9400 */
  5816. { .modelname = "benq", .config = ALC262_BENQ_ED8 },
  5817. { .pci_subvendor = 0x17ff, .pci_subdevice = 0x0560,
  5818. .config = ALC262_BENQ_ED8 },
  5819. { .modelname = "auto", .config = ALC262_AUTO },
  5820. {}
  5821. };
  5822. static struct alc_config_preset alc262_presets[] = {
  5823. [ALC262_BASIC] = {
  5824. .mixers = { alc262_base_mixer },
  5825. .init_verbs = { alc262_init_verbs },
  5826. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5827. .dac_nids = alc262_dac_nids,
  5828. .hp_nid = 0x03,
  5829. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5830. .channel_mode = alc262_modes,
  5831. .input_mux = &alc262_capture_source,
  5832. },
  5833. [ALC262_HIPPO] = {
  5834. .mixers = { alc262_base_mixer },
  5835. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  5836. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5837. .dac_nids = alc262_dac_nids,
  5838. .hp_nid = 0x03,
  5839. .dig_out_nid = ALC262_DIGOUT_NID,
  5840. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5841. .channel_mode = alc262_modes,
  5842. .input_mux = &alc262_capture_source,
  5843. .unsol_event = alc262_hippo_unsol_event,
  5844. },
  5845. [ALC262_HIPPO_1] = {
  5846. .mixers = { alc262_hippo1_mixer },
  5847. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  5848. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5849. .dac_nids = alc262_dac_nids,
  5850. .hp_nid = 0x02,
  5851. .dig_out_nid = ALC262_DIGOUT_NID,
  5852. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5853. .channel_mode = alc262_modes,
  5854. .input_mux = &alc262_capture_source,
  5855. .unsol_event = alc262_hippo1_unsol_event,
  5856. },
  5857. [ALC262_FUJITSU] = {
  5858. .mixers = { alc262_fujitsu_mixer },
  5859. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  5860. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5861. .dac_nids = alc262_dac_nids,
  5862. .hp_nid = 0x03,
  5863. .dig_out_nid = ALC262_DIGOUT_NID,
  5864. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5865. .channel_mode = alc262_modes,
  5866. .input_mux = &alc262_fujitsu_capture_source,
  5867. .unsol_event = alc262_fujitsu_unsol_event,
  5868. },
  5869. [ALC262_HP_BPC] = {
  5870. .mixers = { alc262_HP_BPC_mixer },
  5871. .init_verbs = { alc262_HP_BPC_init_verbs },
  5872. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5873. .dac_nids = alc262_dac_nids,
  5874. .hp_nid = 0x03,
  5875. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5876. .channel_mode = alc262_modes,
  5877. .input_mux = &alc262_HP_capture_source,
  5878. },
  5879. [ALC262_BENQ_ED8] = {
  5880. .mixers = { alc262_base_mixer },
  5881. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  5882. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5883. .dac_nids = alc262_dac_nids,
  5884. .hp_nid = 0x03,
  5885. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5886. .channel_mode = alc262_modes,
  5887. .input_mux = &alc262_capture_source,
  5888. },
  5889. };
  5890. static int patch_alc262(struct hda_codec *codec)
  5891. {
  5892. struct alc_spec *spec;
  5893. int board_config;
  5894. int err;
  5895. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  5896. if (spec == NULL)
  5897. return -ENOMEM;
  5898. codec->spec = spec;
  5899. #if 0
  5900. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  5901. {
  5902. int tmp;
  5903. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  5904. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  5905. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  5906. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  5907. }
  5908. #endif
  5909. board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
  5910. if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
  5911. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  5912. "trying auto-probe from BIOS...\n");
  5913. board_config = ALC262_AUTO;
  5914. }
  5915. if (board_config == ALC262_AUTO) {
  5916. /* automatic parse from the BIOS config */
  5917. err = alc262_parse_auto_config(codec);
  5918. if (err < 0) {
  5919. alc_free(codec);
  5920. return err;
  5921. } else if (! err) {
  5922. printk(KERN_INFO
  5923. "hda_codec: Cannot set up configuration "
  5924. "from BIOS. Using base mode...\n");
  5925. board_config = ALC262_BASIC;
  5926. }
  5927. }
  5928. if (board_config != ALC262_AUTO)
  5929. setup_preset(spec, &alc262_presets[board_config]);
  5930. spec->stream_name_analog = "ALC262 Analog";
  5931. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  5932. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  5933. spec->stream_name_digital = "ALC262 Digital";
  5934. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  5935. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  5936. if (! spec->adc_nids && spec->input_mux) {
  5937. /* check whether NID 0x07 is valid */
  5938. unsigned int wcap = get_wcaps(codec, 0x07);
  5939. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  5940. if (wcap != AC_WID_AUD_IN) {
  5941. spec->adc_nids = alc262_adc_nids_alt;
  5942. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  5943. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  5944. spec->num_mixers++;
  5945. } else {
  5946. spec->adc_nids = alc262_adc_nids;
  5947. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  5948. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  5949. spec->num_mixers++;
  5950. }
  5951. }
  5952. codec->patch_ops = alc_patch_ops;
  5953. if (board_config == ALC262_AUTO)
  5954. spec->init_hook = alc262_auto_init;
  5955. return 0;
  5956. }
  5957. /*
  5958. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  5959. */
  5960. /*
  5961. * set the path ways for 2 channel output
  5962. * need to set the codec line out and mic 1 pin widgets to inputs
  5963. */
  5964. static struct hda_verb alc861_threestack_ch2_init[] = {
  5965. /* set pin widget 1Ah (line in) for input */
  5966. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  5967. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  5968. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  5969. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  5970. #if 0
  5971. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  5972. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  5973. #endif
  5974. { } /* end */
  5975. };
  5976. /*
  5977. * 6ch mode
  5978. * need to set the codec line out and mic 1 pin widgets to outputs
  5979. */
  5980. static struct hda_verb alc861_threestack_ch6_init[] = {
  5981. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  5982. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5983. /* set pin widget 18h (mic1) for output (CLFE)*/
  5984. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  5985. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5986. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  5987. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  5988. #if 0
  5989. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  5990. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  5991. #endif
  5992. { } /* end */
  5993. };
  5994. static struct hda_channel_mode alc861_threestack_modes[2] = {
  5995. { 2, alc861_threestack_ch2_init },
  5996. { 6, alc861_threestack_ch6_init },
  5997. };
  5998. /* Set mic1 as input and unmute the mixer */
  5999. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  6000. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6001. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6002. { } /* end */
  6003. };
  6004. /* Set mic1 as output and mute mixer */
  6005. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  6006. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6007. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6008. { } /* end */
  6009. };
  6010. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  6011. { 2, alc861_uniwill_m31_ch2_init },
  6012. { 4, alc861_uniwill_m31_ch4_init },
  6013. };
  6014. /* Set mic1 and line-in as input and unmute the mixer */
  6015. static struct hda_verb alc861_asus_ch2_init[] = {
  6016. /* set pin widget 1Ah (line in) for input */
  6017. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6018. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  6019. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6020. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6021. #if 0
  6022. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6023. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6024. #endif
  6025. { } /* end */
  6026. };
  6027. /* Set mic1 nad line-in as output and mute mixer */
  6028. static struct hda_verb alc861_asus_ch6_init[] = {
  6029. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6030. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6031. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6032. /* set pin widget 18h (mic1) for output (CLFE)*/
  6033. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6034. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6035. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6036. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6037. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6038. #if 0
  6039. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6040. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6041. #endif
  6042. { } /* end */
  6043. };
  6044. static struct hda_channel_mode alc861_asus_modes[2] = {
  6045. { 2, alc861_asus_ch2_init },
  6046. { 6, alc861_asus_ch6_init },
  6047. };
  6048. /* patch-ALC861 */
  6049. static struct snd_kcontrol_new alc861_base_mixer[] = {
  6050. /* output mixer control */
  6051. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6052. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6053. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6054. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6055. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6056. /*Input mixer control */
  6057. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6058. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6059. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6060. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6061. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6062. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6063. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6064. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6065. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6066. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6067. /* Capture mixer control */
  6068. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6069. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6070. {
  6071. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6072. .name = "Capture Source",
  6073. .count = 1,
  6074. .info = alc_mux_enum_info,
  6075. .get = alc_mux_enum_get,
  6076. .put = alc_mux_enum_put,
  6077. },
  6078. { } /* end */
  6079. };
  6080. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  6081. /* output mixer control */
  6082. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6083. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6084. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6085. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6086. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6087. /* Input mixer control */
  6088. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6089. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6090. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6091. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6092. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6093. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6094. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6095. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6096. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6097. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6098. /* Capture mixer control */
  6099. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6100. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6101. {
  6102. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6103. .name = "Capture Source",
  6104. .count = 1,
  6105. .info = alc_mux_enum_info,
  6106. .get = alc_mux_enum_get,
  6107. .put = alc_mux_enum_put,
  6108. },
  6109. {
  6110. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6111. .name = "Channel Mode",
  6112. .info = alc_ch_mode_info,
  6113. .get = alc_ch_mode_get,
  6114. .put = alc_ch_mode_put,
  6115. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  6116. },
  6117. { } /* end */
  6118. };
  6119. static snd_kcontrol_new_t alc861_toshiba_mixer[] = {
  6120. /* output mixer control */
  6121. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6122. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6123. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6124. /*Capture mixer control */
  6125. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6126. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6127. {
  6128. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6129. .name = "Capture Source",
  6130. .count = 1,
  6131. .info = alc_mux_enum_info,
  6132. .get = alc_mux_enum_get,
  6133. .put = alc_mux_enum_put,
  6134. },
  6135. { } /* end */
  6136. };
  6137. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  6138. /* output mixer control */
  6139. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6140. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6141. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6142. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6143. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6144. /* Input mixer control */
  6145. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6146. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6147. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6148. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6149. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6150. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6151. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6152. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6153. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6154. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6155. /* Capture mixer control */
  6156. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6157. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6158. {
  6159. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6160. .name = "Capture Source",
  6161. .count = 1,
  6162. .info = alc_mux_enum_info,
  6163. .get = alc_mux_enum_get,
  6164. .put = alc_mux_enum_put,
  6165. },
  6166. {
  6167. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6168. .name = "Channel Mode",
  6169. .info = alc_ch_mode_info,
  6170. .get = alc_ch_mode_get,
  6171. .put = alc_ch_mode_put,
  6172. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6173. },
  6174. { } /* end */
  6175. };
  6176. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  6177. /* output mixer control */
  6178. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6179. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6180. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6181. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6182. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6183. /* Input mixer control */
  6184. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6185. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6186. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6187. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6188. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6189. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6190. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6191. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6192. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6193. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
  6194. /* Capture mixer control */
  6195. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6196. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6197. {
  6198. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6199. .name = "Capture Source",
  6200. .count = 1,
  6201. .info = alc_mux_enum_info,
  6202. .get = alc_mux_enum_get,
  6203. .put = alc_mux_enum_put,
  6204. },
  6205. {
  6206. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6207. .name = "Channel Mode",
  6208. .info = alc_ch_mode_info,
  6209. .get = alc_ch_mode_get,
  6210. .put = alc_ch_mode_put,
  6211. .private_value = ARRAY_SIZE(alc861_asus_modes),
  6212. },
  6213. { }
  6214. };
  6215. /*
  6216. * generic initialization of ADC, input mixers and output mixers
  6217. */
  6218. static struct hda_verb alc861_base_init_verbs[] = {
  6219. /*
  6220. * Unmute ADC0 and set the default input to mic-in
  6221. */
  6222. /* port-A for surround (rear panel) */
  6223. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6224. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6225. /* port-B for mic-in (rear panel) with vref */
  6226. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6227. /* port-C for line-in (rear panel) */
  6228. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6229. /* port-D for Front */
  6230. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6231. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6232. /* port-E for HP out (front panel) */
  6233. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6234. /* route front PCM to HP */
  6235. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  6236. /* port-F for mic-in (front panel) with vref */
  6237. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6238. /* port-G for CLFE (rear panel) */
  6239. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6240. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6241. /* port-H for side (rear panel) */
  6242. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6243. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6244. /* CD-in */
  6245. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6246. /* route front mic to ADC1*/
  6247. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6248. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6249. /* Unmute DAC0~3 & spdif out*/
  6250. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6251. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6252. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6253. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6254. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6255. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6256. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6257. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6258. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6259. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6260. /* Unmute Stereo Mixer 15 */
  6261. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6262. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6263. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6264. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6265. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6266. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6267. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6268. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6269. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6270. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6271. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6272. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6273. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6274. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6275. { }
  6276. };
  6277. static struct hda_verb alc861_threestack_init_verbs[] = {
  6278. /*
  6279. * Unmute ADC0 and set the default input to mic-in
  6280. */
  6281. /* port-A for surround (rear panel) */
  6282. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6283. /* port-B for mic-in (rear panel) with vref */
  6284. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6285. /* port-C for line-in (rear panel) */
  6286. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6287. /* port-D for Front */
  6288. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6289. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6290. /* port-E for HP out (front panel) */
  6291. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6292. /* route front PCM to HP */
  6293. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  6294. /* port-F for mic-in (front panel) with vref */
  6295. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6296. /* port-G for CLFE (rear panel) */
  6297. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6298. /* port-H for side (rear panel) */
  6299. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6300. /* CD-in */
  6301. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6302. /* route front mic to ADC1*/
  6303. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6304. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6305. /* Unmute DAC0~3 & spdif out*/
  6306. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6307. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6308. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6309. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6310. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6311. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6312. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6313. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6314. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6315. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6316. /* Unmute Stereo Mixer 15 */
  6317. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6318. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6319. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6320. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6321. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6322. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6323. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6324. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6325. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6326. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6327. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6328. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6329. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6330. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6331. { }
  6332. };
  6333. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  6334. /*
  6335. * Unmute ADC0 and set the default input to mic-in
  6336. */
  6337. /* port-A for surround (rear panel) */
  6338. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6339. /* port-B for mic-in (rear panel) with vref */
  6340. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6341. /* port-C for line-in (rear panel) */
  6342. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6343. /* port-D for Front */
  6344. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6345. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6346. /* port-E for HP out (front panel) */
  6347. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
  6348. /* route front PCM to HP */
  6349. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  6350. /* port-F for mic-in (front panel) with vref */
  6351. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6352. /* port-G for CLFE (rear panel) */
  6353. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6354. /* port-H for side (rear panel) */
  6355. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6356. /* CD-in */
  6357. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6358. /* route front mic to ADC1*/
  6359. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6360. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6361. /* Unmute DAC0~3 & spdif out*/
  6362. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6363. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6364. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6365. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6366. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6367. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6368. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6369. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6370. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6371. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6372. /* Unmute Stereo Mixer 15 */
  6373. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6374. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6375. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6376. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6377. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6378. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6379. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6380. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6381. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6382. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6383. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6384. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6385. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6386. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6387. { }
  6388. };
  6389. static struct hda_verb alc861_asus_init_verbs[] = {
  6390. /*
  6391. * Unmute ADC0 and set the default input to mic-in
  6392. */
  6393. /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
  6394. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  6395. /* route front PCM to HP */
  6396. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  6397. /* port-B for mic-in (rear panel) with vref */
  6398. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6399. /* port-C for line-in (rear panel) */
  6400. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6401. /* port-D for Front */
  6402. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6403. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6404. /* port-E for HP out (front panel) */
  6405. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
  6406. /* route front PCM to HP */
  6407. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  6408. /* port-F for mic-in (front panel) with vref */
  6409. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6410. /* port-G for CLFE (rear panel) */
  6411. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6412. /* port-H for side (rear panel) */
  6413. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6414. /* CD-in */
  6415. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6416. /* route front mic to ADC1*/
  6417. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6418. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6419. /* Unmute DAC0~3 & spdif out*/
  6420. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6421. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6422. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6423. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6424. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6425. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6426. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6427. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6428. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6429. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6430. /* Unmute Stereo Mixer 15 */
  6431. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6432. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6433. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6434. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */
  6435. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6436. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6437. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6438. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6439. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6440. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6441. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6442. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6443. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
  6444. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6445. { }
  6446. };
  6447. /*
  6448. * generic initialization of ADC, input mixers and output mixers
  6449. */
  6450. static struct hda_verb alc861_auto_init_verbs[] = {
  6451. /*
  6452. * Unmute ADC0 and set the default input to mic-in
  6453. */
  6454. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6455. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6456. /* Unmute DAC0~3 & spdif out*/
  6457. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6458. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6459. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6460. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6461. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6462. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6463. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6464. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6465. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6466. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6467. /* Unmute Stereo Mixer 15 */
  6468. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6469. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6470. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6471. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  6472. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6473. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6474. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6475. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6476. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6477. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6478. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6479. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6480. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6481. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6482. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6483. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6484. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6485. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6486. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6487. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6488. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  6489. { }
  6490. };
  6491. static struct hda_verb alc861_toshiba_init_verbs[] = {
  6492. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6493. { }
  6494. };
  6495. /* toggle speaker-output according to the hp-jack state */
  6496. static void alc861_toshiba_automute(struct hda_codec *codec)
  6497. {
  6498. unsigned int present;
  6499. present = snd_hda_codec_read(codec, 0x0f, 0,
  6500. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6501. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  6502. 0x80, present ? 0x80 : 0);
  6503. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  6504. 0x80, present ? 0x80 : 0);
  6505. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  6506. 0x80, present ? 0 : 0x80);
  6507. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  6508. 0x80, present ? 0 : 0x80);
  6509. }
  6510. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  6511. unsigned int res)
  6512. {
  6513. /* Looks like the unsol event is incompatible with the standard
  6514. * definition. 6bit tag is placed at 26 bit!
  6515. */
  6516. if ((res >> 26) == ALC880_HP_EVENT)
  6517. alc861_toshiba_automute(codec);
  6518. }
  6519. /* pcm configuration: identiacal with ALC880 */
  6520. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  6521. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  6522. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  6523. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  6524. #define ALC861_DIGOUT_NID 0x07
  6525. static struct hda_channel_mode alc861_8ch_modes[1] = {
  6526. { 8, NULL }
  6527. };
  6528. static hda_nid_t alc861_dac_nids[4] = {
  6529. /* front, surround, clfe, side */
  6530. 0x03, 0x06, 0x05, 0x04
  6531. };
  6532. static hda_nid_t alc660_dac_nids[3] = {
  6533. /* front, clfe, surround */
  6534. 0x03, 0x05, 0x06
  6535. };
  6536. static hda_nid_t alc861_adc_nids[1] = {
  6537. /* ADC0-2 */
  6538. 0x08,
  6539. };
  6540. static struct hda_input_mux alc861_capture_source = {
  6541. .num_items = 5,
  6542. .items = {
  6543. { "Mic", 0x0 },
  6544. { "Front Mic", 0x3 },
  6545. { "Line", 0x1 },
  6546. { "CD", 0x4 },
  6547. { "Mixer", 0x5 },
  6548. },
  6549. };
  6550. /* fill in the dac_nids table from the parsed pin configuration */
  6551. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  6552. {
  6553. int i;
  6554. hda_nid_t nid;
  6555. spec->multiout.dac_nids = spec->private_dac_nids;
  6556. for (i = 0; i < cfg->line_outs; i++) {
  6557. nid = cfg->line_out_pins[i];
  6558. if (nid) {
  6559. if (i >= ARRAY_SIZE(alc861_dac_nids))
  6560. continue;
  6561. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  6562. }
  6563. }
  6564. spec->multiout.num_dacs = cfg->line_outs;
  6565. return 0;
  6566. }
  6567. /* add playback controls from the parsed DAC table */
  6568. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  6569. const struct auto_pin_cfg *cfg)
  6570. {
  6571. char name[32];
  6572. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  6573. hda_nid_t nid;
  6574. int i, idx, err;
  6575. for (i = 0; i < cfg->line_outs; i++) {
  6576. nid = spec->multiout.dac_nids[i];
  6577. if (! nid)
  6578. continue;
  6579. if (nid == 0x05) {
  6580. /* Center/LFE */
  6581. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  6582. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  6583. return err;
  6584. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  6585. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  6586. return err;
  6587. } else {
  6588. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  6589. if (nid == alc861_dac_nids[idx])
  6590. break;
  6591. sprintf(name, "%s Playback Switch", chname[idx]);
  6592. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  6593. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  6594. return err;
  6595. }
  6596. }
  6597. return 0;
  6598. }
  6599. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  6600. {
  6601. int err;
  6602. hda_nid_t nid;
  6603. if (! pin)
  6604. return 0;
  6605. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  6606. nid = 0x03;
  6607. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  6608. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  6609. return err;
  6610. spec->multiout.hp_nid = nid;
  6611. }
  6612. return 0;
  6613. }
  6614. /* create playback/capture controls for input pins */
  6615. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  6616. {
  6617. struct hda_input_mux *imux = &spec->private_imux;
  6618. int i, err, idx, idx1;
  6619. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6620. switch(cfg->input_pins[i]) {
  6621. case 0x0c:
  6622. idx1 = 1;
  6623. idx = 2; // Line In
  6624. break;
  6625. case 0x0f:
  6626. idx1 = 2;
  6627. idx = 2; // Line In
  6628. break;
  6629. case 0x0d:
  6630. idx1 = 0;
  6631. idx = 1; // Mic In
  6632. break;
  6633. case 0x10:
  6634. idx1 = 3;
  6635. idx = 1; // Mic In
  6636. break;
  6637. case 0x11:
  6638. idx1 = 4;
  6639. idx = 0; // CD
  6640. break;
  6641. default:
  6642. continue;
  6643. }
  6644. err = new_analog_input(spec, cfg->input_pins[i],
  6645. auto_pin_cfg_labels[i], idx, 0x15);
  6646. if (err < 0)
  6647. return err;
  6648. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  6649. imux->items[imux->num_items].index = idx1;
  6650. imux->num_items++;
  6651. }
  6652. return 0;
  6653. }
  6654. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  6655. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6656. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6657. {
  6658. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6659. /* The multiple "Capture Source" controls confuse alsamixer
  6660. * So call somewhat different..
  6661. *FIXME: the controls appear in the "playback" view!
  6662. */
  6663. /* .name = "Capture Source", */
  6664. .name = "Input Source",
  6665. .count = 1,
  6666. .info = alc_mux_enum_info,
  6667. .get = alc_mux_enum_get,
  6668. .put = alc_mux_enum_put,
  6669. },
  6670. { } /* end */
  6671. };
  6672. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  6673. int pin_type, int dac_idx)
  6674. {
  6675. /* set as output */
  6676. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  6677. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  6678. }
  6679. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  6680. {
  6681. struct alc_spec *spec = codec->spec;
  6682. int i;
  6683. for (i = 0; i < spec->autocfg.line_outs; i++) {
  6684. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6685. if (nid)
  6686. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  6687. }
  6688. }
  6689. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  6690. {
  6691. struct alc_spec *spec = codec->spec;
  6692. hda_nid_t pin;
  6693. pin = spec->autocfg.hp_pins[0];
  6694. if (pin) /* connect to front */
  6695. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  6696. }
  6697. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  6698. {
  6699. struct alc_spec *spec = codec->spec;
  6700. int i;
  6701. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6702. hda_nid_t nid = spec->autocfg.input_pins[i];
  6703. if ((nid>=0x0c) && (nid <=0x11)) {
  6704. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6705. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  6706. }
  6707. }
  6708. }
  6709. /* parse the BIOS configuration and set up the alc_spec */
  6710. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  6711. static int alc861_parse_auto_config(struct hda_codec *codec)
  6712. {
  6713. struct alc_spec *spec = codec->spec;
  6714. int err;
  6715. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  6716. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6717. alc861_ignore)) < 0)
  6718. return err;
  6719. if (! spec->autocfg.line_outs)
  6720. return 0; /* can't find valid BIOS pin config */
  6721. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  6722. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  6723. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
  6724. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  6725. return err;
  6726. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6727. if (spec->autocfg.dig_out_pin)
  6728. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  6729. if (spec->kctl_alloc)
  6730. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6731. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  6732. spec->num_mux_defs = 1;
  6733. spec->input_mux = &spec->private_imux;
  6734. spec->adc_nids = alc861_adc_nids;
  6735. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  6736. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  6737. spec->num_mixers++;
  6738. return 1;
  6739. }
  6740. /* additional initialization for auto-configuration model */
  6741. static void alc861_auto_init(struct hda_codec *codec)
  6742. {
  6743. alc861_auto_init_multi_out(codec);
  6744. alc861_auto_init_hp_out(codec);
  6745. alc861_auto_init_analog_input(codec);
  6746. }
  6747. /*
  6748. * configuration and preset
  6749. */
  6750. static struct hda_board_config alc861_cfg_tbl[] = {
  6751. { .modelname = "3stack", .config = ALC861_3ST },
  6752. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600,
  6753. .config = ALC861_3ST },
  6754. { .modelname = "3stack-660", .config = ALC660_3ST },
  6755. { .pci_subvendor = 0x1043, .pci_subdevice = 0x81e7,
  6756. .config = ALC660_3ST },
  6757. { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
  6758. { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
  6759. { .modelname = "uniwill-m31", .config = ALC861_UNIWILL_M31},
  6760. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9072,
  6761. .config = ALC861_UNIWILL_M31 },
  6762. { .modelname = "toshiba", .config = ALC861_TOSHIBA },
  6763. { .pci_subvendor = 0x1179, .pci_subdevice = 0xff10,
  6764. .config = ALC861_TOSHIBA },
  6765. { .modelname = "asus", .config = ALC861_ASUS},
  6766. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1393,
  6767. .config = ALC861_ASUS },
  6768. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1338,
  6769. .config = ALC861_ASUS },
  6770. { .modelname = "auto", .config = ALC861_AUTO },
  6771. {}
  6772. };
  6773. static struct alc_config_preset alc861_presets[] = {
  6774. [ALC861_3ST] = {
  6775. .mixers = { alc861_3ST_mixer },
  6776. .init_verbs = { alc861_threestack_init_verbs },
  6777. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6778. .dac_nids = alc861_dac_nids,
  6779. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6780. .channel_mode = alc861_threestack_modes,
  6781. .need_dac_fix = 1,
  6782. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6783. .adc_nids = alc861_adc_nids,
  6784. .input_mux = &alc861_capture_source,
  6785. },
  6786. [ALC861_3ST_DIG] = {
  6787. .mixers = { alc861_base_mixer },
  6788. .init_verbs = { alc861_threestack_init_verbs },
  6789. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6790. .dac_nids = alc861_dac_nids,
  6791. .dig_out_nid = ALC861_DIGOUT_NID,
  6792. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6793. .channel_mode = alc861_threestack_modes,
  6794. .need_dac_fix = 1,
  6795. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6796. .adc_nids = alc861_adc_nids,
  6797. .input_mux = &alc861_capture_source,
  6798. },
  6799. [ALC861_6ST_DIG] = {
  6800. .mixers = { alc861_base_mixer },
  6801. .init_verbs = { alc861_base_init_verbs },
  6802. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6803. .dac_nids = alc861_dac_nids,
  6804. .dig_out_nid = ALC861_DIGOUT_NID,
  6805. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  6806. .channel_mode = alc861_8ch_modes,
  6807. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6808. .adc_nids = alc861_adc_nids,
  6809. .input_mux = &alc861_capture_source,
  6810. },
  6811. [ALC660_3ST] = {
  6812. .mixers = { alc861_3ST_mixer },
  6813. .init_verbs = { alc861_threestack_init_verbs },
  6814. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  6815. .dac_nids = alc660_dac_nids,
  6816. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6817. .channel_mode = alc861_threestack_modes,
  6818. .need_dac_fix = 1,
  6819. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6820. .adc_nids = alc861_adc_nids,
  6821. .input_mux = &alc861_capture_source,
  6822. },
  6823. [ALC861_UNIWILL_M31] = {
  6824. .mixers = { alc861_uniwill_m31_mixer },
  6825. .init_verbs = { alc861_uniwill_m31_init_verbs },
  6826. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6827. .dac_nids = alc861_dac_nids,
  6828. .dig_out_nid = ALC861_DIGOUT_NID,
  6829. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6830. .channel_mode = alc861_uniwill_m31_modes,
  6831. .need_dac_fix = 1,
  6832. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6833. .adc_nids = alc861_adc_nids,
  6834. .input_mux = &alc861_capture_source,
  6835. },
  6836. [ALC861_TOSHIBA] = {
  6837. .mixers = { alc861_toshiba_mixer },
  6838. .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
  6839. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6840. .dac_nids = alc861_dac_nids,
  6841. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6842. .channel_mode = alc883_3ST_2ch_modes,
  6843. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6844. .adc_nids = alc861_adc_nids,
  6845. .input_mux = &alc861_capture_source,
  6846. .unsol_event = alc861_toshiba_unsol_event,
  6847. .init_hook = alc861_toshiba_automute,
  6848. },
  6849. [ALC861_ASUS] = {
  6850. .mixers = { alc861_asus_mixer },
  6851. .init_verbs = { alc861_asus_init_verbs },
  6852. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6853. .dac_nids = alc861_dac_nids,
  6854. .dig_out_nid = ALC861_DIGOUT_NID,
  6855. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  6856. .channel_mode = alc861_asus_modes,
  6857. .need_dac_fix = 1,
  6858. .hp_nid = 0x06,
  6859. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6860. .adc_nids = alc861_adc_nids,
  6861. .input_mux = &alc861_capture_source,
  6862. },
  6863. };
  6864. static int patch_alc861(struct hda_codec *codec)
  6865. {
  6866. struct alc_spec *spec;
  6867. int board_config;
  6868. int err;
  6869. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  6870. if (spec == NULL)
  6871. return -ENOMEM;
  6872. codec->spec = spec;
  6873. board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
  6874. if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
  6875. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  6876. "trying auto-probe from BIOS...\n");
  6877. board_config = ALC861_AUTO;
  6878. }
  6879. if (board_config == ALC861_AUTO) {
  6880. /* automatic parse from the BIOS config */
  6881. err = alc861_parse_auto_config(codec);
  6882. if (err < 0) {
  6883. alc_free(codec);
  6884. return err;
  6885. } else if (! err) {
  6886. printk(KERN_INFO
  6887. "hda_codec: Cannot set up configuration "
  6888. "from BIOS. Using base mode...\n");
  6889. board_config = ALC861_3ST_DIG;
  6890. }
  6891. }
  6892. if (board_config != ALC861_AUTO)
  6893. setup_preset(spec, &alc861_presets[board_config]);
  6894. spec->stream_name_analog = "ALC861 Analog";
  6895. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  6896. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  6897. spec->stream_name_digital = "ALC861 Digital";
  6898. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  6899. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  6900. codec->patch_ops = alc_patch_ops;
  6901. if (board_config == ALC861_AUTO)
  6902. spec->init_hook = alc861_auto_init;
  6903. return 0;
  6904. }
  6905. /*
  6906. * patch entries
  6907. */
  6908. struct hda_codec_preset snd_hda_preset_realtek[] = {
  6909. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  6910. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  6911. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  6912. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  6913. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  6914. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  6915. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  6916. { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
  6917. .patch = patch_alc861 },
  6918. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  6919. .patch = patch_alc861 },
  6920. { .id = 0x10ec0660, .name = "ALC660", .patch = patch_alc861 },
  6921. {} /* terminator */
  6922. };