patch_realtek.c 224 KB

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