patch_realtek.c 332 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_AUTO,
  92. ALC262_MODEL_LAST /* last tag */
  93. };
  94. /* ALC861 models */
  95. enum {
  96. ALC861_3ST,
  97. ALC660_3ST,
  98. ALC861_3ST_DIG,
  99. ALC861_6ST_DIG,
  100. ALC861_UNIWILL_M31,
  101. ALC861_TOSHIBA,
  102. ALC861_ASUS,
  103. ALC861_ASUS_LAPTOP,
  104. ALC861_AUTO,
  105. ALC861_MODEL_LAST,
  106. };
  107. /* ALC861-VD models */
  108. enum {
  109. ALC660VD_3ST,
  110. ALC861VD_3ST,
  111. ALC861VD_3ST_DIG,
  112. ALC861VD_6ST_DIG,
  113. ALC861VD_AUTO,
  114. ALC861VD_MODEL_LAST,
  115. };
  116. /* ALC662 models */
  117. enum {
  118. ALC662_3ST_2ch_DIG,
  119. ALC662_3ST_6ch_DIG,
  120. ALC662_3ST_6ch,
  121. ALC662_5ST_DIG,
  122. ALC662_LENOVO_101E,
  123. ALC662_AUTO,
  124. ALC662_MODEL_LAST,
  125. };
  126. /* ALC882 models */
  127. enum {
  128. ALC882_3ST_DIG,
  129. ALC882_6ST_DIG,
  130. ALC882_ARIMA,
  131. ALC882_AUTO,
  132. ALC885_MACPRO,
  133. ALC882_MODEL_LAST,
  134. };
  135. /* ALC883 models */
  136. enum {
  137. ALC883_3ST_2ch_DIG,
  138. ALC883_3ST_6ch_DIG,
  139. ALC883_3ST_6ch,
  140. ALC883_6ST_DIG,
  141. ALC883_TARGA_DIG,
  142. ALC883_TARGA_2ch_DIG,
  143. ALC888_DEMO_BOARD,
  144. ALC883_ACER,
  145. ALC883_MEDION,
  146. ALC883_LAPTOP_EAPD,
  147. ALC883_LENOVO_101E_2ch,
  148. ALC883_AUTO,
  149. ALC883_MODEL_LAST,
  150. };
  151. /* for GPIO Poll */
  152. #define GPIO_MASK 0x03
  153. struct alc_spec {
  154. /* codec parameterization */
  155. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  156. unsigned int num_mixers;
  157. const struct hda_verb *init_verbs[5]; /* initialization verbs
  158. * don't forget NULL
  159. * termination!
  160. */
  161. unsigned int num_init_verbs;
  162. char *stream_name_analog; /* analog PCM stream */
  163. struct hda_pcm_stream *stream_analog_playback;
  164. struct hda_pcm_stream *stream_analog_capture;
  165. char *stream_name_digital; /* digital PCM stream */
  166. struct hda_pcm_stream *stream_digital_playback;
  167. struct hda_pcm_stream *stream_digital_capture;
  168. /* playback */
  169. struct hda_multi_out multiout; /* playback set-up
  170. * max_channels, dacs must be set
  171. * dig_out_nid and hp_nid are optional
  172. */
  173. /* capture */
  174. unsigned int num_adc_nids;
  175. hda_nid_t *adc_nids;
  176. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  177. /* capture source */
  178. unsigned int num_mux_defs;
  179. const struct hda_input_mux *input_mux;
  180. unsigned int cur_mux[3];
  181. /* channel model */
  182. const struct hda_channel_mode *channel_mode;
  183. int num_channel_mode;
  184. int need_dac_fix;
  185. /* PCM information */
  186. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  187. /* dynamic controls, init_verbs and input_mux */
  188. struct auto_pin_cfg autocfg;
  189. unsigned int num_kctl_alloc, num_kctl_used;
  190. struct snd_kcontrol_new *kctl_alloc;
  191. struct hda_input_mux private_imux;
  192. hda_nid_t private_dac_nids[5];
  193. /* hooks */
  194. void (*init_hook)(struct hda_codec *codec);
  195. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  196. /* for pin sensing */
  197. unsigned int sense_updated: 1;
  198. unsigned int jack_present: 1;
  199. };
  200. /*
  201. * configuration template - to be copied to the spec instance
  202. */
  203. struct alc_config_preset {
  204. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  205. * with spec
  206. */
  207. const struct hda_verb *init_verbs[5];
  208. unsigned int num_dacs;
  209. hda_nid_t *dac_nids;
  210. hda_nid_t dig_out_nid; /* optional */
  211. hda_nid_t hp_nid; /* optional */
  212. unsigned int num_adc_nids;
  213. hda_nid_t *adc_nids;
  214. hda_nid_t dig_in_nid;
  215. unsigned int num_channel_mode;
  216. const struct hda_channel_mode *channel_mode;
  217. int need_dac_fix;
  218. unsigned int num_mux_defs;
  219. const struct hda_input_mux *input_mux;
  220. void (*unsol_event)(struct hda_codec *, unsigned int);
  221. void (*init_hook)(struct hda_codec *);
  222. };
  223. /*
  224. * input MUX handling
  225. */
  226. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  227. struct snd_ctl_elem_info *uinfo)
  228. {
  229. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  230. struct alc_spec *spec = codec->spec;
  231. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  232. if (mux_idx >= spec->num_mux_defs)
  233. mux_idx = 0;
  234. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  235. }
  236. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  237. struct snd_ctl_elem_value *ucontrol)
  238. {
  239. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  240. struct alc_spec *spec = codec->spec;
  241. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  242. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  243. return 0;
  244. }
  245. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  246. struct snd_ctl_elem_value *ucontrol)
  247. {
  248. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  249. struct alc_spec *spec = codec->spec;
  250. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  251. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  252. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  253. spec->adc_nids[adc_idx],
  254. &spec->cur_mux[adc_idx]);
  255. }
  256. /*
  257. * channel mode setting
  258. */
  259. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  260. struct snd_ctl_elem_info *uinfo)
  261. {
  262. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  263. struct alc_spec *spec = codec->spec;
  264. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  265. spec->num_channel_mode);
  266. }
  267. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  268. struct snd_ctl_elem_value *ucontrol)
  269. {
  270. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  271. struct alc_spec *spec = codec->spec;
  272. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  273. spec->num_channel_mode,
  274. spec->multiout.max_channels);
  275. }
  276. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  277. struct snd_ctl_elem_value *ucontrol)
  278. {
  279. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  280. struct alc_spec *spec = codec->spec;
  281. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  282. spec->num_channel_mode,
  283. &spec->multiout.max_channels);
  284. if (err >= 0 && spec->need_dac_fix)
  285. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  286. return err;
  287. }
  288. /*
  289. * Control the mode of pin widget settings via the mixer. "pc" is used
  290. * instead of "%" to avoid consequences of accidently treating the % as
  291. * being part of a format specifier. Maximum allowed length of a value is
  292. * 63 characters plus NULL terminator.
  293. *
  294. * Note: some retasking pin complexes seem to ignore requests for input
  295. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  296. * are requested. Therefore order this list so that this behaviour will not
  297. * cause problems when mixer clients move through the enum sequentially.
  298. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  299. * March 2006.
  300. */
  301. static char *alc_pin_mode_names[] = {
  302. "Mic 50pc bias", "Mic 80pc bias",
  303. "Line in", "Line out", "Headphone out",
  304. };
  305. static unsigned char alc_pin_mode_values[] = {
  306. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  307. };
  308. /* The control can present all 5 options, or it can limit the options based
  309. * in the pin being assumed to be exclusively an input or an output pin. In
  310. * addition, "input" pins may or may not process the mic bias option
  311. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  312. * accept requests for bias as of chip versions up to March 2006) and/or
  313. * wiring in the computer.
  314. */
  315. #define ALC_PIN_DIR_IN 0x00
  316. #define ALC_PIN_DIR_OUT 0x01
  317. #define ALC_PIN_DIR_INOUT 0x02
  318. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  319. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  320. /* Info about the pin modes supported by the different pin direction modes.
  321. * For each direction the minimum and maximum values are given.
  322. */
  323. static signed char alc_pin_mode_dir_info[5][2] = {
  324. { 0, 2 }, /* ALC_PIN_DIR_IN */
  325. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  326. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  327. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  328. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  329. };
  330. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  331. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  332. #define alc_pin_mode_n_items(_dir) \
  333. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  334. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  335. struct snd_ctl_elem_info *uinfo)
  336. {
  337. unsigned int item_num = uinfo->value.enumerated.item;
  338. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  339. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  340. uinfo->count = 1;
  341. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  342. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  343. item_num = alc_pin_mode_min(dir);
  344. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  345. return 0;
  346. }
  347. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  348. struct snd_ctl_elem_value *ucontrol)
  349. {
  350. unsigned int i;
  351. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  352. hda_nid_t nid = kcontrol->private_value & 0xffff;
  353. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  354. long *valp = ucontrol->value.integer.value;
  355. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  356. AC_VERB_GET_PIN_WIDGET_CONTROL,
  357. 0x00);
  358. /* Find enumerated value for current pinctl setting */
  359. i = alc_pin_mode_min(dir);
  360. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  361. i++;
  362. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  363. return 0;
  364. }
  365. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  366. struct snd_ctl_elem_value *ucontrol)
  367. {
  368. signed int change;
  369. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  370. hda_nid_t nid = kcontrol->private_value & 0xffff;
  371. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  372. long val = *ucontrol->value.integer.value;
  373. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  374. AC_VERB_GET_PIN_WIDGET_CONTROL,
  375. 0x00);
  376. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  377. val = alc_pin_mode_min(dir);
  378. change = pinctl != alc_pin_mode_values[val];
  379. if (change) {
  380. /* Set pin mode to that requested */
  381. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  382. alc_pin_mode_values[val]);
  383. /* Also enable the retasking pin's input/output as required
  384. * for the requested pin mode. Enum values of 2 or less are
  385. * input modes.
  386. *
  387. * Dynamically switching the input/output buffers probably
  388. * reduces noise slightly (particularly on input) so we'll
  389. * do it. However, having both input and output buffers
  390. * enabled simultaneously doesn't seem to be problematic if
  391. * this turns out to be necessary in the future.
  392. */
  393. if (val <= 2) {
  394. snd_hda_codec_write(codec, nid, 0,
  395. AC_VERB_SET_AMP_GAIN_MUTE,
  396. AMP_OUT_MUTE);
  397. snd_hda_codec_write(codec, nid, 0,
  398. AC_VERB_SET_AMP_GAIN_MUTE,
  399. AMP_IN_UNMUTE(0));
  400. } else {
  401. snd_hda_codec_write(codec, nid, 0,
  402. AC_VERB_SET_AMP_GAIN_MUTE,
  403. AMP_IN_MUTE(0));
  404. snd_hda_codec_write(codec, nid, 0,
  405. AC_VERB_SET_AMP_GAIN_MUTE,
  406. AMP_OUT_UNMUTE);
  407. }
  408. }
  409. return change;
  410. }
  411. #define ALC_PIN_MODE(xname, nid, dir) \
  412. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  413. .info = alc_pin_mode_info, \
  414. .get = alc_pin_mode_get, \
  415. .put = alc_pin_mode_put, \
  416. .private_value = nid | (dir<<16) }
  417. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  418. * together using a mask with more than one bit set. This control is
  419. * currently used only by the ALC260 test model. At this stage they are not
  420. * needed for any "production" models.
  421. */
  422. #ifdef CONFIG_SND_DEBUG
  423. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  424. struct snd_ctl_elem_info *uinfo)
  425. {
  426. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  427. uinfo->count = 1;
  428. uinfo->value.integer.min = 0;
  429. uinfo->value.integer.max = 1;
  430. return 0;
  431. }
  432. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  433. struct snd_ctl_elem_value *ucontrol)
  434. {
  435. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  436. hda_nid_t nid = kcontrol->private_value & 0xffff;
  437. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  438. long *valp = ucontrol->value.integer.value;
  439. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  440. AC_VERB_GET_GPIO_DATA, 0x00);
  441. *valp = (val & mask) != 0;
  442. return 0;
  443. }
  444. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  445. struct snd_ctl_elem_value *ucontrol)
  446. {
  447. signed int change;
  448. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  449. hda_nid_t nid = kcontrol->private_value & 0xffff;
  450. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  451. long val = *ucontrol->value.integer.value;
  452. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  453. AC_VERB_GET_GPIO_DATA,
  454. 0x00);
  455. /* Set/unset the masked GPIO bit(s) as needed */
  456. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  457. if (val == 0)
  458. gpio_data &= ~mask;
  459. else
  460. gpio_data |= mask;
  461. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  462. return change;
  463. }
  464. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  465. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  466. .info = alc_gpio_data_info, \
  467. .get = alc_gpio_data_get, \
  468. .put = alc_gpio_data_put, \
  469. .private_value = nid | (mask<<16) }
  470. #endif /* CONFIG_SND_DEBUG */
  471. /* A switch control to allow the enabling of the digital IO pins on the
  472. * ALC260. This is incredibly simplistic; the intention of this control is
  473. * to provide something in the test model allowing digital outputs to be
  474. * identified if present. If models are found which can utilise these
  475. * outputs a more complete mixer control can be devised for those models if
  476. * necessary.
  477. */
  478. #ifdef CONFIG_SND_DEBUG
  479. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  480. struct snd_ctl_elem_info *uinfo)
  481. {
  482. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  483. uinfo->count = 1;
  484. uinfo->value.integer.min = 0;
  485. uinfo->value.integer.max = 1;
  486. return 0;
  487. }
  488. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  489. struct snd_ctl_elem_value *ucontrol)
  490. {
  491. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  492. hda_nid_t nid = kcontrol->private_value & 0xffff;
  493. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  494. long *valp = ucontrol->value.integer.value;
  495. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  496. AC_VERB_GET_DIGI_CONVERT, 0x00);
  497. *valp = (val & mask) != 0;
  498. return 0;
  499. }
  500. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  501. struct snd_ctl_elem_value *ucontrol)
  502. {
  503. signed int change;
  504. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  505. hda_nid_t nid = kcontrol->private_value & 0xffff;
  506. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  507. long val = *ucontrol->value.integer.value;
  508. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  509. AC_VERB_GET_DIGI_CONVERT,
  510. 0x00);
  511. /* Set/unset the masked control bit(s) as needed */
  512. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  513. if (val==0)
  514. ctrl_data &= ~mask;
  515. else
  516. ctrl_data |= mask;
  517. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  518. ctrl_data);
  519. return change;
  520. }
  521. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  522. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  523. .info = alc_spdif_ctrl_info, \
  524. .get = alc_spdif_ctrl_get, \
  525. .put = alc_spdif_ctrl_put, \
  526. .private_value = nid | (mask<<16) }
  527. #endif /* CONFIG_SND_DEBUG */
  528. /*
  529. * set up from the preset table
  530. */
  531. static void setup_preset(struct alc_spec *spec,
  532. const struct alc_config_preset *preset)
  533. {
  534. int i;
  535. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  536. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  537. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  538. i++)
  539. spec->init_verbs[spec->num_init_verbs++] =
  540. preset->init_verbs[i];
  541. spec->channel_mode = preset->channel_mode;
  542. spec->num_channel_mode = preset->num_channel_mode;
  543. spec->need_dac_fix = preset->need_dac_fix;
  544. spec->multiout.max_channels = spec->channel_mode[0].channels;
  545. spec->multiout.num_dacs = preset->num_dacs;
  546. spec->multiout.dac_nids = preset->dac_nids;
  547. spec->multiout.dig_out_nid = preset->dig_out_nid;
  548. spec->multiout.hp_nid = preset->hp_nid;
  549. spec->num_mux_defs = preset->num_mux_defs;
  550. if (!spec->num_mux_defs)
  551. spec->num_mux_defs = 1;
  552. spec->input_mux = preset->input_mux;
  553. spec->num_adc_nids = preset->num_adc_nids;
  554. spec->adc_nids = preset->adc_nids;
  555. spec->dig_in_nid = preset->dig_in_nid;
  556. spec->unsol_event = preset->unsol_event;
  557. spec->init_hook = preset->init_hook;
  558. }
  559. /* Enable GPIO mask and set output */
  560. static struct hda_verb alc_gpio1_init_verbs[] = {
  561. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  562. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  563. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  564. { }
  565. };
  566. static struct hda_verb alc_gpio2_init_verbs[] = {
  567. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  568. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  569. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  570. { }
  571. };
  572. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  573. * 31 ~ 16 : Manufacture ID
  574. * 15 ~ 8 : SKU ID
  575. * 7 ~ 0 : Assembly ID
  576. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  577. */
  578. static void alc_subsystem_id(struct hda_codec *codec,
  579. unsigned int porta, unsigned int porte,
  580. unsigned int portd)
  581. {
  582. unsigned int ass, tmp;
  583. ass = codec->subsystem_id;
  584. if (!(ass & 1))
  585. return;
  586. /* Override */
  587. tmp = (ass & 0x38) >> 3; /* external Amp control */
  588. switch (tmp) {
  589. case 1:
  590. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  591. break;
  592. case 3:
  593. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  594. break;
  595. case 5:
  596. case 6:
  597. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  598. hda_nid_t port = 0;
  599. tmp = (ass & 0x1800) >> 11;
  600. switch (tmp) {
  601. case 0: port = porta; break;
  602. case 1: port = porte; break;
  603. case 2: port = portd; break;
  604. }
  605. if (port)
  606. snd_hda_codec_write(codec, port, 0,
  607. AC_VERB_SET_EAPD_BTLENABLE,
  608. 2);
  609. }
  610. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  611. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  612. (tmp == 5 ? 0x3040 : 0x3050));
  613. break;
  614. }
  615. }
  616. /*
  617. * ALC880 3-stack model
  618. *
  619. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  620. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  621. * F-Mic = 0x1b, HP = 0x19
  622. */
  623. static hda_nid_t alc880_dac_nids[4] = {
  624. /* front, rear, clfe, rear_surr */
  625. 0x02, 0x05, 0x04, 0x03
  626. };
  627. static hda_nid_t alc880_adc_nids[3] = {
  628. /* ADC0-2 */
  629. 0x07, 0x08, 0x09,
  630. };
  631. /* The datasheet says the node 0x07 is connected from inputs,
  632. * but it shows zero connection in the real implementation on some devices.
  633. * Note: this is a 915GAV bug, fixed on 915GLV
  634. */
  635. static hda_nid_t alc880_adc_nids_alt[2] = {
  636. /* ADC1-2 */
  637. 0x08, 0x09,
  638. };
  639. #define ALC880_DIGOUT_NID 0x06
  640. #define ALC880_DIGIN_NID 0x0a
  641. static struct hda_input_mux alc880_capture_source = {
  642. .num_items = 4,
  643. .items = {
  644. { "Mic", 0x0 },
  645. { "Front Mic", 0x3 },
  646. { "Line", 0x2 },
  647. { "CD", 0x4 },
  648. },
  649. };
  650. /* channel source setting (2/6 channel selection for 3-stack) */
  651. /* 2ch mode */
  652. static struct hda_verb alc880_threestack_ch2_init[] = {
  653. /* set line-in to input, mute it */
  654. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  655. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  656. /* set mic-in to input vref 80%, mute it */
  657. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  658. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  659. { } /* end */
  660. };
  661. /* 6ch mode */
  662. static struct hda_verb alc880_threestack_ch6_init[] = {
  663. /* set line-in to output, unmute it */
  664. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  665. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  666. /* set mic-in to output, unmute it */
  667. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  668. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  669. { } /* end */
  670. };
  671. static struct hda_channel_mode alc880_threestack_modes[2] = {
  672. { 2, alc880_threestack_ch2_init },
  673. { 6, alc880_threestack_ch6_init },
  674. };
  675. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  676. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  677. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  678. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  679. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  680. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  681. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  682. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  683. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  684. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  685. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  686. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  687. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  688. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  689. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  690. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  691. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  692. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  693. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  694. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  695. {
  696. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  697. .name = "Channel Mode",
  698. .info = alc_ch_mode_info,
  699. .get = alc_ch_mode_get,
  700. .put = alc_ch_mode_put,
  701. },
  702. { } /* end */
  703. };
  704. /* capture mixer elements */
  705. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  706. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  707. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  708. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  709. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  710. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  711. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  712. {
  713. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  714. /* The multiple "Capture Source" controls confuse alsamixer
  715. * So call somewhat different..
  716. * FIXME: the controls appear in the "playback" view!
  717. */
  718. /* .name = "Capture Source", */
  719. .name = "Input Source",
  720. .count = 3,
  721. .info = alc_mux_enum_info,
  722. .get = alc_mux_enum_get,
  723. .put = alc_mux_enum_put,
  724. },
  725. { } /* end */
  726. };
  727. /* capture mixer elements (in case NID 0x07 not available) */
  728. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  729. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  730. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  731. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  732. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  733. {
  734. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  735. /* The multiple "Capture Source" controls confuse alsamixer
  736. * So call somewhat different..
  737. * FIXME: the controls appear in the "playback" view!
  738. */
  739. /* .name = "Capture Source", */
  740. .name = "Input Source",
  741. .count = 2,
  742. .info = alc_mux_enum_info,
  743. .get = alc_mux_enum_get,
  744. .put = alc_mux_enum_put,
  745. },
  746. { } /* end */
  747. };
  748. /*
  749. * ALC880 5-stack model
  750. *
  751. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  752. * Side = 0x02 (0xd)
  753. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  754. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  755. */
  756. /* additional mixers to alc880_three_stack_mixer */
  757. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  758. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  759. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  760. { } /* end */
  761. };
  762. /* channel source setting (6/8 channel selection for 5-stack) */
  763. /* 6ch mode */
  764. static struct hda_verb alc880_fivestack_ch6_init[] = {
  765. /* set line-in to input, mute it */
  766. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  767. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  768. { } /* end */
  769. };
  770. /* 8ch mode */
  771. static struct hda_verb alc880_fivestack_ch8_init[] = {
  772. /* set line-in to output, unmute it */
  773. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  774. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  775. { } /* end */
  776. };
  777. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  778. { 6, alc880_fivestack_ch6_init },
  779. { 8, alc880_fivestack_ch8_init },
  780. };
  781. /*
  782. * ALC880 6-stack model
  783. *
  784. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  785. * Side = 0x05 (0x0f)
  786. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  787. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  788. */
  789. static hda_nid_t alc880_6st_dac_nids[4] = {
  790. /* front, rear, clfe, rear_surr */
  791. 0x02, 0x03, 0x04, 0x05
  792. };
  793. static struct hda_input_mux alc880_6stack_capture_source = {
  794. .num_items = 4,
  795. .items = {
  796. { "Mic", 0x0 },
  797. { "Front Mic", 0x1 },
  798. { "Line", 0x2 },
  799. { "CD", 0x4 },
  800. },
  801. };
  802. /* fixed 8-channels */
  803. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  804. { 8, NULL },
  805. };
  806. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  807. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  808. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  809. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  810. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  811. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  812. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  813. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  814. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  815. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  816. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 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("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  820. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  821. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  822. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  823. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  824. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  825. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  826. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  827. {
  828. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  829. .name = "Channel Mode",
  830. .info = alc_ch_mode_info,
  831. .get = alc_ch_mode_get,
  832. .put = alc_ch_mode_put,
  833. },
  834. { } /* end */
  835. };
  836. /*
  837. * ALC880 W810 model
  838. *
  839. * W810 has rear IO for:
  840. * Front (DAC 02)
  841. * Surround (DAC 03)
  842. * Center/LFE (DAC 04)
  843. * Digital out (06)
  844. *
  845. * The system also has a pair of internal speakers, and a headphone jack.
  846. * These are both connected to Line2 on the codec, hence to DAC 02.
  847. *
  848. * There is a variable resistor to control the speaker or headphone
  849. * volume. This is a hardware-only device without a software API.
  850. *
  851. * Plugging headphones in will disable the internal speakers. This is
  852. * implemented in hardware, not via the driver using jack sense. In
  853. * a similar fashion, plugging into the rear socket marked "front" will
  854. * disable both the speakers and headphones.
  855. *
  856. * For input, there's a microphone jack, and an "audio in" jack.
  857. * These may not do anything useful with this driver yet, because I
  858. * haven't setup any initialization verbs for these yet...
  859. */
  860. static hda_nid_t alc880_w810_dac_nids[3] = {
  861. /* front, rear/surround, clfe */
  862. 0x02, 0x03, 0x04
  863. };
  864. /* fixed 6 channels */
  865. static struct hda_channel_mode alc880_w810_modes[1] = {
  866. { 6, NULL }
  867. };
  868. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  869. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  870. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  871. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  872. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  873. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  874. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  875. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  876. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  877. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  878. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  879. { } /* end */
  880. };
  881. /*
  882. * Z710V model
  883. *
  884. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  885. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  886. * Line = 0x1a
  887. */
  888. static hda_nid_t alc880_z71v_dac_nids[1] = {
  889. 0x02
  890. };
  891. #define ALC880_Z71V_HP_DAC 0x03
  892. /* fixed 2 channels */
  893. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  894. { 2, NULL }
  895. };
  896. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  897. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  898. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  899. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  900. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  901. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  902. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  903. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  904. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  905. { } /* end */
  906. };
  907. /* FIXME! */
  908. /*
  909. * ALC880 F1734 model
  910. *
  911. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  912. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  913. */
  914. static hda_nid_t alc880_f1734_dac_nids[1] = {
  915. 0x03
  916. };
  917. #define ALC880_F1734_HP_DAC 0x02
  918. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  919. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  920. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  921. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  922. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  923. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  924. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  925. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  926. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  927. { } /* end */
  928. };
  929. /* FIXME! */
  930. /*
  931. * ALC880 ASUS model
  932. *
  933. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  934. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  935. * Mic = 0x18, Line = 0x1a
  936. */
  937. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  938. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  939. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  940. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  941. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  942. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  943. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  944. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  945. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  946. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  947. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  948. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  949. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  950. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  951. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  952. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  953. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  954. {
  955. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  956. .name = "Channel Mode",
  957. .info = alc_ch_mode_info,
  958. .get = alc_ch_mode_get,
  959. .put = alc_ch_mode_put,
  960. },
  961. { } /* end */
  962. };
  963. /* FIXME! */
  964. /*
  965. * ALC880 ASUS W1V model
  966. *
  967. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  968. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  969. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  970. */
  971. /* additional mixers to alc880_asus_mixer */
  972. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  973. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  974. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  975. { } /* end */
  976. };
  977. /* additional mixers to alc880_asus_mixer */
  978. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  979. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  980. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  981. { } /* end */
  982. };
  983. /* TCL S700 */
  984. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  985. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  986. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  987. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  988. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  989. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  990. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  991. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  992. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  993. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  994. {
  995. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  996. /* The multiple "Capture Source" controls confuse alsamixer
  997. * So call somewhat different..
  998. * FIXME: the controls appear in the "playback" view!
  999. */
  1000. /* .name = "Capture Source", */
  1001. .name = "Input Source",
  1002. .count = 1,
  1003. .info = alc_mux_enum_info,
  1004. .get = alc_mux_enum_get,
  1005. .put = alc_mux_enum_put,
  1006. },
  1007. { } /* end */
  1008. };
  1009. /* Uniwill */
  1010. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1011. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1012. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1013. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1014. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1015. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1016. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1017. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1018. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1019. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1020. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1021. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1022. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1023. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1024. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1025. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1026. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1027. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1028. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1029. {
  1030. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1031. .name = "Channel Mode",
  1032. .info = alc_ch_mode_info,
  1033. .get = alc_ch_mode_get,
  1034. .put = alc_ch_mode_put,
  1035. },
  1036. { } /* end */
  1037. };
  1038. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1039. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1040. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1041. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1042. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1043. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1044. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1045. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1046. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1047. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1048. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1049. { } /* end */
  1050. };
  1051. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1052. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1053. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1054. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1055. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1056. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1057. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1058. { } /* end */
  1059. };
  1060. /*
  1061. * build control elements
  1062. */
  1063. static int alc_build_controls(struct hda_codec *codec)
  1064. {
  1065. struct alc_spec *spec = codec->spec;
  1066. int err;
  1067. int i;
  1068. for (i = 0; i < spec->num_mixers; i++) {
  1069. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1070. if (err < 0)
  1071. return err;
  1072. }
  1073. if (spec->multiout.dig_out_nid) {
  1074. err = snd_hda_create_spdif_out_ctls(codec,
  1075. spec->multiout.dig_out_nid);
  1076. if (err < 0)
  1077. return err;
  1078. }
  1079. if (spec->dig_in_nid) {
  1080. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1081. if (err < 0)
  1082. return err;
  1083. }
  1084. return 0;
  1085. }
  1086. /*
  1087. * initialize the codec volumes, etc
  1088. */
  1089. /*
  1090. * generic initialization of ADC, input mixers and output mixers
  1091. */
  1092. static struct hda_verb alc880_volume_init_verbs[] = {
  1093. /*
  1094. * Unmute ADC0-2 and set the default input to mic-in
  1095. */
  1096. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1097. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1098. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1099. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1100. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1101. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1102. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1103. * mixer widget
  1104. * Note: PASD motherboards uses the Line In 2 as the input for front
  1105. * panel mic (mic 2)
  1106. */
  1107. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1108. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1109. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1110. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1111. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1112. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1113. /*
  1114. * Set up output mixers (0x0c - 0x0f)
  1115. */
  1116. /* set vol=0 to output mixers */
  1117. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1118. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1119. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1120. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1121. /* set up input amps for analog loopback */
  1122. /* Amp Indices: DAC = 0, mixer = 1 */
  1123. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1124. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1125. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1126. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1127. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1128. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1129. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1130. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1131. { }
  1132. };
  1133. /*
  1134. * 3-stack pin configuration:
  1135. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1136. */
  1137. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1138. /*
  1139. * preset connection lists of input pins
  1140. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1141. */
  1142. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1143. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1144. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1145. /*
  1146. * Set pin mode and muting
  1147. */
  1148. /* set front pin widgets 0x14 for output */
  1149. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1150. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1151. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1152. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1153. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1154. /* Mic2 (as headphone out) for HP output */
  1155. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1156. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1157. /* Line In pin widget for input */
  1158. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1159. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1160. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1161. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1162. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1163. /* CD pin widget for input */
  1164. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1165. { }
  1166. };
  1167. /*
  1168. * 5-stack pin configuration:
  1169. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1170. * line-in/side = 0x1a, f-mic = 0x1b
  1171. */
  1172. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1173. /*
  1174. * preset connection lists of input pins
  1175. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1176. */
  1177. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1178. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1179. /*
  1180. * Set pin mode and muting
  1181. */
  1182. /* set pin widgets 0x14-0x17 for output */
  1183. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1184. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1185. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1186. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1187. /* unmute pins for output (no gain on this amp) */
  1188. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1189. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1190. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1191. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1192. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1193. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1194. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1195. /* Mic2 (as headphone out) for HP output */
  1196. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1197. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1198. /* Line In pin widget for input */
  1199. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1200. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1201. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1202. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1203. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1204. /* CD pin widget for input */
  1205. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1206. { }
  1207. };
  1208. /*
  1209. * W810 pin configuration:
  1210. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1211. */
  1212. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1213. /* hphone/speaker input selector: front DAC */
  1214. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1215. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1216. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1217. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1218. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1219. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1220. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1221. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1222. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1223. { }
  1224. };
  1225. /*
  1226. * Z71V pin configuration:
  1227. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1228. */
  1229. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1230. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1231. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1232. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1233. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1234. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1235. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1236. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1237. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1238. { }
  1239. };
  1240. /*
  1241. * 6-stack pin configuration:
  1242. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1243. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1244. */
  1245. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1246. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1247. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1248. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1249. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1250. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1251. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1253. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1254. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1255. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1256. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1257. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1258. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1259. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1260. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1261. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1262. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1263. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1264. { }
  1265. };
  1266. /*
  1267. * Uniwill pin configuration:
  1268. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1269. * line = 0x1a
  1270. */
  1271. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1272. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1273. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1274. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1275. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1276. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1277. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1278. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1279. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1280. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1281. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1282. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1283. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1284. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1285. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1286. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1287. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1288. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1289. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1290. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1291. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1292. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1293. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1294. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1295. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1296. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1297. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1298. { }
  1299. };
  1300. /*
  1301. * Uniwill P53
  1302. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1303. */
  1304. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1305. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1306. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1307. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1308. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1309. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1310. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1311. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1312. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1313. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1314. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1315. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1316. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1317. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1318. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1319. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1320. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1321. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1322. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1323. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1324. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1325. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1326. { }
  1327. };
  1328. static struct hda_verb alc880_beep_init_verbs[] = {
  1329. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1330. { }
  1331. };
  1332. /* toggle speaker-output according to the hp-jack state */
  1333. static void alc880_uniwill_automute(struct hda_codec *codec)
  1334. {
  1335. unsigned int present;
  1336. unsigned char bits;
  1337. present = snd_hda_codec_read(codec, 0x14, 0,
  1338. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1339. bits = present ? 0x80 : 0;
  1340. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1341. 0x80, bits);
  1342. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1343. 0x80, bits);
  1344. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1345. 0x80, bits);
  1346. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1347. 0x80, bits);
  1348. present = snd_hda_codec_read(codec, 0x18, 0,
  1349. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1350. snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1351. 0x7000 | (0x01 << 8) | bits);
  1352. }
  1353. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1354. unsigned int res)
  1355. {
  1356. /* Looks like the unsol event is incompatible with the standard
  1357. * definition. 4bit tag is placed at 28 bit!
  1358. */
  1359. if ((res >> 28) == ALC880_HP_EVENT ||
  1360. (res >> 28) == ALC880_MIC_EVENT)
  1361. alc880_uniwill_automute(codec);
  1362. }
  1363. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1364. {
  1365. unsigned int present;
  1366. unsigned char bits;
  1367. present = snd_hda_codec_read(codec, 0x14, 0,
  1368. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1369. bits = present ? 0x80 : 0;
  1370. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1371. 0x80, bits);
  1372. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1373. 0x80, bits);
  1374. }
  1375. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1376. {
  1377. unsigned int present;
  1378. present = snd_hda_codec_read(codec, 0x21, 0,
  1379. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1380. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1381. 0x7f, present);
  1382. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1383. 0x7f, present);
  1384. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1385. 0x7f, present);
  1386. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1387. 0x7f, present);
  1388. }
  1389. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1390. unsigned int res)
  1391. {
  1392. /* Looks like the unsol event is incompatible with the standard
  1393. * definition. 4bit tag is placed at 28 bit!
  1394. */
  1395. if ((res >> 28) == ALC880_HP_EVENT)
  1396. alc880_uniwill_p53_hp_automute(codec);
  1397. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1398. alc880_uniwill_p53_dcvol_automute(codec);
  1399. }
  1400. /* FIXME! */
  1401. /*
  1402. * F1734 pin configuration:
  1403. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1404. */
  1405. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1406. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1407. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1408. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1409. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1410. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1411. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1412. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1413. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1414. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1415. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1416. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1417. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1418. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1419. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1420. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1421. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1422. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1423. { }
  1424. };
  1425. /* FIXME! */
  1426. /*
  1427. * ASUS pin configuration:
  1428. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1429. */
  1430. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1431. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1432. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1433. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1434. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1435. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1436. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1437. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1438. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1439. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1440. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1441. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1442. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1443. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1444. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1445. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1446. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1447. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1448. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1449. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1450. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1451. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1452. { }
  1453. };
  1454. /* Enable GPIO mask and set output */
  1455. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1456. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1457. /* Clevo m520g init */
  1458. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1459. /* headphone output */
  1460. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1461. /* line-out */
  1462. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1463. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1464. /* Line-in */
  1465. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1466. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1467. /* CD */
  1468. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1469. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1470. /* Mic1 (rear panel) */
  1471. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1472. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1473. /* Mic2 (front panel) */
  1474. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1475. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1476. /* headphone */
  1477. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1478. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1479. /* change to EAPD mode */
  1480. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1481. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1482. { }
  1483. };
  1484. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1485. /* change to EAPD mode */
  1486. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1487. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1488. /* Headphone output */
  1489. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1490. /* Front output*/
  1491. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1492. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1493. /* Line In pin widget for input */
  1494. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1495. /* CD pin widget for input */
  1496. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1497. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1498. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1499. /* change to EAPD mode */
  1500. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1501. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1502. { }
  1503. };
  1504. /*
  1505. * LG m1 express dual
  1506. *
  1507. * Pin assignment:
  1508. * Rear Line-In/Out (blue): 0x14
  1509. * Build-in Mic-In: 0x15
  1510. * Speaker-out: 0x17
  1511. * HP-Out (green): 0x1b
  1512. * Mic-In/Out (red): 0x19
  1513. * SPDIF-Out: 0x1e
  1514. */
  1515. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1516. static hda_nid_t alc880_lg_dac_nids[3] = {
  1517. 0x05, 0x02, 0x03
  1518. };
  1519. /* seems analog CD is not working */
  1520. static struct hda_input_mux alc880_lg_capture_source = {
  1521. .num_items = 3,
  1522. .items = {
  1523. { "Mic", 0x1 },
  1524. { "Line", 0x5 },
  1525. { "Internal Mic", 0x6 },
  1526. },
  1527. };
  1528. /* 2,4,6 channel modes */
  1529. static struct hda_verb alc880_lg_ch2_init[] = {
  1530. /* set line-in and mic-in to input */
  1531. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1532. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1533. { }
  1534. };
  1535. static struct hda_verb alc880_lg_ch4_init[] = {
  1536. /* set line-in to out and mic-in to input */
  1537. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1538. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1539. { }
  1540. };
  1541. static struct hda_verb alc880_lg_ch6_init[] = {
  1542. /* set line-in and mic-in to output */
  1543. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1544. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1545. { }
  1546. };
  1547. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1548. { 2, alc880_lg_ch2_init },
  1549. { 4, alc880_lg_ch4_init },
  1550. { 6, alc880_lg_ch6_init },
  1551. };
  1552. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1553. /* FIXME: it's not really "master" but front channels */
  1554. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1555. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1556. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1557. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1558. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1559. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1560. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1561. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1562. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1563. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1564. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1565. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1566. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1567. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1568. {
  1569. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1570. .name = "Channel Mode",
  1571. .info = alc_ch_mode_info,
  1572. .get = alc_ch_mode_get,
  1573. .put = alc_ch_mode_put,
  1574. },
  1575. { } /* end */
  1576. };
  1577. static struct hda_verb alc880_lg_init_verbs[] = {
  1578. /* set capture source to mic-in */
  1579. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1580. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1581. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1582. /* mute all amp mixer inputs */
  1583. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1584. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1585. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1586. /* line-in to input */
  1587. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1588. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1589. /* built-in mic */
  1590. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1591. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1592. /* speaker-out */
  1593. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1594. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1595. /* mic-in to input */
  1596. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1597. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1598. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1599. /* HP-out */
  1600. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1601. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1602. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1603. /* jack sense */
  1604. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1605. { }
  1606. };
  1607. /* toggle speaker-output according to the hp-jack state */
  1608. static void alc880_lg_automute(struct hda_codec *codec)
  1609. {
  1610. unsigned int present;
  1611. unsigned char bits;
  1612. present = snd_hda_codec_read(codec, 0x1b, 0,
  1613. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1614. bits = present ? 0x80 : 0;
  1615. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1616. 0x80, bits);
  1617. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1618. 0x80, bits);
  1619. }
  1620. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1621. {
  1622. /* Looks like the unsol event is incompatible with the standard
  1623. * definition. 4bit tag is placed at 28 bit!
  1624. */
  1625. if ((res >> 28) == 0x01)
  1626. alc880_lg_automute(codec);
  1627. }
  1628. /*
  1629. * LG LW20
  1630. *
  1631. * Pin assignment:
  1632. * Speaker-out: 0x14
  1633. * Mic-In: 0x18
  1634. * Built-in Mic-In: 0x19 (?)
  1635. * HP-Out: 0x1b
  1636. * SPDIF-Out: 0x1e
  1637. */
  1638. /* seems analog CD is not working */
  1639. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1640. .num_items = 2,
  1641. .items = {
  1642. { "Mic", 0x0 },
  1643. { "Internal Mic", 0x1 },
  1644. },
  1645. };
  1646. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1647. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1648. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1649. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1650. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1651. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1652. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1653. { } /* end */
  1654. };
  1655. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1656. /* set capture source to mic-in */
  1657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1658. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1659. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1660. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1661. /* speaker-out */
  1662. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1663. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1664. /* HP-out */
  1665. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1666. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1667. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1668. /* mic-in to input */
  1669. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1670. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1671. /* built-in mic */
  1672. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1673. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1674. /* jack sense */
  1675. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1676. { }
  1677. };
  1678. /* toggle speaker-output according to the hp-jack state */
  1679. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1680. {
  1681. unsigned int present;
  1682. unsigned char bits;
  1683. present = snd_hda_codec_read(codec, 0x1b, 0,
  1684. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1685. bits = present ? 0x80 : 0;
  1686. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1687. 0x80, bits);
  1688. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1689. 0x80, bits);
  1690. }
  1691. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1692. {
  1693. /* Looks like the unsol event is incompatible with the standard
  1694. * definition. 4bit tag is placed at 28 bit!
  1695. */
  1696. if ((res >> 28) == 0x01)
  1697. alc880_lg_lw_automute(codec);
  1698. }
  1699. /*
  1700. * Common callbacks
  1701. */
  1702. static int alc_init(struct hda_codec *codec)
  1703. {
  1704. struct alc_spec *spec = codec->spec;
  1705. unsigned int i;
  1706. for (i = 0; i < spec->num_init_verbs; i++)
  1707. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1708. if (spec->init_hook)
  1709. spec->init_hook(codec);
  1710. return 0;
  1711. }
  1712. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1713. {
  1714. struct alc_spec *spec = codec->spec;
  1715. if (spec->unsol_event)
  1716. spec->unsol_event(codec, res);
  1717. }
  1718. #ifdef CONFIG_PM
  1719. /*
  1720. * resume
  1721. */
  1722. static int alc_resume(struct hda_codec *codec)
  1723. {
  1724. struct alc_spec *spec = codec->spec;
  1725. int i;
  1726. alc_init(codec);
  1727. for (i = 0; i < spec->num_mixers; i++)
  1728. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1729. if (spec->multiout.dig_out_nid)
  1730. snd_hda_resume_spdif_out(codec);
  1731. if (spec->dig_in_nid)
  1732. snd_hda_resume_spdif_in(codec);
  1733. return 0;
  1734. }
  1735. #endif
  1736. /*
  1737. * Analog playback callbacks
  1738. */
  1739. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1740. struct hda_codec *codec,
  1741. struct snd_pcm_substream *substream)
  1742. {
  1743. struct alc_spec *spec = codec->spec;
  1744. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1745. }
  1746. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1747. struct hda_codec *codec,
  1748. unsigned int stream_tag,
  1749. unsigned int format,
  1750. struct snd_pcm_substream *substream)
  1751. {
  1752. struct alc_spec *spec = codec->spec;
  1753. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1754. stream_tag, format, substream);
  1755. }
  1756. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1757. struct hda_codec *codec,
  1758. struct snd_pcm_substream *substream)
  1759. {
  1760. struct alc_spec *spec = codec->spec;
  1761. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1762. }
  1763. /*
  1764. * Digital out
  1765. */
  1766. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1767. struct hda_codec *codec,
  1768. struct snd_pcm_substream *substream)
  1769. {
  1770. struct alc_spec *spec = codec->spec;
  1771. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1772. }
  1773. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1774. struct hda_codec *codec,
  1775. unsigned int stream_tag,
  1776. unsigned int format,
  1777. struct snd_pcm_substream *substream)
  1778. {
  1779. struct alc_spec *spec = codec->spec;
  1780. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1781. stream_tag, format, substream);
  1782. }
  1783. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1784. struct hda_codec *codec,
  1785. struct snd_pcm_substream *substream)
  1786. {
  1787. struct alc_spec *spec = codec->spec;
  1788. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1789. }
  1790. /*
  1791. * Analog capture
  1792. */
  1793. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1794. struct hda_codec *codec,
  1795. unsigned int stream_tag,
  1796. unsigned int format,
  1797. struct snd_pcm_substream *substream)
  1798. {
  1799. struct alc_spec *spec = codec->spec;
  1800. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1801. stream_tag, 0, format);
  1802. return 0;
  1803. }
  1804. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1805. struct hda_codec *codec,
  1806. struct snd_pcm_substream *substream)
  1807. {
  1808. struct alc_spec *spec = codec->spec;
  1809. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1810. 0, 0, 0);
  1811. return 0;
  1812. }
  1813. /*
  1814. */
  1815. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1816. .substreams = 1,
  1817. .channels_min = 2,
  1818. .channels_max = 8,
  1819. /* NID is set in alc_build_pcms */
  1820. .ops = {
  1821. .open = alc880_playback_pcm_open,
  1822. .prepare = alc880_playback_pcm_prepare,
  1823. .cleanup = alc880_playback_pcm_cleanup
  1824. },
  1825. };
  1826. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1827. .substreams = 2,
  1828. .channels_min = 2,
  1829. .channels_max = 2,
  1830. /* NID is set in alc_build_pcms */
  1831. .ops = {
  1832. .prepare = alc880_capture_pcm_prepare,
  1833. .cleanup = alc880_capture_pcm_cleanup
  1834. },
  1835. };
  1836. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1837. .substreams = 1,
  1838. .channels_min = 2,
  1839. .channels_max = 2,
  1840. /* NID is set in alc_build_pcms */
  1841. .ops = {
  1842. .open = alc880_dig_playback_pcm_open,
  1843. .close = alc880_dig_playback_pcm_close,
  1844. .prepare = alc880_dig_playback_pcm_prepare
  1845. },
  1846. };
  1847. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1848. .substreams = 1,
  1849. .channels_min = 2,
  1850. .channels_max = 2,
  1851. /* NID is set in alc_build_pcms */
  1852. };
  1853. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1854. static struct hda_pcm_stream alc_pcm_null_playback = {
  1855. .substreams = 0,
  1856. .channels_min = 0,
  1857. .channels_max = 0,
  1858. };
  1859. static int alc_build_pcms(struct hda_codec *codec)
  1860. {
  1861. struct alc_spec *spec = codec->spec;
  1862. struct hda_pcm *info = spec->pcm_rec;
  1863. int i;
  1864. codec->num_pcms = 1;
  1865. codec->pcm_info = info;
  1866. info->name = spec->stream_name_analog;
  1867. if (spec->stream_analog_playback) {
  1868. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1869. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1870. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1871. }
  1872. if (spec->stream_analog_capture) {
  1873. snd_assert(spec->adc_nids, return -EINVAL);
  1874. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1875. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1876. }
  1877. if (spec->channel_mode) {
  1878. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1879. for (i = 0; i < spec->num_channel_mode; i++) {
  1880. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1881. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1882. }
  1883. }
  1884. }
  1885. /* SPDIF for stream index #1 */
  1886. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1887. codec->num_pcms = 2;
  1888. info = spec->pcm_rec + 1;
  1889. info->name = spec->stream_name_digital;
  1890. if (spec->multiout.dig_out_nid &&
  1891. spec->stream_digital_playback) {
  1892. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1893. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1894. }
  1895. if (spec->dig_in_nid &&
  1896. spec->stream_digital_capture) {
  1897. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1898. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1899. }
  1900. }
  1901. /* If the use of more than one ADC is requested for the current
  1902. * model, configure a second analog capture-only PCM.
  1903. */
  1904. /* Additional Analaog capture for index #2 */
  1905. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1906. spec->adc_nids) {
  1907. codec->num_pcms = 3;
  1908. info = spec->pcm_rec + 2;
  1909. info->name = spec->stream_name_analog;
  1910. /* No playback stream for second PCM */
  1911. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1912. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1913. if (spec->stream_analog_capture) {
  1914. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1915. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1916. }
  1917. }
  1918. return 0;
  1919. }
  1920. static void alc_free(struct hda_codec *codec)
  1921. {
  1922. struct alc_spec *spec = codec->spec;
  1923. unsigned int i;
  1924. if (!spec)
  1925. return;
  1926. if (spec->kctl_alloc) {
  1927. for (i = 0; i < spec->num_kctl_used; i++)
  1928. kfree(spec->kctl_alloc[i].name);
  1929. kfree(spec->kctl_alloc);
  1930. }
  1931. kfree(spec);
  1932. }
  1933. /*
  1934. */
  1935. static struct hda_codec_ops alc_patch_ops = {
  1936. .build_controls = alc_build_controls,
  1937. .build_pcms = alc_build_pcms,
  1938. .init = alc_init,
  1939. .free = alc_free,
  1940. .unsol_event = alc_unsol_event,
  1941. #ifdef CONFIG_PM
  1942. .resume = alc_resume,
  1943. #endif
  1944. };
  1945. /*
  1946. * Test configuration for debugging
  1947. *
  1948. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1949. * enum controls.
  1950. */
  1951. #ifdef CONFIG_SND_DEBUG
  1952. static hda_nid_t alc880_test_dac_nids[4] = {
  1953. 0x02, 0x03, 0x04, 0x05
  1954. };
  1955. static struct hda_input_mux alc880_test_capture_source = {
  1956. .num_items = 7,
  1957. .items = {
  1958. { "In-1", 0x0 },
  1959. { "In-2", 0x1 },
  1960. { "In-3", 0x2 },
  1961. { "In-4", 0x3 },
  1962. { "CD", 0x4 },
  1963. { "Front", 0x5 },
  1964. { "Surround", 0x6 },
  1965. },
  1966. };
  1967. static struct hda_channel_mode alc880_test_modes[4] = {
  1968. { 2, NULL },
  1969. { 4, NULL },
  1970. { 6, NULL },
  1971. { 8, NULL },
  1972. };
  1973. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  1974. struct snd_ctl_elem_info *uinfo)
  1975. {
  1976. static char *texts[] = {
  1977. "N/A", "Line Out", "HP Out",
  1978. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1979. };
  1980. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1981. uinfo->count = 1;
  1982. uinfo->value.enumerated.items = 8;
  1983. if (uinfo->value.enumerated.item >= 8)
  1984. uinfo->value.enumerated.item = 7;
  1985. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1986. return 0;
  1987. }
  1988. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  1989. struct snd_ctl_elem_value *ucontrol)
  1990. {
  1991. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1992. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1993. unsigned int pin_ctl, item = 0;
  1994. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1995. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1996. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1997. if (pin_ctl & AC_PINCTL_HP_EN)
  1998. item = 2;
  1999. else
  2000. item = 1;
  2001. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2002. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2003. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2004. case AC_PINCTL_VREF_50: item = 4; break;
  2005. case AC_PINCTL_VREF_GRD: item = 5; break;
  2006. case AC_PINCTL_VREF_80: item = 6; break;
  2007. case AC_PINCTL_VREF_100: item = 7; break;
  2008. }
  2009. }
  2010. ucontrol->value.enumerated.item[0] = item;
  2011. return 0;
  2012. }
  2013. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2014. struct snd_ctl_elem_value *ucontrol)
  2015. {
  2016. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2017. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2018. static unsigned int ctls[] = {
  2019. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2020. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2021. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2022. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2023. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2024. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2025. };
  2026. unsigned int old_ctl, new_ctl;
  2027. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2028. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2029. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2030. if (old_ctl != new_ctl) {
  2031. snd_hda_codec_write(codec, nid, 0,
  2032. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2033. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2034. (ucontrol->value.enumerated.item[0] >= 3 ?
  2035. 0xb080 : 0xb000));
  2036. return 1;
  2037. }
  2038. return 0;
  2039. }
  2040. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2041. struct snd_ctl_elem_info *uinfo)
  2042. {
  2043. static char *texts[] = {
  2044. "Front", "Surround", "CLFE", "Side"
  2045. };
  2046. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2047. uinfo->count = 1;
  2048. uinfo->value.enumerated.items = 4;
  2049. if (uinfo->value.enumerated.item >= 4)
  2050. uinfo->value.enumerated.item = 3;
  2051. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2052. return 0;
  2053. }
  2054. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2055. struct snd_ctl_elem_value *ucontrol)
  2056. {
  2057. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2058. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2059. unsigned int sel;
  2060. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2061. ucontrol->value.enumerated.item[0] = sel & 3;
  2062. return 0;
  2063. }
  2064. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2065. struct snd_ctl_elem_value *ucontrol)
  2066. {
  2067. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2068. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2069. unsigned int sel;
  2070. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2071. if (ucontrol->value.enumerated.item[0] != sel) {
  2072. sel = ucontrol->value.enumerated.item[0] & 3;
  2073. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2074. return 1;
  2075. }
  2076. return 0;
  2077. }
  2078. #define PIN_CTL_TEST(xname,nid) { \
  2079. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2080. .name = xname, \
  2081. .info = alc_test_pin_ctl_info, \
  2082. .get = alc_test_pin_ctl_get, \
  2083. .put = alc_test_pin_ctl_put, \
  2084. .private_value = nid \
  2085. }
  2086. #define PIN_SRC_TEST(xname,nid) { \
  2087. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2088. .name = xname, \
  2089. .info = alc_test_pin_src_info, \
  2090. .get = alc_test_pin_src_get, \
  2091. .put = alc_test_pin_src_put, \
  2092. .private_value = nid \
  2093. }
  2094. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2095. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2096. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2097. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2098. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2099. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2100. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2101. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2102. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2103. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2104. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2105. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2106. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2107. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2108. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2109. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2110. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2111. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2112. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2113. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2114. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2115. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2116. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2117. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2118. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2119. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2120. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2121. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2122. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2123. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2124. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2125. {
  2126. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2127. .name = "Channel Mode",
  2128. .info = alc_ch_mode_info,
  2129. .get = alc_ch_mode_get,
  2130. .put = alc_ch_mode_put,
  2131. },
  2132. { } /* end */
  2133. };
  2134. static struct hda_verb alc880_test_init_verbs[] = {
  2135. /* Unmute inputs of 0x0c - 0x0f */
  2136. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2137. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2138. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2139. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2140. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2141. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2142. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2143. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2144. /* Vol output for 0x0c-0x0f */
  2145. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2146. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2147. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2148. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2149. /* Set output pins 0x14-0x17 */
  2150. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2151. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2152. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2153. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2154. /* Unmute output pins 0x14-0x17 */
  2155. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2156. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2157. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2158. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2159. /* Set input pins 0x18-0x1c */
  2160. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2161. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2162. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2163. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2164. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2165. /* Mute input pins 0x18-0x1b */
  2166. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2167. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2168. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2169. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2170. /* ADC set up */
  2171. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2172. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2173. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2174. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2175. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2176. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2177. /* Analog input/passthru */
  2178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2179. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2180. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2181. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2182. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2183. { }
  2184. };
  2185. #endif
  2186. /*
  2187. */
  2188. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2189. [ALC880_3ST] = "3stack",
  2190. [ALC880_TCL_S700] = "tcl",
  2191. [ALC880_3ST_DIG] = "3stack-digout",
  2192. [ALC880_CLEVO] = "clevo",
  2193. [ALC880_5ST] = "5stack",
  2194. [ALC880_5ST_DIG] = "5stack-digout",
  2195. [ALC880_W810] = "w810",
  2196. [ALC880_Z71V] = "z71v",
  2197. [ALC880_6ST] = "6stack",
  2198. [ALC880_6ST_DIG] = "6stack-digout",
  2199. [ALC880_ASUS] = "asus",
  2200. [ALC880_ASUS_W1V] = "asus-w1v",
  2201. [ALC880_ASUS_DIG] = "asus-dig",
  2202. [ALC880_ASUS_DIG2] = "asus-dig2",
  2203. [ALC880_UNIWILL_DIG] = "uniwill",
  2204. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2205. [ALC880_FUJITSU] = "fujitsu",
  2206. [ALC880_F1734] = "F1734",
  2207. [ALC880_LG] = "lg",
  2208. [ALC880_LG_LW] = "lg-lw",
  2209. #ifdef CONFIG_SND_DEBUG
  2210. [ALC880_TEST] = "test",
  2211. #endif
  2212. [ALC880_AUTO] = "auto",
  2213. };
  2214. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2215. /* Broken BIOS configuration */
  2216. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2217. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2218. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2219. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2220. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2221. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2222. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2223. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2224. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2225. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2226. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2227. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2228. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2229. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2230. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2231. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2232. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2233. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2234. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2235. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2236. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2237. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2238. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2239. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2240. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2241. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2242. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2243. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2244. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2245. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2246. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2247. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2248. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2249. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2250. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2251. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2252. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2253. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2254. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2255. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2256. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2257. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2258. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2259. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2260. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2261. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2262. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2263. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2264. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2265. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2266. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2267. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2268. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2269. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2270. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2271. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2272. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2273. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2274. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2275. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2276. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2277. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2278. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2279. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2280. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2281. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2282. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2283. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2284. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2285. {}
  2286. };
  2287. /*
  2288. * ALC880 codec presets
  2289. */
  2290. static struct alc_config_preset alc880_presets[] = {
  2291. [ALC880_3ST] = {
  2292. .mixers = { alc880_three_stack_mixer },
  2293. .init_verbs = { alc880_volume_init_verbs,
  2294. alc880_pin_3stack_init_verbs },
  2295. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2296. .dac_nids = alc880_dac_nids,
  2297. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2298. .channel_mode = alc880_threestack_modes,
  2299. .need_dac_fix = 1,
  2300. .input_mux = &alc880_capture_source,
  2301. },
  2302. [ALC880_3ST_DIG] = {
  2303. .mixers = { alc880_three_stack_mixer },
  2304. .init_verbs = { alc880_volume_init_verbs,
  2305. alc880_pin_3stack_init_verbs },
  2306. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2307. .dac_nids = alc880_dac_nids,
  2308. .dig_out_nid = ALC880_DIGOUT_NID,
  2309. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2310. .channel_mode = alc880_threestack_modes,
  2311. .need_dac_fix = 1,
  2312. .input_mux = &alc880_capture_source,
  2313. },
  2314. [ALC880_TCL_S700] = {
  2315. .mixers = { alc880_tcl_s700_mixer },
  2316. .init_verbs = { alc880_volume_init_verbs,
  2317. alc880_pin_tcl_S700_init_verbs,
  2318. alc880_gpio2_init_verbs },
  2319. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2320. .dac_nids = alc880_dac_nids,
  2321. .hp_nid = 0x03,
  2322. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2323. .channel_mode = alc880_2_jack_modes,
  2324. .input_mux = &alc880_capture_source,
  2325. },
  2326. [ALC880_5ST] = {
  2327. .mixers = { alc880_three_stack_mixer,
  2328. alc880_five_stack_mixer},
  2329. .init_verbs = { alc880_volume_init_verbs,
  2330. alc880_pin_5stack_init_verbs },
  2331. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2332. .dac_nids = alc880_dac_nids,
  2333. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2334. .channel_mode = alc880_fivestack_modes,
  2335. .input_mux = &alc880_capture_source,
  2336. },
  2337. [ALC880_5ST_DIG] = {
  2338. .mixers = { alc880_three_stack_mixer,
  2339. alc880_five_stack_mixer },
  2340. .init_verbs = { alc880_volume_init_verbs,
  2341. alc880_pin_5stack_init_verbs },
  2342. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2343. .dac_nids = alc880_dac_nids,
  2344. .dig_out_nid = ALC880_DIGOUT_NID,
  2345. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2346. .channel_mode = alc880_fivestack_modes,
  2347. .input_mux = &alc880_capture_source,
  2348. },
  2349. [ALC880_6ST] = {
  2350. .mixers = { alc880_six_stack_mixer },
  2351. .init_verbs = { alc880_volume_init_verbs,
  2352. alc880_pin_6stack_init_verbs },
  2353. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2354. .dac_nids = alc880_6st_dac_nids,
  2355. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2356. .channel_mode = alc880_sixstack_modes,
  2357. .input_mux = &alc880_6stack_capture_source,
  2358. },
  2359. [ALC880_6ST_DIG] = {
  2360. .mixers = { alc880_six_stack_mixer },
  2361. .init_verbs = { alc880_volume_init_verbs,
  2362. alc880_pin_6stack_init_verbs },
  2363. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2364. .dac_nids = alc880_6st_dac_nids,
  2365. .dig_out_nid = ALC880_DIGOUT_NID,
  2366. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2367. .channel_mode = alc880_sixstack_modes,
  2368. .input_mux = &alc880_6stack_capture_source,
  2369. },
  2370. [ALC880_W810] = {
  2371. .mixers = { alc880_w810_base_mixer },
  2372. .init_verbs = { alc880_volume_init_verbs,
  2373. alc880_pin_w810_init_verbs,
  2374. alc880_gpio2_init_verbs },
  2375. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2376. .dac_nids = alc880_w810_dac_nids,
  2377. .dig_out_nid = ALC880_DIGOUT_NID,
  2378. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2379. .channel_mode = alc880_w810_modes,
  2380. .input_mux = &alc880_capture_source,
  2381. },
  2382. [ALC880_Z71V] = {
  2383. .mixers = { alc880_z71v_mixer },
  2384. .init_verbs = { alc880_volume_init_verbs,
  2385. alc880_pin_z71v_init_verbs },
  2386. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2387. .dac_nids = alc880_z71v_dac_nids,
  2388. .dig_out_nid = ALC880_DIGOUT_NID,
  2389. .hp_nid = 0x03,
  2390. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2391. .channel_mode = alc880_2_jack_modes,
  2392. .input_mux = &alc880_capture_source,
  2393. },
  2394. [ALC880_F1734] = {
  2395. .mixers = { alc880_f1734_mixer },
  2396. .init_verbs = { alc880_volume_init_verbs,
  2397. alc880_pin_f1734_init_verbs },
  2398. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2399. .dac_nids = alc880_f1734_dac_nids,
  2400. .hp_nid = 0x02,
  2401. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2402. .channel_mode = alc880_2_jack_modes,
  2403. .input_mux = &alc880_capture_source,
  2404. },
  2405. [ALC880_ASUS] = {
  2406. .mixers = { alc880_asus_mixer },
  2407. .init_verbs = { alc880_volume_init_verbs,
  2408. alc880_pin_asus_init_verbs,
  2409. alc880_gpio1_init_verbs },
  2410. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2411. .dac_nids = alc880_asus_dac_nids,
  2412. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2413. .channel_mode = alc880_asus_modes,
  2414. .need_dac_fix = 1,
  2415. .input_mux = &alc880_capture_source,
  2416. },
  2417. [ALC880_ASUS_DIG] = {
  2418. .mixers = { alc880_asus_mixer },
  2419. .init_verbs = { alc880_volume_init_verbs,
  2420. alc880_pin_asus_init_verbs,
  2421. alc880_gpio1_init_verbs },
  2422. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2423. .dac_nids = alc880_asus_dac_nids,
  2424. .dig_out_nid = ALC880_DIGOUT_NID,
  2425. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2426. .channel_mode = alc880_asus_modes,
  2427. .need_dac_fix = 1,
  2428. .input_mux = &alc880_capture_source,
  2429. },
  2430. [ALC880_ASUS_DIG2] = {
  2431. .mixers = { alc880_asus_mixer },
  2432. .init_verbs = { alc880_volume_init_verbs,
  2433. alc880_pin_asus_init_verbs,
  2434. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2435. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2436. .dac_nids = alc880_asus_dac_nids,
  2437. .dig_out_nid = ALC880_DIGOUT_NID,
  2438. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2439. .channel_mode = alc880_asus_modes,
  2440. .need_dac_fix = 1,
  2441. .input_mux = &alc880_capture_source,
  2442. },
  2443. [ALC880_ASUS_W1V] = {
  2444. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2445. .init_verbs = { alc880_volume_init_verbs,
  2446. alc880_pin_asus_init_verbs,
  2447. alc880_gpio1_init_verbs },
  2448. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2449. .dac_nids = alc880_asus_dac_nids,
  2450. .dig_out_nid = ALC880_DIGOUT_NID,
  2451. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2452. .channel_mode = alc880_asus_modes,
  2453. .need_dac_fix = 1,
  2454. .input_mux = &alc880_capture_source,
  2455. },
  2456. [ALC880_UNIWILL_DIG] = {
  2457. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2458. .init_verbs = { alc880_volume_init_verbs,
  2459. alc880_pin_asus_init_verbs },
  2460. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2461. .dac_nids = alc880_asus_dac_nids,
  2462. .dig_out_nid = ALC880_DIGOUT_NID,
  2463. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2464. .channel_mode = alc880_asus_modes,
  2465. .need_dac_fix = 1,
  2466. .input_mux = &alc880_capture_source,
  2467. },
  2468. [ALC880_UNIWILL] = {
  2469. .mixers = { alc880_uniwill_mixer },
  2470. .init_verbs = { alc880_volume_init_verbs,
  2471. alc880_uniwill_init_verbs },
  2472. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2473. .dac_nids = alc880_asus_dac_nids,
  2474. .dig_out_nid = ALC880_DIGOUT_NID,
  2475. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2476. .channel_mode = alc880_threestack_modes,
  2477. .need_dac_fix = 1,
  2478. .input_mux = &alc880_capture_source,
  2479. .unsol_event = alc880_uniwill_unsol_event,
  2480. .init_hook = alc880_uniwill_automute,
  2481. },
  2482. [ALC880_UNIWILL_P53] = {
  2483. .mixers = { alc880_uniwill_p53_mixer },
  2484. .init_verbs = { alc880_volume_init_verbs,
  2485. alc880_uniwill_p53_init_verbs },
  2486. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2487. .dac_nids = alc880_asus_dac_nids,
  2488. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2489. .channel_mode = alc880_threestack_modes,
  2490. .input_mux = &alc880_capture_source,
  2491. .unsol_event = alc880_uniwill_p53_unsol_event,
  2492. .init_hook = alc880_uniwill_p53_hp_automute,
  2493. },
  2494. [ALC880_FUJITSU] = {
  2495. .mixers = { alc880_fujitsu_mixer,
  2496. alc880_pcbeep_mixer, },
  2497. .init_verbs = { alc880_volume_init_verbs,
  2498. alc880_uniwill_p53_init_verbs,
  2499. alc880_beep_init_verbs },
  2500. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2501. .dac_nids = alc880_dac_nids,
  2502. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2503. .channel_mode = alc880_2_jack_modes,
  2504. .input_mux = &alc880_capture_source,
  2505. .unsol_event = alc880_uniwill_p53_unsol_event,
  2506. .init_hook = alc880_uniwill_p53_hp_automute,
  2507. },
  2508. [ALC880_CLEVO] = {
  2509. .mixers = { alc880_three_stack_mixer },
  2510. .init_verbs = { alc880_volume_init_verbs,
  2511. alc880_pin_clevo_init_verbs },
  2512. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2513. .dac_nids = alc880_dac_nids,
  2514. .hp_nid = 0x03,
  2515. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2516. .channel_mode = alc880_threestack_modes,
  2517. .need_dac_fix = 1,
  2518. .input_mux = &alc880_capture_source,
  2519. },
  2520. [ALC880_LG] = {
  2521. .mixers = { alc880_lg_mixer },
  2522. .init_verbs = { alc880_volume_init_verbs,
  2523. alc880_lg_init_verbs },
  2524. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2525. .dac_nids = alc880_lg_dac_nids,
  2526. .dig_out_nid = ALC880_DIGOUT_NID,
  2527. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2528. .channel_mode = alc880_lg_ch_modes,
  2529. .need_dac_fix = 1,
  2530. .input_mux = &alc880_lg_capture_source,
  2531. .unsol_event = alc880_lg_unsol_event,
  2532. .init_hook = alc880_lg_automute,
  2533. },
  2534. [ALC880_LG_LW] = {
  2535. .mixers = { alc880_lg_lw_mixer },
  2536. .init_verbs = { alc880_volume_init_verbs,
  2537. alc880_lg_lw_init_verbs },
  2538. .num_dacs = 1,
  2539. .dac_nids = alc880_dac_nids,
  2540. .dig_out_nid = ALC880_DIGOUT_NID,
  2541. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2542. .channel_mode = alc880_2_jack_modes,
  2543. .input_mux = &alc880_lg_lw_capture_source,
  2544. .unsol_event = alc880_lg_lw_unsol_event,
  2545. .init_hook = alc880_lg_lw_automute,
  2546. },
  2547. #ifdef CONFIG_SND_DEBUG
  2548. [ALC880_TEST] = {
  2549. .mixers = { alc880_test_mixer },
  2550. .init_verbs = { alc880_test_init_verbs },
  2551. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2552. .dac_nids = alc880_test_dac_nids,
  2553. .dig_out_nid = ALC880_DIGOUT_NID,
  2554. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2555. .channel_mode = alc880_test_modes,
  2556. .input_mux = &alc880_test_capture_source,
  2557. },
  2558. #endif
  2559. };
  2560. /*
  2561. * Automatic parse of I/O pins from the BIOS configuration
  2562. */
  2563. #define NUM_CONTROL_ALLOC 32
  2564. #define NUM_VERB_ALLOC 32
  2565. enum {
  2566. ALC_CTL_WIDGET_VOL,
  2567. ALC_CTL_WIDGET_MUTE,
  2568. ALC_CTL_BIND_MUTE,
  2569. };
  2570. static struct snd_kcontrol_new alc880_control_templates[] = {
  2571. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2572. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2573. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2574. };
  2575. /* add dynamic controls */
  2576. static int add_control(struct alc_spec *spec, int type, const char *name,
  2577. unsigned long val)
  2578. {
  2579. struct snd_kcontrol_new *knew;
  2580. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2581. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2582. /* array + terminator */
  2583. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2584. if (!knew)
  2585. return -ENOMEM;
  2586. if (spec->kctl_alloc) {
  2587. memcpy(knew, spec->kctl_alloc,
  2588. sizeof(*knew) * spec->num_kctl_alloc);
  2589. kfree(spec->kctl_alloc);
  2590. }
  2591. spec->kctl_alloc = knew;
  2592. spec->num_kctl_alloc = num;
  2593. }
  2594. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2595. *knew = alc880_control_templates[type];
  2596. knew->name = kstrdup(name, GFP_KERNEL);
  2597. if (!knew->name)
  2598. return -ENOMEM;
  2599. knew->private_value = val;
  2600. spec->num_kctl_used++;
  2601. return 0;
  2602. }
  2603. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2604. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2605. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2606. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2607. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2608. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2609. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2610. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2611. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2612. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2613. #define ALC880_PIN_CD_NID 0x1c
  2614. /* fill in the dac_nids table from the parsed pin configuration */
  2615. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2616. const struct auto_pin_cfg *cfg)
  2617. {
  2618. hda_nid_t nid;
  2619. int assigned[4];
  2620. int i, j;
  2621. memset(assigned, 0, sizeof(assigned));
  2622. spec->multiout.dac_nids = spec->private_dac_nids;
  2623. /* check the pins hardwired to audio widget */
  2624. for (i = 0; i < cfg->line_outs; i++) {
  2625. nid = cfg->line_out_pins[i];
  2626. if (alc880_is_fixed_pin(nid)) {
  2627. int idx = alc880_fixed_pin_idx(nid);
  2628. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2629. assigned[idx] = 1;
  2630. }
  2631. }
  2632. /* left pins can be connect to any audio widget */
  2633. for (i = 0; i < cfg->line_outs; i++) {
  2634. nid = cfg->line_out_pins[i];
  2635. if (alc880_is_fixed_pin(nid))
  2636. continue;
  2637. /* search for an empty channel */
  2638. for (j = 0; j < cfg->line_outs; j++) {
  2639. if (!assigned[j]) {
  2640. spec->multiout.dac_nids[i] =
  2641. alc880_idx_to_dac(j);
  2642. assigned[j] = 1;
  2643. break;
  2644. }
  2645. }
  2646. }
  2647. spec->multiout.num_dacs = cfg->line_outs;
  2648. return 0;
  2649. }
  2650. /* add playback controls from the parsed DAC table */
  2651. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2652. const struct auto_pin_cfg *cfg)
  2653. {
  2654. char name[32];
  2655. static const char *chname[4] = {
  2656. "Front", "Surround", NULL /*CLFE*/, "Side"
  2657. };
  2658. hda_nid_t nid;
  2659. int i, err;
  2660. for (i = 0; i < cfg->line_outs; i++) {
  2661. if (!spec->multiout.dac_nids[i])
  2662. continue;
  2663. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2664. if (i == 2) {
  2665. /* Center/LFE */
  2666. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2667. "Center Playback Volume",
  2668. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2669. HDA_OUTPUT));
  2670. if (err < 0)
  2671. return err;
  2672. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2673. "LFE Playback Volume",
  2674. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2675. HDA_OUTPUT));
  2676. if (err < 0)
  2677. return err;
  2678. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2679. "Center Playback Switch",
  2680. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2681. HDA_INPUT));
  2682. if (err < 0)
  2683. return err;
  2684. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2685. "LFE Playback Switch",
  2686. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2687. HDA_INPUT));
  2688. if (err < 0)
  2689. return err;
  2690. } else {
  2691. sprintf(name, "%s Playback Volume", chname[i]);
  2692. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2693. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2694. HDA_OUTPUT));
  2695. if (err < 0)
  2696. return err;
  2697. sprintf(name, "%s Playback Switch", chname[i]);
  2698. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2699. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2700. HDA_INPUT));
  2701. if (err < 0)
  2702. return err;
  2703. }
  2704. }
  2705. return 0;
  2706. }
  2707. /* add playback controls for speaker and HP outputs */
  2708. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2709. const char *pfx)
  2710. {
  2711. hda_nid_t nid;
  2712. int err;
  2713. char name[32];
  2714. if (!pin)
  2715. return 0;
  2716. if (alc880_is_fixed_pin(pin)) {
  2717. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2718. /* specify the DAC as the extra output */
  2719. if (!spec->multiout.hp_nid)
  2720. spec->multiout.hp_nid = nid;
  2721. else
  2722. spec->multiout.extra_out_nid[0] = nid;
  2723. /* control HP volume/switch on the output mixer amp */
  2724. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2725. sprintf(name, "%s Playback Volume", pfx);
  2726. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2727. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2728. if (err < 0)
  2729. return err;
  2730. sprintf(name, "%s Playback Switch", pfx);
  2731. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2732. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2733. if (err < 0)
  2734. return err;
  2735. } else if (alc880_is_multi_pin(pin)) {
  2736. /* set manual connection */
  2737. /* we have only a switch on HP-out PIN */
  2738. sprintf(name, "%s Playback Switch", pfx);
  2739. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2740. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2741. if (err < 0)
  2742. return err;
  2743. }
  2744. return 0;
  2745. }
  2746. /* create input playback/capture controls for the given pin */
  2747. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2748. const char *ctlname,
  2749. int idx, hda_nid_t mix_nid)
  2750. {
  2751. char name[32];
  2752. int err;
  2753. sprintf(name, "%s Playback Volume", ctlname);
  2754. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2755. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2756. if (err < 0)
  2757. return err;
  2758. sprintf(name, "%s Playback Switch", ctlname);
  2759. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2760. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2761. if (err < 0)
  2762. return err;
  2763. return 0;
  2764. }
  2765. /* create playback/capture controls for input pins */
  2766. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2767. const struct auto_pin_cfg *cfg)
  2768. {
  2769. struct hda_input_mux *imux = &spec->private_imux;
  2770. int i, err, idx;
  2771. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2772. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2773. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2774. err = new_analog_input(spec, cfg->input_pins[i],
  2775. auto_pin_cfg_labels[i],
  2776. idx, 0x0b);
  2777. if (err < 0)
  2778. return err;
  2779. imux->items[imux->num_items].label =
  2780. auto_pin_cfg_labels[i];
  2781. imux->items[imux->num_items].index =
  2782. alc880_input_pin_idx(cfg->input_pins[i]);
  2783. imux->num_items++;
  2784. }
  2785. }
  2786. return 0;
  2787. }
  2788. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2789. hda_nid_t nid, int pin_type,
  2790. int dac_idx)
  2791. {
  2792. /* set as output */
  2793. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2794. pin_type);
  2795. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2796. AMP_OUT_UNMUTE);
  2797. /* need the manual connection? */
  2798. if (alc880_is_multi_pin(nid)) {
  2799. struct alc_spec *spec = codec->spec;
  2800. int idx = alc880_multi_pin_idx(nid);
  2801. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2802. AC_VERB_SET_CONNECT_SEL,
  2803. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2804. }
  2805. }
  2806. static int get_pin_type(int line_out_type)
  2807. {
  2808. if (line_out_type == AUTO_PIN_HP_OUT)
  2809. return PIN_HP;
  2810. else
  2811. return PIN_OUT;
  2812. }
  2813. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2814. {
  2815. struct alc_spec *spec = codec->spec;
  2816. int i;
  2817. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2818. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2819. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2820. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2821. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2822. }
  2823. }
  2824. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2825. {
  2826. struct alc_spec *spec = codec->spec;
  2827. hda_nid_t pin;
  2828. pin = spec->autocfg.speaker_pins[0];
  2829. if (pin) /* connect to front */
  2830. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2831. pin = spec->autocfg.hp_pins[0];
  2832. if (pin) /* connect to front */
  2833. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2834. }
  2835. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2836. {
  2837. struct alc_spec *spec = codec->spec;
  2838. int i;
  2839. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2840. hda_nid_t nid = spec->autocfg.input_pins[i];
  2841. if (alc880_is_input_pin(nid)) {
  2842. snd_hda_codec_write(codec, nid, 0,
  2843. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2844. i <= AUTO_PIN_FRONT_MIC ?
  2845. PIN_VREF80 : PIN_IN);
  2846. if (nid != ALC880_PIN_CD_NID)
  2847. snd_hda_codec_write(codec, nid, 0,
  2848. AC_VERB_SET_AMP_GAIN_MUTE,
  2849. AMP_OUT_MUTE);
  2850. }
  2851. }
  2852. }
  2853. /* parse the BIOS configuration and set up the alc_spec */
  2854. /* return 1 if successful, 0 if the proper config is not found,
  2855. * or a negative error code
  2856. */
  2857. static int alc880_parse_auto_config(struct hda_codec *codec)
  2858. {
  2859. struct alc_spec *spec = codec->spec;
  2860. int err;
  2861. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2862. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2863. alc880_ignore);
  2864. if (err < 0)
  2865. return err;
  2866. if (!spec->autocfg.line_outs)
  2867. return 0; /* can't find valid BIOS pin config */
  2868. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2869. if (err < 0)
  2870. return err;
  2871. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2872. if (err < 0)
  2873. return err;
  2874. err = alc880_auto_create_extra_out(spec,
  2875. spec->autocfg.speaker_pins[0],
  2876. "Speaker");
  2877. if (err < 0)
  2878. return err;
  2879. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2880. "Headphone");
  2881. if (err < 0)
  2882. return err;
  2883. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2884. if (err < 0)
  2885. return err;
  2886. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2887. if (spec->autocfg.dig_out_pin)
  2888. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2889. if (spec->autocfg.dig_in_pin)
  2890. spec->dig_in_nid = ALC880_DIGIN_NID;
  2891. if (spec->kctl_alloc)
  2892. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2893. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2894. spec->num_mux_defs = 1;
  2895. spec->input_mux = &spec->private_imux;
  2896. return 1;
  2897. }
  2898. /* additional initialization for auto-configuration model */
  2899. static void alc880_auto_init(struct hda_codec *codec)
  2900. {
  2901. alc880_auto_init_multi_out(codec);
  2902. alc880_auto_init_extra_out(codec);
  2903. alc880_auto_init_analog_input(codec);
  2904. }
  2905. /*
  2906. * OK, here we have finally the patch for ALC880
  2907. */
  2908. static int patch_alc880(struct hda_codec *codec)
  2909. {
  2910. struct alc_spec *spec;
  2911. int board_config;
  2912. int err;
  2913. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2914. if (spec == NULL)
  2915. return -ENOMEM;
  2916. codec->spec = spec;
  2917. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2918. alc880_models,
  2919. alc880_cfg_tbl);
  2920. if (board_config < 0) {
  2921. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2922. "trying auto-probe from BIOS...\n");
  2923. board_config = ALC880_AUTO;
  2924. }
  2925. if (board_config == ALC880_AUTO) {
  2926. /* automatic parse from the BIOS config */
  2927. err = alc880_parse_auto_config(codec);
  2928. if (err < 0) {
  2929. alc_free(codec);
  2930. return err;
  2931. } else if (!err) {
  2932. printk(KERN_INFO
  2933. "hda_codec: Cannot set up configuration "
  2934. "from BIOS. Using 3-stack mode...\n");
  2935. board_config = ALC880_3ST;
  2936. }
  2937. }
  2938. if (board_config != ALC880_AUTO)
  2939. setup_preset(spec, &alc880_presets[board_config]);
  2940. spec->stream_name_analog = "ALC880 Analog";
  2941. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2942. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2943. spec->stream_name_digital = "ALC880 Digital";
  2944. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2945. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2946. if (!spec->adc_nids && spec->input_mux) {
  2947. /* check whether NID 0x07 is valid */
  2948. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2949. /* get type */
  2950. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  2951. if (wcap != AC_WID_AUD_IN) {
  2952. spec->adc_nids = alc880_adc_nids_alt;
  2953. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2954. spec->mixers[spec->num_mixers] =
  2955. alc880_capture_alt_mixer;
  2956. spec->num_mixers++;
  2957. } else {
  2958. spec->adc_nids = alc880_adc_nids;
  2959. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2960. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2961. spec->num_mixers++;
  2962. }
  2963. }
  2964. codec->patch_ops = alc_patch_ops;
  2965. if (board_config == ALC880_AUTO)
  2966. spec->init_hook = alc880_auto_init;
  2967. return 0;
  2968. }
  2969. /*
  2970. * ALC260 support
  2971. */
  2972. static hda_nid_t alc260_dac_nids[1] = {
  2973. /* front */
  2974. 0x02,
  2975. };
  2976. static hda_nid_t alc260_adc_nids[1] = {
  2977. /* ADC0 */
  2978. 0x04,
  2979. };
  2980. static hda_nid_t alc260_adc_nids_alt[1] = {
  2981. /* ADC1 */
  2982. 0x05,
  2983. };
  2984. static hda_nid_t alc260_hp_adc_nids[2] = {
  2985. /* ADC1, 0 */
  2986. 0x05, 0x04
  2987. };
  2988. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2989. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2990. */
  2991. static hda_nid_t alc260_dual_adc_nids[2] = {
  2992. /* ADC0, ADC1 */
  2993. 0x04, 0x05
  2994. };
  2995. #define ALC260_DIGOUT_NID 0x03
  2996. #define ALC260_DIGIN_NID 0x06
  2997. static struct hda_input_mux alc260_capture_source = {
  2998. .num_items = 4,
  2999. .items = {
  3000. { "Mic", 0x0 },
  3001. { "Front Mic", 0x1 },
  3002. { "Line", 0x2 },
  3003. { "CD", 0x4 },
  3004. },
  3005. };
  3006. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3007. * headphone jack and the internal CD lines since these are the only pins at
  3008. * which audio can appear. For flexibility, also allow the option of
  3009. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3010. * connection to the mixer output).
  3011. */
  3012. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3013. {
  3014. .num_items = 3,
  3015. .items = {
  3016. { "Mic/Line", 0x0 },
  3017. { "CD", 0x4 },
  3018. { "Headphone", 0x2 },
  3019. },
  3020. },
  3021. {
  3022. .num_items = 4,
  3023. .items = {
  3024. { "Mic/Line", 0x0 },
  3025. { "CD", 0x4 },
  3026. { "Headphone", 0x2 },
  3027. { "Mixer", 0x5 },
  3028. },
  3029. },
  3030. };
  3031. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3032. * the Fujitsu S702x, but jacks are marked differently.
  3033. */
  3034. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3035. {
  3036. .num_items = 4,
  3037. .items = {
  3038. { "Mic", 0x0 },
  3039. { "Line", 0x2 },
  3040. { "CD", 0x4 },
  3041. { "Headphone", 0x5 },
  3042. },
  3043. },
  3044. {
  3045. .num_items = 5,
  3046. .items = {
  3047. { "Mic", 0x0 },
  3048. { "Line", 0x2 },
  3049. { "CD", 0x4 },
  3050. { "Headphone", 0x6 },
  3051. { "Mixer", 0x5 },
  3052. },
  3053. },
  3054. };
  3055. /*
  3056. * This is just place-holder, so there's something for alc_build_pcms to look
  3057. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3058. * element which allows changing the channel mode, so the verb list is
  3059. * never used.
  3060. */
  3061. static struct hda_channel_mode alc260_modes[1] = {
  3062. { 2, NULL },
  3063. };
  3064. /* Mixer combinations
  3065. *
  3066. * basic: base_output + input + pc_beep + capture
  3067. * HP: base_output + input + capture_alt
  3068. * HP_3013: hp_3013 + input + capture
  3069. * fujitsu: fujitsu + capture
  3070. * acer: acer + capture
  3071. */
  3072. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3073. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3074. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3075. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3076. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3077. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3078. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3079. { } /* end */
  3080. };
  3081. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3082. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3083. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3084. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3085. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3086. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3087. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3088. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3089. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3090. { } /* end */
  3091. };
  3092. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3093. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3094. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3095. { } /* end */
  3096. };
  3097. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3098. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3099. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3100. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3101. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3102. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3103. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3104. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3105. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3106. { } /* end */
  3107. };
  3108. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3109. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3110. */
  3111. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3112. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3113. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3114. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3115. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3116. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3117. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3118. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3119. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3120. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3121. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3122. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3123. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3124. { } /* end */
  3125. };
  3126. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3127. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3128. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3129. * datasheet doesn't mention this restriction. At this stage it's not clear
  3130. * whether this behaviour is intentional or is a hardware bug in chip
  3131. * revisions available in early 2006. Therefore for now allow the
  3132. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3133. * that the lack of mic bias for this NID is intentional we could change the
  3134. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3135. *
  3136. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3137. * don't appear to make the mic bias available from the "line" jack, even
  3138. * though the NID used for this jack (0x14) can supply it. The theory is
  3139. * that perhaps Acer have included blocking capacitors between the ALC260
  3140. * and the output jack. If this turns out to be the case for all such
  3141. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3142. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3143. *
  3144. * The C20x Tablet series have a mono internal speaker which is controlled
  3145. * via the chip's Mono sum widget and pin complex, so include the necessary
  3146. * controls for such models. On models without a "mono speaker" the control
  3147. * won't do anything.
  3148. */
  3149. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3150. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3151. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3152. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3153. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3154. HDA_OUTPUT),
  3155. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3156. HDA_INPUT),
  3157. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3158. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3159. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3160. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3161. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3162. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3163. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3164. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3165. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3166. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3167. { } /* end */
  3168. };
  3169. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3170. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3171. */
  3172. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3173. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3174. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3175. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3176. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3177. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3178. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3179. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3180. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3181. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3182. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3183. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3184. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3185. { } /* end */
  3186. };
  3187. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3188. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3189. */
  3190. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3191. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3192. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3193. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3194. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3195. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3196. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3197. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3198. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3199. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3200. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3201. { } /* end */
  3202. };
  3203. /* capture mixer elements */
  3204. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3205. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3206. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3207. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3208. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3209. {
  3210. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3211. /* The multiple "Capture Source" controls confuse alsamixer
  3212. * So call somewhat different..
  3213. * FIXME: the controls appear in the "playback" view!
  3214. */
  3215. /* .name = "Capture Source", */
  3216. .name = "Input Source",
  3217. .count = 2,
  3218. .info = alc_mux_enum_info,
  3219. .get = alc_mux_enum_get,
  3220. .put = alc_mux_enum_put,
  3221. },
  3222. { } /* end */
  3223. };
  3224. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3225. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3226. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3227. {
  3228. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3229. /* The multiple "Capture Source" controls confuse alsamixer
  3230. * So call somewhat different..
  3231. * FIXME: the controls appear in the "playback" view!
  3232. */
  3233. /* .name = "Capture Source", */
  3234. .name = "Input Source",
  3235. .count = 1,
  3236. .info = alc_mux_enum_info,
  3237. .get = alc_mux_enum_get,
  3238. .put = alc_mux_enum_put,
  3239. },
  3240. { } /* end */
  3241. };
  3242. /*
  3243. * initialization verbs
  3244. */
  3245. static struct hda_verb alc260_init_verbs[] = {
  3246. /* Line In pin widget for input */
  3247. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3248. /* CD pin widget for input */
  3249. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3250. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3251. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3252. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3253. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3254. /* LINE-2 is used for line-out in rear */
  3255. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3256. /* select line-out */
  3257. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3258. /* LINE-OUT pin */
  3259. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3260. /* enable HP */
  3261. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3262. /* enable Mono */
  3263. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3264. /* mute capture amp left and right */
  3265. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3266. /* set connection select to line in (default select for this ADC) */
  3267. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3268. /* mute capture amp left and right */
  3269. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3270. /* set connection select to line in (default select for this ADC) */
  3271. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3272. /* set vol=0 Line-Out mixer amp left and right */
  3273. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3274. /* unmute pin widget amp left and right (no gain on this amp) */
  3275. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3276. /* set vol=0 HP mixer amp left and right */
  3277. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3278. /* unmute pin widget amp left and right (no gain on this amp) */
  3279. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3280. /* set vol=0 Mono mixer amp left and right */
  3281. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3282. /* unmute pin widget amp left and right (no gain on this amp) */
  3283. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3284. /* unmute LINE-2 out pin */
  3285. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3286. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3287. * Line In 2 = 0x03
  3288. */
  3289. /* mute CD */
  3290. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3291. /* mute Line In */
  3292. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3293. /* mute Mic */
  3294. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3295. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3296. /* mute Front out path */
  3297. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3298. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3299. /* mute Headphone out path */
  3300. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3301. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3302. /* mute Mono out path */
  3303. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3304. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3305. { }
  3306. };
  3307. #if 0 /* should be identical with alc260_init_verbs? */
  3308. static struct hda_verb alc260_hp_init_verbs[] = {
  3309. /* Headphone and output */
  3310. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3311. /* mono output */
  3312. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3313. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3314. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3315. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3316. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3317. /* Line In pin widget for input */
  3318. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3319. /* Line-2 pin widget for output */
  3320. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3321. /* CD pin widget for input */
  3322. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3323. /* unmute amp left and right */
  3324. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3325. /* set connection select to line in (default select for this ADC) */
  3326. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3327. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3328. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3329. /* mute pin widget amp left and right (no gain on this amp) */
  3330. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3331. /* unmute HP mixer amp left and right (volume = 0) */
  3332. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3333. /* mute pin widget amp left and right (no gain on this amp) */
  3334. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3335. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3336. * Line In 2 = 0x03
  3337. */
  3338. /* unmute CD */
  3339. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3340. /* unmute Line In */
  3341. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3342. /* unmute Mic */
  3343. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3344. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3345. /* Unmute Front out path */
  3346. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3347. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3348. /* Unmute Headphone out path */
  3349. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3350. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3351. /* Unmute Mono out path */
  3352. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3353. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3354. { }
  3355. };
  3356. #endif
  3357. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3358. /* Line out and output */
  3359. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3360. /* mono output */
  3361. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3362. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3363. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3364. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3365. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3366. /* Line In pin widget for input */
  3367. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3368. /* Headphone pin widget for output */
  3369. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3370. /* CD pin widget for input */
  3371. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3372. /* unmute amp left and right */
  3373. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3374. /* set connection select to line in (default select for this ADC) */
  3375. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3376. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3377. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3378. /* mute pin widget amp left and right (no gain on this amp) */
  3379. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3380. /* unmute HP mixer amp left and right (volume = 0) */
  3381. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3382. /* mute pin widget amp left and right (no gain on this amp) */
  3383. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3384. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3385. * Line In 2 = 0x03
  3386. */
  3387. /* unmute CD */
  3388. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3389. /* unmute Line In */
  3390. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3391. /* unmute Mic */
  3392. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3393. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3394. /* Unmute Front out path */
  3395. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3396. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3397. /* Unmute Headphone out path */
  3398. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3399. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3400. /* Unmute Mono out path */
  3401. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3402. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3403. { }
  3404. };
  3405. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3406. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3407. * audio = 0x16, internal speaker = 0x10.
  3408. */
  3409. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3410. /* Disable all GPIOs */
  3411. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3412. /* Internal speaker is connected to headphone pin */
  3413. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3414. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3415. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3416. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3417. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3418. /* Ensure all other unused pins are disabled and muted. */
  3419. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3420. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3421. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3422. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3423. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3424. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3425. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3426. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3427. /* Disable digital (SPDIF) pins */
  3428. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3429. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3430. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3431. * when acting as an output.
  3432. */
  3433. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3434. /* Start with output sum widgets muted and their output gains at min */
  3435. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3436. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3437. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3438. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3439. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3440. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3441. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3442. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3443. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3444. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3445. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3446. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3447. * If the pin mode is changed by the user the pin mode control will
  3448. * take care of enabling the pin's input/output buffers as needed.
  3449. * Therefore there's no need to enable the input buffer at this
  3450. * stage.
  3451. */
  3452. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3453. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3454. * mixer ctrl)
  3455. */
  3456. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3457. /* Mute capture amp left and right */
  3458. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3459. /* Set ADC connection select to match default mixer setting - line
  3460. * in (on mic1 pin)
  3461. */
  3462. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3463. /* Do the same for the second ADC: mute capture input amp and
  3464. * set ADC connection to line in (on mic1 pin)
  3465. */
  3466. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3467. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3468. /* Mute all inputs to mixer widget (even unconnected ones) */
  3469. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3470. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3471. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3472. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3473. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3474. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3475. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3476. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3477. { }
  3478. };
  3479. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3480. * similar laptops (adapted from Fujitsu init verbs).
  3481. */
  3482. static struct hda_verb alc260_acer_init_verbs[] = {
  3483. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3484. * the headphone jack. Turn this on and rely on the standard mute
  3485. * methods whenever the user wants to turn these outputs off.
  3486. */
  3487. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3488. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3489. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3490. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3491. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3492. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3493. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3494. /* Line In jack is connected to Line1 pin */
  3495. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3496. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3497. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3498. /* Ensure all other unused pins are disabled and muted. */
  3499. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3500. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3501. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3502. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3503. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3504. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3505. /* Disable digital (SPDIF) pins */
  3506. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3507. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3508. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3509. * bus when acting as outputs.
  3510. */
  3511. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3512. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3513. /* Start with output sum widgets muted and their output gains at min */
  3514. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3515. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3516. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3517. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3518. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3519. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3520. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3521. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3522. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3523. /* Unmute Line-out pin widget amp left and right
  3524. * (no equiv mixer ctrl)
  3525. */
  3526. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3527. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3528. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3529. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3530. * inputs. If the pin mode is changed by the user the pin mode control
  3531. * will take care of enabling the pin's input/output buffers as needed.
  3532. * Therefore there's no need to enable the input buffer at this
  3533. * stage.
  3534. */
  3535. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3536. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3537. /* Mute capture amp left and right */
  3538. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3539. /* Set ADC connection select to match default mixer setting - mic
  3540. * (on mic1 pin)
  3541. */
  3542. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3543. /* Do similar with the second ADC: mute capture input amp and
  3544. * set ADC connection to mic to match ALSA's default state.
  3545. */
  3546. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3547. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3548. /* Mute all inputs to mixer widget (even unconnected ones) */
  3549. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3550. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3551. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3552. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3553. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3554. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3555. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3556. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3557. { }
  3558. };
  3559. static struct hda_verb alc260_will_verbs[] = {
  3560. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3561. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3562. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3563. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3564. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3565. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3566. {}
  3567. };
  3568. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3569. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3570. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3571. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3572. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3573. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3574. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3575. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3576. {}
  3577. };
  3578. /* toggle speaker-output according to the hp-jack state */
  3579. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3580. {
  3581. unsigned int present;
  3582. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3583. present = snd_hda_codec_read(codec, 0x0f, 0,
  3584. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3585. if (present) {
  3586. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3587. snd_hda_codec_write(codec, 0x0f, 0,
  3588. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3589. } else {
  3590. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3591. snd_hda_codec_write(codec, 0x0f, 0,
  3592. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3593. }
  3594. }
  3595. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3596. unsigned int res)
  3597. {
  3598. if ((res >> 26) == ALC880_HP_EVENT)
  3599. alc260_replacer_672v_automute(codec);
  3600. }
  3601. /* Test configuration for debugging, modelled after the ALC880 test
  3602. * configuration.
  3603. */
  3604. #ifdef CONFIG_SND_DEBUG
  3605. static hda_nid_t alc260_test_dac_nids[1] = {
  3606. 0x02,
  3607. };
  3608. static hda_nid_t alc260_test_adc_nids[2] = {
  3609. 0x04, 0x05,
  3610. };
  3611. /* For testing the ALC260, each input MUX needs its own definition since
  3612. * the signal assignments are different. This assumes that the first ADC
  3613. * is NID 0x04.
  3614. */
  3615. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3616. {
  3617. .num_items = 7,
  3618. .items = {
  3619. { "MIC1 pin", 0x0 },
  3620. { "MIC2 pin", 0x1 },
  3621. { "LINE1 pin", 0x2 },
  3622. { "LINE2 pin", 0x3 },
  3623. { "CD pin", 0x4 },
  3624. { "LINE-OUT pin", 0x5 },
  3625. { "HP-OUT pin", 0x6 },
  3626. },
  3627. },
  3628. {
  3629. .num_items = 8,
  3630. .items = {
  3631. { "MIC1 pin", 0x0 },
  3632. { "MIC2 pin", 0x1 },
  3633. { "LINE1 pin", 0x2 },
  3634. { "LINE2 pin", 0x3 },
  3635. { "CD pin", 0x4 },
  3636. { "Mixer", 0x5 },
  3637. { "LINE-OUT pin", 0x6 },
  3638. { "HP-OUT pin", 0x7 },
  3639. },
  3640. },
  3641. };
  3642. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3643. /* Output driver widgets */
  3644. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3645. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3646. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3647. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3648. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3649. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3650. /* Modes for retasking pin widgets
  3651. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3652. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3653. * mention this restriction. At this stage it's not clear whether
  3654. * this behaviour is intentional or is a hardware bug in chip
  3655. * revisions available at least up until early 2006. Therefore for
  3656. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3657. * choices, but if it turns out that the lack of mic bias for these
  3658. * NIDs is intentional we could change their modes from
  3659. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3660. */
  3661. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3662. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3663. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3664. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3665. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3666. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3667. /* Loopback mixer controls */
  3668. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3669. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3670. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3671. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3672. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3673. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3674. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3675. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3676. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3677. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3678. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3679. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3680. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3681. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3682. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3683. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3684. /* Controls for GPIO pins, assuming they are configured as outputs */
  3685. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3686. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3687. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3688. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3689. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3690. * is ambigious as to which NID is which; testing on laptops which
  3691. * make this output available should provide clarification.
  3692. */
  3693. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3694. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3695. { } /* end */
  3696. };
  3697. static struct hda_verb alc260_test_init_verbs[] = {
  3698. /* Enable all GPIOs as outputs with an initial value of 0 */
  3699. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3700. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3701. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3702. /* Enable retasking pins as output, initially without power amp */
  3703. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3704. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3705. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3706. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3707. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3708. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3709. /* Disable digital (SPDIF) pins initially, but users can enable
  3710. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3711. * payload also sets the generation to 0, output to be in "consumer"
  3712. * PCM format, copyright asserted, no pre-emphasis and no validity
  3713. * control.
  3714. */
  3715. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3716. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3717. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3718. * OUT1 sum bus when acting as an output.
  3719. */
  3720. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3721. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3722. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3723. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3724. /* Start with output sum widgets muted and their output gains at min */
  3725. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3726. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3727. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3728. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3729. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3730. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3731. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3732. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3733. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3734. /* Unmute retasking pin widget output buffers since the default
  3735. * state appears to be output. As the pin mode is changed by the
  3736. * user the pin mode control will take care of enabling the pin's
  3737. * input/output buffers as needed.
  3738. */
  3739. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3740. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3741. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3742. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3743. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3744. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3745. /* Also unmute the mono-out pin widget */
  3746. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3747. /* Mute capture amp left and right */
  3748. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3749. /* Set ADC connection select to match default mixer setting (mic1
  3750. * pin)
  3751. */
  3752. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3753. /* Do the same for the second ADC: mute capture input amp and
  3754. * set ADC connection to mic1 pin
  3755. */
  3756. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3757. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3758. /* Mute all inputs to mixer widget (even unconnected ones) */
  3759. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3760. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3761. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3762. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3763. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3764. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3765. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3766. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3767. { }
  3768. };
  3769. #endif
  3770. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3771. .substreams = 1,
  3772. .channels_min = 2,
  3773. .channels_max = 2,
  3774. };
  3775. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3776. .substreams = 1,
  3777. .channels_min = 2,
  3778. .channels_max = 2,
  3779. };
  3780. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3781. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3782. /*
  3783. * for BIOS auto-configuration
  3784. */
  3785. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3786. const char *pfx)
  3787. {
  3788. hda_nid_t nid_vol;
  3789. unsigned long vol_val, sw_val;
  3790. char name[32];
  3791. int err;
  3792. if (nid >= 0x0f && nid < 0x11) {
  3793. nid_vol = nid - 0x7;
  3794. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3795. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3796. } else if (nid == 0x11) {
  3797. nid_vol = nid - 0x7;
  3798. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3799. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3800. } else if (nid >= 0x12 && nid <= 0x15) {
  3801. nid_vol = 0x08;
  3802. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3803. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3804. } else
  3805. return 0; /* N/A */
  3806. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3807. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3808. if (err < 0)
  3809. return err;
  3810. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3811. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3812. if (err < 0)
  3813. return err;
  3814. return 1;
  3815. }
  3816. /* add playback controls from the parsed DAC table */
  3817. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3818. const struct auto_pin_cfg *cfg)
  3819. {
  3820. hda_nid_t nid;
  3821. int err;
  3822. spec->multiout.num_dacs = 1;
  3823. spec->multiout.dac_nids = spec->private_dac_nids;
  3824. spec->multiout.dac_nids[0] = 0x02;
  3825. nid = cfg->line_out_pins[0];
  3826. if (nid) {
  3827. err = alc260_add_playback_controls(spec, nid, "Front");
  3828. if (err < 0)
  3829. return err;
  3830. }
  3831. nid = cfg->speaker_pins[0];
  3832. if (nid) {
  3833. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3834. if (err < 0)
  3835. return err;
  3836. }
  3837. nid = cfg->hp_pins[0];
  3838. if (nid) {
  3839. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3840. if (err < 0)
  3841. return err;
  3842. }
  3843. return 0;
  3844. }
  3845. /* create playback/capture controls for input pins */
  3846. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3847. const struct auto_pin_cfg *cfg)
  3848. {
  3849. struct hda_input_mux *imux = &spec->private_imux;
  3850. int i, err, idx;
  3851. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3852. if (cfg->input_pins[i] >= 0x12) {
  3853. idx = cfg->input_pins[i] - 0x12;
  3854. err = new_analog_input(spec, cfg->input_pins[i],
  3855. auto_pin_cfg_labels[i], idx,
  3856. 0x07);
  3857. if (err < 0)
  3858. return err;
  3859. imux->items[imux->num_items].label =
  3860. auto_pin_cfg_labels[i];
  3861. imux->items[imux->num_items].index = idx;
  3862. imux->num_items++;
  3863. }
  3864. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3865. idx = cfg->input_pins[i] - 0x09;
  3866. err = new_analog_input(spec, cfg->input_pins[i],
  3867. auto_pin_cfg_labels[i], idx,
  3868. 0x07);
  3869. if (err < 0)
  3870. return err;
  3871. imux->items[imux->num_items].label =
  3872. auto_pin_cfg_labels[i];
  3873. imux->items[imux->num_items].index = idx;
  3874. imux->num_items++;
  3875. }
  3876. }
  3877. return 0;
  3878. }
  3879. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3880. hda_nid_t nid, int pin_type,
  3881. int sel_idx)
  3882. {
  3883. /* set as output */
  3884. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3885. pin_type);
  3886. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3887. AMP_OUT_UNMUTE);
  3888. /* need the manual connection? */
  3889. if (nid >= 0x12) {
  3890. int idx = nid - 0x12;
  3891. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3892. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3893. }
  3894. }
  3895. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3896. {
  3897. struct alc_spec *spec = codec->spec;
  3898. hda_nid_t nid;
  3899. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  3900. nid = spec->autocfg.line_out_pins[0];
  3901. if (nid) {
  3902. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3903. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  3904. }
  3905. nid = spec->autocfg.speaker_pins[0];
  3906. if (nid)
  3907. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3908. nid = spec->autocfg.hp_pins[0];
  3909. if (nid)
  3910. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  3911. }
  3912. #define ALC260_PIN_CD_NID 0x16
  3913. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3914. {
  3915. struct alc_spec *spec = codec->spec;
  3916. int i;
  3917. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3918. hda_nid_t nid = spec->autocfg.input_pins[i];
  3919. if (nid >= 0x12) {
  3920. snd_hda_codec_write(codec, nid, 0,
  3921. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3922. i <= AUTO_PIN_FRONT_MIC ?
  3923. PIN_VREF80 : PIN_IN);
  3924. if (nid != ALC260_PIN_CD_NID)
  3925. snd_hda_codec_write(codec, nid, 0,
  3926. AC_VERB_SET_AMP_GAIN_MUTE,
  3927. AMP_OUT_MUTE);
  3928. }
  3929. }
  3930. }
  3931. /*
  3932. * generic initialization of ADC, input mixers and output mixers
  3933. */
  3934. static struct hda_verb alc260_volume_init_verbs[] = {
  3935. /*
  3936. * Unmute ADC0-1 and set the default input to mic-in
  3937. */
  3938. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3939. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3940. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3941. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3942. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3943. * mixer widget
  3944. * Note: PASD motherboards uses the Line In 2 as the input for
  3945. * front panel mic (mic 2)
  3946. */
  3947. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3948. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3949. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3950. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3951. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3952. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3953. /*
  3954. * Set up output mixers (0x08 - 0x0a)
  3955. */
  3956. /* set vol=0 to output mixers */
  3957. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3958. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3959. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3960. /* set up input amps for analog loopback */
  3961. /* Amp Indices: DAC = 0, mixer = 1 */
  3962. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3963. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3964. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3965. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3966. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3967. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3968. { }
  3969. };
  3970. static int alc260_parse_auto_config(struct hda_codec *codec)
  3971. {
  3972. struct alc_spec *spec = codec->spec;
  3973. unsigned int wcap;
  3974. int err;
  3975. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3976. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3977. alc260_ignore);
  3978. if (err < 0)
  3979. return err;
  3980. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  3981. if (err < 0)
  3982. return err;
  3983. if (!spec->kctl_alloc)
  3984. return 0; /* can't find valid BIOS pin config */
  3985. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  3986. if (err < 0)
  3987. return err;
  3988. spec->multiout.max_channels = 2;
  3989. if (spec->autocfg.dig_out_pin)
  3990. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3991. if (spec->kctl_alloc)
  3992. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3993. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3994. spec->num_mux_defs = 1;
  3995. spec->input_mux = &spec->private_imux;
  3996. /* check whether NID 0x04 is valid */
  3997. wcap = get_wcaps(codec, 0x04);
  3998. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3999. if (wcap != AC_WID_AUD_IN) {
  4000. spec->adc_nids = alc260_adc_nids_alt;
  4001. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4002. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4003. } else {
  4004. spec->adc_nids = alc260_adc_nids;
  4005. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4006. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4007. }
  4008. spec->num_mixers++;
  4009. return 1;
  4010. }
  4011. /* additional initialization for auto-configuration model */
  4012. static void alc260_auto_init(struct hda_codec *codec)
  4013. {
  4014. alc260_auto_init_multi_out(codec);
  4015. alc260_auto_init_analog_input(codec);
  4016. }
  4017. /*
  4018. * ALC260 configurations
  4019. */
  4020. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4021. [ALC260_BASIC] = "basic",
  4022. [ALC260_HP] = "hp",
  4023. [ALC260_HP_3013] = "hp-3013",
  4024. [ALC260_FUJITSU_S702X] = "fujitsu",
  4025. [ALC260_ACER] = "acer",
  4026. [ALC260_WILL] = "will",
  4027. [ALC260_REPLACER_672V] = "replacer",
  4028. #ifdef CONFIG_SND_DEBUG
  4029. [ALC260_TEST] = "test",
  4030. #endif
  4031. [ALC260_AUTO] = "auto",
  4032. };
  4033. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4034. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4035. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4036. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4037. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4038. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4039. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4040. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4041. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4042. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4043. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4044. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4045. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4046. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4047. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4048. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4049. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4050. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4051. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4052. {}
  4053. };
  4054. static struct alc_config_preset alc260_presets[] = {
  4055. [ALC260_BASIC] = {
  4056. .mixers = { alc260_base_output_mixer,
  4057. alc260_input_mixer,
  4058. alc260_pc_beep_mixer,
  4059. alc260_capture_mixer },
  4060. .init_verbs = { alc260_init_verbs },
  4061. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4062. .dac_nids = alc260_dac_nids,
  4063. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4064. .adc_nids = alc260_adc_nids,
  4065. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4066. .channel_mode = alc260_modes,
  4067. .input_mux = &alc260_capture_source,
  4068. },
  4069. [ALC260_HP] = {
  4070. .mixers = { alc260_base_output_mixer,
  4071. alc260_input_mixer,
  4072. alc260_capture_alt_mixer },
  4073. .init_verbs = { alc260_init_verbs },
  4074. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4075. .dac_nids = alc260_dac_nids,
  4076. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4077. .adc_nids = alc260_hp_adc_nids,
  4078. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4079. .channel_mode = alc260_modes,
  4080. .input_mux = &alc260_capture_source,
  4081. },
  4082. [ALC260_HP_3013] = {
  4083. .mixers = { alc260_hp_3013_mixer,
  4084. alc260_input_mixer,
  4085. alc260_capture_alt_mixer },
  4086. .init_verbs = { alc260_hp_3013_init_verbs },
  4087. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4088. .dac_nids = alc260_dac_nids,
  4089. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4090. .adc_nids = alc260_hp_adc_nids,
  4091. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4092. .channel_mode = alc260_modes,
  4093. .input_mux = &alc260_capture_source,
  4094. },
  4095. [ALC260_FUJITSU_S702X] = {
  4096. .mixers = { alc260_fujitsu_mixer,
  4097. alc260_capture_mixer },
  4098. .init_verbs = { alc260_fujitsu_init_verbs },
  4099. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4100. .dac_nids = alc260_dac_nids,
  4101. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4102. .adc_nids = alc260_dual_adc_nids,
  4103. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4104. .channel_mode = alc260_modes,
  4105. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4106. .input_mux = alc260_fujitsu_capture_sources,
  4107. },
  4108. [ALC260_ACER] = {
  4109. .mixers = { alc260_acer_mixer,
  4110. alc260_capture_mixer },
  4111. .init_verbs = { alc260_acer_init_verbs },
  4112. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4113. .dac_nids = alc260_dac_nids,
  4114. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4115. .adc_nids = alc260_dual_adc_nids,
  4116. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4117. .channel_mode = alc260_modes,
  4118. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4119. .input_mux = alc260_acer_capture_sources,
  4120. },
  4121. [ALC260_WILL] = {
  4122. .mixers = { alc260_will_mixer,
  4123. alc260_capture_mixer },
  4124. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4125. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4126. .dac_nids = alc260_dac_nids,
  4127. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4128. .adc_nids = alc260_adc_nids,
  4129. .dig_out_nid = ALC260_DIGOUT_NID,
  4130. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4131. .channel_mode = alc260_modes,
  4132. .input_mux = &alc260_capture_source,
  4133. },
  4134. [ALC260_REPLACER_672V] = {
  4135. .mixers = { alc260_replacer_672v_mixer,
  4136. alc260_capture_mixer },
  4137. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4138. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4139. .dac_nids = alc260_dac_nids,
  4140. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4141. .adc_nids = alc260_adc_nids,
  4142. .dig_out_nid = ALC260_DIGOUT_NID,
  4143. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4144. .channel_mode = alc260_modes,
  4145. .input_mux = &alc260_capture_source,
  4146. .unsol_event = alc260_replacer_672v_unsol_event,
  4147. .init_hook = alc260_replacer_672v_automute,
  4148. },
  4149. #ifdef CONFIG_SND_DEBUG
  4150. [ALC260_TEST] = {
  4151. .mixers = { alc260_test_mixer,
  4152. alc260_capture_mixer },
  4153. .init_verbs = { alc260_test_init_verbs },
  4154. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4155. .dac_nids = alc260_test_dac_nids,
  4156. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4157. .adc_nids = alc260_test_adc_nids,
  4158. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4159. .channel_mode = alc260_modes,
  4160. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4161. .input_mux = alc260_test_capture_sources,
  4162. },
  4163. #endif
  4164. };
  4165. static int patch_alc260(struct hda_codec *codec)
  4166. {
  4167. struct alc_spec *spec;
  4168. int err, board_config;
  4169. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4170. if (spec == NULL)
  4171. return -ENOMEM;
  4172. codec->spec = spec;
  4173. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4174. alc260_models,
  4175. alc260_cfg_tbl);
  4176. if (board_config < 0) {
  4177. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4178. "trying auto-probe from BIOS...\n");
  4179. board_config = ALC260_AUTO;
  4180. }
  4181. if (board_config == ALC260_AUTO) {
  4182. /* automatic parse from the BIOS config */
  4183. err = alc260_parse_auto_config(codec);
  4184. if (err < 0) {
  4185. alc_free(codec);
  4186. return err;
  4187. } else if (!err) {
  4188. printk(KERN_INFO
  4189. "hda_codec: Cannot set up configuration "
  4190. "from BIOS. Using base mode...\n");
  4191. board_config = ALC260_BASIC;
  4192. }
  4193. }
  4194. if (board_config != ALC260_AUTO)
  4195. setup_preset(spec, &alc260_presets[board_config]);
  4196. spec->stream_name_analog = "ALC260 Analog";
  4197. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4198. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4199. spec->stream_name_digital = "ALC260 Digital";
  4200. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4201. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4202. codec->patch_ops = alc_patch_ops;
  4203. if (board_config == ALC260_AUTO)
  4204. spec->init_hook = alc260_auto_init;
  4205. return 0;
  4206. }
  4207. /*
  4208. * ALC882 support
  4209. *
  4210. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4211. * configuration. Each pin widget can choose any input DACs and a mixer.
  4212. * Each ADC is connected from a mixer of all inputs. This makes possible
  4213. * 6-channel independent captures.
  4214. *
  4215. * In addition, an independent DAC for the multi-playback (not used in this
  4216. * driver yet).
  4217. */
  4218. #define ALC882_DIGOUT_NID 0x06
  4219. #define ALC882_DIGIN_NID 0x0a
  4220. static struct hda_channel_mode alc882_ch_modes[1] = {
  4221. { 8, NULL }
  4222. };
  4223. static hda_nid_t alc882_dac_nids[4] = {
  4224. /* front, rear, clfe, rear_surr */
  4225. 0x02, 0x03, 0x04, 0x05
  4226. };
  4227. /* identical with ALC880 */
  4228. #define alc882_adc_nids alc880_adc_nids
  4229. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4230. /* input MUX */
  4231. /* FIXME: should be a matrix-type input source selection */
  4232. static struct hda_input_mux alc882_capture_source = {
  4233. .num_items = 4,
  4234. .items = {
  4235. { "Mic", 0x0 },
  4236. { "Front Mic", 0x1 },
  4237. { "Line", 0x2 },
  4238. { "CD", 0x4 },
  4239. },
  4240. };
  4241. #define alc882_mux_enum_info alc_mux_enum_info
  4242. #define alc882_mux_enum_get alc_mux_enum_get
  4243. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4244. struct snd_ctl_elem_value *ucontrol)
  4245. {
  4246. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4247. struct alc_spec *spec = codec->spec;
  4248. const struct hda_input_mux *imux = spec->input_mux;
  4249. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4250. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4251. hda_nid_t nid = capture_mixers[adc_idx];
  4252. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4253. unsigned int i, idx;
  4254. idx = ucontrol->value.enumerated.item[0];
  4255. if (idx >= imux->num_items)
  4256. idx = imux->num_items - 1;
  4257. if (*cur_val == idx && !codec->in_resume)
  4258. return 0;
  4259. for (i = 0; i < imux->num_items; i++) {
  4260. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4261. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4262. v | (imux->items[i].index << 8));
  4263. }
  4264. *cur_val = idx;
  4265. return 1;
  4266. }
  4267. /*
  4268. * 6ch mode
  4269. */
  4270. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4271. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4272. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4273. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4274. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4275. { } /* end */
  4276. };
  4277. /*
  4278. * 8ch mode
  4279. */
  4280. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4281. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4282. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4283. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4284. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4285. { } /* end */
  4286. };
  4287. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4288. { 6, alc882_sixstack_ch6_init },
  4289. { 8, alc882_sixstack_ch8_init },
  4290. };
  4291. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4292. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4293. */
  4294. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4295. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4296. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4297. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4298. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4299. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4300. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4301. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4302. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4303. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4304. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4305. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4306. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4307. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4308. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4309. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4310. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4311. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4312. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4313. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4314. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4315. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4316. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4317. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4318. { } /* end */
  4319. };
  4320. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4321. {
  4322. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4323. .name = "Channel Mode",
  4324. .info = alc_ch_mode_info,
  4325. .get = alc_ch_mode_get,
  4326. .put = alc_ch_mode_put,
  4327. },
  4328. { } /* end */
  4329. };
  4330. static struct hda_verb alc882_init_verbs[] = {
  4331. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4332. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4333. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4334. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4335. /* Rear mixer */
  4336. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4337. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4338. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4339. /* CLFE mixer */
  4340. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4341. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4342. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4343. /* Side mixer */
  4344. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4345. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4346. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4347. /* Front Pin: output 0 (0x0c) */
  4348. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4349. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4350. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4351. /* Rear Pin: output 1 (0x0d) */
  4352. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4353. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4354. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4355. /* CLFE Pin: output 2 (0x0e) */
  4356. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4357. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4358. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4359. /* Side Pin: output 3 (0x0f) */
  4360. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4361. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4362. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4363. /* Mic (rear) pin: input vref at 80% */
  4364. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4365. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4366. /* Front Mic pin: input vref at 80% */
  4367. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4368. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4369. /* Line In pin: input */
  4370. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4371. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4372. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4373. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4374. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4375. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4376. /* CD pin widget for input */
  4377. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4378. /* FIXME: use matrix-type input source selection */
  4379. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4380. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4381. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4382. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4383. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4384. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4385. /* Input mixer2 */
  4386. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4387. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4388. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4389. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4390. /* Input mixer3 */
  4391. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4392. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4393. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4394. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4395. /* ADC1: mute amp left and right */
  4396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4397. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4398. /* ADC2: mute amp left and right */
  4399. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4400. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4401. /* ADC3: mute amp left and right */
  4402. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4403. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4404. { }
  4405. };
  4406. static struct hda_verb alc882_eapd_verbs[] = {
  4407. /* change to EAPD mode */
  4408. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4409. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4410. { }
  4411. };
  4412. /* Mac Pro test */
  4413. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4414. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4415. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4416. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4417. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4418. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4419. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4420. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4421. { } /* end */
  4422. };
  4423. static struct hda_verb alc882_macpro_init_verbs[] = {
  4424. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4425. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4426. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4427. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4428. /* Front Pin: output 0 (0x0c) */
  4429. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4430. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4431. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4432. /* Front Mic pin: input vref at 80% */
  4433. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4434. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4435. /* Speaker: output */
  4436. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4437. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4438. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4439. /* Headphone output (output 0 - 0x0c) */
  4440. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4441. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4442. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4443. /* FIXME: use matrix-type input source selection */
  4444. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4445. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4446. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4447. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4448. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4449. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4450. /* Input mixer2 */
  4451. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4452. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4453. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4454. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4455. /* Input mixer3 */
  4456. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4457. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4458. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4459. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4460. /* ADC1: mute amp left and right */
  4461. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4462. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4463. /* ADC2: mute amp left and right */
  4464. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4465. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4466. /* ADC3: mute amp left and right */
  4467. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4468. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4469. { }
  4470. };
  4471. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4472. {
  4473. unsigned int gpiostate, gpiomask, gpiodir;
  4474. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4475. AC_VERB_GET_GPIO_DATA, 0);
  4476. if (!muted)
  4477. gpiostate |= (1 << pin);
  4478. else
  4479. gpiostate &= ~(1 << pin);
  4480. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4481. AC_VERB_GET_GPIO_MASK, 0);
  4482. gpiomask |= (1 << pin);
  4483. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4484. AC_VERB_GET_GPIO_DIRECTION, 0);
  4485. gpiodir |= (1 << pin);
  4486. snd_hda_codec_write(codec, codec->afg, 0,
  4487. AC_VERB_SET_GPIO_MASK, gpiomask);
  4488. snd_hda_codec_write(codec, codec->afg, 0,
  4489. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4490. msleep(1);
  4491. snd_hda_codec_write(codec, codec->afg, 0,
  4492. AC_VERB_SET_GPIO_DATA, gpiostate);
  4493. }
  4494. /*
  4495. * generic initialization of ADC, input mixers and output mixers
  4496. */
  4497. static struct hda_verb alc882_auto_init_verbs[] = {
  4498. /*
  4499. * Unmute ADC0-2 and set the default input to mic-in
  4500. */
  4501. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4502. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4503. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4504. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4505. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4506. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4507. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4508. * mixer widget
  4509. * Note: PASD motherboards uses the Line In 2 as the input for
  4510. * front panel mic (mic 2)
  4511. */
  4512. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4513. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4514. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4515. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4516. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4517. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4518. /*
  4519. * Set up output mixers (0x0c - 0x0f)
  4520. */
  4521. /* set vol=0 to output mixers */
  4522. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4523. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4524. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4525. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4526. /* set up input amps for analog loopback */
  4527. /* Amp Indices: DAC = 0, mixer = 1 */
  4528. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4529. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4530. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4531. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4532. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4533. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4534. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4535. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4536. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4537. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4538. /* FIXME: use matrix-type input source selection */
  4539. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4540. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4541. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4542. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4543. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4544. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4545. /* Input mixer2 */
  4546. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4547. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4548. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4549. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4550. /* Input mixer3 */
  4551. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4552. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4553. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4554. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4555. { }
  4556. };
  4557. /* capture mixer elements */
  4558. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4559. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4560. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4561. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4562. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4563. {
  4564. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4565. /* The multiple "Capture Source" controls confuse alsamixer
  4566. * So call somewhat different..
  4567. * FIXME: the controls appear in the "playback" view!
  4568. */
  4569. /* .name = "Capture Source", */
  4570. .name = "Input Source",
  4571. .count = 2,
  4572. .info = alc882_mux_enum_info,
  4573. .get = alc882_mux_enum_get,
  4574. .put = alc882_mux_enum_put,
  4575. },
  4576. { } /* end */
  4577. };
  4578. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4579. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4580. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4581. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4582. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4583. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4584. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4585. {
  4586. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4587. /* The multiple "Capture Source" controls confuse alsamixer
  4588. * So call somewhat different..
  4589. * FIXME: the controls appear in the "playback" view!
  4590. */
  4591. /* .name = "Capture Source", */
  4592. .name = "Input Source",
  4593. .count = 3,
  4594. .info = alc882_mux_enum_info,
  4595. .get = alc882_mux_enum_get,
  4596. .put = alc882_mux_enum_put,
  4597. },
  4598. { } /* end */
  4599. };
  4600. /* pcm configuration: identiacal with ALC880 */
  4601. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4602. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4603. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4604. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4605. /*
  4606. * configuration and preset
  4607. */
  4608. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4609. [ALC882_3ST_DIG] = "3stack-dig",
  4610. [ALC882_6ST_DIG] = "6stack-dig",
  4611. [ALC882_ARIMA] = "arima",
  4612. [ALC885_MACPRO] = "macpro",
  4613. [ALC882_AUTO] = "auto",
  4614. };
  4615. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4616. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4617. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4618. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4619. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4620. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4621. {}
  4622. };
  4623. static struct alc_config_preset alc882_presets[] = {
  4624. [ALC882_3ST_DIG] = {
  4625. .mixers = { alc882_base_mixer },
  4626. .init_verbs = { alc882_init_verbs },
  4627. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4628. .dac_nids = alc882_dac_nids,
  4629. .dig_out_nid = ALC882_DIGOUT_NID,
  4630. .dig_in_nid = ALC882_DIGIN_NID,
  4631. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4632. .channel_mode = alc882_ch_modes,
  4633. .need_dac_fix = 1,
  4634. .input_mux = &alc882_capture_source,
  4635. },
  4636. [ALC882_6ST_DIG] = {
  4637. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4638. .init_verbs = { alc882_init_verbs },
  4639. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4640. .dac_nids = alc882_dac_nids,
  4641. .dig_out_nid = ALC882_DIGOUT_NID,
  4642. .dig_in_nid = ALC882_DIGIN_NID,
  4643. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4644. .channel_mode = alc882_sixstack_modes,
  4645. .input_mux = &alc882_capture_source,
  4646. },
  4647. [ALC882_ARIMA] = {
  4648. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4649. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4650. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4651. .dac_nids = alc882_dac_nids,
  4652. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4653. .channel_mode = alc882_sixstack_modes,
  4654. .input_mux = &alc882_capture_source,
  4655. },
  4656. [ALC885_MACPRO] = {
  4657. .mixers = { alc882_macpro_mixer },
  4658. .init_verbs = { alc882_macpro_init_verbs },
  4659. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4660. .dac_nids = alc882_dac_nids,
  4661. .dig_out_nid = ALC882_DIGOUT_NID,
  4662. .dig_in_nid = ALC882_DIGIN_NID,
  4663. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4664. .channel_mode = alc882_ch_modes,
  4665. .input_mux = &alc882_capture_source,
  4666. },
  4667. };
  4668. /*
  4669. * BIOS auto configuration
  4670. */
  4671. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4672. hda_nid_t nid, int pin_type,
  4673. int dac_idx)
  4674. {
  4675. /* set as output */
  4676. struct alc_spec *spec = codec->spec;
  4677. int idx;
  4678. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4679. idx = 4;
  4680. else
  4681. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4682. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4683. pin_type);
  4684. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4685. AMP_OUT_UNMUTE);
  4686. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4687. }
  4688. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4689. {
  4690. struct alc_spec *spec = codec->spec;
  4691. int i;
  4692. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4693. for (i = 0; i <= HDA_SIDE; i++) {
  4694. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4695. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4696. if (nid)
  4697. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  4698. i);
  4699. }
  4700. }
  4701. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4702. {
  4703. struct alc_spec *spec = codec->spec;
  4704. hda_nid_t pin;
  4705. pin = spec->autocfg.hp_pins[0];
  4706. if (pin) /* connect to front */
  4707. /* use dac 0 */
  4708. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4709. }
  4710. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4711. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4712. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4713. {
  4714. struct alc_spec *spec = codec->spec;
  4715. int i;
  4716. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4717. hda_nid_t nid = spec->autocfg.input_pins[i];
  4718. if (alc882_is_input_pin(nid)) {
  4719. snd_hda_codec_write(codec, nid, 0,
  4720. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4721. i <= AUTO_PIN_FRONT_MIC ?
  4722. PIN_VREF80 : PIN_IN);
  4723. if (nid != ALC882_PIN_CD_NID)
  4724. snd_hda_codec_write(codec, nid, 0,
  4725. AC_VERB_SET_AMP_GAIN_MUTE,
  4726. AMP_OUT_MUTE);
  4727. }
  4728. }
  4729. }
  4730. /* almost identical with ALC880 parser... */
  4731. static int alc882_parse_auto_config(struct hda_codec *codec)
  4732. {
  4733. struct alc_spec *spec = codec->spec;
  4734. int err = alc880_parse_auto_config(codec);
  4735. if (err < 0)
  4736. return err;
  4737. else if (err > 0)
  4738. /* hack - override the init verbs */
  4739. spec->init_verbs[0] = alc882_auto_init_verbs;
  4740. return err;
  4741. }
  4742. /* additional initialization for auto-configuration model */
  4743. static void alc882_auto_init(struct hda_codec *codec)
  4744. {
  4745. alc882_auto_init_multi_out(codec);
  4746. alc882_auto_init_hp_out(codec);
  4747. alc882_auto_init_analog_input(codec);
  4748. }
  4749. static int patch_alc882(struct hda_codec *codec)
  4750. {
  4751. struct alc_spec *spec;
  4752. int err, board_config;
  4753. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4754. if (spec == NULL)
  4755. return -ENOMEM;
  4756. codec->spec = spec;
  4757. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4758. alc882_models,
  4759. alc882_cfg_tbl);
  4760. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4761. /* Pick up systems that don't supply PCI SSID */
  4762. switch (codec->subsystem_id) {
  4763. case 0x106b0c00: /* Mac Pro */
  4764. board_config = ALC885_MACPRO;
  4765. break;
  4766. default:
  4767. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4768. "trying auto-probe from BIOS...\n");
  4769. board_config = ALC882_AUTO;
  4770. }
  4771. }
  4772. if (board_config == ALC882_AUTO) {
  4773. /* automatic parse from the BIOS config */
  4774. err = alc882_parse_auto_config(codec);
  4775. if (err < 0) {
  4776. alc_free(codec);
  4777. return err;
  4778. } else if (!err) {
  4779. printk(KERN_INFO
  4780. "hda_codec: Cannot set up configuration "
  4781. "from BIOS. Using base mode...\n");
  4782. board_config = ALC882_3ST_DIG;
  4783. }
  4784. }
  4785. if (board_config != ALC882_AUTO)
  4786. setup_preset(spec, &alc882_presets[board_config]);
  4787. if (board_config == ALC885_MACPRO) {
  4788. alc882_gpio_mute(codec, 0, 0);
  4789. alc882_gpio_mute(codec, 1, 0);
  4790. }
  4791. spec->stream_name_analog = "ALC882 Analog";
  4792. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  4793. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  4794. spec->stream_name_digital = "ALC882 Digital";
  4795. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  4796. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  4797. if (!spec->adc_nids && spec->input_mux) {
  4798. /* check whether NID 0x07 is valid */
  4799. unsigned int wcap = get_wcaps(codec, 0x07);
  4800. /* get type */
  4801. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  4802. if (wcap != AC_WID_AUD_IN) {
  4803. spec->adc_nids = alc882_adc_nids_alt;
  4804. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  4805. spec->mixers[spec->num_mixers] =
  4806. alc882_capture_alt_mixer;
  4807. spec->num_mixers++;
  4808. } else {
  4809. spec->adc_nids = alc882_adc_nids;
  4810. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  4811. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  4812. spec->num_mixers++;
  4813. }
  4814. }
  4815. codec->patch_ops = alc_patch_ops;
  4816. if (board_config == ALC882_AUTO)
  4817. spec->init_hook = alc882_auto_init;
  4818. return 0;
  4819. }
  4820. /*
  4821. * ALC883 support
  4822. *
  4823. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  4824. * configuration. Each pin widget can choose any input DACs and a mixer.
  4825. * Each ADC is connected from a mixer of all inputs. This makes possible
  4826. * 6-channel independent captures.
  4827. *
  4828. * In addition, an independent DAC for the multi-playback (not used in this
  4829. * driver yet).
  4830. */
  4831. #define ALC883_DIGOUT_NID 0x06
  4832. #define ALC883_DIGIN_NID 0x0a
  4833. static hda_nid_t alc883_dac_nids[4] = {
  4834. /* front, rear, clfe, rear_surr */
  4835. 0x02, 0x04, 0x03, 0x05
  4836. };
  4837. static hda_nid_t alc883_adc_nids[2] = {
  4838. /* ADC1-2 */
  4839. 0x08, 0x09,
  4840. };
  4841. /* input MUX */
  4842. /* FIXME: should be a matrix-type input source selection */
  4843. static struct hda_input_mux alc883_capture_source = {
  4844. .num_items = 4,
  4845. .items = {
  4846. { "Mic", 0x0 },
  4847. { "Front Mic", 0x1 },
  4848. { "Line", 0x2 },
  4849. { "CD", 0x4 },
  4850. },
  4851. };
  4852. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  4853. .num_items = 2,
  4854. .items = {
  4855. { "Mic", 0x1 },
  4856. { "Line", 0x2 },
  4857. },
  4858. };
  4859. #define alc883_mux_enum_info alc_mux_enum_info
  4860. #define alc883_mux_enum_get alc_mux_enum_get
  4861. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  4862. struct snd_ctl_elem_value *ucontrol)
  4863. {
  4864. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4865. struct alc_spec *spec = codec->spec;
  4866. const struct hda_input_mux *imux = spec->input_mux;
  4867. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4868. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4869. hda_nid_t nid = capture_mixers[adc_idx];
  4870. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4871. unsigned int i, idx;
  4872. idx = ucontrol->value.enumerated.item[0];
  4873. if (idx >= imux->num_items)
  4874. idx = imux->num_items - 1;
  4875. if (*cur_val == idx && !codec->in_resume)
  4876. return 0;
  4877. for (i = 0; i < imux->num_items; i++) {
  4878. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4879. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4880. v | (imux->items[i].index << 8));
  4881. }
  4882. *cur_val = idx;
  4883. return 1;
  4884. }
  4885. /*
  4886. * 2ch mode
  4887. */
  4888. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  4889. { 2, NULL }
  4890. };
  4891. /*
  4892. * 2ch mode
  4893. */
  4894. static struct hda_verb alc883_3ST_ch2_init[] = {
  4895. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4896. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4897. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4898. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4899. { } /* end */
  4900. };
  4901. /*
  4902. * 6ch mode
  4903. */
  4904. static struct hda_verb alc883_3ST_ch6_init[] = {
  4905. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4906. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4907. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4908. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4909. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4910. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4911. { } /* end */
  4912. };
  4913. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  4914. { 2, alc883_3ST_ch2_init },
  4915. { 6, alc883_3ST_ch6_init },
  4916. };
  4917. /*
  4918. * 6ch mode
  4919. */
  4920. static struct hda_verb alc883_sixstack_ch6_init[] = {
  4921. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4922. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4923. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4924. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4925. { } /* end */
  4926. };
  4927. /*
  4928. * 8ch mode
  4929. */
  4930. static struct hda_verb alc883_sixstack_ch8_init[] = {
  4931. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4932. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4933. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4934. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4935. { } /* end */
  4936. };
  4937. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  4938. { 6, alc883_sixstack_ch6_init },
  4939. { 8, alc883_sixstack_ch8_init },
  4940. };
  4941. static struct hda_verb alc883_medion_eapd_verbs[] = {
  4942. /* eanable EAPD on medion laptop */
  4943. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4944. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  4945. { }
  4946. };
  4947. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4948. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4949. */
  4950. static struct snd_kcontrol_new alc883_base_mixer[] = {
  4951. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4952. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4953. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4954. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4955. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4956. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4957. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4958. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4959. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4960. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4961. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4962. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4963. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4964. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4965. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4966. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4967. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4968. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4969. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4970. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4971. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4972. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4973. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4974. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4975. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4976. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4977. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4978. {
  4979. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4980. /* .name = "Capture Source", */
  4981. .name = "Input Source",
  4982. .count = 2,
  4983. .info = alc883_mux_enum_info,
  4984. .get = alc883_mux_enum_get,
  4985. .put = alc883_mux_enum_put,
  4986. },
  4987. { } /* end */
  4988. };
  4989. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  4990. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4991. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4992. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4993. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4994. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4995. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4996. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4997. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4998. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4999. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5000. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5001. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5002. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5003. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5004. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5005. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5006. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5007. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5008. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5009. {
  5010. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5011. /* .name = "Capture Source", */
  5012. .name = "Input Source",
  5013. .count = 2,
  5014. .info = alc883_mux_enum_info,
  5015. .get = alc883_mux_enum_get,
  5016. .put = alc883_mux_enum_put,
  5017. },
  5018. { } /* end */
  5019. };
  5020. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5021. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5022. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5023. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5024. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5025. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5026. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5027. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5028. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5029. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5030. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5031. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5032. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5033. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5034. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5035. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5036. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5037. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5038. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5039. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5040. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5041. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5042. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5043. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5044. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5045. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5046. {
  5047. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5048. /* .name = "Capture Source", */
  5049. .name = "Input Source",
  5050. .count = 2,
  5051. .info = alc883_mux_enum_info,
  5052. .get = alc883_mux_enum_get,
  5053. .put = alc883_mux_enum_put,
  5054. },
  5055. { } /* end */
  5056. };
  5057. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5058. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5059. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5060. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5061. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5062. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5063. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5064. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5065. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5066. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5067. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5068. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5069. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5070. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5071. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5072. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5073. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5074. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5075. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5076. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5077. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5078. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5079. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5080. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5081. {
  5082. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5083. /* .name = "Capture Source", */
  5084. .name = "Input Source",
  5085. .count = 1,
  5086. .info = alc883_mux_enum_info,
  5087. .get = alc883_mux_enum_get,
  5088. .put = alc883_mux_enum_put,
  5089. },
  5090. { } /* end */
  5091. };
  5092. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5093. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5094. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5095. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5096. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5097. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5098. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5099. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5100. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5101. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5102. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5103. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5104. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5105. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5106. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5107. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5108. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5109. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5110. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5111. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5112. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5113. {
  5114. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5115. /* .name = "Capture Source", */
  5116. .name = "Input Source",
  5117. .count = 2,
  5118. .info = alc883_mux_enum_info,
  5119. .get = alc883_mux_enum_get,
  5120. .put = alc883_mux_enum_put,
  5121. },
  5122. { } /* end */
  5123. };
  5124. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5125. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5126. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5127. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5128. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5129. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5130. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5131. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5132. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5133. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5134. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5135. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5136. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5137. {
  5138. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5139. /* .name = "Capture Source", */
  5140. .name = "Input Source",
  5141. .count = 2,
  5142. .info = alc883_mux_enum_info,
  5143. .get = alc883_mux_enum_get,
  5144. .put = alc883_mux_enum_put,
  5145. },
  5146. { } /* end */
  5147. };
  5148. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5149. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5150. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5151. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5152. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5153. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5154. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5155. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5156. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5157. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5158. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5159. {
  5160. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5161. /* .name = "Capture Source", */
  5162. .name = "Input Source",
  5163. .count = 1,
  5164. .info = alc883_mux_enum_info,
  5165. .get = alc883_mux_enum_get,
  5166. .put = alc883_mux_enum_put,
  5167. },
  5168. { } /* end */
  5169. };
  5170. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5171. {
  5172. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5173. .name = "Channel Mode",
  5174. .info = alc_ch_mode_info,
  5175. .get = alc_ch_mode_get,
  5176. .put = alc_ch_mode_put,
  5177. },
  5178. { } /* end */
  5179. };
  5180. static struct hda_verb alc883_init_verbs[] = {
  5181. /* ADC1: mute amp left and right */
  5182. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5183. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5184. /* ADC2: mute amp left and right */
  5185. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5186. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5187. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5188. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5189. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5191. /* Rear mixer */
  5192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5194. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5195. /* CLFE mixer */
  5196. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5197. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5198. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5199. /* Side mixer */
  5200. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5201. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5202. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5203. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5204. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5205. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5206. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5207. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5208. /* Front Pin: output 0 (0x0c) */
  5209. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5210. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5211. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5212. /* Rear Pin: output 1 (0x0d) */
  5213. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5214. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5215. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5216. /* CLFE Pin: output 2 (0x0e) */
  5217. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5218. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5219. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5220. /* Side Pin: output 3 (0x0f) */
  5221. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5222. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5223. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5224. /* Mic (rear) pin: input vref at 80% */
  5225. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5226. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5227. /* Front Mic pin: input vref at 80% */
  5228. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5229. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5230. /* Line In pin: input */
  5231. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5232. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5233. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5234. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5235. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5236. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5237. /* CD pin widget for input */
  5238. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5239. /* FIXME: use matrix-type input source selection */
  5240. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5241. /* Input mixer2 */
  5242. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5243. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5244. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5245. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5246. /* Input mixer3 */
  5247. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5248. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5249. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5250. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5251. { }
  5252. };
  5253. static struct hda_verb alc883_tagra_verbs[] = {
  5254. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5255. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5256. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5257. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5258. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5259. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5260. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5261. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5262. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5263. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5264. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5265. { } /* end */
  5266. };
  5267. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5268. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5269. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5270. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5271. { } /* end */
  5272. };
  5273. /* toggle speaker-output according to the hp-jack state */
  5274. static void alc883_tagra_automute(struct hda_codec *codec)
  5275. {
  5276. unsigned int present;
  5277. unsigned char bits;
  5278. present = snd_hda_codec_read(codec, 0x14, 0,
  5279. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5280. bits = present ? 0x80 : 0;
  5281. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5282. 0x80, bits);
  5283. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5284. 0x80, bits);
  5285. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5286. present ? 1 : 3);
  5287. }
  5288. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5289. {
  5290. if ((res >> 26) == ALC880_HP_EVENT)
  5291. alc883_tagra_automute(codec);
  5292. }
  5293. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5294. {
  5295. unsigned int present;
  5296. unsigned char bits;
  5297. present = snd_hda_codec_read(codec, 0x14, 0,
  5298. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5299. bits = present ? 0x80 : 0;
  5300. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5301. 0x80, bits);
  5302. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5303. 0x80, bits);
  5304. }
  5305. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5306. {
  5307. unsigned int present;
  5308. unsigned char bits;
  5309. present = snd_hda_codec_read(codec, 0x1b, 0,
  5310. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5311. bits = present ? 0x80 : 0;
  5312. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5313. 0x80, bits);
  5314. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5315. 0x80, bits);
  5316. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5317. 0x80, bits);
  5318. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5319. 0x80, bits);
  5320. }
  5321. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5322. unsigned int res)
  5323. {
  5324. if ((res >> 26) == ALC880_HP_EVENT)
  5325. alc883_lenovo_101e_all_automute(codec);
  5326. if ((res >> 26) == ALC880_FRONT_EVENT)
  5327. alc883_lenovo_101e_ispeaker_automute(codec);
  5328. }
  5329. /*
  5330. * generic initialization of ADC, input mixers and output mixers
  5331. */
  5332. static struct hda_verb alc883_auto_init_verbs[] = {
  5333. /*
  5334. * Unmute ADC0-2 and set the default input to mic-in
  5335. */
  5336. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5337. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5338. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5339. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5340. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5341. * mixer widget
  5342. * Note: PASD motherboards uses the Line In 2 as the input for
  5343. * front panel mic (mic 2)
  5344. */
  5345. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5346. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5347. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5348. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5349. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5350. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5351. /*
  5352. * Set up output mixers (0x0c - 0x0f)
  5353. */
  5354. /* set vol=0 to output mixers */
  5355. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5356. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5357. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5358. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5359. /* set up input amps for analog loopback */
  5360. /* Amp Indices: DAC = 0, mixer = 1 */
  5361. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5362. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5363. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5364. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5365. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5366. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5367. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5368. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5369. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5370. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5371. /* FIXME: use matrix-type input source selection */
  5372. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5373. /* Input mixer1 */
  5374. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5375. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5376. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5377. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5378. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5379. /* Input mixer2 */
  5380. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5381. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5382. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5383. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5384. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5385. { }
  5386. };
  5387. /* capture mixer elements */
  5388. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5389. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5390. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5391. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5392. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5393. {
  5394. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5395. /* The multiple "Capture Source" controls confuse alsamixer
  5396. * So call somewhat different..
  5397. * FIXME: the controls appear in the "playback" view!
  5398. */
  5399. /* .name = "Capture Source", */
  5400. .name = "Input Source",
  5401. .count = 2,
  5402. .info = alc882_mux_enum_info,
  5403. .get = alc882_mux_enum_get,
  5404. .put = alc882_mux_enum_put,
  5405. },
  5406. { } /* end */
  5407. };
  5408. /* pcm configuration: identiacal with ALC880 */
  5409. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5410. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5411. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5412. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5413. /*
  5414. * configuration and preset
  5415. */
  5416. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5417. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5418. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5419. [ALC883_3ST_6ch] = "3stack-6ch",
  5420. [ALC883_6ST_DIG] = "6stack-dig",
  5421. [ALC883_TARGA_DIG] = "targa-dig",
  5422. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5423. [ALC888_DEMO_BOARD] = "6stack-dig-demo",
  5424. [ALC883_ACER] = "acer",
  5425. [ALC883_MEDION] = "medion",
  5426. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5427. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5428. [ALC883_AUTO] = "auto",
  5429. };
  5430. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5431. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5432. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5433. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5434. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5435. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5436. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5437. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5438. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5439. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5440. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5441. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5442. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5443. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5444. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5445. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5446. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5447. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5448. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5449. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5450. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5451. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5452. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5453. SND_PCI_QUIRK(0x17aa, 0x101e, "lenovo 101e", ALC883_LENOVO_101E_2ch),
  5454. {}
  5455. };
  5456. static struct alc_config_preset alc883_presets[] = {
  5457. [ALC883_3ST_2ch_DIG] = {
  5458. .mixers = { alc883_3ST_2ch_mixer },
  5459. .init_verbs = { alc883_init_verbs },
  5460. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5461. .dac_nids = alc883_dac_nids,
  5462. .dig_out_nid = ALC883_DIGOUT_NID,
  5463. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5464. .adc_nids = alc883_adc_nids,
  5465. .dig_in_nid = ALC883_DIGIN_NID,
  5466. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5467. .channel_mode = alc883_3ST_2ch_modes,
  5468. .input_mux = &alc883_capture_source,
  5469. },
  5470. [ALC883_3ST_6ch_DIG] = {
  5471. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5472. .init_verbs = { alc883_init_verbs },
  5473. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5474. .dac_nids = alc883_dac_nids,
  5475. .dig_out_nid = ALC883_DIGOUT_NID,
  5476. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5477. .adc_nids = alc883_adc_nids,
  5478. .dig_in_nid = ALC883_DIGIN_NID,
  5479. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5480. .channel_mode = alc883_3ST_6ch_modes,
  5481. .need_dac_fix = 1,
  5482. .input_mux = &alc883_capture_source,
  5483. },
  5484. [ALC883_3ST_6ch] = {
  5485. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5486. .init_verbs = { alc883_init_verbs },
  5487. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5488. .dac_nids = alc883_dac_nids,
  5489. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5490. .adc_nids = alc883_adc_nids,
  5491. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5492. .channel_mode = alc883_3ST_6ch_modes,
  5493. .need_dac_fix = 1,
  5494. .input_mux = &alc883_capture_source,
  5495. },
  5496. [ALC883_6ST_DIG] = {
  5497. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5498. .init_verbs = { alc883_init_verbs },
  5499. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5500. .dac_nids = alc883_dac_nids,
  5501. .dig_out_nid = ALC883_DIGOUT_NID,
  5502. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5503. .adc_nids = alc883_adc_nids,
  5504. .dig_in_nid = ALC883_DIGIN_NID,
  5505. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5506. .channel_mode = alc883_sixstack_modes,
  5507. .input_mux = &alc883_capture_source,
  5508. },
  5509. [ALC883_TARGA_DIG] = {
  5510. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5511. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5512. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5513. .dac_nids = alc883_dac_nids,
  5514. .dig_out_nid = ALC883_DIGOUT_NID,
  5515. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5516. .adc_nids = alc883_adc_nids,
  5517. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5518. .channel_mode = alc883_3ST_6ch_modes,
  5519. .need_dac_fix = 1,
  5520. .input_mux = &alc883_capture_source,
  5521. .unsol_event = alc883_tagra_unsol_event,
  5522. .init_hook = alc883_tagra_automute,
  5523. },
  5524. [ALC883_TARGA_2ch_DIG] = {
  5525. .mixers = { alc883_tagra_2ch_mixer},
  5526. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5527. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5528. .dac_nids = alc883_dac_nids,
  5529. .dig_out_nid = ALC883_DIGOUT_NID,
  5530. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5531. .adc_nids = alc883_adc_nids,
  5532. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5533. .channel_mode = alc883_3ST_2ch_modes,
  5534. .input_mux = &alc883_capture_source,
  5535. .unsol_event = alc883_tagra_unsol_event,
  5536. .init_hook = alc883_tagra_automute,
  5537. },
  5538. [ALC888_DEMO_BOARD] = {
  5539. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5540. .init_verbs = { alc883_init_verbs },
  5541. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5542. .dac_nids = alc883_dac_nids,
  5543. .dig_out_nid = ALC883_DIGOUT_NID,
  5544. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5545. .adc_nids = alc883_adc_nids,
  5546. .dig_in_nid = ALC883_DIGIN_NID,
  5547. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5548. .channel_mode = alc883_sixstack_modes,
  5549. .input_mux = &alc883_capture_source,
  5550. },
  5551. [ALC883_ACER] = {
  5552. .mixers = { alc883_base_mixer,
  5553. alc883_chmode_mixer },
  5554. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5555. * and the headphone jack. Turn this on and rely on the
  5556. * standard mute methods whenever the user wants to turn
  5557. * these outputs off.
  5558. */
  5559. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5560. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5561. .dac_nids = alc883_dac_nids,
  5562. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5563. .adc_nids = alc883_adc_nids,
  5564. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5565. .channel_mode = alc883_3ST_2ch_modes,
  5566. .input_mux = &alc883_capture_source,
  5567. },
  5568. [ALC883_MEDION] = {
  5569. .mixers = { alc883_fivestack_mixer,
  5570. alc883_chmode_mixer },
  5571. .init_verbs = { alc883_init_verbs,
  5572. alc883_medion_eapd_verbs },
  5573. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5574. .dac_nids = alc883_dac_nids,
  5575. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5576. .adc_nids = alc883_adc_nids,
  5577. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5578. .channel_mode = alc883_sixstack_modes,
  5579. .input_mux = &alc883_capture_source,
  5580. },
  5581. [ALC883_LAPTOP_EAPD] = {
  5582. .mixers = { alc883_base_mixer,
  5583. alc883_chmode_mixer },
  5584. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5585. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5586. .dac_nids = alc883_dac_nids,
  5587. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5588. .adc_nids = alc883_adc_nids,
  5589. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5590. .channel_mode = alc883_3ST_2ch_modes,
  5591. .input_mux = &alc883_capture_source,
  5592. },
  5593. [ALC883_LENOVO_101E_2ch] = {
  5594. .mixers = { alc883_lenovo_101e_2ch_mixer},
  5595. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  5596. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5597. .dac_nids = alc883_dac_nids,
  5598. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5599. .adc_nids = alc883_adc_nids,
  5600. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5601. .channel_mode = alc883_3ST_2ch_modes,
  5602. .input_mux = &alc883_lenovo_101e_capture_source,
  5603. .unsol_event = alc883_lenovo_101e_unsol_event,
  5604. .init_hook = alc883_lenovo_101e_all_automute,
  5605. },
  5606. };
  5607. /*
  5608. * BIOS auto configuration
  5609. */
  5610. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  5611. hda_nid_t nid, int pin_type,
  5612. int dac_idx)
  5613. {
  5614. /* set as output */
  5615. struct alc_spec *spec = codec->spec;
  5616. int idx;
  5617. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5618. idx = 4;
  5619. else
  5620. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5621. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5622. pin_type);
  5623. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5624. AMP_OUT_UNMUTE);
  5625. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5626. }
  5627. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  5628. {
  5629. struct alc_spec *spec = codec->spec;
  5630. int i;
  5631. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5632. for (i = 0; i <= HDA_SIDE; i++) {
  5633. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5634. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5635. if (nid)
  5636. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  5637. i);
  5638. }
  5639. }
  5640. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  5641. {
  5642. struct alc_spec *spec = codec->spec;
  5643. hda_nid_t pin;
  5644. pin = spec->autocfg.hp_pins[0];
  5645. if (pin) /* connect to front */
  5646. /* use dac 0 */
  5647. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5648. }
  5649. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  5650. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  5651. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  5652. {
  5653. struct alc_spec *spec = codec->spec;
  5654. int i;
  5655. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5656. hda_nid_t nid = spec->autocfg.input_pins[i];
  5657. if (alc883_is_input_pin(nid)) {
  5658. snd_hda_codec_write(codec, nid, 0,
  5659. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5660. (i <= AUTO_PIN_FRONT_MIC ?
  5661. PIN_VREF80 : PIN_IN));
  5662. if (nid != ALC883_PIN_CD_NID)
  5663. snd_hda_codec_write(codec, nid, 0,
  5664. AC_VERB_SET_AMP_GAIN_MUTE,
  5665. AMP_OUT_MUTE);
  5666. }
  5667. }
  5668. }
  5669. /* almost identical with ALC880 parser... */
  5670. static int alc883_parse_auto_config(struct hda_codec *codec)
  5671. {
  5672. struct alc_spec *spec = codec->spec;
  5673. int err = alc880_parse_auto_config(codec);
  5674. if (err < 0)
  5675. return err;
  5676. else if (err > 0)
  5677. /* hack - override the init verbs */
  5678. spec->init_verbs[0] = alc883_auto_init_verbs;
  5679. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  5680. spec->num_mixers++;
  5681. return err;
  5682. }
  5683. /* additional initialization for auto-configuration model */
  5684. static void alc883_auto_init(struct hda_codec *codec)
  5685. {
  5686. alc883_auto_init_multi_out(codec);
  5687. alc883_auto_init_hp_out(codec);
  5688. alc883_auto_init_analog_input(codec);
  5689. }
  5690. static int patch_alc883(struct hda_codec *codec)
  5691. {
  5692. struct alc_spec *spec;
  5693. int err, board_config;
  5694. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5695. if (spec == NULL)
  5696. return -ENOMEM;
  5697. codec->spec = spec;
  5698. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  5699. alc883_models,
  5700. alc883_cfg_tbl);
  5701. if (board_config < 0) {
  5702. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  5703. "trying auto-probe from BIOS...\n");
  5704. board_config = ALC883_AUTO;
  5705. }
  5706. if (board_config == ALC883_AUTO) {
  5707. /* automatic parse from the BIOS config */
  5708. err = alc883_parse_auto_config(codec);
  5709. if (err < 0) {
  5710. alc_free(codec);
  5711. return err;
  5712. } else if (!err) {
  5713. printk(KERN_INFO
  5714. "hda_codec: Cannot set up configuration "
  5715. "from BIOS. Using base mode...\n");
  5716. board_config = ALC883_3ST_2ch_DIG;
  5717. }
  5718. }
  5719. if (board_config != ALC883_AUTO)
  5720. setup_preset(spec, &alc883_presets[board_config]);
  5721. spec->stream_name_analog = "ALC883 Analog";
  5722. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  5723. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  5724. spec->stream_name_digital = "ALC883 Digital";
  5725. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  5726. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  5727. if (!spec->adc_nids && spec->input_mux) {
  5728. spec->adc_nids = alc883_adc_nids;
  5729. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  5730. }
  5731. codec->patch_ops = alc_patch_ops;
  5732. if (board_config == ALC883_AUTO)
  5733. spec->init_hook = alc883_auto_init;
  5734. return 0;
  5735. }
  5736. /*
  5737. * ALC262 support
  5738. */
  5739. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  5740. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  5741. #define alc262_dac_nids alc260_dac_nids
  5742. #define alc262_adc_nids alc882_adc_nids
  5743. #define alc262_adc_nids_alt alc882_adc_nids_alt
  5744. #define alc262_modes alc260_modes
  5745. #define alc262_capture_source alc882_capture_source
  5746. static struct snd_kcontrol_new alc262_base_mixer[] = {
  5747. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5748. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5749. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5750. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5751. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5752. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5753. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5754. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5755. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5756. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5757. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5758. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5759. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5760. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5761. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  5762. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5763. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5764. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5765. { } /* end */
  5766. };
  5767. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  5768. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5769. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5770. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5771. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5772. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5773. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5774. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5775. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5776. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5777. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5778. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5779. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5780. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5781. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5782. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  5783. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5784. { } /* end */
  5785. };
  5786. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  5787. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5788. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5789. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5790. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5791. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5792. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5793. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5794. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5795. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5796. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5797. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5798. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5799. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5800. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5801. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5802. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5803. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5804. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  5805. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  5806. { } /* end */
  5807. };
  5808. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  5809. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5810. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5811. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5812. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5813. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5814. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5815. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5816. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5817. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  5818. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5819. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5820. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5821. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5822. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5823. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5824. { } /* end */
  5825. };
  5826. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  5827. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5828. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5829. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  5830. { } /* end */
  5831. };
  5832. #define alc262_capture_mixer alc882_capture_mixer
  5833. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  5834. /*
  5835. * generic initialization of ADC, input mixers and output mixers
  5836. */
  5837. static struct hda_verb alc262_init_verbs[] = {
  5838. /*
  5839. * Unmute ADC0-2 and set the default input to mic-in
  5840. */
  5841. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5842. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5843. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5844. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5845. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5846. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5847. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5848. * mixer widget
  5849. * Note: PASD motherboards uses the Line In 2 as the input for
  5850. * front panel mic (mic 2)
  5851. */
  5852. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5853. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5854. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5855. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5856. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5857. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5858. /*
  5859. * Set up output mixers (0x0c - 0x0e)
  5860. */
  5861. /* set vol=0 to output mixers */
  5862. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5863. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5864. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5865. /* set up input amps for analog loopback */
  5866. /* Amp Indices: DAC = 0, mixer = 1 */
  5867. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5868. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5869. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5870. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5871. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5872. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5873. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5874. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5875. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5876. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5877. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5878. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5879. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5880. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5881. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5882. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5883. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5884. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5885. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5886. /* FIXME: use matrix-type input source selection */
  5887. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5888. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5889. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5890. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5891. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5892. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5893. /* Input mixer2 */
  5894. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5895. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5896. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5897. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5898. /* Input mixer3 */
  5899. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5900. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5901. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5902. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5903. { }
  5904. };
  5905. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  5906. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5907. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5908. {}
  5909. };
  5910. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  5911. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5912. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5913. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5914. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5915. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5916. {}
  5917. };
  5918. /* mute/unmute internal speaker according to the hp jack and mute state */
  5919. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  5920. {
  5921. struct alc_spec *spec = codec->spec;
  5922. unsigned int mute;
  5923. if (force || !spec->sense_updated) {
  5924. unsigned int present;
  5925. /* need to execute and sync at first */
  5926. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  5927. present = snd_hda_codec_read(codec, 0x15, 0,
  5928. AC_VERB_GET_PIN_SENSE, 0);
  5929. spec->jack_present = (present & 0x80000000) != 0;
  5930. spec->sense_updated = 1;
  5931. }
  5932. if (spec->jack_present) {
  5933. /* mute internal speaker */
  5934. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5935. 0x80, 0x80);
  5936. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5937. 0x80, 0x80);
  5938. } else {
  5939. /* unmute internal speaker if necessary */
  5940. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  5941. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5942. 0x80, mute & 0x80);
  5943. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  5944. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5945. 0x80, mute & 0x80);
  5946. }
  5947. }
  5948. /* unsolicited event for HP jack sensing */
  5949. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  5950. unsigned int res)
  5951. {
  5952. if ((res >> 26) != ALC880_HP_EVENT)
  5953. return;
  5954. alc262_hippo_automute(codec, 1);
  5955. }
  5956. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  5957. {
  5958. struct alc_spec *spec = codec->spec;
  5959. unsigned int mute;
  5960. if (force || !spec->sense_updated) {
  5961. unsigned int present;
  5962. /* need to execute and sync at first */
  5963. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  5964. present = snd_hda_codec_read(codec, 0x1b, 0,
  5965. AC_VERB_GET_PIN_SENSE, 0);
  5966. spec->jack_present = (present & 0x80000000) != 0;
  5967. spec->sense_updated = 1;
  5968. }
  5969. if (spec->jack_present) {
  5970. /* mute internal speaker */
  5971. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5972. 0x80, 0x80);
  5973. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5974. 0x80, 0x80);
  5975. } else {
  5976. /* unmute internal speaker if necessary */
  5977. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  5978. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5979. 0x80, mute & 0x80);
  5980. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  5981. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5982. 0x80, mute & 0x80);
  5983. }
  5984. }
  5985. /* unsolicited event for HP jack sensing */
  5986. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  5987. unsigned int res)
  5988. {
  5989. if ((res >> 26) != ALC880_HP_EVENT)
  5990. return;
  5991. alc262_hippo1_automute(codec, 1);
  5992. }
  5993. /*
  5994. * fujitsu model
  5995. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  5996. */
  5997. #define ALC_HP_EVENT 0x37
  5998. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  5999. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6000. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6001. {}
  6002. };
  6003. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6004. .num_items = 2,
  6005. .items = {
  6006. { "Mic", 0x0 },
  6007. { "CD", 0x4 },
  6008. },
  6009. };
  6010. static struct hda_input_mux alc262_HP_capture_source = {
  6011. .num_items = 5,
  6012. .items = {
  6013. { "Mic", 0x0 },
  6014. { "Front Mic", 0x3 },
  6015. { "Line", 0x2 },
  6016. { "CD", 0x4 },
  6017. { "AUX IN", 0x6 },
  6018. },
  6019. };
  6020. /* mute/unmute internal speaker according to the hp jack and mute state */
  6021. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6022. {
  6023. struct alc_spec *spec = codec->spec;
  6024. unsigned int mute;
  6025. if (force || !spec->sense_updated) {
  6026. unsigned int present;
  6027. /* need to execute and sync at first */
  6028. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6029. present = snd_hda_codec_read(codec, 0x14, 0,
  6030. AC_VERB_GET_PIN_SENSE, 0);
  6031. spec->jack_present = (present & 0x80000000) != 0;
  6032. spec->sense_updated = 1;
  6033. }
  6034. if (spec->jack_present) {
  6035. /* mute internal speaker */
  6036. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6037. 0x80, 0x80);
  6038. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6039. 0x80, 0x80);
  6040. } else {
  6041. /* unmute internal speaker if necessary */
  6042. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6043. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6044. 0x80, mute & 0x80);
  6045. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6046. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6047. 0x80, mute & 0x80);
  6048. }
  6049. }
  6050. /* unsolicited event for HP jack sensing */
  6051. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6052. unsigned int res)
  6053. {
  6054. if ((res >> 26) != ALC_HP_EVENT)
  6055. return;
  6056. alc262_fujitsu_automute(codec, 1);
  6057. }
  6058. /* bind volumes of both NID 0x0c and 0x0d */
  6059. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6060. struct snd_ctl_elem_value *ucontrol)
  6061. {
  6062. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6063. long *valp = ucontrol->value.integer.value;
  6064. int change;
  6065. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6066. 0x7f, valp[0] & 0x7f);
  6067. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6068. 0x7f, valp[1] & 0x7f);
  6069. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6070. 0x7f, valp[0] & 0x7f);
  6071. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6072. 0x7f, valp[1] & 0x7f);
  6073. return change;
  6074. }
  6075. /* bind hp and internal speaker mute (with plug check) */
  6076. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6077. struct snd_ctl_elem_value *ucontrol)
  6078. {
  6079. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6080. long *valp = ucontrol->value.integer.value;
  6081. int change;
  6082. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6083. 0x80, valp[0] ? 0 : 0x80);
  6084. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6085. 0x80, valp[1] ? 0 : 0x80);
  6086. if (change || codec->in_resume)
  6087. alc262_fujitsu_automute(codec, codec->in_resume);
  6088. return change;
  6089. }
  6090. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6091. {
  6092. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6093. .name = "Master Playback Volume",
  6094. .info = snd_hda_mixer_amp_volume_info,
  6095. .get = snd_hda_mixer_amp_volume_get,
  6096. .put = alc262_fujitsu_master_vol_put,
  6097. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6098. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6099. },
  6100. {
  6101. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6102. .name = "Master Playback Switch",
  6103. .info = snd_hda_mixer_amp_switch_info,
  6104. .get = snd_hda_mixer_amp_switch_get,
  6105. .put = alc262_fujitsu_master_sw_put,
  6106. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6107. },
  6108. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6109. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6110. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6111. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6112. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6113. { } /* end */
  6114. };
  6115. /* additional init verbs for Benq laptops */
  6116. static struct hda_verb alc262_EAPD_verbs[] = {
  6117. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6118. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6119. {}
  6120. };
  6121. /* add playback controls from the parsed DAC table */
  6122. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6123. const struct auto_pin_cfg *cfg)
  6124. {
  6125. hda_nid_t nid;
  6126. int err;
  6127. spec->multiout.num_dacs = 1; /* only use one dac */
  6128. spec->multiout.dac_nids = spec->private_dac_nids;
  6129. spec->multiout.dac_nids[0] = 2;
  6130. nid = cfg->line_out_pins[0];
  6131. if (nid) {
  6132. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6133. "Front Playback Volume",
  6134. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6135. if (err < 0)
  6136. return err;
  6137. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6138. "Front Playback Switch",
  6139. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6140. if (err < 0)
  6141. return err;
  6142. }
  6143. nid = cfg->speaker_pins[0];
  6144. if (nid) {
  6145. if (nid == 0x16) {
  6146. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6147. "Speaker Playback Volume",
  6148. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6149. HDA_OUTPUT));
  6150. if (err < 0)
  6151. return err;
  6152. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6153. "Speaker Playback Switch",
  6154. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6155. HDA_OUTPUT));
  6156. if (err < 0)
  6157. return err;
  6158. } else {
  6159. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6160. "Speaker Playback Switch",
  6161. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6162. HDA_OUTPUT));
  6163. if (err < 0)
  6164. return err;
  6165. }
  6166. }
  6167. nid = cfg->hp_pins[0];
  6168. if (nid) {
  6169. /* spec->multiout.hp_nid = 2; */
  6170. if (nid == 0x16) {
  6171. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6172. "Headphone Playback Volume",
  6173. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6174. HDA_OUTPUT));
  6175. if (err < 0)
  6176. return err;
  6177. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6178. "Headphone Playback Switch",
  6179. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6180. HDA_OUTPUT));
  6181. if (err < 0)
  6182. return err;
  6183. } else {
  6184. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6185. "Headphone Playback Switch",
  6186. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6187. HDA_OUTPUT));
  6188. if (err < 0)
  6189. return err;
  6190. }
  6191. }
  6192. return 0;
  6193. }
  6194. /* identical with ALC880 */
  6195. #define alc262_auto_create_analog_input_ctls \
  6196. alc880_auto_create_analog_input_ctls
  6197. /*
  6198. * generic initialization of ADC, input mixers and output mixers
  6199. */
  6200. static struct hda_verb alc262_volume_init_verbs[] = {
  6201. /*
  6202. * Unmute ADC0-2 and set the default input to mic-in
  6203. */
  6204. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6205. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6206. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6207. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6208. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6209. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6210. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6211. * mixer widget
  6212. * Note: PASD motherboards uses the Line In 2 as the input for
  6213. * front panel mic (mic 2)
  6214. */
  6215. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6216. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6217. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6218. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6219. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6220. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6221. /*
  6222. * Set up output mixers (0x0c - 0x0f)
  6223. */
  6224. /* set vol=0 to output mixers */
  6225. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6226. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6227. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6228. /* set up input amps for analog loopback */
  6229. /* Amp Indices: DAC = 0, mixer = 1 */
  6230. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6231. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6232. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6233. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6234. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6235. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6236. /* FIXME: use matrix-type input source selection */
  6237. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6238. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6239. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6240. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6241. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6242. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6243. /* Input mixer2 */
  6244. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6245. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6246. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6247. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6248. /* Input mixer3 */
  6249. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6250. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6251. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6252. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6253. { }
  6254. };
  6255. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6256. /*
  6257. * Unmute ADC0-2 and set the default input to mic-in
  6258. */
  6259. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6260. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6261. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6262. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6263. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6264. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6265. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6266. * mixer widget
  6267. * Note: PASD motherboards uses the Line In 2 as the input for
  6268. * front panel mic (mic 2)
  6269. */
  6270. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6271. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6272. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6273. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6274. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6275. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6276. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6277. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6278. /*
  6279. * Set up output mixers (0x0c - 0x0e)
  6280. */
  6281. /* set vol=0 to output mixers */
  6282. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6283. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6284. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6285. /* set up input amps for analog loopback */
  6286. /* Amp Indices: DAC = 0, mixer = 1 */
  6287. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6288. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6289. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6290. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6291. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6292. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6293. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6294. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6295. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6296. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6297. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6298. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6299. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6300. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6301. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6302. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6303. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6304. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6305. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6306. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6307. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6308. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6309. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6310. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6311. /* FIXME: use matrix-type input source selection */
  6312. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6313. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6314. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6315. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6316. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6317. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6318. /* Input mixer2 */
  6319. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6320. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6321. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6322. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6323. /* Input mixer3 */
  6324. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6325. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6326. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6327. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6328. { }
  6329. };
  6330. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6331. /*
  6332. * Unmute ADC0-2 and set the default input to mic-in
  6333. */
  6334. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6335. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6336. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6337. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6338. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6339. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6340. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6341. * mixer widget
  6342. * Note: PASD motherboards uses the Line In 2 as the input for front
  6343. * panel mic (mic 2)
  6344. */
  6345. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6346. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6347. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6348. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6349. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6350. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6351. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6352. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6353. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6354. /*
  6355. * Set up output mixers (0x0c - 0x0e)
  6356. */
  6357. /* set vol=0 to output mixers */
  6358. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6359. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6360. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6361. /* set up input amps for analog loopback */
  6362. /* Amp Indices: DAC = 0, mixer = 1 */
  6363. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6364. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6365. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6366. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6367. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6368. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6369. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  6370. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  6371. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  6372. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  6373. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  6374. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  6375. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  6376. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6377. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6378. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6379. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6380. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  6381. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6382. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6383. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6384. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6385. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6386. /* FIXME: use matrix-type input source selection */
  6387. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6388. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6389. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  6390. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  6391. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  6392. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  6393. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  6394. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6395. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  6396. /* Input mixer2 */
  6397. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6398. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6399. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6400. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6401. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6402. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6403. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6404. /* Input mixer3 */
  6405. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6406. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6407. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6408. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6409. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6410. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6411. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6412. { }
  6413. };
  6414. /* pcm configuration: identiacal with ALC880 */
  6415. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  6416. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  6417. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  6418. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  6419. /*
  6420. * BIOS auto configuration
  6421. */
  6422. static int alc262_parse_auto_config(struct hda_codec *codec)
  6423. {
  6424. struct alc_spec *spec = codec->spec;
  6425. int err;
  6426. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  6427. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6428. alc262_ignore);
  6429. if (err < 0)
  6430. return err;
  6431. if (!spec->autocfg.line_outs)
  6432. return 0; /* can't find valid BIOS pin config */
  6433. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  6434. if (err < 0)
  6435. return err;
  6436. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  6437. if (err < 0)
  6438. return err;
  6439. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6440. if (spec->autocfg.dig_out_pin)
  6441. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  6442. if (spec->autocfg.dig_in_pin)
  6443. spec->dig_in_nid = ALC262_DIGIN_NID;
  6444. if (spec->kctl_alloc)
  6445. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6446. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  6447. spec->num_mux_defs = 1;
  6448. spec->input_mux = &spec->private_imux;
  6449. return 1;
  6450. }
  6451. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  6452. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  6453. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  6454. /* init callback for auto-configuration model -- overriding the default init */
  6455. static void alc262_auto_init(struct hda_codec *codec)
  6456. {
  6457. alc262_auto_init_multi_out(codec);
  6458. alc262_auto_init_hp_out(codec);
  6459. alc262_auto_init_analog_input(codec);
  6460. }
  6461. /*
  6462. * configuration and preset
  6463. */
  6464. static const char *alc262_models[ALC262_MODEL_LAST] = {
  6465. [ALC262_BASIC] = "basic",
  6466. [ALC262_HIPPO] = "hippo",
  6467. [ALC262_HIPPO_1] = "hippo_1",
  6468. [ALC262_FUJITSU] = "fujitsu",
  6469. [ALC262_HP_BPC] = "hp-bpc",
  6470. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  6471. [ALC262_BENQ_ED8] = "benq",
  6472. [ALC262_AUTO] = "auto",
  6473. };
  6474. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  6475. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  6476. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  6477. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  6478. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  6479. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  6480. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6481. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6482. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6483. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  6484. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6485. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6486. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6487. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  6488. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  6489. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  6490. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  6491. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  6492. {}
  6493. };
  6494. static struct alc_config_preset alc262_presets[] = {
  6495. [ALC262_BASIC] = {
  6496. .mixers = { alc262_base_mixer },
  6497. .init_verbs = { alc262_init_verbs },
  6498. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6499. .dac_nids = alc262_dac_nids,
  6500. .hp_nid = 0x03,
  6501. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6502. .channel_mode = alc262_modes,
  6503. .input_mux = &alc262_capture_source,
  6504. },
  6505. [ALC262_HIPPO] = {
  6506. .mixers = { alc262_base_mixer },
  6507. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  6508. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6509. .dac_nids = alc262_dac_nids,
  6510. .hp_nid = 0x03,
  6511. .dig_out_nid = ALC262_DIGOUT_NID,
  6512. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6513. .channel_mode = alc262_modes,
  6514. .input_mux = &alc262_capture_source,
  6515. .unsol_event = alc262_hippo_unsol_event,
  6516. },
  6517. [ALC262_HIPPO_1] = {
  6518. .mixers = { alc262_hippo1_mixer },
  6519. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  6520. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6521. .dac_nids = alc262_dac_nids,
  6522. .hp_nid = 0x02,
  6523. .dig_out_nid = ALC262_DIGOUT_NID,
  6524. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6525. .channel_mode = alc262_modes,
  6526. .input_mux = &alc262_capture_source,
  6527. .unsol_event = alc262_hippo1_unsol_event,
  6528. },
  6529. [ALC262_FUJITSU] = {
  6530. .mixers = { alc262_fujitsu_mixer },
  6531. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  6532. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6533. .dac_nids = alc262_dac_nids,
  6534. .hp_nid = 0x03,
  6535. .dig_out_nid = ALC262_DIGOUT_NID,
  6536. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6537. .channel_mode = alc262_modes,
  6538. .input_mux = &alc262_fujitsu_capture_source,
  6539. .unsol_event = alc262_fujitsu_unsol_event,
  6540. },
  6541. [ALC262_HP_BPC] = {
  6542. .mixers = { alc262_HP_BPC_mixer },
  6543. .init_verbs = { alc262_HP_BPC_init_verbs },
  6544. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6545. .dac_nids = alc262_dac_nids,
  6546. .hp_nid = 0x03,
  6547. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6548. .channel_mode = alc262_modes,
  6549. .input_mux = &alc262_HP_capture_source,
  6550. },
  6551. [ALC262_HP_BPC_D7000_WF] = {
  6552. .mixers = { alc262_HP_BPC_WildWest_mixer },
  6553. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6554. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6555. .dac_nids = alc262_dac_nids,
  6556. .hp_nid = 0x03,
  6557. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6558. .channel_mode = alc262_modes,
  6559. .input_mux = &alc262_HP_capture_source,
  6560. },
  6561. [ALC262_HP_BPC_D7000_WL] = {
  6562. .mixers = { alc262_HP_BPC_WildWest_mixer,
  6563. alc262_HP_BPC_WildWest_option_mixer },
  6564. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  6565. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6566. .dac_nids = alc262_dac_nids,
  6567. .hp_nid = 0x03,
  6568. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6569. .channel_mode = alc262_modes,
  6570. .input_mux = &alc262_HP_capture_source,
  6571. },
  6572. [ALC262_BENQ_ED8] = {
  6573. .mixers = { alc262_base_mixer },
  6574. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  6575. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  6576. .dac_nids = alc262_dac_nids,
  6577. .hp_nid = 0x03,
  6578. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  6579. .channel_mode = alc262_modes,
  6580. .input_mux = &alc262_capture_source,
  6581. },
  6582. };
  6583. static int patch_alc262(struct hda_codec *codec)
  6584. {
  6585. struct alc_spec *spec;
  6586. int board_config;
  6587. int err;
  6588. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6589. if (spec == NULL)
  6590. return -ENOMEM;
  6591. codec->spec = spec;
  6592. #if 0
  6593. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  6594. * under-run
  6595. */
  6596. {
  6597. int tmp;
  6598. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  6599. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  6600. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  6601. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  6602. }
  6603. #endif
  6604. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  6605. alc262_models,
  6606. alc262_cfg_tbl);
  6607. if (board_config < 0) {
  6608. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  6609. "trying auto-probe from BIOS...\n");
  6610. board_config = ALC262_AUTO;
  6611. }
  6612. if (board_config == ALC262_AUTO) {
  6613. /* automatic parse from the BIOS config */
  6614. err = alc262_parse_auto_config(codec);
  6615. if (err < 0) {
  6616. alc_free(codec);
  6617. return err;
  6618. } else if (!err) {
  6619. printk(KERN_INFO
  6620. "hda_codec: Cannot set up configuration "
  6621. "from BIOS. Using base mode...\n");
  6622. board_config = ALC262_BASIC;
  6623. }
  6624. }
  6625. if (board_config != ALC262_AUTO)
  6626. setup_preset(spec, &alc262_presets[board_config]);
  6627. spec->stream_name_analog = "ALC262 Analog";
  6628. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  6629. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  6630. spec->stream_name_digital = "ALC262 Digital";
  6631. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  6632. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  6633. if (!spec->adc_nids && spec->input_mux) {
  6634. /* check whether NID 0x07 is valid */
  6635. unsigned int wcap = get_wcaps(codec, 0x07);
  6636. /* get type */
  6637. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  6638. if (wcap != AC_WID_AUD_IN) {
  6639. spec->adc_nids = alc262_adc_nids_alt;
  6640. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  6641. spec->mixers[spec->num_mixers] =
  6642. alc262_capture_alt_mixer;
  6643. spec->num_mixers++;
  6644. } else {
  6645. spec->adc_nids = alc262_adc_nids;
  6646. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  6647. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  6648. spec->num_mixers++;
  6649. }
  6650. }
  6651. codec->patch_ops = alc_patch_ops;
  6652. if (board_config == ALC262_AUTO)
  6653. spec->init_hook = alc262_auto_init;
  6654. return 0;
  6655. }
  6656. /*
  6657. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  6658. */
  6659. /*
  6660. * set the path ways for 2 channel output
  6661. * need to set the codec line out and mic 1 pin widgets to inputs
  6662. */
  6663. static struct hda_verb alc861_threestack_ch2_init[] = {
  6664. /* set pin widget 1Ah (line in) for input */
  6665. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6666. /* set pin widget 18h (mic1/2) for input, for mic also enable
  6667. * the vref
  6668. */
  6669. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6670. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6671. #if 0
  6672. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6673. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6674. #endif
  6675. { } /* end */
  6676. };
  6677. /*
  6678. * 6ch mode
  6679. * need to set the codec line out and mic 1 pin widgets to outputs
  6680. */
  6681. static struct hda_verb alc861_threestack_ch6_init[] = {
  6682. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6683. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6684. /* set pin widget 18h (mic1) for output (CLFE)*/
  6685. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6686. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6687. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6688. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6689. #if 0
  6690. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6691. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6692. #endif
  6693. { } /* end */
  6694. };
  6695. static struct hda_channel_mode alc861_threestack_modes[2] = {
  6696. { 2, alc861_threestack_ch2_init },
  6697. { 6, alc861_threestack_ch6_init },
  6698. };
  6699. /* Set mic1 as input and unmute the mixer */
  6700. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  6701. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6702. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6703. { } /* end */
  6704. };
  6705. /* Set mic1 as output and mute mixer */
  6706. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  6707. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6708. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6709. { } /* end */
  6710. };
  6711. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  6712. { 2, alc861_uniwill_m31_ch2_init },
  6713. { 4, alc861_uniwill_m31_ch4_init },
  6714. };
  6715. /* Set mic1 and line-in as input and unmute the mixer */
  6716. static struct hda_verb alc861_asus_ch2_init[] = {
  6717. /* set pin widget 1Ah (line in) for input */
  6718. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6719. /* set pin widget 18h (mic1/2) for input, for mic also enable
  6720. * the vref
  6721. */
  6722. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6723. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6724. #if 0
  6725. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6726. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6727. #endif
  6728. { } /* end */
  6729. };
  6730. /* Set mic1 nad line-in as output and mute mixer */
  6731. static struct hda_verb alc861_asus_ch6_init[] = {
  6732. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6733. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6734. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6735. /* set pin widget 18h (mic1) for output (CLFE)*/
  6736. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6737. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6738. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6739. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6740. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6741. #if 0
  6742. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6743. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6744. #endif
  6745. { } /* end */
  6746. };
  6747. static struct hda_channel_mode alc861_asus_modes[2] = {
  6748. { 2, alc861_asus_ch2_init },
  6749. { 6, alc861_asus_ch6_init },
  6750. };
  6751. /* patch-ALC861 */
  6752. static struct snd_kcontrol_new alc861_base_mixer[] = {
  6753. /* output mixer control */
  6754. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6755. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6756. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6757. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6758. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6759. /*Input mixer control */
  6760. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6761. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6762. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6763. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6764. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6765. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6766. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6767. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6768. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6769. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6770. /* Capture mixer control */
  6771. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6772. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6773. {
  6774. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6775. .name = "Capture Source",
  6776. .count = 1,
  6777. .info = alc_mux_enum_info,
  6778. .get = alc_mux_enum_get,
  6779. .put = alc_mux_enum_put,
  6780. },
  6781. { } /* end */
  6782. };
  6783. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  6784. /* output mixer control */
  6785. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6786. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6787. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6788. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6789. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6790. /* Input mixer control */
  6791. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6792. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6793. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6794. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6795. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6796. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6797. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6798. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6799. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6800. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6801. /* Capture mixer control */
  6802. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6803. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6804. {
  6805. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6806. .name = "Capture Source",
  6807. .count = 1,
  6808. .info = alc_mux_enum_info,
  6809. .get = alc_mux_enum_get,
  6810. .put = alc_mux_enum_put,
  6811. },
  6812. {
  6813. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6814. .name = "Channel Mode",
  6815. .info = alc_ch_mode_info,
  6816. .get = alc_ch_mode_get,
  6817. .put = alc_ch_mode_put,
  6818. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  6819. },
  6820. { } /* end */
  6821. };
  6822. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  6823. /* output mixer control */
  6824. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6825. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6826. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6827. /*Capture mixer control */
  6828. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6829. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6830. {
  6831. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6832. .name = "Capture Source",
  6833. .count = 1,
  6834. .info = alc_mux_enum_info,
  6835. .get = alc_mux_enum_get,
  6836. .put = alc_mux_enum_put,
  6837. },
  6838. { } /* end */
  6839. };
  6840. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  6841. /* output mixer control */
  6842. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6843. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6844. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6845. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6846. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6847. /* Input mixer control */
  6848. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6849. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6850. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6851. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6852. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6853. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6854. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6855. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6856. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6857. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6858. /* Capture mixer control */
  6859. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6860. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6861. {
  6862. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6863. .name = "Capture Source",
  6864. .count = 1,
  6865. .info = alc_mux_enum_info,
  6866. .get = alc_mux_enum_get,
  6867. .put = alc_mux_enum_put,
  6868. },
  6869. {
  6870. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6871. .name = "Channel Mode",
  6872. .info = alc_ch_mode_info,
  6873. .get = alc_ch_mode_get,
  6874. .put = alc_ch_mode_put,
  6875. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6876. },
  6877. { } /* end */
  6878. };
  6879. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  6880. /* output mixer control */
  6881. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6882. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6883. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6884. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6885. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6886. /* Input mixer control */
  6887. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6888. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6889. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6890. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6891. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6892. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6893. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6894. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6895. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6896. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  6897. /* Capture mixer control */
  6898. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6899. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6900. {
  6901. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6902. .name = "Capture Source",
  6903. .count = 1,
  6904. .info = alc_mux_enum_info,
  6905. .get = alc_mux_enum_get,
  6906. .put = alc_mux_enum_put,
  6907. },
  6908. {
  6909. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6910. .name = "Channel Mode",
  6911. .info = alc_ch_mode_info,
  6912. .get = alc_ch_mode_get,
  6913. .put = alc_ch_mode_put,
  6914. .private_value = ARRAY_SIZE(alc861_asus_modes),
  6915. },
  6916. { }
  6917. };
  6918. /* additional mixer */
  6919. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  6920. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6921. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6922. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  6923. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  6924. { }
  6925. };
  6926. /*
  6927. * generic initialization of ADC, input mixers and output mixers
  6928. */
  6929. static struct hda_verb alc861_base_init_verbs[] = {
  6930. /*
  6931. * Unmute ADC0 and set the default input to mic-in
  6932. */
  6933. /* port-A for surround (rear panel) */
  6934. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6935. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6936. /* port-B for mic-in (rear panel) with vref */
  6937. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6938. /* port-C for line-in (rear panel) */
  6939. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6940. /* port-D for Front */
  6941. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6942. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6943. /* port-E for HP out (front panel) */
  6944. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6945. /* route front PCM to HP */
  6946. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6947. /* port-F for mic-in (front panel) with vref */
  6948. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6949. /* port-G for CLFE (rear panel) */
  6950. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6951. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6952. /* port-H for side (rear panel) */
  6953. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6954. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6955. /* CD-in */
  6956. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6957. /* route front mic to ADC1*/
  6958. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6959. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6960. /* Unmute DAC0~3 & spdif out*/
  6961. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6962. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6963. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6964. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6965. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6966. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6967. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6968. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6969. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6970. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6971. /* Unmute Stereo Mixer 15 */
  6972. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6973. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6974. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6975. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  6976. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6977. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6978. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6979. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6980. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6981. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6982. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6983. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6984. /* hp used DAC 3 (Front) */
  6985. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6986. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6987. { }
  6988. };
  6989. static struct hda_verb alc861_threestack_init_verbs[] = {
  6990. /*
  6991. * Unmute ADC0 and set the default input to mic-in
  6992. */
  6993. /* port-A for surround (rear panel) */
  6994. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6995. /* port-B for mic-in (rear panel) with vref */
  6996. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6997. /* port-C for line-in (rear panel) */
  6998. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6999. /* port-D for Front */
  7000. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7001. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7002. /* port-E for HP out (front panel) */
  7003. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  7004. /* route front PCM to HP */
  7005. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7006. /* port-F for mic-in (front panel) with vref */
  7007. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7008. /* port-G for CLFE (rear panel) */
  7009. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7010. /* port-H for side (rear panel) */
  7011. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7012. /* CD-in */
  7013. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7014. /* route front mic to ADC1*/
  7015. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7016. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7017. /* Unmute DAC0~3 & spdif out*/
  7018. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7019. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7020. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7021. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7022. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7023. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7024. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7025. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7026. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7027. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7028. /* Unmute Stereo Mixer 15 */
  7029. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7030. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7031. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7032. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7033. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7034. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7035. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7036. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7037. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7038. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7039. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7040. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7041. /* hp used DAC 3 (Front) */
  7042. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7043. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7044. { }
  7045. };
  7046. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  7047. /*
  7048. * Unmute ADC0 and set the default input to mic-in
  7049. */
  7050. /* port-A for surround (rear panel) */
  7051. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7052. /* port-B for mic-in (rear panel) with vref */
  7053. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7054. /* port-C for line-in (rear panel) */
  7055. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7056. /* port-D for Front */
  7057. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7058. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7059. /* port-E for HP out (front panel) */
  7060. /* this has to be set to VREF80 */
  7061. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7062. /* route front PCM to HP */
  7063. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7064. /* port-F for mic-in (front panel) with vref */
  7065. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7066. /* port-G for CLFE (rear panel) */
  7067. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7068. /* port-H for side (rear panel) */
  7069. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7070. /* CD-in */
  7071. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7072. /* route front mic to ADC1*/
  7073. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7074. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7075. /* Unmute DAC0~3 & spdif out*/
  7076. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7077. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7078. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7079. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7080. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7081. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7082. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7083. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7084. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7085. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7086. /* Unmute Stereo Mixer 15 */
  7087. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7088. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7089. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7090. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7091. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7092. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7093. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7094. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7095. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7096. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7097. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7098. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7099. /* hp used DAC 3 (Front) */
  7100. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7101. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7102. { }
  7103. };
  7104. static struct hda_verb alc861_asus_init_verbs[] = {
  7105. /*
  7106. * Unmute ADC0 and set the default input to mic-in
  7107. */
  7108. /* port-A for surround (rear panel)
  7109. * according to codec#0 this is the HP jack
  7110. */
  7111. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  7112. /* route front PCM to HP */
  7113. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  7114. /* port-B for mic-in (rear panel) with vref */
  7115. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7116. /* port-C for line-in (rear panel) */
  7117. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7118. /* port-D for Front */
  7119. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7120. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7121. /* port-E for HP out (front panel) */
  7122. /* this has to be set to VREF80 */
  7123. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7124. /* route front PCM to HP */
  7125. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7126. /* port-F for mic-in (front panel) with vref */
  7127. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7128. /* port-G for CLFE (rear panel) */
  7129. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7130. /* port-H for side (rear panel) */
  7131. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7132. /* CD-in */
  7133. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7134. /* route front mic to ADC1*/
  7135. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7136. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7137. /* Unmute DAC0~3 & spdif out*/
  7138. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7139. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7140. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7141. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7142. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7143. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7144. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7145. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7146. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7147. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7148. /* Unmute Stereo Mixer 15 */
  7149. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7150. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7151. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7152. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  7153. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7154. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7155. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7156. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7157. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7158. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7159. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7160. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7161. /* hp used DAC 3 (Front) */
  7162. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7163. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7164. { }
  7165. };
  7166. /* additional init verbs for ASUS laptops */
  7167. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  7168. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  7169. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  7170. { }
  7171. };
  7172. /*
  7173. * generic initialization of ADC, input mixers and output mixers
  7174. */
  7175. static struct hda_verb alc861_auto_init_verbs[] = {
  7176. /*
  7177. * Unmute ADC0 and set the default input to mic-in
  7178. */
  7179. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  7180. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7181. /* Unmute DAC0~3 & spdif out*/
  7182. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7183. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7184. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7185. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7186. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7187. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  7188. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7189. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7190. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7191. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7192. /* Unmute Stereo Mixer 15 */
  7193. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7194. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7195. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7196. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  7197. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7198. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7199. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7200. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7201. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7202. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7203. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7204. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7205. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7206. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7207. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7208. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7209. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7210. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7211. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7212. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7213. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  7214. { }
  7215. };
  7216. static struct hda_verb alc861_toshiba_init_verbs[] = {
  7217. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7218. { }
  7219. };
  7220. /* toggle speaker-output according to the hp-jack state */
  7221. static void alc861_toshiba_automute(struct hda_codec *codec)
  7222. {
  7223. unsigned int present;
  7224. present = snd_hda_codec_read(codec, 0x0f, 0,
  7225. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  7226. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  7227. 0x80, present ? 0x80 : 0);
  7228. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  7229. 0x80, present ? 0x80 : 0);
  7230. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  7231. 0x80, present ? 0 : 0x80);
  7232. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  7233. 0x80, present ? 0 : 0x80);
  7234. }
  7235. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  7236. unsigned int res)
  7237. {
  7238. if ((res >> 26) == ALC880_HP_EVENT)
  7239. alc861_toshiba_automute(codec);
  7240. }
  7241. /* pcm configuration: identiacal with ALC880 */
  7242. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  7243. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  7244. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  7245. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  7246. #define ALC861_DIGOUT_NID 0x07
  7247. static struct hda_channel_mode alc861_8ch_modes[1] = {
  7248. { 8, NULL }
  7249. };
  7250. static hda_nid_t alc861_dac_nids[4] = {
  7251. /* front, surround, clfe, side */
  7252. 0x03, 0x06, 0x05, 0x04
  7253. };
  7254. static hda_nid_t alc660_dac_nids[3] = {
  7255. /* front, clfe, surround */
  7256. 0x03, 0x05, 0x06
  7257. };
  7258. static hda_nid_t alc861_adc_nids[1] = {
  7259. /* ADC0-2 */
  7260. 0x08,
  7261. };
  7262. static struct hda_input_mux alc861_capture_source = {
  7263. .num_items = 5,
  7264. .items = {
  7265. { "Mic", 0x0 },
  7266. { "Front Mic", 0x3 },
  7267. { "Line", 0x1 },
  7268. { "CD", 0x4 },
  7269. { "Mixer", 0x5 },
  7270. },
  7271. };
  7272. /* fill in the dac_nids table from the parsed pin configuration */
  7273. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  7274. const struct auto_pin_cfg *cfg)
  7275. {
  7276. int i;
  7277. hda_nid_t nid;
  7278. spec->multiout.dac_nids = spec->private_dac_nids;
  7279. for (i = 0; i < cfg->line_outs; i++) {
  7280. nid = cfg->line_out_pins[i];
  7281. if (nid) {
  7282. if (i >= ARRAY_SIZE(alc861_dac_nids))
  7283. continue;
  7284. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  7285. }
  7286. }
  7287. spec->multiout.num_dacs = cfg->line_outs;
  7288. return 0;
  7289. }
  7290. /* add playback controls from the parsed DAC table */
  7291. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  7292. const struct auto_pin_cfg *cfg)
  7293. {
  7294. char name[32];
  7295. static const char *chname[4] = {
  7296. "Front", "Surround", NULL /*CLFE*/, "Side"
  7297. };
  7298. hda_nid_t nid;
  7299. int i, idx, err;
  7300. for (i = 0; i < cfg->line_outs; i++) {
  7301. nid = spec->multiout.dac_nids[i];
  7302. if (!nid)
  7303. continue;
  7304. if (nid == 0x05) {
  7305. /* Center/LFE */
  7306. err = add_control(spec, ALC_CTL_BIND_MUTE,
  7307. "Center Playback Switch",
  7308. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  7309. HDA_OUTPUT));
  7310. if (err < 0)
  7311. return err;
  7312. err = add_control(spec, ALC_CTL_BIND_MUTE,
  7313. "LFE Playback Switch",
  7314. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7315. HDA_OUTPUT));
  7316. if (err < 0)
  7317. return err;
  7318. } else {
  7319. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  7320. idx++)
  7321. if (nid == alc861_dac_nids[idx])
  7322. break;
  7323. sprintf(name, "%s Playback Switch", chname[idx]);
  7324. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  7325. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7326. HDA_OUTPUT));
  7327. if (err < 0)
  7328. return err;
  7329. }
  7330. }
  7331. return 0;
  7332. }
  7333. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  7334. {
  7335. int err;
  7336. hda_nid_t nid;
  7337. if (!pin)
  7338. return 0;
  7339. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  7340. nid = 0x03;
  7341. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7342. "Headphone Playback Switch",
  7343. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7344. if (err < 0)
  7345. return err;
  7346. spec->multiout.hp_nid = nid;
  7347. }
  7348. return 0;
  7349. }
  7350. /* create playback/capture controls for input pins */
  7351. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  7352. const struct auto_pin_cfg *cfg)
  7353. {
  7354. struct hda_input_mux *imux = &spec->private_imux;
  7355. int i, err, idx, idx1;
  7356. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7357. switch (cfg->input_pins[i]) {
  7358. case 0x0c:
  7359. idx1 = 1;
  7360. idx = 2; /* Line In */
  7361. break;
  7362. case 0x0f:
  7363. idx1 = 2;
  7364. idx = 2; /* Line In */
  7365. break;
  7366. case 0x0d:
  7367. idx1 = 0;
  7368. idx = 1; /* Mic In */
  7369. break;
  7370. case 0x10:
  7371. idx1 = 3;
  7372. idx = 1; /* Mic In */
  7373. break;
  7374. case 0x11:
  7375. idx1 = 4;
  7376. idx = 0; /* CD */
  7377. break;
  7378. default:
  7379. continue;
  7380. }
  7381. err = new_analog_input(spec, cfg->input_pins[i],
  7382. auto_pin_cfg_labels[i], idx, 0x15);
  7383. if (err < 0)
  7384. return err;
  7385. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7386. imux->items[imux->num_items].index = idx1;
  7387. imux->num_items++;
  7388. }
  7389. return 0;
  7390. }
  7391. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  7392. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7393. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7394. {
  7395. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7396. /* The multiple "Capture Source" controls confuse alsamixer
  7397. * So call somewhat different..
  7398. *FIXME: the controls appear in the "playback" view!
  7399. */
  7400. /* .name = "Capture Source", */
  7401. .name = "Input Source",
  7402. .count = 1,
  7403. .info = alc_mux_enum_info,
  7404. .get = alc_mux_enum_get,
  7405. .put = alc_mux_enum_put,
  7406. },
  7407. { } /* end */
  7408. };
  7409. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  7410. hda_nid_t nid,
  7411. int pin_type, int dac_idx)
  7412. {
  7413. /* set as output */
  7414. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  7415. pin_type);
  7416. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7417. AMP_OUT_UNMUTE);
  7418. }
  7419. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  7420. {
  7421. struct alc_spec *spec = codec->spec;
  7422. int i;
  7423. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  7424. for (i = 0; i < spec->autocfg.line_outs; i++) {
  7425. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  7426. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  7427. if (nid)
  7428. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  7429. spec->multiout.dac_nids[i]);
  7430. }
  7431. }
  7432. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  7433. {
  7434. struct alc_spec *spec = codec->spec;
  7435. hda_nid_t pin;
  7436. pin = spec->autocfg.hp_pins[0];
  7437. if (pin) /* connect to front */
  7438. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  7439. spec->multiout.dac_nids[0]);
  7440. }
  7441. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  7442. {
  7443. struct alc_spec *spec = codec->spec;
  7444. int i;
  7445. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7446. hda_nid_t nid = spec->autocfg.input_pins[i];
  7447. if (nid >= 0x0c && nid <= 0x11) {
  7448. snd_hda_codec_write(codec, nid, 0,
  7449. AC_VERB_SET_PIN_WIDGET_CONTROL,
  7450. i <= AUTO_PIN_FRONT_MIC ?
  7451. PIN_VREF80 : PIN_IN);
  7452. }
  7453. }
  7454. }
  7455. /* parse the BIOS configuration and set up the alc_spec */
  7456. /* return 1 if successful, 0 if the proper config is not found,
  7457. * or a negative error code
  7458. */
  7459. static int alc861_parse_auto_config(struct hda_codec *codec)
  7460. {
  7461. struct alc_spec *spec = codec->spec;
  7462. int err;
  7463. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  7464. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7465. alc861_ignore);
  7466. if (err < 0)
  7467. return err;
  7468. if (!spec->autocfg.line_outs)
  7469. return 0; /* can't find valid BIOS pin config */
  7470. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  7471. if (err < 0)
  7472. return err;
  7473. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7474. if (err < 0)
  7475. return err;
  7476. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  7477. if (err < 0)
  7478. return err;
  7479. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7480. if (err < 0)
  7481. return err;
  7482. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7483. if (spec->autocfg.dig_out_pin)
  7484. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  7485. if (spec->kctl_alloc)
  7486. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7487. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  7488. spec->num_mux_defs = 1;
  7489. spec->input_mux = &spec->private_imux;
  7490. spec->adc_nids = alc861_adc_nids;
  7491. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  7492. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  7493. spec->num_mixers++;
  7494. return 1;
  7495. }
  7496. /* additional initialization for auto-configuration model */
  7497. static void alc861_auto_init(struct hda_codec *codec)
  7498. {
  7499. alc861_auto_init_multi_out(codec);
  7500. alc861_auto_init_hp_out(codec);
  7501. alc861_auto_init_analog_input(codec);
  7502. }
  7503. /*
  7504. * configuration and preset
  7505. */
  7506. static const char *alc861_models[ALC861_MODEL_LAST] = {
  7507. [ALC861_3ST] = "3stack",
  7508. [ALC660_3ST] = "3stack-660",
  7509. [ALC861_3ST_DIG] = "3stack-dig",
  7510. [ALC861_6ST_DIG] = "6stack-dig",
  7511. [ALC861_UNIWILL_M31] = "uniwill-m31",
  7512. [ALC861_TOSHIBA] = "toshiba",
  7513. [ALC861_ASUS] = "asus",
  7514. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  7515. [ALC861_AUTO] = "auto",
  7516. };
  7517. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  7518. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  7519. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  7520. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  7521. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  7522. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
  7523. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  7524. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  7525. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  7526. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  7527. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  7528. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  7529. {}
  7530. };
  7531. static struct alc_config_preset alc861_presets[] = {
  7532. [ALC861_3ST] = {
  7533. .mixers = { alc861_3ST_mixer },
  7534. .init_verbs = { alc861_threestack_init_verbs },
  7535. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7536. .dac_nids = alc861_dac_nids,
  7537. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7538. .channel_mode = alc861_threestack_modes,
  7539. .need_dac_fix = 1,
  7540. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7541. .adc_nids = alc861_adc_nids,
  7542. .input_mux = &alc861_capture_source,
  7543. },
  7544. [ALC861_3ST_DIG] = {
  7545. .mixers = { alc861_base_mixer },
  7546. .init_verbs = { alc861_threestack_init_verbs },
  7547. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7548. .dac_nids = alc861_dac_nids,
  7549. .dig_out_nid = ALC861_DIGOUT_NID,
  7550. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7551. .channel_mode = alc861_threestack_modes,
  7552. .need_dac_fix = 1,
  7553. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7554. .adc_nids = alc861_adc_nids,
  7555. .input_mux = &alc861_capture_source,
  7556. },
  7557. [ALC861_6ST_DIG] = {
  7558. .mixers = { alc861_base_mixer },
  7559. .init_verbs = { alc861_base_init_verbs },
  7560. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7561. .dac_nids = alc861_dac_nids,
  7562. .dig_out_nid = ALC861_DIGOUT_NID,
  7563. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  7564. .channel_mode = alc861_8ch_modes,
  7565. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7566. .adc_nids = alc861_adc_nids,
  7567. .input_mux = &alc861_capture_source,
  7568. },
  7569. [ALC660_3ST] = {
  7570. .mixers = { alc861_3ST_mixer },
  7571. .init_verbs = { alc861_threestack_init_verbs },
  7572. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  7573. .dac_nids = alc660_dac_nids,
  7574. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  7575. .channel_mode = alc861_threestack_modes,
  7576. .need_dac_fix = 1,
  7577. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7578. .adc_nids = alc861_adc_nids,
  7579. .input_mux = &alc861_capture_source,
  7580. },
  7581. [ALC861_UNIWILL_M31] = {
  7582. .mixers = { alc861_uniwill_m31_mixer },
  7583. .init_verbs = { alc861_uniwill_m31_init_verbs },
  7584. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7585. .dac_nids = alc861_dac_nids,
  7586. .dig_out_nid = ALC861_DIGOUT_NID,
  7587. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7588. .channel_mode = alc861_uniwill_m31_modes,
  7589. .need_dac_fix = 1,
  7590. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7591. .adc_nids = alc861_adc_nids,
  7592. .input_mux = &alc861_capture_source,
  7593. },
  7594. [ALC861_TOSHIBA] = {
  7595. .mixers = { alc861_toshiba_mixer },
  7596. .init_verbs = { alc861_base_init_verbs,
  7597. alc861_toshiba_init_verbs },
  7598. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7599. .dac_nids = alc861_dac_nids,
  7600. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  7601. .channel_mode = alc883_3ST_2ch_modes,
  7602. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7603. .adc_nids = alc861_adc_nids,
  7604. .input_mux = &alc861_capture_source,
  7605. .unsol_event = alc861_toshiba_unsol_event,
  7606. .init_hook = alc861_toshiba_automute,
  7607. },
  7608. [ALC861_ASUS] = {
  7609. .mixers = { alc861_asus_mixer },
  7610. .init_verbs = { alc861_asus_init_verbs },
  7611. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7612. .dac_nids = alc861_dac_nids,
  7613. .dig_out_nid = ALC861_DIGOUT_NID,
  7614. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  7615. .channel_mode = alc861_asus_modes,
  7616. .need_dac_fix = 1,
  7617. .hp_nid = 0x06,
  7618. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7619. .adc_nids = alc861_adc_nids,
  7620. .input_mux = &alc861_capture_source,
  7621. },
  7622. [ALC861_ASUS_LAPTOP] = {
  7623. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  7624. .init_verbs = { alc861_asus_init_verbs,
  7625. alc861_asus_laptop_init_verbs },
  7626. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  7627. .dac_nids = alc861_dac_nids,
  7628. .dig_out_nid = ALC861_DIGOUT_NID,
  7629. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  7630. .channel_mode = alc883_3ST_2ch_modes,
  7631. .need_dac_fix = 1,
  7632. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  7633. .adc_nids = alc861_adc_nids,
  7634. .input_mux = &alc861_capture_source,
  7635. },
  7636. };
  7637. static int patch_alc861(struct hda_codec *codec)
  7638. {
  7639. struct alc_spec *spec;
  7640. int board_config;
  7641. int err;
  7642. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7643. if (spec == NULL)
  7644. return -ENOMEM;
  7645. codec->spec = spec;
  7646. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  7647. alc861_models,
  7648. alc861_cfg_tbl);
  7649. if (board_config < 0) {
  7650. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  7651. "trying auto-probe from BIOS...\n");
  7652. board_config = ALC861_AUTO;
  7653. }
  7654. if (board_config == ALC861_AUTO) {
  7655. /* automatic parse from the BIOS config */
  7656. err = alc861_parse_auto_config(codec);
  7657. if (err < 0) {
  7658. alc_free(codec);
  7659. return err;
  7660. } else if (!err) {
  7661. printk(KERN_INFO
  7662. "hda_codec: Cannot set up configuration "
  7663. "from BIOS. Using base mode...\n");
  7664. board_config = ALC861_3ST_DIG;
  7665. }
  7666. }
  7667. if (board_config != ALC861_AUTO)
  7668. setup_preset(spec, &alc861_presets[board_config]);
  7669. spec->stream_name_analog = "ALC861 Analog";
  7670. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  7671. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  7672. spec->stream_name_digital = "ALC861 Digital";
  7673. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  7674. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  7675. codec->patch_ops = alc_patch_ops;
  7676. if (board_config == ALC861_AUTO)
  7677. spec->init_hook = alc861_auto_init;
  7678. return 0;
  7679. }
  7680. /*
  7681. * ALC861-VD support
  7682. *
  7683. * Based on ALC882
  7684. *
  7685. * In addition, an independent DAC
  7686. */
  7687. #define ALC861VD_DIGOUT_NID 0x06
  7688. static hda_nid_t alc861vd_dac_nids[4] = {
  7689. /* front, surr, clfe, side surr */
  7690. 0x02, 0x03, 0x04, 0x05
  7691. };
  7692. /* dac_nids for ALC660vd are in a different order - according to
  7693. * Realtek's driver.
  7694. * This should probably tesult in a different mixer for 6stack models
  7695. * of ALC660vd codecs, but for now there is only 3stack mixer
  7696. * - and it is the same as in 861vd.
  7697. * adc_nids in ALC660vd are (is) the same as in 861vd
  7698. */
  7699. static hda_nid_t alc660vd_dac_nids[3] = {
  7700. /* front, rear, clfe, rear_surr */
  7701. 0x02, 0x04, 0x03
  7702. };
  7703. static hda_nid_t alc861vd_adc_nids[1] = {
  7704. /* ADC0 */
  7705. 0x09,
  7706. };
  7707. /* input MUX */
  7708. /* FIXME: should be a matrix-type input source selection */
  7709. static struct hda_input_mux alc861vd_capture_source = {
  7710. .num_items = 4,
  7711. .items = {
  7712. { "Mic", 0x0 },
  7713. { "Front Mic", 0x1 },
  7714. { "Line", 0x2 },
  7715. { "CD", 0x4 },
  7716. },
  7717. };
  7718. #define alc861vd_mux_enum_info alc_mux_enum_info
  7719. #define alc861vd_mux_enum_get alc_mux_enum_get
  7720. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  7721. struct snd_ctl_elem_value *ucontrol)
  7722. {
  7723. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7724. struct alc_spec *spec = codec->spec;
  7725. const struct hda_input_mux *imux = spec->input_mux;
  7726. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7727. static hda_nid_t capture_mixers[1] = { 0x22 };
  7728. hda_nid_t nid = capture_mixers[adc_idx];
  7729. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7730. unsigned int i, idx;
  7731. idx = ucontrol->value.enumerated.item[0];
  7732. if (idx >= imux->num_items)
  7733. idx = imux->num_items - 1;
  7734. if (*cur_val == idx && !codec->in_resume)
  7735. return 0;
  7736. for (i = 0; i < imux->num_items; i++) {
  7737. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7738. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7739. v | (imux->items[i].index << 8));
  7740. }
  7741. *cur_val = idx;
  7742. return 1;
  7743. }
  7744. /*
  7745. * 2ch mode
  7746. */
  7747. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  7748. { 2, NULL }
  7749. };
  7750. /*
  7751. * 6ch mode
  7752. */
  7753. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  7754. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  7755. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7756. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7757. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7758. { } /* end */
  7759. };
  7760. /*
  7761. * 8ch mode
  7762. */
  7763. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  7764. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7765. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7766. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7767. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7768. { } /* end */
  7769. };
  7770. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  7771. { 6, alc861vd_6stack_ch6_init },
  7772. { 8, alc861vd_6stack_ch8_init },
  7773. };
  7774. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  7775. {
  7776. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7777. .name = "Channel Mode",
  7778. .info = alc_ch_mode_info,
  7779. .get = alc_ch_mode_get,
  7780. .put = alc_ch_mode_put,
  7781. },
  7782. { } /* end */
  7783. };
  7784. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  7785. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  7786. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  7787. {
  7788. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7789. /* The multiple "Capture Source" controls confuse alsamixer
  7790. * So call somewhat different..
  7791. *FIXME: the controls appear in the "playback" view!
  7792. */
  7793. /* .name = "Capture Source", */
  7794. .name = "Input Source",
  7795. .count = 1,
  7796. .info = alc861vd_mux_enum_info,
  7797. .get = alc861vd_mux_enum_get,
  7798. .put = alc861vd_mux_enum_put,
  7799. },
  7800. { } /* end */
  7801. };
  7802. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  7803. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  7804. */
  7805. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  7806. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  7807. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  7808. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  7809. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  7810. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  7811. HDA_OUTPUT),
  7812. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  7813. HDA_OUTPUT),
  7814. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  7815. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  7816. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  7817. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  7818. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  7819. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7820. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7821. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7822. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7823. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7824. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7825. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7826. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7827. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7828. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7829. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7830. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7831. { } /* end */
  7832. };
  7833. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  7834. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  7835. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  7836. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  7837. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7838. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7839. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7840. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7841. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7842. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7843. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7844. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7845. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7846. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7847. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7848. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7849. { } /* end */
  7850. };
  7851. /*
  7852. * generic initialization of ADC, input mixers and output mixers
  7853. */
  7854. static struct hda_verb alc861vd_volume_init_verbs[] = {
  7855. /*
  7856. * Unmute ADC0 and set the default input to mic-in
  7857. */
  7858. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7859. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7860. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  7861. * the analog-loopback mixer widget
  7862. */
  7863. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7864. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7865. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7866. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7867. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7868. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  7869. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  7870. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  7871. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  7872. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  7873. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(8)},
  7874. /*
  7875. * Set up output mixers (0x02 - 0x05)
  7876. */
  7877. /* set vol=0 to output mixers */
  7878. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7879. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7880. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7881. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7882. /* set up input amps for analog loopback */
  7883. /* Amp Indices: DAC = 0, mixer = 1 */
  7884. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7885. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7886. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7887. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7888. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7889. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7890. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7891. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7892. { }
  7893. };
  7894. /*
  7895. * 3-stack pin configuration:
  7896. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  7897. */
  7898. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  7899. /*
  7900. * Set pin mode and muting
  7901. */
  7902. /* set front pin widgets 0x14 for output */
  7903. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7904. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7905. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7906. /* Mic (rear) pin: input vref at 80% */
  7907. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7908. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7909. /* Front Mic pin: input vref at 80% */
  7910. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7911. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7912. /* Line In pin: input */
  7913. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7914. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7915. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  7916. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7917. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7918. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7919. /* CD pin widget for input */
  7920. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7921. { }
  7922. };
  7923. /*
  7924. * 6-stack pin configuration:
  7925. */
  7926. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  7927. /*
  7928. * Set pin mode and muting
  7929. */
  7930. /* set front pin widgets 0x14 for output */
  7931. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7932. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7933. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7934. /* Rear Pin: output 1 (0x0d) */
  7935. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7936. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7937. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7938. /* CLFE Pin: output 2 (0x0e) */
  7939. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7940. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7941. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  7942. /* Side Pin: output 3 (0x0f) */
  7943. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7944. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7945. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  7946. /* Mic (rear) pin: input vref at 80% */
  7947. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7948. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7949. /* Front Mic pin: input vref at 80% */
  7950. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  7951. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7952. /* Line In pin: input */
  7953. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7954. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7955. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  7956. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7957. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  7958. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7959. /* CD pin widget for input */
  7960. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  7961. { }
  7962. };
  7963. /* pcm configuration: identiacal with ALC880 */
  7964. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  7965. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  7966. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  7967. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  7968. /*
  7969. * configuration and preset
  7970. */
  7971. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  7972. [ALC660VD_3ST] = "3stack-660",
  7973. [ALC861VD_3ST] = "3stack",
  7974. [ALC861VD_3ST_DIG] = "3stack-digout",
  7975. [ALC861VD_6ST_DIG] = "6stack-digout",
  7976. [ALC861VD_AUTO] = "auto",
  7977. };
  7978. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  7979. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  7980. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  7981. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  7982. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  7983. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_3ST),
  7984. {}
  7985. };
  7986. static struct alc_config_preset alc861vd_presets[] = {
  7987. [ALC660VD_3ST] = {
  7988. .mixers = { alc861vd_3st_mixer },
  7989. .init_verbs = { alc861vd_volume_init_verbs,
  7990. alc861vd_3stack_init_verbs },
  7991. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  7992. .dac_nids = alc660vd_dac_nids,
  7993. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  7994. .adc_nids = alc861vd_adc_nids,
  7995. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  7996. .channel_mode = alc861vd_3stack_2ch_modes,
  7997. .input_mux = &alc861vd_capture_source,
  7998. },
  7999. [ALC861VD_3ST] = {
  8000. .mixers = { alc861vd_3st_mixer },
  8001. .init_verbs = { alc861vd_volume_init_verbs,
  8002. alc861vd_3stack_init_verbs },
  8003. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8004. .dac_nids = alc861vd_dac_nids,
  8005. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8006. .channel_mode = alc861vd_3stack_2ch_modes,
  8007. .input_mux = &alc861vd_capture_source,
  8008. },
  8009. [ALC861VD_3ST_DIG] = {
  8010. .mixers = { alc861vd_3st_mixer },
  8011. .init_verbs = { alc861vd_volume_init_verbs,
  8012. alc861vd_3stack_init_verbs },
  8013. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8014. .dac_nids = alc861vd_dac_nids,
  8015. .dig_out_nid = ALC861VD_DIGOUT_NID,
  8016. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  8017. .channel_mode = alc861vd_3stack_2ch_modes,
  8018. .input_mux = &alc861vd_capture_source,
  8019. },
  8020. [ALC861VD_6ST_DIG] = {
  8021. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  8022. .init_verbs = { alc861vd_volume_init_verbs,
  8023. alc861vd_6stack_init_verbs },
  8024. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  8025. .dac_nids = alc861vd_dac_nids,
  8026. .dig_out_nid = ALC861VD_DIGOUT_NID,
  8027. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  8028. .channel_mode = alc861vd_6stack_modes,
  8029. .input_mux = &alc861vd_capture_source,
  8030. },
  8031. };
  8032. /*
  8033. * BIOS auto configuration
  8034. */
  8035. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  8036. hda_nid_t nid, int pin_type, int dac_idx)
  8037. {
  8038. /* set as output */
  8039. snd_hda_codec_write(codec, nid, 0,
  8040. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  8041. snd_hda_codec_write(codec, nid, 0,
  8042. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  8043. }
  8044. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  8045. {
  8046. struct alc_spec *spec = codec->spec;
  8047. int i;
  8048. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  8049. for (i = 0; i <= HDA_SIDE; i++) {
  8050. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8051. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8052. if (nid)
  8053. alc861vd_auto_set_output_and_unmute(codec, nid,
  8054. pin_type, i);
  8055. }
  8056. }
  8057. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  8058. {
  8059. struct alc_spec *spec = codec->spec;
  8060. hda_nid_t pin;
  8061. pin = spec->autocfg.hp_pins[0];
  8062. if (pin) /* connect to front and use dac 0 */
  8063. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  8064. }
  8065. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  8066. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  8067. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  8068. {
  8069. struct alc_spec *spec = codec->spec;
  8070. int i;
  8071. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8072. hda_nid_t nid = spec->autocfg.input_pins[i];
  8073. if (alc861vd_is_input_pin(nid)) {
  8074. snd_hda_codec_write(codec, nid, 0,
  8075. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8076. i <= AUTO_PIN_FRONT_MIC ?
  8077. PIN_VREF80 : PIN_IN);
  8078. if (nid != ALC861VD_PIN_CD_NID)
  8079. snd_hda_codec_write(codec, nid, 0,
  8080. AC_VERB_SET_AMP_GAIN_MUTE,
  8081. AMP_OUT_MUTE);
  8082. }
  8083. }
  8084. }
  8085. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  8086. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  8087. /* add playback controls from the parsed DAC table */
  8088. /* Based on ALC880 version. But ALC861VD has separate,
  8089. * different NIDs for mute/unmute switch and volume control */
  8090. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  8091. const struct auto_pin_cfg *cfg)
  8092. {
  8093. char name[32];
  8094. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  8095. hda_nid_t nid_v, nid_s;
  8096. int i, err;
  8097. for (i = 0; i < cfg->line_outs; i++) {
  8098. if (!spec->multiout.dac_nids[i])
  8099. continue;
  8100. nid_v = alc861vd_idx_to_mixer_vol(
  8101. alc880_dac_to_idx(
  8102. spec->multiout.dac_nids[i]));
  8103. nid_s = alc861vd_idx_to_mixer_switch(
  8104. alc880_dac_to_idx(
  8105. spec->multiout.dac_nids[i]));
  8106. if (i == 2) {
  8107. /* Center/LFE */
  8108. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8109. "Center Playback Volume",
  8110. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  8111. HDA_OUTPUT));
  8112. if (err < 0)
  8113. return err;
  8114. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8115. "LFE Playback Volume",
  8116. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  8117. HDA_OUTPUT));
  8118. if (err < 0)
  8119. return err;
  8120. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8121. "Center Playback Switch",
  8122. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  8123. HDA_INPUT));
  8124. if (err < 0)
  8125. return err;
  8126. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8127. "LFE Playback Switch",
  8128. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  8129. HDA_INPUT));
  8130. if (err < 0)
  8131. return err;
  8132. } else {
  8133. sprintf(name, "%s Playback Volume", chname[i]);
  8134. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8135. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  8136. HDA_OUTPUT));
  8137. if (err < 0)
  8138. return err;
  8139. sprintf(name, "%s Playback Switch", chname[i]);
  8140. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8141. HDA_COMPOSE_AMP_VAL(nid_v, 3, 2,
  8142. HDA_INPUT));
  8143. if (err < 0)
  8144. return err;
  8145. }
  8146. }
  8147. return 0;
  8148. }
  8149. /* add playback controls for speaker and HP outputs */
  8150. /* Based on ALC880 version. But ALC861VD has separate,
  8151. * different NIDs for mute/unmute switch and volume control */
  8152. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  8153. hda_nid_t pin, const char *pfx)
  8154. {
  8155. hda_nid_t nid_v, nid_s;
  8156. int err;
  8157. char name[32];
  8158. if (!pin)
  8159. return 0;
  8160. if (alc880_is_fixed_pin(pin)) {
  8161. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  8162. /* specify the DAC as the extra output */
  8163. if (!spec->multiout.hp_nid)
  8164. spec->multiout.hp_nid = nid_v;
  8165. else
  8166. spec->multiout.extra_out_nid[0] = nid_v;
  8167. /* control HP volume/switch on the output mixer amp */
  8168. nid_v = alc861vd_idx_to_mixer_vol(
  8169. alc880_fixed_pin_idx(pin));
  8170. nid_s = alc861vd_idx_to_mixer_switch(
  8171. alc880_fixed_pin_idx(pin));
  8172. sprintf(name, "%s Playback Volume", pfx);
  8173. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8174. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  8175. if (err < 0)
  8176. return err;
  8177. sprintf(name, "%s Playback Switch", pfx);
  8178. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8179. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  8180. if (err < 0)
  8181. return err;
  8182. } else if (alc880_is_multi_pin(pin)) {
  8183. /* set manual connection */
  8184. /* we have only a switch on HP-out PIN */
  8185. sprintf(name, "%s Playback Switch", pfx);
  8186. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8187. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  8188. if (err < 0)
  8189. return err;
  8190. }
  8191. return 0;
  8192. }
  8193. /* parse the BIOS configuration and set up the alc_spec
  8194. * return 1 if successful, 0 if the proper config is not found,
  8195. * or a negative error code
  8196. * Based on ALC880 version - had to change it to override
  8197. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  8198. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  8199. {
  8200. struct alc_spec *spec = codec->spec;
  8201. int err;
  8202. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  8203. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8204. alc861vd_ignore);
  8205. if (err < 0)
  8206. return err;
  8207. if (!spec->autocfg.line_outs)
  8208. return 0; /* can't find valid BIOS pin config */
  8209. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  8210. if (err < 0)
  8211. return err;
  8212. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8213. if (err < 0)
  8214. return err;
  8215. err = alc861vd_auto_create_extra_out(spec,
  8216. spec->autocfg.speaker_pins[0],
  8217. "Speaker");
  8218. if (err < 0)
  8219. return err;
  8220. err = alc861vd_auto_create_extra_out(spec,
  8221. spec->autocfg.hp_pins[0],
  8222. "Headphone");
  8223. if (err < 0)
  8224. return err;
  8225. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8226. if (err < 0)
  8227. return err;
  8228. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8229. if (spec->autocfg.dig_out_pin)
  8230. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  8231. if (spec->kctl_alloc)
  8232. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8233. spec->init_verbs[spec->num_init_verbs++]
  8234. = alc861vd_volume_init_verbs;
  8235. spec->num_mux_defs = 1;
  8236. spec->input_mux = &spec->private_imux;
  8237. return 1;
  8238. }
  8239. /* additional initialization for auto-configuration model */
  8240. static void alc861vd_auto_init(struct hda_codec *codec)
  8241. {
  8242. alc861vd_auto_init_multi_out(codec);
  8243. alc861vd_auto_init_hp_out(codec);
  8244. alc861vd_auto_init_analog_input(codec);
  8245. }
  8246. static int patch_alc861vd(struct hda_codec *codec)
  8247. {
  8248. struct alc_spec *spec;
  8249. int err, board_config;
  8250. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8251. if (spec == NULL)
  8252. return -ENOMEM;
  8253. codec->spec = spec;
  8254. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  8255. alc861vd_models,
  8256. alc861vd_cfg_tbl);
  8257. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  8258. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  8259. "ALC861VD, trying auto-probe from BIOS...\n");
  8260. board_config = ALC861VD_AUTO;
  8261. }
  8262. if (board_config == ALC861VD_AUTO) {
  8263. /* automatic parse from the BIOS config */
  8264. err = alc861vd_parse_auto_config(codec);
  8265. if (err < 0) {
  8266. alc_free(codec);
  8267. return err;
  8268. } else if (!err) {
  8269. printk(KERN_INFO
  8270. "hda_codec: Cannot set up configuration "
  8271. "from BIOS. Using base mode...\n");
  8272. board_config = ALC861VD_3ST;
  8273. }
  8274. }
  8275. if (board_config != ALC861VD_AUTO)
  8276. setup_preset(spec, &alc861vd_presets[board_config]);
  8277. spec->stream_name_analog = "ALC861VD Analog";
  8278. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  8279. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  8280. spec->stream_name_digital = "ALC861VD Digital";
  8281. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  8282. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  8283. spec->adc_nids = alc861vd_adc_nids;
  8284. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  8285. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  8286. spec->num_mixers++;
  8287. codec->patch_ops = alc_patch_ops;
  8288. if (board_config == ALC861VD_AUTO)
  8289. spec->init_hook = alc861vd_auto_init;
  8290. return 0;
  8291. }
  8292. /*
  8293. * ALC662 support
  8294. *
  8295. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  8296. * configuration. Each pin widget can choose any input DACs and a mixer.
  8297. * Each ADC is connected from a mixer of all inputs. This makes possible
  8298. * 6-channel independent captures.
  8299. *
  8300. * In addition, an independent DAC for the multi-playback (not used in this
  8301. * driver yet).
  8302. */
  8303. #define ALC662_DIGOUT_NID 0x06
  8304. #define ALC662_DIGIN_NID 0x0a
  8305. static hda_nid_t alc662_dac_nids[4] = {
  8306. /* front, rear, clfe, rear_surr */
  8307. 0x02, 0x03, 0x04
  8308. };
  8309. static hda_nid_t alc662_adc_nids[1] = {
  8310. /* ADC1-2 */
  8311. 0x09,
  8312. };
  8313. /* input MUX */
  8314. /* FIXME: should be a matrix-type input source selection */
  8315. static struct hda_input_mux alc662_capture_source = {
  8316. .num_items = 4,
  8317. .items = {
  8318. { "Mic", 0x0 },
  8319. { "Front Mic", 0x1 },
  8320. { "Line", 0x2 },
  8321. { "CD", 0x4 },
  8322. },
  8323. };
  8324. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  8325. .num_items = 2,
  8326. .items = {
  8327. { "Mic", 0x1 },
  8328. { "Line", 0x2 },
  8329. },
  8330. };
  8331. #define alc662_mux_enum_info alc_mux_enum_info
  8332. #define alc662_mux_enum_get alc_mux_enum_get
  8333. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  8334. struct snd_ctl_elem_value *ucontrol)
  8335. {
  8336. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8337. struct alc_spec *spec = codec->spec;
  8338. const struct hda_input_mux *imux = spec->input_mux;
  8339. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8340. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  8341. hda_nid_t nid = capture_mixers[adc_idx];
  8342. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8343. unsigned int i, idx;
  8344. idx = ucontrol->value.enumerated.item[0];
  8345. if (idx >= imux->num_items)
  8346. idx = imux->num_items - 1;
  8347. if (*cur_val == idx && !codec->in_resume)
  8348. return 0;
  8349. for (i = 0; i < imux->num_items; i++) {
  8350. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8351. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8352. v | (imux->items[i].index << 8));
  8353. }
  8354. *cur_val = idx;
  8355. return 1;
  8356. }
  8357. /*
  8358. * 2ch mode
  8359. */
  8360. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  8361. { 2, NULL }
  8362. };
  8363. /*
  8364. * 2ch mode
  8365. */
  8366. static struct hda_verb alc662_3ST_ch2_init[] = {
  8367. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  8368. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  8369. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  8370. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  8371. { } /* end */
  8372. };
  8373. /*
  8374. * 6ch mode
  8375. */
  8376. static struct hda_verb alc662_3ST_ch6_init[] = {
  8377. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8378. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  8379. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  8380. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8381. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  8382. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8383. { } /* end */
  8384. };
  8385. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  8386. { 2, alc662_3ST_ch2_init },
  8387. { 6, alc662_3ST_ch6_init },
  8388. };
  8389. /*
  8390. * 2ch mode
  8391. */
  8392. static struct hda_verb alc662_sixstack_ch6_init[] = {
  8393. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8394. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8395. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8396. { } /* end */
  8397. };
  8398. /*
  8399. * 6ch mode
  8400. */
  8401. static struct hda_verb alc662_sixstack_ch8_init[] = {
  8402. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8403. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8404. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8405. { } /* end */
  8406. };
  8407. static struct hda_channel_mode alc662_5stack_modes[2] = {
  8408. { 2, alc662_sixstack_ch6_init },
  8409. { 6, alc662_sixstack_ch8_init },
  8410. };
  8411. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8412. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8413. */
  8414. static struct snd_kcontrol_new alc662_base_mixer[] = {
  8415. /* output mixer control */
  8416. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  8417. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  8418. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  8419. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8420. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  8421. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  8422. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  8423. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  8424. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8425. /*Input mixer control */
  8426. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  8427. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  8428. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  8429. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  8430. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  8431. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  8432. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  8433. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  8434. /* Capture mixer control */
  8435. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8436. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8437. {
  8438. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8439. .name = "Capture Source",
  8440. .count = 1,
  8441. .info = alc_mux_enum_info,
  8442. .get = alc_mux_enum_get,
  8443. .put = alc_mux_enum_put,
  8444. },
  8445. { } /* end */
  8446. };
  8447. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  8448. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8449. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  8450. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8451. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8452. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8453. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8454. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8455. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8456. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8457. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8458. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8459. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8460. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8461. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8462. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8463. {
  8464. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8465. /* .name = "Capture Source", */
  8466. .name = "Input Source",
  8467. .count = 1,
  8468. .info = alc662_mux_enum_info,
  8469. .get = alc662_mux_enum_get,
  8470. .put = alc662_mux_enum_put,
  8471. },
  8472. { } /* end */
  8473. };
  8474. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  8475. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8476. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  8477. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8478. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  8479. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  8480. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  8481. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  8482. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  8483. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8484. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8485. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8486. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8487. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8488. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8489. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8490. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8491. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8492. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8493. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8494. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8495. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8496. {
  8497. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8498. /* .name = "Capture Source", */
  8499. .name = "Input Source",
  8500. .count = 1,
  8501. .info = alc662_mux_enum_info,
  8502. .get = alc662_mux_enum_get,
  8503. .put = alc662_mux_enum_put,
  8504. },
  8505. { } /* end */
  8506. };
  8507. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  8508. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8509. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  8510. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8511. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  8512. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8513. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8514. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8515. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8516. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8517. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8518. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8519. {
  8520. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8521. /* .name = "Capture Source", */
  8522. .name = "Input Source",
  8523. .count = 1,
  8524. .info = alc662_mux_enum_info,
  8525. .get = alc662_mux_enum_get,
  8526. .put = alc662_mux_enum_put,
  8527. },
  8528. { } /* end */
  8529. };
  8530. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  8531. {
  8532. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8533. .name = "Channel Mode",
  8534. .info = alc_ch_mode_info,
  8535. .get = alc_ch_mode_get,
  8536. .put = alc_ch_mode_put,
  8537. },
  8538. { } /* end */
  8539. };
  8540. static struct hda_verb alc662_init_verbs[] = {
  8541. /* ADC: mute amp left and right */
  8542. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8543. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8544. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  8545. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8546. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8547. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8548. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8549. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8550. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8551. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8552. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8553. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8554. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8555. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8556. /* Front Pin: output 0 (0x0c) */
  8557. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8558. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8559. /* Rear Pin: output 1 (0x0d) */
  8560. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8561. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8562. /* CLFE Pin: output 2 (0x0e) */
  8563. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8564. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8565. /* Mic (rear) pin: input vref at 80% */
  8566. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8567. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8568. /* Front Mic pin: input vref at 80% */
  8569. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8570. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8571. /* Line In pin: input */
  8572. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8573. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8574. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  8575. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8576. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8577. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  8578. /* CD pin widget for input */
  8579. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8580. /* FIXME: use matrix-type input source selection */
  8581. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  8582. /* Input mixer */
  8583. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8584. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8585. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8586. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8587. { }
  8588. };
  8589. static struct hda_verb alc662_sue_init_verbs[] = {
  8590. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  8591. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  8592. {}
  8593. };
  8594. /*
  8595. * generic initialization of ADC, input mixers and output mixers
  8596. */
  8597. static struct hda_verb alc662_auto_init_verbs[] = {
  8598. /*
  8599. * Unmute ADC and set the default input to mic-in
  8600. */
  8601. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8602. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8603. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  8604. * mixer widget
  8605. * Note: PASD motherboards uses the Line In 2 as the input for front
  8606. * panel mic (mic 2)
  8607. */
  8608. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  8609. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8610. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8611. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8612. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8613. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8614. /*
  8615. * Set up output mixers (0x0c - 0x0f)
  8616. */
  8617. /* set vol=0 to output mixers */
  8618. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8619. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8620. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8621. /* set up input amps for analog loopback */
  8622. /* Amp Indices: DAC = 0, mixer = 1 */
  8623. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8624. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8625. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8626. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8627. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8628. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8629. /* FIXME: use matrix-type input source selection */
  8630. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  8631. /* Input mixer */
  8632. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8633. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8634. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8635. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  8636. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8637. { }
  8638. };
  8639. /* capture mixer elements */
  8640. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  8641. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8642. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8643. {
  8644. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8645. /* The multiple "Capture Source" controls confuse alsamixer
  8646. * So call somewhat different..
  8647. * FIXME: the controls appear in the "playback" view!
  8648. */
  8649. /* .name = "Capture Source", */
  8650. .name = "Input Source",
  8651. .count = 1,
  8652. .info = alc882_mux_enum_info,
  8653. .get = alc882_mux_enum_get,
  8654. .put = alc882_mux_enum_put,
  8655. },
  8656. { } /* end */
  8657. };
  8658. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  8659. {
  8660. unsigned int present;
  8661. unsigned char bits;
  8662. present = snd_hda_codec_read(codec, 0x14, 0,
  8663. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8664. bits = present ? 0x80 : 0;
  8665. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  8666. 0x80, bits);
  8667. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  8668. 0x80, bits);
  8669. }
  8670. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  8671. {
  8672. unsigned int present;
  8673. unsigned char bits;
  8674. present = snd_hda_codec_read(codec, 0x1b, 0,
  8675. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8676. bits = present ? 0x80 : 0;
  8677. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  8678. 0x80, bits);
  8679. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  8680. 0x80, bits);
  8681. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8682. 0x80, bits);
  8683. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8684. 0x80, bits);
  8685. }
  8686. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  8687. unsigned int res)
  8688. {
  8689. if ((res >> 26) == ALC880_HP_EVENT)
  8690. alc662_lenovo_101e_all_automute(codec);
  8691. if ((res >> 26) == ALC880_FRONT_EVENT)
  8692. alc662_lenovo_101e_ispeaker_automute(codec);
  8693. }
  8694. /* pcm configuration: identiacal with ALC880 */
  8695. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  8696. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  8697. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  8698. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  8699. /*
  8700. * configuration and preset
  8701. */
  8702. static const char *alc662_models[ALC662_MODEL_LAST] = {
  8703. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  8704. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  8705. [ALC662_3ST_6ch] = "3stack-6ch",
  8706. [ALC662_5ST_DIG] = "6stack-dig",
  8707. [ALC662_LENOVO_101E] = "lenovo-101e",
  8708. [ALC662_AUTO] = "auto",
  8709. };
  8710. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  8711. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  8712. {}
  8713. };
  8714. static struct alc_config_preset alc662_presets[] = {
  8715. [ALC662_3ST_2ch_DIG] = {
  8716. .mixers = { alc662_3ST_2ch_mixer },
  8717. .init_verbs = { alc662_init_verbs },
  8718. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  8719. .dac_nids = alc662_dac_nids,
  8720. .dig_out_nid = ALC662_DIGOUT_NID,
  8721. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  8722. .adc_nids = alc662_adc_nids,
  8723. .dig_in_nid = ALC662_DIGIN_NID,
  8724. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  8725. .channel_mode = alc662_3ST_2ch_modes,
  8726. .input_mux = &alc662_capture_source,
  8727. },
  8728. [ALC662_3ST_6ch_DIG] = {
  8729. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  8730. .init_verbs = { alc662_init_verbs },
  8731. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  8732. .dac_nids = alc662_dac_nids,
  8733. .dig_out_nid = ALC662_DIGOUT_NID,
  8734. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  8735. .adc_nids = alc662_adc_nids,
  8736. .dig_in_nid = ALC662_DIGIN_NID,
  8737. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  8738. .channel_mode = alc662_3ST_6ch_modes,
  8739. .need_dac_fix = 1,
  8740. .input_mux = &alc662_capture_source,
  8741. },
  8742. [ALC662_3ST_6ch] = {
  8743. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  8744. .init_verbs = { alc662_init_verbs },
  8745. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  8746. .dac_nids = alc662_dac_nids,
  8747. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  8748. .adc_nids = alc662_adc_nids,
  8749. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  8750. .channel_mode = alc662_3ST_6ch_modes,
  8751. .need_dac_fix = 1,
  8752. .input_mux = &alc662_capture_source,
  8753. },
  8754. [ALC662_5ST_DIG] = {
  8755. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  8756. .init_verbs = { alc662_init_verbs },
  8757. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  8758. .dac_nids = alc662_dac_nids,
  8759. .dig_out_nid = ALC662_DIGOUT_NID,
  8760. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  8761. .adc_nids = alc662_adc_nids,
  8762. .dig_in_nid = ALC662_DIGIN_NID,
  8763. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  8764. .channel_mode = alc662_5stack_modes,
  8765. .input_mux = &alc662_capture_source,
  8766. },
  8767. [ALC662_LENOVO_101E] = {
  8768. .mixers = { alc662_lenovo_101e_mixer },
  8769. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  8770. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  8771. .dac_nids = alc662_dac_nids,
  8772. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  8773. .adc_nids = alc662_adc_nids,
  8774. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  8775. .channel_mode = alc662_3ST_2ch_modes,
  8776. .input_mux = &alc662_lenovo_101e_capture_source,
  8777. .unsol_event = alc662_lenovo_101e_unsol_event,
  8778. .init_hook = alc662_lenovo_101e_all_automute,
  8779. },
  8780. };
  8781. /*
  8782. * BIOS auto configuration
  8783. */
  8784. /* add playback controls from the parsed DAC table */
  8785. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  8786. const struct auto_pin_cfg *cfg)
  8787. {
  8788. char name[32];
  8789. static const char *chname[4] = {
  8790. "Front", "Surround", NULL /*CLFE*/, "Side"
  8791. };
  8792. hda_nid_t nid;
  8793. int i, err;
  8794. for (i = 0; i < cfg->line_outs; i++) {
  8795. if (!spec->multiout.dac_nids[i])
  8796. continue;
  8797. nid = alc880_idx_to_dac(i);
  8798. if (i == 2) {
  8799. /* Center/LFE */
  8800. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8801. "Center Playback Volume",
  8802. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8803. HDA_OUTPUT));
  8804. if (err < 0)
  8805. return err;
  8806. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8807. "LFE Playback Volume",
  8808. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8809. HDA_OUTPUT));
  8810. if (err < 0)
  8811. return err;
  8812. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8813. "Center Playback Switch",
  8814. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  8815. HDA_INPUT));
  8816. if (err < 0)
  8817. return err;
  8818. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8819. "LFE Playback Switch",
  8820. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  8821. HDA_INPUT));
  8822. if (err < 0)
  8823. return err;
  8824. } else {
  8825. sprintf(name, "%s Playback Volume", chname[i]);
  8826. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8827. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8828. HDA_OUTPUT));
  8829. if (err < 0)
  8830. return err;
  8831. sprintf(name, "%s Playback Switch", chname[i]);
  8832. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8833. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  8834. HDA_INPUT));
  8835. if (err < 0)
  8836. return err;
  8837. }
  8838. }
  8839. return 0;
  8840. }
  8841. /* add playback controls for speaker and HP outputs */
  8842. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  8843. const char *pfx)
  8844. {
  8845. hda_nid_t nid;
  8846. int err;
  8847. char name[32];
  8848. if (!pin)
  8849. return 0;
  8850. if (alc880_is_fixed_pin(pin)) {
  8851. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  8852. /* printk("DAC nid=%x\n",nid); */
  8853. /* specify the DAC as the extra output */
  8854. if (!spec->multiout.hp_nid)
  8855. spec->multiout.hp_nid = nid;
  8856. else
  8857. spec->multiout.extra_out_nid[0] = nid;
  8858. /* control HP volume/switch on the output mixer amp */
  8859. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  8860. sprintf(name, "%s Playback Volume", pfx);
  8861. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8862. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8863. if (err < 0)
  8864. return err;
  8865. sprintf(name, "%s Playback Switch", pfx);
  8866. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8867. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  8868. if (err < 0)
  8869. return err;
  8870. } else if (alc880_is_multi_pin(pin)) {
  8871. /* set manual connection */
  8872. /* we have only a switch on HP-out PIN */
  8873. sprintf(name, "%s Playback Switch", pfx);
  8874. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8875. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  8876. if (err < 0)
  8877. return err;
  8878. }
  8879. return 0;
  8880. }
  8881. /* create playback/capture controls for input pins */
  8882. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  8883. const struct auto_pin_cfg *cfg)
  8884. {
  8885. struct hda_input_mux *imux = &spec->private_imux;
  8886. int i, err, idx;
  8887. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8888. if (alc880_is_input_pin(cfg->input_pins[i])) {
  8889. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  8890. err = new_analog_input(spec, cfg->input_pins[i],
  8891. auto_pin_cfg_labels[i],
  8892. idx, 0x0b);
  8893. if (err < 0)
  8894. return err;
  8895. imux->items[imux->num_items].label =
  8896. auto_pin_cfg_labels[i];
  8897. imux->items[imux->num_items].index =
  8898. alc880_input_pin_idx(cfg->input_pins[i]);
  8899. imux->num_items++;
  8900. }
  8901. }
  8902. return 0;
  8903. }
  8904. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  8905. hda_nid_t nid, int pin_type,
  8906. int dac_idx)
  8907. {
  8908. /* set as output */
  8909. snd_hda_codec_write(codec, nid, 0,
  8910. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  8911. snd_hda_codec_write(codec, nid, 0,
  8912. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  8913. /* need the manual connection? */
  8914. if (alc880_is_multi_pin(nid)) {
  8915. struct alc_spec *spec = codec->spec;
  8916. int idx = alc880_multi_pin_idx(nid);
  8917. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  8918. AC_VERB_SET_CONNECT_SEL,
  8919. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  8920. }
  8921. }
  8922. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  8923. {
  8924. struct alc_spec *spec = codec->spec;
  8925. int i;
  8926. for (i = 0; i <= HDA_SIDE; i++) {
  8927. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8928. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8929. if (nid)
  8930. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  8931. i);
  8932. }
  8933. }
  8934. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  8935. {
  8936. struct alc_spec *spec = codec->spec;
  8937. hda_nid_t pin;
  8938. pin = spec->autocfg.hp_pins[0];
  8939. if (pin) /* connect to front */
  8940. /* use dac 0 */
  8941. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  8942. }
  8943. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  8944. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  8945. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  8946. {
  8947. struct alc_spec *spec = codec->spec;
  8948. int i;
  8949. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8950. hda_nid_t nid = spec->autocfg.input_pins[i];
  8951. if (alc662_is_input_pin(nid)) {
  8952. snd_hda_codec_write(codec, nid, 0,
  8953. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8954. (i <= AUTO_PIN_FRONT_MIC ?
  8955. PIN_VREF80 : PIN_IN));
  8956. if (nid != ALC662_PIN_CD_NID)
  8957. snd_hda_codec_write(codec, nid, 0,
  8958. AC_VERB_SET_AMP_GAIN_MUTE,
  8959. AMP_OUT_MUTE);
  8960. }
  8961. }
  8962. }
  8963. static int alc662_parse_auto_config(struct hda_codec *codec)
  8964. {
  8965. struct alc_spec *spec = codec->spec;
  8966. int err;
  8967. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  8968. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8969. alc662_ignore);
  8970. if (err < 0)
  8971. return err;
  8972. if (!spec->autocfg.line_outs)
  8973. return 0; /* can't find valid BIOS pin config */
  8974. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  8975. if (err < 0)
  8976. return err;
  8977. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8978. if (err < 0)
  8979. return err;
  8980. err = alc662_auto_create_extra_out(spec,
  8981. spec->autocfg.speaker_pins[0],
  8982. "Speaker");
  8983. if (err < 0)
  8984. return err;
  8985. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  8986. "Headphone");
  8987. if (err < 0)
  8988. return err;
  8989. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8990. if (err < 0)
  8991. return err;
  8992. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8993. if (spec->autocfg.dig_out_pin)
  8994. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  8995. if (spec->kctl_alloc)
  8996. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8997. spec->num_mux_defs = 1;
  8998. spec->input_mux = &spec->private_imux;
  8999. if (err < 0)
  9000. return err;
  9001. else if (err > 0)
  9002. /* hack - override the init verbs */
  9003. spec->init_verbs[0] = alc662_auto_init_verbs;
  9004. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  9005. spec->num_mixers++;
  9006. return err;
  9007. }
  9008. /* additional initialization for auto-configuration model */
  9009. static void alc662_auto_init(struct hda_codec *codec)
  9010. {
  9011. alc662_auto_init_multi_out(codec);
  9012. alc662_auto_init_hp_out(codec);
  9013. alc662_auto_init_analog_input(codec);
  9014. }
  9015. static int patch_alc662(struct hda_codec *codec)
  9016. {
  9017. struct alc_spec *spec;
  9018. int err, board_config;
  9019. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9020. if (!spec)
  9021. return -ENOMEM;
  9022. codec->spec = spec;
  9023. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  9024. alc662_models,
  9025. alc662_cfg_tbl);
  9026. if (board_config < 0) {
  9027. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  9028. "trying auto-probe from BIOS...\n");
  9029. board_config = ALC662_AUTO;
  9030. }
  9031. if (board_config == ALC662_AUTO) {
  9032. /* automatic parse from the BIOS config */
  9033. err = alc662_parse_auto_config(codec);
  9034. if (err < 0) {
  9035. alc_free(codec);
  9036. return err;
  9037. } else if (err) {
  9038. printk(KERN_INFO
  9039. "hda_codec: Cannot set up configuration "
  9040. "from BIOS. Using base mode...\n");
  9041. board_config = ALC662_3ST_2ch_DIG;
  9042. }
  9043. }
  9044. if (board_config != ALC662_AUTO)
  9045. setup_preset(spec, &alc662_presets[board_config]);
  9046. spec->stream_name_analog = "ALC662 Analog";
  9047. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  9048. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  9049. spec->stream_name_digital = "ALC662 Digital";
  9050. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  9051. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  9052. if (!spec->adc_nids && spec->input_mux) {
  9053. spec->adc_nids = alc662_adc_nids;
  9054. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  9055. }
  9056. codec->patch_ops = alc_patch_ops;
  9057. if (board_config == ALC662_AUTO)
  9058. spec->init_hook = alc662_auto_init;
  9059. return 0;
  9060. }
  9061. /*
  9062. * patch entries
  9063. */
  9064. struct hda_codec_preset snd_hda_preset_realtek[] = {
  9065. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  9066. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  9067. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  9068. .patch = patch_alc861 },
  9069. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  9070. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  9071. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  9072. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  9073. .patch = patch_alc883 },
  9074. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  9075. .patch = patch_alc662 },
  9076. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  9077. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  9078. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  9079. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  9080. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  9081. {} /* terminator */
  9082. };