patch_realtek.c 265 KB

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