patch_realtek.c 294 KB

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