patch_sigmatel.c 119 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461
  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/jack.h>
  34. #include <sound/tlv.h>
  35. #include "hda_codec.h"
  36. #include "hda_local.h"
  37. #include "hda_auto_parser.h"
  38. #include "hda_beep.h"
  39. #include "hda_jack.h"
  40. #include "hda_generic.h"
  41. enum {
  42. STAC_VREF_EVENT = 8,
  43. STAC_PWR_EVENT,
  44. };
  45. enum {
  46. STAC_REF,
  47. STAC_9200_OQO,
  48. STAC_9200_DELL_D21,
  49. STAC_9200_DELL_D22,
  50. STAC_9200_DELL_D23,
  51. STAC_9200_DELL_M21,
  52. STAC_9200_DELL_M22,
  53. STAC_9200_DELL_M23,
  54. STAC_9200_DELL_M24,
  55. STAC_9200_DELL_M25,
  56. STAC_9200_DELL_M26,
  57. STAC_9200_DELL_M27,
  58. STAC_9200_M4,
  59. STAC_9200_M4_2,
  60. STAC_9200_PANASONIC,
  61. STAC_9200_EAPD_INIT,
  62. STAC_9200_MODELS
  63. };
  64. enum {
  65. STAC_9205_REF,
  66. STAC_9205_DELL_M42,
  67. STAC_9205_DELL_M43,
  68. STAC_9205_DELL_M44,
  69. STAC_9205_EAPD,
  70. STAC_9205_MODELS
  71. };
  72. enum {
  73. STAC_92HD73XX_NO_JD, /* no jack-detection */
  74. STAC_92HD73XX_REF,
  75. STAC_92HD73XX_INTEL,
  76. STAC_DELL_M6_AMIC,
  77. STAC_DELL_M6_DMIC,
  78. STAC_DELL_M6_BOTH,
  79. STAC_DELL_EQ,
  80. STAC_ALIENWARE_M17X,
  81. STAC_92HD73XX_MODELS
  82. };
  83. enum {
  84. STAC_92HD83XXX_REF,
  85. STAC_92HD83XXX_PWR_REF,
  86. STAC_DELL_S14,
  87. STAC_DELL_VOSTRO_3500,
  88. STAC_92HD83XXX_HP_cNB11_INTQUAD,
  89. STAC_HP_DV7_4000,
  90. STAC_HP_ZEPHYR,
  91. STAC_92HD83XXX_HP_LED,
  92. STAC_92HD83XXX_HP_INV_LED,
  93. STAC_92HD83XXX_HP_MIC_LED,
  94. STAC_92HD83XXX_HEADSET_JACK,
  95. STAC_92HD83XXX_HP,
  96. STAC_HP_ENVY_BASS,
  97. STAC_92HD83XXX_MODELS
  98. };
  99. enum {
  100. STAC_92HD71BXX_REF,
  101. STAC_DELL_M4_1,
  102. STAC_DELL_M4_2,
  103. STAC_DELL_M4_3,
  104. STAC_HP_M4,
  105. STAC_HP_DV4,
  106. STAC_HP_DV5,
  107. STAC_HP_HDX,
  108. STAC_92HD71BXX_HP,
  109. STAC_92HD71BXX_NO_DMIC,
  110. STAC_92HD71BXX_NO_SMUX,
  111. STAC_92HD71BXX_MODELS
  112. };
  113. enum {
  114. STAC_925x_REF,
  115. STAC_M1,
  116. STAC_M1_2,
  117. STAC_M2,
  118. STAC_M2_2,
  119. STAC_M3,
  120. STAC_M5,
  121. STAC_M6,
  122. STAC_925x_MODELS
  123. };
  124. enum {
  125. STAC_D945_REF,
  126. STAC_D945GTP3,
  127. STAC_D945GTP5,
  128. STAC_INTEL_MAC_V1,
  129. STAC_INTEL_MAC_V2,
  130. STAC_INTEL_MAC_V3,
  131. STAC_INTEL_MAC_V4,
  132. STAC_INTEL_MAC_V5,
  133. STAC_INTEL_MAC_AUTO,
  134. STAC_ECS_202,
  135. STAC_922X_DELL_D81,
  136. STAC_922X_DELL_D82,
  137. STAC_922X_DELL_M81,
  138. STAC_922X_DELL_M82,
  139. STAC_922X_INTEL_MAC_GPIO,
  140. STAC_922X_MODELS
  141. };
  142. enum {
  143. STAC_D965_REF_NO_JD, /* no jack-detection */
  144. STAC_D965_REF,
  145. STAC_D965_3ST,
  146. STAC_D965_5ST,
  147. STAC_D965_5ST_NO_FP,
  148. STAC_D965_VERBS,
  149. STAC_DELL_3ST,
  150. STAC_DELL_BIOS,
  151. STAC_DELL_BIOS_SPDIF,
  152. STAC_927X_DELL_DMIC,
  153. STAC_927X_VOLKNOB,
  154. STAC_927X_MODELS
  155. };
  156. enum {
  157. STAC_9872_VAIO,
  158. STAC_9872_MODELS
  159. };
  160. struct sigmatel_spec {
  161. struct hda_gen_spec gen;
  162. unsigned int eapd_switch: 1;
  163. unsigned int linear_tone_beep:1;
  164. unsigned int headset_jack:1; /* 4-pin headset jack (hp + mono mic) */
  165. unsigned int volknob_init:1; /* special volume-knob initialization */
  166. unsigned int powerdown_adcs:1;
  167. unsigned int have_spdif_mux:1;
  168. /* gpio lines */
  169. unsigned int eapd_mask;
  170. unsigned int gpio_mask;
  171. unsigned int gpio_dir;
  172. unsigned int gpio_data;
  173. unsigned int gpio_mute;
  174. unsigned int gpio_led;
  175. unsigned int gpio_led_polarity;
  176. unsigned int vref_mute_led_nid; /* pin NID for mute-LED vref control */
  177. unsigned int vref_led;
  178. int default_polarity;
  179. unsigned int mic_mute_led_gpio; /* capture mute LED GPIO */
  180. bool mic_mute_led_on; /* current mic mute state */
  181. /* stream */
  182. unsigned int stream_delay;
  183. /* analog loopback */
  184. const struct snd_kcontrol_new *aloopback_ctl;
  185. unsigned int aloopback;
  186. unsigned char aloopback_mask;
  187. unsigned char aloopback_shift;
  188. /* power management */
  189. unsigned int power_map_bits;
  190. unsigned int num_pwrs;
  191. const hda_nid_t *pwr_nids;
  192. unsigned int active_adcs;
  193. /* beep widgets */
  194. hda_nid_t anabeep_nid;
  195. /* SPDIF-out mux */
  196. const char * const *spdif_labels;
  197. struct hda_input_mux spdif_mux;
  198. unsigned int cur_smux[2];
  199. };
  200. #define AC_VERB_IDT_SET_POWER_MAP 0x7ec
  201. #define AC_VERB_IDT_GET_POWER_MAP 0xfec
  202. static const hda_nid_t stac92hd73xx_pwr_nids[8] = {
  203. 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
  204. 0x0f, 0x10, 0x11
  205. };
  206. static const hda_nid_t stac92hd83xxx_pwr_nids[7] = {
  207. 0x0a, 0x0b, 0x0c, 0xd, 0x0e,
  208. 0x0f, 0x10
  209. };
  210. static const hda_nid_t stac92hd71bxx_pwr_nids[3] = {
  211. 0x0a, 0x0d, 0x0f
  212. };
  213. /*
  214. * PCM hooks
  215. */
  216. static void stac_playback_pcm_hook(struct hda_pcm_stream *hinfo,
  217. struct hda_codec *codec,
  218. struct snd_pcm_substream *substream,
  219. int action)
  220. {
  221. struct sigmatel_spec *spec = codec->spec;
  222. if (action == HDA_GEN_PCM_ACT_OPEN && spec->stream_delay)
  223. msleep(spec->stream_delay);
  224. }
  225. static void stac_capture_pcm_hook(struct hda_pcm_stream *hinfo,
  226. struct hda_codec *codec,
  227. struct snd_pcm_substream *substream,
  228. int action)
  229. {
  230. struct sigmatel_spec *spec = codec->spec;
  231. int i, idx = 0;
  232. if (!spec->powerdown_adcs)
  233. return;
  234. for (i = 0; i < spec->gen.num_all_adcs; i++) {
  235. if (spec->gen.all_adcs[i] == hinfo->nid) {
  236. idx = i;
  237. break;
  238. }
  239. }
  240. switch (action) {
  241. case HDA_GEN_PCM_ACT_OPEN:
  242. msleep(40);
  243. snd_hda_codec_write(codec, hinfo->nid, 0,
  244. AC_VERB_SET_POWER_STATE, AC_PWRST_D0);
  245. spec->active_adcs |= (1 << idx);
  246. break;
  247. case HDA_GEN_PCM_ACT_CLOSE:
  248. snd_hda_codec_write(codec, hinfo->nid, 0,
  249. AC_VERB_SET_POWER_STATE, AC_PWRST_D3);
  250. spec->active_adcs &= ~(1 << idx);
  251. break;
  252. }
  253. }
  254. /*
  255. * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
  256. * funky external mute control using GPIO pins.
  257. */
  258. static void stac_gpio_set(struct hda_codec *codec, unsigned int mask,
  259. unsigned int dir_mask, unsigned int data)
  260. {
  261. unsigned int gpiostate, gpiomask, gpiodir;
  262. snd_printdd("%s msk %x dir %x gpio %x\n", __func__, mask, dir_mask, data);
  263. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  264. AC_VERB_GET_GPIO_DATA, 0);
  265. gpiostate = (gpiostate & ~dir_mask) | (data & dir_mask);
  266. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  267. AC_VERB_GET_GPIO_MASK, 0);
  268. gpiomask |= mask;
  269. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  270. AC_VERB_GET_GPIO_DIRECTION, 0);
  271. gpiodir |= dir_mask;
  272. /* Configure GPIOx as CMOS */
  273. snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
  274. snd_hda_codec_write(codec, codec->afg, 0,
  275. AC_VERB_SET_GPIO_MASK, gpiomask);
  276. snd_hda_codec_read(codec, codec->afg, 0,
  277. AC_VERB_SET_GPIO_DIRECTION, gpiodir); /* sync */
  278. msleep(1);
  279. snd_hda_codec_read(codec, codec->afg, 0,
  280. AC_VERB_SET_GPIO_DATA, gpiostate); /* sync */
  281. }
  282. /* hook for controlling mic-mute LED GPIO */
  283. static void stac_capture_led_hook(struct hda_codec *codec,
  284. struct snd_ctl_elem_value *ucontrol)
  285. {
  286. struct sigmatel_spec *spec = codec->spec;
  287. bool mute;
  288. if (!ucontrol)
  289. return;
  290. mute = !(ucontrol->value.integer.value[0] ||
  291. ucontrol->value.integer.value[1]);
  292. if (spec->mic_mute_led_on != mute) {
  293. spec->mic_mute_led_on = mute;
  294. if (mute)
  295. spec->gpio_data |= spec->mic_mute_led_gpio;
  296. else
  297. spec->gpio_data &= ~spec->mic_mute_led_gpio;
  298. stac_gpio_set(codec, spec->gpio_mask,
  299. spec->gpio_dir, spec->gpio_data);
  300. }
  301. }
  302. static int stac_vrefout_set(struct hda_codec *codec,
  303. hda_nid_t nid, unsigned int new_vref)
  304. {
  305. int error, pinctl;
  306. snd_printdd("%s, nid %x ctl %x\n", __func__, nid, new_vref);
  307. pinctl = snd_hda_codec_read(codec, nid, 0,
  308. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  309. if (pinctl < 0)
  310. return pinctl;
  311. pinctl &= 0xff;
  312. pinctl &= ~AC_PINCTL_VREFEN;
  313. pinctl |= (new_vref & AC_PINCTL_VREFEN);
  314. error = snd_hda_set_pin_ctl_cache(codec, nid, pinctl);
  315. if (error < 0)
  316. return error;
  317. return 1;
  318. }
  319. /* update mute-LED accoring to the master switch */
  320. static void stac_update_led_status(struct hda_codec *codec, int enabled)
  321. {
  322. struct sigmatel_spec *spec = codec->spec;
  323. int muted = !enabled;
  324. if (!spec->gpio_led)
  325. return;
  326. /* LED state is inverted on these systems */
  327. if (spec->gpio_led_polarity)
  328. muted = !muted;
  329. if (!spec->vref_mute_led_nid) {
  330. if (muted)
  331. spec->gpio_data |= spec->gpio_led;
  332. else
  333. spec->gpio_data &= ~spec->gpio_led;
  334. stac_gpio_set(codec, spec->gpio_mask,
  335. spec->gpio_dir, spec->gpio_data);
  336. } else {
  337. spec->vref_led = muted ? AC_PINCTL_VREF_50 : AC_PINCTL_VREF_GRD;
  338. stac_vrefout_set(codec, spec->vref_mute_led_nid,
  339. spec->vref_led);
  340. }
  341. }
  342. /* vmaster hook to update mute LED */
  343. static void stac_vmaster_hook(void *private_data, int val)
  344. {
  345. stac_update_led_status(private_data, val);
  346. }
  347. /* automute hook to handle GPIO mute and EAPD updates */
  348. static void stac_update_outputs(struct hda_codec *codec)
  349. {
  350. struct sigmatel_spec *spec = codec->spec;
  351. if (spec->gpio_mute)
  352. spec->gen.master_mute =
  353. !(snd_hda_codec_read(codec, codec->afg, 0,
  354. AC_VERB_GET_GPIO_DATA, 0) & spec->gpio_mute);
  355. snd_hda_gen_update_outputs(codec);
  356. if (spec->eapd_mask && spec->eapd_switch) {
  357. unsigned int val = spec->gpio_data;
  358. if (spec->gen.speaker_muted)
  359. val &= ~spec->eapd_mask;
  360. else
  361. val |= spec->eapd_mask;
  362. if (spec->gpio_data != val) {
  363. spec->gpio_data = val;
  364. stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir,
  365. val);
  366. }
  367. }
  368. }
  369. static void stac_toggle_power_map(struct hda_codec *codec, hda_nid_t nid,
  370. bool enable, bool do_write)
  371. {
  372. struct sigmatel_spec *spec = codec->spec;
  373. unsigned int idx, val;
  374. for (idx = 0; idx < spec->num_pwrs; idx++) {
  375. if (spec->pwr_nids[idx] == nid)
  376. break;
  377. }
  378. if (idx >= spec->num_pwrs)
  379. return;
  380. idx = 1 << idx;
  381. val = spec->power_map_bits;
  382. if (enable)
  383. val &= ~idx;
  384. else
  385. val |= idx;
  386. /* power down unused output ports */
  387. if (val != spec->power_map_bits) {
  388. spec->power_map_bits = val;
  389. if (do_write)
  390. snd_hda_codec_write(codec, codec->afg, 0,
  391. AC_VERB_IDT_SET_POWER_MAP, val);
  392. }
  393. }
  394. /* update power bit per jack plug/unplug */
  395. static void jack_update_power(struct hda_codec *codec,
  396. struct hda_jack_tbl *jack)
  397. {
  398. struct sigmatel_spec *spec = codec->spec;
  399. int i;
  400. if (!spec->num_pwrs)
  401. return;
  402. if (jack && jack->nid) {
  403. stac_toggle_power_map(codec, jack->nid,
  404. snd_hda_jack_detect(codec, jack->nid),
  405. true);
  406. return;
  407. }
  408. /* update all jacks */
  409. for (i = 0; i < spec->num_pwrs; i++) {
  410. hda_nid_t nid = spec->pwr_nids[i];
  411. jack = snd_hda_jack_tbl_get(codec, nid);
  412. if (!jack || !jack->action)
  413. continue;
  414. if (jack->action == STAC_PWR_EVENT ||
  415. jack->action <= HDA_GEN_LAST_EVENT)
  416. stac_toggle_power_map(codec, nid,
  417. snd_hda_jack_detect(codec, nid),
  418. false);
  419. }
  420. snd_hda_codec_write(codec, codec->afg, 0, AC_VERB_IDT_SET_POWER_MAP,
  421. spec->power_map_bits);
  422. }
  423. static void stac_hp_automute(struct hda_codec *codec,
  424. struct hda_jack_tbl *jack)
  425. {
  426. snd_hda_gen_hp_automute(codec, jack);
  427. jack_update_power(codec, jack);
  428. }
  429. static void stac_line_automute(struct hda_codec *codec,
  430. struct hda_jack_tbl *jack)
  431. {
  432. snd_hda_gen_line_automute(codec, jack);
  433. jack_update_power(codec, jack);
  434. }
  435. static void stac_mic_autoswitch(struct hda_codec *codec,
  436. struct hda_jack_tbl *jack)
  437. {
  438. snd_hda_gen_mic_autoswitch(codec, jack);
  439. jack_update_power(codec, jack);
  440. }
  441. static void stac_vref_event(struct hda_codec *codec, struct hda_jack_tbl *event)
  442. {
  443. unsigned int data;
  444. data = snd_hda_codec_read(codec, codec->afg, 0,
  445. AC_VERB_GET_GPIO_DATA, 0);
  446. /* toggle VREF state based on GPIOx status */
  447. snd_hda_codec_write(codec, codec->afg, 0, 0x7e0,
  448. !!(data & (1 << event->private_data)));
  449. }
  450. /* initialize the power map and enable the power event to jacks that
  451. * haven't been assigned to automute
  452. */
  453. static void stac_init_power_map(struct hda_codec *codec)
  454. {
  455. struct sigmatel_spec *spec = codec->spec;
  456. int i;
  457. for (i = 0; i < spec->num_pwrs; i++) {
  458. hda_nid_t nid = spec->pwr_nids[i];
  459. unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid);
  460. def_conf = get_defcfg_connect(def_conf);
  461. if (snd_hda_jack_tbl_get(codec, nid))
  462. continue;
  463. if (def_conf == AC_JACK_PORT_COMPLEX &&
  464. !(spec->vref_mute_led_nid == nid ||
  465. is_jack_detectable(codec, nid))) {
  466. snd_hda_jack_detect_enable_callback(codec, nid,
  467. STAC_PWR_EVENT,
  468. jack_update_power);
  469. } else {
  470. if (def_conf == AC_JACK_PORT_NONE)
  471. stac_toggle_power_map(codec, nid, false, false);
  472. else
  473. stac_toggle_power_map(codec, nid, true, false);
  474. }
  475. }
  476. }
  477. /*
  478. */
  479. static inline bool get_int_hint(struct hda_codec *codec, const char *key,
  480. int *valp)
  481. {
  482. return !snd_hda_get_int_hint(codec, key, valp);
  483. }
  484. /* override some hints from the hwdep entry */
  485. static void stac_store_hints(struct hda_codec *codec)
  486. {
  487. struct sigmatel_spec *spec = codec->spec;
  488. int val;
  489. if (get_int_hint(codec, "gpio_mask", &spec->gpio_mask)) {
  490. spec->eapd_mask = spec->gpio_dir = spec->gpio_data =
  491. spec->gpio_mask;
  492. }
  493. if (get_int_hint(codec, "gpio_dir", &spec->gpio_dir))
  494. spec->gpio_mask &= spec->gpio_mask;
  495. if (get_int_hint(codec, "gpio_data", &spec->gpio_data))
  496. spec->gpio_dir &= spec->gpio_mask;
  497. if (get_int_hint(codec, "eapd_mask", &spec->eapd_mask))
  498. spec->eapd_mask &= spec->gpio_mask;
  499. if (get_int_hint(codec, "gpio_mute", &spec->gpio_mute))
  500. spec->gpio_mute &= spec->gpio_mask;
  501. val = snd_hda_get_bool_hint(codec, "eapd_switch");
  502. if (val >= 0)
  503. spec->eapd_switch = val;
  504. }
  505. /*
  506. * loopback controls
  507. */
  508. #define stac_aloopback_info snd_ctl_boolean_mono_info
  509. static int stac_aloopback_get(struct snd_kcontrol *kcontrol,
  510. struct snd_ctl_elem_value *ucontrol)
  511. {
  512. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  513. unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  514. struct sigmatel_spec *spec = codec->spec;
  515. ucontrol->value.integer.value[0] = !!(spec->aloopback &
  516. (spec->aloopback_mask << idx));
  517. return 0;
  518. }
  519. static int stac_aloopback_put(struct snd_kcontrol *kcontrol,
  520. struct snd_ctl_elem_value *ucontrol)
  521. {
  522. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  523. struct sigmatel_spec *spec = codec->spec;
  524. unsigned int idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  525. unsigned int dac_mode;
  526. unsigned int val, idx_val;
  527. idx_val = spec->aloopback_mask << idx;
  528. if (ucontrol->value.integer.value[0])
  529. val = spec->aloopback | idx_val;
  530. else
  531. val = spec->aloopback & ~idx_val;
  532. if (spec->aloopback == val)
  533. return 0;
  534. spec->aloopback = val;
  535. /* Only return the bits defined by the shift value of the
  536. * first two bytes of the mask
  537. */
  538. dac_mode = snd_hda_codec_read(codec, codec->afg, 0,
  539. kcontrol->private_value & 0xFFFF, 0x0);
  540. dac_mode >>= spec->aloopback_shift;
  541. if (spec->aloopback & idx_val) {
  542. snd_hda_power_up(codec);
  543. dac_mode |= idx_val;
  544. } else {
  545. snd_hda_power_down(codec);
  546. dac_mode &= ~idx_val;
  547. }
  548. snd_hda_codec_write_cache(codec, codec->afg, 0,
  549. kcontrol->private_value >> 16, dac_mode);
  550. return 1;
  551. }
  552. #define STAC_ANALOG_LOOPBACK(verb_read, verb_write, cnt) \
  553. { \
  554. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  555. .name = "Analog Loopback", \
  556. .count = cnt, \
  557. .info = stac_aloopback_info, \
  558. .get = stac_aloopback_get, \
  559. .put = stac_aloopback_put, \
  560. .private_value = verb_read | (verb_write << 16), \
  561. }
  562. /*
  563. * Mute LED handling on HP laptops
  564. */
  565. /* check whether it's a HP laptop with a docking port */
  566. static bool hp_bnb2011_with_dock(struct hda_codec *codec)
  567. {
  568. if (codec->vendor_id != 0x111d7605 &&
  569. codec->vendor_id != 0x111d76d1)
  570. return false;
  571. switch (codec->subsystem_id) {
  572. case 0x103c1618:
  573. case 0x103c1619:
  574. case 0x103c161a:
  575. case 0x103c161b:
  576. case 0x103c161c:
  577. case 0x103c161d:
  578. case 0x103c161e:
  579. case 0x103c161f:
  580. case 0x103c162a:
  581. case 0x103c162b:
  582. case 0x103c1630:
  583. case 0x103c1631:
  584. case 0x103c1633:
  585. case 0x103c1634:
  586. case 0x103c1635:
  587. case 0x103c3587:
  588. case 0x103c3588:
  589. case 0x103c3589:
  590. case 0x103c358a:
  591. case 0x103c3667:
  592. case 0x103c3668:
  593. case 0x103c3669:
  594. return true;
  595. }
  596. return false;
  597. }
  598. static bool hp_blike_system(u32 subsystem_id)
  599. {
  600. switch (subsystem_id) {
  601. case 0x103c1520:
  602. case 0x103c1521:
  603. case 0x103c1523:
  604. case 0x103c1524:
  605. case 0x103c1525:
  606. case 0x103c1722:
  607. case 0x103c1723:
  608. case 0x103c1724:
  609. case 0x103c1725:
  610. case 0x103c1726:
  611. case 0x103c1727:
  612. case 0x103c1728:
  613. case 0x103c1729:
  614. case 0x103c172a:
  615. case 0x103c172b:
  616. case 0x103c307e:
  617. case 0x103c307f:
  618. case 0x103c3080:
  619. case 0x103c3081:
  620. case 0x103c7007:
  621. case 0x103c7008:
  622. return true;
  623. }
  624. return false;
  625. }
  626. static void set_hp_led_gpio(struct hda_codec *codec)
  627. {
  628. struct sigmatel_spec *spec = codec->spec;
  629. unsigned int gpio;
  630. if (spec->gpio_led)
  631. return;
  632. gpio = snd_hda_param_read(codec, codec->afg, AC_PAR_GPIO_CAP);
  633. gpio &= AC_GPIO_IO_COUNT;
  634. if (gpio > 3)
  635. spec->gpio_led = 0x08; /* GPIO 3 */
  636. else
  637. spec->gpio_led = 0x01; /* GPIO 0 */
  638. }
  639. /*
  640. * This method searches for the mute LED GPIO configuration
  641. * provided as OEM string in SMBIOS. The format of that string
  642. * is HP_Mute_LED_P_G or HP_Mute_LED_P
  643. * where P can be 0 or 1 and defines mute LED GPIO control state (low/high)
  644. * that corresponds to the NOT muted state of the master volume
  645. * and G is the index of the GPIO to use as the mute LED control (0..9)
  646. * If _G portion is missing it is assigned based on the codec ID
  647. *
  648. * So, HP B-series like systems may have HP_Mute_LED_0 (current models)
  649. * or HP_Mute_LED_0_3 (future models) OEM SMBIOS strings
  650. *
  651. *
  652. * The dv-series laptops don't seem to have the HP_Mute_LED* strings in
  653. * SMBIOS - at least the ones I have seen do not have them - which include
  654. * my own system (HP Pavilion dv6-1110ax) and my cousin's
  655. * HP Pavilion dv9500t CTO.
  656. * Need more information on whether it is true across the entire series.
  657. * -- kunal
  658. */
  659. static int find_mute_led_cfg(struct hda_codec *codec, int default_polarity)
  660. {
  661. struct sigmatel_spec *spec = codec->spec;
  662. const struct dmi_device *dev = NULL;
  663. if (get_int_hint(codec, "gpio_led", &spec->gpio_led)) {
  664. get_int_hint(codec, "gpio_led_polarity",
  665. &spec->gpio_led_polarity);
  666. return 1;
  667. }
  668. while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
  669. if (sscanf(dev->name, "HP_Mute_LED_%d_%x",
  670. &spec->gpio_led_polarity,
  671. &spec->gpio_led) == 2) {
  672. unsigned int max_gpio;
  673. max_gpio = snd_hda_param_read(codec, codec->afg,
  674. AC_PAR_GPIO_CAP);
  675. max_gpio &= AC_GPIO_IO_COUNT;
  676. if (spec->gpio_led < max_gpio)
  677. spec->gpio_led = 1 << spec->gpio_led;
  678. else
  679. spec->vref_mute_led_nid = spec->gpio_led;
  680. return 1;
  681. }
  682. if (sscanf(dev->name, "HP_Mute_LED_%d",
  683. &spec->gpio_led_polarity) == 1) {
  684. set_hp_led_gpio(codec);
  685. return 1;
  686. }
  687. /* BIOS bug: unfilled OEM string */
  688. if (strstr(dev->name, "HP_Mute_LED_P_G")) {
  689. set_hp_led_gpio(codec);
  690. if (default_polarity >= 0)
  691. spec->gpio_led_polarity = default_polarity;
  692. else
  693. spec->gpio_led_polarity = 1;
  694. return 1;
  695. }
  696. }
  697. /*
  698. * Fallback case - if we don't find the DMI strings,
  699. * we statically set the GPIO - if not a B-series system
  700. * and default polarity is provided
  701. */
  702. if (!hp_blike_system(codec->subsystem_id) &&
  703. (default_polarity == 0 || default_polarity == 1)) {
  704. set_hp_led_gpio(codec);
  705. spec->gpio_led_polarity = default_polarity;
  706. return 1;
  707. }
  708. return 0;
  709. }
  710. /* check whether a built-in speaker is included in parsed pins */
  711. static bool has_builtin_speaker(struct hda_codec *codec)
  712. {
  713. struct sigmatel_spec *spec = codec->spec;
  714. hda_nid_t *nid_pin;
  715. int nids, i;
  716. if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT) {
  717. nid_pin = spec->gen.autocfg.line_out_pins;
  718. nids = spec->gen.autocfg.line_outs;
  719. } else {
  720. nid_pin = spec->gen.autocfg.speaker_pins;
  721. nids = spec->gen.autocfg.speaker_outs;
  722. }
  723. for (i = 0; i < nids; i++) {
  724. unsigned int def_conf = snd_hda_codec_get_pincfg(codec, nid_pin[i]);
  725. if (snd_hda_get_input_pin_attr(def_conf) == INPUT_PIN_ATTR_INT)
  726. return true;
  727. }
  728. return false;
  729. }
  730. /*
  731. * PC beep controls
  732. */
  733. /* create PC beep volume controls */
  734. static int stac_auto_create_beep_ctls(struct hda_codec *codec,
  735. hda_nid_t nid)
  736. {
  737. struct sigmatel_spec *spec = codec->spec;
  738. u32 caps = query_amp_caps(codec, nid, HDA_OUTPUT);
  739. struct snd_kcontrol_new *knew;
  740. static struct snd_kcontrol_new abeep_mute_ctl =
  741. HDA_CODEC_MUTE(NULL, 0, 0, 0);
  742. static struct snd_kcontrol_new dbeep_mute_ctl =
  743. HDA_CODEC_MUTE_BEEP(NULL, 0, 0, 0);
  744. static struct snd_kcontrol_new beep_vol_ctl =
  745. HDA_CODEC_VOLUME(NULL, 0, 0, 0);
  746. /* check for mute support for the the amp */
  747. if ((caps & AC_AMPCAP_MUTE) >> AC_AMPCAP_MUTE_SHIFT) {
  748. const struct snd_kcontrol_new *temp;
  749. if (spec->anabeep_nid == nid)
  750. temp = &abeep_mute_ctl;
  751. else
  752. temp = &dbeep_mute_ctl;
  753. knew = snd_hda_gen_add_kctl(&spec->gen,
  754. "Beep Playback Switch", temp);
  755. if (!knew)
  756. return -ENOMEM;
  757. knew->private_value =
  758. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT);
  759. }
  760. /* check to see if there is volume support for the amp */
  761. if ((caps & AC_AMPCAP_NUM_STEPS) >> AC_AMPCAP_NUM_STEPS_SHIFT) {
  762. knew = snd_hda_gen_add_kctl(&spec->gen,
  763. "Beep Playback Volume",
  764. &beep_vol_ctl);
  765. if (!knew)
  766. return -ENOMEM;
  767. knew->private_value =
  768. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT);
  769. }
  770. return 0;
  771. }
  772. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  773. #define stac_dig_beep_switch_info snd_ctl_boolean_mono_info
  774. static int stac_dig_beep_switch_get(struct snd_kcontrol *kcontrol,
  775. struct snd_ctl_elem_value *ucontrol)
  776. {
  777. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  778. ucontrol->value.integer.value[0] = codec->beep->enabled;
  779. return 0;
  780. }
  781. static int stac_dig_beep_switch_put(struct snd_kcontrol *kcontrol,
  782. struct snd_ctl_elem_value *ucontrol)
  783. {
  784. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  785. return snd_hda_enable_beep_device(codec, ucontrol->value.integer.value[0]);
  786. }
  787. static const struct snd_kcontrol_new stac_dig_beep_ctrl = {
  788. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  789. .name = "Beep Playback Switch",
  790. .info = stac_dig_beep_switch_info,
  791. .get = stac_dig_beep_switch_get,
  792. .put = stac_dig_beep_switch_put,
  793. };
  794. static int stac_beep_switch_ctl(struct hda_codec *codec)
  795. {
  796. struct sigmatel_spec *spec = codec->spec;
  797. if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &stac_dig_beep_ctrl))
  798. return -ENOMEM;
  799. return 0;
  800. }
  801. #endif
  802. /*
  803. * SPDIF-out mux controls
  804. */
  805. static int stac_smux_enum_info(struct snd_kcontrol *kcontrol,
  806. struct snd_ctl_elem_info *uinfo)
  807. {
  808. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  809. struct sigmatel_spec *spec = codec->spec;
  810. return snd_hda_input_mux_info(&spec->spdif_mux, uinfo);
  811. }
  812. static int stac_smux_enum_get(struct snd_kcontrol *kcontrol,
  813. struct snd_ctl_elem_value *ucontrol)
  814. {
  815. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  816. struct sigmatel_spec *spec = codec->spec;
  817. unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  818. ucontrol->value.enumerated.item[0] = spec->cur_smux[smux_idx];
  819. return 0;
  820. }
  821. static int stac_smux_enum_put(struct snd_kcontrol *kcontrol,
  822. struct snd_ctl_elem_value *ucontrol)
  823. {
  824. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  825. struct sigmatel_spec *spec = codec->spec;
  826. unsigned int smux_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  827. return snd_hda_input_mux_put(codec, &spec->spdif_mux, ucontrol,
  828. spec->gen.autocfg.dig_out_pins[smux_idx],
  829. &spec->cur_smux[smux_idx]);
  830. }
  831. static struct snd_kcontrol_new stac_smux_mixer = {
  832. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  833. .name = "IEC958 Playback Source",
  834. /* count set later */
  835. .info = stac_smux_enum_info,
  836. .get = stac_smux_enum_get,
  837. .put = stac_smux_enum_put,
  838. };
  839. static const char * const stac_spdif_labels[] = {
  840. "Digital Playback", "Analog Mux 1", "Analog Mux 2", NULL
  841. };
  842. static int stac_create_spdif_mux_ctls(struct hda_codec *codec)
  843. {
  844. struct sigmatel_spec *spec = codec->spec;
  845. struct auto_pin_cfg *cfg = &spec->gen.autocfg;
  846. const char * const *labels = spec->spdif_labels;
  847. struct snd_kcontrol_new *kctl;
  848. int i, num_cons;
  849. if (cfg->dig_outs < 1)
  850. return 0;
  851. num_cons = snd_hda_get_num_conns(codec, cfg->dig_out_pins[0]);
  852. if (num_cons <= 1)
  853. return 0;
  854. if (!labels)
  855. labels = stac_spdif_labels;
  856. for (i = 0; i < num_cons; i++) {
  857. if (snd_BUG_ON(!labels[i]))
  858. return -EINVAL;
  859. snd_hda_add_imux_item(&spec->spdif_mux, labels[i], i, NULL);
  860. }
  861. kctl = snd_hda_gen_add_kctl(&spec->gen, NULL, &stac_smux_mixer);
  862. if (!kctl)
  863. return -ENOMEM;
  864. kctl->count = cfg->dig_outs;
  865. return 0;
  866. }
  867. /*
  868. */
  869. static const struct hda_verb stac9200_core_init[] = {
  870. /* set dac0mux for dac converter */
  871. { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  872. {}
  873. };
  874. static const struct hda_verb stac9200_eapd_init[] = {
  875. /* set dac0mux for dac converter */
  876. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  877. {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  878. {}
  879. };
  880. static const struct hda_verb dell_eq_core_init[] = {
  881. /* set master volume to max value without distortion
  882. * and direct control */
  883. { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xec},
  884. {}
  885. };
  886. static const struct hda_verb stac92hd73xx_core_init[] = {
  887. /* set master volume and direct control */
  888. { 0x1f, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  889. {}
  890. };
  891. static const struct hda_verb stac92hd83xxx_core_init[] = {
  892. /* power state controls amps */
  893. { 0x01, AC_VERB_SET_EAPD, 1 << 2},
  894. {}
  895. };
  896. static const struct hda_verb stac92hd83xxx_hp_zephyr_init[] = {
  897. { 0x22, 0x785, 0x43 },
  898. { 0x22, 0x782, 0xe0 },
  899. { 0x22, 0x795, 0x00 },
  900. {}
  901. };
  902. static const struct hda_verb stac92hd71bxx_core_init[] = {
  903. /* set master volume and direct control */
  904. { 0x28, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  905. {}
  906. };
  907. static const struct hda_verb stac92hd71bxx_unmute_core_init[] = {
  908. /* unmute right and left channels for nodes 0x0f, 0xa, 0x0d */
  909. { 0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  910. { 0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  911. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  912. {}
  913. };
  914. static const struct hda_verb stac925x_core_init[] = {
  915. /* set dac0mux for dac converter */
  916. { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
  917. /* mute the master volume */
  918. { 0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  919. {}
  920. };
  921. static const struct hda_verb stac922x_core_init[] = {
  922. /* set master volume and direct control */
  923. { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  924. {}
  925. };
  926. static const struct hda_verb d965_core_init[] = {
  927. /* unmute node 0x1b */
  928. { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  929. /* select node 0x03 as DAC */
  930. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
  931. {}
  932. };
  933. static const struct hda_verb dell_3st_core_init[] = {
  934. /* don't set delta bit */
  935. {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
  936. /* unmute node 0x1b */
  937. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  938. /* select node 0x03 as DAC */
  939. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
  940. {}
  941. };
  942. static const struct hda_verb stac927x_core_init[] = {
  943. /* set master volume and direct control */
  944. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  945. /* enable analog pc beep path */
  946. { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
  947. {}
  948. };
  949. static const struct hda_verb stac927x_volknob_core_init[] = {
  950. /* don't set delta bit */
  951. {0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0x7f},
  952. /* enable analog pc beep path */
  953. {0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
  954. {}
  955. };
  956. static const struct hda_verb stac9205_core_init[] = {
  957. /* set master volume and direct control */
  958. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  959. /* enable analog pc beep path */
  960. { 0x01, AC_VERB_SET_DIGI_CONVERT_2, 1 << 5},
  961. {}
  962. };
  963. static const struct snd_kcontrol_new stac92hd73xx_6ch_loopback =
  964. STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 3);
  965. static const struct snd_kcontrol_new stac92hd73xx_8ch_loopback =
  966. STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 4);
  967. static const struct snd_kcontrol_new stac92hd73xx_10ch_loopback =
  968. STAC_ANALOG_LOOPBACK(0xFA0, 0x7A1, 5);
  969. static const struct snd_kcontrol_new stac92hd71bxx_loopback =
  970. STAC_ANALOG_LOOPBACK(0xFA0, 0x7A0, 2);
  971. static const struct snd_kcontrol_new stac9205_loopback =
  972. STAC_ANALOG_LOOPBACK(0xFE0, 0x7E0, 1);
  973. static const struct snd_kcontrol_new stac927x_loopback =
  974. STAC_ANALOG_LOOPBACK(0xFEB, 0x7EB, 1);
  975. static const struct hda_pintbl ref9200_pin_configs[] = {
  976. { 0x08, 0x01c47010 },
  977. { 0x09, 0x01447010 },
  978. { 0x0d, 0x0221401f },
  979. { 0x0e, 0x01114010 },
  980. { 0x0f, 0x02a19020 },
  981. { 0x10, 0x01a19021 },
  982. { 0x11, 0x90100140 },
  983. { 0x12, 0x01813122 },
  984. {}
  985. };
  986. static const struct hda_pintbl gateway9200_m4_pin_configs[] = {
  987. { 0x08, 0x400000fe },
  988. { 0x09, 0x404500f4 },
  989. { 0x0d, 0x400100f0 },
  990. { 0x0e, 0x90110010 },
  991. { 0x0f, 0x400100f1 },
  992. { 0x10, 0x02a1902e },
  993. { 0x11, 0x500000f2 },
  994. { 0x12, 0x500000f3 },
  995. {}
  996. };
  997. static const struct hda_pintbl gateway9200_m4_2_pin_configs[] = {
  998. { 0x08, 0x400000fe },
  999. { 0x09, 0x404500f4 },
  1000. { 0x0d, 0x400100f0 },
  1001. { 0x0e, 0x90110010 },
  1002. { 0x0f, 0x400100f1 },
  1003. { 0x10, 0x02a1902e },
  1004. { 0x11, 0x500000f2 },
  1005. { 0x12, 0x500000f3 },
  1006. {}
  1007. };
  1008. /*
  1009. STAC 9200 pin configs for
  1010. 102801A8
  1011. 102801DE
  1012. 102801E8
  1013. */
  1014. static const struct hda_pintbl dell9200_d21_pin_configs[] = {
  1015. { 0x08, 0x400001f0 },
  1016. { 0x09, 0x400001f1 },
  1017. { 0x0d, 0x02214030 },
  1018. { 0x0e, 0x01014010 },
  1019. { 0x0f, 0x02a19020 },
  1020. { 0x10, 0x01a19021 },
  1021. { 0x11, 0x90100140 },
  1022. { 0x12, 0x01813122 },
  1023. {}
  1024. };
  1025. /*
  1026. STAC 9200 pin configs for
  1027. 102801C0
  1028. 102801C1
  1029. */
  1030. static const struct hda_pintbl dell9200_d22_pin_configs[] = {
  1031. { 0x08, 0x400001f0 },
  1032. { 0x09, 0x400001f1 },
  1033. { 0x0d, 0x0221401f },
  1034. { 0x0e, 0x01014010 },
  1035. { 0x0f, 0x01813020 },
  1036. { 0x10, 0x02a19021 },
  1037. { 0x11, 0x90100140 },
  1038. { 0x12, 0x400001f2 },
  1039. {}
  1040. };
  1041. /*
  1042. STAC 9200 pin configs for
  1043. 102801C4 (Dell Dimension E310)
  1044. 102801C5
  1045. 102801C7
  1046. 102801D9
  1047. 102801DA
  1048. 102801E3
  1049. */
  1050. static const struct hda_pintbl dell9200_d23_pin_configs[] = {
  1051. { 0x08, 0x400001f0 },
  1052. { 0x09, 0x400001f1 },
  1053. { 0x0d, 0x0221401f },
  1054. { 0x0e, 0x01014010 },
  1055. { 0x0f, 0x01813020 },
  1056. { 0x10, 0x01a19021 },
  1057. { 0x11, 0x90100140 },
  1058. { 0x12, 0x400001f2 },
  1059. {}
  1060. };
  1061. /*
  1062. STAC 9200-32 pin configs for
  1063. 102801B5 (Dell Inspiron 630m)
  1064. 102801D8 (Dell Inspiron 640m)
  1065. */
  1066. static const struct hda_pintbl dell9200_m21_pin_configs[] = {
  1067. { 0x08, 0x40c003fa },
  1068. { 0x09, 0x03441340 },
  1069. { 0x0d, 0x0321121f },
  1070. { 0x0e, 0x90170310 },
  1071. { 0x0f, 0x408003fb },
  1072. { 0x10, 0x03a11020 },
  1073. { 0x11, 0x401003fc },
  1074. { 0x12, 0x403003fd },
  1075. {}
  1076. };
  1077. /*
  1078. STAC 9200-32 pin configs for
  1079. 102801C2 (Dell Latitude D620)
  1080. 102801C8
  1081. 102801CC (Dell Latitude D820)
  1082. 102801D4
  1083. 102801D6
  1084. */
  1085. static const struct hda_pintbl dell9200_m22_pin_configs[] = {
  1086. { 0x08, 0x40c003fa },
  1087. { 0x09, 0x0144131f },
  1088. { 0x0d, 0x0321121f },
  1089. { 0x0e, 0x90170310 },
  1090. { 0x0f, 0x90a70321 },
  1091. { 0x10, 0x03a11020 },
  1092. { 0x11, 0x401003fb },
  1093. { 0x12, 0x40f000fc },
  1094. {}
  1095. };
  1096. /*
  1097. STAC 9200-32 pin configs for
  1098. 102801CE (Dell XPS M1710)
  1099. 102801CF (Dell Precision M90)
  1100. */
  1101. static const struct hda_pintbl dell9200_m23_pin_configs[] = {
  1102. { 0x08, 0x40c003fa },
  1103. { 0x09, 0x01441340 },
  1104. { 0x0d, 0x0421421f },
  1105. { 0x0e, 0x90170310 },
  1106. { 0x0f, 0x408003fb },
  1107. { 0x10, 0x04a1102e },
  1108. { 0x11, 0x90170311 },
  1109. { 0x12, 0x403003fc },
  1110. {}
  1111. };
  1112. /*
  1113. STAC 9200-32 pin configs for
  1114. 102801C9
  1115. 102801CA
  1116. 102801CB (Dell Latitude 120L)
  1117. 102801D3
  1118. */
  1119. static const struct hda_pintbl dell9200_m24_pin_configs[] = {
  1120. { 0x08, 0x40c003fa },
  1121. { 0x09, 0x404003fb },
  1122. { 0x0d, 0x0321121f },
  1123. { 0x0e, 0x90170310 },
  1124. { 0x0f, 0x408003fc },
  1125. { 0x10, 0x03a11020 },
  1126. { 0x11, 0x401003fd },
  1127. { 0x12, 0x403003fe },
  1128. {}
  1129. };
  1130. /*
  1131. STAC 9200-32 pin configs for
  1132. 102801BD (Dell Inspiron E1505n)
  1133. 102801EE
  1134. 102801EF
  1135. */
  1136. static const struct hda_pintbl dell9200_m25_pin_configs[] = {
  1137. { 0x08, 0x40c003fa },
  1138. { 0x09, 0x01441340 },
  1139. { 0x0d, 0x0421121f },
  1140. { 0x0e, 0x90170310 },
  1141. { 0x0f, 0x408003fb },
  1142. { 0x10, 0x04a11020 },
  1143. { 0x11, 0x401003fc },
  1144. { 0x12, 0x403003fd },
  1145. {}
  1146. };
  1147. /*
  1148. STAC 9200-32 pin configs for
  1149. 102801F5 (Dell Inspiron 1501)
  1150. 102801F6
  1151. */
  1152. static const struct hda_pintbl dell9200_m26_pin_configs[] = {
  1153. { 0x08, 0x40c003fa },
  1154. { 0x09, 0x404003fb },
  1155. { 0x0d, 0x0421121f },
  1156. { 0x0e, 0x90170310 },
  1157. { 0x0f, 0x408003fc },
  1158. { 0x10, 0x04a11020 },
  1159. { 0x11, 0x401003fd },
  1160. { 0x12, 0x403003fe },
  1161. {}
  1162. };
  1163. /*
  1164. STAC 9200-32
  1165. 102801CD (Dell Inspiron E1705/9400)
  1166. */
  1167. static const struct hda_pintbl dell9200_m27_pin_configs[] = {
  1168. { 0x08, 0x40c003fa },
  1169. { 0x09, 0x01441340 },
  1170. { 0x0d, 0x0421121f },
  1171. { 0x0e, 0x90170310 },
  1172. { 0x0f, 0x90170310 },
  1173. { 0x10, 0x04a11020 },
  1174. { 0x11, 0x90170310 },
  1175. { 0x12, 0x40f003fc },
  1176. {}
  1177. };
  1178. static const struct hda_pintbl oqo9200_pin_configs[] = {
  1179. { 0x08, 0x40c000f0 },
  1180. { 0x09, 0x404000f1 },
  1181. { 0x0d, 0x0221121f },
  1182. { 0x0e, 0x02211210 },
  1183. { 0x0f, 0x90170111 },
  1184. { 0x10, 0x90a70120 },
  1185. { 0x11, 0x400000f2 },
  1186. { 0x12, 0x400000f3 },
  1187. {}
  1188. };
  1189. static void stac9200_fixup_panasonic(struct hda_codec *codec,
  1190. const struct hda_fixup *fix, int action)
  1191. {
  1192. struct sigmatel_spec *spec = codec->spec;
  1193. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  1194. spec->gpio_mask = spec->gpio_dir = 0x09;
  1195. spec->gpio_data = 0x00;
  1196. /* CF-74 has no headphone detection, and the driver should *NOT*
  1197. * do detection and HP/speaker toggle because the hardware does it.
  1198. */
  1199. spec->gen.suppress_auto_mute = 1;
  1200. }
  1201. }
  1202. static const struct hda_fixup stac9200_fixups[] = {
  1203. [STAC_REF] = {
  1204. .type = HDA_FIXUP_PINS,
  1205. .v.pins = ref9200_pin_configs,
  1206. },
  1207. [STAC_9200_OQO] = {
  1208. .type = HDA_FIXUP_PINS,
  1209. .v.pins = oqo9200_pin_configs,
  1210. .chained = true,
  1211. .chain_id = STAC_9200_EAPD_INIT,
  1212. },
  1213. [STAC_9200_DELL_D21] = {
  1214. .type = HDA_FIXUP_PINS,
  1215. .v.pins = dell9200_d21_pin_configs,
  1216. },
  1217. [STAC_9200_DELL_D22] = {
  1218. .type = HDA_FIXUP_PINS,
  1219. .v.pins = dell9200_d22_pin_configs,
  1220. },
  1221. [STAC_9200_DELL_D23] = {
  1222. .type = HDA_FIXUP_PINS,
  1223. .v.pins = dell9200_d23_pin_configs,
  1224. },
  1225. [STAC_9200_DELL_M21] = {
  1226. .type = HDA_FIXUP_PINS,
  1227. .v.pins = dell9200_m21_pin_configs,
  1228. },
  1229. [STAC_9200_DELL_M22] = {
  1230. .type = HDA_FIXUP_PINS,
  1231. .v.pins = dell9200_m22_pin_configs,
  1232. },
  1233. [STAC_9200_DELL_M23] = {
  1234. .type = HDA_FIXUP_PINS,
  1235. .v.pins = dell9200_m23_pin_configs,
  1236. },
  1237. [STAC_9200_DELL_M24] = {
  1238. .type = HDA_FIXUP_PINS,
  1239. .v.pins = dell9200_m24_pin_configs,
  1240. },
  1241. [STAC_9200_DELL_M25] = {
  1242. .type = HDA_FIXUP_PINS,
  1243. .v.pins = dell9200_m25_pin_configs,
  1244. },
  1245. [STAC_9200_DELL_M26] = {
  1246. .type = HDA_FIXUP_PINS,
  1247. .v.pins = dell9200_m26_pin_configs,
  1248. },
  1249. [STAC_9200_DELL_M27] = {
  1250. .type = HDA_FIXUP_PINS,
  1251. .v.pins = dell9200_m27_pin_configs,
  1252. },
  1253. [STAC_9200_M4] = {
  1254. .type = HDA_FIXUP_PINS,
  1255. .v.pins = gateway9200_m4_pin_configs,
  1256. .chained = true,
  1257. .chain_id = STAC_9200_EAPD_INIT,
  1258. },
  1259. [STAC_9200_M4_2] = {
  1260. .type = HDA_FIXUP_PINS,
  1261. .v.pins = gateway9200_m4_2_pin_configs,
  1262. .chained = true,
  1263. .chain_id = STAC_9200_EAPD_INIT,
  1264. },
  1265. [STAC_9200_PANASONIC] = {
  1266. .type = HDA_FIXUP_FUNC,
  1267. .v.func = stac9200_fixup_panasonic,
  1268. },
  1269. [STAC_9200_EAPD_INIT] = {
  1270. .type = HDA_FIXUP_VERBS,
  1271. .v.verbs = (const struct hda_verb[]) {
  1272. {0x08, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  1273. {}
  1274. },
  1275. },
  1276. };
  1277. static const struct hda_model_fixup stac9200_models[] = {
  1278. { .id = STAC_REF, .name = "ref" },
  1279. { .id = STAC_9200_OQO, .name = "oqo" },
  1280. { .id = STAC_9200_DELL_D21, .name = "dell-d21" },
  1281. { .id = STAC_9200_DELL_D22, .name = "dell-d22" },
  1282. { .id = STAC_9200_DELL_D23, .name = "dell-d23" },
  1283. { .id = STAC_9200_DELL_M21, .name = "dell-m21" },
  1284. { .id = STAC_9200_DELL_M22, .name = "dell-m22" },
  1285. { .id = STAC_9200_DELL_M23, .name = "dell-m23" },
  1286. { .id = STAC_9200_DELL_M24, .name = "dell-m24" },
  1287. { .id = STAC_9200_DELL_M25, .name = "dell-m25" },
  1288. { .id = STAC_9200_DELL_M26, .name = "dell-m26" },
  1289. { .id = STAC_9200_DELL_M27, .name = "dell-m27" },
  1290. { .id = STAC_9200_M4, .name = "gateway-m4" },
  1291. { .id = STAC_9200_M4_2, .name = "gateway-m4-2" },
  1292. { .id = STAC_9200_PANASONIC, .name = "panasonic" },
  1293. {}
  1294. };
  1295. static const struct snd_pci_quirk stac9200_fixup_tbl[] = {
  1296. /* SigmaTel reference board */
  1297. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1298. "DFI LanParty", STAC_REF),
  1299. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1300. "DFI LanParty", STAC_REF),
  1301. /* Dell laptops have BIOS problem */
  1302. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a8,
  1303. "unknown Dell", STAC_9200_DELL_D21),
  1304. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
  1305. "Dell Inspiron 630m", STAC_9200_DELL_M21),
  1306. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bd,
  1307. "Dell Inspiron E1505n", STAC_9200_DELL_M25),
  1308. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c0,
  1309. "unknown Dell", STAC_9200_DELL_D22),
  1310. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c1,
  1311. "unknown Dell", STAC_9200_DELL_D22),
  1312. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
  1313. "Dell Latitude D620", STAC_9200_DELL_M22),
  1314. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c5,
  1315. "unknown Dell", STAC_9200_DELL_D23),
  1316. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c7,
  1317. "unknown Dell", STAC_9200_DELL_D23),
  1318. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c8,
  1319. "unknown Dell", STAC_9200_DELL_M22),
  1320. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c9,
  1321. "unknown Dell", STAC_9200_DELL_M24),
  1322. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ca,
  1323. "unknown Dell", STAC_9200_DELL_M24),
  1324. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
  1325. "Dell Latitude 120L", STAC_9200_DELL_M24),
  1326. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
  1327. "Dell Latitude D820", STAC_9200_DELL_M22),
  1328. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
  1329. "Dell Inspiron E1705/9400", STAC_9200_DELL_M27),
  1330. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
  1331. "Dell XPS M1710", STAC_9200_DELL_M23),
  1332. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
  1333. "Dell Precision M90", STAC_9200_DELL_M23),
  1334. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d3,
  1335. "unknown Dell", STAC_9200_DELL_M22),
  1336. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d4,
  1337. "unknown Dell", STAC_9200_DELL_M22),
  1338. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
  1339. "unknown Dell", STAC_9200_DELL_M22),
  1340. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
  1341. "Dell Inspiron 640m", STAC_9200_DELL_M21),
  1342. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d9,
  1343. "unknown Dell", STAC_9200_DELL_D23),
  1344. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01da,
  1345. "unknown Dell", STAC_9200_DELL_D23),
  1346. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01de,
  1347. "unknown Dell", STAC_9200_DELL_D21),
  1348. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e3,
  1349. "unknown Dell", STAC_9200_DELL_D23),
  1350. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01e8,
  1351. "unknown Dell", STAC_9200_DELL_D21),
  1352. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ee,
  1353. "unknown Dell", STAC_9200_DELL_M25),
  1354. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ef,
  1355. "unknown Dell", STAC_9200_DELL_M25),
  1356. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
  1357. "Dell Inspiron 1501", STAC_9200_DELL_M26),
  1358. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f6,
  1359. "unknown Dell", STAC_9200_DELL_M26),
  1360. /* Panasonic */
  1361. SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_9200_PANASONIC),
  1362. /* Gateway machines needs EAPD to be set on resume */
  1363. SND_PCI_QUIRK(0x107b, 0x0205, "Gateway S-7110M", STAC_9200_M4),
  1364. SND_PCI_QUIRK(0x107b, 0x0317, "Gateway MT3423, MX341*", STAC_9200_M4_2),
  1365. SND_PCI_QUIRK(0x107b, 0x0318, "Gateway ML3019, MT3707", STAC_9200_M4_2),
  1366. /* OQO Mobile */
  1367. SND_PCI_QUIRK(0x1106, 0x3288, "OQO Model 2", STAC_9200_OQO),
  1368. {} /* terminator */
  1369. };
  1370. static const struct hda_pintbl ref925x_pin_configs[] = {
  1371. { 0x07, 0x40c003f0 },
  1372. { 0x08, 0x424503f2 },
  1373. { 0x0a, 0x01813022 },
  1374. { 0x0b, 0x02a19021 },
  1375. { 0x0c, 0x90a70320 },
  1376. { 0x0d, 0x02214210 },
  1377. { 0x10, 0x01019020 },
  1378. { 0x11, 0x9033032e },
  1379. {}
  1380. };
  1381. static const struct hda_pintbl stac925xM1_pin_configs[] = {
  1382. { 0x07, 0x40c003f4 },
  1383. { 0x08, 0x424503f2 },
  1384. { 0x0a, 0x400000f3 },
  1385. { 0x0b, 0x02a19020 },
  1386. { 0x0c, 0x40a000f0 },
  1387. { 0x0d, 0x90100210 },
  1388. { 0x10, 0x400003f1 },
  1389. { 0x11, 0x9033032e },
  1390. {}
  1391. };
  1392. static const struct hda_pintbl stac925xM1_2_pin_configs[] = {
  1393. { 0x07, 0x40c003f4 },
  1394. { 0x08, 0x424503f2 },
  1395. { 0x0a, 0x400000f3 },
  1396. { 0x0b, 0x02a19020 },
  1397. { 0x0c, 0x40a000f0 },
  1398. { 0x0d, 0x90100210 },
  1399. { 0x10, 0x400003f1 },
  1400. { 0x11, 0x9033032e },
  1401. {}
  1402. };
  1403. static const struct hda_pintbl stac925xM2_pin_configs[] = {
  1404. { 0x07, 0x40c003f4 },
  1405. { 0x08, 0x424503f2 },
  1406. { 0x0a, 0x400000f3 },
  1407. { 0x0b, 0x02a19020 },
  1408. { 0x0c, 0x40a000f0 },
  1409. { 0x0d, 0x90100210 },
  1410. { 0x10, 0x400003f1 },
  1411. { 0x11, 0x9033032e },
  1412. {}
  1413. };
  1414. static const struct hda_pintbl stac925xM2_2_pin_configs[] = {
  1415. { 0x07, 0x40c003f4 },
  1416. { 0x08, 0x424503f2 },
  1417. { 0x0a, 0x400000f3 },
  1418. { 0x0b, 0x02a19020 },
  1419. { 0x0c, 0x40a000f0 },
  1420. { 0x0d, 0x90100210 },
  1421. { 0x10, 0x400003f1 },
  1422. { 0x11, 0x9033032e },
  1423. {}
  1424. };
  1425. static const struct hda_pintbl stac925xM3_pin_configs[] = {
  1426. { 0x07, 0x40c003f4 },
  1427. { 0x08, 0x424503f2 },
  1428. { 0x0a, 0x400000f3 },
  1429. { 0x0b, 0x02a19020 },
  1430. { 0x0c, 0x40a000f0 },
  1431. { 0x0d, 0x90100210 },
  1432. { 0x10, 0x400003f1 },
  1433. { 0x11, 0x503303f3 },
  1434. {}
  1435. };
  1436. static const struct hda_pintbl stac925xM5_pin_configs[] = {
  1437. { 0x07, 0x40c003f4 },
  1438. { 0x08, 0x424503f2 },
  1439. { 0x0a, 0x400000f3 },
  1440. { 0x0b, 0x02a19020 },
  1441. { 0x0c, 0x40a000f0 },
  1442. { 0x0d, 0x90100210 },
  1443. { 0x10, 0x400003f1 },
  1444. { 0x11, 0x9033032e },
  1445. {}
  1446. };
  1447. static const struct hda_pintbl stac925xM6_pin_configs[] = {
  1448. { 0x07, 0x40c003f4 },
  1449. { 0x08, 0x424503f2 },
  1450. { 0x0a, 0x400000f3 },
  1451. { 0x0b, 0x02a19020 },
  1452. { 0x0c, 0x40a000f0 },
  1453. { 0x0d, 0x90100210 },
  1454. { 0x10, 0x400003f1 },
  1455. { 0x11, 0x90330320 },
  1456. {}
  1457. };
  1458. static const struct hda_fixup stac925x_fixups[] = {
  1459. [STAC_REF] = {
  1460. .type = HDA_FIXUP_PINS,
  1461. .v.pins = ref925x_pin_configs,
  1462. },
  1463. [STAC_M1] = {
  1464. .type = HDA_FIXUP_PINS,
  1465. .v.pins = stac925xM1_pin_configs,
  1466. },
  1467. [STAC_M1_2] = {
  1468. .type = HDA_FIXUP_PINS,
  1469. .v.pins = stac925xM1_2_pin_configs,
  1470. },
  1471. [STAC_M2] = {
  1472. .type = HDA_FIXUP_PINS,
  1473. .v.pins = stac925xM2_pin_configs,
  1474. },
  1475. [STAC_M2_2] = {
  1476. .type = HDA_FIXUP_PINS,
  1477. .v.pins = stac925xM2_2_pin_configs,
  1478. },
  1479. [STAC_M3] = {
  1480. .type = HDA_FIXUP_PINS,
  1481. .v.pins = stac925xM3_pin_configs,
  1482. },
  1483. [STAC_M5] = {
  1484. .type = HDA_FIXUP_PINS,
  1485. .v.pins = stac925xM5_pin_configs,
  1486. },
  1487. [STAC_M6] = {
  1488. .type = HDA_FIXUP_PINS,
  1489. .v.pins = stac925xM6_pin_configs,
  1490. },
  1491. };
  1492. static const struct hda_model_fixup stac925x_models[] = {
  1493. { .id = STAC_REF, .name = "ref" },
  1494. { .id = STAC_M1, .name = "m1" },
  1495. { .id = STAC_M1_2, .name = "m1-2" },
  1496. { .id = STAC_M2, .name = "m2" },
  1497. { .id = STAC_M2_2, .name = "m2-2" },
  1498. { .id = STAC_M3, .name = "m3" },
  1499. { .id = STAC_M5, .name = "m5" },
  1500. { .id = STAC_M6, .name = "m6" },
  1501. {}
  1502. };
  1503. static const struct snd_pci_quirk stac925x_fixup_tbl[] = {
  1504. /* SigmaTel reference board */
  1505. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
  1506. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101, "DFI LanParty", STAC_REF),
  1507. SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
  1508. /* Default table for unknown ID */
  1509. SND_PCI_QUIRK(0x1002, 0x437b, "Gateway mobile", STAC_M2_2),
  1510. /* gateway machines are checked via codec ssid */
  1511. SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_M2),
  1512. SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_M5),
  1513. SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_M1),
  1514. SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_M2),
  1515. SND_PCI_QUIRK(0x107b, 0x0367, "Gateway MX6453", STAC_M1_2),
  1516. /* Not sure about the brand name for those */
  1517. SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M1),
  1518. SND_PCI_QUIRK(0x107b, 0x0507, "Gateway mobile", STAC_M3),
  1519. SND_PCI_QUIRK(0x107b, 0x0281, "Gateway mobile", STAC_M6),
  1520. SND_PCI_QUIRK(0x107b, 0x0685, "Gateway mobile", STAC_M2_2),
  1521. {} /* terminator */
  1522. };
  1523. static const struct hda_pintbl ref92hd73xx_pin_configs[] = {
  1524. { 0x0a, 0x02214030 },
  1525. { 0x0b, 0x02a19040 },
  1526. { 0x0c, 0x01a19020 },
  1527. { 0x0d, 0x02214030 },
  1528. { 0x0e, 0x0181302e },
  1529. { 0x0f, 0x01014010 },
  1530. { 0x10, 0x01014020 },
  1531. { 0x11, 0x01014030 },
  1532. { 0x12, 0x02319040 },
  1533. { 0x13, 0x90a000f0 },
  1534. { 0x14, 0x90a000f0 },
  1535. { 0x22, 0x01452050 },
  1536. { 0x23, 0x01452050 },
  1537. {}
  1538. };
  1539. static const struct hda_pintbl dell_m6_pin_configs[] = {
  1540. { 0x0a, 0x0321101f },
  1541. { 0x0b, 0x4f00000f },
  1542. { 0x0c, 0x4f0000f0 },
  1543. { 0x0d, 0x90170110 },
  1544. { 0x0e, 0x03a11020 },
  1545. { 0x0f, 0x0321101f },
  1546. { 0x10, 0x4f0000f0 },
  1547. { 0x11, 0x4f0000f0 },
  1548. { 0x12, 0x4f0000f0 },
  1549. { 0x13, 0x90a60160 },
  1550. { 0x14, 0x4f0000f0 },
  1551. { 0x22, 0x4f0000f0 },
  1552. { 0x23, 0x4f0000f0 },
  1553. {}
  1554. };
  1555. static const struct hda_pintbl alienware_m17x_pin_configs[] = {
  1556. { 0x0a, 0x0321101f },
  1557. { 0x0b, 0x0321101f },
  1558. { 0x0c, 0x03a11020 },
  1559. { 0x0d, 0x03014020 },
  1560. { 0x0e, 0x90170110 },
  1561. { 0x0f, 0x4f0000f0 },
  1562. { 0x10, 0x4f0000f0 },
  1563. { 0x11, 0x4f0000f0 },
  1564. { 0x12, 0x4f0000f0 },
  1565. { 0x13, 0x90a60160 },
  1566. { 0x14, 0x4f0000f0 },
  1567. { 0x22, 0x4f0000f0 },
  1568. { 0x23, 0x904601b0 },
  1569. {}
  1570. };
  1571. static const struct hda_pintbl intel_dg45id_pin_configs[] = {
  1572. { 0x0a, 0x02214230 },
  1573. { 0x0b, 0x02A19240 },
  1574. { 0x0c, 0x01013214 },
  1575. { 0x0d, 0x01014210 },
  1576. { 0x0e, 0x01A19250 },
  1577. { 0x0f, 0x01011212 },
  1578. { 0x10, 0x01016211 },
  1579. {}
  1580. };
  1581. static void stac92hd73xx_fixup_ref(struct hda_codec *codec,
  1582. const struct hda_fixup *fix, int action)
  1583. {
  1584. struct sigmatel_spec *spec = codec->spec;
  1585. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  1586. return;
  1587. snd_hda_apply_pincfgs(codec, ref92hd73xx_pin_configs);
  1588. spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
  1589. }
  1590. static void stac92hd73xx_fixup_dell(struct hda_codec *codec)
  1591. {
  1592. struct sigmatel_spec *spec = codec->spec;
  1593. snd_hda_apply_pincfgs(codec, dell_m6_pin_configs);
  1594. spec->eapd_switch = 0;
  1595. }
  1596. static void stac92hd73xx_fixup_dell_eq(struct hda_codec *codec,
  1597. const struct hda_fixup *fix, int action)
  1598. {
  1599. struct sigmatel_spec *spec = codec->spec;
  1600. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  1601. return;
  1602. stac92hd73xx_fixup_dell(codec);
  1603. snd_hda_add_verbs(codec, dell_eq_core_init);
  1604. spec->volknob_init = 1;
  1605. }
  1606. /* Analog Mics */
  1607. static void stac92hd73xx_fixup_dell_m6_amic(struct hda_codec *codec,
  1608. const struct hda_fixup *fix, int action)
  1609. {
  1610. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  1611. return;
  1612. stac92hd73xx_fixup_dell(codec);
  1613. snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
  1614. }
  1615. /* Digital Mics */
  1616. static void stac92hd73xx_fixup_dell_m6_dmic(struct hda_codec *codec,
  1617. const struct hda_fixup *fix, int action)
  1618. {
  1619. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  1620. return;
  1621. stac92hd73xx_fixup_dell(codec);
  1622. snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
  1623. }
  1624. /* Both */
  1625. static void stac92hd73xx_fixup_dell_m6_both(struct hda_codec *codec,
  1626. const struct hda_fixup *fix, int action)
  1627. {
  1628. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  1629. return;
  1630. stac92hd73xx_fixup_dell(codec);
  1631. snd_hda_codec_set_pincfg(codec, 0x0b, 0x90A70170);
  1632. snd_hda_codec_set_pincfg(codec, 0x13, 0x90A60160);
  1633. }
  1634. static void stac92hd73xx_fixup_alienware_m17x(struct hda_codec *codec,
  1635. const struct hda_fixup *fix, int action)
  1636. {
  1637. struct sigmatel_spec *spec = codec->spec;
  1638. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  1639. return;
  1640. snd_hda_apply_pincfgs(codec, alienware_m17x_pin_configs);
  1641. spec->eapd_switch = 0;
  1642. }
  1643. static void stac92hd73xx_fixup_no_jd(struct hda_codec *codec,
  1644. const struct hda_fixup *fix, int action)
  1645. {
  1646. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  1647. codec->no_jack_detect = 1;
  1648. }
  1649. static const struct hda_fixup stac92hd73xx_fixups[] = {
  1650. [STAC_92HD73XX_REF] = {
  1651. .type = HDA_FIXUP_FUNC,
  1652. .v.func = stac92hd73xx_fixup_ref,
  1653. },
  1654. [STAC_DELL_M6_AMIC] = {
  1655. .type = HDA_FIXUP_FUNC,
  1656. .v.func = stac92hd73xx_fixup_dell_m6_amic,
  1657. },
  1658. [STAC_DELL_M6_DMIC] = {
  1659. .type = HDA_FIXUP_FUNC,
  1660. .v.func = stac92hd73xx_fixup_dell_m6_dmic,
  1661. },
  1662. [STAC_DELL_M6_BOTH] = {
  1663. .type = HDA_FIXUP_FUNC,
  1664. .v.func = stac92hd73xx_fixup_dell_m6_both,
  1665. },
  1666. [STAC_DELL_EQ] = {
  1667. .type = HDA_FIXUP_FUNC,
  1668. .v.func = stac92hd73xx_fixup_dell_eq,
  1669. },
  1670. [STAC_ALIENWARE_M17X] = {
  1671. .type = HDA_FIXUP_FUNC,
  1672. .v.func = stac92hd73xx_fixup_alienware_m17x,
  1673. },
  1674. [STAC_92HD73XX_INTEL] = {
  1675. .type = HDA_FIXUP_PINS,
  1676. .v.pins = intel_dg45id_pin_configs,
  1677. },
  1678. [STAC_92HD73XX_NO_JD] = {
  1679. .type = HDA_FIXUP_FUNC,
  1680. .v.func = stac92hd73xx_fixup_no_jd,
  1681. }
  1682. };
  1683. static const struct hda_model_fixup stac92hd73xx_models[] = {
  1684. { .id = STAC_92HD73XX_NO_JD, .name = "no-jd" },
  1685. { .id = STAC_92HD73XX_REF, .name = "ref" },
  1686. { .id = STAC_92HD73XX_INTEL, .name = "intel" },
  1687. { .id = STAC_DELL_M6_AMIC, .name = "dell-m6-amic" },
  1688. { .id = STAC_DELL_M6_DMIC, .name = "dell-m6-dmic" },
  1689. { .id = STAC_DELL_M6_BOTH, .name = "dell-m6" },
  1690. { .id = STAC_DELL_EQ, .name = "dell-eq" },
  1691. { .id = STAC_ALIENWARE_M17X, .name = "alienware" },
  1692. {}
  1693. };
  1694. static const struct snd_pci_quirk stac92hd73xx_fixup_tbl[] = {
  1695. /* SigmaTel reference board */
  1696. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1697. "DFI LanParty", STAC_92HD73XX_REF),
  1698. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1699. "DFI LanParty", STAC_92HD73XX_REF),
  1700. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5002,
  1701. "Intel DG45ID", STAC_92HD73XX_INTEL),
  1702. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5003,
  1703. "Intel DG45FC", STAC_92HD73XX_INTEL),
  1704. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0254,
  1705. "Dell Studio 1535", STAC_DELL_M6_DMIC),
  1706. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0255,
  1707. "unknown Dell", STAC_DELL_M6_DMIC),
  1708. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0256,
  1709. "unknown Dell", STAC_DELL_M6_BOTH),
  1710. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0257,
  1711. "unknown Dell", STAC_DELL_M6_BOTH),
  1712. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025e,
  1713. "unknown Dell", STAC_DELL_M6_AMIC),
  1714. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x025f,
  1715. "unknown Dell", STAC_DELL_M6_AMIC),
  1716. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0271,
  1717. "unknown Dell", STAC_DELL_M6_DMIC),
  1718. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0272,
  1719. "unknown Dell", STAC_DELL_M6_DMIC),
  1720. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x029f,
  1721. "Dell Studio 1537", STAC_DELL_M6_DMIC),
  1722. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a0,
  1723. "Dell Studio 17", STAC_DELL_M6_DMIC),
  1724. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02be,
  1725. "Dell Studio 1555", STAC_DELL_M6_DMIC),
  1726. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02bd,
  1727. "Dell Studio 1557", STAC_DELL_M6_DMIC),
  1728. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02fe,
  1729. "Dell Studio XPS 1645", STAC_DELL_M6_DMIC),
  1730. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0413,
  1731. "Dell Studio 1558", STAC_DELL_M6_DMIC),
  1732. /* codec SSID matching */
  1733. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02a1,
  1734. "Alienware M17x", STAC_ALIENWARE_M17X),
  1735. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x043a,
  1736. "Alienware M17x", STAC_ALIENWARE_M17X),
  1737. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0490,
  1738. "Alienware M17x R3", STAC_DELL_EQ),
  1739. {} /* terminator */
  1740. };
  1741. static const struct hda_pintbl ref92hd83xxx_pin_configs[] = {
  1742. { 0x0a, 0x02214030 },
  1743. { 0x0b, 0x02211010 },
  1744. { 0x0c, 0x02a19020 },
  1745. { 0x0d, 0x02170130 },
  1746. { 0x0e, 0x01014050 },
  1747. { 0x0f, 0x01819040 },
  1748. { 0x10, 0x01014020 },
  1749. { 0x11, 0x90a3014e },
  1750. { 0x1f, 0x01451160 },
  1751. { 0x20, 0x98560170 },
  1752. {}
  1753. };
  1754. static const struct hda_pintbl dell_s14_pin_configs[] = {
  1755. { 0x0a, 0x0221403f },
  1756. { 0x0b, 0x0221101f },
  1757. { 0x0c, 0x02a19020 },
  1758. { 0x0d, 0x90170110 },
  1759. { 0x0e, 0x40f000f0 },
  1760. { 0x0f, 0x40f000f0 },
  1761. { 0x10, 0x40f000f0 },
  1762. { 0x11, 0x90a60160 },
  1763. { 0x1f, 0x40f000f0 },
  1764. { 0x20, 0x40f000f0 },
  1765. {}
  1766. };
  1767. static const struct hda_pintbl dell_vostro_3500_pin_configs[] = {
  1768. { 0x0a, 0x02a11020 },
  1769. { 0x0b, 0x0221101f },
  1770. { 0x0c, 0x400000f0 },
  1771. { 0x0d, 0x90170110 },
  1772. { 0x0e, 0x400000f1 },
  1773. { 0x0f, 0x400000f2 },
  1774. { 0x10, 0x400000f3 },
  1775. { 0x11, 0x90a60160 },
  1776. { 0x1f, 0x400000f4 },
  1777. { 0x20, 0x400000f5 },
  1778. {}
  1779. };
  1780. static const struct hda_pintbl hp_dv7_4000_pin_configs[] = {
  1781. { 0x0a, 0x03a12050 },
  1782. { 0x0b, 0x0321201f },
  1783. { 0x0c, 0x40f000f0 },
  1784. { 0x0d, 0x90170110 },
  1785. { 0x0e, 0x40f000f0 },
  1786. { 0x0f, 0x40f000f0 },
  1787. { 0x10, 0x90170110 },
  1788. { 0x11, 0xd5a30140 },
  1789. { 0x1f, 0x40f000f0 },
  1790. { 0x20, 0x40f000f0 },
  1791. {}
  1792. };
  1793. static const struct hda_pintbl hp_zephyr_pin_configs[] = {
  1794. { 0x0a, 0x01813050 },
  1795. { 0x0b, 0x0421201f },
  1796. { 0x0c, 0x04a1205e },
  1797. { 0x0d, 0x96130310 },
  1798. { 0x0e, 0x96130310 },
  1799. { 0x0f, 0x0101401f },
  1800. { 0x10, 0x1111611f },
  1801. { 0x11, 0xd5a30130 },
  1802. {}
  1803. };
  1804. static const struct hda_pintbl hp_cNB11_intquad_pin_configs[] = {
  1805. { 0x0a, 0x40f000f0 },
  1806. { 0x0b, 0x0221101f },
  1807. { 0x0c, 0x02a11020 },
  1808. { 0x0d, 0x92170110 },
  1809. { 0x0e, 0x40f000f0 },
  1810. { 0x0f, 0x92170110 },
  1811. { 0x10, 0x40f000f0 },
  1812. { 0x11, 0xd5a30130 },
  1813. { 0x1f, 0x40f000f0 },
  1814. { 0x20, 0x40f000f0 },
  1815. {}
  1816. };
  1817. static void stac92hd83xxx_fixup_hp(struct hda_codec *codec,
  1818. const struct hda_fixup *fix, int action)
  1819. {
  1820. struct sigmatel_spec *spec = codec->spec;
  1821. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  1822. return;
  1823. if (hp_bnb2011_with_dock(codec)) {
  1824. snd_hda_codec_set_pincfg(codec, 0xa, 0x2101201f);
  1825. snd_hda_codec_set_pincfg(codec, 0xf, 0x2181205e);
  1826. }
  1827. if (find_mute_led_cfg(codec, spec->default_polarity))
  1828. snd_printd("mute LED gpio %d polarity %d\n",
  1829. spec->gpio_led,
  1830. spec->gpio_led_polarity);
  1831. }
  1832. static void stac92hd83xxx_fixup_hp_zephyr(struct hda_codec *codec,
  1833. const struct hda_fixup *fix, int action)
  1834. {
  1835. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  1836. return;
  1837. snd_hda_apply_pincfgs(codec, hp_zephyr_pin_configs);
  1838. snd_hda_add_verbs(codec, stac92hd83xxx_hp_zephyr_init);
  1839. }
  1840. static void stac92hd83xxx_fixup_hp_led(struct hda_codec *codec,
  1841. const struct hda_fixup *fix, int action)
  1842. {
  1843. struct sigmatel_spec *spec = codec->spec;
  1844. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  1845. spec->default_polarity = 0;
  1846. }
  1847. static void stac92hd83xxx_fixup_hp_inv_led(struct hda_codec *codec,
  1848. const struct hda_fixup *fix, int action)
  1849. {
  1850. struct sigmatel_spec *spec = codec->spec;
  1851. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  1852. spec->default_polarity = 1;
  1853. }
  1854. static void stac92hd83xxx_fixup_hp_mic_led(struct hda_codec *codec,
  1855. const struct hda_fixup *fix, int action)
  1856. {
  1857. struct sigmatel_spec *spec = codec->spec;
  1858. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  1859. spec->mic_mute_led_gpio = 0x08; /* GPIO3 */
  1860. }
  1861. static void stac92hd83xxx_fixup_headset_jack(struct hda_codec *codec,
  1862. const struct hda_fixup *fix, int action)
  1863. {
  1864. struct sigmatel_spec *spec = codec->spec;
  1865. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  1866. spec->headset_jack = 1;
  1867. }
  1868. static const struct hda_fixup stac92hd83xxx_fixups[] = {
  1869. [STAC_92HD83XXX_REF] = {
  1870. .type = HDA_FIXUP_PINS,
  1871. .v.pins = ref92hd83xxx_pin_configs,
  1872. },
  1873. [STAC_92HD83XXX_PWR_REF] = {
  1874. .type = HDA_FIXUP_PINS,
  1875. .v.pins = ref92hd83xxx_pin_configs,
  1876. },
  1877. [STAC_DELL_S14] = {
  1878. .type = HDA_FIXUP_PINS,
  1879. .v.pins = dell_s14_pin_configs,
  1880. },
  1881. [STAC_DELL_VOSTRO_3500] = {
  1882. .type = HDA_FIXUP_PINS,
  1883. .v.pins = dell_vostro_3500_pin_configs,
  1884. },
  1885. [STAC_92HD83XXX_HP_cNB11_INTQUAD] = {
  1886. .type = HDA_FIXUP_PINS,
  1887. .v.pins = hp_cNB11_intquad_pin_configs,
  1888. .chained = true,
  1889. .chain_id = STAC_92HD83XXX_HP,
  1890. },
  1891. [STAC_92HD83XXX_HP] = {
  1892. .type = HDA_FIXUP_FUNC,
  1893. .v.func = stac92hd83xxx_fixup_hp,
  1894. },
  1895. [STAC_HP_DV7_4000] = {
  1896. .type = HDA_FIXUP_PINS,
  1897. .v.pins = hp_dv7_4000_pin_configs,
  1898. .chained = true,
  1899. .chain_id = STAC_92HD83XXX_HP,
  1900. },
  1901. [STAC_HP_ZEPHYR] = {
  1902. .type = HDA_FIXUP_FUNC,
  1903. .v.func = stac92hd83xxx_fixup_hp_zephyr,
  1904. .chained = true,
  1905. .chain_id = STAC_92HD83XXX_HP,
  1906. },
  1907. [STAC_92HD83XXX_HP_LED] = {
  1908. .type = HDA_FIXUP_FUNC,
  1909. .v.func = stac92hd83xxx_fixup_hp_led,
  1910. .chained = true,
  1911. .chain_id = STAC_92HD83XXX_HP,
  1912. },
  1913. [STAC_92HD83XXX_HP_INV_LED] = {
  1914. .type = HDA_FIXUP_FUNC,
  1915. .v.func = stac92hd83xxx_fixup_hp_inv_led,
  1916. .chained = true,
  1917. .chain_id = STAC_92HD83XXX_HP,
  1918. },
  1919. [STAC_92HD83XXX_HP_MIC_LED] = {
  1920. .type = HDA_FIXUP_FUNC,
  1921. .v.func = stac92hd83xxx_fixup_hp_mic_led,
  1922. .chained = true,
  1923. .chain_id = STAC_92HD83XXX_HP,
  1924. },
  1925. [STAC_92HD83XXX_HEADSET_JACK] = {
  1926. .type = HDA_FIXUP_FUNC,
  1927. .v.func = stac92hd83xxx_fixup_headset_jack,
  1928. },
  1929. [STAC_HP_ENVY_BASS] = {
  1930. .type = HDA_FIXUP_PINS,
  1931. .v.pins = (const struct hda_pintbl[]) {
  1932. { 0x0f, 0x90170111 },
  1933. {}
  1934. },
  1935. },
  1936. };
  1937. static const struct hda_model_fixup stac92hd83xxx_models[] = {
  1938. { .id = STAC_92HD83XXX_REF, .name = "ref" },
  1939. { .id = STAC_92HD83XXX_PWR_REF, .name = "mic-ref" },
  1940. { .id = STAC_DELL_S14, .name = "dell-s14" },
  1941. { .id = STAC_DELL_VOSTRO_3500, .name = "dell-vostro-3500" },
  1942. { .id = STAC_92HD83XXX_HP_cNB11_INTQUAD, .name = "hp_cNB11_intquad" },
  1943. { .id = STAC_HP_DV7_4000, .name = "hp-dv7-4000" },
  1944. { .id = STAC_HP_ZEPHYR, .name = "hp-zephyr" },
  1945. { .id = STAC_92HD83XXX_HP_LED, .name = "hp-led" },
  1946. { .id = STAC_92HD83XXX_HP_INV_LED, .name = "hp-inv-led" },
  1947. { .id = STAC_92HD83XXX_HP_MIC_LED, .name = "hp-mic-led" },
  1948. { .id = STAC_92HD83XXX_HEADSET_JACK, .name = "headset-jack" },
  1949. { .id = STAC_HP_ENVY_BASS, .name = "hp-envy-bass" },
  1950. {}
  1951. };
  1952. static const struct snd_pci_quirk stac92hd83xxx_fixup_tbl[] = {
  1953. /* SigmaTel reference board */
  1954. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  1955. "DFI LanParty", STAC_92HD83XXX_REF),
  1956. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  1957. "DFI LanParty", STAC_92HD83XXX_REF),
  1958. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ba,
  1959. "unknown Dell", STAC_DELL_S14),
  1960. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0532,
  1961. "Dell Latitude E6230", STAC_92HD83XXX_HEADSET_JACK),
  1962. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0533,
  1963. "Dell Latitude E6330", STAC_92HD83XXX_HEADSET_JACK),
  1964. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0534,
  1965. "Dell Latitude E6430", STAC_92HD83XXX_HEADSET_JACK),
  1966. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0535,
  1967. "Dell Latitude E6530", STAC_92HD83XXX_HEADSET_JACK),
  1968. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053c,
  1969. "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
  1970. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x053d,
  1971. "Dell Latitude E5530", STAC_92HD83XXX_HEADSET_JACK),
  1972. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0549,
  1973. "Dell Latitude E5430", STAC_92HD83XXX_HEADSET_JACK),
  1974. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x057d,
  1975. "Dell Latitude E6430s", STAC_92HD83XXX_HEADSET_JACK),
  1976. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0584,
  1977. "Dell Latitude E6430U", STAC_92HD83XXX_HEADSET_JACK),
  1978. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x1028,
  1979. "Dell Vostro 3500", STAC_DELL_VOSTRO_3500),
  1980. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1656,
  1981. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1982. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1657,
  1983. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1984. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1658,
  1985. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1986. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1659,
  1987. "HP Pavilion dv7", STAC_HP_DV7_4000),
  1988. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165A,
  1989. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1990. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x165B,
  1991. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  1992. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x1888,
  1993. "HP Envy Spectre", STAC_HP_ENVY_BASS),
  1994. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x18df,
  1995. "HP Folio", STAC_92HD83XXX_HP_MIC_LED),
  1996. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x1900,
  1997. "HP", STAC_92HD83XXX_HP_MIC_LED),
  1998. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x2000,
  1999. "HP", STAC_92HD83XXX_HP_MIC_LED),
  2000. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xff00, 0x2100,
  2001. "HP", STAC_92HD83XXX_HP_MIC_LED),
  2002. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3388,
  2003. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2004. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3389,
  2005. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2006. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355B,
  2007. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2008. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355C,
  2009. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2010. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355D,
  2011. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2012. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355E,
  2013. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2014. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x355F,
  2015. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2016. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3560,
  2017. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2018. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358B,
  2019. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2020. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358C,
  2021. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2022. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x358D,
  2023. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2024. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3591,
  2025. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2026. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3592,
  2027. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2028. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3593,
  2029. "HP", STAC_92HD83XXX_HP_cNB11_INTQUAD),
  2030. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3561,
  2031. "HP", STAC_HP_ZEPHYR),
  2032. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3660,
  2033. "HP Mini", STAC_92HD83XXX_HP_LED),
  2034. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x144E,
  2035. "HP Pavilion dv5", STAC_92HD83XXX_HP_INV_LED),
  2036. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x148a,
  2037. "HP Mini", STAC_92HD83XXX_HP_LED),
  2038. SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD83XXX_HP),
  2039. {} /* terminator */
  2040. };
  2041. /* HP dv7 bass switch - GPIO5 */
  2042. #define stac_hp_bass_gpio_info snd_ctl_boolean_mono_info
  2043. static int stac_hp_bass_gpio_get(struct snd_kcontrol *kcontrol,
  2044. struct snd_ctl_elem_value *ucontrol)
  2045. {
  2046. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2047. struct sigmatel_spec *spec = codec->spec;
  2048. ucontrol->value.integer.value[0] = !!(spec->gpio_data & 0x20);
  2049. return 0;
  2050. }
  2051. static int stac_hp_bass_gpio_put(struct snd_kcontrol *kcontrol,
  2052. struct snd_ctl_elem_value *ucontrol)
  2053. {
  2054. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2055. struct sigmatel_spec *spec = codec->spec;
  2056. unsigned int gpio_data;
  2057. gpio_data = (spec->gpio_data & ~0x20) |
  2058. (ucontrol->value.integer.value[0] ? 0x20 : 0);
  2059. if (gpio_data == spec->gpio_data)
  2060. return 0;
  2061. spec->gpio_data = gpio_data;
  2062. stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
  2063. return 1;
  2064. }
  2065. static const struct snd_kcontrol_new stac_hp_bass_sw_ctrl = {
  2066. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2067. .info = stac_hp_bass_gpio_info,
  2068. .get = stac_hp_bass_gpio_get,
  2069. .put = stac_hp_bass_gpio_put,
  2070. };
  2071. static int stac_add_hp_bass_switch(struct hda_codec *codec)
  2072. {
  2073. struct sigmatel_spec *spec = codec->spec;
  2074. if (!snd_hda_gen_add_kctl(&spec->gen, "Bass Speaker Playback Switch",
  2075. &stac_hp_bass_sw_ctrl))
  2076. return -ENOMEM;
  2077. spec->gpio_mask |= 0x20;
  2078. spec->gpio_dir |= 0x20;
  2079. spec->gpio_data |= 0x20;
  2080. return 0;
  2081. }
  2082. static const struct hda_pintbl ref92hd71bxx_pin_configs[] = {
  2083. { 0x0a, 0x02214030 },
  2084. { 0x0b, 0x02a19040 },
  2085. { 0x0c, 0x01a19020 },
  2086. { 0x0d, 0x01014010 },
  2087. { 0x0e, 0x0181302e },
  2088. { 0x0f, 0x01014010 },
  2089. { 0x14, 0x01019020 },
  2090. { 0x18, 0x90a000f0 },
  2091. { 0x19, 0x90a000f0 },
  2092. { 0x1e, 0x01452050 },
  2093. { 0x1f, 0x01452050 },
  2094. {}
  2095. };
  2096. static const struct hda_pintbl dell_m4_1_pin_configs[] = {
  2097. { 0x0a, 0x0421101f },
  2098. { 0x0b, 0x04a11221 },
  2099. { 0x0c, 0x40f000f0 },
  2100. { 0x0d, 0x90170110 },
  2101. { 0x0e, 0x23a1902e },
  2102. { 0x0f, 0x23014250 },
  2103. { 0x14, 0x40f000f0 },
  2104. { 0x18, 0x90a000f0 },
  2105. { 0x19, 0x40f000f0 },
  2106. { 0x1e, 0x4f0000f0 },
  2107. { 0x1f, 0x4f0000f0 },
  2108. {}
  2109. };
  2110. static const struct hda_pintbl dell_m4_2_pin_configs[] = {
  2111. { 0x0a, 0x0421101f },
  2112. { 0x0b, 0x04a11221 },
  2113. { 0x0c, 0x90a70330 },
  2114. { 0x0d, 0x90170110 },
  2115. { 0x0e, 0x23a1902e },
  2116. { 0x0f, 0x23014250 },
  2117. { 0x14, 0x40f000f0 },
  2118. { 0x18, 0x40f000f0 },
  2119. { 0x19, 0x40f000f0 },
  2120. { 0x1e, 0x044413b0 },
  2121. { 0x1f, 0x044413b0 },
  2122. {}
  2123. };
  2124. static const struct hda_pintbl dell_m4_3_pin_configs[] = {
  2125. { 0x0a, 0x0421101f },
  2126. { 0x0b, 0x04a11221 },
  2127. { 0x0c, 0x90a70330 },
  2128. { 0x0d, 0x90170110 },
  2129. { 0x0e, 0x40f000f0 },
  2130. { 0x0f, 0x40f000f0 },
  2131. { 0x14, 0x40f000f0 },
  2132. { 0x18, 0x90a000f0 },
  2133. { 0x19, 0x40f000f0 },
  2134. { 0x1e, 0x044413b0 },
  2135. { 0x1f, 0x044413b0 },
  2136. {}
  2137. };
  2138. static void stac92hd71bxx_fixup_ref(struct hda_codec *codec,
  2139. const struct hda_fixup *fix, int action)
  2140. {
  2141. struct sigmatel_spec *spec = codec->spec;
  2142. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  2143. return;
  2144. snd_hda_apply_pincfgs(codec, ref92hd71bxx_pin_configs);
  2145. spec->gpio_mask = spec->gpio_dir = spec->gpio_data = 0;
  2146. }
  2147. static void stac92hd71bxx_fixup_hp_m4(struct hda_codec *codec,
  2148. const struct hda_fixup *fix, int action)
  2149. {
  2150. struct sigmatel_spec *spec = codec->spec;
  2151. struct hda_jack_tbl *jack;
  2152. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  2153. return;
  2154. /* Enable VREF power saving on GPIO1 detect */
  2155. snd_hda_codec_write_cache(codec, codec->afg, 0,
  2156. AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x02);
  2157. snd_hda_jack_detect_enable_callback(codec, codec->afg,
  2158. STAC_VREF_EVENT,
  2159. stac_vref_event);
  2160. jack = snd_hda_jack_tbl_get(codec, codec->afg);
  2161. if (jack)
  2162. jack->private_data = 0x02;
  2163. spec->gpio_mask |= 0x02;
  2164. /* enable internal microphone */
  2165. snd_hda_codec_set_pincfg(codec, 0x0e, 0x01813040);
  2166. }
  2167. static void stac92hd71bxx_fixup_hp_dv4(struct hda_codec *codec,
  2168. const struct hda_fixup *fix, int action)
  2169. {
  2170. struct sigmatel_spec *spec = codec->spec;
  2171. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  2172. return;
  2173. spec->gpio_led = 0x01;
  2174. }
  2175. static void stac92hd71bxx_fixup_hp_dv5(struct hda_codec *codec,
  2176. const struct hda_fixup *fix, int action)
  2177. {
  2178. unsigned int cap;
  2179. switch (action) {
  2180. case HDA_FIXUP_ACT_PRE_PROBE:
  2181. snd_hda_codec_set_pincfg(codec, 0x0d, 0x90170010);
  2182. break;
  2183. case HDA_FIXUP_ACT_PROBE:
  2184. /* enable bass on HP dv7 */
  2185. cap = snd_hda_param_read(codec, 0x1, AC_PAR_GPIO_CAP);
  2186. cap &= AC_GPIO_IO_COUNT;
  2187. if (cap >= 6)
  2188. stac_add_hp_bass_switch(codec);
  2189. break;
  2190. }
  2191. }
  2192. static void stac92hd71bxx_fixup_hp_hdx(struct hda_codec *codec,
  2193. const struct hda_fixup *fix, int action)
  2194. {
  2195. struct sigmatel_spec *spec = codec->spec;
  2196. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  2197. return;
  2198. spec->gpio_led = 0x08;
  2199. }
  2200. static void stac92hd71bxx_fixup_hp(struct hda_codec *codec,
  2201. const struct hda_fixup *fix, int action)
  2202. {
  2203. struct sigmatel_spec *spec = codec->spec;
  2204. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  2205. return;
  2206. if (hp_blike_system(codec->subsystem_id)) {
  2207. unsigned int pin_cfg = snd_hda_codec_get_pincfg(codec, 0x0f);
  2208. if (get_defcfg_device(pin_cfg) == AC_JACK_LINE_OUT ||
  2209. get_defcfg_device(pin_cfg) == AC_JACK_SPEAKER ||
  2210. get_defcfg_device(pin_cfg) == AC_JACK_HP_OUT) {
  2211. /* It was changed in the BIOS to just satisfy MS DTM.
  2212. * Lets turn it back into slaved HP
  2213. */
  2214. pin_cfg = (pin_cfg & (~AC_DEFCFG_DEVICE))
  2215. | (AC_JACK_HP_OUT <<
  2216. AC_DEFCFG_DEVICE_SHIFT);
  2217. pin_cfg = (pin_cfg & (~(AC_DEFCFG_DEF_ASSOC
  2218. | AC_DEFCFG_SEQUENCE)))
  2219. | 0x1f;
  2220. snd_hda_codec_set_pincfg(codec, 0x0f, pin_cfg);
  2221. }
  2222. }
  2223. if (find_mute_led_cfg(codec, 1))
  2224. snd_printd("mute LED gpio %d polarity %d\n",
  2225. spec->gpio_led,
  2226. spec->gpio_led_polarity);
  2227. }
  2228. static const struct hda_fixup stac92hd71bxx_fixups[] = {
  2229. [STAC_92HD71BXX_REF] = {
  2230. .type = HDA_FIXUP_FUNC,
  2231. .v.func = stac92hd71bxx_fixup_ref,
  2232. },
  2233. [STAC_DELL_M4_1] = {
  2234. .type = HDA_FIXUP_PINS,
  2235. .v.pins = dell_m4_1_pin_configs,
  2236. },
  2237. [STAC_DELL_M4_2] = {
  2238. .type = HDA_FIXUP_PINS,
  2239. .v.pins = dell_m4_2_pin_configs,
  2240. },
  2241. [STAC_DELL_M4_3] = {
  2242. .type = HDA_FIXUP_PINS,
  2243. .v.pins = dell_m4_3_pin_configs,
  2244. },
  2245. [STAC_HP_M4] = {
  2246. .type = HDA_FIXUP_FUNC,
  2247. .v.func = stac92hd71bxx_fixup_hp_m4,
  2248. .chained = true,
  2249. .chain_id = STAC_92HD71BXX_HP,
  2250. },
  2251. [STAC_HP_DV4] = {
  2252. .type = HDA_FIXUP_FUNC,
  2253. .v.func = stac92hd71bxx_fixup_hp_dv4,
  2254. .chained = true,
  2255. .chain_id = STAC_HP_DV5,
  2256. },
  2257. [STAC_HP_DV5] = {
  2258. .type = HDA_FIXUP_FUNC,
  2259. .v.func = stac92hd71bxx_fixup_hp_dv5,
  2260. .chained = true,
  2261. .chain_id = STAC_92HD71BXX_HP,
  2262. },
  2263. [STAC_HP_HDX] = {
  2264. .type = HDA_FIXUP_FUNC,
  2265. .v.func = stac92hd71bxx_fixup_hp_hdx,
  2266. .chained = true,
  2267. .chain_id = STAC_92HD71BXX_HP,
  2268. },
  2269. [STAC_92HD71BXX_HP] = {
  2270. .type = HDA_FIXUP_FUNC,
  2271. .v.func = stac92hd71bxx_fixup_hp,
  2272. },
  2273. };
  2274. static const struct hda_model_fixup stac92hd71bxx_models[] = {
  2275. { .id = STAC_92HD71BXX_REF, .name = "ref" },
  2276. { .id = STAC_DELL_M4_1, .name = "dell-m4-1" },
  2277. { .id = STAC_DELL_M4_2, .name = "dell-m4-2" },
  2278. { .id = STAC_DELL_M4_3, .name = "dell-m4-3" },
  2279. { .id = STAC_HP_M4, .name = "hp-m4" },
  2280. { .id = STAC_HP_DV4, .name = "hp-dv4" },
  2281. { .id = STAC_HP_DV5, .name = "hp-dv5" },
  2282. { .id = STAC_HP_HDX, .name = "hp-hdx" },
  2283. { .id = STAC_HP_DV4, .name = "hp-dv4-1222nr" },
  2284. {}
  2285. };
  2286. static const struct snd_pci_quirk stac92hd71bxx_fixup_tbl[] = {
  2287. /* SigmaTel reference board */
  2288. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  2289. "DFI LanParty", STAC_92HD71BXX_REF),
  2290. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  2291. "DFI LanParty", STAC_92HD71BXX_REF),
  2292. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x1720,
  2293. "HP", STAC_HP_DV5),
  2294. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3080,
  2295. "HP", STAC_HP_DV5),
  2296. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x30f0,
  2297. "HP dv4-7", STAC_HP_DV4),
  2298. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3600,
  2299. "HP dv4-7", STAC_HP_DV5),
  2300. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3610,
  2301. "HP HDX", STAC_HP_HDX), /* HDX18 */
  2302. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361a,
  2303. "HP mini 1000", STAC_HP_M4),
  2304. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x361b,
  2305. "HP HDX", STAC_HP_HDX), /* HDX16 */
  2306. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x3620,
  2307. "HP dv6", STAC_HP_DV5),
  2308. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x3061,
  2309. "HP dv6", STAC_HP_DV5), /* HP dv6-1110ax */
  2310. SND_PCI_QUIRK(PCI_VENDOR_ID_HP, 0x363e,
  2311. "HP DV6", STAC_HP_DV5),
  2312. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_HP, 0xfff0, 0x7010,
  2313. "HP", STAC_HP_DV5),
  2314. SND_PCI_QUIRK_VENDOR(PCI_VENDOR_ID_HP, "HP", STAC_92HD71BXX_HP),
  2315. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0233,
  2316. "unknown Dell", STAC_DELL_M4_1),
  2317. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0234,
  2318. "unknown Dell", STAC_DELL_M4_1),
  2319. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0250,
  2320. "unknown Dell", STAC_DELL_M4_1),
  2321. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024f,
  2322. "unknown Dell", STAC_DELL_M4_1),
  2323. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x024d,
  2324. "unknown Dell", STAC_DELL_M4_1),
  2325. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0251,
  2326. "unknown Dell", STAC_DELL_M4_1),
  2327. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0277,
  2328. "unknown Dell", STAC_DELL_M4_1),
  2329. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0263,
  2330. "unknown Dell", STAC_DELL_M4_2),
  2331. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0265,
  2332. "unknown Dell", STAC_DELL_M4_2),
  2333. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0262,
  2334. "unknown Dell", STAC_DELL_M4_2),
  2335. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0264,
  2336. "unknown Dell", STAC_DELL_M4_2),
  2337. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02aa,
  2338. "unknown Dell", STAC_DELL_M4_3),
  2339. {} /* terminator */
  2340. };
  2341. static const struct hda_pintbl ref922x_pin_configs[] = {
  2342. { 0x0a, 0x01014010 },
  2343. { 0x0b, 0x01016011 },
  2344. { 0x0c, 0x01012012 },
  2345. { 0x0d, 0x0221401f },
  2346. { 0x0e, 0x01813122 },
  2347. { 0x0f, 0x01011014 },
  2348. { 0x10, 0x01441030 },
  2349. { 0x11, 0x01c41030 },
  2350. { 0x15, 0x40000100 },
  2351. { 0x1b, 0x40000100 },
  2352. {}
  2353. };
  2354. /*
  2355. STAC 922X pin configs for
  2356. 102801A7
  2357. 102801AB
  2358. 102801A9
  2359. 102801D1
  2360. 102801D2
  2361. */
  2362. static const struct hda_pintbl dell_922x_d81_pin_configs[] = {
  2363. { 0x0a, 0x02214030 },
  2364. { 0x0b, 0x01a19021 },
  2365. { 0x0c, 0x01111012 },
  2366. { 0x0d, 0x01114010 },
  2367. { 0x0e, 0x02a19020 },
  2368. { 0x0f, 0x01117011 },
  2369. { 0x10, 0x400001f0 },
  2370. { 0x11, 0x400001f1 },
  2371. { 0x15, 0x01813122 },
  2372. { 0x1b, 0x400001f2 },
  2373. {}
  2374. };
  2375. /*
  2376. STAC 922X pin configs for
  2377. 102801AC
  2378. 102801D0
  2379. */
  2380. static const struct hda_pintbl dell_922x_d82_pin_configs[] = {
  2381. { 0x0a, 0x02214030 },
  2382. { 0x0b, 0x01a19021 },
  2383. { 0x0c, 0x01111012 },
  2384. { 0x0d, 0x01114010 },
  2385. { 0x0e, 0x02a19020 },
  2386. { 0x0f, 0x01117011 },
  2387. { 0x10, 0x01451140 },
  2388. { 0x11, 0x400001f0 },
  2389. { 0x15, 0x01813122 },
  2390. { 0x1b, 0x400001f1 },
  2391. {}
  2392. };
  2393. /*
  2394. STAC 922X pin configs for
  2395. 102801BF
  2396. */
  2397. static const struct hda_pintbl dell_922x_m81_pin_configs[] = {
  2398. { 0x0a, 0x0321101f },
  2399. { 0x0b, 0x01112024 },
  2400. { 0x0c, 0x01111222 },
  2401. { 0x0d, 0x91174220 },
  2402. { 0x0e, 0x03a11050 },
  2403. { 0x0f, 0x01116221 },
  2404. { 0x10, 0x90a70330 },
  2405. { 0x11, 0x01452340 },
  2406. { 0x15, 0x40C003f1 },
  2407. { 0x1b, 0x405003f0 },
  2408. {}
  2409. };
  2410. /*
  2411. STAC 9221 A1 pin configs for
  2412. 102801D7 (Dell XPS M1210)
  2413. */
  2414. static const struct hda_pintbl dell_922x_m82_pin_configs[] = {
  2415. { 0x0a, 0x02211211 },
  2416. { 0x0b, 0x408103ff },
  2417. { 0x0c, 0x02a1123e },
  2418. { 0x0d, 0x90100310 },
  2419. { 0x0e, 0x408003f1 },
  2420. { 0x0f, 0x0221121f },
  2421. { 0x10, 0x03451340 },
  2422. { 0x11, 0x40c003f2 },
  2423. { 0x15, 0x508003f3 },
  2424. { 0x1b, 0x405003f4 },
  2425. {}
  2426. };
  2427. static const struct hda_pintbl d945gtp3_pin_configs[] = {
  2428. { 0x0a, 0x0221401f },
  2429. { 0x0b, 0x01a19022 },
  2430. { 0x0c, 0x01813021 },
  2431. { 0x0d, 0x01014010 },
  2432. { 0x0e, 0x40000100 },
  2433. { 0x0f, 0x40000100 },
  2434. { 0x10, 0x40000100 },
  2435. { 0x11, 0x40000100 },
  2436. { 0x15, 0x02a19120 },
  2437. { 0x1b, 0x40000100 },
  2438. {}
  2439. };
  2440. static const struct hda_pintbl d945gtp5_pin_configs[] = {
  2441. { 0x0a, 0x0221401f },
  2442. { 0x0b, 0x01011012 },
  2443. { 0x0c, 0x01813024 },
  2444. { 0x0d, 0x01014010 },
  2445. { 0x0e, 0x01a19021 },
  2446. { 0x0f, 0x01016011 },
  2447. { 0x10, 0x01452130 },
  2448. { 0x11, 0x40000100 },
  2449. { 0x15, 0x02a19320 },
  2450. { 0x1b, 0x40000100 },
  2451. {}
  2452. };
  2453. static const struct hda_pintbl intel_mac_v1_pin_configs[] = {
  2454. { 0x0a, 0x0121e21f },
  2455. { 0x0b, 0x400000ff },
  2456. { 0x0c, 0x9017e110 },
  2457. { 0x0d, 0x400000fd },
  2458. { 0x0e, 0x400000fe },
  2459. { 0x0f, 0x0181e020 },
  2460. { 0x10, 0x1145e030 },
  2461. { 0x11, 0x11c5e240 },
  2462. { 0x15, 0x400000fc },
  2463. { 0x1b, 0x400000fb },
  2464. {}
  2465. };
  2466. static const struct hda_pintbl intel_mac_v2_pin_configs[] = {
  2467. { 0x0a, 0x0121e21f },
  2468. { 0x0b, 0x90a7012e },
  2469. { 0x0c, 0x9017e110 },
  2470. { 0x0d, 0x400000fd },
  2471. { 0x0e, 0x400000fe },
  2472. { 0x0f, 0x0181e020 },
  2473. { 0x10, 0x1145e230 },
  2474. { 0x11, 0x500000fa },
  2475. { 0x15, 0x400000fc },
  2476. { 0x1b, 0x400000fb },
  2477. {}
  2478. };
  2479. static const struct hda_pintbl intel_mac_v3_pin_configs[] = {
  2480. { 0x0a, 0x0121e21f },
  2481. { 0x0b, 0x90a7012e },
  2482. { 0x0c, 0x9017e110 },
  2483. { 0x0d, 0x400000fd },
  2484. { 0x0e, 0x400000fe },
  2485. { 0x0f, 0x0181e020 },
  2486. { 0x10, 0x1145e230 },
  2487. { 0x11, 0x11c5e240 },
  2488. { 0x15, 0x400000fc },
  2489. { 0x1b, 0x400000fb },
  2490. {}
  2491. };
  2492. static const struct hda_pintbl intel_mac_v4_pin_configs[] = {
  2493. { 0x0a, 0x0321e21f },
  2494. { 0x0b, 0x03a1e02e },
  2495. { 0x0c, 0x9017e110 },
  2496. { 0x0d, 0x9017e11f },
  2497. { 0x0e, 0x400000fe },
  2498. { 0x0f, 0x0381e020 },
  2499. { 0x10, 0x1345e230 },
  2500. { 0x11, 0x13c5e240 },
  2501. { 0x15, 0x400000fc },
  2502. { 0x1b, 0x400000fb },
  2503. {}
  2504. };
  2505. static const struct hda_pintbl intel_mac_v5_pin_configs[] = {
  2506. { 0x0a, 0x0321e21f },
  2507. { 0x0b, 0x03a1e02e },
  2508. { 0x0c, 0x9017e110 },
  2509. { 0x0d, 0x9017e11f },
  2510. { 0x0e, 0x400000fe },
  2511. { 0x0f, 0x0381e020 },
  2512. { 0x10, 0x1345e230 },
  2513. { 0x11, 0x13c5e240 },
  2514. { 0x15, 0x400000fc },
  2515. { 0x1b, 0x400000fb },
  2516. {}
  2517. };
  2518. static const struct hda_pintbl ecs202_pin_configs[] = {
  2519. { 0x0a, 0x0221401f },
  2520. { 0x0b, 0x02a19020 },
  2521. { 0x0c, 0x01a19020 },
  2522. { 0x0d, 0x01114010 },
  2523. { 0x0e, 0x408000f0 },
  2524. { 0x0f, 0x01813022 },
  2525. { 0x10, 0x074510a0 },
  2526. { 0x11, 0x40c400f1 },
  2527. { 0x15, 0x9037012e },
  2528. { 0x1b, 0x40e000f2 },
  2529. {}
  2530. };
  2531. /* codec SSIDs for Intel Mac sharing the same PCI SSID 8384:7680 */
  2532. static const struct snd_pci_quirk stac922x_intel_mac_fixup_tbl[] = {
  2533. SND_PCI_QUIRK(0x106b, 0x0800, "Mac", STAC_INTEL_MAC_V1),
  2534. SND_PCI_QUIRK(0x106b, 0x0600, "Mac", STAC_INTEL_MAC_V2),
  2535. SND_PCI_QUIRK(0x106b, 0x0700, "Mac", STAC_INTEL_MAC_V2),
  2536. SND_PCI_QUIRK(0x106b, 0x0e00, "Mac", STAC_INTEL_MAC_V3),
  2537. SND_PCI_QUIRK(0x106b, 0x0f00, "Mac", STAC_INTEL_MAC_V3),
  2538. SND_PCI_QUIRK(0x106b, 0x1600, "Mac", STAC_INTEL_MAC_V3),
  2539. SND_PCI_QUIRK(0x106b, 0x1700, "Mac", STAC_INTEL_MAC_V3),
  2540. SND_PCI_QUIRK(0x106b, 0x0200, "Mac", STAC_INTEL_MAC_V3),
  2541. SND_PCI_QUIRK(0x106b, 0x1e00, "Mac", STAC_INTEL_MAC_V3),
  2542. SND_PCI_QUIRK(0x106b, 0x1a00, "Mac", STAC_INTEL_MAC_V4),
  2543. SND_PCI_QUIRK(0x106b, 0x0a00, "Mac", STAC_INTEL_MAC_V5),
  2544. SND_PCI_QUIRK(0x106b, 0x2200, "Mac", STAC_INTEL_MAC_V5),
  2545. {}
  2546. };
  2547. static const struct hda_fixup stac922x_fixups[];
  2548. /* remap the fixup from codec SSID and apply it */
  2549. static void stac922x_fixup_intel_mac_auto(struct hda_codec *codec,
  2550. const struct hda_fixup *fix,
  2551. int action)
  2552. {
  2553. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  2554. return;
  2555. snd_hda_pick_fixup(codec, NULL, stac922x_intel_mac_fixup_tbl,
  2556. stac922x_fixups);
  2557. if (codec->fixup_id != STAC_INTEL_MAC_AUTO)
  2558. snd_hda_apply_fixup(codec, action);
  2559. }
  2560. static void stac922x_fixup_intel_mac_gpio(struct hda_codec *codec,
  2561. const struct hda_fixup *fix,
  2562. int action)
  2563. {
  2564. struct sigmatel_spec *spec = codec->spec;
  2565. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  2566. spec->gpio_mask = spec->gpio_dir = 0x03;
  2567. spec->gpio_data = 0x03;
  2568. }
  2569. }
  2570. static const struct hda_fixup stac922x_fixups[] = {
  2571. [STAC_D945_REF] = {
  2572. .type = HDA_FIXUP_PINS,
  2573. .v.pins = ref922x_pin_configs,
  2574. },
  2575. [STAC_D945GTP3] = {
  2576. .type = HDA_FIXUP_PINS,
  2577. .v.pins = d945gtp3_pin_configs,
  2578. },
  2579. [STAC_D945GTP5] = {
  2580. .type = HDA_FIXUP_PINS,
  2581. .v.pins = d945gtp5_pin_configs,
  2582. },
  2583. [STAC_INTEL_MAC_AUTO] = {
  2584. .type = HDA_FIXUP_FUNC,
  2585. .v.func = stac922x_fixup_intel_mac_auto,
  2586. },
  2587. [STAC_INTEL_MAC_V1] = {
  2588. .type = HDA_FIXUP_PINS,
  2589. .v.pins = intel_mac_v1_pin_configs,
  2590. .chained = true,
  2591. .chain_id = STAC_922X_INTEL_MAC_GPIO,
  2592. },
  2593. [STAC_INTEL_MAC_V2] = {
  2594. .type = HDA_FIXUP_PINS,
  2595. .v.pins = intel_mac_v2_pin_configs,
  2596. .chained = true,
  2597. .chain_id = STAC_922X_INTEL_MAC_GPIO,
  2598. },
  2599. [STAC_INTEL_MAC_V3] = {
  2600. .type = HDA_FIXUP_PINS,
  2601. .v.pins = intel_mac_v3_pin_configs,
  2602. .chained = true,
  2603. .chain_id = STAC_922X_INTEL_MAC_GPIO,
  2604. },
  2605. [STAC_INTEL_MAC_V4] = {
  2606. .type = HDA_FIXUP_PINS,
  2607. .v.pins = intel_mac_v4_pin_configs,
  2608. .chained = true,
  2609. .chain_id = STAC_922X_INTEL_MAC_GPIO,
  2610. },
  2611. [STAC_INTEL_MAC_V5] = {
  2612. .type = HDA_FIXUP_PINS,
  2613. .v.pins = intel_mac_v5_pin_configs,
  2614. .chained = true,
  2615. .chain_id = STAC_922X_INTEL_MAC_GPIO,
  2616. },
  2617. [STAC_922X_INTEL_MAC_GPIO] = {
  2618. .type = HDA_FIXUP_FUNC,
  2619. .v.func = stac922x_fixup_intel_mac_gpio,
  2620. },
  2621. [STAC_ECS_202] = {
  2622. .type = HDA_FIXUP_PINS,
  2623. .v.pins = ecs202_pin_configs,
  2624. },
  2625. [STAC_922X_DELL_D81] = {
  2626. .type = HDA_FIXUP_PINS,
  2627. .v.pins = dell_922x_d81_pin_configs,
  2628. },
  2629. [STAC_922X_DELL_D82] = {
  2630. .type = HDA_FIXUP_PINS,
  2631. .v.pins = dell_922x_d82_pin_configs,
  2632. },
  2633. [STAC_922X_DELL_M81] = {
  2634. .type = HDA_FIXUP_PINS,
  2635. .v.pins = dell_922x_m81_pin_configs,
  2636. },
  2637. [STAC_922X_DELL_M82] = {
  2638. .type = HDA_FIXUP_PINS,
  2639. .v.pins = dell_922x_m82_pin_configs,
  2640. },
  2641. };
  2642. static const struct hda_model_fixup stac922x_models[] = {
  2643. { .id = STAC_D945_REF, .name = "ref" },
  2644. { .id = STAC_D945GTP5, .name = "5stack" },
  2645. { .id = STAC_D945GTP3, .name = "3stack" },
  2646. { .id = STAC_INTEL_MAC_V1, .name = "intel-mac-v1" },
  2647. { .id = STAC_INTEL_MAC_V2, .name = "intel-mac-v2" },
  2648. { .id = STAC_INTEL_MAC_V3, .name = "intel-mac-v3" },
  2649. { .id = STAC_INTEL_MAC_V4, .name = "intel-mac-v4" },
  2650. { .id = STAC_INTEL_MAC_V5, .name = "intel-mac-v5" },
  2651. { .id = STAC_INTEL_MAC_AUTO, .name = "intel-mac-auto" },
  2652. { .id = STAC_ECS_202, .name = "ecs202" },
  2653. { .id = STAC_922X_DELL_D81, .name = "dell-d81" },
  2654. { .id = STAC_922X_DELL_D82, .name = "dell-d82" },
  2655. { .id = STAC_922X_DELL_M81, .name = "dell-m81" },
  2656. { .id = STAC_922X_DELL_M82, .name = "dell-m82" },
  2657. /* for backward compatibility */
  2658. { .id = STAC_INTEL_MAC_V3, .name = "macmini" },
  2659. { .id = STAC_INTEL_MAC_V5, .name = "macbook" },
  2660. { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro-v1" },
  2661. { .id = STAC_INTEL_MAC_V3, .name = "macbook-pro" },
  2662. { .id = STAC_INTEL_MAC_V2, .name = "imac-intel" },
  2663. { .id = STAC_INTEL_MAC_V3, .name = "imac-intel-20" },
  2664. {}
  2665. };
  2666. static const struct snd_pci_quirk stac922x_fixup_tbl[] = {
  2667. /* SigmaTel reference board */
  2668. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  2669. "DFI LanParty", STAC_D945_REF),
  2670. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  2671. "DFI LanParty", STAC_D945_REF),
  2672. /* Intel 945G based systems */
  2673. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
  2674. "Intel D945G", STAC_D945GTP3),
  2675. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
  2676. "Intel D945G", STAC_D945GTP3),
  2677. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
  2678. "Intel D945G", STAC_D945GTP3),
  2679. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
  2680. "Intel D945G", STAC_D945GTP3),
  2681. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
  2682. "Intel D945G", STAC_D945GTP3),
  2683. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
  2684. "Intel D945G", STAC_D945GTP3),
  2685. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
  2686. "Intel D945G", STAC_D945GTP3),
  2687. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
  2688. "Intel D945G", STAC_D945GTP3),
  2689. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
  2690. "Intel D945G", STAC_D945GTP3),
  2691. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
  2692. "Intel D945G", STAC_D945GTP3),
  2693. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
  2694. "Intel D945G", STAC_D945GTP3),
  2695. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
  2696. "Intel D945G", STAC_D945GTP3),
  2697. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
  2698. "Intel D945G", STAC_D945GTP3),
  2699. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
  2700. "Intel D945G", STAC_D945GTP3),
  2701. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
  2702. "Intel D945G", STAC_D945GTP3),
  2703. /* Intel D945G 5-stack systems */
  2704. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
  2705. "Intel D945G", STAC_D945GTP5),
  2706. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
  2707. "Intel D945G", STAC_D945GTP5),
  2708. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
  2709. "Intel D945G", STAC_D945GTP5),
  2710. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
  2711. "Intel D945G", STAC_D945GTP5),
  2712. /* Intel 945P based systems */
  2713. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
  2714. "Intel D945P", STAC_D945GTP3),
  2715. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
  2716. "Intel D945P", STAC_D945GTP3),
  2717. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
  2718. "Intel D945P", STAC_D945GTP3),
  2719. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
  2720. "Intel D945P", STAC_D945GTP3),
  2721. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
  2722. "Intel D945P", STAC_D945GTP3),
  2723. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
  2724. "Intel D945P", STAC_D945GTP5),
  2725. /* other intel */
  2726. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0204,
  2727. "Intel D945", STAC_D945_REF),
  2728. /* other systems */
  2729. /* Apple Intel Mac (Mac Mini, MacBook, MacBook Pro...) */
  2730. SND_PCI_QUIRK(0x8384, 0x7680, "Mac", STAC_INTEL_MAC_AUTO),
  2731. /* Dell systems */
  2732. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a7,
  2733. "unknown Dell", STAC_922X_DELL_D81),
  2734. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01a9,
  2735. "unknown Dell", STAC_922X_DELL_D81),
  2736. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ab,
  2737. "unknown Dell", STAC_922X_DELL_D81),
  2738. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ac,
  2739. "unknown Dell", STAC_922X_DELL_D82),
  2740. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01bf,
  2741. "unknown Dell", STAC_922X_DELL_M81),
  2742. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d0,
  2743. "unknown Dell", STAC_922X_DELL_D82),
  2744. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d1,
  2745. "unknown Dell", STAC_922X_DELL_D81),
  2746. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d2,
  2747. "unknown Dell", STAC_922X_DELL_D81),
  2748. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d7,
  2749. "Dell XPS M1210", STAC_922X_DELL_M82),
  2750. /* ECS/PC Chips boards */
  2751. SND_PCI_QUIRK_MASK(0x1019, 0xf000, 0x2000,
  2752. "ECS/PC chips", STAC_ECS_202),
  2753. {} /* terminator */
  2754. };
  2755. static const struct hda_pintbl ref927x_pin_configs[] = {
  2756. { 0x0a, 0x02214020 },
  2757. { 0x0b, 0x02a19080 },
  2758. { 0x0c, 0x0181304e },
  2759. { 0x0d, 0x01014010 },
  2760. { 0x0e, 0x01a19040 },
  2761. { 0x0f, 0x01011012 },
  2762. { 0x10, 0x01016011 },
  2763. { 0x11, 0x0101201f },
  2764. { 0x12, 0x183301f0 },
  2765. { 0x13, 0x18a001f0 },
  2766. { 0x14, 0x18a001f0 },
  2767. { 0x21, 0x01442070 },
  2768. { 0x22, 0x01c42190 },
  2769. { 0x23, 0x40000100 },
  2770. {}
  2771. };
  2772. static const struct hda_pintbl d965_3st_pin_configs[] = {
  2773. { 0x0a, 0x0221401f },
  2774. { 0x0b, 0x02a19120 },
  2775. { 0x0c, 0x40000100 },
  2776. { 0x0d, 0x01014011 },
  2777. { 0x0e, 0x01a19021 },
  2778. { 0x0f, 0x01813024 },
  2779. { 0x10, 0x40000100 },
  2780. { 0x11, 0x40000100 },
  2781. { 0x12, 0x40000100 },
  2782. { 0x13, 0x40000100 },
  2783. { 0x14, 0x40000100 },
  2784. { 0x21, 0x40000100 },
  2785. { 0x22, 0x40000100 },
  2786. { 0x23, 0x40000100 },
  2787. {}
  2788. };
  2789. static const struct hda_pintbl d965_5st_pin_configs[] = {
  2790. { 0x0a, 0x02214020 },
  2791. { 0x0b, 0x02a19080 },
  2792. { 0x0c, 0x0181304e },
  2793. { 0x0d, 0x01014010 },
  2794. { 0x0e, 0x01a19040 },
  2795. { 0x0f, 0x01011012 },
  2796. { 0x10, 0x01016011 },
  2797. { 0x11, 0x40000100 },
  2798. { 0x12, 0x40000100 },
  2799. { 0x13, 0x40000100 },
  2800. { 0x14, 0x40000100 },
  2801. { 0x21, 0x01442070 },
  2802. { 0x22, 0x40000100 },
  2803. { 0x23, 0x40000100 },
  2804. {}
  2805. };
  2806. static const struct hda_pintbl d965_5st_no_fp_pin_configs[] = {
  2807. { 0x0a, 0x40000100 },
  2808. { 0x0b, 0x40000100 },
  2809. { 0x0c, 0x0181304e },
  2810. { 0x0d, 0x01014010 },
  2811. { 0x0e, 0x01a19040 },
  2812. { 0x0f, 0x01011012 },
  2813. { 0x10, 0x01016011 },
  2814. { 0x11, 0x40000100 },
  2815. { 0x12, 0x40000100 },
  2816. { 0x13, 0x40000100 },
  2817. { 0x14, 0x40000100 },
  2818. { 0x21, 0x01442070 },
  2819. { 0x22, 0x40000100 },
  2820. { 0x23, 0x40000100 },
  2821. {}
  2822. };
  2823. static const struct hda_pintbl dell_3st_pin_configs[] = {
  2824. { 0x0a, 0x02211230 },
  2825. { 0x0b, 0x02a11220 },
  2826. { 0x0c, 0x01a19040 },
  2827. { 0x0d, 0x01114210 },
  2828. { 0x0e, 0x01111212 },
  2829. { 0x0f, 0x01116211 },
  2830. { 0x10, 0x01813050 },
  2831. { 0x11, 0x01112214 },
  2832. { 0x12, 0x403003fa },
  2833. { 0x13, 0x90a60040 },
  2834. { 0x14, 0x90a60040 },
  2835. { 0x21, 0x404003fb },
  2836. { 0x22, 0x40c003fc },
  2837. { 0x23, 0x40000100 },
  2838. {}
  2839. };
  2840. static void stac927x_fixup_ref_no_jd(struct hda_codec *codec,
  2841. const struct hda_fixup *fix, int action)
  2842. {
  2843. /* no jack detecion for ref-no-jd model */
  2844. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  2845. codec->no_jack_detect = 1;
  2846. }
  2847. static void stac927x_fixup_ref(struct hda_codec *codec,
  2848. const struct hda_fixup *fix, int action)
  2849. {
  2850. struct sigmatel_spec *spec = codec->spec;
  2851. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  2852. snd_hda_apply_pincfgs(codec, ref927x_pin_configs);
  2853. spec->eapd_mask = spec->gpio_mask = 0;
  2854. spec->gpio_dir = spec->gpio_data = 0;
  2855. }
  2856. }
  2857. static void stac927x_fixup_dell_dmic(struct hda_codec *codec,
  2858. const struct hda_fixup *fix, int action)
  2859. {
  2860. struct sigmatel_spec *spec = codec->spec;
  2861. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  2862. return;
  2863. if (codec->subsystem_id != 0x1028022f) {
  2864. /* GPIO2 High = Enable EAPD */
  2865. spec->eapd_mask = spec->gpio_mask = 0x04;
  2866. spec->gpio_dir = spec->gpio_data = 0x04;
  2867. }
  2868. snd_hda_add_verbs(codec, dell_3st_core_init);
  2869. spec->volknob_init = 1;
  2870. }
  2871. static void stac927x_fixup_volknob(struct hda_codec *codec,
  2872. const struct hda_fixup *fix, int action)
  2873. {
  2874. struct sigmatel_spec *spec = codec->spec;
  2875. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  2876. snd_hda_add_verbs(codec, stac927x_volknob_core_init);
  2877. spec->volknob_init = 1;
  2878. }
  2879. }
  2880. static const struct hda_fixup stac927x_fixups[] = {
  2881. [STAC_D965_REF_NO_JD] = {
  2882. .type = HDA_FIXUP_FUNC,
  2883. .v.func = stac927x_fixup_ref_no_jd,
  2884. .chained = true,
  2885. .chain_id = STAC_D965_REF,
  2886. },
  2887. [STAC_D965_REF] = {
  2888. .type = HDA_FIXUP_FUNC,
  2889. .v.func = stac927x_fixup_ref,
  2890. },
  2891. [STAC_D965_3ST] = {
  2892. .type = HDA_FIXUP_PINS,
  2893. .v.pins = d965_3st_pin_configs,
  2894. .chained = true,
  2895. .chain_id = STAC_D965_VERBS,
  2896. },
  2897. [STAC_D965_5ST] = {
  2898. .type = HDA_FIXUP_PINS,
  2899. .v.pins = d965_5st_pin_configs,
  2900. .chained = true,
  2901. .chain_id = STAC_D965_VERBS,
  2902. },
  2903. [STAC_D965_VERBS] = {
  2904. .type = HDA_FIXUP_VERBS,
  2905. .v.verbs = d965_core_init,
  2906. },
  2907. [STAC_D965_5ST_NO_FP] = {
  2908. .type = HDA_FIXUP_PINS,
  2909. .v.pins = d965_5st_no_fp_pin_configs,
  2910. },
  2911. [STAC_DELL_3ST] = {
  2912. .type = HDA_FIXUP_PINS,
  2913. .v.pins = dell_3st_pin_configs,
  2914. .chained = true,
  2915. .chain_id = STAC_927X_DELL_DMIC,
  2916. },
  2917. [STAC_DELL_BIOS] = {
  2918. .type = HDA_FIXUP_PINS,
  2919. .v.pins = (const struct hda_pintbl[]) {
  2920. /* configure the analog microphone on some laptops */
  2921. { 0x0c, 0x90a79130 },
  2922. /* correct the front output jack as a hp out */
  2923. { 0x0f, 0x0221101f },
  2924. /* correct the front input jack as a mic */
  2925. { 0x0e, 0x02a79130 },
  2926. {}
  2927. },
  2928. .chained = true,
  2929. .chain_id = STAC_927X_DELL_DMIC,
  2930. },
  2931. [STAC_DELL_BIOS_SPDIF] = {
  2932. .type = HDA_FIXUP_PINS,
  2933. .v.pins = (const struct hda_pintbl[]) {
  2934. /* correct the device field to SPDIF out */
  2935. { 0x21, 0x01442070 },
  2936. {}
  2937. },
  2938. .chained = true,
  2939. .chain_id = STAC_DELL_BIOS,
  2940. },
  2941. [STAC_927X_DELL_DMIC] = {
  2942. .type = HDA_FIXUP_FUNC,
  2943. .v.func = stac927x_fixup_dell_dmic,
  2944. },
  2945. [STAC_927X_VOLKNOB] = {
  2946. .type = HDA_FIXUP_FUNC,
  2947. .v.func = stac927x_fixup_volknob,
  2948. },
  2949. };
  2950. static const struct hda_model_fixup stac927x_models[] = {
  2951. { .id = STAC_D965_REF_NO_JD, .name = "ref-no-jd" },
  2952. { .id = STAC_D965_REF, .name = "ref" },
  2953. { .id = STAC_D965_3ST, .name = "3stack" },
  2954. { .id = STAC_D965_5ST, .name = "5stack" },
  2955. { .id = STAC_D965_5ST_NO_FP, .name = "5stack-no-fp" },
  2956. { .id = STAC_DELL_3ST, .name = "dell-3stack" },
  2957. { .id = STAC_DELL_BIOS, .name = "dell-bios" },
  2958. { .id = STAC_927X_VOLKNOB, .name = "volknob" },
  2959. {}
  2960. };
  2961. static const struct snd_pci_quirk stac927x_fixup_tbl[] = {
  2962. /* SigmaTel reference board */
  2963. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  2964. "DFI LanParty", STAC_D965_REF),
  2965. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  2966. "DFI LanParty", STAC_D965_REF),
  2967. /* Intel 946 based systems */
  2968. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
  2969. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
  2970. /* 965 based 3 stack systems */
  2971. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2100,
  2972. "Intel D965", STAC_D965_3ST),
  2973. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2000,
  2974. "Intel D965", STAC_D965_3ST),
  2975. /* Dell 3 stack systems */
  2976. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01dd, "Dell Dimension E520", STAC_DELL_3ST),
  2977. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ed, "Dell ", STAC_DELL_3ST),
  2978. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f4, "Dell ", STAC_DELL_3ST),
  2979. /* Dell 3 stack systems with verb table in BIOS */
  2980. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f3, "Dell Inspiron 1420", STAC_DELL_BIOS),
  2981. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f7, "Dell XPS M1730", STAC_DELL_BIOS),
  2982. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0227, "Dell Vostro 1400 ", STAC_DELL_BIOS),
  2983. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022e, "Dell ", STAC_DELL_BIOS_SPDIF),
  2984. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x022f, "Dell Inspiron 1525", STAC_DELL_BIOS),
  2985. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0242, "Dell ", STAC_DELL_BIOS),
  2986. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0243, "Dell ", STAC_DELL_BIOS),
  2987. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x02ff, "Dell ", STAC_DELL_BIOS),
  2988. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0209, "Dell XPS 1330", STAC_DELL_BIOS_SPDIF),
  2989. /* 965 based 5 stack systems */
  2990. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2300,
  2991. "Intel D965", STAC_D965_5ST),
  2992. SND_PCI_QUIRK_MASK(PCI_VENDOR_ID_INTEL, 0xff00, 0x2500,
  2993. "Intel D965", STAC_D965_5ST),
  2994. /* volume-knob fixes */
  2995. SND_PCI_QUIRK_VENDOR(0x10cf, "FSC", STAC_927X_VOLKNOB),
  2996. {} /* terminator */
  2997. };
  2998. static const struct hda_pintbl ref9205_pin_configs[] = {
  2999. { 0x0a, 0x40000100 },
  3000. { 0x0b, 0x40000100 },
  3001. { 0x0c, 0x01016011 },
  3002. { 0x0d, 0x01014010 },
  3003. { 0x0e, 0x01813122 },
  3004. { 0x0f, 0x01a19021 },
  3005. { 0x14, 0x01019020 },
  3006. { 0x16, 0x40000100 },
  3007. { 0x17, 0x90a000f0 },
  3008. { 0x18, 0x90a000f0 },
  3009. { 0x21, 0x01441030 },
  3010. { 0x22, 0x01c41030 },
  3011. {}
  3012. };
  3013. /*
  3014. STAC 9205 pin configs for
  3015. 102801F1
  3016. 102801F2
  3017. 102801FC
  3018. 102801FD
  3019. 10280204
  3020. 1028021F
  3021. 10280228 (Dell Vostro 1500)
  3022. 10280229 (Dell Vostro 1700)
  3023. */
  3024. static const struct hda_pintbl dell_9205_m42_pin_configs[] = {
  3025. { 0x0a, 0x0321101F },
  3026. { 0x0b, 0x03A11020 },
  3027. { 0x0c, 0x400003FA },
  3028. { 0x0d, 0x90170310 },
  3029. { 0x0e, 0x400003FB },
  3030. { 0x0f, 0x400003FC },
  3031. { 0x14, 0x400003FD },
  3032. { 0x16, 0x40F000F9 },
  3033. { 0x17, 0x90A60330 },
  3034. { 0x18, 0x400003FF },
  3035. { 0x21, 0x0144131F },
  3036. { 0x22, 0x40C003FE },
  3037. {}
  3038. };
  3039. /*
  3040. STAC 9205 pin configs for
  3041. 102801F9
  3042. 102801FA
  3043. 102801FE
  3044. 102801FF (Dell Precision M4300)
  3045. 10280206
  3046. 10280200
  3047. 10280201
  3048. */
  3049. static const struct hda_pintbl dell_9205_m43_pin_configs[] = {
  3050. { 0x0a, 0x0321101f },
  3051. { 0x0b, 0x03a11020 },
  3052. { 0x0c, 0x90a70330 },
  3053. { 0x0d, 0x90170310 },
  3054. { 0x0e, 0x400000fe },
  3055. { 0x0f, 0x400000ff },
  3056. { 0x14, 0x400000fd },
  3057. { 0x16, 0x40f000f9 },
  3058. { 0x17, 0x400000fa },
  3059. { 0x18, 0x400000fc },
  3060. { 0x21, 0x0144131f },
  3061. { 0x22, 0x40c003f8 },
  3062. /* Enable SPDIF in/out */
  3063. { 0x1f, 0x01441030 },
  3064. { 0x20, 0x1c410030 },
  3065. {}
  3066. };
  3067. static const struct hda_pintbl dell_9205_m44_pin_configs[] = {
  3068. { 0x0a, 0x0421101f },
  3069. { 0x0b, 0x04a11020 },
  3070. { 0x0c, 0x400003fa },
  3071. { 0x0d, 0x90170310 },
  3072. { 0x0e, 0x400003fb },
  3073. { 0x0f, 0x400003fc },
  3074. { 0x14, 0x400003fd },
  3075. { 0x16, 0x400003f9 },
  3076. { 0x17, 0x90a60330 },
  3077. { 0x18, 0x400003ff },
  3078. { 0x21, 0x01441340 },
  3079. { 0x22, 0x40c003fe },
  3080. {}
  3081. };
  3082. static void stac9205_fixup_ref(struct hda_codec *codec,
  3083. const struct hda_fixup *fix, int action)
  3084. {
  3085. struct sigmatel_spec *spec = codec->spec;
  3086. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  3087. snd_hda_apply_pincfgs(codec, ref9205_pin_configs);
  3088. /* SPDIF-In enabled */
  3089. spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0;
  3090. }
  3091. }
  3092. static void stac9205_fixup_dell_m43(struct hda_codec *codec,
  3093. const struct hda_fixup *fix, int action)
  3094. {
  3095. struct sigmatel_spec *spec = codec->spec;
  3096. struct hda_jack_tbl *jack;
  3097. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  3098. snd_hda_apply_pincfgs(codec, dell_9205_m43_pin_configs);
  3099. /* Enable unsol response for GPIO4/Dock HP connection */
  3100. snd_hda_codec_write_cache(codec, codec->afg, 0,
  3101. AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK, 0x10);
  3102. snd_hda_jack_detect_enable_callback(codec, codec->afg,
  3103. STAC_VREF_EVENT,
  3104. stac_vref_event);
  3105. jack = snd_hda_jack_tbl_get(codec, codec->afg);
  3106. if (jack)
  3107. jack->private_data = 0x01;
  3108. spec->gpio_dir = 0x0b;
  3109. spec->eapd_mask = 0x01;
  3110. spec->gpio_mask = 0x1b;
  3111. spec->gpio_mute = 0x10;
  3112. /* GPIO0 High = EAPD, GPIO1 Low = Headphone Mute,
  3113. * GPIO3 Low = DRM
  3114. */
  3115. spec->gpio_data = 0x01;
  3116. }
  3117. }
  3118. static void stac9205_fixup_eapd(struct hda_codec *codec,
  3119. const struct hda_fixup *fix, int action)
  3120. {
  3121. struct sigmatel_spec *spec = codec->spec;
  3122. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  3123. spec->eapd_switch = 0;
  3124. }
  3125. static const struct hda_fixup stac9205_fixups[] = {
  3126. [STAC_9205_REF] = {
  3127. .type = HDA_FIXUP_FUNC,
  3128. .v.func = stac9205_fixup_ref,
  3129. },
  3130. [STAC_9205_DELL_M42] = {
  3131. .type = HDA_FIXUP_PINS,
  3132. .v.pins = dell_9205_m42_pin_configs,
  3133. },
  3134. [STAC_9205_DELL_M43] = {
  3135. .type = HDA_FIXUP_FUNC,
  3136. .v.func = stac9205_fixup_dell_m43,
  3137. },
  3138. [STAC_9205_DELL_M44] = {
  3139. .type = HDA_FIXUP_PINS,
  3140. .v.pins = dell_9205_m44_pin_configs,
  3141. },
  3142. [STAC_9205_EAPD] = {
  3143. .type = HDA_FIXUP_FUNC,
  3144. .v.func = stac9205_fixup_eapd,
  3145. },
  3146. {}
  3147. };
  3148. static const struct hda_model_fixup stac9205_models[] = {
  3149. { .id = STAC_9205_REF, .name = "ref" },
  3150. { .id = STAC_9205_DELL_M42, .name = "dell-m42" },
  3151. { .id = STAC_9205_DELL_M43, .name = "dell-m43" },
  3152. { .id = STAC_9205_DELL_M44, .name = "dell-m44" },
  3153. { .id = STAC_9205_EAPD, .name = "eapd" },
  3154. {}
  3155. };
  3156. static const struct snd_pci_quirk stac9205_fixup_tbl[] = {
  3157. /* SigmaTel reference board */
  3158. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  3159. "DFI LanParty", STAC_9205_REF),
  3160. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xfb30,
  3161. "SigmaTel", STAC_9205_REF),
  3162. SND_PCI_QUIRK(PCI_VENDOR_ID_DFI, 0x3101,
  3163. "DFI LanParty", STAC_9205_REF),
  3164. /* Dell */
  3165. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f1,
  3166. "unknown Dell", STAC_9205_DELL_M42),
  3167. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f2,
  3168. "unknown Dell", STAC_9205_DELL_M42),
  3169. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f8,
  3170. "Dell Precision", STAC_9205_DELL_M43),
  3171. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f9,
  3172. "Dell Precision", STAC_9205_DELL_M43),
  3173. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fa,
  3174. "Dell Precision", STAC_9205_DELL_M43),
  3175. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fc,
  3176. "unknown Dell", STAC_9205_DELL_M42),
  3177. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fd,
  3178. "unknown Dell", STAC_9205_DELL_M42),
  3179. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01fe,
  3180. "Dell Precision", STAC_9205_DELL_M43),
  3181. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ff,
  3182. "Dell Precision M4300", STAC_9205_DELL_M43),
  3183. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0204,
  3184. "unknown Dell", STAC_9205_DELL_M42),
  3185. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0206,
  3186. "Dell Precision", STAC_9205_DELL_M43),
  3187. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021b,
  3188. "Dell Precision", STAC_9205_DELL_M43),
  3189. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021c,
  3190. "Dell Precision", STAC_9205_DELL_M43),
  3191. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x021f,
  3192. "Dell Inspiron", STAC_9205_DELL_M44),
  3193. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0228,
  3194. "Dell Vostro 1500", STAC_9205_DELL_M42),
  3195. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x0229,
  3196. "Dell Vostro 1700", STAC_9205_DELL_M42),
  3197. /* Gateway */
  3198. SND_PCI_QUIRK(0x107b, 0x0560, "Gateway T6834c", STAC_9205_EAPD),
  3199. SND_PCI_QUIRK(0x107b, 0x0565, "Gateway T1616", STAC_9205_EAPD),
  3200. {} /* terminator */
  3201. };
  3202. static int stac_parse_auto_config(struct hda_codec *codec)
  3203. {
  3204. struct sigmatel_spec *spec = codec->spec;
  3205. int err;
  3206. int flags = 0;
  3207. if (spec->headset_jack)
  3208. flags |= HDA_PINCFG_HEADSET_MIC;
  3209. err = snd_hda_parse_pin_defcfg(codec, &spec->gen.autocfg, NULL, flags);
  3210. if (err < 0)
  3211. return err;
  3212. /* add hooks */
  3213. spec->gen.pcm_playback_hook = stac_playback_pcm_hook;
  3214. spec->gen.pcm_capture_hook = stac_capture_pcm_hook;
  3215. spec->gen.automute_hook = stac_update_outputs;
  3216. spec->gen.hp_automute_hook = stac_hp_automute;
  3217. spec->gen.line_automute_hook = stac_line_automute;
  3218. spec->gen.mic_autoswitch_hook = stac_mic_autoswitch;
  3219. err = snd_hda_gen_parse_auto_config(codec, &spec->gen.autocfg);
  3220. if (err < 0)
  3221. return err;
  3222. /* minimum value is actually mute */
  3223. spec->gen.vmaster_tlv[3] |= TLV_DB_SCALE_MUTE;
  3224. /* setup analog beep controls */
  3225. if (spec->anabeep_nid > 0) {
  3226. err = stac_auto_create_beep_ctls(codec,
  3227. spec->anabeep_nid);
  3228. if (err < 0)
  3229. return err;
  3230. }
  3231. /* setup digital beep controls and input device */
  3232. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  3233. if (spec->gen.beep_nid) {
  3234. hda_nid_t nid = spec->gen.beep_nid;
  3235. unsigned int caps;
  3236. err = stac_auto_create_beep_ctls(codec, nid);
  3237. if (err < 0)
  3238. return err;
  3239. if (codec->beep) {
  3240. /* IDT/STAC codecs have linear beep tone parameter */
  3241. codec->beep->linear_tone = spec->linear_tone_beep;
  3242. /* if no beep switch is available, make its own one */
  3243. caps = query_amp_caps(codec, nid, HDA_OUTPUT);
  3244. if (!(caps & AC_AMPCAP_MUTE)) {
  3245. err = stac_beep_switch_ctl(codec);
  3246. if (err < 0)
  3247. return err;
  3248. }
  3249. }
  3250. }
  3251. #endif
  3252. if (spec->gpio_led)
  3253. spec->gen.vmaster_mute.hook = stac_vmaster_hook;
  3254. if (spec->aloopback_ctl &&
  3255. snd_hda_get_bool_hint(codec, "loopback") == 1) {
  3256. if (!snd_hda_gen_add_kctl(&spec->gen, NULL, spec->aloopback_ctl))
  3257. return -ENOMEM;
  3258. }
  3259. if (spec->have_spdif_mux) {
  3260. err = stac_create_spdif_mux_ctls(codec);
  3261. if (err < 0)
  3262. return err;
  3263. }
  3264. stac_init_power_map(codec);
  3265. return 0;
  3266. }
  3267. static int stac_init(struct hda_codec *codec)
  3268. {
  3269. struct sigmatel_spec *spec = codec->spec;
  3270. int i;
  3271. /* override some hints */
  3272. stac_store_hints(codec);
  3273. /* set up GPIO */
  3274. /* turn on EAPD statically when spec->eapd_switch isn't set.
  3275. * otherwise, unsol event will turn it on/off dynamically
  3276. */
  3277. if (!spec->eapd_switch)
  3278. spec->gpio_data |= spec->eapd_mask;
  3279. stac_gpio_set(codec, spec->gpio_mask, spec->gpio_dir, spec->gpio_data);
  3280. snd_hda_gen_init(codec);
  3281. /* sync the power-map */
  3282. if (spec->num_pwrs)
  3283. snd_hda_codec_write(codec, codec->afg, 0,
  3284. AC_VERB_IDT_SET_POWER_MAP,
  3285. spec->power_map_bits);
  3286. /* power down inactive ADCs */
  3287. if (spec->powerdown_adcs) {
  3288. for (i = 0; i < spec->gen.num_all_adcs; i++) {
  3289. if (spec->active_adcs & (1 << i))
  3290. continue;
  3291. snd_hda_codec_write(codec, spec->gen.all_adcs[i], 0,
  3292. AC_VERB_SET_POWER_STATE,
  3293. AC_PWRST_D3);
  3294. }
  3295. }
  3296. return 0;
  3297. }
  3298. static void stac_shutup(struct hda_codec *codec)
  3299. {
  3300. struct sigmatel_spec *spec = codec->spec;
  3301. snd_hda_shutup_pins(codec);
  3302. if (spec->eapd_mask)
  3303. stac_gpio_set(codec, spec->gpio_mask,
  3304. spec->gpio_dir, spec->gpio_data &
  3305. ~spec->eapd_mask);
  3306. }
  3307. #define stac_free snd_hda_gen_free
  3308. #ifdef CONFIG_PROC_FS
  3309. static void stac92hd_proc_hook(struct snd_info_buffer *buffer,
  3310. struct hda_codec *codec, hda_nid_t nid)
  3311. {
  3312. if (nid == codec->afg)
  3313. snd_iprintf(buffer, "Power-Map: 0x%02x\n",
  3314. snd_hda_codec_read(codec, nid, 0,
  3315. AC_VERB_IDT_GET_POWER_MAP, 0));
  3316. }
  3317. static void analog_loop_proc_hook(struct snd_info_buffer *buffer,
  3318. struct hda_codec *codec,
  3319. unsigned int verb)
  3320. {
  3321. snd_iprintf(buffer, "Analog Loopback: 0x%02x\n",
  3322. snd_hda_codec_read(codec, codec->afg, 0, verb, 0));
  3323. }
  3324. /* stac92hd71bxx, stac92hd73xx */
  3325. static void stac92hd7x_proc_hook(struct snd_info_buffer *buffer,
  3326. struct hda_codec *codec, hda_nid_t nid)
  3327. {
  3328. stac92hd_proc_hook(buffer, codec, nid);
  3329. if (nid == codec->afg)
  3330. analog_loop_proc_hook(buffer, codec, 0xfa0);
  3331. }
  3332. static void stac9205_proc_hook(struct snd_info_buffer *buffer,
  3333. struct hda_codec *codec, hda_nid_t nid)
  3334. {
  3335. if (nid == codec->afg)
  3336. analog_loop_proc_hook(buffer, codec, 0xfe0);
  3337. }
  3338. static void stac927x_proc_hook(struct snd_info_buffer *buffer,
  3339. struct hda_codec *codec, hda_nid_t nid)
  3340. {
  3341. if (nid == codec->afg)
  3342. analog_loop_proc_hook(buffer, codec, 0xfeb);
  3343. }
  3344. #else
  3345. #define stac92hd_proc_hook NULL
  3346. #define stac92hd7x_proc_hook NULL
  3347. #define stac9205_proc_hook NULL
  3348. #define stac927x_proc_hook NULL
  3349. #endif
  3350. #ifdef CONFIG_PM
  3351. static int stac_suspend(struct hda_codec *codec)
  3352. {
  3353. stac_shutup(codec);
  3354. return 0;
  3355. }
  3356. static void stac_set_power_state(struct hda_codec *codec, hda_nid_t fg,
  3357. unsigned int power_state)
  3358. {
  3359. unsigned int afg_power_state = power_state;
  3360. struct sigmatel_spec *spec = codec->spec;
  3361. if (power_state == AC_PWRST_D3) {
  3362. if (spec->vref_mute_led_nid) {
  3363. /* with vref-out pin used for mute led control
  3364. * codec AFG is prevented from D3 state
  3365. */
  3366. afg_power_state = AC_PWRST_D1;
  3367. }
  3368. /* this delay seems necessary to avoid click noise at power-down */
  3369. msleep(100);
  3370. }
  3371. snd_hda_codec_read(codec, fg, 0, AC_VERB_SET_POWER_STATE,
  3372. afg_power_state);
  3373. snd_hda_codec_set_power_to_all(codec, fg, power_state);
  3374. }
  3375. #else
  3376. #define stac_suspend NULL
  3377. #define stac_set_power_state NULL
  3378. #endif /* CONFIG_PM */
  3379. static const struct hda_codec_ops stac_patch_ops = {
  3380. .build_controls = snd_hda_gen_build_controls,
  3381. .build_pcms = snd_hda_gen_build_pcms,
  3382. .init = stac_init,
  3383. .free = stac_free,
  3384. .unsol_event = snd_hda_jack_unsol_event,
  3385. #ifdef CONFIG_PM
  3386. .suspend = stac_suspend,
  3387. #endif
  3388. .reboot_notify = stac_shutup,
  3389. };
  3390. static int alloc_stac_spec(struct hda_codec *codec)
  3391. {
  3392. struct sigmatel_spec *spec;
  3393. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3394. if (!spec)
  3395. return -ENOMEM;
  3396. snd_hda_gen_spec_init(&spec->gen);
  3397. codec->spec = spec;
  3398. codec->no_trigger_sense = 1; /* seems common with STAC/IDT codecs */
  3399. return 0;
  3400. }
  3401. static int patch_stac9200(struct hda_codec *codec)
  3402. {
  3403. struct sigmatel_spec *spec;
  3404. int err;
  3405. err = alloc_stac_spec(codec);
  3406. if (err < 0)
  3407. return err;
  3408. spec = codec->spec;
  3409. spec->linear_tone_beep = 1;
  3410. spec->gen.own_eapd_ctl = 1;
  3411. codec->patch_ops = stac_patch_ops;
  3412. codec->power_filter = snd_hda_codec_eapd_power_filter;
  3413. snd_hda_add_verbs(codec, stac9200_eapd_init);
  3414. snd_hda_pick_fixup(codec, stac9200_models, stac9200_fixup_tbl,
  3415. stac9200_fixups);
  3416. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  3417. err = stac_parse_auto_config(codec);
  3418. if (err < 0) {
  3419. stac_free(codec);
  3420. return err;
  3421. }
  3422. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  3423. return 0;
  3424. }
  3425. static int patch_stac925x(struct hda_codec *codec)
  3426. {
  3427. struct sigmatel_spec *spec;
  3428. int err;
  3429. err = alloc_stac_spec(codec);
  3430. if (err < 0)
  3431. return err;
  3432. spec = codec->spec;
  3433. spec->linear_tone_beep = 1;
  3434. spec->gen.own_eapd_ctl = 1;
  3435. codec->patch_ops = stac_patch_ops;
  3436. snd_hda_add_verbs(codec, stac925x_core_init);
  3437. snd_hda_pick_fixup(codec, stac925x_models, stac925x_fixup_tbl,
  3438. stac925x_fixups);
  3439. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  3440. err = stac_parse_auto_config(codec);
  3441. if (err < 0) {
  3442. stac_free(codec);
  3443. return err;
  3444. }
  3445. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  3446. return 0;
  3447. }
  3448. static int patch_stac92hd73xx(struct hda_codec *codec)
  3449. {
  3450. struct sigmatel_spec *spec;
  3451. int err;
  3452. int num_dacs;
  3453. err = alloc_stac_spec(codec);
  3454. if (err < 0)
  3455. return err;
  3456. spec = codec->spec;
  3457. spec->linear_tone_beep = 0;
  3458. spec->gen.mixer_nid = 0x1d;
  3459. spec->have_spdif_mux = 1;
  3460. num_dacs = snd_hda_get_num_conns(codec, 0x0a) - 1;
  3461. if (num_dacs < 3 || num_dacs > 5) {
  3462. printk(KERN_WARNING "hda_codec: Could not determine "
  3463. "number of channels defaulting to DAC count\n");
  3464. num_dacs = 5;
  3465. }
  3466. switch (num_dacs) {
  3467. case 0x3: /* 6 Channel */
  3468. spec->aloopback_ctl = &stac92hd73xx_6ch_loopback;
  3469. break;
  3470. case 0x4: /* 8 Channel */
  3471. spec->aloopback_ctl = &stac92hd73xx_8ch_loopback;
  3472. break;
  3473. case 0x5: /* 10 Channel */
  3474. spec->aloopback_ctl = &stac92hd73xx_10ch_loopback;
  3475. break;
  3476. }
  3477. spec->aloopback_mask = 0x01;
  3478. spec->aloopback_shift = 8;
  3479. spec->gen.beep_nid = 0x1c; /* digital beep */
  3480. /* GPIO0 High = Enable EAPD */
  3481. spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
  3482. spec->gpio_data = 0x01;
  3483. spec->eapd_switch = 1;
  3484. spec->num_pwrs = ARRAY_SIZE(stac92hd73xx_pwr_nids);
  3485. spec->pwr_nids = stac92hd73xx_pwr_nids;
  3486. spec->gen.own_eapd_ctl = 1;
  3487. spec->gen.power_down_unused = 1;
  3488. codec->patch_ops = stac_patch_ops;
  3489. snd_hda_pick_fixup(codec, stac92hd73xx_models, stac92hd73xx_fixup_tbl,
  3490. stac92hd73xx_fixups);
  3491. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  3492. if (!spec->volknob_init)
  3493. snd_hda_add_verbs(codec, stac92hd73xx_core_init);
  3494. err = stac_parse_auto_config(codec);
  3495. if (err < 0) {
  3496. stac_free(codec);
  3497. return err;
  3498. }
  3499. /* Don't GPIO-mute speakers if there are no internal speakers, because
  3500. * the GPIO might be necessary for Headphone
  3501. */
  3502. if (spec->eapd_switch && !has_builtin_speaker(codec))
  3503. spec->eapd_switch = 0;
  3504. codec->proc_widget_hook = stac92hd7x_proc_hook;
  3505. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  3506. return 0;
  3507. }
  3508. static void stac_setup_gpio(struct hda_codec *codec)
  3509. {
  3510. struct sigmatel_spec *spec = codec->spec;
  3511. spec->gpio_mask |= spec->eapd_mask;
  3512. if (spec->gpio_led) {
  3513. if (!spec->vref_mute_led_nid) {
  3514. spec->gpio_mask |= spec->gpio_led;
  3515. spec->gpio_dir |= spec->gpio_led;
  3516. spec->gpio_data |= spec->gpio_led;
  3517. } else {
  3518. codec->patch_ops.set_power_state =
  3519. stac_set_power_state;
  3520. }
  3521. }
  3522. if (spec->mic_mute_led_gpio) {
  3523. spec->gpio_mask |= spec->mic_mute_led_gpio;
  3524. spec->gpio_dir |= spec->mic_mute_led_gpio;
  3525. spec->mic_mute_led_on = true;
  3526. spec->gpio_data |= spec->mic_mute_led_gpio;
  3527. spec->gen.cap_sync_hook = stac_capture_led_hook;
  3528. }
  3529. }
  3530. static int patch_stac92hd83xxx(struct hda_codec *codec)
  3531. {
  3532. struct sigmatel_spec *spec;
  3533. int err;
  3534. err = alloc_stac_spec(codec);
  3535. if (err < 0)
  3536. return err;
  3537. codec->epss = 0; /* longer delay needed for D3 */
  3538. spec = codec->spec;
  3539. spec->linear_tone_beep = 0;
  3540. spec->gen.own_eapd_ctl = 1;
  3541. spec->gen.power_down_unused = 1;
  3542. spec->gen.mixer_nid = 0x1b;
  3543. spec->gen.beep_nid = 0x21; /* digital beep */
  3544. spec->pwr_nids = stac92hd83xxx_pwr_nids;
  3545. spec->num_pwrs = ARRAY_SIZE(stac92hd83xxx_pwr_nids);
  3546. spec->default_polarity = -1; /* no default cfg */
  3547. codec->patch_ops = stac_patch_ops;
  3548. snd_hda_add_verbs(codec, stac92hd83xxx_core_init);
  3549. snd_hda_pick_fixup(codec, stac92hd83xxx_models, stac92hd83xxx_fixup_tbl,
  3550. stac92hd83xxx_fixups);
  3551. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  3552. stac_setup_gpio(codec);
  3553. err = stac_parse_auto_config(codec);
  3554. if (err < 0) {
  3555. stac_free(codec);
  3556. return err;
  3557. }
  3558. codec->proc_widget_hook = stac92hd_proc_hook;
  3559. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  3560. return 0;
  3561. }
  3562. static const hda_nid_t stac92hd95_pwr_nids[] = {
  3563. 0x0a, 0x0b, 0x0c, 0x0d
  3564. };
  3565. static int patch_stac92hd95(struct hda_codec *codec)
  3566. {
  3567. struct sigmatel_spec *spec;
  3568. int err;
  3569. err = alloc_stac_spec(codec);
  3570. if (err < 0)
  3571. return err;
  3572. codec->epss = 0; /* longer delay needed for D3 */
  3573. spec = codec->spec;
  3574. spec->linear_tone_beep = 0;
  3575. spec->gen.own_eapd_ctl = 1;
  3576. spec->gen.power_down_unused = 1;
  3577. spec->gen.beep_nid = 0x19; /* digital beep */
  3578. spec->pwr_nids = stac92hd95_pwr_nids;
  3579. spec->num_pwrs = ARRAY_SIZE(stac92hd95_pwr_nids);
  3580. spec->default_polarity = -1; /* no default cfg */
  3581. codec->patch_ops = stac_patch_ops;
  3582. err = stac_parse_auto_config(codec);
  3583. if (err < 0) {
  3584. stac_free(codec);
  3585. return err;
  3586. }
  3587. codec->proc_widget_hook = stac92hd_proc_hook;
  3588. return 0;
  3589. }
  3590. static int patch_stac92hd71bxx(struct hda_codec *codec)
  3591. {
  3592. struct sigmatel_spec *spec;
  3593. const struct hda_verb *unmute_init = stac92hd71bxx_unmute_core_init;
  3594. int err;
  3595. err = alloc_stac_spec(codec);
  3596. if (err < 0)
  3597. return err;
  3598. spec = codec->spec;
  3599. spec->linear_tone_beep = 0;
  3600. spec->gen.own_eapd_ctl = 1;
  3601. spec->gen.power_down_unused = 1;
  3602. spec->gen.mixer_nid = 0x17;
  3603. spec->have_spdif_mux = 1;
  3604. codec->patch_ops = stac_patch_ops;
  3605. /* GPIO0 = EAPD */
  3606. spec->gpio_mask = 0x01;
  3607. spec->gpio_dir = 0x01;
  3608. spec->gpio_data = 0x01;
  3609. switch (codec->vendor_id) {
  3610. case 0x111d76b6: /* 4 Port without Analog Mixer */
  3611. case 0x111d76b7:
  3612. unmute_init++;
  3613. break;
  3614. case 0x111d7608: /* 5 Port with Analog Mixer */
  3615. if ((codec->revision_id & 0xf) == 0 ||
  3616. (codec->revision_id & 0xf) == 1)
  3617. spec->stream_delay = 40; /* 40 milliseconds */
  3618. /* disable VSW */
  3619. unmute_init++;
  3620. snd_hda_codec_set_pincfg(codec, 0x0f, 0x40f000f0);
  3621. snd_hda_codec_set_pincfg(codec, 0x19, 0x40f000f3);
  3622. break;
  3623. case 0x111d7603: /* 6 Port with Analog Mixer */
  3624. if ((codec->revision_id & 0xf) == 1)
  3625. spec->stream_delay = 40; /* 40 milliseconds */
  3626. break;
  3627. }
  3628. if (get_wcaps_type(get_wcaps(codec, 0x28)) == AC_WID_VOL_KNB)
  3629. snd_hda_add_verbs(codec, stac92hd71bxx_core_init);
  3630. if (get_wcaps(codec, 0xa) & AC_WCAP_IN_AMP)
  3631. snd_hda_sequence_write_cache(codec, unmute_init);
  3632. spec->aloopback_ctl = &stac92hd71bxx_loopback;
  3633. spec->aloopback_mask = 0x50;
  3634. spec->aloopback_shift = 0;
  3635. spec->powerdown_adcs = 1;
  3636. spec->gen.beep_nid = 0x26; /* digital beep */
  3637. spec->num_pwrs = ARRAY_SIZE(stac92hd71bxx_pwr_nids);
  3638. spec->pwr_nids = stac92hd71bxx_pwr_nids;
  3639. snd_hda_pick_fixup(codec, stac92hd71bxx_models, stac92hd71bxx_fixup_tbl,
  3640. stac92hd71bxx_fixups);
  3641. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  3642. stac_setup_gpio(codec);
  3643. err = stac_parse_auto_config(codec);
  3644. if (err < 0) {
  3645. stac_free(codec);
  3646. return err;
  3647. }
  3648. codec->proc_widget_hook = stac92hd7x_proc_hook;
  3649. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  3650. return 0;
  3651. }
  3652. static int patch_stac922x(struct hda_codec *codec)
  3653. {
  3654. struct sigmatel_spec *spec;
  3655. int err;
  3656. err = alloc_stac_spec(codec);
  3657. if (err < 0)
  3658. return err;
  3659. spec = codec->spec;
  3660. spec->linear_tone_beep = 1;
  3661. spec->gen.own_eapd_ctl = 1;
  3662. codec->patch_ops = stac_patch_ops;
  3663. snd_hda_add_verbs(codec, stac922x_core_init);
  3664. /* Fix Mux capture level; max to 2 */
  3665. snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
  3666. (0 << AC_AMPCAP_OFFSET_SHIFT) |
  3667. (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
  3668. (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
  3669. (0 << AC_AMPCAP_MUTE_SHIFT));
  3670. snd_hda_pick_fixup(codec, stac922x_models, stac922x_fixup_tbl,
  3671. stac922x_fixups);
  3672. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  3673. err = stac_parse_auto_config(codec);
  3674. if (err < 0) {
  3675. stac_free(codec);
  3676. return err;
  3677. }
  3678. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  3679. return 0;
  3680. }
  3681. static const char * const stac927x_spdif_labels[] = {
  3682. "Digital Playback", "ADAT", "Analog Mux 1",
  3683. "Analog Mux 2", "Analog Mux 3", NULL
  3684. };
  3685. static int patch_stac927x(struct hda_codec *codec)
  3686. {
  3687. struct sigmatel_spec *spec;
  3688. int err;
  3689. err = alloc_stac_spec(codec);
  3690. if (err < 0)
  3691. return err;
  3692. spec = codec->spec;
  3693. spec->linear_tone_beep = 1;
  3694. spec->gen.own_eapd_ctl = 1;
  3695. spec->have_spdif_mux = 1;
  3696. spec->spdif_labels = stac927x_spdif_labels;
  3697. spec->gen.beep_nid = 0x23; /* digital beep */
  3698. /* GPIO0 High = Enable EAPD */
  3699. spec->eapd_mask = spec->gpio_mask = 0x01;
  3700. spec->gpio_dir = spec->gpio_data = 0x01;
  3701. spec->aloopback_ctl = &stac927x_loopback;
  3702. spec->aloopback_mask = 0x40;
  3703. spec->aloopback_shift = 0;
  3704. spec->eapd_switch = 1;
  3705. codec->patch_ops = stac_patch_ops;
  3706. snd_hda_pick_fixup(codec, stac927x_models, stac927x_fixup_tbl,
  3707. stac927x_fixups);
  3708. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  3709. if (!spec->volknob_init)
  3710. snd_hda_add_verbs(codec, stac927x_core_init);
  3711. err = stac_parse_auto_config(codec);
  3712. if (err < 0) {
  3713. stac_free(codec);
  3714. return err;
  3715. }
  3716. codec->proc_widget_hook = stac927x_proc_hook;
  3717. /*
  3718. * !!FIXME!!
  3719. * The STAC927x seem to require fairly long delays for certain
  3720. * command sequences. With too short delays (even if the answer
  3721. * is set to RIRB properly), it results in the silence output
  3722. * on some hardwares like Dell.
  3723. *
  3724. * The below flag enables the longer delay (see get_response
  3725. * in hda_intel.c).
  3726. */
  3727. codec->bus->needs_damn_long_delay = 1;
  3728. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  3729. return 0;
  3730. }
  3731. static int patch_stac9205(struct hda_codec *codec)
  3732. {
  3733. struct sigmatel_spec *spec;
  3734. int err;
  3735. err = alloc_stac_spec(codec);
  3736. if (err < 0)
  3737. return err;
  3738. spec = codec->spec;
  3739. spec->linear_tone_beep = 1;
  3740. spec->gen.own_eapd_ctl = 1;
  3741. spec->have_spdif_mux = 1;
  3742. spec->gen.beep_nid = 0x23; /* digital beep */
  3743. snd_hda_add_verbs(codec, stac9205_core_init);
  3744. spec->aloopback_ctl = &stac9205_loopback;
  3745. spec->aloopback_mask = 0x40;
  3746. spec->aloopback_shift = 0;
  3747. /* GPIO0 High = EAPD */
  3748. spec->eapd_mask = spec->gpio_mask = spec->gpio_dir = 0x1;
  3749. spec->gpio_data = 0x01;
  3750. /* Turn on/off EAPD per HP plugging */
  3751. spec->eapd_switch = 1;
  3752. codec->patch_ops = stac_patch_ops;
  3753. snd_hda_pick_fixup(codec, stac9205_models, stac9205_fixup_tbl,
  3754. stac9205_fixups);
  3755. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  3756. err = stac_parse_auto_config(codec);
  3757. if (err < 0) {
  3758. stac_free(codec);
  3759. return err;
  3760. }
  3761. codec->proc_widget_hook = stac9205_proc_hook;
  3762. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  3763. return 0;
  3764. }
  3765. /*
  3766. * STAC9872 hack
  3767. */
  3768. static const struct hda_verb stac9872_core_init[] = {
  3769. {0x15, AC_VERB_SET_CONNECT_SEL, 0x1}, /* mic-sel: 0a,0d,14,02 */
  3770. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
  3771. {}
  3772. };
  3773. static const struct hda_pintbl stac9872_vaio_pin_configs[] = {
  3774. { 0x0a, 0x03211020 },
  3775. { 0x0b, 0x411111f0 },
  3776. { 0x0c, 0x411111f0 },
  3777. { 0x0d, 0x03a15030 },
  3778. { 0x0e, 0x411111f0 },
  3779. { 0x0f, 0x90170110 },
  3780. { 0x11, 0x411111f0 },
  3781. { 0x13, 0x411111f0 },
  3782. { 0x14, 0x90a7013e },
  3783. {}
  3784. };
  3785. static const struct hda_model_fixup stac9872_models[] = {
  3786. { .id = STAC_9872_VAIO, .name = "vaio" },
  3787. {}
  3788. };
  3789. static const struct hda_fixup stac9872_fixups[] = {
  3790. [STAC_9872_VAIO] = {
  3791. .type = HDA_FIXUP_PINS,
  3792. .v.pins = stac9872_vaio_pin_configs,
  3793. },
  3794. };
  3795. static const struct snd_pci_quirk stac9872_fixup_tbl[] = {
  3796. SND_PCI_QUIRK_MASK(0x104d, 0xfff0, 0x81e0,
  3797. "Sony VAIO F/S", STAC_9872_VAIO),
  3798. {} /* terminator */
  3799. };
  3800. static int patch_stac9872(struct hda_codec *codec)
  3801. {
  3802. struct sigmatel_spec *spec;
  3803. int err;
  3804. err = alloc_stac_spec(codec);
  3805. if (err < 0)
  3806. return err;
  3807. spec = codec->spec;
  3808. spec->linear_tone_beep = 1;
  3809. spec->gen.own_eapd_ctl = 1;
  3810. codec->patch_ops = stac_patch_ops;
  3811. snd_hda_add_verbs(codec, stac9872_core_init);
  3812. snd_hda_pick_fixup(codec, stac9872_models, stac9872_fixup_tbl,
  3813. stac9872_fixups);
  3814. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  3815. err = stac_parse_auto_config(codec);
  3816. if (err < 0) {
  3817. stac_free(codec);
  3818. return -EINVAL;
  3819. }
  3820. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  3821. return 0;
  3822. }
  3823. /*
  3824. * patch entries
  3825. */
  3826. static const struct hda_codec_preset snd_hda_preset_sigmatel[] = {
  3827. { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
  3828. { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
  3829. { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
  3830. { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
  3831. { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
  3832. { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
  3833. { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
  3834. { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
  3835. { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
  3836. { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
  3837. { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
  3838. { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
  3839. { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
  3840. { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
  3841. { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
  3842. { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
  3843. { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
  3844. { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
  3845. { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
  3846. { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
  3847. { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
  3848. { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
  3849. { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
  3850. { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
  3851. { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
  3852. { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
  3853. { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
  3854. { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
  3855. { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
  3856. { .id = 0x83847645, .name = "92HD206X", .patch = patch_stac927x },
  3857. { .id = 0x83847646, .name = "92HD206D", .patch = patch_stac927x },
  3858. /* The following does not take into account .id=0x83847661 when subsys =
  3859. * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
  3860. * currently not fully supported.
  3861. */
  3862. { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
  3863. { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
  3864. { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
  3865. { .id = 0x83847698, .name = "STAC9205", .patch = patch_stac9205 },
  3866. { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
  3867. { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
  3868. { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
  3869. { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
  3870. { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
  3871. { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
  3872. { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
  3873. { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
  3874. { .id = 0x111d7603, .name = "92HD75B3X5", .patch = patch_stac92hd71bxx},
  3875. { .id = 0x111d7604, .name = "92HD83C1X5", .patch = patch_stac92hd83xxx},
  3876. { .id = 0x111d76d4, .name = "92HD83C1C5", .patch = patch_stac92hd83xxx},
  3877. { .id = 0x111d7605, .name = "92HD81B1X5", .patch = patch_stac92hd83xxx},
  3878. { .id = 0x111d76d5, .name = "92HD81B1C5", .patch = patch_stac92hd83xxx},
  3879. { .id = 0x111d76d1, .name = "92HD87B1/3", .patch = patch_stac92hd83xxx},
  3880. { .id = 0x111d76d9, .name = "92HD87B2/4", .patch = patch_stac92hd83xxx},
  3881. { .id = 0x111d7666, .name = "92HD88B3", .patch = patch_stac92hd83xxx},
  3882. { .id = 0x111d7667, .name = "92HD88B1", .patch = patch_stac92hd83xxx},
  3883. { .id = 0x111d7668, .name = "92HD88B2", .patch = patch_stac92hd83xxx},
  3884. { .id = 0x111d7669, .name = "92HD88B4", .patch = patch_stac92hd83xxx},
  3885. { .id = 0x111d7608, .name = "92HD75B2X5", .patch = patch_stac92hd71bxx},
  3886. { .id = 0x111d7674, .name = "92HD73D1X5", .patch = patch_stac92hd73xx },
  3887. { .id = 0x111d7675, .name = "92HD73C1X5", .patch = patch_stac92hd73xx },
  3888. { .id = 0x111d7676, .name = "92HD73E1X5", .patch = patch_stac92hd73xx },
  3889. { .id = 0x111d7695, .name = "92HD95", .patch = patch_stac92hd95 },
  3890. { .id = 0x111d76b0, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
  3891. { .id = 0x111d76b1, .name = "92HD71B8X", .patch = patch_stac92hd71bxx },
  3892. { .id = 0x111d76b2, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
  3893. { .id = 0x111d76b3, .name = "92HD71B7X", .patch = patch_stac92hd71bxx },
  3894. { .id = 0x111d76b4, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
  3895. { .id = 0x111d76b5, .name = "92HD71B6X", .patch = patch_stac92hd71bxx },
  3896. { .id = 0x111d76b6, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
  3897. { .id = 0x111d76b7, .name = "92HD71B5X", .patch = patch_stac92hd71bxx },
  3898. { .id = 0x111d76c0, .name = "92HD89C3", .patch = patch_stac92hd73xx },
  3899. { .id = 0x111d76c1, .name = "92HD89C2", .patch = patch_stac92hd73xx },
  3900. { .id = 0x111d76c2, .name = "92HD89C1", .patch = patch_stac92hd73xx },
  3901. { .id = 0x111d76c3, .name = "92HD89B3", .patch = patch_stac92hd73xx },
  3902. { .id = 0x111d76c4, .name = "92HD89B2", .patch = patch_stac92hd73xx },
  3903. { .id = 0x111d76c5, .name = "92HD89B1", .patch = patch_stac92hd73xx },
  3904. { .id = 0x111d76c6, .name = "92HD89E3", .patch = patch_stac92hd73xx },
  3905. { .id = 0x111d76c7, .name = "92HD89E2", .patch = patch_stac92hd73xx },
  3906. { .id = 0x111d76c8, .name = "92HD89E1", .patch = patch_stac92hd73xx },
  3907. { .id = 0x111d76c9, .name = "92HD89D3", .patch = patch_stac92hd73xx },
  3908. { .id = 0x111d76ca, .name = "92HD89D2", .patch = patch_stac92hd73xx },
  3909. { .id = 0x111d76cb, .name = "92HD89D1", .patch = patch_stac92hd73xx },
  3910. { .id = 0x111d76cc, .name = "92HD89F3", .patch = patch_stac92hd73xx },
  3911. { .id = 0x111d76cd, .name = "92HD89F2", .patch = patch_stac92hd73xx },
  3912. { .id = 0x111d76ce, .name = "92HD89F1", .patch = patch_stac92hd73xx },
  3913. { .id = 0x111d76df, .name = "92HD93BXX", .patch = patch_stac92hd83xxx},
  3914. { .id = 0x111d76e0, .name = "92HD91BXX", .patch = patch_stac92hd83xxx},
  3915. { .id = 0x111d76e3, .name = "92HD98BXX", .patch = patch_stac92hd83xxx},
  3916. { .id = 0x111d76e5, .name = "92HD99BXX", .patch = patch_stac92hd83xxx},
  3917. { .id = 0x111d76e7, .name = "92HD90BXX", .patch = patch_stac92hd83xxx},
  3918. { .id = 0x111d76e8, .name = "92HD66B1X5", .patch = patch_stac92hd83xxx},
  3919. { .id = 0x111d76e9, .name = "92HD66B2X5", .patch = patch_stac92hd83xxx},
  3920. { .id = 0x111d76ea, .name = "92HD66B3X5", .patch = patch_stac92hd83xxx},
  3921. { .id = 0x111d76eb, .name = "92HD66C1X5", .patch = patch_stac92hd83xxx},
  3922. { .id = 0x111d76ec, .name = "92HD66C2X5", .patch = patch_stac92hd83xxx},
  3923. { .id = 0x111d76ed, .name = "92HD66C3X5", .patch = patch_stac92hd83xxx},
  3924. { .id = 0x111d76ee, .name = "92HD66B1X3", .patch = patch_stac92hd83xxx},
  3925. { .id = 0x111d76ef, .name = "92HD66B2X3", .patch = patch_stac92hd83xxx},
  3926. { .id = 0x111d76f0, .name = "92HD66B3X3", .patch = patch_stac92hd83xxx},
  3927. { .id = 0x111d76f1, .name = "92HD66C1X3", .patch = patch_stac92hd83xxx},
  3928. { .id = 0x111d76f2, .name = "92HD66C2X3", .patch = patch_stac92hd83xxx},
  3929. { .id = 0x111d76f3, .name = "92HD66C3/65", .patch = patch_stac92hd83xxx},
  3930. {} /* terminator */
  3931. };
  3932. MODULE_ALIAS("snd-hda-codec-id:8384*");
  3933. MODULE_ALIAS("snd-hda-codec-id:111d*");
  3934. MODULE_LICENSE("GPL");
  3935. MODULE_DESCRIPTION("IDT/Sigmatel HD-audio codec");
  3936. static struct hda_codec_preset_list sigmatel_list = {
  3937. .preset = snd_hda_preset_sigmatel,
  3938. .owner = THIS_MODULE,
  3939. };
  3940. static int __init patch_sigmatel_init(void)
  3941. {
  3942. return snd_hda_add_codec_preset(&sigmatel_list);
  3943. }
  3944. static void __exit patch_sigmatel_exit(void)
  3945. {
  3946. snd_hda_delete_codec_preset(&sigmatel_list);
  3947. }
  3948. module_init(patch_sigmatel_init)
  3949. module_exit(patch_sigmatel_exit)