patch_sigmatel.c 183 KB

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