patch_sigmatel.c 181 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for SigmaTel STAC92xx
  5. *
  6. * Copyright (c) 2005 Embedded Alley Solutions, Inc.
  7. * Matt Porter <mporter@embeddedalley.com>
  8. *
  9. * Based on patch_cmedia.c and patch_realtek.c
  10. * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
  11. *
  12. * This driver is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This driver is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. */
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <linux/dmi.h>
  31. #include <linux/module.h>
  32. #include <sound/core.h>
  33. #include <sound/asoundef.h>
  34. #include <sound/jack.h>
  35. #include <sound/tlv.h>
  36. #include "hda_codec.h"
  37. #include "hda_local.h"
  38. #include "hda_auto_parser.h"
  39. #include "hda_beep.h"
  40. #include "hda_jack.h"
  41. enum {
  42. STAC_VREF_EVENT = 1,
  43. STAC_INSERT_EVENT,
  44. STAC_PWR_EVENT,
  45. STAC_HP_EVENT,
  46. STAC_LO_EVENT,
  47. STAC_MIC_EVENT,
  48. };
  49. enum {
  50. STAC_AUTO,
  51. STAC_REF,
  52. STAC_9200_OQO,
  53. STAC_9200_DELL_D21,
  54. STAC_9200_DELL_D22,
  55. STAC_9200_DELL_D23,
  56. STAC_9200_DELL_M21,
  57. STAC_9200_DELL_M22,
  58. STAC_9200_DELL_M23,
  59. STAC_9200_DELL_M24,
  60. STAC_9200_DELL_M25,
  61. STAC_9200_DELL_M26,
  62. STAC_9200_DELL_M27,
  63. STAC_9200_M4,
  64. STAC_9200_M4_2,
  65. STAC_9200_PANASONIC,
  66. STAC_9200_MODELS
  67. };
  68. enum {
  69. STAC_9205_AUTO,
  70. STAC_9205_REF,
  71. STAC_9205_DELL_M42,
  72. STAC_9205_DELL_M43,
  73. STAC_9205_DELL_M44,
  74. STAC_9205_EAPD,
  75. STAC_9205_MODELS
  76. };
  77. enum {
  78. STAC_92HD73XX_AUTO,
  79. STAC_92HD73XX_NO_JD, /* no jack-detection */
  80. STAC_92HD73XX_REF,
  81. STAC_92HD73XX_INTEL,
  82. STAC_DELL_M6_AMIC,
  83. STAC_DELL_M6_DMIC,
  84. STAC_DELL_M6_BOTH,
  85. STAC_DELL_EQ,
  86. STAC_ALIENWARE_M17X,
  87. STAC_92HD73XX_MODELS
  88. };
  89. enum {
  90. STAC_92HD83XXX_AUTO,
  91. STAC_92HD83XXX_REF,
  92. STAC_92HD83XXX_PWR_REF,
  93. STAC_DELL_S14,
  94. STAC_DELL_VOSTRO_3500,
  95. STAC_92HD83XXX_HP_cNB11_INTQUAD,
  96. STAC_HP_DV7_4000,
  97. STAC_HP_ZEPHYR,
  98. STAC_92HD83XXX_MODELS
  99. };
  100. enum {
  101. STAC_92HD71BXX_AUTO,
  102. STAC_92HD71BXX_REF,
  103. STAC_DELL_M4_1,
  104. STAC_DELL_M4_2,
  105. STAC_DELL_M4_3,
  106. STAC_HP_M4,
  107. STAC_HP_DV4,
  108. STAC_HP_DV5,
  109. STAC_HP_HDX,
  110. STAC_HP_DV4_1222NR,
  111. STAC_92HD71BXX_MODELS
  112. };
  113. enum {
  114. STAC_925x_AUTO,
  115. STAC_925x_REF,
  116. STAC_M1,
  117. STAC_M1_2,
  118. STAC_M2,
  119. STAC_M2_2,
  120. STAC_M3,
  121. STAC_M5,
  122. STAC_M6,
  123. STAC_925x_MODELS
  124. };
  125. enum {
  126. STAC_922X_AUTO,
  127. STAC_D945_REF,
  128. STAC_D945GTP3,
  129. STAC_D945GTP5,
  130. STAC_INTEL_MAC_V1,
  131. STAC_INTEL_MAC_V2,
  132. STAC_INTEL_MAC_V3,
  133. STAC_INTEL_MAC_V4,
  134. STAC_INTEL_MAC_V5,
  135. STAC_INTEL_MAC_AUTO, /* This model is selected if no module parameter
  136. * is given, one of the above models will be
  137. * chosen according to the subsystem id. */
  138. /* for backward compatibility */
  139. STAC_MACMINI,
  140. STAC_MACBOOK,
  141. STAC_MACBOOK_PRO_V1,
  142. STAC_MACBOOK_PRO_V2,
  143. STAC_IMAC_INTEL,
  144. STAC_IMAC_INTEL_20,
  145. STAC_ECS_202,
  146. STAC_922X_DELL_D81,
  147. STAC_922X_DELL_D82,
  148. STAC_922X_DELL_M81,
  149. STAC_922X_DELL_M82,
  150. STAC_922X_MODELS
  151. };
  152. enum {
  153. STAC_927X_AUTO,
  154. STAC_D965_REF_NO_JD, /* no jack-detection */
  155. STAC_D965_REF,
  156. STAC_D965_3ST,
  157. STAC_D965_5ST,
  158. STAC_D965_5ST_NO_FP,
  159. STAC_DELL_3ST,
  160. STAC_DELL_BIOS,
  161. STAC_927X_VOLKNOB,
  162. STAC_927X_MODELS
  163. };
  164. enum {
  165. STAC_9872_AUTO,
  166. STAC_9872_VAIO,
  167. STAC_9872_MODELS
  168. };
  169. struct sigmatel_mic_route {
  170. hda_nid_t pin;
  171. signed char mux_idx;
  172. signed char dmux_idx;
  173. };
  174. #define MAX_PINS_NUM 16
  175. #define MAX_ADCS_NUM 4
  176. #define MAX_DMICS_NUM 4
  177. struct sigmatel_spec {
  178. struct snd_kcontrol_new *mixers[4];
  179. unsigned int num_mixers;
  180. int board_config;
  181. unsigned int eapd_switch: 1;
  182. unsigned int surr_switch: 1;
  183. unsigned int alt_switch: 1;
  184. unsigned int hp_detect: 1;
  185. unsigned int spdif_mute: 1;
  186. unsigned int check_volume_offset:1;
  187. unsigned int auto_mic:1;
  188. unsigned int linear_tone_beep:1;
  189. /* gpio lines */
  190. unsigned int eapd_mask;
  191. unsigned int gpio_mask;
  192. unsigned int gpio_dir;
  193. unsigned int gpio_data;
  194. unsigned int gpio_mute;
  195. unsigned int gpio_led;
  196. unsigned int gpio_led_polarity;
  197. unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
  198. unsigned int vref_led;
  199. /* stream */
  200. unsigned int stream_delay;
  201. /* analog loopback */
  202. const struct snd_kcontrol_new *aloopback_ctl;
  203. unsigned char aloopback_mask;
  204. unsigned char aloopback_shift;
  205. /* power management */
  206. unsigned int power_map_bits;
  207. unsigned int num_pwrs;
  208. const hda_nid_t *pwr_nids;
  209. const hda_nid_t *dac_list;
  210. /* playback */
  211. struct hda_input_mux *mono_mux;
  212. unsigned int cur_mmux;
  213. struct hda_multi_out multiout;
  214. hda_nid_t dac_nids[5];
  215. hda_nid_t hp_dacs[5];
  216. hda_nid_t speaker_dacs[5];
  217. int volume_offset;
  218. /* capture */
  219. const hda_nid_t *adc_nids;
  220. unsigned int num_adcs;
  221. const hda_nid_t *mux_nids;
  222. unsigned int num_muxes;
  223. const hda_nid_t *dmic_nids;
  224. unsigned int num_dmics;
  225. const hda_nid_t *dmux_nids;
  226. unsigned int num_dmuxes;
  227. const hda_nid_t *smux_nids;
  228. unsigned int num_smuxes;
  229. unsigned int num_analog_muxes;
  230. const unsigned long *capvols; /* amp-volume attr: HDA_COMPOSE_AMP_VAL() */
  231. const unsigned long *capsws; /* amp-mute attr: HDA_COMPOSE_AMP_VAL() */
  232. unsigned int num_caps; /* number of capture volume/switch elements */
  233. struct sigmatel_mic_route ext_mic;
  234. struct sigmatel_mic_route int_mic;
  235. struct sigmatel_mic_route dock_mic;
  236. const char * const *spdif_labels;
  237. hda_nid_t dig_in_nid;
  238. hda_nid_t mono_nid;
  239. hda_nid_t anabeep_nid;
  240. hda_nid_t digbeep_nid;
  241. /* pin widgets */
  242. const hda_nid_t *pin_nids;
  243. unsigned int num_pins;
  244. /* codec specific stuff */
  245. const struct hda_verb *init;
  246. const struct snd_kcontrol_new *mixer;
  247. /* capture source */
  248. struct hda_input_mux *dinput_mux;
  249. unsigned int cur_dmux[2];
  250. struct hda_input_mux *input_mux;
  251. unsigned int cur_mux[3];
  252. struct hda_input_mux *sinput_mux;
  253. unsigned int cur_smux[2];
  254. unsigned int cur_amux;
  255. hda_nid_t *amp_nids;
  256. unsigned int powerdown_adcs;
  257. /* i/o switches */
  258. unsigned int io_switch[2];
  259. unsigned int clfe_swap;
  260. hda_nid_t line_switch; /* shared line-in for input and output */
  261. hda_nid_t mic_switch; /* shared mic-in for input and output */
  262. hda_nid_t hp_switch; /* NID of HP as line-out */
  263. unsigned int aloopback;
  264. struct hda_pcm pcm_rec[2]; /* PCM information */
  265. /* dynamic controls and input_mux */
  266. struct auto_pin_cfg autocfg;
  267. struct snd_array kctls;
  268. struct hda_input_mux private_dimux;
  269. struct hda_input_mux private_imux;
  270. struct hda_input_mux private_smux;
  271. struct hda_input_mux private_mono_mux;
  272. /* auto spec */
  273. unsigned auto_pin_cnt;
  274. hda_nid_t auto_pin_nids[MAX_PINS_NUM];
  275. unsigned auto_adc_cnt;
  276. hda_nid_t auto_adc_nids[MAX_ADCS_NUM];
  277. hda_nid_t auto_mux_nids[MAX_ADCS_NUM];
  278. hda_nid_t auto_dmux_nids[MAX_ADCS_NUM];
  279. unsigned long auto_capvols[MAX_ADCS_NUM];
  280. unsigned auto_dmic_cnt;
  281. hda_nid_t auto_dmic_nids[MAX_DMICS_NUM];
  282. struct hda_vmaster_mute_hook vmaster_mute;
  283. };
  284. #define AC_VERB_IDT_SET_POWER_MAP 0x7ec
  285. #define AC_VERB_IDT_GET_POWER_MAP 0xfec
  286. static const hda_nid_t stac9200_adc_nids[1] = {
  287. 0x03,
  288. };
  289. static const hda_nid_t stac9200_mux_nids[1] = {
  290. 0x0c,
  291. };
  292. static const hda_nid_t stac9200_dac_nids[1] = {
  293. 0x02,
  294. };
  295. static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
  296. 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
  297. 0x0f, 0x10, 0x11
  298. };
  299. static const hda_nid_t stac92hd73xx_slave_dig_outs[2] = {
  300. 0x26, 0,
  301. };
  302. static const hda_nid_t stac92hd73xx_adc_nids[2] = {
  303. 0x1a, 0x1b
  304. };
  305. #define STAC92HD73XX_NUM_DMICS 2
  306. static const hda_nid_t stac92hd73xx_dmic_nids[STAC92HD73XX_NUM_DMICS + 1] = {
  307. 0x13, 0x14, 0
  308. };
  309. #define STAC92HD73_DAC_COUNT 5
  310. static const hda_nid_t stac92hd73xx_mux_nids[2] = {
  311. 0x20, 0x21,
  312. };
  313. static const hda_nid_t stac92hd73xx_dmux_nids[2] = {
  314. 0x20, 0x21,
  315. };
  316. static const hda_nid_t stac92hd73xx_smux_nids[2] = {
  317. 0x22, 0x23,
  318. };
  319. #define STAC92HD73XX_NUM_CAPS 2
  320. static const unsigned long stac92hd73xx_capvols[] = {
  321. HDA_COMPOSE_AMP_VAL(0x20, 3, 0, HDA_OUTPUT),
  322. HDA_COMPOSE_AMP_VAL(0x21, 3, 0, HDA_OUTPUT),
  323. };
  324. #define stac92hd73xx_capsws stac92hd73xx_capvols
  325. #define STAC92HD83_DAC_COUNT 3
  326. static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
  327. 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
  328. 0x0f, 0x10
  329. };
  330. static const hda_nid_t stac92hd83xxx_slave_dig_outs[2] = {
  331. 0x1e, 0,
  332. };
  333. static const hda_nid_t stac92hd83xxx_dmic_nids[] = {
  334. 0x11, 0x20,
  335. };
  336. static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
  337. 0x0a, 0x0d, 0x0f
  338. };
  339. static const hda_nid_t stac92hd71bxx_adc_nids[2] = {
  340. 0x12, 0x13,
  341. };
  342. static const hda_nid_t stac92hd71bxx_mux_nids[2] = {
  343. 0x1a, 0x1b
  344. };
  345. static const hda_nid_t stac92hd71bxx_dmux_nids[2] = {
  346. 0x1c, 0x1d,
  347. };
  348. static const hda_nid_t stac92hd71bxx_smux_nids[2] = {
  349. 0x24, 0x25,
  350. };
  351. #define STAC92HD71BXX_NUM_DMICS 2
  352. static const hda_nid_t stac92hd71bxx_dmic_nids[STAC92HD71BXX_NUM_DMICS + 1] = {
  353. 0x18, 0x19, 0
  354. };
  355. static const hda_nid_t stac92hd71bxx_dmic_5port_nids[STAC92HD71BXX_NUM_DMICS] = {
  356. 0x18, 0
  357. };
  358. static const hda_nid_t stac92hd71bxx_slave_dig_outs[2] = {
  359. 0x22, 0
  360. };
  361. #define STAC92HD71BXX_NUM_CAPS 2
  362. static const unsigned long stac92hd71bxx_capvols[] = {
  363. HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
  364. HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
  365. };
  366. #define stac92hd71bxx_capsws stac92hd71bxx_capvols
  367. static const hda_nid_t stac925x_adc_nids[1] = {
  368. 0x03,
  369. };
  370. static const hda_nid_t stac925x_mux_nids[1] = {
  371. 0x0f,
  372. };
  373. static const hda_nid_t stac925x_dac_nids[1] = {
  374. 0x02,
  375. };
  376. #define STAC925X_NUM_DMICS 1
  377. static const hda_nid_t stac925x_dmic_nids[STAC925X_NUM_DMICS + 1] = {
  378. 0x15, 0
  379. };
  380. static const hda_nid_t stac925x_dmux_nids[1] = {
  381. 0x14,
  382. };
  383. static const unsigned long stac925x_capvols[] = {
  384. HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_OUTPUT),
  385. };
  386. static const unsigned long stac925x_capsws[] = {
  387. HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  388. };
  389. static const hda_nid_t stac922x_adc_nids[2] = {
  390. 0x06, 0x07,
  391. };
  392. static const hda_nid_t stac922x_mux_nids[2] = {
  393. 0x12, 0x13,
  394. };
  395. #define STAC922X_NUM_CAPS 2
  396. static const unsigned long stac922x_capvols[] = {
  397. HDA_COMPOSE_AMP_VAL(0x17, 3, 0, HDA_INPUT),
  398. HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
  399. };
  400. #define stac922x_capsws stac922x_capvols
  401. static const hda_nid_t stac927x_slave_dig_outs[2] = {
  402. 0x1f, 0,
  403. };
  404. static const hda_nid_t stac927x_adc_nids[3] = {
  405. 0x07, 0x08, 0x09
  406. };
  407. static const hda_nid_t stac927x_mux_nids[3] = {
  408. 0x15, 0x16, 0x17
  409. };
  410. static const hda_nid_t stac927x_smux_nids[1] = {
  411. 0x21,
  412. };
  413. static const hda_nid_t stac927x_dac_nids[6] = {
  414. 0x02, 0x03, 0x04, 0x05, 0x06, 0
  415. };
  416. static const hda_nid_t stac927x_dmux_nids[1] = {
  417. 0x1b,
  418. };
  419. #define STAC927X_NUM_DMICS 2
  420. static const hda_nid_t stac927x_dmic_nids[STAC927X_NUM_DMICS + 1] = {
  421. 0x13, 0x14, 0
  422. };
  423. #define STAC927X_NUM_CAPS 3
  424. static const unsigned long stac927x_capvols[] = {
  425. HDA_COMPOSE_AMP_VAL(0x18, 3, 0, HDA_INPUT),
  426. HDA_COMPOSE_AMP_VAL(0x19, 3, 0, HDA_INPUT),
  427. HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_INPUT),
  428. };
  429. static const unsigned long stac927x_capsws[] = {
  430. HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
  431. HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_OUTPUT),
  432. HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
  433. };
  434. static const char * const stac927x_spdif_labels[5] = {
  435. "Digital Playback", "ADAT", "Analog Mux 1",
  436. "Analog Mux 2", "Analog Mux 3"
  437. };
  438. static const hda_nid_t stac9205_adc_nids[2] = {
  439. 0x12, 0x13
  440. };
  441. static const hda_nid_t stac9205_mux_nids[2] = {
  442. 0x19, 0x1a
  443. };
  444. static const hda_nid_t stac9205_dmux_nids[1] = {
  445. 0x1d,
  446. };
  447. static const hda_nid_t stac9205_smux_nids[1] = {
  448. 0x21,
  449. };
  450. #define STAC9205_NUM_DMICS 2
  451. static const hda_nid_t stac9205_dmic_nids[STAC9205_NUM_DMICS + 1] = {
  452. 0x17, 0x18, 0
  453. };
  454. #define STAC9205_NUM_CAPS 2
  455. static const unsigned long stac9205_capvols[] = {
  456. HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_INPUT),
  457. HDA_COMPOSE_AMP_VAL(0x1c, 3, 0, HDA_INPUT),
  458. };
  459. static const unsigned long stac9205_capsws[] = {
  460. HDA_COMPOSE_AMP_VAL(0x1d, 3, 0, HDA_OUTPUT),
  461. HDA_COMPOSE_AMP_VAL(0x1e, 3, 0, HDA_OUTPUT),
  462. };
  463. static const hda_nid_t stac9200_pin_nids[8] = {
  464. 0x08, 0x09, 0x0d, 0x0e,
  465. 0x0f, 0x10, 0x11, 0x12,
  466. };
  467. static const hda_nid_t stac925x_pin_nids[8] = {
  468. 0x07, 0x08, 0x0a, 0x0b,
  469. 0x0c, 0x0d, 0x10, 0x11,
  470. };
  471. static const hda_nid_t stac922x_pin_nids[10] = {
  472. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  473. 0x0f, 0x10, 0x11, 0x15, 0x1b,
  474. };
  475. static const hda_nid_t stac92hd73xx_pin_nids[13] = {
  476. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  477. 0x0f, 0x10, 0x11, 0x12, 0x13,
  478. 0x14, 0x22, 0x23
  479. };
  480. #define STAC92HD71BXX_NUM_PINS 13
  481. static const hda_nid_t stac92hd71bxx_pin_nids_4port[STAC92HD71BXX_NUM_PINS] = {
  482. 0x0a, 0x0b, 0x0c, 0x0d, 0x00,
  483. 0x00, 0x14, 0x18, 0x19, 0x1e,
  484. 0x1f, 0x20, 0x27
  485. };
  486. static const hda_nid_t stac92hd71bxx_pin_nids_6port[STAC92HD71BXX_NUM_PINS] = {
  487. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  488. 0x0f, 0x14, 0x18, 0x19, 0x1e,
  489. 0x1f, 0x20, 0x27
  490. };
  491. static const hda_nid_t stac927x_pin_nids[14] = {
  492. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  493. 0x0f, 0x10, 0x11, 0x12, 0x13,
  494. 0x14, 0x21, 0x22, 0x23,
  495. };
  496. static const hda_nid_t stac9205_pin_nids[12] = {
  497. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  498. 0x0f, 0x14, 0x16, 0x17, 0x18,
  499. 0x21, 0x22,
  500. };
  501. static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
  502. struct snd_ctl_elem_info *uinfo)
  503. {
  504. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  505. struct sigmatel_spec *spec = codec->spec;
  506. return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
  507. }
  508. static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
  509. struct snd_ctl_elem_value *ucontrol)
  510. {
  511. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  512. struct sigmatel_spec *spec = codec->spec;
  513. unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  514. ucontrol->value.enumerated.item[0] = spec->cur_dmux[dmux_idx];
  515. return 0;
  516. }
  517. static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
  518. struct snd_ctl_elem_value *ucontrol)
  519. {
  520. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  521. struct sigmatel_spec *spec = codec->spec;
  522. unsigned int dmux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  523. return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
  524. spec->dmux_nids[dmux_idx], &spec->cur_dmux[dmux_idx]);
  525. }
  526. static int stac92xx_smux_enum_info(struct snd_kcontrol *kcontrol,
  527. struct snd_ctl_elem_info *uinfo)
  528. {
  529. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  530. struct sigmatel_spec *spec = codec->spec;
  531. return snd_hda_input_mux_info(spec->sinput_mux, uinfo);
  532. }
  533. static int stac92xx_smux_enum_get(struct snd_kcontrol *kcontrol,
  534. struct snd_ctl_elem_value *ucontrol)
  535. {
  536. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  537. struct sigmatel_spec *spec = codec->spec;
  538. unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  539. ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
  540. return 0;
  541. }
  542. static int stac92xx_smux_enum_put(struct snd_kcontrol *kcontrol,
  543. struct snd_ctl_elem_value *ucontrol)
  544. {
  545. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  546. struct sigmatel_spec *spec = codec->spec;
  547. struct hda_input_mux *smux = &spec->private_smux;
  548. unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  549. int err, val;
  550. hda_nid_t nid;
  551. err = snd_hda_input_mux_put(codec, spec->sinput_mux, ucontrol,
  552. spec->smux_nids[smux_idx], &spec->cur_smux[smux_idx]);
  553. if (err < 0)
  554. return err;
  555. if (spec->spdif_mute) {
  556. if (smux_idx == 0)
  557. nid = spec->multiout.dig_out_nid;
  558. else
  559. nid = codec->slave_dig_outs[smux_idx - 1];
  560. if (spec->cur_smux[smux_idx] == smux->num_items - 1)
  561. val = HDA_AMP_MUTE;
  562. else
  563. val = 0;
  564. /* un/mute SPDIF out */
  565. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  566. HDA_AMP_MUTE, val);
  567. }
  568. return 0;
  569. }
  570. static int stac_vrefout_set(struct hda_codec *codec,
  571. hda_nid_t nid, unsigned int new_vref)
  572. {
  573. int error, pinctl;
  574. snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
  575. pinctl = snd_hda_codec_read(codec, nid, 0,
  576. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  577. if (pinctl < 0)
  578. return pinctl;
  579. pinctl &= 0xff;
  580. pinctl &= ~AC_PINCTL_VREFEN;
  581. pinctl |= (new_vref & AC_PINCTL_VREFEN);
  582. error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
  583. if (error < 0)
  584. return error;
  585. return 1;
  586. }
  587. static unsigned int stac92xx_vref_set(struct hda_codec *codec,
  588. hda_nid_t nid, unsigned int new_vref)
  589. {
  590. int error;
  591. unsigned int pincfg;
  592. pincfg = snd_hda_codec_read(codec, nid, 0,
  593. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  594. pincfg &= 0xff;
  595. pincfg &= ~(AC_PINCTL_VREFEN | AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
  596. pincfg |= new_vref;
  597. if (new_vref == AC_PINCTL_VREF_HIZ)
  598. pincfg |= AC_PINCTL_OUT_EN;
  599. else
  600. pincfg |= AC_PINCTL_IN_EN;
  601. error = snd_hda_set_pin_ctl_cache(codec, nid, pincfg);
  602. if (error < 0)
  603. return error;
  604. else
  605. return 1;
  606. }
  607. static unsigned int stac92xx_vref_get(struct hda_codec *codec, hda_nid_t nid)
  608. {
  609. unsigned int vref;
  610. vref = snd_hda_codec_read(codec, nid, 0,
  611. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  612. vref &= AC_PINCTL_VREFEN;
  613. return vref;
  614. }
  615. static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  616. {
  617. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  618. struct sigmatel_spec *spec = codec->spec;
  619. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  620. }
  621. static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  622. {
  623. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  624. struct sigmatel_spec *spec = codec->spec;
  625. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  626. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  627. return 0;
  628. }
  629. static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  630. {
  631. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  632. struct sigmatel_spec *spec = codec->spec;
  633. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  634. const struct hda_input_mux *imux = spec->input_mux;
  635. unsigned int idx, prev_idx, didx;
  636. idx = ucontrol->value.enumerated.item[0];
  637. if (idx >= imux->num_items)
  638. idx = imux->num_items - 1;
  639. prev_idx = spec->cur_mux[adc_idx];
  640. if (prev_idx == idx)
  641. return 0;
  642. if (idx < spec->num_analog_muxes) {
  643. snd_hda_codec_write_cache(codec, spec->mux_nids[adc_idx], 0,
  644. AC_VERB_SET_CONNECT_SEL,
  645. imux->items[idx].index);
  646. if (prev_idx >= spec->num_analog_muxes &&
  647. spec->mux_nids[adc_idx] != spec->dmux_nids[adc_idx]) {
  648. imux = spec->dinput_mux;
  649. /* 0 = analog */
  650. snd_hda_codec_write_cache(codec,
  651. spec->dmux_nids[adc_idx], 0,
  652. AC_VERB_SET_CONNECT_SEL,
  653. imux->items[0].index);
  654. }
  655. } else {
  656. imux = spec->dinput_mux;
  657. /* first dimux item is hardcoded to select analog imux,
  658. * so lets skip it
  659. */
  660. didx = idx - spec->num_analog_muxes + 1;
  661. snd_hda_codec_write_cache(codec, spec->dmux_nids[adc_idx], 0,
  662. AC_VERB_SET_CONNECT_SEL,
  663. imux->items[didx].index);
  664. }
  665. spec->cur_mux[adc_idx] = idx;
  666. return 1;
  667. }
  668. static int stac92xx_mono_mux_enum_info(struct snd_kcontrol *kcontrol,
  669. struct snd_ctl_elem_info *uinfo)
  670. {
  671. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  672. struct sigmatel_spec *spec = codec->spec;
  673. return snd_hda_input_mux_info(spec->mono_mux, uinfo);
  674. }
  675. static int stac92xx_mono_mux_enum_get(struct snd_kcontrol *kcontrol,
  676. struct snd_ctl_elem_value *ucontrol)
  677. {
  678. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  679. struct sigmatel_spec *spec = codec->spec;
  680. ucontrol->value.enumerated.item[0] = spec->cur_mmux;
  681. return 0;
  682. }
  683. static int stac92xx_mono_mux_enum_put(struct snd_kcontrol *kcontrol,
  684. struct snd_ctl_elem_value *ucontrol)
  685. {
  686. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  687. struct sigmatel_spec *spec = codec->spec;
  688. return snd_hda_input_mux_put(codec, spec->mono_mux, ucontrol,
  689. spec->mono_nid, &spec->cur_mmux);
  690. }
  691. #define stac92xx_aloopback_info snd_ctl_boolean_mono_info
  692. static int stac92xx_aloopback_get(struct snd_kcontrol *kcontrol,
  693. struct snd_ctl_elem_value *ucontrol)
  694. {
  695. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  696. unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  697. struct sigmatel_spec *spec = codec->spec;
  698. ucontrol->value.integer.value[0] = !!(spec->aloopback &
  699. (spec->aloopback_mask << idx));
  700. return 0;
  701. }
  702. static int stac92xx_aloopback_put(struct snd_kcontrol *kcontrol,
  703. struct snd_ctl_elem_value *ucontrol)
  704. {
  705. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  706. struct sigmatel_spec *spec = codec->spec;
  707. unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  708. unsigned int dac_mode;
  709. unsigned int val, idx_val;
  710. idx_val = spec->aloopback_mask << idx;
  711. if (ucontrol->value.integer.value[0])
  712. val = spec->aloopback | idx_val;
  713. else
  714. val = spec->aloopback & ~idx_val;
  715. if (spec->aloopback == val)
  716. return 0;
  717. spec->aloopback = val;
  718. /* Only return the bits defined by the shift value of the
  719. * first two bytes of the mask
  720. */
  721. dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
  722. kcontrol->private_value & 0xFFFF, 0x0);
  723. dac_mode >>= spec->aloopback_shift;
  724. if (spec->aloopback & idx_val) {
  725. snd_hda_power_up(codec);
  726. dac_mode |= idx_val;
  727. } else {
  728. snd_hda_power_down(codec);
  729. dac_mode &= ~idx_val;
  730. }
  731. snd_hda_codec_write_cache(codec, codec->afg, 0,
  732. kcontrol->private_value >> 16, dac_mode);
  733. return 1;
  734. }
  735. static const struct hda_verb stac9200_core_init[] = {
  736. /* set dac0mux for dac converter */
  737. { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  738. {}
  739. };
  740. static const struct hda_verb stac9200_eapd_init[] = {
  741. /* set dac0mux for dac converter */
  742. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  743. {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  744. {}
  745. };
  746. static const struct hda_verb dell_eq_core_init[] = {
  747. /* set master volume to max value without distortion
  748. * and direct control */
  749. { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
  750. {}
  751. };
  752. static const struct hda_verb stac92hd73xx_core_init[] = {
  753. /* set master volume and direct control */
  754. { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  755. {}
  756. };
  757. static const struct hda_verb stac92hd83xxx_core_init[] = {
  758. /* power state controls amps */
  759. { 0x01, AC_VERB_SET_EAPD, 1 << 2},
  760. {}
  761. };
  762. static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
  763. { 0x22, 0x785, 0x43 },
  764. { 0x22, 0x782, 0xe0 },
  765. { 0x22, 0x795, 0x00 },
  766. {}
  767. };
  768. static const struct hda_verb stac92hd71bxx_core_init[] = {
  769. /* set master volume and direct control */
  770. { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  771. {}
  772. };
  773. static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
  774. /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
  775. { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  776. { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  777. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  778. {}
  779. };
  780. static const struct hda_verb stac925x_core_init[] = {
  781. /* set dac0mux for dac converter */
  782. { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
  783. /* mute the master volume */
  784. { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  785. {}
  786. };
  787. static const struct hda_verb stac922x_core_init[] = {
  788. /* set master volume and direct control */
  789. { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  790. {}
  791. };
  792. static const struct hda_verb d965_core_init[] = {
  793. /* set master volume and direct control */
  794. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  795. /* unmute node 0x1b */
  796. { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  797. /* select node 0x03 as DAC */
  798. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
  799. {}
  800. };
  801. static const struct hda_verb dell_3st_core_init[] = {
  802. /* don't set delta bit */
  803. {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
  804. /* unmute node 0x1b */
  805. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  806. /* select node 0x03 as DAC */
  807. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
  808. {}
  809. };
  810. static const struct hda_verb stac927x_core_init[] = {
  811. /* set master volume and direct control */
  812. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  813. /* enable analog pc beep path */
  814. { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
  815. {}
  816. };
  817. static const struct hda_verb stac927x_volknob_core_init[] = {
  818. /* don't set delta bit */
  819. {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
  820. /* enable analog pc beep path */
  821. {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
  822. {}
  823. };
  824. static const struct hda_verb stac9205_core_init[] = {
  825. /* set master volume and direct control */
  826. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  827. /* enable analog pc beep path */
  828. { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
  829. {}
  830. };
  831. #define STAC_MONO_MUX \
  832. { \
  833. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  834. .name = "Mono Mux", \
  835. .count = 1, \
  836. .info = stac92xx_mono_mux_enum_info, \
  837. .get = stac92xx_mono_mux_enum_get, \
  838. .put = stac92xx_mono_mux_enum_put, \
  839. }
  840. #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
  841. { \
  842. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  843. .name = "Analog Loopback", \
  844. .count = cnt, \
  845. .info = stac92xx_aloopback_info, \
  846. .get = stac92xx_aloopback_get, \
  847. .put = stac92xx_aloopback_put, \
  848. .private_value = verb_read | (verb_write << 16), \
  849. }
  850. #define DC_BIAS(xname, idx, nid) \
  851. { \
  852. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  853. .name = xname, \
  854. .index = idx, \
  855. .info = stac92xx_dc_bias_info, \
  856. .get = stac92xx_dc_bias_get, \
  857. .put = stac92xx_dc_bias_put, \
  858. .private_value = nid, \
  859. }
  860. static const struct snd_kcontrol_new stac9200_mixer[] = {
  861. HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xb, 0, HDA_OUTPUT),
  862. HDA_CODEC_MUTE("PCM Playback Switch", 0xb, 0, HDA_OUTPUT),
  863. HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
  864. HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
  865. { } /* end */
  866. };
  867. static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback[] = {
  868. STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3),
  869. {}
  870. };
  871. static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback[] = {
  872. STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4),
  873. {}
  874. };
  875. static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback[] = {
  876. STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5),
  877. {}
  878. };
  879. static const struct snd_kcontrol_new stac92hd71bxx_loopback[] = {
  880. STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2)
  881. };
  882. static const struct snd_kcontrol_new stac925x_mixer[] = {
  883. HDA_CODEC_VOLUME_MIN_MUTE("PCM Playback Volume", 0xe, 0, HDA_OUTPUT),
  884. HDA_CODEC_MUTE("PCM Playback Switch", 0x0e, 0, HDA_OUTPUT),
  885. { } /* end */
  886. };
  887. static const struct snd_kcontrol_new stac9205_loopback[] = {
  888. STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1),
  889. {}
  890. };
  891. static const struct snd_kcontrol_new stac927x_loopback[] = {
  892. STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1),
  893. {}
  894. };
  895. static struct snd_kcontrol_new stac_dmux_mixer = {
  896. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  897. .name = "Digital Input Source",
  898. /* count set later */
  899. .info = stac92xx_dmux_enum_info,
  900. .get = stac92xx_dmux_enum_get,
  901. .put = stac92xx_dmux_enum_put,
  902. };
  903. static struct snd_kcontrol_new stac_smux_mixer = {
  904. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  905. .name = "IEC958 Playback Source",
  906. /* count set later */
  907. .info = stac92xx_smux_enum_info,
  908. .get = stac92xx_smux_enum_get,
  909. .put = stac92xx_smux_enum_put,
  910. };
  911. static const char * const slave_pfxs[] = {
  912. "Front", "Surround", "Center", "LFE", "Side",
  913. "Headphone", "Speaker", "IEC958",
  914. NULL
  915. };
  916. static void stac92xx_update_led_status(struct hda_codec *codec, int enabled);
  917. static void stac92xx_vmaster_hook(void *private_data, int val)
  918. {
  919. stac92xx_update_led_status(private_data, val);
  920. }
  921. static void stac92xx_free_kctls(struct hda_codec *codec);
  922. static int stac92xx_build_controls(struct hda_codec *codec)
  923. {
  924. struct sigmatel_spec *spec = codec->spec;
  925. unsigned int vmaster_tlv[4];
  926. int err;
  927. int i;
  928. if (spec->mixer) {
  929. err = snd_hda_add_new_ctls(codec, spec->mixer);
  930. if (err < 0)
  931. return err;
  932. }
  933. for (i = 0; i < spec->num_mixers; i++) {
  934. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  935. if (err < 0)
  936. return err;
  937. }
  938. if (!spec->auto_mic && spec->num_dmuxes > 0 &&
  939. snd_hda_get_bool_hint(codec, "separate_dmux") == 1) {
  940. stac_dmux_mixer.count = spec->num_dmuxes;
  941. err = snd_hda_ctl_add(codec, 0,
  942. snd_ctl_new1(&stac_dmux_mixer, codec));
  943. if (err < 0)
  944. return err;
  945. }
  946. if (spec->num_smuxes > 0) {
  947. int wcaps = get_wcaps(codec, spec->multiout.dig_out_nid);
  948. struct hda_input_mux *smux = &spec->private_smux;
  949. /* check for mute support on SPDIF out */
  950. if (wcaps & AC_WCAP_OUT_AMP) {
  951. snd_hda_add_imux_item(smux, "Off", 0, NULL);
  952. spec->spdif_mute = 1;
  953. }
  954. stac_smux_mixer.count = spec->num_smuxes;
  955. err = snd_hda_ctl_add(codec, 0,
  956. snd_ctl_new1(&stac_smux_mixer, codec));
  957. if (err < 0)
  958. return err;
  959. }
  960. if (spec->multiout.dig_out_nid) {
  961. err = snd_hda_create_spdif_out_ctls(codec,
  962. spec->multiout.dig_out_nid,
  963. spec->multiout.dig_out_nid);
  964. if (err < 0)
  965. return err;
  966. err = snd_hda_create_spdif_share_sw(codec,
  967. &spec->multiout);
  968. if (err < 0)
  969. return err;
  970. spec->multiout.share_spdif = 1;
  971. }
  972. if (spec->dig_in_nid && !(spec->gpio_dir & 0x01)) {
  973. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  974. if (err < 0)
  975. return err;
  976. }
  977. /* if we have no master control, let's create it */
  978. snd_hda_set_vmaster_tlv(codec, spec->multiout.dac_nids[0],
  979. HDA_OUTPUT, vmaster_tlv);
  980. /* correct volume offset */
  981. vmaster_tlv[2] += vmaster_tlv[3] * spec->volume_offset;
  982. /* minimum value is actually mute */
  983. vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
  984. err = snd_hda_add_vmaster(codec, "Master Playback Volume",
  985. vmaster_tlv, slave_pfxs,
  986. "Playback Volume");
  987. if (err < 0)
  988. return err;
  989. err = __snd_hda_add_vmaster(codec, "Master Playback Switch",
  990. NULL, slave_pfxs,
  991. "Playback Switch", true,
  992. &spec->vmaster_mute.sw_kctl);
  993. if (err < 0)
  994. return err;
  995. if (spec->gpio_led) {
  996. spec->vmaster_mute.hook = stac92xx_vmaster_hook;
  997. err = snd_hda_add_vmaster_hook(codec, &spec->vmaster_mute, true);
  998. if (err < 0)
  999. return err;
  1000. }
  1001. if (spec->aloopback_ctl &&
  1002. snd_hda_get_bool_hint(codec, "loopback") == 1) {
  1003. err = snd_hda_add_new_ctls(codec, spec->aloopback_ctl);
  1004. if (err < 0)
  1005. return err;
  1006. }
  1007. stac92xx_free_kctls(codec); /* no longer needed */
  1008. err = snd_hda_jack_add_kctls(codec, &spec->autocfg);
  1009. if (err < 0)
  1010. return err;
  1011. return 0;
  1012. }
  1013. static const unsigned int ref9200_pin_configs[8] = {
  1014. 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
  1015. 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
  1016. };
  1017. static const unsigned int gateway9200_m4_pin_configs[8] = {
  1018. 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
  1019. 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
  1020. };
  1021. static const unsigned int gateway9200_m4_2_pin_configs[8] = {
  1022. 0x400000fe, 0x404500f4, 0x400100f0, 0x90110010,
  1023. 0x400100f1, 0x02a1902e, 0x500000f2, 0x500000f3,
  1024. };
  1025. /*
  1026. STAC 9200 pin configs for
  1027. 102801A8
  1028. 102801DE
  1029. 102801E8
  1030. */
  1031. static const unsigned int dell9200_d21_pin_configs[8] = {
  1032. 0x400001f0, 0x400001f1, 0x02214030, 0x01014010,
  1033. 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
  1034. };
  1035. /*
  1036. STAC 9200 pin configs for
  1037. 102801C0
  1038. 102801C1
  1039. */
  1040. static const unsigned int dell9200_d22_pin_configs[8] = {
  1041. 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
  1042. 0x01813020, 0x02a19021, 0x90100140, 0x400001f2,
  1043. };
  1044. /*
  1045. STAC 9200 pin configs for
  1046. 102801C4 (Dell Dimension E310)
  1047. 102801C5
  1048. 102801C7
  1049. 102801D9
  1050. 102801DA
  1051. 102801E3
  1052. */
  1053. static const unsigned int dell9200_d23_pin_configs[8] = {
  1054. 0x400001f0, 0x400001f1, 0x0221401f, 0x01014010,
  1055. 0x01813020, 0x01a19021, 0x90100140, 0x400001f2,
  1056. };
  1057. /*
  1058. STAC 9200-32 pin configs for
  1059. 102801B5 (Dell Inspiron 630m)
  1060. 102801D8 (Dell Inspiron 640m)
  1061. */
  1062. static const unsigned int dell9200_m21_pin_configs[8] = {
  1063. 0x40c003fa, 0x03441340, 0x0321121f, 0x90170310,
  1064. 0x408003fb, 0x03a11020, 0x401003fc, 0x403003fd,
  1065. };
  1066. /*
  1067. STAC 9200-32 pin configs for
  1068. 102801C2 (Dell Latitude D620)
  1069. 102801C8
  1070. 102801CC (Dell Latitude D820)
  1071. 102801D4
  1072. 102801D6
  1073. */
  1074. static const unsigned int dell9200_m22_pin_configs[8] = {
  1075. 0x40c003fa, 0x0144131f, 0x0321121f, 0x90170310,
  1076. 0x90a70321, 0x03a11020, 0x401003fb, 0x40f000fc,
  1077. };
  1078. /*
  1079. STAC 9200-32 pin configs for
  1080. 102801CE (Dell XPS M1710)
  1081. 102801CF (Dell Precision M90)
  1082. */
  1083. static const unsigned int dell9200_m23_pin_configs[8] = {
  1084. 0x40c003fa, 0x01441340, 0x0421421f, 0x90170310,
  1085. 0x408003fb, 0x04a1102e, 0x90170311, 0x403003fc,
  1086. };
  1087. /*
  1088. STAC 9200-32 pin configs for
  1089. 102801C9
  1090. 102801CA
  1091. 102801CB (Dell Latitude 120L)
  1092. 102801D3
  1093. */
  1094. static const unsigned int dell9200_m24_pin_configs[8] = {
  1095. 0x40c003fa, 0x404003fb, 0x0321121f, 0x90170310,
  1096. 0x408003fc, 0x03a11020, 0x401003fd, 0x403003fe,
  1097. };
  1098. /*
  1099. STAC 9200-32 pin configs for
  1100. 102801BD (Dell Inspiron E1505n)
  1101. 102801EE
  1102. 102801EF
  1103. */
  1104. static const unsigned int dell9200_m25_pin_configs[8] = {
  1105. 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
  1106. 0x408003fb, 0x04a11020, 0x401003fc, 0x403003fd,
  1107. };
  1108. /*
  1109. STAC 9200-32 pin configs for
  1110. 102801F5 (Dell Inspiron 1501)
  1111. 102801F6
  1112. */
  1113. static const unsigned int dell9200_m26_pin_configs[8] = {
  1114. 0x40c003fa, 0x404003fb, 0x0421121f, 0x90170310,
  1115. 0x408003fc, 0x04a11020, 0x401003fd, 0x403003fe,
  1116. };
  1117. /*
  1118. STAC 9200-32
  1119. 102801CD (Dell Inspiron E1705/9400)
  1120. */
  1121. static const unsigned int dell9200_m27_pin_configs[8] = {
  1122. 0x40c003fa, 0x01441340, 0x0421121f, 0x90170310,
  1123. 0x90170310, 0x04a11020, 0x90170310, 0x40f003fc,
  1124. };
  1125. static const unsigned int oqo9200_pin_configs[8] = {
  1126. 0x40c000f0, 0x404000f1, 0x0221121f, 0x02211210,
  1127. 0x90170111, 0x90a70120, 0x400000f2, 0x400000f3,
  1128. };
  1129. static const unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
  1130. [STAC_REF] = ref9200_pin_configs,
  1131. [STAC_9200_OQO] = oqo9200_pin_configs,
  1132. [STAC_9200_DELL_D21] = dell9200_d21_pin_configs,
  1133. [STAC_9200_DELL_D22] = dell9200_d22_pin_configs,
  1134. [STAC_9200_DELL_D23] = dell9200_d23_pin_configs,
  1135. [STAC_9200_DELL_M21] = dell9200_m21_pin_configs,
  1136. [STAC_9200_DELL_M22] = dell9200_m22_pin_configs,
  1137. [STAC_9200_DELL_M23] = dell9200_m23_pin_configs,
  1138. [STAC_9200_DELL_M24] = dell9200_m24_pin_configs,
  1139. [STAC_9200_DELL_M25] = dell9200_m25_pin_configs,
  1140. [STAC_9200_DELL_M26] = dell9200_m26_pin_configs,
  1141. [STAC_9200_DELL_M27] = dell9200_m27_pin_configs,
  1142. [STAC_9200_M4] = gateway9200_m4_pin_configs,
  1143. [STAC_9200_M4_2] = gateway9200_m4_2_pin_configs,
  1144. [STAC_9200_PANASONIC] = ref9200_pin_configs,
  1145. };
  1146. static const char * const stac9200_models[STAC_9200_MODELS] = {
  1147. [STAC_AUTO] = "auto",
  1148. [STAC_REF] = "ref",
  1149. [STAC_9200_OQO] = "oqo",
  1150. [STAC_9200_DELL_D21] = "dell-d21",
  1151. [STAC_9200_DELL_D22] = "dell-d22",
  1152. [STAC_9200_DELL_D23] = "dell-d23",
  1153. [STAC_9200_DELL_M21] = "dell-m21",
  1154. [STAC_9200_DELL_M22] = "dell-m22",
  1155. [STAC_9200_DELL_M23] = "dell-m23",
  1156. [STAC_9200_DELL_M24] = "dell-m24",
  1157. [STAC_9200_DELL_M25] = "dell-m25",
  1158. [STAC_9200_DELL_M26] = "dell-m26",
  1159. [STAC_9200_DELL_M27] = "dell-m27",
  1160. [STAC_9200_M4] = "gateway-m4",
  1161. [STAC_9200_M4_2] = "gateway-m4-2",
  1162. [STAC_9200_PANASONIC] = "panasonic",
  1163. };
  1164. static const struct snd_pci_quirk stac9200_cfg_tbl[] = {
  1165. /* SigmaTel reference board */
  1166. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1167. "DFI LanParty", STAC_REF),
  1168. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1169. "DFI LanParty", STAC_REF),
  1170. /* Dell laptops have BIOS problem */
  1171. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
  1172. "unknown Dell", STAC_9200_DELL_D21),
  1173. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
  1174. "Dell Inspiron 630m", STAC_9200_DELL_M21),
  1175. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
  1176. "Dell Inspiron E1505n", STAC_9200_DELL_M25),
  1177. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
  1178. "unknown Dell", STAC_9200_DELL_D22),
  1179. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
  1180. "unknown Dell", STAC_9200_DELL_D22),
  1181. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
  1182. "Dell Latitude D620", STAC_9200_DELL_M22),
  1183. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
  1184. "unknown Dell", STAC_9200_DELL_D23),
  1185. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
  1186. "unknown Dell", STAC_9200_DELL_D23),
  1187. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
  1188. "unknown Dell", STAC_9200_DELL_M22),
  1189. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
  1190. "unknown Dell", STAC_9200_DELL_M24),
  1191. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
  1192. "unknown Dell", STAC_9200_DELL_M24),
  1193. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
  1194. "Dell Latitude 120L", STAC_9200_DELL_M24),
  1195. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
  1196. "Dell Latitude D820", STAC_9200_DELL_M22),
  1197. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
  1198. "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
  1199. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
  1200. "Dell XPS M1710", STAC_9200_DELL_M23),
  1201. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
  1202. "Dell Precision M90", STAC_9200_DELL_M23),
  1203. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
  1204. "unknown Dell", STAC_9200_DELL_M22),
  1205. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
  1206. "unknown Dell", STAC_9200_DELL_M22),
  1207. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
  1208. "unknown Dell", STAC_9200_DELL_M22),
  1209. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
  1210. "Dell Inspiron 640m", STAC_9200_DELL_M21),
  1211. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
  1212. "unknown Dell", STAC_9200_DELL_D23),
  1213. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
  1214. "unknown Dell", STAC_9200_DELL_D23),
  1215. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
  1216. "unknown Dell", STAC_9200_DELL_D21),
  1217. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
  1218. "unknown Dell", STAC_9200_DELL_D23),
  1219. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
  1220. "unknown Dell", STAC_9200_DELL_D21),
  1221. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
  1222. "unknown Dell", STAC_9200_DELL_M25),
  1223. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
  1224. "unknown Dell", STAC_9200_DELL_M25),
  1225. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
  1226. "Dell Inspiron 1501", STAC_9200_DELL_M26),
  1227. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
  1228. "unknown Dell", STAC_9200_DELL_M26),
  1229. /* Panasonic */
  1230. SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
  1231. /* Gateway machines needs EAPD to be set on resume */
  1232. SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
  1233. SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
  1234. SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
  1235. /* OQO Mobile */
  1236. SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
  1237. {} /* terminator */
  1238. };
  1239. static const unsigned int ref925x_pin_configs[8] = {
  1240. 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
  1241. 0x90a70320, 0x02214210, 0x01019020, 0x9033032e,
  1242. };
  1243. static const unsigned int stac925xM1_pin_configs[8] = {
  1244. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1245. 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
  1246. };
  1247. static const unsigned int stac925xM1_2_pin_configs[8] = {
  1248. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1249. 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
  1250. };
  1251. static const unsigned int stac925xM2_pin_configs[8] = {
  1252. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1253. 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
  1254. };
  1255. static const unsigned int stac925xM2_2_pin_configs[8] = {
  1256. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1257. 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
  1258. };
  1259. static const unsigned int stac925xM3_pin_configs[8] = {
  1260. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1261. 0x40a000f0, 0x90100210, 0x400003f1, 0x503303f3,
  1262. };
  1263. static const unsigned int stac925xM5_pin_configs[8] = {
  1264. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1265. 0x40a000f0, 0x90100210, 0x400003f1, 0x9033032e,
  1266. };
  1267. static const unsigned int stac925xM6_pin_configs[8] = {
  1268. 0x40c003f4, 0x424503f2, 0x400000f3, 0x02a19020,
  1269. 0x40a000f0, 0x90100210, 0x400003f1, 0x90330320,
  1270. };
  1271. static const unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
  1272. [STAC_REF] = ref925x_pin_configs,
  1273. [STAC_M1] = stac925xM1_pin_configs,
  1274. [STAC_M1_2] = stac925xM1_2_pin_configs,
  1275. [STAC_M2] = stac925xM2_pin_configs,
  1276. [STAC_M2_2] = stac925xM2_2_pin_configs,
  1277. [STAC_M3] = stac925xM3_pin_configs,
  1278. [STAC_M5] = stac925xM5_pin_configs,
  1279. [STAC_M6] = stac925xM6_pin_configs,
  1280. };
  1281. static const char * const stac925x_models[STAC_925x_MODELS] = {
  1282. [STAC_925x_AUTO] = "auto",
  1283. [STAC_REF] = "ref",
  1284. [STAC_M1] = "m1",
  1285. [STAC_M1_2] = "m1-2",
  1286. [STAC_M2] = "m2",
  1287. [STAC_M2_2] = "m2-2",
  1288. [STAC_M3] = "m3",
  1289. [STAC_M5] = "m5",
  1290. [STAC_M6] = "m6",
  1291. };
  1292. static const struct snd_pci_quirk stac925x_codec_id_cfg_tbl[] = {
  1293. SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
  1294. SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
  1295. SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
  1296. SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
  1297. SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
  1298. /* Not sure about the brand name for those */
  1299. SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
  1300. SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
  1301. SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
  1302. SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
  1303. {} /* terminator */
  1304. };
  1305. static const struct snd_pci_quirk stac925x_cfg_tbl[] = {
  1306. /* SigmaTel reference board */
  1307. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
  1308. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
  1309. SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
  1310. /* Default table for unknown ID */
  1311. SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
  1312. {} /* terminator */
  1313. };
  1314. static const unsigned int ref92hd73xx_pin_configs[13] = {
  1315. 0x02214030, 0x02a19040, 0x01a19020, 0x02214030,
  1316. 0x0181302e, 0x01014010, 0x01014020, 0x01014030,
  1317. 0x02319040, 0x90a000f0, 0x90a000f0, 0x01452050,
  1318. 0x01452050,
  1319. };
  1320. static const unsigned int dell_m6_pin_configs[13] = {
  1321. 0x0321101f, 0x4f00000f, 0x4f0000f0, 0x90170110,
  1322. 0x03a11020, 0x0321101f, 0x4f0000f0, 0x4f0000f0,
  1323. 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
  1324. 0x4f0000f0,
  1325. };
  1326. static const unsigned int alienware_m17x_pin_configs[13] = {
  1327. 0x0321101f, 0x0321101f, 0x03a11020, 0x03014020,
  1328. 0x90170110, 0x4f0000f0, 0x4f0000f0, 0x4f0000f0,
  1329. 0x4f0000f0, 0x90a60160, 0x4f0000f0, 0x4f0000f0,
  1330. 0x904601b0,
  1331. };
  1332. static const unsigned int intel_dg45id_pin_configs[13] = {
  1333. 0x02214230, 0x02A19240, 0x01013214, 0x01014210,
  1334. 0x01A19250, 0x01011212, 0x01016211
  1335. };
  1336. static const unsigned int *stac92hd73xx_brd_tbl[STAC_92HD73XX_MODELS] = {
  1337. [STAC_92HD73XX_REF] = ref92hd73xx_pin_configs,
  1338. [STAC_DELL_M6_AMIC] = dell_m6_pin_configs,
  1339. [STAC_DELL_M6_DMIC] = dell_m6_pin_configs,
  1340. [STAC_DELL_M6_BOTH] = dell_m6_pin_configs,
  1341. [STAC_DELL_EQ] = dell_m6_pin_configs,
  1342. [STAC_ALIENWARE_M17X] = alienware_m17x_pin_configs,
  1343. [STAC_92HD73XX_INTEL] = intel_dg45id_pin_configs,
  1344. };
  1345. static const char * const stac92hd73xx_models[STAC_92HD73XX_MODELS] = {
  1346. [STAC_92HD73XX_AUTO] = "auto",
  1347. [STAC_92HD73XX_NO_JD] = "no-jd",
  1348. [STAC_92HD73XX_REF] = "ref",
  1349. [STAC_92HD73XX_INTEL] = "intel",
  1350. [STAC_DELL_M6_AMIC] = "dell-m6-amic",
  1351. [STAC_DELL_M6_DMIC] = "dell-m6-dmic",
  1352. [STAC_DELL_M6_BOTH] = "dell-m6",
  1353. [STAC_DELL_EQ] = "dell-eq",
  1354. [STAC_ALIENWARE_M17X] = "alienware",
  1355. };
  1356. static const struct snd_pci_quirk stac92hd73xx_cfg_tbl[] = {
  1357. /* SigmaTel reference board */
  1358. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1359. "DFI LanParty", STAC_92HD73XX_REF),
  1360. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1361. "DFI LanParty", STAC_92HD73XX_REF),
  1362. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
  1363. "Intel DG45ID", STAC_92HD73XX_INTEL),
  1364. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
  1365. "Intel DG45FC", STAC_92HD73XX_INTEL),
  1366. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
  1367. "Dell Studio 1535", STAC_DELL_M6_DMIC),
  1368. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
  1369. "unknown Dell", STAC_DELL_M6_DMIC),
  1370. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
  1371. "unknown Dell", STAC_DELL_M6_BOTH),
  1372. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
  1373. "unknown Dell", STAC_DELL_M6_BOTH),
  1374. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
  1375. "unknown Dell", STAC_DELL_M6_AMIC),
  1376. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
  1377. "unknown Dell", STAC_DELL_M6_AMIC),
  1378. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
  1379. "unknown Dell", STAC_DELL_M6_DMIC),
  1380. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
  1381. "unknown Dell", STAC_DELL_M6_DMIC),
  1382. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
  1383. "Dell Studio 1537", STAC_DELL_M6_DMIC),
  1384. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
  1385. "Dell Studio 17", STAC_DELL_M6_DMIC),
  1386. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
  1387. "Dell Studio 1555", STAC_DELL_M6_DMIC),
  1388. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
  1389. "Dell Studio 1557", STAC_DELL_M6_DMIC),
  1390. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
  1391. "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
  1392. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
  1393. "Dell Studio 1558", STAC_DELL_M6_DMIC),
  1394. {} /* terminator */
  1395. };
  1396. static const struct snd_pci_quirk stac92hd73xx_codec_id_cfg_tbl[] = {
  1397. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
  1398. "Alienware M17x", STAC_ALIENWARE_M17X),
  1399. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
  1400. "Alienware M17x", STAC_ALIENWARE_M17X),
  1401. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
  1402. "Alienware M17x R3", STAC_DELL_EQ),
  1403. {} /* terminator */
  1404. };
  1405. static const unsigned int ref92hd83xxx_pin_configs[10] = {
  1406. 0x02214030, 0x02211010, 0x02a19020, 0x02170130,
  1407. 0x01014050, 0x01819040, 0x01014020, 0x90a3014e,
  1408. 0x01451160, 0x98560170,
  1409. };
  1410. static const unsigned int dell_s14_pin_configs[10] = {
  1411. 0x0221403f, 0x0221101f, 0x02a19020, 0x90170110,
  1412. 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a60160,
  1413. 0x40f000f0, 0x40f000f0,
  1414. };
  1415. static const unsigned int dell_vostro_3500_pin_configs[10] = {
  1416. 0x02a11020, 0x0221101f, 0x400000f0, 0x90170110,
  1417. 0x400000f1, 0x400000f2, 0x400000f3, 0x90a60160,
  1418. 0x400000f4, 0x400000f5,
  1419. };
  1420. static const unsigned int hp_dv7_4000_pin_configs[10] = {
  1421. 0x03a12050, 0x0321201f, 0x40f000f0, 0x90170110,
  1422. 0x40f000f0, 0x40f000f0, 0x90170110, 0xd5a30140,
  1423. 0x40f000f0, 0x40f000f0,
  1424. };
  1425. static const unsigned int hp_zephyr_pin_configs[10] = {
  1426. 0x01813050, 0x0421201f, 0x04a1205e, 0x96130310,
  1427. 0x96130310, 0x0101401f, 0x1111611f, 0xd5a30130,
  1428. 0, 0,
  1429. };
  1430. static const unsigned int hp_cNB11_intquad_pin_configs[10] = {
  1431. 0x40f000f0, 0x0221101f, 0x02a11020, 0x92170110,
  1432. 0x40f000f0, 0x92170110, 0x40f000f0, 0xd5a30130,
  1433. 0x40f000f0, 0x40f000f0,
  1434. };
  1435. static const unsigned int *stac92hd83xxx_brd_tbl[STAC_92HD83XXX_MODELS] = {
  1436. [STAC_92HD83XXX_REF] = ref92hd83xxx_pin_configs,
  1437. [STAC_92HD83XXX_PWR_REF] = ref92hd83xxx_pin_configs,
  1438. [STAC_DELL_S14] = dell_s14_pin_configs,
  1439. [STAC_DELL_VOSTRO_3500] = dell_vostro_3500_pin_configs,
  1440. [STAC_92HD83XXX_HP_cNB11_INTQUAD] = hp_cNB11_intquad_pin_configs,
  1441. [STAC_HP_DV7_4000] = hp_dv7_4000_pin_configs,
  1442. [STAC_HP_ZEPHYR] = hp_zephyr_pin_configs,
  1443. };
  1444. static const char * const stac92hd83xxx_models[STAC_92HD83XXX_MODELS] = {
  1445. [STAC_92HD83XXX_AUTO] = "auto",
  1446. [STAC_92HD83XXX_REF] = "ref",
  1447. [STAC_92HD83XXX_PWR_REF] = "mic-ref",
  1448. [STAC_DELL_S14] = "dell-s14",
  1449. [STAC_DELL_VOSTRO_3500] = "dell-vostro-3500",
  1450. [STAC_92HD83XXX_HP_cNB11_INTQUAD] = "hp_cNB11_intquad",
  1451. [STAC_HP_DV7_4000] = "hp-dv7-4000",
  1452. [STAC_HP_ZEPHYR] = "hp-zephyr",
  1453. };
  1454. static const struct snd_pci_quirk stac92hd83xxx_cfg_tbl[] = {
  1455. /* SigmaTel reference board */
  1456. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1457. "DFI LanParty", STAC_92HD83XXX_REF),
  1458. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1459. "DFI LanParty", STAC_92HD83XXX_REF),
  1460. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
  1461. "unknown Dell", STAC_DELL_S14),
  1462. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
  1463. "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
  1464. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
  1465. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1466. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
  1467. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1468. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
  1469. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1470. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
  1471. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1472. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
  1473. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1474. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
  1475. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1476. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
  1477. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1478. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
  1479. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1480. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
  1481. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1482. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
  1483. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1484. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
  1485. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1486. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
  1487. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1488. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
  1489. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1490. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
  1491. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1492. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
  1493. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1494. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
  1495. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1496. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
  1497. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1498. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
  1499. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1500. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
  1501. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1502. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
  1503. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1504. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
  1505. "HP", STAC_HP_ZEPHYR),
  1506. {} /* terminator */
  1507. };
  1508. static const struct snd_pci_quirk stac92hd83xxx_codec_id_cfg_tbl[] = {
  1509. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
  1510. "HP", STAC_HP_ZEPHYR),
  1511. {} /* terminator */
  1512. };
  1513. static const unsigned int ref92hd71bxx_pin_configs[STAC92HD71BXX_NUM_PINS] = {
  1514. 0x02214030, 0x02a19040, 0x01a19020, 0x01014010,
  1515. 0x0181302e, 0x01014010, 0x01019020, 0x90a000f0,
  1516. 0x90a000f0, 0x01452050, 0x01452050, 0x00000000,
  1517. 0x00000000
  1518. };
  1519. static const unsigned int dell_m4_1_pin_configs[STAC92HD71BXX_NUM_PINS] = {
  1520. 0x0421101f, 0x04a11221, 0x40f000f0, 0x90170110,
  1521. 0x23a1902e, 0x23014250, 0x40f000f0, 0x90a000f0,
  1522. 0x40f000f0, 0x4f0000f0, 0x4f0000f0, 0x00000000,
  1523. 0x00000000
  1524. };
  1525. static const unsigned int dell_m4_2_pin_configs[STAC92HD71BXX_NUM_PINS] = {
  1526. 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
  1527. 0x23a1902e, 0x23014250, 0x40f000f0, 0x40f000f0,
  1528. 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
  1529. 0x00000000
  1530. };
  1531. static const unsigned int dell_m4_3_pin_configs[STAC92HD71BXX_NUM_PINS] = {
  1532. 0x0421101f, 0x04a11221, 0x90a70330, 0x90170110,
  1533. 0x40f000f0, 0x40f000f0, 0x40f000f0, 0x90a000f0,
  1534. 0x40f000f0, 0x044413b0, 0x044413b0, 0x00000000,
  1535. 0x00000000
  1536. };
  1537. static const unsigned int *stac92hd71bxx_brd_tbl[STAC_92HD71BXX_MODELS] = {
  1538. [STAC_92HD71BXX_REF] = ref92hd71bxx_pin_configs,
  1539. [STAC_DELL_M4_1] = dell_m4_1_pin_configs,
  1540. [STAC_DELL_M4_2] = dell_m4_2_pin_configs,
  1541. [STAC_DELL_M4_3] = dell_m4_3_pin_configs,
  1542. [STAC_HP_M4] = NULL,
  1543. [STAC_HP_DV4] = NULL,
  1544. [STAC_HP_DV5] = NULL,
  1545. [STAC_HP_HDX] = NULL,
  1546. [STAC_HP_DV4_1222NR] = NULL,
  1547. };
  1548. static const char * const stac92hd71bxx_models[STAC_92HD71BXX_MODELS] = {
  1549. [STAC_92HD71BXX_AUTO] = "auto",
  1550. [STAC_92HD71BXX_REF] = "ref",
  1551. [STAC_DELL_M4_1] = "dell-m4-1",
  1552. [STAC_DELL_M4_2] = "dell-m4-2",
  1553. [STAC_DELL_M4_3] = "dell-m4-3",
  1554. [STAC_HP_M4] = "hp-m4",
  1555. [STAC_HP_DV4] = "hp-dv4",
  1556. [STAC_HP_DV5] = "hp-dv5",
  1557. [STAC_HP_HDX] = "hp-hdx",
  1558. [STAC_HP_DV4_1222NR] = "hp-dv4-1222nr",
  1559. };
  1560. static const struct snd_pci_quirk stac92hd71bxx_cfg_tbl[] = {
  1561. /* SigmaTel reference board */
  1562. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1563. "DFI LanParty", STAC_92HD71BXX_REF),
  1564. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1565. "DFI LanParty", STAC_92HD71BXX_REF),
  1566. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x30fb,
  1567. "HP dv4-1222nr", STAC_HP_DV4_1222NR),
  1568. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
  1569. "HP", STAC_HP_DV5),
  1570. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
  1571. "HP", STAC_HP_DV5),
  1572. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
  1573. "HP dv4-7", STAC_HP_DV4),
  1574. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
  1575. "HP dv4-7", STAC_HP_DV5),
  1576. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
  1577. "HP HDX", STAC_HP_HDX), /* HDX18 */
  1578. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
  1579. "HP mini 1000", STAC_HP_M4),
  1580. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
  1581. "HP HDX", STAC_HP_HDX), /* HDX16 */
  1582. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
  1583. "HP dv6", STAC_HP_DV5),
  1584. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
  1585. "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
  1586. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
  1587. "HP DV6", STAC_HP_DV5),
  1588. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
  1589. "HP", STAC_HP_DV5),
  1590. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
  1591. "unknown Dell", STAC_DELL_M4_1),
  1592. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
  1593. "unknown Dell", STAC_DELL_M4_1),
  1594. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
  1595. "unknown Dell", STAC_DELL_M4_1),
  1596. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
  1597. "unknown Dell", STAC_DELL_M4_1),
  1598. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
  1599. "unknown Dell", STAC_DELL_M4_1),
  1600. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
  1601. "unknown Dell", STAC_DELL_M4_1),
  1602. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
  1603. "unknown Dell", STAC_DELL_M4_1),
  1604. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
  1605. "unknown Dell", STAC_DELL_M4_2),
  1606. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
  1607. "unknown Dell", STAC_DELL_M4_2),
  1608. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
  1609. "unknown Dell", STAC_DELL_M4_2),
  1610. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
  1611. "unknown Dell", STAC_DELL_M4_2),
  1612. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
  1613. "unknown Dell", STAC_DELL_M4_3),
  1614. {} /* terminator */
  1615. };
  1616. static const unsigned int ref922x_pin_configs[10] = {
  1617. 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
  1618. 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
  1619. 0x40000100, 0x40000100,
  1620. };
  1621. /*
  1622. STAC 922X pin configs for
  1623. 102801A7
  1624. 102801AB
  1625. 102801A9
  1626. 102801D1
  1627. 102801D2
  1628. */
  1629. static const unsigned int dell_922x_d81_pin_configs[10] = {
  1630. 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
  1631. 0x02a19020, 0x01117011, 0x400001f0, 0x400001f1,
  1632. 0x01813122, 0x400001f2,
  1633. };
  1634. /*
  1635. STAC 922X pin configs for
  1636. 102801AC
  1637. 102801D0
  1638. */
  1639. static const unsigned int dell_922x_d82_pin_configs[10] = {
  1640. 0x02214030, 0x01a19021, 0x01111012, 0x01114010,
  1641. 0x02a19020, 0x01117011, 0x01451140, 0x400001f0,
  1642. 0x01813122, 0x400001f1,
  1643. };
  1644. /*
  1645. STAC 922X pin configs for
  1646. 102801BF
  1647. */
  1648. static const unsigned int dell_922x_m81_pin_configs[10] = {
  1649. 0x0321101f, 0x01112024, 0x01111222, 0x91174220,
  1650. 0x03a11050, 0x01116221, 0x90a70330, 0x01452340,
  1651. 0x40C003f1, 0x405003f0,
  1652. };
  1653. /*
  1654. STAC 9221 A1 pin configs for
  1655. 102801D7 (Dell XPS M1210)
  1656. */
  1657. static const unsigned int dell_922x_m82_pin_configs[10] = {
  1658. 0x02211211, 0x408103ff, 0x02a1123e, 0x90100310,
  1659. 0x408003f1, 0x0221121f, 0x03451340, 0x40c003f2,
  1660. 0x508003f3, 0x405003f4,
  1661. };
  1662. static const unsigned int d945gtp3_pin_configs[10] = {
  1663. 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
  1664. 0x40000100, 0x40000100, 0x40000100, 0x40000100,
  1665. 0x02a19120, 0x40000100,
  1666. };
  1667. static const unsigned int d945gtp5_pin_configs[10] = {
  1668. 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
  1669. 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
  1670. 0x02a19320, 0x40000100,
  1671. };
  1672. static const unsigned int intel_mac_v1_pin_configs[10] = {
  1673. 0x0121e21f, 0x400000ff, 0x9017e110, 0x400000fd,
  1674. 0x400000fe, 0x0181e020, 0x1145e030, 0x11c5e240,
  1675. 0x400000fc, 0x400000fb,
  1676. };
  1677. static const unsigned int intel_mac_v2_pin_configs[10] = {
  1678. 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
  1679. 0x400000fe, 0x0181e020, 0x1145e230, 0x500000fa,
  1680. 0x400000fc, 0x400000fb,
  1681. };
  1682. static const unsigned int intel_mac_v3_pin_configs[10] = {
  1683. 0x0121e21f, 0x90a7012e, 0x9017e110, 0x400000fd,
  1684. 0x400000fe, 0x0181e020, 0x1145e230, 0x11c5e240,
  1685. 0x400000fc, 0x400000fb,
  1686. };
  1687. static const unsigned int intel_mac_v4_pin_configs[10] = {
  1688. 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
  1689. 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
  1690. 0x400000fc, 0x400000fb,
  1691. };
  1692. static const unsigned int intel_mac_v5_pin_configs[10] = {
  1693. 0x0321e21f, 0x03a1e02e, 0x9017e110, 0x9017e11f,
  1694. 0x400000fe, 0x0381e020, 0x1345e230, 0x13c5e240,
  1695. 0x400000fc, 0x400000fb,
  1696. };
  1697. static const unsigned int ecs202_pin_configs[10] = {
  1698. 0x0221401f, 0x02a19020, 0x01a19020, 0x01114010,
  1699. 0x408000f0, 0x01813022, 0x074510a0, 0x40c400f1,
  1700. 0x9037012e, 0x40e000f2,
  1701. };
  1702. static const unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
  1703. [STAC_D945_REF] = ref922x_pin_configs,
  1704. [STAC_D945GTP3] = d945gtp3_pin_configs,
  1705. [STAC_D945GTP5] = d945gtp5_pin_configs,
  1706. [STAC_INTEL_MAC_V1] = intel_mac_v1_pin_configs,
  1707. [STAC_INTEL_MAC_V2] = intel_mac_v2_pin_configs,
  1708. [STAC_INTEL_MAC_V3] = intel_mac_v3_pin_configs,
  1709. [STAC_INTEL_MAC_V4] = intel_mac_v4_pin_configs,
  1710. [STAC_INTEL_MAC_V5] = intel_mac_v5_pin_configs,
  1711. [STAC_INTEL_MAC_AUTO] = intel_mac_v3_pin_configs,
  1712. /* for backward compatibility */
  1713. [STAC_MACMINI] = intel_mac_v3_pin_configs,
  1714. [STAC_MACBOOK] = intel_mac_v5_pin_configs,
  1715. [STAC_MACBOOK_PRO_V1] = intel_mac_v3_pin_configs,
  1716. [STAC_MACBOOK_PRO_V2] = intel_mac_v3_pin_configs,
  1717. [STAC_IMAC_INTEL] = intel_mac_v2_pin_configs,
  1718. [STAC_IMAC_INTEL_20] = intel_mac_v3_pin_configs,
  1719. [STAC_ECS_202] = ecs202_pin_configs,
  1720. [STAC_922X_DELL_D81] = dell_922x_d81_pin_configs,
  1721. [STAC_922X_DELL_D82] = dell_922x_d82_pin_configs,
  1722. [STAC_922X_DELL_M81] = dell_922x_m81_pin_configs,
  1723. [STAC_922X_DELL_M82] = dell_922x_m82_pin_configs,
  1724. };
  1725. static const char * const stac922x_models[STAC_922X_MODELS] = {
  1726. [STAC_922X_AUTO] = "auto",
  1727. [STAC_D945_REF] = "ref",
  1728. [STAC_D945GTP5] = "5stack",
  1729. [STAC_D945GTP3] = "3stack",
  1730. [STAC_INTEL_MAC_V1] = "intel-mac-v1",
  1731. [STAC_INTEL_MAC_V2] = "intel-mac-v2",
  1732. [STAC_INTEL_MAC_V3] = "intel-mac-v3",
  1733. [STAC_INTEL_MAC_V4] = "intel-mac-v4",
  1734. [STAC_INTEL_MAC_V5] = "intel-mac-v5",
  1735. [STAC_INTEL_MAC_AUTO] = "intel-mac-auto",
  1736. /* for backward compatibility */
  1737. [STAC_MACMINI] = "macmini",
  1738. [STAC_MACBOOK] = "macbook",
  1739. [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
  1740. [STAC_MACBOOK_PRO_V2] = "macbook-pro",
  1741. [STAC_IMAC_INTEL] = "imac-intel",
  1742. [STAC_IMAC_INTEL_20] = "imac-intel-20",
  1743. [STAC_ECS_202] = "ecs202",
  1744. [STAC_922X_DELL_D81] = "dell-d81",
  1745. [STAC_922X_DELL_D82] = "dell-d82",
  1746. [STAC_922X_DELL_M81] = "dell-m81",
  1747. [STAC_922X_DELL_M82] = "dell-m82",
  1748. };
  1749. static const struct snd_pci_quirk stac922x_cfg_tbl[] = {
  1750. /* SigmaTel reference board */
  1751. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1752. "DFI LanParty", STAC_D945_REF),
  1753. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1754. "DFI LanParty", STAC_D945_REF),
  1755. /* Intel 945G based systems */
  1756. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
  1757. "Intel D945G", STAC_D945GTP3),
  1758. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
  1759. "Intel D945G", STAC_D945GTP3),
  1760. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
  1761. "Intel D945G", STAC_D945GTP3),
  1762. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
  1763. "Intel D945G", STAC_D945GTP3),
  1764. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
  1765. "Intel D945G", STAC_D945GTP3),
  1766. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
  1767. "Intel D945G", STAC_D945GTP3),
  1768. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
  1769. "Intel D945G", STAC_D945GTP3),
  1770. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
  1771. "Intel D945G", STAC_D945GTP3),
  1772. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
  1773. "Intel D945G", STAC_D945GTP3),
  1774. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
  1775. "Intel D945G", STAC_D945GTP3),
  1776. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
  1777. "Intel D945G", STAC_D945GTP3),
  1778. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
  1779. "Intel D945G", STAC_D945GTP3),
  1780. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
  1781. "Intel D945G", STAC_D945GTP3),
  1782. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
  1783. "Intel D945G", STAC_D945GTP3),
  1784. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
  1785. "Intel D945G", STAC_D945GTP3),
  1786. /* Intel D945G 5-stack systems */
  1787. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
  1788. "Intel D945G", STAC_D945GTP5),
  1789. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
  1790. "Intel D945G", STAC_D945GTP5),
  1791. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
  1792. "Intel D945G", STAC_D945GTP5),
  1793. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
  1794. "Intel D945G", STAC_D945GTP5),
  1795. /* Intel 945P based systems */
  1796. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
  1797. "Intel D945P", STAC_D945GTP3),
  1798. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
  1799. "Intel D945P", STAC_D945GTP3),
  1800. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
  1801. "Intel D945P", STAC_D945GTP3),
  1802. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
  1803. "Intel D945P", STAC_D945GTP3),
  1804. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
  1805. "Intel D945P", STAC_D945GTP3),
  1806. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
  1807. "Intel D945P", STAC_D945GTP5),
  1808. /* other intel */
  1809. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
  1810. "Intel D945", STAC_D945_REF),
  1811. /* other systems */
  1812. /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
  1813. SND_PCI_QUIRK(0x8384, 0x7680,
  1814. "Mac", STAC_INTEL_MAC_AUTO),
  1815. /* Dell systems */
  1816. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
  1817. "unknown Dell", STAC_922X_DELL_D81),
  1818. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
  1819. "unknown Dell", STAC_922X_DELL_D81),
  1820. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
  1821. "unknown Dell", STAC_922X_DELL_D81),
  1822. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
  1823. "unknown Dell", STAC_922X_DELL_D82),
  1824. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
  1825. "unknown Dell", STAC_922X_DELL_M81),
  1826. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
  1827. "unknown Dell", STAC_922X_DELL_D82),
  1828. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
  1829. "unknown Dell", STAC_922X_DELL_D81),
  1830. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
  1831. "unknown Dell", STAC_922X_DELL_D81),
  1832. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
  1833. "Dell XPS M1210", STAC_922X_DELL_M82),
  1834. /* ECS/PC Chips boards */
  1835. SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
  1836. "ECS/PC chips", STAC_ECS_202),
  1837. {} /* terminator */
  1838. };
  1839. static const unsigned int ref927x_pin_configs[14] = {
  1840. 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
  1841. 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
  1842. 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
  1843. 0x01c42190, 0x40000100,
  1844. };
  1845. static const unsigned int d965_3st_pin_configs[14] = {
  1846. 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
  1847. 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
  1848. 0x40000100, 0x40000100, 0x40000100, 0x40000100,
  1849. 0x40000100, 0x40000100
  1850. };
  1851. static const unsigned int d965_5st_pin_configs[14] = {
  1852. 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
  1853. 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
  1854. 0x40000100, 0x40000100, 0x40000100, 0x01442070,
  1855. 0x40000100, 0x40000100
  1856. };
  1857. static const unsigned int d965_5st_no_fp_pin_configs[14] = {
  1858. 0x40000100, 0x40000100, 0x0181304e, 0x01014010,
  1859. 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
  1860. 0x40000100, 0x40000100, 0x40000100, 0x01442070,
  1861. 0x40000100, 0x40000100
  1862. };
  1863. static const unsigned int dell_3st_pin_configs[14] = {
  1864. 0x02211230, 0x02a11220, 0x01a19040, 0x01114210,
  1865. 0x01111212, 0x01116211, 0x01813050, 0x01112214,
  1866. 0x403003fa, 0x90a60040, 0x90a60040, 0x404003fb,
  1867. 0x40c003fc, 0x40000100
  1868. };
  1869. static const unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
  1870. [STAC_D965_REF_NO_JD] = ref927x_pin_configs,
  1871. [STAC_D965_REF] = ref927x_pin_configs,
  1872. [STAC_D965_3ST] = d965_3st_pin_configs,
  1873. [STAC_D965_5ST] = d965_5st_pin_configs,
  1874. [STAC_D965_5ST_NO_FP] = d965_5st_no_fp_pin_configs,
  1875. [STAC_DELL_3ST] = dell_3st_pin_configs,
  1876. [STAC_DELL_BIOS] = NULL,
  1877. [STAC_927X_VOLKNOB] = NULL,
  1878. };
  1879. static const char * const stac927x_models[STAC_927X_MODELS] = {
  1880. [STAC_927X_AUTO] = "auto",
  1881. [STAC_D965_REF_NO_JD] = "ref-no-jd",
  1882. [STAC_D965_REF] = "ref",
  1883. [STAC_D965_3ST] = "3stack",
  1884. [STAC_D965_5ST] = "5stack",
  1885. [STAC_D965_5ST_NO_FP] = "5stack-no-fp",
  1886. [STAC_DELL_3ST] = "dell-3stack",
  1887. [STAC_DELL_BIOS] = "dell-bios",
  1888. [STAC_927X_VOLKNOB] = "volknob",
  1889. };
  1890. static const struct snd_pci_quirk stac927x_cfg_tbl[] = {
  1891. /* SigmaTel reference board */
  1892. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1893. "DFI LanParty", STAC_D965_REF),
  1894. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1895. "DFI LanParty", STAC_D965_REF),
  1896. /* Intel 946 based systems */
  1897. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
  1898. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
  1899. /* 965 based 3 stack systems */
  1900. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
  1901. "Intel D965", STAC_D965_3ST),
  1902. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
  1903. "Intel D965", STAC_D965_3ST),
  1904. /* Dell 3 stack systems */
  1905. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
  1906. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
  1907. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
  1908. /* Dell 3 stack systems with verb table in BIOS */
  1909. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
  1910. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
  1911. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
  1912. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS),
  1913. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
  1914. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
  1915. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
  1916. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
  1917. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS),
  1918. /* 965 based 5 stack systems */
  1919. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
  1920. "Intel D965", STAC_D965_5ST),
  1921. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
  1922. "Intel D965", STAC_D965_5ST),
  1923. /* volume-knob fixes */
  1924. SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
  1925. {} /* terminator */
  1926. };
  1927. static const unsigned int ref9205_pin_configs[12] = {
  1928. 0x40000100, 0x40000100, 0x01016011, 0x01014010,
  1929. 0x01813122, 0x01a19021, 0x01019020, 0x40000100,
  1930. 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
  1931. };
  1932. /*
  1933. STAC 9205 pin configs for
  1934. 102801F1
  1935. 102801F2
  1936. 102801FC
  1937. 102801FD
  1938. 10280204
  1939. 1028021F
  1940. 10280228 (Dell Vostro 1500)
  1941. 10280229 (Dell Vostro 1700)
  1942. */
  1943. static const unsigned int dell_9205_m42_pin_configs[12] = {
  1944. 0x0321101F, 0x03A11020, 0x400003FA, 0x90170310,
  1945. 0x400003FB, 0x400003FC, 0x400003FD, 0x40F000F9,
  1946. 0x90A60330, 0x400003FF, 0x0144131F, 0x40C003FE,
  1947. };
  1948. /*
  1949. STAC 9205 pin configs for
  1950. 102801F9
  1951. 102801FA
  1952. 102801FE
  1953. 102801FF (Dell Precision M4300)
  1954. 10280206
  1955. 10280200
  1956. 10280201
  1957. */
  1958. static const unsigned int dell_9205_m43_pin_configs[12] = {
  1959. 0x0321101f, 0x03a11020, 0x90a70330, 0x90170310,
  1960. 0x400000fe, 0x400000ff, 0x400000fd, 0x40f000f9,
  1961. 0x400000fa, 0x400000fc, 0x0144131f, 0x40c003f8,
  1962. };
  1963. static const unsigned int dell_9205_m44_pin_configs[12] = {
  1964. 0x0421101f, 0x04a11020, 0x400003fa, 0x90170310,
  1965. 0x400003fb, 0x400003fc, 0x400003fd, 0x400003f9,
  1966. 0x90a60330, 0x400003ff, 0x01441340, 0x40c003fe,
  1967. };
  1968. static const unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
  1969. [STAC_9205_REF] = ref9205_pin_configs,
  1970. [STAC_9205_DELL_M42] = dell_9205_m42_pin_configs,
  1971. [STAC_9205_DELL_M43] = dell_9205_m43_pin_configs,
  1972. [STAC_9205_DELL_M44] = dell_9205_m44_pin_configs,
  1973. [STAC_9205_EAPD] = NULL,
  1974. };
  1975. static const char * const stac9205_models[STAC_9205_MODELS] = {
  1976. [STAC_9205_AUTO] = "auto",
  1977. [STAC_9205_REF] = "ref",
  1978. [STAC_9205_DELL_M42] = "dell-m42",
  1979. [STAC_9205_DELL_M43] = "dell-m43",
  1980. [STAC_9205_DELL_M44] = "dell-m44",
  1981. [STAC_9205_EAPD] = "eapd",
  1982. };
  1983. static const struct snd_pci_quirk stac9205_cfg_tbl[] = {
  1984. /* SigmaTel reference board */
  1985. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1986. "DFI LanParty", STAC_9205_REF),
  1987. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
  1988. "SigmaTel", STAC_9205_REF),
  1989. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1990. "DFI LanParty", STAC_9205_REF),
  1991. /* Dell */
  1992. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
  1993. "unknown Dell", STAC_9205_DELL_M42),
  1994. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
  1995. "unknown Dell", STAC_9205_DELL_M42),
  1996. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
  1997. "Dell Precision", STAC_9205_DELL_M43),
  1998. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
  1999. "Dell Precision", STAC_9205_DELL_M43),
  2000. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
  2001. "Dell Precision", STAC_9205_DELL_M43),
  2002. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
  2003. "unknown Dell", STAC_9205_DELL_M42),
  2004. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
  2005. "unknown Dell", STAC_9205_DELL_M42),
  2006. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
  2007. "Dell Precision", STAC_9205_DELL_M43),
  2008. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
  2009. "Dell Precision M4300", STAC_9205_DELL_M43),
  2010. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
  2011. "unknown Dell", STAC_9205_DELL_M42),
  2012. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
  2013. "Dell Precision", STAC_9205_DELL_M43),
  2014. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
  2015. "Dell Precision", STAC_9205_DELL_M43),
  2016. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
  2017. "Dell Precision", STAC_9205_DELL_M43),
  2018. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
  2019. "Dell Inspiron", STAC_9205_DELL_M44),
  2020. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
  2021. "Dell Vostro 1500", STAC_9205_DELL_M42),
  2022. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
  2023. "Dell Vostro 1700", STAC_9205_DELL_M42),
  2024. /* Gateway */
  2025. SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
  2026. SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
  2027. {} /* terminator */
  2028. };
  2029. static void stac92xx_set_config_regs(struct hda_codec *codec,
  2030. const unsigned int *pincfgs)
  2031. {
  2032. int i;
  2033. struct sigmatel_spec *spec = codec->spec;
  2034. if (!pincfgs)
  2035. return;
  2036. for (i = 0; i < spec->num_pins; i++)
  2037. if (spec->pin_nids[i] && pincfgs[i])
  2038. snd_hda_codec_set_pincfg(codec, spec->pin_nids[i],
  2039. pincfgs[i]);
  2040. }
  2041. /*
  2042. * Analog playback callbacks
  2043. */
  2044. static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
  2045. struct hda_codec *codec,
  2046. struct snd_pcm_substream *substream)
  2047. {
  2048. struct sigmatel_spec *spec = codec->spec;
  2049. if (spec->stream_delay)
  2050. msleep(spec->stream_delay);
  2051. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
  2052. hinfo);
  2053. }
  2054. static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  2055. struct hda_codec *codec,
  2056. unsigned int stream_tag,
  2057. unsigned int format,
  2058. struct snd_pcm_substream *substream)
  2059. {
  2060. struct sigmatel_spec *spec = codec->spec;
  2061. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
  2062. }
  2063. static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2064. struct hda_codec *codec,
  2065. struct snd_pcm_substream *substream)
  2066. {
  2067. struct sigmatel_spec *spec = codec->spec;
  2068. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  2069. }
  2070. /*
  2071. * Digital playback callbacks
  2072. */
  2073. static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  2074. struct hda_codec *codec,
  2075. struct snd_pcm_substream *substream)
  2076. {
  2077. struct sigmatel_spec *spec = codec->spec;
  2078. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  2079. }
  2080. static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  2081. struct hda_codec *codec,
  2082. struct snd_pcm_substream *substream)
  2083. {
  2084. struct sigmatel_spec *spec = codec->spec;
  2085. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  2086. }
  2087. static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  2088. struct hda_codec *codec,
  2089. unsigned int stream_tag,
  2090. unsigned int format,
  2091. struct snd_pcm_substream *substream)
  2092. {
  2093. struct sigmatel_spec *spec = codec->spec;
  2094. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  2095. stream_tag, format, substream);
  2096. }
  2097. static int stac92xx_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2098. struct hda_codec *codec,
  2099. struct snd_pcm_substream *substream)
  2100. {
  2101. struct sigmatel_spec *spec = codec->spec;
  2102. return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
  2103. }
  2104. /*
  2105. * Analog capture callbacks
  2106. */
  2107. static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  2108. struct hda_codec *codec,
  2109. unsigned int stream_tag,
  2110. unsigned int format,
  2111. struct snd_pcm_substream *substream)
  2112. {
  2113. struct sigmatel_spec *spec = codec->spec;
  2114. hda_nid_t nid = spec->adc_nids[substream->number];
  2115. if (spec->powerdown_adcs) {
  2116. msleep(40);
  2117. snd_hda_codec_write(codec, nid, 0,
  2118. AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
  2119. }
  2120. snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
  2121. return 0;
  2122. }
  2123. static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2124. struct hda_codec *codec,
  2125. struct snd_pcm_substream *substream)
  2126. {
  2127. struct sigmatel_spec *spec = codec->spec;
  2128. hda_nid_t nid = spec->adc_nids[substream->number];
  2129. snd_hda_codec_cleanup_stream(codec, nid);
  2130. if (spec->powerdown_adcs)
  2131. snd_hda_codec_write(codec, nid, 0,
  2132. AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
  2133. return 0;
  2134. }
  2135. static const struct hda_pcm_stream stac92xx_pcm_digital_playback = {
  2136. .substreams = 1,
  2137. .channels_min = 2,
  2138. .channels_max = 2,
  2139. /* NID is set in stac92xx_build_pcms */
  2140. .ops = {
  2141. .open = stac92xx_dig_playback_pcm_open,
  2142. .close = stac92xx_dig_playback_pcm_close,
  2143. .prepare = stac92xx_dig_playback_pcm_prepare,
  2144. .cleanup = stac92xx_dig_playback_pcm_cleanup
  2145. },
  2146. };
  2147. static const struct hda_pcm_stream stac92xx_pcm_digital_capture = {
  2148. .substreams = 1,
  2149. .channels_min = 2,
  2150. .channels_max = 2,
  2151. /* NID is set in stac92xx_build_pcms */
  2152. };
  2153. static const struct hda_pcm_stream stac92xx_pcm_analog_playback = {
  2154. .substreams = 1,
  2155. .channels_min = 2,
  2156. .channels_max = 8,
  2157. .nid = 0x02, /* NID to query formats and rates */
  2158. .ops = {
  2159. .open = stac92xx_playback_pcm_open,
  2160. .prepare = stac92xx_playback_pcm_prepare,
  2161. .cleanup = stac92xx_playback_pcm_cleanup
  2162. },
  2163. };
  2164. static const struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
  2165. .substreams = 1,
  2166. .channels_min = 2,
  2167. .channels_max = 2,
  2168. .nid = 0x06, /* NID to query formats and rates */
  2169. .ops = {
  2170. .open = stac92xx_playback_pcm_open,
  2171. .prepare = stac92xx_playback_pcm_prepare,
  2172. .cleanup = stac92xx_playback_pcm_cleanup
  2173. },
  2174. };
  2175. static const struct hda_pcm_stream stac92xx_pcm_analog_capture = {
  2176. .channels_min = 2,
  2177. .channels_max = 2,
  2178. /* NID + .substreams is set in stac92xx_build_pcms */
  2179. .ops = {
  2180. .prepare = stac92xx_capture_pcm_prepare,
  2181. .cleanup = stac92xx_capture_pcm_cleanup
  2182. },
  2183. };
  2184. static int stac92xx_build_pcms(struct hda_codec *codec)
  2185. {
  2186. struct sigmatel_spec *spec = codec->spec;
  2187. struct hda_pcm *info = spec->pcm_rec;
  2188. codec->num_pcms = 1;
  2189. codec->pcm_info = info;
  2190. info->name = "STAC92xx Analog";
  2191. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
  2192. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
  2193. spec->multiout.dac_nids[0];
  2194. info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
  2195. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  2196. info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adcs;
  2197. if (spec->alt_switch) {
  2198. codec->num_pcms++;
  2199. info++;
  2200. info->name = "STAC92xx Analog Alt";
  2201. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
  2202. }
  2203. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  2204. codec->num_pcms++;
  2205. info++;
  2206. info->name = "STAC92xx Digital";
  2207. info->pcm_type = spec->autocfg.dig_out_type[0];
  2208. if (spec->multiout.dig_out_nid) {
  2209. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
  2210. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  2211. }
  2212. if (spec->dig_in_nid) {
  2213. info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
  2214. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  2215. }
  2216. }
  2217. return 0;
  2218. }
  2219. static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
  2220. {
  2221. snd_hda_set_pin_ctl_cache(codec, nid, pin_type);
  2222. }
  2223. #define stac92xx_hp_switch_info snd_ctl_boolean_mono_info
  2224. static int stac92xx_hp_switch_get(struct snd_kcontrol *kcontrol,
  2225. struct snd_ctl_elem_value *ucontrol)
  2226. {
  2227. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2228. struct sigmatel_spec *spec = codec->spec;
  2229. ucontrol->value.integer.value[0] = !!spec->hp_switch;
  2230. return 0;
  2231. }
  2232. static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid);
  2233. static int stac92xx_hp_switch_put(struct snd_kcontrol *kcontrol,
  2234. struct snd_ctl_elem_value *ucontrol)
  2235. {
  2236. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2237. struct sigmatel_spec *spec = codec->spec;
  2238. int nid = kcontrol->private_value;
  2239. spec->hp_switch = ucontrol->value.integer.value[0] ? nid : 0;
  2240. /* check to be sure that the ports are up to date with
  2241. * switch changes
  2242. */
  2243. stac_issue_unsol_event(codec, nid);
  2244. return 1;
  2245. }
  2246. static int stac92xx_dc_bias_info(struct snd_kcontrol *kcontrol,
  2247. struct snd_ctl_elem_info *uinfo)
  2248. {
  2249. int i;
  2250. static const char * const texts[] = {
  2251. "Mic In", "Line In", "Line Out"
  2252. };
  2253. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2254. struct sigmatel_spec *spec = codec->spec;
  2255. hda_nid_t nid = kcontrol->private_value;
  2256. if (nid == spec->mic_switch || nid == spec->line_switch)
  2257. i = 3;
  2258. else
  2259. i = 2;
  2260. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2261. uinfo->value.enumerated.items = i;
  2262. uinfo->count = 1;
  2263. if (uinfo->value.enumerated.item >= i)
  2264. uinfo->value.enumerated.item = i-1;
  2265. strcpy(uinfo->value.enumerated.name,
  2266. texts[uinfo->value.enumerated.item]);
  2267. return 0;
  2268. }
  2269. static int stac92xx_dc_bias_get(struct snd_kcontrol *kcontrol,
  2270. struct snd_ctl_elem_value *ucontrol)
  2271. {
  2272. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2273. hda_nid_t nid = kcontrol->private_value;
  2274. unsigned int vref = stac92xx_vref_get(codec, nid);
  2275. if (vref == snd_hda_get_default_vref(codec, nid))
  2276. ucontrol->value.enumerated.item[0] = 0;
  2277. else if (vref == AC_PINCTL_VREF_GRD)
  2278. ucontrol->value.enumerated.item[0] = 1;
  2279. else if (vref == AC_PINCTL_VREF_HIZ)
  2280. ucontrol->value.enumerated.item[0] = 2;
  2281. return 0;
  2282. }
  2283. static int stac92xx_dc_bias_put(struct snd_kcontrol *kcontrol,
  2284. struct snd_ctl_elem_value *ucontrol)
  2285. {
  2286. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2287. unsigned int new_vref = 0;
  2288. int error;
  2289. hda_nid_t nid = kcontrol->private_value;
  2290. if (ucontrol->value.enumerated.item[0] == 0)
  2291. new_vref = snd_hda_get_default_vref(codec, nid);
  2292. else if (ucontrol->value.enumerated.item[0] == 1)
  2293. new_vref = AC_PINCTL_VREF_GRD;
  2294. else if (ucontrol->value.enumerated.item[0] == 2)
  2295. new_vref = AC_PINCTL_VREF_HIZ;
  2296. else
  2297. return 0;
  2298. if (new_vref != stac92xx_vref_get(codec, nid)) {
  2299. error = stac92xx_vref_set(codec, nid, new_vref);
  2300. return error;
  2301. }
  2302. return 0;
  2303. }
  2304. static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol,
  2305. struct snd_ctl_elem_info *uinfo)
  2306. {
  2307. char *texts[2];
  2308. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2309. struct sigmatel_spec *spec = codec->spec;
  2310. if (kcontrol->private_value == spec->line_switch)
  2311. texts[0] = "Line In";
  2312. else
  2313. texts[0] = "Mic In";
  2314. texts[1] = "Line Out";
  2315. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2316. uinfo->value.enumerated.items = 2;
  2317. uinfo->count = 1;
  2318. if (uinfo->value.enumerated.item >= 2)
  2319. uinfo->value.enumerated.item = 1;
  2320. strcpy(uinfo->value.enumerated.name,
  2321. texts[uinfo->value.enumerated.item]);
  2322. return 0;
  2323. }
  2324. static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  2325. {
  2326. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2327. struct sigmatel_spec *spec = codec->spec;
  2328. hda_nid_t nid = kcontrol->private_value;
  2329. int io_idx = (nid == spec->mic_switch) ? 1 : 0;
  2330. ucontrol->value.enumerated.item[0] = spec->io_switch[io_idx];
  2331. return 0;
  2332. }
  2333. static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  2334. {
  2335. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2336. struct sigmatel_spec *spec = codec->spec;
  2337. hda_nid_t nid = kcontrol->private_value;
  2338. int io_idx = (nid == spec->mic_switch) ? 1 : 0;
  2339. unsigned short val = !!ucontrol->value.enumerated.item[0];
  2340. spec->io_switch[io_idx] = val;
  2341. if (val)
  2342. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  2343. else {
  2344. unsigned int pinctl = AC_PINCTL_IN_EN;
  2345. if (io_idx) /* set VREF for mic */
  2346. pinctl |= snd_hda_get_default_vref(codec, nid);
  2347. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  2348. }
  2349. /* check the auto-mute again: we need to mute/unmute the speaker
  2350. * appropriately according to the pin direction
  2351. */
  2352. if (spec->hp_detect)
  2353. stac_issue_unsol_event(codec, nid);
  2354. return 1;
  2355. }
  2356. #define stac92xx_clfe_switch_info snd_ctl_boolean_mono_info
  2357. static int stac92xx_clfe_switch_get(struct snd_kcontrol *kcontrol,
  2358. struct snd_ctl_elem_value *ucontrol)
  2359. {
  2360. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2361. struct sigmatel_spec *spec = codec->spec;
  2362. ucontrol->value.integer.value[0] = spec->clfe_swap;
  2363. return 0;
  2364. }
  2365. static int stac92xx_clfe_switch_put(struct snd_kcontrol *kcontrol,
  2366. struct snd_ctl_elem_value *ucontrol)
  2367. {
  2368. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2369. struct sigmatel_spec *spec = codec->spec;
  2370. hda_nid_t nid = kcontrol->private_value & 0xff;
  2371. unsigned int val = !!ucontrol->value.integer.value[0];
  2372. if (spec->clfe_swap == val)
  2373. return 0;
  2374. spec->clfe_swap = val;
  2375. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
  2376. spec->clfe_swap ? 0x4 : 0x0);
  2377. return 1;
  2378. }
  2379. #define STAC_CODEC_HP_SWITCH(xname) \
  2380. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2381. .name = xname, \
  2382. .index = 0, \
  2383. .info = stac92xx_hp_switch_info, \
  2384. .get = stac92xx_hp_switch_get, \
  2385. .put = stac92xx_hp_switch_put, \
  2386. }
  2387. #define STAC_CODEC_IO_SWITCH(xname, xpval) \
  2388. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2389. .name = xname, \
  2390. .index = 0, \
  2391. .info = stac92xx_io_switch_info, \
  2392. .get = stac92xx_io_switch_get, \
  2393. .put = stac92xx_io_switch_put, \
  2394. .private_value = xpval, \
  2395. }
  2396. #define STAC_CODEC_CLFE_SWITCH(xname, xpval) \
  2397. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2398. .name = xname, \
  2399. .index = 0, \
  2400. .info = stac92xx_clfe_switch_info, \
  2401. .get = stac92xx_clfe_switch_get, \
  2402. .put = stac92xx_clfe_switch_put, \
  2403. .private_value = xpval, \
  2404. }
  2405. enum {
  2406. STAC_CTL_WIDGET_VOL,
  2407. STAC_CTL_WIDGET_MUTE,
  2408. STAC_CTL_WIDGET_MUTE_BEEP,
  2409. STAC_CTL_WIDGET_MONO_MUX,
  2410. STAC_CTL_WIDGET_HP_SWITCH,
  2411. STAC_CTL_WIDGET_IO_SWITCH,
  2412. STAC_CTL_WIDGET_CLFE_SWITCH,
  2413. STAC_CTL_WIDGET_DC_BIAS
  2414. };
  2415. static const struct snd_kcontrol_new stac92xx_control_templates[] = {
  2416. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2417. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2418. HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0),
  2419. STAC_MONO_MUX,
  2420. STAC_CODEC_HP_SWITCH(NULL),
  2421. STAC_CODEC_IO_SWITCH(NULL, 0),
  2422. STAC_CODEC_CLFE_SWITCH(NULL, 0),
  2423. DC_BIAS(NULL, 0, 0),
  2424. };
  2425. /* add dynamic controls */
  2426. static struct snd_kcontrol_new *
  2427. stac_control_new(struct sigmatel_spec *spec,
  2428. const struct snd_kcontrol_new *ktemp,
  2429. const char *name,
  2430. unsigned int subdev)
  2431. {
  2432. struct snd_kcontrol_new *knew;
  2433. snd_array_init(&spec->kctls, sizeof(*knew), 32);
  2434. knew = snd_array_new(&spec->kctls);
  2435. if (!knew)
  2436. return NULL;
  2437. *knew = *ktemp;
  2438. knew->name = kstrdup(name, GFP_KERNEL);
  2439. if (!knew->name) {
  2440. /* roolback */
  2441. memset(knew, 0, sizeof(*knew));
  2442. spec->kctls.alloced--;
  2443. return NULL;
  2444. }
  2445. knew->subdevice = subdev;
  2446. return knew;
  2447. }
  2448. static int stac92xx_add_control_temp(struct sigmatel_spec *spec,
  2449. const struct snd_kcontrol_new *ktemp,
  2450. int idx, const char *name,
  2451. unsigned long val)
  2452. {
  2453. struct snd_kcontrol_new *knew = stac_control_new(spec, ktemp, name,
  2454. HDA_SUBDEV_AMP_FLAG);
  2455. if (!knew)
  2456. return -ENOMEM;
  2457. knew->index = idx;
  2458. knew->private_value = val;
  2459. return 0;
  2460. }
  2461. static inline int stac92xx_add_control_idx(struct sigmatel_spec *spec,
  2462. int type, int idx, const char *name,
  2463. unsigned long val)
  2464. {
  2465. return stac92xx_add_control_temp(spec,
  2466. &stac92xx_control_templates[type],
  2467. idx, name, val);
  2468. }
  2469. /* add dynamic controls */
  2470. static inline int stac92xx_add_control(struct sigmatel_spec *spec, int type,
  2471. const char *name, unsigned long val)
  2472. {
  2473. return stac92xx_add_control_idx(spec, type, 0, name, val);
  2474. }
  2475. static const struct snd_kcontrol_new stac_input_src_temp = {
  2476. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2477. .name = "Input Source",
  2478. .info = stac92xx_mux_enum_info,
  2479. .get = stac92xx_mux_enum_get,
  2480. .put = stac92xx_mux_enum_put,
  2481. };
  2482. static inline int stac92xx_add_jack_mode_control(struct hda_codec *codec,
  2483. hda_nid_t nid, int idx)
  2484. {
  2485. int def_conf = snd_hda_codec_get_pincfg(codec, nid);
  2486. int control = 0;
  2487. struct sigmatel_spec *spec = codec->spec;
  2488. char name[22];
  2489. if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
  2490. if (snd_hda_get_default_vref(codec, nid) == AC_PINCTL_VREF_GRD
  2491. && nid == spec->line_switch)
  2492. control = STAC_CTL_WIDGET_IO_SWITCH;
  2493. else if (snd_hda_query_pin_caps(codec, nid)
  2494. & (AC_PINCAP_VREF_GRD << AC_PINCAP_VREF_SHIFT))
  2495. control = STAC_CTL_WIDGET_DC_BIAS;
  2496. else if (nid == spec->mic_switch)
  2497. control = STAC_CTL_WIDGET_IO_SWITCH;
  2498. }
  2499. if (control) {
  2500. snd_hda_get_pin_label(codec, nid, &spec->autocfg,
  2501. name, sizeof(name), NULL);
  2502. return stac92xx_add_control(codec->spec, control,
  2503. strcat(name, " Jack Mode"), nid);
  2504. }
  2505. return 0;
  2506. }
  2507. static int stac92xx_add_input_source(struct sigmatel_spec *spec)
  2508. {
  2509. struct snd_kcontrol_new *knew;
  2510. struct hda_input_mux *imux = &spec->private_imux;
  2511. if (spec->auto_mic)
  2512. return 0; /* no need for input source */
  2513. if (!spec->num_adcs || imux->num_items <= 1)
  2514. return 0; /* no need for input source control */
  2515. knew = stac_control_new(spec, &stac_input_src_temp,
  2516. stac_input_src_temp.name, 0);
  2517. if (!knew)
  2518. return -ENOMEM;
  2519. knew->count = spec->num_adcs;
  2520. return 0;
  2521. }
  2522. /* check whether the line-input can be used as line-out */
  2523. static hda_nid_t check_line_out_switch(struct hda_codec *codec)
  2524. {
  2525. struct sigmatel_spec *spec = codec->spec;
  2526. struct auto_pin_cfg *cfg = &spec->autocfg;
  2527. hda_nid_t nid;
  2528. unsigned int pincap;
  2529. int i;
  2530. if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
  2531. return 0;
  2532. for (i = 0; i < cfg->num_inputs; i++) {
  2533. if (cfg->inputs[i].type == AUTO_PIN_LINE_IN) {
  2534. nid = cfg->inputs[i].pin;
  2535. pincap = snd_hda_query_pin_caps(codec, nid);
  2536. if (pincap & AC_PINCAP_OUT)
  2537. return nid;
  2538. }
  2539. }
  2540. return 0;
  2541. }
  2542. static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid);
  2543. /* check whether the mic-input can be used as line-out */
  2544. static hda_nid_t check_mic_out_switch(struct hda_codec *codec, hda_nid_t *dac)
  2545. {
  2546. struct sigmatel_spec *spec = codec->spec;
  2547. struct auto_pin_cfg *cfg = &spec->autocfg;
  2548. unsigned int def_conf, pincap;
  2549. int i;
  2550. *dac = 0;
  2551. if (cfg->line_out_type != AUTO_PIN_LINE_OUT)
  2552. return 0;
  2553. for (i = 0; i < cfg->num_inputs; i++) {
  2554. hda_nid_t nid = cfg->inputs[i].pin;
  2555. if (cfg->inputs[i].type != AUTO_PIN_MIC)
  2556. continue;
  2557. def_conf = snd_hda_codec_get_pincfg(codec, nid);
  2558. /* some laptops have an internal analog microphone
  2559. * which can't be used as a output */
  2560. if (snd_hda_get_input_pin_attr(def_conf) != INPUT_PIN_ATTR_INT) {
  2561. pincap = snd_hda_query_pin_caps(codec, nid);
  2562. if (pincap & AC_PINCAP_OUT) {
  2563. *dac = get_unassigned_dac(codec, nid);
  2564. if (*dac)
  2565. return nid;
  2566. }
  2567. }
  2568. }
  2569. return 0;
  2570. }
  2571. static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
  2572. {
  2573. int i;
  2574. for (i = 0; i < spec->multiout.num_dacs; i++) {
  2575. if (spec->multiout.dac_nids[i] == nid)
  2576. return 1;
  2577. }
  2578. return 0;
  2579. }
  2580. static int check_all_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
  2581. {
  2582. int i;
  2583. if (is_in_dac_nids(spec, nid))
  2584. return 1;
  2585. for (i = 0; i < spec->autocfg.hp_outs; i++)
  2586. if (spec->hp_dacs[i] == nid)
  2587. return 1;
  2588. for (i = 0; i < spec->autocfg.speaker_outs; i++)
  2589. if (spec->speaker_dacs[i] == nid)
  2590. return 1;
  2591. return 0;
  2592. }
  2593. static hda_nid_t get_unassigned_dac(struct hda_codec *codec, hda_nid_t nid)
  2594. {
  2595. struct sigmatel_spec *spec = codec->spec;
  2596. struct auto_pin_cfg *cfg = &spec->autocfg;
  2597. int j, conn_len;
  2598. hda_nid_t conn[HDA_MAX_CONNECTIONS], fallback_dac;
  2599. unsigned int wcaps, wtype;
  2600. conn_len = snd_hda_get_connections(codec, nid, conn,
  2601. HDA_MAX_CONNECTIONS);
  2602. /* 92HD88: trace back up the link of nids to find the DAC */
  2603. while (conn_len == 1 && (get_wcaps_type(get_wcaps(codec, conn[0]))
  2604. != AC_WID_AUD_OUT)) {
  2605. nid = conn[0];
  2606. conn_len = snd_hda_get_connections(codec, nid, conn,
  2607. HDA_MAX_CONNECTIONS);
  2608. }
  2609. for (j = 0; j < conn_len; j++) {
  2610. wcaps = get_wcaps(codec, conn[j]);
  2611. wtype = get_wcaps_type(wcaps);
  2612. /* we check only analog outputs */
  2613. if (wtype != AC_WID_AUD_OUT || (wcaps & AC_WCAP_DIGITAL))
  2614. continue;
  2615. /* if this route has a free DAC, assign it */
  2616. if (!check_all_dac_nids(spec, conn[j])) {
  2617. if (conn_len > 1) {
  2618. /* select this DAC in the pin's input mux */
  2619. snd_hda_codec_write_cache(codec, nid, 0,
  2620. AC_VERB_SET_CONNECT_SEL, j);
  2621. }
  2622. return conn[j];
  2623. }
  2624. }
  2625. /* if all DACs are already assigned, connect to the primary DAC,
  2626. unless we're assigning a secondary headphone */
  2627. fallback_dac = spec->multiout.dac_nids[0];
  2628. if (spec->multiout.hp_nid) {
  2629. for (j = 0; j < cfg->hp_outs; j++)
  2630. if (cfg->hp_pins[j] == nid) {
  2631. fallback_dac = spec->multiout.hp_nid;
  2632. break;
  2633. }
  2634. }
  2635. if (conn_len > 1) {
  2636. for (j = 0; j < conn_len; j++) {
  2637. if (conn[j] == fallback_dac) {
  2638. snd_hda_codec_write_cache(codec, nid, 0,
  2639. AC_VERB_SET_CONNECT_SEL, j);
  2640. break;
  2641. }
  2642. }
  2643. }
  2644. return 0;
  2645. }
  2646. static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
  2647. static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid);
  2648. /*
  2649. * Fill in the dac_nids table from the parsed pin configuration
  2650. * This function only works when every pin in line_out_pins[]
  2651. * contains atleast one DAC in its connection list. Some 92xx
  2652. * codecs are not connected directly to a DAC, such as the 9200
  2653. * and 9202/925x. For those, dac_nids[] must be hard-coded.
  2654. */
  2655. static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec)
  2656. {
  2657. struct sigmatel_spec *spec = codec->spec;
  2658. struct auto_pin_cfg *cfg = &spec->autocfg;
  2659. int i;
  2660. hda_nid_t nid, dac;
  2661. for (i = 0; i < cfg->line_outs; i++) {
  2662. nid = cfg->line_out_pins[i];
  2663. dac = get_unassigned_dac(codec, nid);
  2664. if (!dac) {
  2665. if (spec->multiout.num_dacs > 0) {
  2666. /* we have already working output pins,
  2667. * so let's drop the broken ones again
  2668. */
  2669. cfg->line_outs = spec->multiout.num_dacs;
  2670. break;
  2671. }
  2672. /* error out, no available DAC found */
  2673. snd_printk(KERN_ERR
  2674. "%s: No available DAC for pin 0x%x\n",
  2675. __func__, nid);
  2676. return -ENODEV;
  2677. }
  2678. add_spec_dacs(spec, dac);
  2679. }
  2680. for (i = 0; i < cfg->hp_outs; i++) {
  2681. nid = cfg->hp_pins[i];
  2682. dac = get_unassigned_dac(codec, nid);
  2683. if (dac) {
  2684. if (!spec->multiout.hp_nid)
  2685. spec->multiout.hp_nid = dac;
  2686. else
  2687. add_spec_extra_dacs(spec, dac);
  2688. }
  2689. spec->hp_dacs[i] = dac;
  2690. }
  2691. for (i = 0; i < cfg->speaker_outs; i++) {
  2692. nid = cfg->speaker_pins[i];
  2693. dac = get_unassigned_dac(codec, nid);
  2694. if (dac)
  2695. add_spec_extra_dacs(spec, dac);
  2696. spec->speaker_dacs[i] = dac;
  2697. }
  2698. /* add line-in as output */
  2699. nid = check_line_out_switch(codec);
  2700. if (nid) {
  2701. dac = get_unassigned_dac(codec, nid);
  2702. if (dac) {
  2703. snd_printdd("STAC: Add line-in 0x%x as output %d\n",
  2704. nid, cfg->line_outs);
  2705. cfg->line_out_pins[cfg->line_outs] = nid;
  2706. cfg->line_outs++;
  2707. spec->line_switch = nid;
  2708. add_spec_dacs(spec, dac);
  2709. }
  2710. }
  2711. /* add mic as output */
  2712. nid = check_mic_out_switch(codec, &dac);
  2713. if (nid && dac) {
  2714. snd_printdd("STAC: Add mic-in 0x%x as output %d\n",
  2715. nid, cfg->line_outs);
  2716. cfg->line_out_pins[cfg->line_outs] = nid;
  2717. cfg->line_outs++;
  2718. spec->mic_switch = nid;
  2719. add_spec_dacs(spec, dac);
  2720. }
  2721. snd_printd("stac92xx: dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
  2722. spec->multiout.num_dacs,
  2723. spec->multiout.dac_nids[0],
  2724. spec->multiout.dac_nids[1],
  2725. spec->multiout.dac_nids[2],
  2726. spec->multiout.dac_nids[3],
  2727. spec->multiout.dac_nids[4]);
  2728. return 0;
  2729. }
  2730. /* create volume control/switch for the given prefx type */
  2731. static int create_controls_idx(struct hda_codec *codec, const char *pfx,
  2732. int idx, hda_nid_t nid, int chs)
  2733. {
  2734. struct sigmatel_spec *spec = codec->spec;
  2735. char name[32];
  2736. int err;
  2737. if (!spec->check_volume_offset) {
  2738. unsigned int caps, step, nums, db_scale;
  2739. caps = query_amp_caps(codec, nid, HDA_OUTPUT);
  2740. step = (caps & AC_AMPCAP_STEP_SIZE) >>
  2741. AC_AMPCAP_STEP_SIZE_SHIFT;
  2742. step = (step + 1) * 25; /* in .01dB unit */
  2743. nums = (caps & AC_AMPCAP_NUM_STEPS) >>
  2744. AC_AMPCAP_NUM_STEPS_SHIFT;
  2745. db_scale = nums * step;
  2746. /* if dB scale is over -64dB, and finer enough,
  2747. * let's reduce it to half
  2748. */
  2749. if (db_scale > 6400 && nums >= 0x1f)
  2750. spec->volume_offset = nums / 2;
  2751. spec->check_volume_offset = 1;
  2752. }
  2753. sprintf(name, "%s Playback Volume", pfx);
  2754. err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, idx, name,
  2755. HDA_COMPOSE_AMP_VAL_OFS(nid, chs, 0, HDA_OUTPUT,
  2756. spec->volume_offset));
  2757. if (err < 0)
  2758. return err;
  2759. sprintf(name, "%s Playback Switch", pfx);
  2760. err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_MUTE, idx, name,
  2761. HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
  2762. if (err < 0)
  2763. return err;
  2764. return 0;
  2765. }
  2766. #define create_controls(codec, pfx, nid, chs) \
  2767. create_controls_idx(codec, pfx, 0, nid, chs)
  2768. static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
  2769. {
  2770. if (spec->multiout.num_dacs > 4) {
  2771. printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
  2772. return 1;
  2773. } else {
  2774. snd_BUG_ON(spec->multiout.dac_nids != spec->dac_nids);
  2775. spec->dac_nids[spec->multiout.num_dacs] = nid;
  2776. spec->multiout.num_dacs++;
  2777. }
  2778. return 0;
  2779. }
  2780. static int add_spec_extra_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
  2781. {
  2782. int i;
  2783. for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
  2784. if (!spec->multiout.extra_out_nid[i]) {
  2785. spec->multiout.extra_out_nid[i] = nid;
  2786. return 0;
  2787. }
  2788. }
  2789. printk(KERN_WARNING "stac92xx: No space for extra DAC 0x%x\n", nid);
  2790. return 1;
  2791. }
  2792. /* Create output controls
  2793. * The mixer elements are named depending on the given type (AUTO_PIN_XXX_OUT)
  2794. */
  2795. static int create_multi_out_ctls(struct hda_codec *codec, int num_outs,
  2796. const hda_nid_t *pins,
  2797. const hda_nid_t *dac_nids,
  2798. int type)
  2799. {
  2800. struct sigmatel_spec *spec = codec->spec;
  2801. static const char * const chname[4] = {
  2802. "Front", "Surround", NULL /*CLFE*/, "Side"
  2803. };
  2804. hda_nid_t nid;
  2805. int i, err;
  2806. unsigned int wid_caps;
  2807. for (i = 0; i < num_outs && i < ARRAY_SIZE(chname); i++) {
  2808. if (type == AUTO_PIN_HP_OUT && !spec->hp_detect) {
  2809. if (is_jack_detectable(codec, pins[i]))
  2810. spec->hp_detect = 1;
  2811. }
  2812. nid = dac_nids[i];
  2813. if (!nid)
  2814. continue;
  2815. if (type != AUTO_PIN_HP_OUT && i == 2) {
  2816. /* Center/LFE */
  2817. err = create_controls(codec, "Center", nid, 1);
  2818. if (err < 0)
  2819. return err;
  2820. err = create_controls(codec, "LFE", nid, 2);
  2821. if (err < 0)
  2822. return err;
  2823. wid_caps = get_wcaps(codec, nid);
  2824. if (wid_caps & AC_WCAP_LR_SWAP) {
  2825. err = stac92xx_add_control(spec,
  2826. STAC_CTL_WIDGET_CLFE_SWITCH,
  2827. "Swap Center/LFE Playback Switch", nid);
  2828. if (err < 0)
  2829. return err;
  2830. }
  2831. } else {
  2832. const char *name;
  2833. int idx;
  2834. switch (type) {
  2835. case AUTO_PIN_HP_OUT:
  2836. name = "Headphone";
  2837. idx = i;
  2838. break;
  2839. case AUTO_PIN_SPEAKER_OUT:
  2840. name = "Speaker";
  2841. idx = i;
  2842. break;
  2843. default:
  2844. name = chname[i];
  2845. idx = 0;
  2846. break;
  2847. }
  2848. err = create_controls_idx(codec, name, idx, nid, 3);
  2849. if (err < 0)
  2850. return err;
  2851. }
  2852. }
  2853. return 0;
  2854. }
  2855. static int stac92xx_add_capvol_ctls(struct hda_codec *codec, unsigned long vol,
  2856. unsigned long sw, int idx)
  2857. {
  2858. int err;
  2859. err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx,
  2860. "Capture Volume", vol);
  2861. if (err < 0)
  2862. return err;
  2863. err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_MUTE, idx,
  2864. "Capture Switch", sw);
  2865. if (err < 0)
  2866. return err;
  2867. return 0;
  2868. }
  2869. /* add playback controls from the parsed DAC table */
  2870. static int stac92xx_auto_create_multi_out_ctls(struct hda_codec *codec,
  2871. const struct auto_pin_cfg *cfg)
  2872. {
  2873. struct sigmatel_spec *spec = codec->spec;
  2874. hda_nid_t nid;
  2875. int err;
  2876. int idx;
  2877. err = create_multi_out_ctls(codec, cfg->line_outs, cfg->line_out_pins,
  2878. spec->multiout.dac_nids,
  2879. cfg->line_out_type);
  2880. if (err < 0)
  2881. return err;
  2882. if (cfg->hp_outs > 1 && cfg->line_out_type == AUTO_PIN_LINE_OUT) {
  2883. err = stac92xx_add_control(spec,
  2884. STAC_CTL_WIDGET_HP_SWITCH,
  2885. "Headphone as Line Out Switch",
  2886. cfg->hp_pins[cfg->hp_outs - 1]);
  2887. if (err < 0)
  2888. return err;
  2889. }
  2890. for (idx = 0; idx < cfg->num_inputs; idx++) {
  2891. if (cfg->inputs[idx].type > AUTO_PIN_LINE_IN)
  2892. break;
  2893. nid = cfg->inputs[idx].pin;
  2894. err = stac92xx_add_jack_mode_control(codec, nid, idx);
  2895. if (err < 0)
  2896. return err;
  2897. }
  2898. return 0;
  2899. }
  2900. /* add playback controls for Speaker and HP outputs */
  2901. static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
  2902. struct auto_pin_cfg *cfg)
  2903. {
  2904. struct sigmatel_spec *spec = codec->spec;
  2905. int err;
  2906. err = create_multi_out_ctls(codec, cfg->hp_outs, cfg->hp_pins,
  2907. spec->hp_dacs, AUTO_PIN_HP_OUT);
  2908. if (err < 0)
  2909. return err;
  2910. err = create_multi_out_ctls(codec, cfg->speaker_outs, cfg->speaker_pins,
  2911. spec->speaker_dacs, AUTO_PIN_SPEAKER_OUT);
  2912. if (err < 0)
  2913. return err;
  2914. return 0;
  2915. }
  2916. /* labels for mono mux outputs */
  2917. static const char * const stac92xx_mono_labels[4] = {
  2918. "DAC0", "DAC1", "Mixer", "DAC2"
  2919. };
  2920. /* create mono mux for mono out on capable codecs */
  2921. static int stac92xx_auto_create_mono_output_ctls(struct hda_codec *codec)
  2922. {
  2923. struct sigmatel_spec *spec = codec->spec;
  2924. struct hda_input_mux *mono_mux = &spec->private_mono_mux;
  2925. int i, num_cons;
  2926. hda_nid_t con_lst[ARRAY_SIZE(stac92xx_mono_labels)];
  2927. num_cons = snd_hda_get_connections(codec,
  2928. spec->mono_nid,
  2929. con_lst,
  2930. HDA_MAX_NUM_INPUTS);
  2931. if (num_cons <= 0 || num_cons > ARRAY_SIZE(stac92xx_mono_labels))
  2932. return -EINVAL;
  2933. for (i = 0; i < num_cons; i++)
  2934. snd_hda_add_imux_item(mono_mux, stac92xx_mono_labels[i], i,
  2935. NULL);
  2936. return stac92xx_add_control(spec, STAC_CTL_WIDGET_MONO_MUX,
  2937. "Mono Mux", spec->mono_nid);
  2938. }
  2939. /* create PC beep volume controls */
  2940. static int stac92xx_auto_create_beep_ctls(struct hda_codec *codec,
  2941. hda_nid_t nid)
  2942. {
  2943. struct sigmatel_spec *spec = codec->spec;
  2944. u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
  2945. int err, type = STAC_CTL_WIDGET_MUTE_BEEP;
  2946. if (spec->anabeep_nid == nid)
  2947. type = STAC_CTL_WIDGET_MUTE;
  2948. /* check for mute support for the the amp */
  2949. if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
  2950. err = stac92xx_add_control(spec, type,
  2951. "Beep Playback Switch",
  2952. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
  2953. if (err < 0)
  2954. return err;
  2955. }
  2956. /* check to see if there is volume support for the amp */
  2957. if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
  2958. err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
  2959. "Beep Playback Volume",
  2960. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT));
  2961. if (err < 0)
  2962. return err;
  2963. }
  2964. return 0;
  2965. }
  2966. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  2967. #define stac92xx_dig_beep_switch_info snd_ctl_boolean_mono_info
  2968. static int stac92xx_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
  2969. struct snd_ctl_elem_value *ucontrol)
  2970. {
  2971. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2972. ucontrol->value.integer.value[0] = codec->beep->enabled;
  2973. return 0;
  2974. }
  2975. static int stac92xx_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
  2976. struct snd_ctl_elem_value *ucontrol)
  2977. {
  2978. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2979. return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
  2980. }
  2981. static const struct snd_kcontrol_new stac92xx_dig_beep_ctrl = {
  2982. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2983. .info = stac92xx_dig_beep_switch_info,
  2984. .get = stac92xx_dig_beep_switch_get,
  2985. .put = stac92xx_dig_beep_switch_put,
  2986. };
  2987. static int stac92xx_beep_switch_ctl(struct hda_codec *codec)
  2988. {
  2989. return stac92xx_add_control_temp(codec->spec, &stac92xx_dig_beep_ctrl,
  2990. 0, "Beep Playback Switch", 0);
  2991. }
  2992. #endif
  2993. static int stac92xx_auto_create_mux_input_ctls(struct hda_codec *codec)
  2994. {
  2995. struct sigmatel_spec *spec = codec->spec;
  2996. int i, j, err = 0;
  2997. for (i = 0; i < spec->num_muxes; i++) {
  2998. hda_nid_t nid;
  2999. unsigned int wcaps;
  3000. unsigned long val;
  3001. nid = spec->mux_nids[i];
  3002. wcaps = get_wcaps(codec, nid);
  3003. if (!(wcaps & AC_WCAP_OUT_AMP))
  3004. continue;
  3005. /* check whether already the same control was created as
  3006. * normal Capture Volume.
  3007. */
  3008. val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3009. for (j = 0; j < spec->num_caps; j++) {
  3010. if (spec->capvols[j] == val)
  3011. break;
  3012. }
  3013. if (j < spec->num_caps)
  3014. continue;
  3015. err = stac92xx_add_control_idx(spec, STAC_CTL_WIDGET_VOL, i,
  3016. "Mux Capture Volume", val);
  3017. if (err < 0)
  3018. return err;
  3019. }
  3020. return 0;
  3021. };
  3022. static const char * const stac92xx_spdif_labels[3] = {
  3023. "Digital Playback", "Analog Mux 1", "Analog Mux 2",
  3024. };
  3025. static int stac92xx_auto_create_spdif_mux_ctls(struct hda_codec *codec)
  3026. {
  3027. struct sigmatel_spec *spec = codec->spec;
  3028. struct hda_input_mux *spdif_mux = &spec->private_smux;
  3029. const char * const *labels = spec->spdif_labels;
  3030. int i, num_cons;
  3031. hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
  3032. num_cons = snd_hda_get_connections(codec,
  3033. spec->smux_nids[0],
  3034. con_lst,
  3035. HDA_MAX_NUM_INPUTS);
  3036. if (num_cons <= 0)
  3037. return -EINVAL;
  3038. if (!labels)
  3039. labels = stac92xx_spdif_labels;
  3040. for (i = 0; i < num_cons; i++)
  3041. snd_hda_add_imux_item(spdif_mux, labels[i], i, NULL);
  3042. return 0;
  3043. }
  3044. /* labels for dmic mux inputs */
  3045. static const char * const stac92xx_dmic_labels[5] = {
  3046. "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
  3047. "Digital Mic 3", "Digital Mic 4"
  3048. };
  3049. static hda_nid_t get_connected_node(struct hda_codec *codec, hda_nid_t mux,
  3050. int idx)
  3051. {
  3052. hda_nid_t conn[HDA_MAX_NUM_INPUTS];
  3053. int nums;
  3054. nums = snd_hda_get_connections(codec, mux, conn, ARRAY_SIZE(conn));
  3055. if (idx >= 0 && idx < nums)
  3056. return conn[idx];
  3057. return 0;
  3058. }
  3059. /* look for NID recursively */
  3060. #define get_connection_index(codec, mux, nid) \
  3061. snd_hda_get_conn_index(codec, mux, nid, 1)
  3062. /* create a volume assigned to the given pin (only if supported) */
  3063. /* return 1 if the volume control is created */
  3064. static int create_elem_capture_vol(struct hda_codec *codec, hda_nid_t nid,
  3065. const char *label, int idx, int direction)
  3066. {
  3067. unsigned int caps, nums;
  3068. char name[32];
  3069. int err;
  3070. if (direction == HDA_OUTPUT)
  3071. caps = AC_WCAP_OUT_AMP;
  3072. else
  3073. caps = AC_WCAP_IN_AMP;
  3074. if (!(get_wcaps(codec, nid) & caps))
  3075. return 0;
  3076. caps = query_amp_caps(codec, nid, direction);
  3077. nums = (caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT;
  3078. if (!nums)
  3079. return 0;
  3080. snprintf(name, sizeof(name), "%s Capture Volume", label);
  3081. err = stac92xx_add_control_idx(codec->spec, STAC_CTL_WIDGET_VOL, idx, name,
  3082. HDA_COMPOSE_AMP_VAL(nid, 3, 0, direction));
  3083. if (err < 0)
  3084. return err;
  3085. return 1;
  3086. }
  3087. /* create playback/capture controls for input pins on dmic capable codecs */
  3088. static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
  3089. const struct auto_pin_cfg *cfg)
  3090. {
  3091. struct sigmatel_spec *spec = codec->spec;
  3092. struct hda_input_mux *imux = &spec->private_imux;
  3093. struct hda_input_mux *dimux = &spec->private_dimux;
  3094. int err, i;
  3095. unsigned int def_conf;
  3096. snd_hda_add_imux_item(dimux, stac92xx_dmic_labels[0], 0, NULL);
  3097. for (i = 0; i < spec->num_dmics; i++) {
  3098. hda_nid_t nid;
  3099. int index, type_idx;
  3100. char label[32];
  3101. nid = spec->dmic_nids[i];
  3102. if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
  3103. continue;
  3104. def_conf = snd_hda_codec_get_pincfg(codec, nid);
  3105. if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
  3106. continue;
  3107. index = get_connection_index(codec, spec->dmux_nids[0], nid);
  3108. if (index < 0)
  3109. continue;
  3110. snd_hda_get_pin_label(codec, nid, &spec->autocfg,
  3111. label, sizeof(label), NULL);
  3112. snd_hda_add_imux_item(dimux, label, index, &type_idx);
  3113. if (snd_hda_get_bool_hint(codec, "separate_dmux") != 1)
  3114. snd_hda_add_imux_item(imux, label, index, &type_idx);
  3115. err = create_elem_capture_vol(codec, nid, label, type_idx,
  3116. HDA_INPUT);
  3117. if (err < 0)
  3118. return err;
  3119. if (!err) {
  3120. err = create_elem_capture_vol(codec, nid, label,
  3121. type_idx, HDA_OUTPUT);
  3122. if (err < 0)
  3123. return err;
  3124. if (!err) {
  3125. nid = get_connected_node(codec,
  3126. spec->dmux_nids[0], index);
  3127. if (nid)
  3128. err = create_elem_capture_vol(codec,
  3129. nid, label,
  3130. type_idx, HDA_INPUT);
  3131. if (err < 0)
  3132. return err;
  3133. }
  3134. }
  3135. }
  3136. return 0;
  3137. }
  3138. static int check_mic_pin(struct hda_codec *codec, hda_nid_t nid,
  3139. hda_nid_t *fixed, hda_nid_t *ext, hda_nid_t *dock)
  3140. {
  3141. unsigned int cfg;
  3142. unsigned int type;
  3143. if (!nid)
  3144. return 0;
  3145. cfg = snd_hda_codec_get_pincfg(codec, nid);
  3146. type = get_defcfg_device(cfg);
  3147. switch (snd_hda_get_input_pin_attr(cfg)) {
  3148. case INPUT_PIN_ATTR_INT:
  3149. if (*fixed)
  3150. return 1; /* already occupied */
  3151. if (type != AC_JACK_MIC_IN)
  3152. return 1; /* invalid type */
  3153. *fixed = nid;
  3154. break;
  3155. case INPUT_PIN_ATTR_UNUSED:
  3156. break;
  3157. case INPUT_PIN_ATTR_DOCK:
  3158. if (*dock)
  3159. return 1; /* already occupied */
  3160. if (type != AC_JACK_MIC_IN && type != AC_JACK_LINE_IN)
  3161. return 1; /* invalid type */
  3162. *dock = nid;
  3163. break;
  3164. default:
  3165. if (*ext)
  3166. return 1; /* already occupied */
  3167. if (type != AC_JACK_MIC_IN)
  3168. return 1; /* invalid type */
  3169. *ext = nid;
  3170. break;
  3171. }
  3172. return 0;
  3173. }
  3174. static int set_mic_route(struct hda_codec *codec,
  3175. struct sigmatel_mic_route *mic,
  3176. hda_nid_t pin)
  3177. {
  3178. struct sigmatel_spec *spec = codec->spec;
  3179. struct auto_pin_cfg *cfg = &spec->autocfg;
  3180. int i;
  3181. mic->pin = pin;
  3182. if (pin == 0)
  3183. return 0;
  3184. for (i = 0; i < cfg->num_inputs; i++) {
  3185. if (pin == cfg->inputs[i].pin)
  3186. break;
  3187. }
  3188. if (i < cfg->num_inputs && cfg->inputs[i].type == AUTO_PIN_MIC) {
  3189. /* analog pin */
  3190. i = get_connection_index(codec, spec->mux_nids[0], pin);
  3191. if (i < 0)
  3192. return -1;
  3193. mic->mux_idx = i;
  3194. mic->dmux_idx = -1;
  3195. if (spec->dmux_nids)
  3196. mic->dmux_idx = get_connection_index(codec,
  3197. spec->dmux_nids[0],
  3198. spec->mux_nids[0]);
  3199. } else if (spec->dmux_nids) {
  3200. /* digital pin */
  3201. i = get_connection_index(codec, spec->dmux_nids[0], pin);
  3202. if (i < 0)
  3203. return -1;
  3204. mic->dmux_idx = i;
  3205. mic->mux_idx = -1;
  3206. if (spec->mux_nids)
  3207. mic->mux_idx = get_connection_index(codec,
  3208. spec->mux_nids[0],
  3209. spec->dmux_nids[0]);
  3210. }
  3211. return 0;
  3212. }
  3213. /* return non-zero if the device is for automatic mic switch */
  3214. static int stac_check_auto_mic(struct hda_codec *codec)
  3215. {
  3216. struct sigmatel_spec *spec = codec->spec;
  3217. struct auto_pin_cfg *cfg = &spec->autocfg;
  3218. hda_nid_t fixed, ext, dock;
  3219. int i;
  3220. fixed = ext = dock = 0;
  3221. for (i = 0; i < cfg->num_inputs; i++)
  3222. if (check_mic_pin(codec, cfg->inputs[i].pin,
  3223. &fixed, &ext, &dock))
  3224. return 0;
  3225. for (i = 0; i < spec->num_dmics; i++)
  3226. if (check_mic_pin(codec, spec->dmic_nids[i],
  3227. &fixed, &ext, &dock))
  3228. return 0;
  3229. if (!fixed || (!ext && !dock))
  3230. return 0; /* no input to switch */
  3231. if (!is_jack_detectable(codec, ext))
  3232. return 0; /* no unsol support */
  3233. if (set_mic_route(codec, &spec->ext_mic, ext) ||
  3234. set_mic_route(codec, &spec->int_mic, fixed) ||
  3235. set_mic_route(codec, &spec->dock_mic, dock))
  3236. return 0; /* something is wrong */
  3237. return 1;
  3238. }
  3239. /* create playback/capture controls for input pins */
  3240. static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
  3241. {
  3242. struct sigmatel_spec *spec = codec->spec;
  3243. struct hda_input_mux *imux = &spec->private_imux;
  3244. int i, j;
  3245. const char *label;
  3246. for (i = 0; i < cfg->num_inputs; i++) {
  3247. hda_nid_t nid = cfg->inputs[i].pin;
  3248. int index, err, type_idx;
  3249. index = -1;
  3250. for (j = 0; j < spec->num_muxes; j++) {
  3251. index = get_connection_index(codec, spec->mux_nids[j],
  3252. nid);
  3253. if (index >= 0)
  3254. break;
  3255. }
  3256. if (index < 0)
  3257. continue;
  3258. label = hda_get_autocfg_input_label(codec, cfg, i);
  3259. snd_hda_add_imux_item(imux, label, index, &type_idx);
  3260. err = create_elem_capture_vol(codec, nid,
  3261. label, type_idx,
  3262. HDA_INPUT);
  3263. if (err < 0)
  3264. return err;
  3265. }
  3266. spec->num_analog_muxes = imux->num_items;
  3267. if (imux->num_items) {
  3268. /*
  3269. * Set the current input for the muxes.
  3270. * The STAC9221 has two input muxes with identical source
  3271. * NID lists. Hopefully this won't get confused.
  3272. */
  3273. for (i = 0; i < spec->num_muxes; i++) {
  3274. snd_hda_codec_write_cache(codec, spec->mux_nids[i], 0,
  3275. AC_VERB_SET_CONNECT_SEL,
  3276. imux->items[0].index);
  3277. }
  3278. }
  3279. return 0;
  3280. }
  3281. static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
  3282. {
  3283. struct sigmatel_spec *spec = codec->spec;
  3284. int i;
  3285. for (i = 0; i < spec->autocfg.line_outs; i++) {
  3286. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3287. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  3288. }
  3289. }
  3290. static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
  3291. {
  3292. struct sigmatel_spec *spec = codec->spec;
  3293. int i;
  3294. for (i = 0; i < spec->autocfg.hp_outs; i++) {
  3295. hda_nid_t pin;
  3296. pin = spec->autocfg.hp_pins[i];
  3297. if (pin) /* connect to front */
  3298. stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
  3299. }
  3300. for (i = 0; i < spec->autocfg.speaker_outs; i++) {
  3301. hda_nid_t pin;
  3302. pin = spec->autocfg.speaker_pins[i];
  3303. if (pin) /* connect to front */
  3304. stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
  3305. }
  3306. }
  3307. static int is_dual_headphones(struct hda_codec *codec)
  3308. {
  3309. struct sigmatel_spec *spec = codec->spec;
  3310. int i, valid_hps;
  3311. if (spec->autocfg.line_out_type != AUTO_PIN_SPEAKER_OUT ||
  3312. spec->autocfg.hp_outs <= 1)
  3313. return 0;
  3314. valid_hps = 0;
  3315. for (i = 0; i < spec->autocfg.hp_outs; i++) {
  3316. hda_nid_t nid = spec->autocfg.hp_pins[i];
  3317. unsigned int cfg = snd_hda_codec_get_pincfg(codec, nid);
  3318. if (get_defcfg_location(cfg) & AC_JACK_LOC_SEPARATE)
  3319. continue;
  3320. valid_hps++;
  3321. }
  3322. return (valid_hps > 1);
  3323. }
  3324. static int stac92xx_parse_auto_config(struct hda_codec *codec)
  3325. {
  3326. struct sigmatel_spec *spec = codec->spec;
  3327. hda_nid_t dig_out = 0, dig_in = 0;
  3328. int hp_swap = 0;
  3329. int i, err;
  3330. if ((err = snd_hda_parse_pin_def_config(codec,
  3331. &spec->autocfg,
  3332. spec->dmic_nids)) < 0)
  3333. return err;
  3334. if (! spec->autocfg.line_outs)
  3335. return 0; /* can't find valid pin config */
  3336. /* If we have no real line-out pin and multiple hp-outs, HPs should
  3337. * be set up as multi-channel outputs.
  3338. */
  3339. if (is_dual_headphones(codec)) {
  3340. /* Copy hp_outs to line_outs, backup line_outs in
  3341. * speaker_outs so that the following routines can handle
  3342. * HP pins as primary outputs.
  3343. */
  3344. snd_printdd("stac92xx: Enabling multi-HPs workaround\n");
  3345. memcpy(spec->autocfg.speaker_pins, spec->autocfg.line_out_pins,
  3346. sizeof(spec->autocfg.line_out_pins));
  3347. spec->autocfg.speaker_outs = spec->autocfg.line_outs;
  3348. memcpy(spec->autocfg.line_out_pins, spec->autocfg.hp_pins,
  3349. sizeof(spec->autocfg.hp_pins));
  3350. spec->autocfg.line_outs = spec->autocfg.hp_outs;
  3351. spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
  3352. spec->autocfg.hp_outs = 0;
  3353. hp_swap = 1;
  3354. }
  3355. if (spec->autocfg.mono_out_pin) {
  3356. int dir = get_wcaps(codec, spec->autocfg.mono_out_pin) &
  3357. (AC_WCAP_OUT_AMP | AC_WCAP_IN_AMP);
  3358. u32 caps = query_amp_caps(codec,
  3359. spec->autocfg.mono_out_pin, dir);
  3360. hda_nid_t conn_list[1];
  3361. /* get the mixer node and then the mono mux if it exists */
  3362. if (snd_hda_get_connections(codec,
  3363. spec->autocfg.mono_out_pin, conn_list, 1) &&
  3364. snd_hda_get_connections(codec, conn_list[0],
  3365. conn_list, 1) > 0) {
  3366. int wcaps = get_wcaps(codec, conn_list[0]);
  3367. int wid_type = get_wcaps_type(wcaps);
  3368. /* LR swap check, some stac925x have a mux that
  3369. * changes the DACs output path instead of the
  3370. * mono-mux path.
  3371. */
  3372. if (wid_type == AC_WID_AUD_SEL &&
  3373. !(wcaps & AC_WCAP_LR_SWAP))
  3374. spec->mono_nid = conn_list[0];
  3375. }
  3376. if (dir) {
  3377. hda_nid_t nid = spec->autocfg.mono_out_pin;
  3378. /* most mono outs have a least a mute/unmute switch */
  3379. dir = (dir & AC_WCAP_OUT_AMP) ? HDA_OUTPUT : HDA_INPUT;
  3380. err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
  3381. "Mono Playback Switch",
  3382. HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
  3383. if (err < 0)
  3384. return err;
  3385. /* check for volume support for the amp */
  3386. if ((caps & AC_AMPCAP_NUM_STEPS)
  3387. >> AC_AMPCAP_NUM_STEPS_SHIFT) {
  3388. err = stac92xx_add_control(spec,
  3389. STAC_CTL_WIDGET_VOL,
  3390. "Mono Playback Volume",
  3391. HDA_COMPOSE_AMP_VAL(nid, 1, 0, dir));
  3392. if (err < 0)
  3393. return err;
  3394. }
  3395. }
  3396. stac92xx_auto_set_pinctl(codec, spec->autocfg.mono_out_pin,
  3397. AC_PINCTL_OUT_EN);
  3398. }
  3399. if (!spec->multiout.num_dacs) {
  3400. err = stac92xx_auto_fill_dac_nids(codec);
  3401. if (err < 0)
  3402. return err;
  3403. err = stac92xx_auto_create_multi_out_ctls(codec,
  3404. &spec->autocfg);
  3405. if (err < 0)
  3406. return err;
  3407. }
  3408. /* setup analog beep controls */
  3409. if (spec->anabeep_nid > 0) {
  3410. err = stac92xx_auto_create_beep_ctls(codec,
  3411. spec->anabeep_nid);
  3412. if (err < 0)
  3413. return err;
  3414. }
  3415. /* setup digital beep controls and input device */
  3416. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  3417. if (spec->digbeep_nid > 0) {
  3418. hda_nid_t nid = spec->digbeep_nid;
  3419. unsigned int caps;
  3420. err = stac92xx_auto_create_beep_ctls(codec, nid);
  3421. if (err < 0)
  3422. return err;
  3423. err = snd_hda_attach_beep_device(codec, nid);
  3424. if (err < 0)
  3425. return err;
  3426. if (codec->beep) {
  3427. /* IDT/STAC codecs have linear beep tone parameter */
  3428. codec->beep->linear_tone = spec->linear_tone_beep;
  3429. /* if no beep switch is available, make its own one */
  3430. caps = query_amp_caps(codec, nid, HDA_OUTPUT);
  3431. if (!(caps & AC_AMPCAP_MUTE)) {
  3432. err = stac92xx_beep_switch_ctl(codec);
  3433. if (err < 0)
  3434. return err;
  3435. }
  3436. }
  3437. }
  3438. #endif
  3439. err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg);
  3440. if (err < 0)
  3441. return err;
  3442. /* All output parsing done, now restore the swapped hp pins */
  3443. if (hp_swap) {
  3444. memcpy(spec->autocfg.hp_pins, spec->autocfg.line_out_pins,
  3445. sizeof(spec->autocfg.hp_pins));
  3446. spec->autocfg.hp_outs = spec->autocfg.line_outs;
  3447. spec->autocfg.line_out_type = AUTO_PIN_HP_OUT;
  3448. spec->autocfg.line_outs = 0;
  3449. }
  3450. if (stac_check_auto_mic(codec)) {
  3451. spec->auto_mic = 1;
  3452. /* only one capture for auto-mic */
  3453. spec->num_adcs = 1;
  3454. spec->num_caps = 1;
  3455. spec->num_muxes = 1;
  3456. }
  3457. for (i = 0; i < spec->num_caps; i++) {
  3458. err = stac92xx_add_capvol_ctls(codec, spec->capvols[i],
  3459. spec->capsws[i], i);
  3460. if (err < 0)
  3461. return err;
  3462. }
  3463. err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg);
  3464. if (err < 0)
  3465. return err;
  3466. if (spec->mono_nid > 0) {
  3467. err = stac92xx_auto_create_mono_output_ctls(codec);
  3468. if (err < 0)
  3469. return err;
  3470. }
  3471. if (spec->num_dmics > 0 && !spec->dinput_mux)
  3472. if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
  3473. &spec->autocfg)) < 0)
  3474. return err;
  3475. if (spec->num_muxes > 0) {
  3476. err = stac92xx_auto_create_mux_input_ctls(codec);
  3477. if (err < 0)
  3478. return err;
  3479. }
  3480. if (spec->num_smuxes > 0) {
  3481. err = stac92xx_auto_create_spdif_mux_ctls(codec);
  3482. if (err < 0)
  3483. return err;
  3484. }
  3485. err = stac92xx_add_input_source(spec);
  3486. if (err < 0)
  3487. return err;
  3488. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  3489. if (spec->multiout.max_channels > 2)
  3490. spec->surr_switch = 1;
  3491. /* find digital out and in converters */
  3492. for (i = codec->start_nid; i < codec->start_nid + codec->num_nodes; i++) {
  3493. unsigned int wid_caps = get_wcaps(codec, i);
  3494. if (wid_caps & AC_WCAP_DIGITAL) {
  3495. switch (get_wcaps_type(wid_caps)) {
  3496. case AC_WID_AUD_OUT:
  3497. if (!dig_out)
  3498. dig_out = i;
  3499. break;
  3500. case AC_WID_AUD_IN:
  3501. if (!dig_in)
  3502. dig_in = i;
  3503. break;
  3504. }
  3505. }
  3506. }
  3507. if (spec->autocfg.dig_outs)
  3508. spec->multiout.dig_out_nid = dig_out;
  3509. if (dig_in && spec->autocfg.dig_in_pin)
  3510. spec->dig_in_nid = dig_in;
  3511. if (spec->kctls.list)
  3512. spec->mixers[spec->num_mixers++] = spec->kctls.list;
  3513. spec->input_mux = &spec->private_imux;
  3514. if (!spec->dinput_mux)
  3515. spec->dinput_mux = &spec->private_dimux;
  3516. spec->sinput_mux = &spec->private_smux;
  3517. spec->mono_mux = &spec->private_mono_mux;
  3518. return 1;
  3519. }
  3520. /* add playback controls for HP output */
  3521. static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
  3522. struct auto_pin_cfg *cfg)
  3523. {
  3524. struct sigmatel_spec *spec = codec->spec;
  3525. hda_nid_t pin = cfg->hp_pins[0];
  3526. if (! pin)
  3527. return 0;
  3528. if (is_jack_detectable(codec, pin))
  3529. spec->hp_detect = 1;
  3530. return 0;
  3531. }
  3532. /* add playback controls for LFE output */
  3533. static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
  3534. struct auto_pin_cfg *cfg)
  3535. {
  3536. struct sigmatel_spec *spec = codec->spec;
  3537. int err;
  3538. hda_nid_t lfe_pin = 0x0;
  3539. int i;
  3540. /*
  3541. * search speaker outs and line outs for a mono speaker pin
  3542. * with an amp. If one is found, add LFE controls
  3543. * for it.
  3544. */
  3545. for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
  3546. hda_nid_t pin = spec->autocfg.speaker_pins[i];
  3547. unsigned int wcaps = get_wcaps(codec, pin);
  3548. wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
  3549. if (wcaps == AC_WCAP_OUT_AMP)
  3550. /* found a mono speaker with an amp, must be lfe */
  3551. lfe_pin = pin;
  3552. }
  3553. /* if speaker_outs is 0, then speakers may be in line_outs */
  3554. if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
  3555. for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
  3556. hda_nid_t pin = spec->autocfg.line_out_pins[i];
  3557. unsigned int defcfg;
  3558. defcfg = snd_hda_codec_get_pincfg(codec, pin);
  3559. if (get_defcfg_device(defcfg) == AC_JACK_SPEAKER) {
  3560. unsigned int wcaps = get_wcaps(codec, pin);
  3561. wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
  3562. if (wcaps == AC_WCAP_OUT_AMP)
  3563. /* found a mono speaker with an amp,
  3564. must be lfe */
  3565. lfe_pin = pin;
  3566. }
  3567. }
  3568. }
  3569. if (lfe_pin) {
  3570. err = create_controls(codec, "LFE", lfe_pin, 1);
  3571. if (err < 0)
  3572. return err;
  3573. }
  3574. return 0;
  3575. }
  3576. static int stac9200_parse_auto_config(struct hda_codec *codec)
  3577. {
  3578. struct sigmatel_spec *spec = codec->spec;
  3579. int err;
  3580. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
  3581. return err;
  3582. if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
  3583. return err;
  3584. if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
  3585. return err;
  3586. if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
  3587. return err;
  3588. if (spec->num_muxes > 0) {
  3589. err = stac92xx_auto_create_mux_input_ctls(codec);
  3590. if (err < 0)
  3591. return err;
  3592. }
  3593. err = stac92xx_add_input_source(spec);
  3594. if (err < 0)
  3595. return err;
  3596. if (spec->autocfg.dig_outs)
  3597. spec->multiout.dig_out_nid = 0x05;
  3598. if (spec->autocfg.dig_in_pin)
  3599. spec->dig_in_nid = 0x04;
  3600. if (spec->kctls.list)
  3601. spec->mixers[spec->num_mixers++] = spec->kctls.list;
  3602. spec->input_mux = &spec->private_imux;
  3603. spec->dinput_mux = &spec->private_dimux;
  3604. return 1;
  3605. }
  3606. /*
  3607. * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
  3608. * funky external mute control using GPIO pins.
  3609. */
  3610. static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
  3611. unsigned int dir_mask, unsigned int data)
  3612. {
  3613. unsigned int gpiostate, gpiomask, gpiodir;
  3614. snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
  3615. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  3616. AC_VERB_GET_GPIO_DATA, 0);
  3617. gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
  3618. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  3619. AC_VERB_GET_GPIO_MASK, 0);
  3620. gpiomask |= mask;
  3621. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  3622. AC_VERB_GET_GPIO_DIRECTION, 0);
  3623. gpiodir |= dir_mask;
  3624. /* Configure GPIOx as CMOS */
  3625. snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
  3626. snd_hda_codec_write(codec, codec->afg, 0,
  3627. AC_VERB_SET_GPIO_MASK, gpiomask);
  3628. snd_hda_codec_read(codec, codec->afg, 0,
  3629. AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
  3630. msleep(1);
  3631. snd_hda_codec_read(codec, codec->afg, 0,
  3632. AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
  3633. }
  3634. static int stac_add_event(struct hda_codec *codec, hda_nid_t nid,
  3635. unsigned char type, int data)
  3636. {
  3637. struct hda_jack_tbl *event;
  3638. event = snd_hda_jack_tbl_new(codec, nid);
  3639. if (!event)
  3640. return -ENOMEM;
  3641. event->action = type;
  3642. event->private_data = data;
  3643. return 0;
  3644. }
  3645. /* check if given nid is a valid pin and no other events are assigned
  3646. * to it. If OK, assign the event, set the unsol flag, and returns 1.
  3647. * Otherwise, returns zero.
  3648. */
  3649. static int enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
  3650. unsigned int type)
  3651. {
  3652. struct hda_jack_tbl *event;
  3653. if (!is_jack_detectable(codec, nid))
  3654. return 0;
  3655. event = snd_hda_jack_tbl_new(codec, nid);
  3656. if (!event)
  3657. return -ENOMEM;
  3658. if (event->action && event->action != type)
  3659. return 0;
  3660. event->action = type;
  3661. snd_hda_jack_detect_enable(codec, nid, 0);
  3662. return 1;
  3663. }
  3664. static int is_nid_out_jack_pin(struct auto_pin_cfg *cfg, hda_nid_t nid)
  3665. {
  3666. int i;
  3667. for (i = 0; i < cfg->hp_outs; i++)
  3668. if (cfg->hp_pins[i] == nid)
  3669. return 1; /* nid is a HP-Out */
  3670. for (i = 0; i < cfg->line_outs; i++)
  3671. if (cfg->line_out_pins[i] == nid)
  3672. return 1; /* nid is a line-Out */
  3673. return 0; /* nid is not a HP-Out */
  3674. };
  3675. static void stac92xx_power_down(struct hda_codec *codec)
  3676. {
  3677. struct sigmatel_spec *spec = codec->spec;
  3678. /* power down inactive DACs */
  3679. const hda_nid_t *dac;
  3680. for (dac = spec->dac_list; *dac; dac++)
  3681. if (!check_all_dac_nids(spec, *dac))
  3682. snd_hda_codec_write(codec, *dac, 0,
  3683. AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
  3684. }
  3685. static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
  3686. int enable);
  3687. static inline int get_int_hint(struct hda_codec *codec, const char *key,
  3688. int *valp)
  3689. {
  3690. const char *p;
  3691. p = snd_hda_get_hint(codec, key);
  3692. if (p) {
  3693. unsigned long val;
  3694. if (!strict_strtoul(p, 0, &val)) {
  3695. *valp = val;
  3696. return 1;
  3697. }
  3698. }
  3699. return 0;
  3700. }
  3701. /* override some hints from the hwdep entry */
  3702. static void stac_store_hints(struct hda_codec *codec)
  3703. {
  3704. struct sigmatel_spec *spec = codec->spec;
  3705. int val;
  3706. val = snd_hda_get_bool_hint(codec, "hp_detect");
  3707. if (val >= 0)
  3708. spec->hp_detect = val;
  3709. if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
  3710. spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
  3711. spec->gpio_mask;
  3712. }
  3713. if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
  3714. spec->gpio_mask &= spec->gpio_mask;
  3715. if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
  3716. spec->gpio_dir &= spec->gpio_mask;
  3717. if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
  3718. spec->eapd_mask &= spec->gpio_mask;
  3719. if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
  3720. spec->gpio_mute &= spec->gpio_mask;
  3721. val = snd_hda_get_bool_hint(codec, "eapd_switch");
  3722. if (val >= 0)
  3723. spec->eapd_switch = val;
  3724. }
  3725. static void stac_issue_unsol_events(struct hda_codec *codec, int num_pins,
  3726. const hda_nid_t *pins)
  3727. {
  3728. while (num_pins--)
  3729. stac_issue_unsol_event(codec, *pins++);
  3730. }
  3731. /* fake event to set up pins */
  3732. static void stac_fake_hp_events(struct hda_codec *codec)
  3733. {
  3734. struct sigmatel_spec *spec = codec->spec;
  3735. if (spec->autocfg.hp_outs)
  3736. stac_issue_unsol_events(codec, spec->autocfg.hp_outs,
  3737. spec->autocfg.hp_pins);
  3738. if (spec->autocfg.line_outs &&
  3739. spec->autocfg.line_out_pins[0] != spec->autocfg.hp_pins[0])
  3740. stac_issue_unsol_events(codec, spec->autocfg.line_outs,
  3741. spec->autocfg.line_out_pins);
  3742. }
  3743. static int stac92xx_init(struct hda_codec *codec)
  3744. {
  3745. struct sigmatel_spec *spec = codec->spec;
  3746. struct auto_pin_cfg *cfg = &spec->autocfg;
  3747. unsigned int gpio;
  3748. int i;
  3749. snd_hda_sequence_write(codec, spec->init);
  3750. /* power down adcs initially */
  3751. if (spec->powerdown_adcs)
  3752. for (i = 0; i < spec->num_adcs; i++)
  3753. snd_hda_codec_write(codec,
  3754. spec->adc_nids[i], 0,
  3755. AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
  3756. /* override some hints */
  3757. stac_store_hints(codec);
  3758. /* set up GPIO */
  3759. gpio = spec->gpio_data;
  3760. /* turn on EAPD statically when spec->eapd_switch isn't set.
  3761. * otherwise, unsol event will turn it on/off dynamically
  3762. */
  3763. if (!spec->eapd_switch)
  3764. gpio |= spec->eapd_mask;
  3765. stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, gpio);
  3766. /* set up pins */
  3767. if (spec->hp_detect) {
  3768. /* Enable unsolicited responses on the HP widget */
  3769. for (i = 0; i < cfg->hp_outs; i++) {
  3770. hda_nid_t nid = cfg->hp_pins[i];
  3771. enable_pin_detect(codec, nid, STAC_HP_EVENT);
  3772. }
  3773. if (cfg->line_out_type == AUTO_PIN_LINE_OUT &&
  3774. cfg->speaker_outs > 0) {
  3775. /* enable pin-detect for line-outs as well */
  3776. for (i = 0; i < cfg->line_outs; i++) {
  3777. hda_nid_t nid = cfg->line_out_pins[i];
  3778. enable_pin_detect(codec, nid, STAC_LO_EVENT);
  3779. }
  3780. }
  3781. /* force to enable the first line-out; the others are set up
  3782. * in unsol_event
  3783. */
  3784. stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
  3785. AC_PINCTL_OUT_EN);
  3786. /* fake event to set up pins */
  3787. stac_fake_hp_events(codec);
  3788. } else {
  3789. stac92xx_auto_init_multi_out(codec);
  3790. stac92xx_auto_init_hp_out(codec);
  3791. for (i = 0; i < cfg->hp_outs; i++)
  3792. stac_toggle_power_map(codec, cfg->hp_pins[i], 1);
  3793. }
  3794. if (spec->auto_mic) {
  3795. /* initialize connection to analog input */
  3796. if (spec->dmux_nids)
  3797. snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
  3798. AC_VERB_SET_CONNECT_SEL, 0);
  3799. if (enable_pin_detect(codec, spec->ext_mic.pin, STAC_MIC_EVENT))
  3800. stac_issue_unsol_event(codec, spec->ext_mic.pin);
  3801. if (enable_pin_detect(codec, spec->dock_mic.pin,
  3802. STAC_MIC_EVENT))
  3803. stac_issue_unsol_event(codec, spec->dock_mic.pin);
  3804. }
  3805. for (i = 0; i < cfg->num_inputs; i++) {
  3806. hda_nid_t nid = cfg->inputs[i].pin;
  3807. int type = cfg->inputs[i].type;
  3808. unsigned int pinctl, conf;
  3809. if (type == AUTO_PIN_MIC) {
  3810. /* for mic pins, force to initialize */
  3811. pinctl = snd_hda_get_default_vref(codec, nid);
  3812. pinctl |= AC_PINCTL_IN_EN;
  3813. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  3814. } else {
  3815. pinctl = snd_hda_codec_read(codec, nid, 0,
  3816. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  3817. /* if PINCTL already set then skip */
  3818. /* Also, if both INPUT and OUTPUT are set,
  3819. * it must be a BIOS bug; need to override, too
  3820. */
  3821. if (!(pinctl & AC_PINCTL_IN_EN) ||
  3822. (pinctl & AC_PINCTL_OUT_EN)) {
  3823. pinctl &= ~AC_PINCTL_OUT_EN;
  3824. pinctl |= AC_PINCTL_IN_EN;
  3825. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  3826. }
  3827. }
  3828. conf = snd_hda_codec_get_pincfg(codec, nid);
  3829. if (get_defcfg_connect(conf) != AC_JACK_PORT_FIXED) {
  3830. if (enable_pin_detect(codec, nid, STAC_INSERT_EVENT))
  3831. stac_issue_unsol_event(codec, nid);
  3832. }
  3833. }
  3834. for (i = 0; i < spec->num_dmics; i++)
  3835. stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
  3836. AC_PINCTL_IN_EN);
  3837. if (cfg->dig_out_pins[0])
  3838. stac92xx_auto_set_pinctl(codec, cfg->dig_out_pins[0],
  3839. AC_PINCTL_OUT_EN);
  3840. if (cfg->dig_in_pin)
  3841. stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
  3842. AC_PINCTL_IN_EN);
  3843. for (i = 0; i < spec->num_pwrs; i++) {
  3844. hda_nid_t nid = spec->pwr_nids[i];
  3845. int pinctl, def_conf;
  3846. def_conf = snd_hda_codec_get_pincfg(codec, nid);
  3847. def_conf = get_defcfg_connect(def_conf);
  3848. if (def_conf == AC_JACK_PORT_NONE) {
  3849. /* power off unused ports */
  3850. stac_toggle_power_map(codec, nid, 0);
  3851. continue;
  3852. }
  3853. /* power on when no jack detection is available */
  3854. /* or when the VREF is used for controlling LED */
  3855. if (!spec->hp_detect ||
  3856. spec->vref_mute_led_nid == nid ||
  3857. !is_jack_detectable(codec, nid)) {
  3858. stac_toggle_power_map(codec, nid, 1);
  3859. continue;
  3860. }
  3861. if (is_nid_out_jack_pin(cfg, nid))
  3862. continue; /* already has an unsol event */
  3863. pinctl = snd_hda_codec_read(codec, nid, 0,
  3864. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  3865. /* outputs are only ports capable of power management
  3866. * any attempts on powering down a input port cause the
  3867. * referenced VREF to act quirky.
  3868. */
  3869. if (pinctl & AC_PINCTL_IN_EN) {
  3870. stac_toggle_power_map(codec, nid, 1);
  3871. continue;
  3872. }
  3873. if (enable_pin_detect(codec, nid, STAC_PWR_EVENT)) {
  3874. stac_issue_unsol_event(codec, nid);
  3875. continue;
  3876. }
  3877. /* none of the above, turn the port OFF */
  3878. stac_toggle_power_map(codec, nid, 0);
  3879. }
  3880. snd_hda_jack_report_sync(codec);
  3881. /* sync mute LED */
  3882. snd_hda_sync_vmaster_hook(&spec->vmaster_mute);
  3883. /* sync the power-map */
  3884. if (spec->num_pwrs)
  3885. snd_hda_codec_write(codec, codec->afg, 0,
  3886. AC_VERB_IDT_SET_POWER_MAP,
  3887. spec->power_map_bits);
  3888. if (spec->dac_list)
  3889. stac92xx_power_down(codec);
  3890. return 0;
  3891. }
  3892. static void stac92xx_free_kctls(struct hda_codec *codec)
  3893. {
  3894. struct sigmatel_spec *spec = codec->spec;
  3895. if (spec->kctls.list) {
  3896. struct snd_kcontrol_new *kctl = spec->kctls.list;
  3897. int i;
  3898. for (i = 0; i < spec->kctls.used; i++)
  3899. kfree(kctl[i].name);
  3900. }
  3901. snd_array_free(&spec->kctls);
  3902. }
  3903. static void stac92xx_shutup_pins(struct hda_codec *codec)
  3904. {
  3905. unsigned int i, def_conf;
  3906. if (codec->bus->shutdown)
  3907. return;
  3908. for (i = 0; i < codec->init_pins.used; i++) {
  3909. struct hda_pincfg *pin = snd_array_elem(&codec->init_pins, i);
  3910. def_conf = snd_hda_codec_get_pincfg(codec, pin->nid);
  3911. if (get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE)
  3912. snd_hda_set_pin_ctl(codec, pin->nid, 0);
  3913. }
  3914. }
  3915. static void stac92xx_shutup(struct hda_codec *codec)
  3916. {
  3917. struct sigmatel_spec *spec = codec->spec;
  3918. stac92xx_shutup_pins(codec);
  3919. if (spec->eapd_mask)
  3920. stac_gpio_set(codec, spec->gpio_mask,
  3921. spec->gpio_dir, spec->gpio_data &
  3922. ~spec->eapd_mask);
  3923. }
  3924. static void stac92xx_free(struct hda_codec *codec)
  3925. {
  3926. struct sigmatel_spec *spec = codec->spec;
  3927. if (! spec)
  3928. return;
  3929. stac92xx_shutup(codec);
  3930. kfree(spec);
  3931. snd_hda_detach_beep_device(codec);
  3932. }
  3933. static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
  3934. unsigned int flag)
  3935. {
  3936. unsigned int old_ctl, pin_ctl;
  3937. pin_ctl = snd_hda_codec_read(codec, nid,
  3938. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  3939. if (pin_ctl & AC_PINCTL_IN_EN) {
  3940. /*
  3941. * we need to check the current set-up direction of
  3942. * shared input pins since they can be switched via
  3943. * "xxx as Output" mixer switch
  3944. */
  3945. struct sigmatel_spec *spec = codec->spec;
  3946. if (nid == spec->line_switch || nid == spec->mic_switch)
  3947. return;
  3948. }
  3949. old_ctl = pin_ctl;
  3950. /* if setting pin direction bits, clear the current
  3951. direction bits first */
  3952. if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
  3953. pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
  3954. pin_ctl |= flag;
  3955. if (old_ctl != pin_ctl)
  3956. snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl);
  3957. }
  3958. static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
  3959. unsigned int flag)
  3960. {
  3961. unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
  3962. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  3963. if (pin_ctl & flag)
  3964. snd_hda_set_pin_ctl_cache(codec, nid, pin_ctl & ~flag);
  3965. }
  3966. static inline int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
  3967. {
  3968. if (!nid)
  3969. return 0;
  3970. return snd_hda_jack_detect(codec, nid);
  3971. }
  3972. static void stac92xx_line_out_detect(struct hda_codec *codec,
  3973. int presence)
  3974. {
  3975. struct sigmatel_spec *spec = codec->spec;
  3976. struct auto_pin_cfg *cfg = &spec->autocfg;
  3977. int i;
  3978. for (i = 0; i < cfg->line_outs; i++) {
  3979. if (presence)
  3980. break;
  3981. presence = get_pin_presence(codec, cfg->line_out_pins[i]);
  3982. if (presence) {
  3983. unsigned int pinctl;
  3984. pinctl = snd_hda_codec_read(codec,
  3985. cfg->line_out_pins[i], 0,
  3986. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  3987. if (pinctl & AC_PINCTL_IN_EN)
  3988. presence = 0; /* mic- or line-input */
  3989. }
  3990. }
  3991. if (presence) {
  3992. /* disable speakers */
  3993. for (i = 0; i < cfg->speaker_outs; i++)
  3994. stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
  3995. AC_PINCTL_OUT_EN);
  3996. if (spec->eapd_mask && spec->eapd_switch)
  3997. stac_gpio_set(codec, spec->gpio_mask,
  3998. spec->gpio_dir, spec->gpio_data &
  3999. ~spec->eapd_mask);
  4000. } else {
  4001. /* enable speakers */
  4002. for (i = 0; i < cfg->speaker_outs; i++)
  4003. stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
  4004. AC_PINCTL_OUT_EN);
  4005. if (spec->eapd_mask && spec->eapd_switch)
  4006. stac_gpio_set(codec, spec->gpio_mask,
  4007. spec->gpio_dir, spec->gpio_data |
  4008. spec->eapd_mask);
  4009. }
  4010. }
  4011. /* return non-zero if the hp-pin of the given array index isn't
  4012. * a jack-detection target
  4013. */
  4014. static int no_hp_sensing(struct sigmatel_spec *spec, int i)
  4015. {
  4016. struct auto_pin_cfg *cfg = &spec->autocfg;
  4017. /* ignore sensing of shared line and mic jacks */
  4018. if (cfg->hp_pins[i] == spec->line_switch)
  4019. return 1;
  4020. if (cfg->hp_pins[i] == spec->mic_switch)
  4021. return 1;
  4022. /* ignore if the pin is set as line-out */
  4023. if (cfg->hp_pins[i] == spec->hp_switch)
  4024. return 1;
  4025. return 0;
  4026. }
  4027. static void stac92xx_hp_detect(struct hda_codec *codec)
  4028. {
  4029. struct sigmatel_spec *spec = codec->spec;
  4030. struct auto_pin_cfg *cfg = &spec->autocfg;
  4031. int i, presence;
  4032. presence = 0;
  4033. if (spec->gpio_mute)
  4034. presence = !(snd_hda_codec_read(codec, codec->afg, 0,
  4035. AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
  4036. for (i = 0; i < cfg->hp_outs; i++) {
  4037. if (presence)
  4038. break;
  4039. if (no_hp_sensing(spec, i))
  4040. continue;
  4041. presence = get_pin_presence(codec, cfg->hp_pins[i]);
  4042. if (presence) {
  4043. unsigned int pinctl;
  4044. pinctl = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
  4045. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  4046. if (pinctl & AC_PINCTL_IN_EN)
  4047. presence = 0; /* mic- or line-input */
  4048. }
  4049. }
  4050. if (presence) {
  4051. /* disable lineouts */
  4052. if (spec->hp_switch)
  4053. stac92xx_reset_pinctl(codec, spec->hp_switch,
  4054. AC_PINCTL_OUT_EN);
  4055. for (i = 0; i < cfg->line_outs; i++)
  4056. stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
  4057. AC_PINCTL_OUT_EN);
  4058. } else {
  4059. /* enable lineouts */
  4060. if (spec->hp_switch)
  4061. stac92xx_set_pinctl(codec, spec->hp_switch,
  4062. AC_PINCTL_OUT_EN);
  4063. for (i = 0; i < cfg->line_outs; i++)
  4064. stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
  4065. AC_PINCTL_OUT_EN);
  4066. }
  4067. stac92xx_line_out_detect(codec, presence);
  4068. /* toggle hp outs */
  4069. for (i = 0; i < cfg->hp_outs; i++) {
  4070. unsigned int val = AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN;
  4071. if (no_hp_sensing(spec, i))
  4072. continue;
  4073. if (1 /*presence*/)
  4074. stac92xx_set_pinctl(codec, cfg->hp_pins[i], val);
  4075. #if 0 /* FIXME */
  4076. /* Resetting the pinctl like below may lead to (a sort of) regressions
  4077. * on some devices since they use the HP pin actually for line/speaker
  4078. * outs although the default pin config shows a different pin (that is
  4079. * wrong and useless).
  4080. *
  4081. * So, it's basically a problem of default pin configs, likely a BIOS issue.
  4082. * But, disabling the code below just works around it, and I'm too tired of
  4083. * bug reports with such devices...
  4084. */
  4085. else
  4086. stac92xx_reset_pinctl(codec, cfg->hp_pins[i], val);
  4087. #endif /* FIXME */
  4088. }
  4089. }
  4090. static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
  4091. int enable)
  4092. {
  4093. struct sigmatel_spec *spec = codec->spec;
  4094. unsigned int idx, val;
  4095. for (idx = 0; idx < spec->num_pwrs; idx++) {
  4096. if (spec->pwr_nids[idx] == nid)
  4097. break;
  4098. }
  4099. if (idx >= spec->num_pwrs)
  4100. return;
  4101. idx = 1 << idx;
  4102. val = spec->power_map_bits;
  4103. if (enable)
  4104. val &= ~idx;
  4105. else
  4106. val |= idx;
  4107. /* power down unused output ports */
  4108. if (val != spec->power_map_bits) {
  4109. spec->power_map_bits = val;
  4110. snd_hda_codec_write(codec, codec->afg, 0,
  4111. AC_VERB_IDT_SET_POWER_MAP, val);
  4112. }
  4113. }
  4114. static void stac92xx_pin_sense(struct hda_codec *codec, hda_nid_t nid)
  4115. {
  4116. stac_toggle_power_map(codec, nid, get_pin_presence(codec, nid));
  4117. }
  4118. /* get the pin connection (fixed, none, etc) */
  4119. static unsigned int stac_get_defcfg_connect(struct hda_codec *codec, int idx)
  4120. {
  4121. struct sigmatel_spec *spec = codec->spec;
  4122. unsigned int cfg;
  4123. cfg = snd_hda_codec_get_pincfg(codec, spec->pin_nids[idx]);
  4124. return get_defcfg_connect(cfg);
  4125. }
  4126. static int stac92xx_connected_ports(struct hda_codec *codec,
  4127. const hda_nid_t *nids, int num_nids)
  4128. {
  4129. struct sigmatel_spec *spec = codec->spec;
  4130. int idx, num;
  4131. unsigned int def_conf;
  4132. for (num = 0; num < num_nids; num++) {
  4133. for (idx = 0; idx < spec->num_pins; idx++)
  4134. if (spec->pin_nids[idx] == nids[num])
  4135. break;
  4136. if (idx >= spec->num_pins)
  4137. break;
  4138. def_conf = stac_get_defcfg_connect(codec, idx);
  4139. if (def_conf == AC_JACK_PORT_NONE)
  4140. break;
  4141. }
  4142. return num;
  4143. }
  4144. static void stac92xx_mic_detect(struct hda_codec *codec)
  4145. {
  4146. struct sigmatel_spec *spec = codec->spec;
  4147. struct sigmatel_mic_route *mic;
  4148. if (get_pin_presence(codec, spec->ext_mic.pin))
  4149. mic = &spec->ext_mic;
  4150. else if (get_pin_presence(codec, spec->dock_mic.pin))
  4151. mic = &spec->dock_mic;
  4152. else
  4153. mic = &spec->int_mic;
  4154. if (mic->dmux_idx >= 0)
  4155. snd_hda_codec_write_cache(codec, spec->dmux_nids[0], 0,
  4156. AC_VERB_SET_CONNECT_SEL,
  4157. mic->dmux_idx);
  4158. if (mic->mux_idx >= 0)
  4159. snd_hda_codec_write_cache(codec, spec->mux_nids[0], 0,
  4160. AC_VERB_SET_CONNECT_SEL,
  4161. mic->mux_idx);
  4162. }
  4163. static void handle_unsol_event(struct hda_codec *codec,
  4164. struct hda_jack_tbl *event)
  4165. {
  4166. struct sigmatel_spec *spec = codec->spec;
  4167. int data;
  4168. switch (event->action) {
  4169. case STAC_HP_EVENT:
  4170. case STAC_LO_EVENT:
  4171. stac92xx_hp_detect(codec);
  4172. break;
  4173. case STAC_MIC_EVENT:
  4174. stac92xx_mic_detect(codec);
  4175. break;
  4176. }
  4177. switch (event->action) {
  4178. case STAC_HP_EVENT:
  4179. case STAC_LO_EVENT:
  4180. case STAC_MIC_EVENT:
  4181. case STAC_INSERT_EVENT:
  4182. case STAC_PWR_EVENT:
  4183. if (spec->num_pwrs > 0)
  4184. stac92xx_pin_sense(codec, event->nid);
  4185. switch (codec->subsystem_id) {
  4186. case 0x103c308f:
  4187. if (event->nid == 0xb) {
  4188. int pin = AC_PINCTL_IN_EN;
  4189. if (get_pin_presence(codec, 0xa)
  4190. && get_pin_presence(codec, 0xb))
  4191. pin |= AC_PINCTL_VREF_80;
  4192. if (!get_pin_presence(codec, 0xb))
  4193. pin |= AC_PINCTL_VREF_80;
  4194. /* toggle VREF state based on mic + hp pin
  4195. * status
  4196. */
  4197. stac92xx_auto_set_pinctl(codec, 0x0a, pin);
  4198. }
  4199. }
  4200. break;
  4201. case STAC_VREF_EVENT:
  4202. data = snd_hda_codec_read(codec, codec->afg, 0,
  4203. AC_VERB_GET_GPIO_DATA, 0);
  4204. /* toggle VREF state based on GPIOx status */
  4205. snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
  4206. !!(data & (1 << event->private_data)));
  4207. break;
  4208. }
  4209. }
  4210. static void stac_issue_unsol_event(struct hda_codec *codec, hda_nid_t nid)
  4211. {
  4212. struct hda_jack_tbl *event = snd_hda_jack_tbl_get(codec, nid);
  4213. if (!event)
  4214. return;
  4215. handle_unsol_event(codec, event);
  4216. }
  4217. static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
  4218. {
  4219. struct hda_jack_tbl *event;
  4220. int tag;
  4221. tag = (res >> 26) & 0x7f;
  4222. event = snd_hda_jack_tbl_get_from_tag(codec, tag);
  4223. if (!event)
  4224. return;
  4225. event->jack_dirty = 1;
  4226. handle_unsol_event(codec, event);
  4227. snd_hda_jack_report_sync(codec);
  4228. }
  4229. static int hp_blike_system(u32 subsystem_id);
  4230. static void set_hp_led_gpio(struct hda_codec *codec)
  4231. {
  4232. struct sigmatel_spec *spec = codec->spec;
  4233. unsigned int gpio;
  4234. if (spec->gpio_led)
  4235. return;
  4236. gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
  4237. gpio &= AC_GPIO_IO_COUNT;
  4238. if (gpio > 3)
  4239. spec->gpio_led = 0x08; /* GPIO 3 */
  4240. else
  4241. spec->gpio_led = 0x01; /* GPIO 0 */
  4242. }
  4243. /*
  4244. * This method searches for the mute LED GPIO configuration
  4245. * provided as OEM string in SMBIOS. The format of that string
  4246. * is HP_Mute_LED_P_G or HP_Mute_LED_P
  4247. * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
  4248. * that corresponds to the NOT muted state of the master volume
  4249. * and G is the index of the GPIO to use as the mute LED control (0..9)
  4250. * If _G portion is missing it is assigned based on the codec ID
  4251. *
  4252. * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
  4253. * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
  4254. *
  4255. *
  4256. * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
  4257. * SMBIOS - at least the ones I have seen do not have them - which include
  4258. * my own system (HP Pavilion dv6-1110ax) and my cousin's
  4259. * HP Pavilion dv9500t CTO.
  4260. * Need more information on whether it is true across the entire series.
  4261. * -- kunal
  4262. */
  4263. static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
  4264. {
  4265. struct sigmatel_spec *spec = codec->spec;
  4266. const struct dmi_device *dev = NULL;
  4267. if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
  4268. get_int_hint(codec, "gpio_led_polarity",
  4269. &spec->gpio_led_polarity);
  4270. return 1;
  4271. }
  4272. if ((codec->subsystem_id >> 16) == PCI_VENDOR_ID_HP) {
  4273. while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING,
  4274. NULL, dev))) {
  4275. if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
  4276. &spec->gpio_led_polarity,
  4277. &spec->gpio_led) == 2) {
  4278. unsigned int max_gpio;
  4279. max_gpio = snd_hda_param_read(codec, codec->afg,
  4280. AC_PAR_GPIO_CAP);
  4281. max_gpio &= AC_GPIO_IO_COUNT;
  4282. if (spec->gpio_led < max_gpio)
  4283. spec->gpio_led = 1 << spec->gpio_led;
  4284. else
  4285. spec->vref_mute_led_nid = spec->gpio_led;
  4286. return 1;
  4287. }
  4288. if (sscanf(dev->name, "HP_Mute_LED_%d",
  4289. &spec->gpio_led_polarity) == 1) {
  4290. set_hp_led_gpio(codec);
  4291. return 1;
  4292. }
  4293. /* BIOS bug: unfilled OEM string */
  4294. if (strstr(dev->name, "HP_Mute_LED_P_G")) {
  4295. set_hp_led_gpio(codec);
  4296. switch (codec->subsystem_id) {
  4297. case 0x103c148a:
  4298. spec->gpio_led_polarity = 0;
  4299. break;
  4300. default:
  4301. spec->gpio_led_polarity = 1;
  4302. break;
  4303. }
  4304. return 1;
  4305. }
  4306. }
  4307. /*
  4308. * Fallback case - if we don't find the DMI strings,
  4309. * we statically set the GPIO - if not a B-series system
  4310. * and default polarity is provided
  4311. */
  4312. if (!hp_blike_system(codec->subsystem_id) &&
  4313. (default_polarity == 0 || default_polarity == 1)) {
  4314. set_hp_led_gpio(codec);
  4315. spec->gpio_led_polarity = default_polarity;
  4316. return 1;
  4317. }
  4318. }
  4319. return 0;
  4320. }
  4321. static int hp_blike_system(u32 subsystem_id)
  4322. {
  4323. switch (subsystem_id) {
  4324. case 0x103c1520:
  4325. case 0x103c1521:
  4326. case 0x103c1523:
  4327. case 0x103c1524:
  4328. case 0x103c1525:
  4329. case 0x103c1722:
  4330. case 0x103c1723:
  4331. case 0x103c1724:
  4332. case 0x103c1725:
  4333. case 0x103c1726:
  4334. case 0x103c1727:
  4335. case 0x103c1728:
  4336. case 0x103c1729:
  4337. case 0x103c172a:
  4338. case 0x103c172b:
  4339. case 0x103c307e:
  4340. case 0x103c307f:
  4341. case 0x103c3080:
  4342. case 0x103c3081:
  4343. case 0x103c7007:
  4344. case 0x103c7008:
  4345. return 1;
  4346. }
  4347. return 0;
  4348. }
  4349. #ifdef CONFIG_PROC_FS
  4350. static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
  4351. struct hda_codec *codec, hda_nid_t nid)
  4352. {
  4353. if (nid == codec->afg)
  4354. snd_iprintf(buffer, "Power-Map: 0x%02x\n",
  4355. snd_hda_codec_read(codec, nid, 0,
  4356. AC_VERB_IDT_GET_POWER_MAP, 0));
  4357. }
  4358. static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
  4359. struct hda_codec *codec,
  4360. unsigned int verb)
  4361. {
  4362. snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
  4363. snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
  4364. }
  4365. /* stac92hd71bxx, stac92hd73xx */
  4366. static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
  4367. struct hda_codec *codec, hda_nid_t nid)
  4368. {
  4369. stac92hd_proc_hook(buffer, codec, nid);
  4370. if (nid == codec->afg)
  4371. analog_loop_proc_hook(buffer, codec, 0xfa0);
  4372. }
  4373. static void stac9205_proc_hook(struct snd_info_buffer *buffer,
  4374. struct hda_codec *codec, hda_nid_t nid)
  4375. {
  4376. if (nid == codec->afg)
  4377. analog_loop_proc_hook(buffer, codec, 0xfe0);
  4378. }
  4379. static void stac927x_proc_hook(struct snd_info_buffer *buffer,
  4380. struct hda_codec *codec, hda_nid_t nid)
  4381. {
  4382. if (nid == codec->afg)
  4383. analog_loop_proc_hook(buffer, codec, 0xfeb);
  4384. }
  4385. #else
  4386. #define stac92hd_proc_hook NULL
  4387. #define stac92hd7x_proc_hook NULL
  4388. #define stac9205_proc_hook NULL
  4389. #define stac927x_proc_hook NULL
  4390. #endif
  4391. #ifdef CONFIG_PM
  4392. static int stac92xx_resume(struct hda_codec *codec)
  4393. {
  4394. stac92xx_init(codec);
  4395. snd_hda_codec_resume_amp(codec);
  4396. snd_hda_codec_resume_cache(codec);
  4397. /* fake event to set up pins again to override cached values */
  4398. stac_fake_hp_events(codec);
  4399. return 0;
  4400. }
  4401. static int stac92xx_suspend(struct hda_codec *codec, pm_message_t state)
  4402. {
  4403. stac92xx_shutup(codec);
  4404. return 0;
  4405. }
  4406. static void stac92xx_set_power_state(struct hda_codec *codec, hda_nid_t fg,
  4407. unsigned int power_state)
  4408. {
  4409. unsigned int afg_power_state = power_state;
  4410. struct sigmatel_spec *spec = codec->spec;
  4411. if (power_state == AC_PWRST_D3) {
  4412. if (spec->vref_mute_led_nid) {
  4413. /* with vref-out pin used for mute led control
  4414. * codec AFG is prevented from D3 state
  4415. */
  4416. afg_power_state = AC_PWRST_D1;
  4417. }
  4418. /* this delay seems necessary to avoid click noise at power-down */
  4419. msleep(100);
  4420. }
  4421. snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
  4422. afg_power_state);
  4423. snd_hda_codec_set_power_to_all(codec, fg, power_state, true);
  4424. }
  4425. #else
  4426. #define stac92xx_suspend NULL
  4427. #define stac92xx_resume NULL
  4428. #define stac92xx_set_power_state NULL
  4429. #endif /* CONFIG_PM */
  4430. /* update mute-LED accoring to the master switch */
  4431. static void stac92xx_update_led_status(struct hda_codec *codec, int enabled)
  4432. {
  4433. struct sigmatel_spec *spec = codec->spec;
  4434. int muted = !enabled;
  4435. if (!spec->gpio_led)
  4436. return;
  4437. /* LED state is inverted on these systems */
  4438. if (spec->gpio_led_polarity)
  4439. muted = !muted;
  4440. if (!spec->vref_mute_led_nid) {
  4441. if (muted)
  4442. spec->gpio_data |= spec->gpio_led;
  4443. else
  4444. spec->gpio_data &= ~spec->gpio_led;
  4445. stac_gpio_set(codec, spec->gpio_mask,
  4446. spec->gpio_dir, spec->gpio_data);
  4447. } else {
  4448. spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
  4449. stac_vrefout_set(codec, spec->vref_mute_led_nid,
  4450. spec->vref_led);
  4451. }
  4452. }
  4453. static const struct hda_codec_ops stac92xx_patch_ops = {
  4454. .build_controls = stac92xx_build_controls,
  4455. .build_pcms = stac92xx_build_pcms,
  4456. .init = stac92xx_init,
  4457. .free = stac92xx_free,
  4458. .unsol_event = stac92xx_unsol_event,
  4459. #ifdef CONFIG_PM
  4460. .suspend = stac92xx_suspend,
  4461. .resume = stac92xx_resume,
  4462. #endif
  4463. .reboot_notify = stac92xx_shutup,
  4464. };
  4465. static int patch_stac9200(struct hda_codec *codec)
  4466. {
  4467. struct sigmatel_spec *spec;
  4468. int err;
  4469. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4470. if (spec == NULL)
  4471. return -ENOMEM;
  4472. codec->no_trigger_sense = 1;
  4473. codec->spec = spec;
  4474. spec->linear_tone_beep = 1;
  4475. spec->num_pins = ARRAY_SIZE(stac9200_pin_nids);
  4476. spec->pin_nids = stac9200_pin_nids;
  4477. spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
  4478. stac9200_models,
  4479. stac9200_cfg_tbl);
  4480. if (spec->board_config < 0)
  4481. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  4482. codec->chip_name);
  4483. else
  4484. stac92xx_set_config_regs(codec,
  4485. stac9200_brd_tbl[spec->board_config]);
  4486. spec->multiout.max_channels = 2;
  4487. spec->multiout.num_dacs = 1;
  4488. spec->multiout.dac_nids = stac9200_dac_nids;
  4489. spec->adc_nids = stac9200_adc_nids;
  4490. spec->mux_nids = stac9200_mux_nids;
  4491. spec->num_muxes = 1;
  4492. spec->num_dmics = 0;
  4493. spec->num_adcs = 1;
  4494. spec->num_pwrs = 0;
  4495. if (spec->board_config == STAC_9200_M4 ||
  4496. spec->board_config == STAC_9200_M4_2 ||
  4497. spec->board_config == STAC_9200_OQO)
  4498. spec->init = stac9200_eapd_init;
  4499. else
  4500. spec->init = stac9200_core_init;
  4501. spec->mixer = stac9200_mixer;
  4502. if (spec->board_config == STAC_9200_PANASONIC) {
  4503. spec->gpio_mask = spec->gpio_dir = 0x09;
  4504. spec->gpio_data = 0x00;
  4505. }
  4506. err = stac9200_parse_auto_config(codec);
  4507. if (err < 0) {
  4508. stac92xx_free(codec);
  4509. return err;
  4510. }
  4511. /* CF-74 has no headphone detection, and the driver should *NOT*
  4512. * do detection and HP/speaker toggle because the hardware does it.
  4513. */
  4514. if (spec->board_config == STAC_9200_PANASONIC)
  4515. spec->hp_detect = 0;
  4516. codec->patch_ops = stac92xx_patch_ops;
  4517. return 0;
  4518. }
  4519. static int patch_stac925x(struct hda_codec *codec)
  4520. {
  4521. struct sigmatel_spec *spec;
  4522. int err;
  4523. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4524. if (spec == NULL)
  4525. return -ENOMEM;
  4526. codec->no_trigger_sense = 1;
  4527. codec->spec = spec;
  4528. spec->linear_tone_beep = 1;
  4529. spec->num_pins = ARRAY_SIZE(stac925x_pin_nids);
  4530. spec->pin_nids = stac925x_pin_nids;
  4531. /* Check first for codec ID */
  4532. spec->board_config = snd_hda_check_board_codec_sid_config(codec,
  4533. STAC_925x_MODELS,
  4534. stac925x_models,
  4535. stac925x_codec_id_cfg_tbl);
  4536. /* Now checks for PCI ID, if codec ID is not found */
  4537. if (spec->board_config < 0)
  4538. spec->board_config = snd_hda_check_board_config(codec,
  4539. STAC_925x_MODELS,
  4540. stac925x_models,
  4541. stac925x_cfg_tbl);
  4542. again:
  4543. if (spec->board_config < 0)
  4544. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  4545. codec->chip_name);
  4546. else
  4547. stac92xx_set_config_regs(codec,
  4548. stac925x_brd_tbl[spec->board_config]);
  4549. spec->multiout.max_channels = 2;
  4550. spec->multiout.num_dacs = 1;
  4551. spec->multiout.dac_nids = stac925x_dac_nids;
  4552. spec->adc_nids = stac925x_adc_nids;
  4553. spec->mux_nids = stac925x_mux_nids;
  4554. spec->num_muxes = 1;
  4555. spec->num_adcs = 1;
  4556. spec->num_pwrs = 0;
  4557. switch (codec->vendor_id) {
  4558. case 0x83847632: /* STAC9202 */
  4559. case 0x83847633: /* STAC9202D */
  4560. case 0x83847636: /* STAC9251 */
  4561. case 0x83847637: /* STAC9251D */
  4562. spec->num_dmics = STAC925X_NUM_DMICS;
  4563. spec->dmic_nids = stac925x_dmic_nids;
  4564. spec->num_dmuxes = ARRAY_SIZE(stac925x_dmux_nids);
  4565. spec->dmux_nids = stac925x_dmux_nids;
  4566. break;
  4567. default:
  4568. spec->num_dmics = 0;
  4569. break;
  4570. }
  4571. spec->init = stac925x_core_init;
  4572. spec->mixer = stac925x_mixer;
  4573. spec->num_caps = 1;
  4574. spec->capvols = stac925x_capvols;
  4575. spec->capsws = stac925x_capsws;
  4576. err = stac92xx_parse_auto_config(codec);
  4577. if (!err) {
  4578. if (spec->board_config < 0) {
  4579. printk(KERN_WARNING "hda_codec: No auto-config is "
  4580. "available, default to model=ref\n");
  4581. spec->board_config = STAC_925x_REF;
  4582. goto again;
  4583. }
  4584. err = -EINVAL;
  4585. }
  4586. if (err < 0) {
  4587. stac92xx_free(codec);
  4588. return err;
  4589. }
  4590. codec->patch_ops = stac92xx_patch_ops;
  4591. return 0;
  4592. }
  4593. static int patch_stac92hd73xx(struct hda_codec *codec)
  4594. {
  4595. struct sigmatel_spec *spec;
  4596. hda_nid_t conn[STAC92HD73_DAC_COUNT + 2];
  4597. int err = 0;
  4598. int num_dacs;
  4599. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4600. if (spec == NULL)
  4601. return -ENOMEM;
  4602. codec->no_trigger_sense = 1;
  4603. codec->spec = spec;
  4604. spec->linear_tone_beep = 0;
  4605. codec->slave_dig_outs = stac92hd73xx_slave_dig_outs;
  4606. spec->num_pins = ARRAY_SIZE(stac92hd73xx_pin_nids);
  4607. spec->pin_nids = stac92hd73xx_pin_nids;
  4608. spec->board_config = snd_hda_check_board_config(codec,
  4609. STAC_92HD73XX_MODELS,
  4610. stac92hd73xx_models,
  4611. stac92hd73xx_cfg_tbl);
  4612. /* check codec subsystem id if not found */
  4613. if (spec->board_config < 0)
  4614. spec->board_config =
  4615. snd_hda_check_board_codec_sid_config(codec,
  4616. STAC_92HD73XX_MODELS, stac92hd73xx_models,
  4617. stac92hd73xx_codec_id_cfg_tbl);
  4618. again:
  4619. if (spec->board_config < 0)
  4620. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  4621. codec->chip_name);
  4622. else
  4623. stac92xx_set_config_regs(codec,
  4624. stac92hd73xx_brd_tbl[spec->board_config]);
  4625. num_dacs = snd_hda_get_connections(codec, 0x0a,
  4626. conn, STAC92HD73_DAC_COUNT + 2) - 1;
  4627. if (num_dacs < 3 || num_dacs > 5) {
  4628. printk(KERN_WARNING "hda_codec: Could not determine "
  4629. "number of channels defaulting to DAC count\n");
  4630. num_dacs = STAC92HD73_DAC_COUNT;
  4631. }
  4632. spec->init = stac92hd73xx_core_init;
  4633. switch (num_dacs) {
  4634. case 0x3: /* 6 Channel */
  4635. spec->aloopback_ctl = stac92hd73xx_6ch_loopback;
  4636. break;
  4637. case 0x4: /* 8 Channel */
  4638. spec->aloopback_ctl = stac92hd73xx_8ch_loopback;
  4639. break;
  4640. case 0x5: /* 10 Channel */
  4641. spec->aloopback_ctl = stac92hd73xx_10ch_loopback;
  4642. break;
  4643. }
  4644. spec->multiout.dac_nids = spec->dac_nids;
  4645. spec->aloopback_mask = 0x01;
  4646. spec->aloopback_shift = 8;
  4647. spec->digbeep_nid = 0x1c;
  4648. spec->mux_nids = stac92hd73xx_mux_nids;
  4649. spec->adc_nids = stac92hd73xx_adc_nids;
  4650. spec->dmic_nids = stac92hd73xx_dmic_nids;
  4651. spec->dmux_nids = stac92hd73xx_dmux_nids;
  4652. spec->smux_nids = stac92hd73xx_smux_nids;
  4653. spec->num_muxes = ARRAY_SIZE(stac92hd73xx_mux_nids);
  4654. spec->num_adcs = ARRAY_SIZE(stac92hd73xx_adc_nids);
  4655. spec->num_dmuxes = ARRAY_SIZE(stac92hd73xx_dmux_nids);
  4656. spec->num_caps = STAC92HD73XX_NUM_CAPS;
  4657. spec->capvols = stac92hd73xx_capvols;
  4658. spec->capsws = stac92hd73xx_capsws;
  4659. switch (spec->board_config) {
  4660. case STAC_DELL_EQ:
  4661. spec->init = dell_eq_core_init;
  4662. /* fallthru */
  4663. case STAC_DELL_M6_AMIC:
  4664. case STAC_DELL_M6_DMIC:
  4665. case STAC_DELL_M6_BOTH:
  4666. spec->num_smuxes = 0;
  4667. spec->eapd_switch = 0;
  4668. switch (spec->board_config) {
  4669. case STAC_DELL_M6_AMIC: /* Analog Mics */
  4670. snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
  4671. spec->num_dmics = 0;
  4672. break;
  4673. case STAC_DELL_M6_DMIC: /* Digital Mics */
  4674. snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
  4675. spec->num_dmics = 1;
  4676. break;
  4677. case STAC_DELL_M6_BOTH: /* Both */
  4678. snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
  4679. snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
  4680. spec->num_dmics = 1;
  4681. break;
  4682. }
  4683. break;
  4684. case STAC_ALIENWARE_M17X:
  4685. spec->num_dmics = STAC92HD73XX_NUM_DMICS;
  4686. spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
  4687. spec->eapd_switch = 0;
  4688. break;
  4689. default:
  4690. spec->num_dmics = STAC92HD73XX_NUM_DMICS;
  4691. spec->num_smuxes = ARRAY_SIZE(stac92hd73xx_smux_nids);
  4692. spec->eapd_switch = 1;
  4693. break;
  4694. }
  4695. if (spec->board_config != STAC_92HD73XX_REF) {
  4696. /* GPIO0 High = Enable EAPD */
  4697. spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
  4698. spec->gpio_data = 0x01;
  4699. }
  4700. spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
  4701. spec->pwr_nids = stac92hd73xx_pwr_nids;
  4702. err = stac92xx_parse_auto_config(codec);
  4703. if (!err) {
  4704. if (spec->board_config < 0) {
  4705. printk(KERN_WARNING "hda_codec: No auto-config is "
  4706. "available, default to model=ref\n");
  4707. spec->board_config = STAC_92HD73XX_REF;
  4708. goto again;
  4709. }
  4710. err = -EINVAL;
  4711. }
  4712. if (err < 0) {
  4713. stac92xx_free(codec);
  4714. return err;
  4715. }
  4716. if (spec->board_config == STAC_92HD73XX_NO_JD)
  4717. spec->hp_detect = 0;
  4718. codec->patch_ops = stac92xx_patch_ops;
  4719. codec->proc_widget_hook = stac92hd7x_proc_hook;
  4720. return 0;
  4721. }
  4722. static int hp_bnb2011_with_dock(struct hda_codec *codec)
  4723. {
  4724. if (codec->vendor_id != 0x111d7605 &&
  4725. codec->vendor_id != 0x111d76d1)
  4726. return 0;
  4727. switch (codec->subsystem_id) {
  4728. case 0x103c1618:
  4729. case 0x103c1619:
  4730. case 0x103c161a:
  4731. case 0x103c161b:
  4732. case 0x103c161c:
  4733. case 0x103c161d:
  4734. case 0x103c161e:
  4735. case 0x103c161f:
  4736. case 0x103c162a:
  4737. case 0x103c162b:
  4738. case 0x103c1630:
  4739. case 0x103c1631:
  4740. case 0x103c1633:
  4741. case 0x103c1634:
  4742. case 0x103c1635:
  4743. case 0x103c3587:
  4744. case 0x103c3588:
  4745. case 0x103c3589:
  4746. case 0x103c358a:
  4747. case 0x103c3667:
  4748. case 0x103c3668:
  4749. case 0x103c3669:
  4750. return 1;
  4751. }
  4752. return 0;
  4753. }
  4754. static void stac92hd8x_add_pin(struct hda_codec *codec, hda_nid_t nid)
  4755. {
  4756. struct sigmatel_spec *spec = codec->spec;
  4757. unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
  4758. int i;
  4759. spec->auto_pin_nids[spec->auto_pin_cnt] = nid;
  4760. spec->auto_pin_cnt++;
  4761. if (get_defcfg_device(def_conf) == AC_JACK_MIC_IN &&
  4762. get_defcfg_connect(def_conf) != AC_JACK_PORT_NONE) {
  4763. for (i = 0; i < ARRAY_SIZE(stac92hd83xxx_dmic_nids); i++) {
  4764. if (nid == stac92hd83xxx_dmic_nids[i]) {
  4765. spec->auto_dmic_nids[spec->auto_dmic_cnt] = nid;
  4766. spec->auto_dmic_cnt++;
  4767. }
  4768. }
  4769. }
  4770. }
  4771. static void stac92hd8x_add_adc(struct hda_codec *codec, hda_nid_t nid)
  4772. {
  4773. struct sigmatel_spec *spec = codec->spec;
  4774. spec->auto_adc_nids[spec->auto_adc_cnt] = nid;
  4775. spec->auto_adc_cnt++;
  4776. }
  4777. static void stac92hd8x_add_mux(struct hda_codec *codec, hda_nid_t nid)
  4778. {
  4779. int i, j;
  4780. struct sigmatel_spec *spec = codec->spec;
  4781. for (i = 0; i < spec->auto_adc_cnt; i++) {
  4782. if (get_connection_index(codec,
  4783. spec->auto_adc_nids[i], nid) >= 0) {
  4784. /* mux and volume for adc_nids[i] */
  4785. if (!spec->auto_mux_nids[i]) {
  4786. spec->auto_mux_nids[i] = nid;
  4787. /* 92hd codecs capture volume is in mux */
  4788. spec->auto_capvols[i] = HDA_COMPOSE_AMP_VAL(nid,
  4789. 3, 0, HDA_OUTPUT);
  4790. }
  4791. for (j = 0; j < spec->auto_dmic_cnt; j++) {
  4792. if (get_connection_index(codec, nid,
  4793. spec->auto_dmic_nids[j]) >= 0) {
  4794. /* dmux for adc_nids[i] */
  4795. if (!spec->auto_dmux_nids[i])
  4796. spec->auto_dmux_nids[i] = nid;
  4797. break;
  4798. }
  4799. }
  4800. break;
  4801. }
  4802. }
  4803. }
  4804. static void stac92hd8x_fill_auto_spec(struct hda_codec *codec)
  4805. {
  4806. hda_nid_t nid, end_nid;
  4807. unsigned int wid_caps, wid_type;
  4808. struct sigmatel_spec *spec = codec->spec;
  4809. end_nid = codec->start_nid + codec->num_nodes;
  4810. for (nid = codec->start_nid; nid < end_nid; nid++) {
  4811. wid_caps = get_wcaps(codec, nid);
  4812. wid_type = get_wcaps_type(wid_caps);
  4813. if (wid_type == AC_WID_PIN)
  4814. stac92hd8x_add_pin(codec, nid);
  4815. if (wid_type == AC_WID_AUD_IN && !(wid_caps & AC_WCAP_DIGITAL))
  4816. stac92hd8x_add_adc(codec, nid);
  4817. }
  4818. for (nid = codec->start_nid; nid < end_nid; nid++) {
  4819. wid_caps = get_wcaps(codec, nid);
  4820. wid_type = get_wcaps_type(wid_caps);
  4821. if (wid_type == AC_WID_AUD_SEL)
  4822. stac92hd8x_add_mux(codec, nid);
  4823. }
  4824. spec->pin_nids = spec->auto_pin_nids;
  4825. spec->num_pins = spec->auto_pin_cnt;
  4826. spec->adc_nids = spec->auto_adc_nids;
  4827. spec->num_adcs = spec->auto_adc_cnt;
  4828. spec->capvols = spec->auto_capvols;
  4829. spec->capsws = spec->auto_capvols;
  4830. spec->num_caps = spec->auto_adc_cnt;
  4831. spec->mux_nids = spec->auto_mux_nids;
  4832. spec->num_muxes = spec->auto_adc_cnt;
  4833. spec->dmux_nids = spec->auto_dmux_nids;
  4834. spec->num_dmuxes = spec->auto_adc_cnt;
  4835. spec->dmic_nids = spec->auto_dmic_nids;
  4836. spec->num_dmics = spec->auto_dmic_cnt;
  4837. }
  4838. static int patch_stac92hd83xxx(struct hda_codec *codec)
  4839. {
  4840. struct sigmatel_spec *spec;
  4841. int err;
  4842. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4843. if (spec == NULL)
  4844. return -ENOMEM;
  4845. if (hp_bnb2011_with_dock(codec)) {
  4846. snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
  4847. snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
  4848. }
  4849. codec->no_trigger_sense = 1;
  4850. codec->spec = spec;
  4851. stac92hd8x_fill_auto_spec(codec);
  4852. spec->linear_tone_beep = 0;
  4853. codec->slave_dig_outs = stac92hd83xxx_slave_dig_outs;
  4854. spec->digbeep_nid = 0x21;
  4855. spec->pwr_nids = stac92hd83xxx_pwr_nids;
  4856. spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
  4857. spec->multiout.dac_nids = spec->dac_nids;
  4858. spec->init = stac92hd83xxx_core_init;
  4859. spec->board_config = snd_hda_check_board_config(codec,
  4860. STAC_92HD83XXX_MODELS,
  4861. stac92hd83xxx_models,
  4862. stac92hd83xxx_cfg_tbl);
  4863. /* check codec subsystem id if not found */
  4864. if (spec->board_config < 0)
  4865. spec->board_config =
  4866. snd_hda_check_board_codec_sid_config(codec,
  4867. STAC_92HD83XXX_MODELS, stac92hd83xxx_models,
  4868. stac92hd83xxx_codec_id_cfg_tbl);
  4869. again:
  4870. if (spec->board_config < 0)
  4871. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  4872. codec->chip_name);
  4873. else
  4874. stac92xx_set_config_regs(codec,
  4875. stac92hd83xxx_brd_tbl[spec->board_config]);
  4876. codec->patch_ops = stac92xx_patch_ops;
  4877. switch (spec->board_config) {
  4878. case STAC_HP_ZEPHYR:
  4879. spec->init = stac92hd83xxx_hp_zephyr_init;
  4880. break;
  4881. }
  4882. if (find_mute_led_cfg(codec, -1/*no default cfg*/))
  4883. snd_printd("mute LED gpio %d polarity %d\n",
  4884. spec->gpio_led,
  4885. spec->gpio_led_polarity);
  4886. if (spec->gpio_led) {
  4887. if (!spec->vref_mute_led_nid) {
  4888. spec->gpio_mask |= spec->gpio_led;
  4889. spec->gpio_dir |= spec->gpio_led;
  4890. spec->gpio_data |= spec->gpio_led;
  4891. } else {
  4892. codec->patch_ops.set_power_state =
  4893. stac92xx_set_power_state;
  4894. }
  4895. }
  4896. err = stac92xx_parse_auto_config(codec);
  4897. if (!err) {
  4898. if (spec->board_config < 0) {
  4899. printk(KERN_WARNING "hda_codec: No auto-config is "
  4900. "available, default to model=ref\n");
  4901. spec->board_config = STAC_92HD83XXX_REF;
  4902. goto again;
  4903. }
  4904. err = -EINVAL;
  4905. }
  4906. if (err < 0) {
  4907. stac92xx_free(codec);
  4908. return err;
  4909. }
  4910. codec->proc_widget_hook = stac92hd_proc_hook;
  4911. return 0;
  4912. }
  4913. static int stac92hd71bxx_connected_smuxes(struct hda_codec *codec,
  4914. hda_nid_t dig0pin)
  4915. {
  4916. struct sigmatel_spec *spec = codec->spec;
  4917. int idx;
  4918. for (idx = 0; idx < spec->num_pins; idx++)
  4919. if (spec->pin_nids[idx] == dig0pin)
  4920. break;
  4921. if ((idx + 2) >= spec->num_pins)
  4922. return 0;
  4923. /* dig1pin case */
  4924. if (stac_get_defcfg_connect(codec, idx + 1) != AC_JACK_PORT_NONE)
  4925. return 2;
  4926. /* dig0pin + dig2pin case */
  4927. if (stac_get_defcfg_connect(codec, idx + 2) != AC_JACK_PORT_NONE)
  4928. return 2;
  4929. if (stac_get_defcfg_connect(codec, idx) != AC_JACK_PORT_NONE)
  4930. return 1;
  4931. else
  4932. return 0;
  4933. }
  4934. /* HP dv7 bass switch - GPIO5 */
  4935. #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
  4936. static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
  4937. struct snd_ctl_elem_value *ucontrol)
  4938. {
  4939. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4940. struct sigmatel_spec *spec = codec->spec;
  4941. ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
  4942. return 0;
  4943. }
  4944. static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
  4945. struct snd_ctl_elem_value *ucontrol)
  4946. {
  4947. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4948. struct sigmatel_spec *spec = codec->spec;
  4949. unsigned int gpio_data;
  4950. gpio_data = (spec->gpio_data & ~0x20) |
  4951. (ucontrol->value.integer.value[0] ? 0x20 : 0);
  4952. if (gpio_data == spec->gpio_data)
  4953. return 0;
  4954. spec->gpio_data = gpio_data;
  4955. stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
  4956. return 1;
  4957. }
  4958. static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
  4959. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4960. .info = stac_hp_bass_gpio_info,
  4961. .get = stac_hp_bass_gpio_get,
  4962. .put = stac_hp_bass_gpio_put,
  4963. };
  4964. static int stac_add_hp_bass_switch(struct hda_codec *codec)
  4965. {
  4966. struct sigmatel_spec *spec = codec->spec;
  4967. if (!stac_control_new(spec, &stac_hp_bass_sw_ctrl,
  4968. "Bass Speaker Playback Switch", 0))
  4969. return -ENOMEM;
  4970. spec->gpio_mask |= 0x20;
  4971. spec->gpio_dir |= 0x20;
  4972. spec->gpio_data |= 0x20;
  4973. return 0;
  4974. }
  4975. static int patch_stac92hd71bxx(struct hda_codec *codec)
  4976. {
  4977. struct sigmatel_spec *spec;
  4978. const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
  4979. unsigned int pin_cfg;
  4980. int err = 0;
  4981. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4982. if (spec == NULL)
  4983. return -ENOMEM;
  4984. codec->no_trigger_sense = 1;
  4985. codec->spec = spec;
  4986. spec->linear_tone_beep = 0;
  4987. codec->patch_ops = stac92xx_patch_ops;
  4988. spec->num_pins = STAC92HD71BXX_NUM_PINS;
  4989. switch (codec->vendor_id) {
  4990. case 0x111d76b6:
  4991. case 0x111d76b7:
  4992. spec->pin_nids = stac92hd71bxx_pin_nids_4port;
  4993. break;
  4994. case 0x111d7603:
  4995. case 0x111d7608:
  4996. /* On 92HD75Bx 0x27 isn't a pin nid */
  4997. spec->num_pins--;
  4998. /* fallthrough */
  4999. default:
  5000. spec->pin_nids = stac92hd71bxx_pin_nids_6port;
  5001. }
  5002. spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
  5003. spec->board_config = snd_hda_check_board_config(codec,
  5004. STAC_92HD71BXX_MODELS,
  5005. stac92hd71bxx_models,
  5006. stac92hd71bxx_cfg_tbl);
  5007. again:
  5008. if (spec->board_config < 0)
  5009. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  5010. codec->chip_name);
  5011. else
  5012. stac92xx_set_config_regs(codec,
  5013. stac92hd71bxx_brd_tbl[spec->board_config]);
  5014. if (spec->board_config != STAC_92HD71BXX_REF) {
  5015. /* GPIO0 = EAPD */
  5016. spec->gpio_mask = 0x01;
  5017. spec->gpio_dir = 0x01;
  5018. spec->gpio_data = 0x01;
  5019. }
  5020. spec->dmic_nids = stac92hd71bxx_dmic_nids;
  5021. spec->dmux_nids = stac92hd71bxx_dmux_nids;
  5022. spec->num_caps = STAC92HD71BXX_NUM_CAPS;
  5023. spec->capvols = stac92hd71bxx_capvols;
  5024. spec->capsws = stac92hd71bxx_capsws;
  5025. switch (codec->vendor_id) {
  5026. case 0x111d76b6: /* 4 Port without Analog Mixer */
  5027. case 0x111d76b7:
  5028. unmute_init++;
  5029. /* fallthru */
  5030. case 0x111d76b4: /* 6 Port without Analog Mixer */
  5031. case 0x111d76b5:
  5032. spec->init = stac92hd71bxx_core_init;
  5033. codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
  5034. spec->num_dmics = stac92xx_connected_ports(codec,
  5035. stac92hd71bxx_dmic_nids,
  5036. STAC92HD71BXX_NUM_DMICS);
  5037. break;
  5038. case 0x111d7608: /* 5 Port with Analog Mixer */
  5039. switch (spec->board_config) {
  5040. case STAC_HP_M4:
  5041. /* Enable VREF power saving on GPIO1 detect */
  5042. err = stac_add_event(codec, codec->afg,
  5043. STAC_VREF_EVENT, 0x02);
  5044. if (err < 0)
  5045. return err;
  5046. snd_hda_codec_write_cache(codec, codec->afg, 0,
  5047. AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
  5048. snd_hda_jack_detect_enable(codec, codec->afg, 0);
  5049. spec->gpio_mask |= 0x02;
  5050. break;
  5051. }
  5052. if ((codec->revision_id & 0xf) == 0 ||
  5053. (codec->revision_id & 0xf) == 1)
  5054. spec->stream_delay = 40; /* 40 milliseconds */
  5055. /* disable VSW */
  5056. spec->init = stac92hd71bxx_core_init;
  5057. unmute_init++;
  5058. snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
  5059. snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
  5060. spec->dmic_nids = stac92hd71bxx_dmic_5port_nids;
  5061. spec->num_dmics = stac92xx_connected_ports(codec,
  5062. stac92hd71bxx_dmic_5port_nids,
  5063. STAC92HD71BXX_NUM_DMICS - 1);
  5064. break;
  5065. case 0x111d7603: /* 6 Port with Analog Mixer */
  5066. if ((codec->revision_id & 0xf) == 1)
  5067. spec->stream_delay = 40; /* 40 milliseconds */
  5068. /* fallthru */
  5069. default:
  5070. spec->init = stac92hd71bxx_core_init;
  5071. codec->slave_dig_outs = stac92hd71bxx_slave_dig_outs;
  5072. spec->num_dmics = stac92xx_connected_ports(codec,
  5073. stac92hd71bxx_dmic_nids,
  5074. STAC92HD71BXX_NUM_DMICS);
  5075. break;
  5076. }
  5077. if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
  5078. snd_hda_sequence_write_cache(codec, unmute_init);
  5079. spec->aloopback_ctl = stac92hd71bxx_loopback;
  5080. spec->aloopback_mask = 0x50;
  5081. spec->aloopback_shift = 0;
  5082. spec->powerdown_adcs = 1;
  5083. spec->digbeep_nid = 0x26;
  5084. spec->mux_nids = stac92hd71bxx_mux_nids;
  5085. spec->adc_nids = stac92hd71bxx_adc_nids;
  5086. spec->smux_nids = stac92hd71bxx_smux_nids;
  5087. spec->pwr_nids = stac92hd71bxx_pwr_nids;
  5088. spec->num_muxes = ARRAY_SIZE(stac92hd71bxx_mux_nids);
  5089. spec->num_adcs = ARRAY_SIZE(stac92hd71bxx_adc_nids);
  5090. spec->num_dmuxes = ARRAY_SIZE(stac92hd71bxx_dmux_nids);
  5091. spec->num_smuxes = stac92hd71bxx_connected_smuxes(codec, 0x1e);
  5092. snd_printdd("Found board config: %d\n", spec->board_config);
  5093. switch (spec->board_config) {
  5094. case STAC_HP_M4:
  5095. /* enable internal microphone */
  5096. snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
  5097. stac92xx_auto_set_pinctl(codec, 0x0e,
  5098. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80);
  5099. /* fallthru */
  5100. case STAC_DELL_M4_2:
  5101. spec->num_dmics = 0;
  5102. spec->num_smuxes = 0;
  5103. spec->num_dmuxes = 0;
  5104. break;
  5105. case STAC_DELL_M4_1:
  5106. case STAC_DELL_M4_3:
  5107. spec->num_dmics = 1;
  5108. spec->num_smuxes = 0;
  5109. spec->num_dmuxes = 1;
  5110. break;
  5111. case STAC_HP_DV4_1222NR:
  5112. spec->num_dmics = 1;
  5113. /* I don't know if it needs 1 or 2 smuxes - will wait for
  5114. * bug reports to fix if needed
  5115. */
  5116. spec->num_smuxes = 1;
  5117. spec->num_dmuxes = 1;
  5118. /* fallthrough */
  5119. case STAC_HP_DV4:
  5120. spec->gpio_led = 0x01;
  5121. /* fallthrough */
  5122. case STAC_HP_DV5:
  5123. snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
  5124. stac92xx_auto_set_pinctl(codec, 0x0d, AC_PINCTL_OUT_EN);
  5125. /* HP dv6 gives the headphone pin as a line-out. Thus we
  5126. * need to set hp_detect flag here to force to enable HP
  5127. * detection.
  5128. */
  5129. spec->hp_detect = 1;
  5130. break;
  5131. case STAC_HP_HDX:
  5132. spec->num_dmics = 1;
  5133. spec->num_dmuxes = 1;
  5134. spec->num_smuxes = 1;
  5135. spec->gpio_led = 0x08;
  5136. break;
  5137. }
  5138. if (hp_blike_system(codec->subsystem_id)) {
  5139. pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
  5140. if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
  5141. get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
  5142. get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
  5143. /* It was changed in the BIOS to just satisfy MS DTM.
  5144. * Lets turn it back into slaved HP
  5145. */
  5146. pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
  5147. | (AC_JACK_HP_OUT <<
  5148. AC_DEFCFG_DEVICE_SHIFT);
  5149. pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
  5150. | AC_DEFCFG_SEQUENCE)))
  5151. | 0x1f;
  5152. snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
  5153. }
  5154. }
  5155. if (find_mute_led_cfg(codec, 1))
  5156. snd_printd("mute LED gpio %d polarity %d\n",
  5157. spec->gpio_led,
  5158. spec->gpio_led_polarity);
  5159. if (spec->gpio_led) {
  5160. if (!spec->vref_mute_led_nid) {
  5161. spec->gpio_mask |= spec->gpio_led;
  5162. spec->gpio_dir |= spec->gpio_led;
  5163. spec->gpio_data |= spec->gpio_led;
  5164. } else {
  5165. codec->patch_ops.set_power_state =
  5166. stac92xx_set_power_state;
  5167. }
  5168. }
  5169. spec->multiout.dac_nids = spec->dac_nids;
  5170. err = stac92xx_parse_auto_config(codec);
  5171. if (!err) {
  5172. if (spec->board_config < 0) {
  5173. printk(KERN_WARNING "hda_codec: No auto-config is "
  5174. "available, default to model=ref\n");
  5175. spec->board_config = STAC_92HD71BXX_REF;
  5176. goto again;
  5177. }
  5178. err = -EINVAL;
  5179. }
  5180. if (err < 0) {
  5181. stac92xx_free(codec);
  5182. return err;
  5183. }
  5184. /* enable bass on HP dv7 */
  5185. if (spec->board_config == STAC_HP_DV4 ||
  5186. spec->board_config == STAC_HP_DV5) {
  5187. unsigned int cap;
  5188. cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
  5189. cap &= AC_GPIO_IO_COUNT;
  5190. if (cap >= 6)
  5191. stac_add_hp_bass_switch(codec);
  5192. }
  5193. codec->proc_widget_hook = stac92hd7x_proc_hook;
  5194. return 0;
  5195. }
  5196. static int patch_stac922x(struct hda_codec *codec)
  5197. {
  5198. struct sigmatel_spec *spec;
  5199. int err;
  5200. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5201. if (spec == NULL)
  5202. return -ENOMEM;
  5203. codec->no_trigger_sense = 1;
  5204. codec->spec = spec;
  5205. spec->linear_tone_beep = 1;
  5206. spec->num_pins = ARRAY_SIZE(stac922x_pin_nids);
  5207. spec->pin_nids = stac922x_pin_nids;
  5208. spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
  5209. stac922x_models,
  5210. stac922x_cfg_tbl);
  5211. if (spec->board_config == STAC_INTEL_MAC_AUTO) {
  5212. spec->gpio_mask = spec->gpio_dir = 0x03;
  5213. spec->gpio_data = 0x03;
  5214. /* Intel Macs have all same PCI SSID, so we need to check
  5215. * codec SSID to distinguish the exact models
  5216. */
  5217. printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
  5218. switch (codec->subsystem_id) {
  5219. case 0x106b0800:
  5220. spec->board_config = STAC_INTEL_MAC_V1;
  5221. break;
  5222. case 0x106b0600:
  5223. case 0x106b0700:
  5224. spec->board_config = STAC_INTEL_MAC_V2;
  5225. break;
  5226. case 0x106b0e00:
  5227. case 0x106b0f00:
  5228. case 0x106b1600:
  5229. case 0x106b1700:
  5230. case 0x106b0200:
  5231. case 0x106b1e00:
  5232. spec->board_config = STAC_INTEL_MAC_V3;
  5233. break;
  5234. case 0x106b1a00:
  5235. case 0x00000100:
  5236. spec->board_config = STAC_INTEL_MAC_V4;
  5237. break;
  5238. case 0x106b0a00:
  5239. case 0x106b2200:
  5240. spec->board_config = STAC_INTEL_MAC_V5;
  5241. break;
  5242. default:
  5243. spec->board_config = STAC_INTEL_MAC_V3;
  5244. break;
  5245. }
  5246. }
  5247. again:
  5248. if (spec->board_config < 0)
  5249. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  5250. codec->chip_name);
  5251. else
  5252. stac92xx_set_config_regs(codec,
  5253. stac922x_brd_tbl[spec->board_config]);
  5254. spec->adc_nids = stac922x_adc_nids;
  5255. spec->mux_nids = stac922x_mux_nids;
  5256. spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
  5257. spec->num_adcs = ARRAY_SIZE(stac922x_adc_nids);
  5258. spec->num_dmics = 0;
  5259. spec->num_pwrs = 0;
  5260. spec->init = stac922x_core_init;
  5261. spec->num_caps = STAC922X_NUM_CAPS;
  5262. spec->capvols = stac922x_capvols;
  5263. spec->capsws = stac922x_capsws;
  5264. spec->multiout.dac_nids = spec->dac_nids;
  5265. err = stac92xx_parse_auto_config(codec);
  5266. if (!err) {
  5267. if (spec->board_config < 0) {
  5268. printk(KERN_WARNING "hda_codec: No auto-config is "
  5269. "available, default to model=ref\n");
  5270. spec->board_config = STAC_D945_REF;
  5271. goto again;
  5272. }
  5273. err = -EINVAL;
  5274. }
  5275. if (err < 0) {
  5276. stac92xx_free(codec);
  5277. return err;
  5278. }
  5279. codec->patch_ops = stac92xx_patch_ops;
  5280. /* Fix Mux capture level; max to 2 */
  5281. snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
  5282. (0 << AC_AMPCAP_OFFSET_SHIFT) |
  5283. (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
  5284. (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
  5285. (0 << AC_AMPCAP_MUTE_SHIFT));
  5286. return 0;
  5287. }
  5288. static int patch_stac927x(struct hda_codec *codec)
  5289. {
  5290. struct sigmatel_spec *spec;
  5291. int err;
  5292. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5293. if (spec == NULL)
  5294. return -ENOMEM;
  5295. codec->no_trigger_sense = 1;
  5296. codec->spec = spec;
  5297. spec->linear_tone_beep = 1;
  5298. codec->slave_dig_outs = stac927x_slave_dig_outs;
  5299. spec->num_pins = ARRAY_SIZE(stac927x_pin_nids);
  5300. spec->pin_nids = stac927x_pin_nids;
  5301. spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
  5302. stac927x_models,
  5303. stac927x_cfg_tbl);
  5304. again:
  5305. if (spec->board_config < 0)
  5306. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  5307. codec->chip_name);
  5308. else
  5309. stac92xx_set_config_regs(codec,
  5310. stac927x_brd_tbl[spec->board_config]);
  5311. spec->digbeep_nid = 0x23;
  5312. spec->adc_nids = stac927x_adc_nids;
  5313. spec->num_adcs = ARRAY_SIZE(stac927x_adc_nids);
  5314. spec->mux_nids = stac927x_mux_nids;
  5315. spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
  5316. spec->smux_nids = stac927x_smux_nids;
  5317. spec->num_smuxes = ARRAY_SIZE(stac927x_smux_nids);
  5318. spec->spdif_labels = stac927x_spdif_labels;
  5319. spec->dac_list = stac927x_dac_nids;
  5320. spec->multiout.dac_nids = spec->dac_nids;
  5321. if (spec->board_config != STAC_D965_REF) {
  5322. /* GPIO0 High = Enable EAPD */
  5323. spec->eapd_mask = spec->gpio_mask = 0x01;
  5324. spec->gpio_dir = spec->gpio_data = 0x01;
  5325. }
  5326. switch (spec->board_config) {
  5327. case STAC_D965_3ST:
  5328. case STAC_D965_5ST:
  5329. /* GPIO0 High = Enable EAPD */
  5330. spec->num_dmics = 0;
  5331. spec->init = d965_core_init;
  5332. break;
  5333. case STAC_DELL_BIOS:
  5334. switch (codec->subsystem_id) {
  5335. case 0x10280209:
  5336. case 0x1028022e:
  5337. /* correct the device field to SPDIF out */
  5338. snd_hda_codec_set_pincfg(codec, 0x21, 0x01442070);
  5339. break;
  5340. }
  5341. /* configure the analog microphone on some laptops */
  5342. snd_hda_codec_set_pincfg(codec, 0x0c, 0x90a79130);
  5343. /* correct the front output jack as a hp out */
  5344. snd_hda_codec_set_pincfg(codec, 0x0f, 0x0227011f);
  5345. /* correct the front input jack as a mic */
  5346. snd_hda_codec_set_pincfg(codec, 0x0e, 0x02a79130);
  5347. /* fallthru */
  5348. case STAC_DELL_3ST:
  5349. if (codec->subsystem_id != 0x1028022f) {
  5350. /* GPIO2 High = Enable EAPD */
  5351. spec->eapd_mask = spec->gpio_mask = 0x04;
  5352. spec->gpio_dir = spec->gpio_data = 0x04;
  5353. }
  5354. spec->dmic_nids = stac927x_dmic_nids;
  5355. spec->num_dmics = STAC927X_NUM_DMICS;
  5356. spec->init = dell_3st_core_init;
  5357. spec->dmux_nids = stac927x_dmux_nids;
  5358. spec->num_dmuxes = ARRAY_SIZE(stac927x_dmux_nids);
  5359. break;
  5360. case STAC_927X_VOLKNOB:
  5361. spec->num_dmics = 0;
  5362. spec->init = stac927x_volknob_core_init;
  5363. break;
  5364. default:
  5365. spec->num_dmics = 0;
  5366. spec->init = stac927x_core_init;
  5367. break;
  5368. }
  5369. spec->num_caps = STAC927X_NUM_CAPS;
  5370. spec->capvols = stac927x_capvols;
  5371. spec->capsws = stac927x_capsws;
  5372. spec->num_pwrs = 0;
  5373. spec->aloopback_ctl = stac927x_loopback;
  5374. spec->aloopback_mask = 0x40;
  5375. spec->aloopback_shift = 0;
  5376. spec->eapd_switch = 1;
  5377. err = stac92xx_parse_auto_config(codec);
  5378. if (!err) {
  5379. if (spec->board_config < 0) {
  5380. printk(KERN_WARNING "hda_codec: No auto-config is "
  5381. "available, default to model=ref\n");
  5382. spec->board_config = STAC_D965_REF;
  5383. goto again;
  5384. }
  5385. err = -EINVAL;
  5386. }
  5387. if (err < 0) {
  5388. stac92xx_free(codec);
  5389. return err;
  5390. }
  5391. codec->patch_ops = stac92xx_patch_ops;
  5392. codec->proc_widget_hook = stac927x_proc_hook;
  5393. /*
  5394. * !!FIXME!!
  5395. * The STAC927x seem to require fairly long delays for certain
  5396. * command sequences. With too short delays (even if the answer
  5397. * is set to RIRB properly), it results in the silence output
  5398. * on some hardwares like Dell.
  5399. *
  5400. * The below flag enables the longer delay (see get_response
  5401. * in hda_intel.c).
  5402. */
  5403. codec->bus->needs_damn_long_delay = 1;
  5404. /* no jack detecion for ref-no-jd model */
  5405. if (spec->board_config == STAC_D965_REF_NO_JD)
  5406. spec->hp_detect = 0;
  5407. return 0;
  5408. }
  5409. static int patch_stac9205(struct hda_codec *codec)
  5410. {
  5411. struct sigmatel_spec *spec;
  5412. int err;
  5413. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5414. if (spec == NULL)
  5415. return -ENOMEM;
  5416. codec->no_trigger_sense = 1;
  5417. codec->spec = spec;
  5418. spec->linear_tone_beep = 1;
  5419. spec->num_pins = ARRAY_SIZE(stac9205_pin_nids);
  5420. spec->pin_nids = stac9205_pin_nids;
  5421. spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
  5422. stac9205_models,
  5423. stac9205_cfg_tbl);
  5424. again:
  5425. if (spec->board_config < 0)
  5426. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  5427. codec->chip_name);
  5428. else
  5429. stac92xx_set_config_regs(codec,
  5430. stac9205_brd_tbl[spec->board_config]);
  5431. spec->digbeep_nid = 0x23;
  5432. spec->adc_nids = stac9205_adc_nids;
  5433. spec->num_adcs = ARRAY_SIZE(stac9205_adc_nids);
  5434. spec->mux_nids = stac9205_mux_nids;
  5435. spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
  5436. spec->smux_nids = stac9205_smux_nids;
  5437. spec->num_smuxes = ARRAY_SIZE(stac9205_smux_nids);
  5438. spec->dmic_nids = stac9205_dmic_nids;
  5439. spec->num_dmics = STAC9205_NUM_DMICS;
  5440. spec->dmux_nids = stac9205_dmux_nids;
  5441. spec->num_dmuxes = ARRAY_SIZE(stac9205_dmux_nids);
  5442. spec->num_pwrs = 0;
  5443. spec->init = stac9205_core_init;
  5444. spec->aloopback_ctl = stac9205_loopback;
  5445. spec->num_caps = STAC9205_NUM_CAPS;
  5446. spec->capvols = stac9205_capvols;
  5447. spec->capsws = stac9205_capsws;
  5448. spec->aloopback_mask = 0x40;
  5449. spec->aloopback_shift = 0;
  5450. /* Turn on/off EAPD per HP plugging */
  5451. if (spec->board_config != STAC_9205_EAPD)
  5452. spec->eapd_switch = 1;
  5453. spec->multiout.dac_nids = spec->dac_nids;
  5454. switch (spec->board_config){
  5455. case STAC_9205_DELL_M43:
  5456. /* Enable SPDIF in/out */
  5457. snd_hda_codec_set_pincfg(codec, 0x1f, 0x01441030);
  5458. snd_hda_codec_set_pincfg(codec, 0x20, 0x1c410030);
  5459. /* Enable unsol response for GPIO4/Dock HP connection */
  5460. err = stac_add_event(codec, codec->afg, STAC_VREF_EVENT, 0x01);
  5461. if (err < 0)
  5462. return err;
  5463. snd_hda_codec_write_cache(codec, codec->afg, 0,
  5464. AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
  5465. snd_hda_jack_detect_enable(codec, codec->afg, 0);
  5466. spec->gpio_dir = 0x0b;
  5467. spec->eapd_mask = 0x01;
  5468. spec->gpio_mask = 0x1b;
  5469. spec->gpio_mute = 0x10;
  5470. /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
  5471. * GPIO3 Low = DRM
  5472. */
  5473. spec->gpio_data = 0x01;
  5474. break;
  5475. case STAC_9205_REF:
  5476. /* SPDIF-In enabled */
  5477. break;
  5478. default:
  5479. /* GPIO0 High = EAPD */
  5480. spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
  5481. spec->gpio_data = 0x01;
  5482. break;
  5483. }
  5484. err = stac92xx_parse_auto_config(codec);
  5485. if (!err) {
  5486. if (spec->board_config < 0) {
  5487. printk(KERN_WARNING "hda_codec: No auto-config is "
  5488. "available, default to model=ref\n");
  5489. spec->board_config = STAC_9205_REF;
  5490. goto again;
  5491. }
  5492. err = -EINVAL;
  5493. }
  5494. if (err < 0) {
  5495. stac92xx_free(codec);
  5496. return err;
  5497. }
  5498. codec->patch_ops = stac92xx_patch_ops;
  5499. codec->proc_widget_hook = stac9205_proc_hook;
  5500. return 0;
  5501. }
  5502. /*
  5503. * STAC9872 hack
  5504. */
  5505. static const struct hda_verb stac9872_core_init[] = {
  5506. {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
  5507. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
  5508. {}
  5509. };
  5510. static const hda_nid_t stac9872_pin_nids[] = {
  5511. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
  5512. 0x11, 0x13, 0x14,
  5513. };
  5514. static const hda_nid_t stac9872_adc_nids[] = {
  5515. 0x8 /*,0x6*/
  5516. };
  5517. static const hda_nid_t stac9872_mux_nids[] = {
  5518. 0x15
  5519. };
  5520. static const unsigned long stac9872_capvols[] = {
  5521. HDA_COMPOSE_AMP_VAL(0x09, 3, 0, HDA_INPUT),
  5522. };
  5523. #define stac9872_capsws stac9872_capvols
  5524. static const unsigned int stac9872_vaio_pin_configs[9] = {
  5525. 0x03211020, 0x411111f0, 0x411111f0, 0x03a15030,
  5526. 0x411111f0, 0x90170110, 0x411111f0, 0x411111f0,
  5527. 0x90a7013e
  5528. };
  5529. static const char * const stac9872_models[STAC_9872_MODELS] = {
  5530. [STAC_9872_AUTO] = "auto",
  5531. [STAC_9872_VAIO] = "vaio",
  5532. };
  5533. static const unsigned int *stac9872_brd_tbl[STAC_9872_MODELS] = {
  5534. [STAC_9872_VAIO] = stac9872_vaio_pin_configs,
  5535. };
  5536. static const struct snd_pci_quirk stac9872_cfg_tbl[] = {
  5537. SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
  5538. "Sony VAIO F/S", STAC_9872_VAIO),
  5539. {} /* terminator */
  5540. };
  5541. static int patch_stac9872(struct hda_codec *codec)
  5542. {
  5543. struct sigmatel_spec *spec;
  5544. int err;
  5545. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5546. if (spec == NULL)
  5547. return -ENOMEM;
  5548. codec->no_trigger_sense = 1;
  5549. codec->spec = spec;
  5550. spec->linear_tone_beep = 1;
  5551. spec->num_pins = ARRAY_SIZE(stac9872_pin_nids);
  5552. spec->pin_nids = stac9872_pin_nids;
  5553. spec->board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
  5554. stac9872_models,
  5555. stac9872_cfg_tbl);
  5556. if (spec->board_config < 0)
  5557. snd_printdd(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  5558. codec->chip_name);
  5559. else
  5560. stac92xx_set_config_regs(codec,
  5561. stac9872_brd_tbl[spec->board_config]);
  5562. spec->multiout.dac_nids = spec->dac_nids;
  5563. spec->num_adcs = ARRAY_SIZE(stac9872_adc_nids);
  5564. spec->adc_nids = stac9872_adc_nids;
  5565. spec->num_muxes = ARRAY_SIZE(stac9872_mux_nids);
  5566. spec->mux_nids = stac9872_mux_nids;
  5567. spec->init = stac9872_core_init;
  5568. spec->num_caps = 1;
  5569. spec->capvols = stac9872_capvols;
  5570. spec->capsws = stac9872_capsws;
  5571. err = stac92xx_parse_auto_config(codec);
  5572. if (err < 0) {
  5573. stac92xx_free(codec);
  5574. return -EINVAL;
  5575. }
  5576. spec->input_mux = &spec->private_imux;
  5577. codec->patch_ops = stac92xx_patch_ops;
  5578. return 0;
  5579. }
  5580. /*
  5581. * patch entries
  5582. */
  5583. static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
  5584. { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
  5585. { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
  5586. { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
  5587. { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
  5588. { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
  5589. { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
  5590. { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
  5591. { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
  5592. { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
  5593. { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
  5594. { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
  5595. { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
  5596. { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
  5597. { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
  5598. { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
  5599. { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
  5600. { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
  5601. { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
  5602. { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
  5603. { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
  5604. { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
  5605. { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
  5606. { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
  5607. { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
  5608. { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
  5609. { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
  5610. { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
  5611. { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
  5612. { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
  5613. { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
  5614. { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
  5615. /* The following does not take into account .id=0x83847661 when subsys =
  5616. * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
  5617. * currently not fully supported.
  5618. */
  5619. { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
  5620. { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
  5621. { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
  5622. { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
  5623. { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
  5624. { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
  5625. { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
  5626. { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
  5627. { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
  5628. { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
  5629. { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
  5630. { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
  5631. { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
  5632. { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
  5633. { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
  5634. { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
  5635. { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
  5636. { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
  5637. { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
  5638. { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
  5639. { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
  5640. { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
  5641. { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
  5642. { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
  5643. { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
  5644. { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
  5645. { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
  5646. { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
  5647. { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
  5648. { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
  5649. { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
  5650. { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
  5651. { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
  5652. { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
  5653. { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
  5654. { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
  5655. { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
  5656. { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
  5657. { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
  5658. { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
  5659. { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
  5660. { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
  5661. { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
  5662. { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
  5663. { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
  5664. { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
  5665. { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
  5666. { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
  5667. { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
  5668. { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
  5669. { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
  5670. { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
  5671. { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
  5672. { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
  5673. { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
  5674. { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
  5675. { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
  5676. { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
  5677. { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
  5678. { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
  5679. { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
  5680. { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
  5681. { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
  5682. { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
  5683. { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
  5684. { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
  5685. { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
  5686. {} /* terminator */
  5687. };
  5688. MODULE_ALIAS("snd-hda-codec-id:8384*");
  5689. MODULE_ALIAS("snd-hda-codec-id:111d*");
  5690. MODULE_LICENSE("GPL");
  5691. MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
  5692. static struct hda_codec_preset_list sigmatel_list = {
  5693. .preset = snd_hda_preset_sigmatel,
  5694. .owner = THIS_MODULE,
  5695. };
  5696. static int __init patch_sigmatel_init(void)
  5697. {
  5698. return snd_hda_add_codec_preset(&sigmatel_list);
  5699. }
  5700. static void __exit patch_sigmatel_exit(void)
  5701. {
  5702. snd_hda_delete_codec_preset(&sigmatel_list);
  5703. }
  5704. module_init(patch_sigmatel_init)
  5705. module_exit(patch_sigmatel_exit)