patch_realtek.c 234 KB

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