patch_sigmatel.c 200 KB

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