patch_realtek.c 225 KB

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