patch_realtek.c 148 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for Realtek ALC codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@just42.net>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <linux/init.h>
  26. #include <linux/delay.h>
  27. #include <linux/slab.h>
  28. #include <linux/pci.h>
  29. #include <linux/dmi.h>
  30. #include <linux/module.h>
  31. #include <sound/core.h>
  32. #include <sound/jack.h>
  33. #include "hda_codec.h"
  34. #include "hda_local.h"
  35. #include "hda_auto_parser.h"
  36. #include "hda_jack.h"
  37. #include "hda_generic.h"
  38. /* keep halting ALC5505 DSP, for power saving */
  39. #define HALT_REALTEK_ALC5505
  40. /* unsol event tags */
  41. #define ALC_DCVOL_EVENT 0x08
  42. /* for GPIO Poll */
  43. #define GPIO_MASK 0x03
  44. /* extra amp-initialization sequence types */
  45. enum {
  46. ALC_INIT_NONE,
  47. ALC_INIT_DEFAULT,
  48. ALC_INIT_GPIO1,
  49. ALC_INIT_GPIO2,
  50. ALC_INIT_GPIO3,
  51. };
  52. enum {
  53. ALC_HEADSET_MODE_UNKNOWN,
  54. ALC_HEADSET_MODE_UNPLUGGED,
  55. ALC_HEADSET_MODE_HEADSET,
  56. ALC_HEADSET_MODE_MIC,
  57. ALC_HEADSET_MODE_HEADPHONE,
  58. };
  59. enum {
  60. ALC_HEADSET_TYPE_UNKNOWN,
  61. ALC_HEADSET_TYPE_CTIA,
  62. ALC_HEADSET_TYPE_OMTP,
  63. };
  64. struct alc_customize_define {
  65. unsigned int sku_cfg;
  66. unsigned char port_connectivity;
  67. unsigned char check_sum;
  68. unsigned char customization;
  69. unsigned char external_amp;
  70. unsigned int enable_pcbeep:1;
  71. unsigned int platform_type:1;
  72. unsigned int swap:1;
  73. unsigned int override:1;
  74. unsigned int fixup:1; /* Means that this sku is set by driver, not read from hw */
  75. };
  76. struct alc_spec {
  77. struct hda_gen_spec gen; /* must be at head */
  78. /* codec parameterization */
  79. const struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  80. unsigned int num_mixers;
  81. unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
  82. struct alc_customize_define cdefine;
  83. unsigned int parse_flags; /* flag for snd_hda_parse_pin_defcfg() */
  84. /* inverted dmic fix */
  85. unsigned int inv_dmic_fixup:1; /* has inverted digital-mic workaround */
  86. unsigned int inv_dmic_muted:1; /* R-ch of inv d-mic is muted? */
  87. hda_nid_t inv_dmic_pin;
  88. /* mute LED for HP laptops, see alc269_fixup_mic_mute_hook() */
  89. int mute_led_polarity;
  90. hda_nid_t mute_led_nid;
  91. unsigned int gpio_led; /* used for alc269_fixup_hp_gpio_led() */
  92. hda_nid_t headset_mic_pin;
  93. hda_nid_t headphone_mic_pin;
  94. int current_headset_mode;
  95. int current_headset_type;
  96. /* hooks */
  97. void (*init_hook)(struct hda_codec *codec);
  98. #ifdef CONFIG_PM
  99. void (*power_hook)(struct hda_codec *codec);
  100. #endif
  101. void (*shutup)(struct hda_codec *codec);
  102. int init_amp;
  103. int codec_variant; /* flag for other variants */
  104. bool has_alc5505_dsp;
  105. /* for PLL fix */
  106. hda_nid_t pll_nid;
  107. unsigned int pll_coef_idx, pll_coef_bit;
  108. unsigned int coef0;
  109. };
  110. /*
  111. * Append the given mixer and verb elements for the later use
  112. * The mixer array is referred in build_controls(), and init_verbs are
  113. * called in init().
  114. */
  115. static void add_mixer(struct alc_spec *spec, const struct snd_kcontrol_new *mix)
  116. {
  117. if (snd_BUG_ON(spec->num_mixers >= ARRAY_SIZE(spec->mixers)))
  118. return;
  119. spec->mixers[spec->num_mixers++] = mix;
  120. }
  121. /*
  122. * GPIO setup tables, used in initialization
  123. */
  124. /* Enable GPIO mask and set output */
  125. static const struct hda_verb alc_gpio1_init_verbs[] = {
  126. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  127. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  128. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  129. { }
  130. };
  131. static const struct hda_verb alc_gpio2_init_verbs[] = {
  132. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  133. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  134. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  135. { }
  136. };
  137. static const struct hda_verb alc_gpio3_init_verbs[] = {
  138. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  139. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  140. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  141. { }
  142. };
  143. /*
  144. * Fix hardware PLL issue
  145. * On some codecs, the analog PLL gating control must be off while
  146. * the default value is 1.
  147. */
  148. static void alc_fix_pll(struct hda_codec *codec)
  149. {
  150. struct alc_spec *spec = codec->spec;
  151. unsigned int val;
  152. if (!spec->pll_nid)
  153. return;
  154. snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
  155. spec->pll_coef_idx);
  156. val = snd_hda_codec_read(codec, spec->pll_nid, 0,
  157. AC_VERB_GET_PROC_COEF, 0);
  158. snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_COEF_INDEX,
  159. spec->pll_coef_idx);
  160. snd_hda_codec_write(codec, spec->pll_nid, 0, AC_VERB_SET_PROC_COEF,
  161. val & ~(1 << spec->pll_coef_bit));
  162. }
  163. static void alc_fix_pll_init(struct hda_codec *codec, hda_nid_t nid,
  164. unsigned int coef_idx, unsigned int coef_bit)
  165. {
  166. struct alc_spec *spec = codec->spec;
  167. spec->pll_nid = nid;
  168. spec->pll_coef_idx = coef_idx;
  169. spec->pll_coef_bit = coef_bit;
  170. alc_fix_pll(codec);
  171. }
  172. /* update the master volume per volume-knob's unsol event */
  173. static void alc_update_knob_master(struct hda_codec *codec, struct hda_jack_tbl *jack)
  174. {
  175. unsigned int val;
  176. struct snd_kcontrol *kctl;
  177. struct snd_ctl_elem_value *uctl;
  178. kctl = snd_hda_find_mixer_ctl(codec, "Master Playback Volume");
  179. if (!kctl)
  180. return;
  181. uctl = kzalloc(sizeof(*uctl), GFP_KERNEL);
  182. if (!uctl)
  183. return;
  184. val = snd_hda_codec_read(codec, jack->nid, 0,
  185. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  186. val &= HDA_AMP_VOLMASK;
  187. uctl->value.integer.value[0] = val;
  188. uctl->value.integer.value[1] = val;
  189. kctl->put(kctl, uctl);
  190. kfree(uctl);
  191. }
  192. static void alc880_unsol_event(struct hda_codec *codec, unsigned int res)
  193. {
  194. /* For some reason, the res given from ALC880 is broken.
  195. Here we adjust it properly. */
  196. snd_hda_jack_unsol_event(codec, res >> 2);
  197. }
  198. /* additional initialization for ALC888 variants */
  199. static void alc888_coef_init(struct hda_codec *codec)
  200. {
  201. unsigned int tmp;
  202. snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 0);
  203. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  204. snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
  205. if ((tmp & 0xf0) == 0x20)
  206. /* alc888S-VC */
  207. snd_hda_codec_read(codec, 0x20, 0,
  208. AC_VERB_SET_PROC_COEF, 0x830);
  209. else
  210. /* alc888-VB */
  211. snd_hda_codec_read(codec, 0x20, 0,
  212. AC_VERB_SET_PROC_COEF, 0x3030);
  213. }
  214. /* additional initialization for ALC889 variants */
  215. static void alc889_coef_init(struct hda_codec *codec)
  216. {
  217. unsigned int tmp;
  218. snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
  219. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  220. snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX, 7);
  221. snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF, tmp|0x2010);
  222. }
  223. /* turn on/off EAPD control (only if available) */
  224. static void set_eapd(struct hda_codec *codec, hda_nid_t nid, int on)
  225. {
  226. if (get_wcaps_type(get_wcaps(codec, nid)) != AC_WID_PIN)
  227. return;
  228. if (snd_hda_query_pin_caps(codec, nid) & AC_PINCAP_EAPD)
  229. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_EAPD_BTLENABLE,
  230. on ? 2 : 0);
  231. }
  232. /* turn on/off EAPD controls of the codec */
  233. static void alc_auto_setup_eapd(struct hda_codec *codec, bool on)
  234. {
  235. /* We currently only handle front, HP */
  236. static hda_nid_t pins[] = {
  237. 0x0f, 0x10, 0x14, 0x15, 0
  238. };
  239. hda_nid_t *p;
  240. for (p = pins; *p; p++)
  241. set_eapd(codec, *p, on);
  242. }
  243. /* generic shutup callback;
  244. * just turning off EPAD and a little pause for avoiding pop-noise
  245. */
  246. static void alc_eapd_shutup(struct hda_codec *codec)
  247. {
  248. alc_auto_setup_eapd(codec, false);
  249. msleep(200);
  250. snd_hda_shutup_pins(codec);
  251. }
  252. /* generic EAPD initialization */
  253. static void alc_auto_init_amp(struct hda_codec *codec, int type)
  254. {
  255. unsigned int tmp;
  256. alc_auto_setup_eapd(codec, true);
  257. switch (type) {
  258. case ALC_INIT_GPIO1:
  259. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  260. break;
  261. case ALC_INIT_GPIO2:
  262. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  263. break;
  264. case ALC_INIT_GPIO3:
  265. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  266. break;
  267. case ALC_INIT_DEFAULT:
  268. switch (codec->vendor_id) {
  269. case 0x10ec0260:
  270. snd_hda_codec_write(codec, 0x1a, 0,
  271. AC_VERB_SET_COEF_INDEX, 7);
  272. tmp = snd_hda_codec_read(codec, 0x1a, 0,
  273. AC_VERB_GET_PROC_COEF, 0);
  274. snd_hda_codec_write(codec, 0x1a, 0,
  275. AC_VERB_SET_COEF_INDEX, 7);
  276. snd_hda_codec_write(codec, 0x1a, 0,
  277. AC_VERB_SET_PROC_COEF,
  278. tmp | 0x2010);
  279. break;
  280. case 0x10ec0262:
  281. case 0x10ec0880:
  282. case 0x10ec0882:
  283. case 0x10ec0883:
  284. case 0x10ec0885:
  285. case 0x10ec0887:
  286. /*case 0x10ec0889:*/ /* this causes an SPDIF problem */
  287. alc889_coef_init(codec);
  288. break;
  289. case 0x10ec0888:
  290. alc888_coef_init(codec);
  291. break;
  292. #if 0 /* XXX: This may cause the silent output on speaker on some machines */
  293. case 0x10ec0267:
  294. case 0x10ec0268:
  295. snd_hda_codec_write(codec, 0x20, 0,
  296. AC_VERB_SET_COEF_INDEX, 7);
  297. tmp = snd_hda_codec_read(codec, 0x20, 0,
  298. AC_VERB_GET_PROC_COEF, 0);
  299. snd_hda_codec_write(codec, 0x20, 0,
  300. AC_VERB_SET_COEF_INDEX, 7);
  301. snd_hda_codec_write(codec, 0x20, 0,
  302. AC_VERB_SET_PROC_COEF,
  303. tmp | 0x3000);
  304. break;
  305. #endif /* XXX */
  306. }
  307. break;
  308. }
  309. }
  310. /*
  311. * Realtek SSID verification
  312. */
  313. /* Could be any non-zero and even value. When used as fixup, tells
  314. * the driver to ignore any present sku defines.
  315. */
  316. #define ALC_FIXUP_SKU_IGNORE (2)
  317. static void alc_fixup_sku_ignore(struct hda_codec *codec,
  318. const struct hda_fixup *fix, int action)
  319. {
  320. struct alc_spec *spec = codec->spec;
  321. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  322. spec->cdefine.fixup = 1;
  323. spec->cdefine.sku_cfg = ALC_FIXUP_SKU_IGNORE;
  324. }
  325. }
  326. static int alc_auto_parse_customize_define(struct hda_codec *codec)
  327. {
  328. unsigned int ass, tmp, i;
  329. unsigned nid = 0;
  330. struct alc_spec *spec = codec->spec;
  331. spec->cdefine.enable_pcbeep = 1; /* assume always enabled */
  332. if (spec->cdefine.fixup) {
  333. ass = spec->cdefine.sku_cfg;
  334. if (ass == ALC_FIXUP_SKU_IGNORE)
  335. return -1;
  336. goto do_sku;
  337. }
  338. ass = codec->subsystem_id & 0xffff;
  339. if (ass != codec->bus->pci->subsystem_device && (ass & 1))
  340. goto do_sku;
  341. nid = 0x1d;
  342. if (codec->vendor_id == 0x10ec0260)
  343. nid = 0x17;
  344. ass = snd_hda_codec_get_pincfg(codec, nid);
  345. if (!(ass & 1)) {
  346. printk(KERN_INFO "hda_codec: %s: SKU not ready 0x%08x\n",
  347. codec->chip_name, ass);
  348. return -1;
  349. }
  350. /* check sum */
  351. tmp = 0;
  352. for (i = 1; i < 16; i++) {
  353. if ((ass >> i) & 1)
  354. tmp++;
  355. }
  356. if (((ass >> 16) & 0xf) != tmp)
  357. return -1;
  358. spec->cdefine.port_connectivity = ass >> 30;
  359. spec->cdefine.enable_pcbeep = (ass & 0x100000) >> 20;
  360. spec->cdefine.check_sum = (ass >> 16) & 0xf;
  361. spec->cdefine.customization = ass >> 8;
  362. do_sku:
  363. spec->cdefine.sku_cfg = ass;
  364. spec->cdefine.external_amp = (ass & 0x38) >> 3;
  365. spec->cdefine.platform_type = (ass & 0x4) >> 2;
  366. spec->cdefine.swap = (ass & 0x2) >> 1;
  367. spec->cdefine.override = ass & 0x1;
  368. snd_printd("SKU: Nid=0x%x sku_cfg=0x%08x\n",
  369. nid, spec->cdefine.sku_cfg);
  370. snd_printd("SKU: port_connectivity=0x%x\n",
  371. spec->cdefine.port_connectivity);
  372. snd_printd("SKU: enable_pcbeep=0x%x\n", spec->cdefine.enable_pcbeep);
  373. snd_printd("SKU: check_sum=0x%08x\n", spec->cdefine.check_sum);
  374. snd_printd("SKU: customization=0x%08x\n", spec->cdefine.customization);
  375. snd_printd("SKU: external_amp=0x%x\n", spec->cdefine.external_amp);
  376. snd_printd("SKU: platform_type=0x%x\n", spec->cdefine.platform_type);
  377. snd_printd("SKU: swap=0x%x\n", spec->cdefine.swap);
  378. snd_printd("SKU: override=0x%x\n", spec->cdefine.override);
  379. return 0;
  380. }
  381. /* return the position of NID in the list, or -1 if not found */
  382. static int find_idx_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
  383. {
  384. int i;
  385. for (i = 0; i < nums; i++)
  386. if (list[i] == nid)
  387. return i;
  388. return -1;
  389. }
  390. /* return true if the given NID is found in the list */
  391. static bool found_in_nid_list(hda_nid_t nid, const hda_nid_t *list, int nums)
  392. {
  393. return find_idx_in_nid_list(nid, list, nums) >= 0;
  394. }
  395. /* check subsystem ID and set up device-specific initialization;
  396. * return 1 if initialized, 0 if invalid SSID
  397. */
  398. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  399. * 31 ~ 16 : Manufacture ID
  400. * 15 ~ 8 : SKU ID
  401. * 7 ~ 0 : Assembly ID
  402. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  403. */
  404. static int alc_subsystem_id(struct hda_codec *codec,
  405. hda_nid_t porta, hda_nid_t porte,
  406. hda_nid_t portd, hda_nid_t porti)
  407. {
  408. unsigned int ass, tmp, i;
  409. unsigned nid;
  410. struct alc_spec *spec = codec->spec;
  411. if (spec->cdefine.fixup) {
  412. ass = spec->cdefine.sku_cfg;
  413. if (ass == ALC_FIXUP_SKU_IGNORE)
  414. return 0;
  415. goto do_sku;
  416. }
  417. ass = codec->subsystem_id & 0xffff;
  418. if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
  419. goto do_sku;
  420. /* invalid SSID, check the special NID pin defcfg instead */
  421. /*
  422. * 31~30 : port connectivity
  423. * 29~21 : reserve
  424. * 20 : PCBEEP input
  425. * 19~16 : Check sum (15:1)
  426. * 15~1 : Custom
  427. * 0 : override
  428. */
  429. nid = 0x1d;
  430. if (codec->vendor_id == 0x10ec0260)
  431. nid = 0x17;
  432. ass = snd_hda_codec_get_pincfg(codec, nid);
  433. snd_printd("realtek: No valid SSID, "
  434. "checking pincfg 0x%08x for NID 0x%x\n",
  435. ass, nid);
  436. if (!(ass & 1))
  437. return 0;
  438. if ((ass >> 30) != 1) /* no physical connection */
  439. return 0;
  440. /* check sum */
  441. tmp = 0;
  442. for (i = 1; i < 16; i++) {
  443. if ((ass >> i) & 1)
  444. tmp++;
  445. }
  446. if (((ass >> 16) & 0xf) != tmp)
  447. return 0;
  448. do_sku:
  449. snd_printd("realtek: Enabling init ASM_ID=0x%04x CODEC_ID=%08x\n",
  450. ass & 0xffff, codec->vendor_id);
  451. /*
  452. * 0 : override
  453. * 1 : Swap Jack
  454. * 2 : 0 --> Desktop, 1 --> Laptop
  455. * 3~5 : External Amplifier control
  456. * 7~6 : Reserved
  457. */
  458. tmp = (ass & 0x38) >> 3; /* external Amp control */
  459. switch (tmp) {
  460. case 1:
  461. spec->init_amp = ALC_INIT_GPIO1;
  462. break;
  463. case 3:
  464. spec->init_amp = ALC_INIT_GPIO2;
  465. break;
  466. case 7:
  467. spec->init_amp = ALC_INIT_GPIO3;
  468. break;
  469. case 5:
  470. default:
  471. spec->init_amp = ALC_INIT_DEFAULT;
  472. break;
  473. }
  474. /* is laptop or Desktop and enable the function "Mute internal speaker
  475. * when the external headphone out jack is plugged"
  476. */
  477. if (!(ass & 0x8000))
  478. return 1;
  479. /*
  480. * 10~8 : Jack location
  481. * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
  482. * 14~13: Resvered
  483. * 15 : 1 --> enable the function "Mute internal speaker
  484. * when the external headphone out jack is plugged"
  485. */
  486. if (!spec->gen.autocfg.hp_pins[0] &&
  487. !(spec->gen.autocfg.line_out_pins[0] &&
  488. spec->gen.autocfg.line_out_type == AUTO_PIN_HP_OUT)) {
  489. hda_nid_t nid;
  490. tmp = (ass >> 11) & 0x3; /* HP to chassis */
  491. if (tmp == 0)
  492. nid = porta;
  493. else if (tmp == 1)
  494. nid = porte;
  495. else if (tmp == 2)
  496. nid = portd;
  497. else if (tmp == 3)
  498. nid = porti;
  499. if (found_in_nid_list(nid, spec->gen.autocfg.line_out_pins,
  500. spec->gen.autocfg.line_outs))
  501. return 1;
  502. spec->gen.autocfg.hp_pins[0] = nid;
  503. }
  504. return 1;
  505. }
  506. /* Check the validity of ALC subsystem-id
  507. * ports contains an array of 4 pin NIDs for port-A, E, D and I */
  508. static void alc_ssid_check(struct hda_codec *codec, const hda_nid_t *ports)
  509. {
  510. if (!alc_subsystem_id(codec, ports[0], ports[1], ports[2], ports[3])) {
  511. struct alc_spec *spec = codec->spec;
  512. snd_printd("realtek: "
  513. "Enable default setup for auto mode as fallback\n");
  514. spec->init_amp = ALC_INIT_DEFAULT;
  515. }
  516. }
  517. /*
  518. * COEF access helper functions
  519. */
  520. static int alc_read_coef_idx(struct hda_codec *codec,
  521. unsigned int coef_idx)
  522. {
  523. unsigned int val;
  524. snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
  525. coef_idx);
  526. val = snd_hda_codec_read(codec, 0x20, 0,
  527. AC_VERB_GET_PROC_COEF, 0);
  528. return val;
  529. }
  530. static void alc_write_coef_idx(struct hda_codec *codec, unsigned int coef_idx,
  531. unsigned int coef_val)
  532. {
  533. snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_COEF_INDEX,
  534. coef_idx);
  535. snd_hda_codec_write(codec, 0x20, 0, AC_VERB_SET_PROC_COEF,
  536. coef_val);
  537. }
  538. /* a special bypass for COEF 0; read the cached value at the second time */
  539. static unsigned int alc_get_coef0(struct hda_codec *codec)
  540. {
  541. struct alc_spec *spec = codec->spec;
  542. if (!spec->coef0)
  543. spec->coef0 = alc_read_coef_idx(codec, 0);
  544. return spec->coef0;
  545. }
  546. /*
  547. */
  548. static hda_nid_t get_adc_nid(struct hda_codec *codec, int adc_idx, int imux_idx)
  549. {
  550. struct hda_gen_spec *spec = codec->spec;
  551. if (spec->dyn_adc_switch)
  552. adc_idx = spec->dyn_adc_idx[imux_idx];
  553. return spec->adc_nids[adc_idx];
  554. }
  555. static void alc_inv_dmic_sync_adc(struct hda_codec *codec, int adc_idx)
  556. {
  557. struct alc_spec *spec = codec->spec;
  558. struct hda_input_mux *imux = &spec->gen.input_mux;
  559. struct nid_path *path;
  560. hda_nid_t nid;
  561. int i, dir, parm;
  562. unsigned int val;
  563. for (i = 0; i < imux->num_items; i++) {
  564. if (spec->gen.imux_pins[i] == spec->inv_dmic_pin)
  565. break;
  566. }
  567. if (i >= imux->num_items)
  568. return;
  569. path = snd_hda_get_nid_path(codec, spec->inv_dmic_pin,
  570. get_adc_nid(codec, adc_idx, i));
  571. val = path->ctls[NID_PATH_MUTE_CTL];
  572. if (!val)
  573. return;
  574. nid = get_amp_nid_(val);
  575. dir = get_amp_direction_(val);
  576. parm = AC_AMP_SET_RIGHT |
  577. (dir == HDA_OUTPUT ? AC_AMP_SET_OUTPUT : AC_AMP_SET_INPUT);
  578. /* flush all cached amps at first */
  579. snd_hda_codec_flush_cache(codec);
  580. /* we care only right channel */
  581. val = snd_hda_codec_amp_read(codec, nid, 1, dir, 0);
  582. if (val & 0x80) /* if already muted, we don't need to touch */
  583. return;
  584. val |= 0x80;
  585. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  586. parm | val);
  587. }
  588. /*
  589. * Inverted digital-mic handling
  590. *
  591. * First off, it's a bit tricky. The "Inverted Internal Mic Capture Switch"
  592. * gives the additional mute only to the right channel of the digital mic
  593. * capture stream. This is a workaround for avoiding the almost silence
  594. * by summing the stereo stream from some (known to be ForteMedia)
  595. * digital mic unit.
  596. *
  597. * The logic is to call alc_inv_dmic_sync() after each action (possibly)
  598. * modifying ADC amp. When the mute flag is set, it mutes the R-channel
  599. * without caching so that the cache can still keep the original value.
  600. * The cached value is then restored when the flag is set off or any other
  601. * than d-mic is used as the current input source.
  602. */
  603. static void alc_inv_dmic_sync(struct hda_codec *codec, bool force)
  604. {
  605. struct alc_spec *spec = codec->spec;
  606. int src, nums;
  607. if (!spec->inv_dmic_fixup)
  608. return;
  609. if (!spec->inv_dmic_muted && !force)
  610. return;
  611. nums = spec->gen.dyn_adc_switch ? 1 : spec->gen.num_adc_nids;
  612. for (src = 0; src < nums; src++) {
  613. bool dmic_fixup = false;
  614. if (spec->inv_dmic_muted &&
  615. spec->gen.imux_pins[spec->gen.cur_mux[src]] == spec->inv_dmic_pin)
  616. dmic_fixup = true;
  617. if (!dmic_fixup && !force)
  618. continue;
  619. alc_inv_dmic_sync_adc(codec, src);
  620. }
  621. }
  622. static void alc_inv_dmic_hook(struct hda_codec *codec,
  623. struct snd_ctl_elem_value *ucontrol)
  624. {
  625. alc_inv_dmic_sync(codec, false);
  626. }
  627. static int alc_inv_dmic_sw_get(struct snd_kcontrol *kcontrol,
  628. struct snd_ctl_elem_value *ucontrol)
  629. {
  630. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  631. struct alc_spec *spec = codec->spec;
  632. ucontrol->value.integer.value[0] = !spec->inv_dmic_muted;
  633. return 0;
  634. }
  635. static int alc_inv_dmic_sw_put(struct snd_kcontrol *kcontrol,
  636. struct snd_ctl_elem_value *ucontrol)
  637. {
  638. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  639. struct alc_spec *spec = codec->spec;
  640. unsigned int val = !ucontrol->value.integer.value[0];
  641. if (val == spec->inv_dmic_muted)
  642. return 0;
  643. spec->inv_dmic_muted = val;
  644. alc_inv_dmic_sync(codec, true);
  645. return 0;
  646. }
  647. static const struct snd_kcontrol_new alc_inv_dmic_sw = {
  648. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  649. .name = "Inverted Internal Mic Capture Switch",
  650. .info = snd_ctl_boolean_mono_info,
  651. .get = alc_inv_dmic_sw_get,
  652. .put = alc_inv_dmic_sw_put,
  653. };
  654. static int alc_add_inv_dmic_mixer(struct hda_codec *codec, hda_nid_t nid)
  655. {
  656. struct alc_spec *spec = codec->spec;
  657. if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &alc_inv_dmic_sw))
  658. return -ENOMEM;
  659. spec->inv_dmic_fixup = 1;
  660. spec->inv_dmic_muted = 0;
  661. spec->inv_dmic_pin = nid;
  662. spec->gen.cap_sync_hook = alc_inv_dmic_hook;
  663. return 0;
  664. }
  665. /* typically the digital mic is put at node 0x12 */
  666. static void alc_fixup_inv_dmic_0x12(struct hda_codec *codec,
  667. const struct hda_fixup *fix, int action)
  668. {
  669. if (action == HDA_FIXUP_ACT_PROBE)
  670. alc_add_inv_dmic_mixer(codec, 0x12);
  671. }
  672. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  673. /* additional beep mixers; the actual parameters are overwritten at build */
  674. static const struct snd_kcontrol_new alc_beep_mixer[] = {
  675. HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_INPUT),
  676. HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_INPUT),
  677. { } /* end */
  678. };
  679. #endif
  680. static int alc_build_controls(struct hda_codec *codec)
  681. {
  682. struct alc_spec *spec = codec->spec;
  683. int i, err;
  684. err = snd_hda_gen_build_controls(codec);
  685. if (err < 0)
  686. return err;
  687. for (i = 0; i < spec->num_mixers; i++) {
  688. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  689. if (err < 0)
  690. return err;
  691. }
  692. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  693. /* create beep controls if needed */
  694. if (spec->beep_amp) {
  695. const struct snd_kcontrol_new *knew;
  696. for (knew = alc_beep_mixer; knew->name; knew++) {
  697. struct snd_kcontrol *kctl;
  698. kctl = snd_ctl_new1(knew, codec);
  699. if (!kctl)
  700. return -ENOMEM;
  701. kctl->private_value = spec->beep_amp;
  702. err = snd_hda_ctl_add(codec, 0, kctl);
  703. if (err < 0)
  704. return err;
  705. }
  706. }
  707. #endif
  708. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_BUILD);
  709. return 0;
  710. }
  711. /*
  712. * Common callbacks
  713. */
  714. static int alc_init(struct hda_codec *codec)
  715. {
  716. struct alc_spec *spec = codec->spec;
  717. if (spec->init_hook)
  718. spec->init_hook(codec);
  719. alc_fix_pll(codec);
  720. alc_auto_init_amp(codec, spec->init_amp);
  721. snd_hda_gen_init(codec);
  722. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_INIT);
  723. return 0;
  724. }
  725. static inline void alc_shutup(struct hda_codec *codec)
  726. {
  727. struct alc_spec *spec = codec->spec;
  728. if (spec && spec->shutup)
  729. spec->shutup(codec);
  730. else
  731. snd_hda_shutup_pins(codec);
  732. }
  733. static void alc_free(struct hda_codec *codec)
  734. {
  735. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_FREE);
  736. snd_hda_gen_free(codec);
  737. }
  738. #ifdef CONFIG_PM
  739. static void alc_power_eapd(struct hda_codec *codec)
  740. {
  741. alc_auto_setup_eapd(codec, false);
  742. }
  743. static int alc_suspend(struct hda_codec *codec)
  744. {
  745. struct alc_spec *spec = codec->spec;
  746. alc_shutup(codec);
  747. if (spec && spec->power_hook)
  748. spec->power_hook(codec);
  749. return 0;
  750. }
  751. #endif
  752. #ifdef CONFIG_PM
  753. static int alc_resume(struct hda_codec *codec)
  754. {
  755. msleep(150); /* to avoid pop noise */
  756. codec->patch_ops.init(codec);
  757. snd_hda_codec_resume_amp(codec);
  758. snd_hda_codec_resume_cache(codec);
  759. alc_inv_dmic_sync(codec, true);
  760. hda_call_check_power_status(codec, 0x01);
  761. return 0;
  762. }
  763. #endif
  764. /*
  765. */
  766. static const struct hda_codec_ops alc_patch_ops = {
  767. .build_controls = alc_build_controls,
  768. .build_pcms = snd_hda_gen_build_pcms,
  769. .init = alc_init,
  770. .free = alc_free,
  771. .unsol_event = snd_hda_jack_unsol_event,
  772. #ifdef CONFIG_PM
  773. .resume = alc_resume,
  774. .suspend = alc_suspend,
  775. .check_power_status = snd_hda_gen_check_power_status,
  776. #endif
  777. .reboot_notify = alc_shutup,
  778. };
  779. /* replace the codec chip_name with the given string */
  780. static int alc_codec_rename(struct hda_codec *codec, const char *name)
  781. {
  782. kfree(codec->chip_name);
  783. codec->chip_name = kstrdup(name, GFP_KERNEL);
  784. if (!codec->chip_name) {
  785. alc_free(codec);
  786. return -ENOMEM;
  787. }
  788. return 0;
  789. }
  790. /*
  791. * Rename codecs appropriately from COEF value
  792. */
  793. struct alc_codec_rename_table {
  794. unsigned int vendor_id;
  795. unsigned short coef_mask;
  796. unsigned short coef_bits;
  797. const char *name;
  798. };
  799. static struct alc_codec_rename_table rename_tbl[] = {
  800. { 0x10ec0269, 0xfff0, 0x3010, "ALC277" },
  801. { 0x10ec0269, 0xf0f0, 0x2010, "ALC259" },
  802. { 0x10ec0269, 0xf0f0, 0x3010, "ALC258" },
  803. { 0x10ec0269, 0x00f0, 0x0010, "ALC269VB" },
  804. { 0x10ec0269, 0xffff, 0xa023, "ALC259" },
  805. { 0x10ec0269, 0xffff, 0x6023, "ALC281X" },
  806. { 0x10ec0269, 0x00f0, 0x0020, "ALC269VC" },
  807. { 0x10ec0269, 0x00f0, 0x0030, "ALC269VD" },
  808. { 0x10ec0887, 0x00f0, 0x0030, "ALC887-VD" },
  809. { 0x10ec0888, 0x00f0, 0x0030, "ALC888-VD" },
  810. { 0x10ec0888, 0xf0f0, 0x3020, "ALC886" },
  811. { 0x10ec0899, 0x2000, 0x2000, "ALC899" },
  812. { 0x10ec0892, 0xffff, 0x8020, "ALC661" },
  813. { 0x10ec0892, 0xffff, 0x8011, "ALC661" },
  814. { 0x10ec0892, 0xffff, 0x4011, "ALC656" },
  815. { } /* terminator */
  816. };
  817. static int alc_codec_rename_from_preset(struct hda_codec *codec)
  818. {
  819. const struct alc_codec_rename_table *p;
  820. for (p = rename_tbl; p->vendor_id; p++) {
  821. if (p->vendor_id != codec->vendor_id)
  822. continue;
  823. if ((alc_get_coef0(codec) & p->coef_mask) == p->coef_bits)
  824. return alc_codec_rename(codec, p->name);
  825. }
  826. return 0;
  827. }
  828. /*
  829. * Digital-beep handlers
  830. */
  831. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  832. #define set_beep_amp(spec, nid, idx, dir) \
  833. ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 3, idx, dir))
  834. static const struct snd_pci_quirk beep_white_list[] = {
  835. SND_PCI_QUIRK(0x1043, 0x103c, "ASUS", 1),
  836. SND_PCI_QUIRK(0x1043, 0x829f, "ASUS", 1),
  837. SND_PCI_QUIRK(0x1043, 0x8376, "EeePC", 1),
  838. SND_PCI_QUIRK(0x1043, 0x83ce, "EeePC", 1),
  839. SND_PCI_QUIRK(0x1043, 0x831a, "EeePC", 1),
  840. SND_PCI_QUIRK(0x1043, 0x834a, "EeePC", 1),
  841. SND_PCI_QUIRK(0x1458, 0xa002, "GA-MA790X", 1),
  842. SND_PCI_QUIRK(0x8086, 0xd613, "Intel", 1),
  843. {}
  844. };
  845. static inline int has_cdefine_beep(struct hda_codec *codec)
  846. {
  847. struct alc_spec *spec = codec->spec;
  848. const struct snd_pci_quirk *q;
  849. q = snd_pci_quirk_lookup(codec->bus->pci, beep_white_list);
  850. if (q)
  851. return q->value;
  852. return spec->cdefine.enable_pcbeep;
  853. }
  854. #else
  855. #define set_beep_amp(spec, nid, idx, dir) /* NOP */
  856. #define has_cdefine_beep(codec) 0
  857. #endif
  858. /* parse the BIOS configuration and set up the alc_spec */
  859. /* return 1 if successful, 0 if the proper config is not found,
  860. * or a negative error code
  861. */
  862. static int alc_parse_auto_config(struct hda_codec *codec,
  863. const hda_nid_t *ignore_nids,
  864. const hda_nid_t *ssid_nids)
  865. {
  866. struct alc_spec *spec = codec->spec;
  867. struct auto_pin_cfg *cfg = &spec->gen.autocfg;
  868. int err;
  869. err = snd_hda_parse_pin_defcfg(codec, cfg, ignore_nids,
  870. spec->parse_flags);
  871. if (err < 0)
  872. return err;
  873. if (ssid_nids)
  874. alc_ssid_check(codec, ssid_nids);
  875. err = snd_hda_gen_parse_auto_config(codec, cfg);
  876. if (err < 0)
  877. return err;
  878. return 1;
  879. }
  880. /* common preparation job for alc_spec */
  881. static int alc_alloc_spec(struct hda_codec *codec, hda_nid_t mixer_nid)
  882. {
  883. struct alc_spec *spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  884. int err;
  885. if (!spec)
  886. return -ENOMEM;
  887. codec->spec = spec;
  888. snd_hda_gen_spec_init(&spec->gen);
  889. spec->gen.mixer_nid = mixer_nid;
  890. spec->gen.own_eapd_ctl = 1;
  891. codec->single_adc_amp = 1;
  892. /* FIXME: do we need this for all Realtek codec models? */
  893. codec->spdif_status_reset = 1;
  894. err = alc_codec_rename_from_preset(codec);
  895. if (err < 0) {
  896. kfree(spec);
  897. return err;
  898. }
  899. return 0;
  900. }
  901. static int alc880_parse_auto_config(struct hda_codec *codec)
  902. {
  903. static const hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  904. static const hda_nid_t alc880_ssids[] = { 0x15, 0x1b, 0x14, 0 };
  905. return alc_parse_auto_config(codec, alc880_ignore, alc880_ssids);
  906. }
  907. /*
  908. * ALC880 fix-ups
  909. */
  910. enum {
  911. ALC880_FIXUP_GPIO1,
  912. ALC880_FIXUP_GPIO2,
  913. ALC880_FIXUP_MEDION_RIM,
  914. ALC880_FIXUP_LG,
  915. ALC880_FIXUP_LG_LW25,
  916. ALC880_FIXUP_W810,
  917. ALC880_FIXUP_EAPD_COEF,
  918. ALC880_FIXUP_TCL_S700,
  919. ALC880_FIXUP_VOL_KNOB,
  920. ALC880_FIXUP_FUJITSU,
  921. ALC880_FIXUP_F1734,
  922. ALC880_FIXUP_UNIWILL,
  923. ALC880_FIXUP_UNIWILL_DIG,
  924. ALC880_FIXUP_Z71V,
  925. ALC880_FIXUP_ASUS_W5A,
  926. ALC880_FIXUP_3ST_BASE,
  927. ALC880_FIXUP_3ST,
  928. ALC880_FIXUP_3ST_DIG,
  929. ALC880_FIXUP_5ST_BASE,
  930. ALC880_FIXUP_5ST,
  931. ALC880_FIXUP_5ST_DIG,
  932. ALC880_FIXUP_6ST_BASE,
  933. ALC880_FIXUP_6ST,
  934. ALC880_FIXUP_6ST_DIG,
  935. ALC880_FIXUP_6ST_AUTOMUTE,
  936. };
  937. /* enable the volume-knob widget support on NID 0x21 */
  938. static void alc880_fixup_vol_knob(struct hda_codec *codec,
  939. const struct hda_fixup *fix, int action)
  940. {
  941. if (action == HDA_FIXUP_ACT_PROBE)
  942. snd_hda_jack_detect_enable_callback(codec, 0x21, ALC_DCVOL_EVENT, alc_update_knob_master);
  943. }
  944. static const struct hda_fixup alc880_fixups[] = {
  945. [ALC880_FIXUP_GPIO1] = {
  946. .type = HDA_FIXUP_VERBS,
  947. .v.verbs = alc_gpio1_init_verbs,
  948. },
  949. [ALC880_FIXUP_GPIO2] = {
  950. .type = HDA_FIXUP_VERBS,
  951. .v.verbs = alc_gpio2_init_verbs,
  952. },
  953. [ALC880_FIXUP_MEDION_RIM] = {
  954. .type = HDA_FIXUP_VERBS,
  955. .v.verbs = (const struct hda_verb[]) {
  956. { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
  957. { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
  958. { }
  959. },
  960. .chained = true,
  961. .chain_id = ALC880_FIXUP_GPIO2,
  962. },
  963. [ALC880_FIXUP_LG] = {
  964. .type = HDA_FIXUP_PINS,
  965. .v.pins = (const struct hda_pintbl[]) {
  966. /* disable bogus unused pins */
  967. { 0x16, 0x411111f0 },
  968. { 0x18, 0x411111f0 },
  969. { 0x1a, 0x411111f0 },
  970. { }
  971. }
  972. },
  973. [ALC880_FIXUP_LG_LW25] = {
  974. .type = HDA_FIXUP_PINS,
  975. .v.pins = (const struct hda_pintbl[]) {
  976. { 0x1a, 0x0181344f }, /* line-in */
  977. { 0x1b, 0x0321403f }, /* headphone */
  978. { }
  979. }
  980. },
  981. [ALC880_FIXUP_W810] = {
  982. .type = HDA_FIXUP_PINS,
  983. .v.pins = (const struct hda_pintbl[]) {
  984. /* disable bogus unused pins */
  985. { 0x17, 0x411111f0 },
  986. { }
  987. },
  988. .chained = true,
  989. .chain_id = ALC880_FIXUP_GPIO2,
  990. },
  991. [ALC880_FIXUP_EAPD_COEF] = {
  992. .type = HDA_FIXUP_VERBS,
  993. .v.verbs = (const struct hda_verb[]) {
  994. /* change to EAPD mode */
  995. { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
  996. { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
  997. {}
  998. },
  999. },
  1000. [ALC880_FIXUP_TCL_S700] = {
  1001. .type = HDA_FIXUP_VERBS,
  1002. .v.verbs = (const struct hda_verb[]) {
  1003. /* change to EAPD mode */
  1004. { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
  1005. { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
  1006. {}
  1007. },
  1008. .chained = true,
  1009. .chain_id = ALC880_FIXUP_GPIO2,
  1010. },
  1011. [ALC880_FIXUP_VOL_KNOB] = {
  1012. .type = HDA_FIXUP_FUNC,
  1013. .v.func = alc880_fixup_vol_knob,
  1014. },
  1015. [ALC880_FIXUP_FUJITSU] = {
  1016. /* override all pins as BIOS on old Amilo is broken */
  1017. .type = HDA_FIXUP_PINS,
  1018. .v.pins = (const struct hda_pintbl[]) {
  1019. { 0x14, 0x0121411f }, /* HP */
  1020. { 0x15, 0x99030120 }, /* speaker */
  1021. { 0x16, 0x99030130 }, /* bass speaker */
  1022. { 0x17, 0x411111f0 }, /* N/A */
  1023. { 0x18, 0x411111f0 }, /* N/A */
  1024. { 0x19, 0x01a19950 }, /* mic-in */
  1025. { 0x1a, 0x411111f0 }, /* N/A */
  1026. { 0x1b, 0x411111f0 }, /* N/A */
  1027. { 0x1c, 0x411111f0 }, /* N/A */
  1028. { 0x1d, 0x411111f0 }, /* N/A */
  1029. { 0x1e, 0x01454140 }, /* SPDIF out */
  1030. { }
  1031. },
  1032. .chained = true,
  1033. .chain_id = ALC880_FIXUP_VOL_KNOB,
  1034. },
  1035. [ALC880_FIXUP_F1734] = {
  1036. /* almost compatible with FUJITSU, but no bass and SPDIF */
  1037. .type = HDA_FIXUP_PINS,
  1038. .v.pins = (const struct hda_pintbl[]) {
  1039. { 0x14, 0x0121411f }, /* HP */
  1040. { 0x15, 0x99030120 }, /* speaker */
  1041. { 0x16, 0x411111f0 }, /* N/A */
  1042. { 0x17, 0x411111f0 }, /* N/A */
  1043. { 0x18, 0x411111f0 }, /* N/A */
  1044. { 0x19, 0x01a19950 }, /* mic-in */
  1045. { 0x1a, 0x411111f0 }, /* N/A */
  1046. { 0x1b, 0x411111f0 }, /* N/A */
  1047. { 0x1c, 0x411111f0 }, /* N/A */
  1048. { 0x1d, 0x411111f0 }, /* N/A */
  1049. { 0x1e, 0x411111f0 }, /* N/A */
  1050. { }
  1051. },
  1052. .chained = true,
  1053. .chain_id = ALC880_FIXUP_VOL_KNOB,
  1054. },
  1055. [ALC880_FIXUP_UNIWILL] = {
  1056. /* need to fix HP and speaker pins to be parsed correctly */
  1057. .type = HDA_FIXUP_PINS,
  1058. .v.pins = (const struct hda_pintbl[]) {
  1059. { 0x14, 0x0121411f }, /* HP */
  1060. { 0x15, 0x99030120 }, /* speaker */
  1061. { 0x16, 0x99030130 }, /* bass speaker */
  1062. { }
  1063. },
  1064. },
  1065. [ALC880_FIXUP_UNIWILL_DIG] = {
  1066. .type = HDA_FIXUP_PINS,
  1067. .v.pins = (const struct hda_pintbl[]) {
  1068. /* disable bogus unused pins */
  1069. { 0x17, 0x411111f0 },
  1070. { 0x19, 0x411111f0 },
  1071. { 0x1b, 0x411111f0 },
  1072. { 0x1f, 0x411111f0 },
  1073. { }
  1074. }
  1075. },
  1076. [ALC880_FIXUP_Z71V] = {
  1077. .type = HDA_FIXUP_PINS,
  1078. .v.pins = (const struct hda_pintbl[]) {
  1079. /* set up the whole pins as BIOS is utterly broken */
  1080. { 0x14, 0x99030120 }, /* speaker */
  1081. { 0x15, 0x0121411f }, /* HP */
  1082. { 0x16, 0x411111f0 }, /* N/A */
  1083. { 0x17, 0x411111f0 }, /* N/A */
  1084. { 0x18, 0x01a19950 }, /* mic-in */
  1085. { 0x19, 0x411111f0 }, /* N/A */
  1086. { 0x1a, 0x01813031 }, /* line-in */
  1087. { 0x1b, 0x411111f0 }, /* N/A */
  1088. { 0x1c, 0x411111f0 }, /* N/A */
  1089. { 0x1d, 0x411111f0 }, /* N/A */
  1090. { 0x1e, 0x0144111e }, /* SPDIF */
  1091. { }
  1092. }
  1093. },
  1094. [ALC880_FIXUP_ASUS_W5A] = {
  1095. .type = HDA_FIXUP_PINS,
  1096. .v.pins = (const struct hda_pintbl[]) {
  1097. /* set up the whole pins as BIOS is utterly broken */
  1098. { 0x14, 0x0121411f }, /* HP */
  1099. { 0x15, 0x411111f0 }, /* N/A */
  1100. { 0x16, 0x411111f0 }, /* N/A */
  1101. { 0x17, 0x411111f0 }, /* N/A */
  1102. { 0x18, 0x90a60160 }, /* mic */
  1103. { 0x19, 0x411111f0 }, /* N/A */
  1104. { 0x1a, 0x411111f0 }, /* N/A */
  1105. { 0x1b, 0x411111f0 }, /* N/A */
  1106. { 0x1c, 0x411111f0 }, /* N/A */
  1107. { 0x1d, 0x411111f0 }, /* N/A */
  1108. { 0x1e, 0xb743111e }, /* SPDIF out */
  1109. { }
  1110. },
  1111. .chained = true,
  1112. .chain_id = ALC880_FIXUP_GPIO1,
  1113. },
  1114. [ALC880_FIXUP_3ST_BASE] = {
  1115. .type = HDA_FIXUP_PINS,
  1116. .v.pins = (const struct hda_pintbl[]) {
  1117. { 0x14, 0x01014010 }, /* line-out */
  1118. { 0x15, 0x411111f0 }, /* N/A */
  1119. { 0x16, 0x411111f0 }, /* N/A */
  1120. { 0x17, 0x411111f0 }, /* N/A */
  1121. { 0x18, 0x01a19c30 }, /* mic-in */
  1122. { 0x19, 0x0121411f }, /* HP */
  1123. { 0x1a, 0x01813031 }, /* line-in */
  1124. { 0x1b, 0x02a19c40 }, /* front-mic */
  1125. { 0x1c, 0x411111f0 }, /* N/A */
  1126. { 0x1d, 0x411111f0 }, /* N/A */
  1127. /* 0x1e is filled in below */
  1128. { 0x1f, 0x411111f0 }, /* N/A */
  1129. { }
  1130. }
  1131. },
  1132. [ALC880_FIXUP_3ST] = {
  1133. .type = HDA_FIXUP_PINS,
  1134. .v.pins = (const struct hda_pintbl[]) {
  1135. { 0x1e, 0x411111f0 }, /* N/A */
  1136. { }
  1137. },
  1138. .chained = true,
  1139. .chain_id = ALC880_FIXUP_3ST_BASE,
  1140. },
  1141. [ALC880_FIXUP_3ST_DIG] = {
  1142. .type = HDA_FIXUP_PINS,
  1143. .v.pins = (const struct hda_pintbl[]) {
  1144. { 0x1e, 0x0144111e }, /* SPDIF */
  1145. { }
  1146. },
  1147. .chained = true,
  1148. .chain_id = ALC880_FIXUP_3ST_BASE,
  1149. },
  1150. [ALC880_FIXUP_5ST_BASE] = {
  1151. .type = HDA_FIXUP_PINS,
  1152. .v.pins = (const struct hda_pintbl[]) {
  1153. { 0x14, 0x01014010 }, /* front */
  1154. { 0x15, 0x411111f0 }, /* N/A */
  1155. { 0x16, 0x01011411 }, /* CLFE */
  1156. { 0x17, 0x01016412 }, /* surr */
  1157. { 0x18, 0x01a19c30 }, /* mic-in */
  1158. { 0x19, 0x0121411f }, /* HP */
  1159. { 0x1a, 0x01813031 }, /* line-in */
  1160. { 0x1b, 0x02a19c40 }, /* front-mic */
  1161. { 0x1c, 0x411111f0 }, /* N/A */
  1162. { 0x1d, 0x411111f0 }, /* N/A */
  1163. /* 0x1e is filled in below */
  1164. { 0x1f, 0x411111f0 }, /* N/A */
  1165. { }
  1166. }
  1167. },
  1168. [ALC880_FIXUP_5ST] = {
  1169. .type = HDA_FIXUP_PINS,
  1170. .v.pins = (const struct hda_pintbl[]) {
  1171. { 0x1e, 0x411111f0 }, /* N/A */
  1172. { }
  1173. },
  1174. .chained = true,
  1175. .chain_id = ALC880_FIXUP_5ST_BASE,
  1176. },
  1177. [ALC880_FIXUP_5ST_DIG] = {
  1178. .type = HDA_FIXUP_PINS,
  1179. .v.pins = (const struct hda_pintbl[]) {
  1180. { 0x1e, 0x0144111e }, /* SPDIF */
  1181. { }
  1182. },
  1183. .chained = true,
  1184. .chain_id = ALC880_FIXUP_5ST_BASE,
  1185. },
  1186. [ALC880_FIXUP_6ST_BASE] = {
  1187. .type = HDA_FIXUP_PINS,
  1188. .v.pins = (const struct hda_pintbl[]) {
  1189. { 0x14, 0x01014010 }, /* front */
  1190. { 0x15, 0x01016412 }, /* surr */
  1191. { 0x16, 0x01011411 }, /* CLFE */
  1192. { 0x17, 0x01012414 }, /* side */
  1193. { 0x18, 0x01a19c30 }, /* mic-in */
  1194. { 0x19, 0x02a19c40 }, /* front-mic */
  1195. { 0x1a, 0x01813031 }, /* line-in */
  1196. { 0x1b, 0x0121411f }, /* HP */
  1197. { 0x1c, 0x411111f0 }, /* N/A */
  1198. { 0x1d, 0x411111f0 }, /* N/A */
  1199. /* 0x1e is filled in below */
  1200. { 0x1f, 0x411111f0 }, /* N/A */
  1201. { }
  1202. }
  1203. },
  1204. [ALC880_FIXUP_6ST] = {
  1205. .type = HDA_FIXUP_PINS,
  1206. .v.pins = (const struct hda_pintbl[]) {
  1207. { 0x1e, 0x411111f0 }, /* N/A */
  1208. { }
  1209. },
  1210. .chained = true,
  1211. .chain_id = ALC880_FIXUP_6ST_BASE,
  1212. },
  1213. [ALC880_FIXUP_6ST_DIG] = {
  1214. .type = HDA_FIXUP_PINS,
  1215. .v.pins = (const struct hda_pintbl[]) {
  1216. { 0x1e, 0x0144111e }, /* SPDIF */
  1217. { }
  1218. },
  1219. .chained = true,
  1220. .chain_id = ALC880_FIXUP_6ST_BASE,
  1221. },
  1222. [ALC880_FIXUP_6ST_AUTOMUTE] = {
  1223. .type = HDA_FIXUP_PINS,
  1224. .v.pins = (const struct hda_pintbl[]) {
  1225. { 0x1b, 0x0121401f }, /* HP with jack detect */
  1226. { }
  1227. },
  1228. .chained_before = true,
  1229. .chain_id = ALC880_FIXUP_6ST_BASE,
  1230. },
  1231. };
  1232. static const struct snd_pci_quirk alc880_fixup_tbl[] = {
  1233. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_FIXUP_W810),
  1234. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS W5A", ALC880_FIXUP_ASUS_W5A),
  1235. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_FIXUP_Z71V),
  1236. SND_PCI_QUIRK_VENDOR(0x1043, "ASUS", ALC880_FIXUP_GPIO1),
  1237. SND_PCI_QUIRK(0x1558, 0x5401, "Clevo GPIO2", ALC880_FIXUP_GPIO2),
  1238. SND_PCI_QUIRK_VENDOR(0x1558, "Clevo", ALC880_FIXUP_EAPD_COEF),
  1239. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_FIXUP_UNIWILL_DIG),
  1240. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwill", ALC880_FIXUP_F1734),
  1241. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_FIXUP_UNIWILL),
  1242. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_FIXUP_VOL_KNOB),
  1243. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_FIXUP_W810),
  1244. SND_PCI_QUIRK(0x161f, 0x205d, "Medion Rim 2150", ALC880_FIXUP_MEDION_RIM),
  1245. SND_PCI_QUIRK(0x1631, 0xe011, "PB 13201056", ALC880_FIXUP_6ST_AUTOMUTE),
  1246. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_FIXUP_F1734),
  1247. SND_PCI_QUIRK(0x1734, 0x1094, "FSC Amilo M1451G", ALC880_FIXUP_FUJITSU),
  1248. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC AMILO Xi 1526", ALC880_FIXUP_F1734),
  1249. SND_PCI_QUIRK(0x1734, 0x10b0, "FSC Amilo Pi1556", ALC880_FIXUP_FUJITSU),
  1250. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_FIXUP_LG),
  1251. SND_PCI_QUIRK(0x1854, 0x005f, "LG P1 Express", ALC880_FIXUP_LG),
  1252. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_FIXUP_LG),
  1253. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_FIXUP_LG_LW25),
  1254. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_FIXUP_TCL_S700),
  1255. /* Below is the copied entries from alc880_quirks.c.
  1256. * It's not quite sure whether BIOS sets the correct pin-config table
  1257. * on these machines, thus they are kept to be compatible with
  1258. * the old static quirks. Once when it's confirmed to work without
  1259. * these overrides, it'd be better to remove.
  1260. */
  1261. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_FIXUP_5ST_DIG),
  1262. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_FIXUP_6ST),
  1263. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_FIXUP_3ST_DIG),
  1264. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_FIXUP_6ST_DIG),
  1265. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_FIXUP_6ST_DIG),
  1266. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_FIXUP_6ST_DIG),
  1267. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_FIXUP_3ST_DIG),
  1268. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_FIXUP_3ST),
  1269. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_FIXUP_6ST_DIG),
  1270. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_FIXUP_3ST),
  1271. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_FIXUP_3ST),
  1272. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_FIXUP_5ST),
  1273. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_FIXUP_5ST),
  1274. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_FIXUP_5ST),
  1275. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_FIXUP_6ST_DIG),
  1276. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_FIXUP_6ST_DIG),
  1277. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_FIXUP_6ST_DIG),
  1278. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_FIXUP_6ST_DIG),
  1279. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_FIXUP_5ST_DIG),
  1280. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_FIXUP_5ST_DIG),
  1281. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_FIXUP_5ST_DIG),
  1282. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_FIXUP_6ST_DIG), /* broken BIOS */
  1283. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_FIXUP_6ST_DIG),
  1284. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_FIXUP_5ST_DIG),
  1285. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
  1286. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
  1287. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_FIXUP_3ST_DIG),
  1288. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_FIXUP_5ST_DIG),
  1289. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_FIXUP_3ST_DIG),
  1290. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_FIXUP_3ST_DIG),
  1291. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_FIXUP_5ST_DIG),
  1292. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_FIXUP_5ST_DIG),
  1293. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_FIXUP_5ST_DIG),
  1294. /* default Intel */
  1295. SND_PCI_QUIRK_VENDOR(0x8086, "Intel mobo", ALC880_FIXUP_3ST),
  1296. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_FIXUP_5ST_DIG),
  1297. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_FIXUP_6ST_DIG),
  1298. {}
  1299. };
  1300. static const struct hda_model_fixup alc880_fixup_models[] = {
  1301. {.id = ALC880_FIXUP_3ST, .name = "3stack"},
  1302. {.id = ALC880_FIXUP_3ST_DIG, .name = "3stack-digout"},
  1303. {.id = ALC880_FIXUP_5ST, .name = "5stack"},
  1304. {.id = ALC880_FIXUP_5ST_DIG, .name = "5stack-digout"},
  1305. {.id = ALC880_FIXUP_6ST, .name = "6stack"},
  1306. {.id = ALC880_FIXUP_6ST_DIG, .name = "6stack-digout"},
  1307. {.id = ALC880_FIXUP_6ST_AUTOMUTE, .name = "6stack-automute"},
  1308. {}
  1309. };
  1310. /*
  1311. * OK, here we have finally the patch for ALC880
  1312. */
  1313. static int patch_alc880(struct hda_codec *codec)
  1314. {
  1315. struct alc_spec *spec;
  1316. int err;
  1317. err = alc_alloc_spec(codec, 0x0b);
  1318. if (err < 0)
  1319. return err;
  1320. spec = codec->spec;
  1321. spec->gen.need_dac_fix = 1;
  1322. spec->gen.beep_nid = 0x01;
  1323. snd_hda_pick_fixup(codec, alc880_fixup_models, alc880_fixup_tbl,
  1324. alc880_fixups);
  1325. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  1326. /* automatic parse from the BIOS config */
  1327. err = alc880_parse_auto_config(codec);
  1328. if (err < 0)
  1329. goto error;
  1330. if (!spec->gen.no_analog)
  1331. set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
  1332. codec->patch_ops = alc_patch_ops;
  1333. codec->patch_ops.unsol_event = alc880_unsol_event;
  1334. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  1335. return 0;
  1336. error:
  1337. alc_free(codec);
  1338. return err;
  1339. }
  1340. /*
  1341. * ALC260 support
  1342. */
  1343. static int alc260_parse_auto_config(struct hda_codec *codec)
  1344. {
  1345. static const hda_nid_t alc260_ignore[] = { 0x17, 0 };
  1346. static const hda_nid_t alc260_ssids[] = { 0x10, 0x15, 0x0f, 0 };
  1347. return alc_parse_auto_config(codec, alc260_ignore, alc260_ssids);
  1348. }
  1349. /*
  1350. * Pin config fixes
  1351. */
  1352. enum {
  1353. ALC260_FIXUP_HP_DC5750,
  1354. ALC260_FIXUP_HP_PIN_0F,
  1355. ALC260_FIXUP_COEF,
  1356. ALC260_FIXUP_GPIO1,
  1357. ALC260_FIXUP_GPIO1_TOGGLE,
  1358. ALC260_FIXUP_REPLACER,
  1359. ALC260_FIXUP_HP_B1900,
  1360. ALC260_FIXUP_KN1,
  1361. ALC260_FIXUP_FSC_S7020,
  1362. ALC260_FIXUP_FSC_S7020_JWSE,
  1363. };
  1364. static void alc260_gpio1_automute(struct hda_codec *codec)
  1365. {
  1366. struct alc_spec *spec = codec->spec;
  1367. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
  1368. spec->gen.hp_jack_present);
  1369. }
  1370. static void alc260_fixup_gpio1_toggle(struct hda_codec *codec,
  1371. const struct hda_fixup *fix, int action)
  1372. {
  1373. struct alc_spec *spec = codec->spec;
  1374. if (action == HDA_FIXUP_ACT_PROBE) {
  1375. /* although the machine has only one output pin, we need to
  1376. * toggle GPIO1 according to the jack state
  1377. */
  1378. spec->gen.automute_hook = alc260_gpio1_automute;
  1379. spec->gen.detect_hp = 1;
  1380. spec->gen.automute_speaker = 1;
  1381. spec->gen.autocfg.hp_pins[0] = 0x0f; /* copy it for automute */
  1382. snd_hda_jack_detect_enable_callback(codec, 0x0f, HDA_GEN_HP_EVENT,
  1383. snd_hda_gen_hp_automute);
  1384. snd_hda_add_verbs(codec, alc_gpio1_init_verbs);
  1385. }
  1386. }
  1387. static void alc260_fixup_kn1(struct hda_codec *codec,
  1388. const struct hda_fixup *fix, int action)
  1389. {
  1390. struct alc_spec *spec = codec->spec;
  1391. static const struct hda_pintbl pincfgs[] = {
  1392. { 0x0f, 0x02214000 }, /* HP/speaker */
  1393. { 0x12, 0x90a60160 }, /* int mic */
  1394. { 0x13, 0x02a19000 }, /* ext mic */
  1395. { 0x18, 0x01446000 }, /* SPDIF out */
  1396. /* disable bogus I/O pins */
  1397. { 0x10, 0x411111f0 },
  1398. { 0x11, 0x411111f0 },
  1399. { 0x14, 0x411111f0 },
  1400. { 0x15, 0x411111f0 },
  1401. { 0x16, 0x411111f0 },
  1402. { 0x17, 0x411111f0 },
  1403. { 0x19, 0x411111f0 },
  1404. { }
  1405. };
  1406. switch (action) {
  1407. case HDA_FIXUP_ACT_PRE_PROBE:
  1408. snd_hda_apply_pincfgs(codec, pincfgs);
  1409. break;
  1410. case HDA_FIXUP_ACT_PROBE:
  1411. spec->init_amp = ALC_INIT_NONE;
  1412. break;
  1413. }
  1414. }
  1415. static void alc260_fixup_fsc_s7020(struct hda_codec *codec,
  1416. const struct hda_fixup *fix, int action)
  1417. {
  1418. struct alc_spec *spec = codec->spec;
  1419. if (action == HDA_FIXUP_ACT_PROBE)
  1420. spec->init_amp = ALC_INIT_NONE;
  1421. }
  1422. static void alc260_fixup_fsc_s7020_jwse(struct hda_codec *codec,
  1423. const struct hda_fixup *fix, int action)
  1424. {
  1425. struct alc_spec *spec = codec->spec;
  1426. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  1427. spec->gen.add_jack_modes = 1;
  1428. spec->gen.hp_mic = 1;
  1429. }
  1430. }
  1431. static const struct hda_fixup alc260_fixups[] = {
  1432. [ALC260_FIXUP_HP_DC5750] = {
  1433. .type = HDA_FIXUP_PINS,
  1434. .v.pins = (const struct hda_pintbl[]) {
  1435. { 0x11, 0x90130110 }, /* speaker */
  1436. { }
  1437. }
  1438. },
  1439. [ALC260_FIXUP_HP_PIN_0F] = {
  1440. .type = HDA_FIXUP_PINS,
  1441. .v.pins = (const struct hda_pintbl[]) {
  1442. { 0x0f, 0x01214000 }, /* HP */
  1443. { }
  1444. }
  1445. },
  1446. [ALC260_FIXUP_COEF] = {
  1447. .type = HDA_FIXUP_VERBS,
  1448. .v.verbs = (const struct hda_verb[]) {
  1449. { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
  1450. { 0x20, AC_VERB_SET_PROC_COEF, 0x3040 },
  1451. { }
  1452. },
  1453. .chained = true,
  1454. .chain_id = ALC260_FIXUP_HP_PIN_0F,
  1455. },
  1456. [ALC260_FIXUP_GPIO1] = {
  1457. .type = HDA_FIXUP_VERBS,
  1458. .v.verbs = alc_gpio1_init_verbs,
  1459. },
  1460. [ALC260_FIXUP_GPIO1_TOGGLE] = {
  1461. .type = HDA_FIXUP_FUNC,
  1462. .v.func = alc260_fixup_gpio1_toggle,
  1463. .chained = true,
  1464. .chain_id = ALC260_FIXUP_HP_PIN_0F,
  1465. },
  1466. [ALC260_FIXUP_REPLACER] = {
  1467. .type = HDA_FIXUP_VERBS,
  1468. .v.verbs = (const struct hda_verb[]) {
  1469. { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
  1470. { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
  1471. { }
  1472. },
  1473. .chained = true,
  1474. .chain_id = ALC260_FIXUP_GPIO1_TOGGLE,
  1475. },
  1476. [ALC260_FIXUP_HP_B1900] = {
  1477. .type = HDA_FIXUP_FUNC,
  1478. .v.func = alc260_fixup_gpio1_toggle,
  1479. .chained = true,
  1480. .chain_id = ALC260_FIXUP_COEF,
  1481. },
  1482. [ALC260_FIXUP_KN1] = {
  1483. .type = HDA_FIXUP_FUNC,
  1484. .v.func = alc260_fixup_kn1,
  1485. },
  1486. [ALC260_FIXUP_FSC_S7020] = {
  1487. .type = HDA_FIXUP_FUNC,
  1488. .v.func = alc260_fixup_fsc_s7020,
  1489. },
  1490. [ALC260_FIXUP_FSC_S7020_JWSE] = {
  1491. .type = HDA_FIXUP_FUNC,
  1492. .v.func = alc260_fixup_fsc_s7020_jwse,
  1493. .chained = true,
  1494. .chain_id = ALC260_FIXUP_FSC_S7020,
  1495. },
  1496. };
  1497. static const struct snd_pci_quirk alc260_fixup_tbl[] = {
  1498. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_FIXUP_GPIO1),
  1499. SND_PCI_QUIRK(0x1025, 0x007f, "Acer Aspire 9500", ALC260_FIXUP_COEF),
  1500. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_FIXUP_GPIO1),
  1501. SND_PCI_QUIRK(0x103c, 0x280a, "HP dc5750", ALC260_FIXUP_HP_DC5750),
  1502. SND_PCI_QUIRK(0x103c, 0x30ba, "HP Presario B1900", ALC260_FIXUP_HP_B1900),
  1503. SND_PCI_QUIRK(0x10cf, 0x1326, "FSC LifeBook S7020", ALC260_FIXUP_FSC_S7020),
  1504. SND_PCI_QUIRK(0x1509, 0x4540, "Favorit 100XS", ALC260_FIXUP_GPIO1),
  1505. SND_PCI_QUIRK(0x152d, 0x0729, "Quanta KN1", ALC260_FIXUP_KN1),
  1506. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_FIXUP_REPLACER),
  1507. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_FIXUP_COEF),
  1508. {}
  1509. };
  1510. static const struct hda_model_fixup alc260_fixup_models[] = {
  1511. {.id = ALC260_FIXUP_GPIO1, .name = "gpio1"},
  1512. {.id = ALC260_FIXUP_COEF, .name = "coef"},
  1513. {.id = ALC260_FIXUP_FSC_S7020, .name = "fujitsu"},
  1514. {.id = ALC260_FIXUP_FSC_S7020_JWSE, .name = "fujitsu-jwse"},
  1515. {}
  1516. };
  1517. /*
  1518. */
  1519. static int patch_alc260(struct hda_codec *codec)
  1520. {
  1521. struct alc_spec *spec;
  1522. int err;
  1523. err = alc_alloc_spec(codec, 0x07);
  1524. if (err < 0)
  1525. return err;
  1526. spec = codec->spec;
  1527. /* as quite a few machines require HP amp for speaker outputs,
  1528. * it's easier to enable it unconditionally; even if it's unneeded,
  1529. * it's almost harmless.
  1530. */
  1531. spec->gen.prefer_hp_amp = 1;
  1532. spec->gen.beep_nid = 0x01;
  1533. snd_hda_pick_fixup(codec, alc260_fixup_models, alc260_fixup_tbl,
  1534. alc260_fixups);
  1535. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  1536. /* automatic parse from the BIOS config */
  1537. err = alc260_parse_auto_config(codec);
  1538. if (err < 0)
  1539. goto error;
  1540. if (!spec->gen.no_analog)
  1541. set_beep_amp(spec, 0x07, 0x05, HDA_INPUT);
  1542. codec->patch_ops = alc_patch_ops;
  1543. spec->shutup = alc_eapd_shutup;
  1544. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  1545. return 0;
  1546. error:
  1547. alc_free(codec);
  1548. return err;
  1549. }
  1550. /*
  1551. * ALC882/883/885/888/889 support
  1552. *
  1553. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  1554. * configuration. Each pin widget can choose any input DACs and a mixer.
  1555. * Each ADC is connected from a mixer of all inputs. This makes possible
  1556. * 6-channel independent captures.
  1557. *
  1558. * In addition, an independent DAC for the multi-playback (not used in this
  1559. * driver yet).
  1560. */
  1561. /*
  1562. * Pin config fixes
  1563. */
  1564. enum {
  1565. ALC882_FIXUP_ABIT_AW9D_MAX,
  1566. ALC882_FIXUP_LENOVO_Y530,
  1567. ALC882_FIXUP_PB_M5210,
  1568. ALC882_FIXUP_ACER_ASPIRE_7736,
  1569. ALC882_FIXUP_ASUS_W90V,
  1570. ALC889_FIXUP_CD,
  1571. ALC889_FIXUP_VAIO_TT,
  1572. ALC888_FIXUP_EEE1601,
  1573. ALC882_FIXUP_EAPD,
  1574. ALC883_FIXUP_EAPD,
  1575. ALC883_FIXUP_ACER_EAPD,
  1576. ALC882_FIXUP_GPIO1,
  1577. ALC882_FIXUP_GPIO2,
  1578. ALC882_FIXUP_GPIO3,
  1579. ALC889_FIXUP_COEF,
  1580. ALC882_FIXUP_ASUS_W2JC,
  1581. ALC882_FIXUP_ACER_ASPIRE_4930G,
  1582. ALC882_FIXUP_ACER_ASPIRE_8930G,
  1583. ALC882_FIXUP_ASPIRE_8930G_VERBS,
  1584. ALC885_FIXUP_MACPRO_GPIO,
  1585. ALC889_FIXUP_DAC_ROUTE,
  1586. ALC889_FIXUP_MBP_VREF,
  1587. ALC889_FIXUP_IMAC91_VREF,
  1588. ALC882_FIXUP_INV_DMIC,
  1589. ALC882_FIXUP_NO_PRIMARY_HP,
  1590. };
  1591. static void alc889_fixup_coef(struct hda_codec *codec,
  1592. const struct hda_fixup *fix, int action)
  1593. {
  1594. if (action != HDA_FIXUP_ACT_INIT)
  1595. return;
  1596. alc889_coef_init(codec);
  1597. }
  1598. /* toggle speaker-output according to the hp-jack state */
  1599. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  1600. {
  1601. unsigned int gpiostate, gpiomask, gpiodir;
  1602. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  1603. AC_VERB_GET_GPIO_DATA, 0);
  1604. if (!muted)
  1605. gpiostate |= (1 << pin);
  1606. else
  1607. gpiostate &= ~(1 << pin);
  1608. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  1609. AC_VERB_GET_GPIO_MASK, 0);
  1610. gpiomask |= (1 << pin);
  1611. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  1612. AC_VERB_GET_GPIO_DIRECTION, 0);
  1613. gpiodir |= (1 << pin);
  1614. snd_hda_codec_write(codec, codec->afg, 0,
  1615. AC_VERB_SET_GPIO_MASK, gpiomask);
  1616. snd_hda_codec_write(codec, codec->afg, 0,
  1617. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  1618. msleep(1);
  1619. snd_hda_codec_write(codec, codec->afg, 0,
  1620. AC_VERB_SET_GPIO_DATA, gpiostate);
  1621. }
  1622. /* set up GPIO at initialization */
  1623. static void alc885_fixup_macpro_gpio(struct hda_codec *codec,
  1624. const struct hda_fixup *fix, int action)
  1625. {
  1626. if (action != HDA_FIXUP_ACT_INIT)
  1627. return;
  1628. alc882_gpio_mute(codec, 0, 0);
  1629. alc882_gpio_mute(codec, 1, 0);
  1630. }
  1631. /* Fix the connection of some pins for ALC889:
  1632. * At least, Acer Aspire 5935 shows the connections to DAC3/4 don't
  1633. * work correctly (bko#42740)
  1634. */
  1635. static void alc889_fixup_dac_route(struct hda_codec *codec,
  1636. const struct hda_fixup *fix, int action)
  1637. {
  1638. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  1639. /* fake the connections during parsing the tree */
  1640. hda_nid_t conn1[2] = { 0x0c, 0x0d };
  1641. hda_nid_t conn2[2] = { 0x0e, 0x0f };
  1642. snd_hda_override_conn_list(codec, 0x14, 2, conn1);
  1643. snd_hda_override_conn_list(codec, 0x15, 2, conn1);
  1644. snd_hda_override_conn_list(codec, 0x18, 2, conn2);
  1645. snd_hda_override_conn_list(codec, 0x1a, 2, conn2);
  1646. } else if (action == HDA_FIXUP_ACT_PROBE) {
  1647. /* restore the connections */
  1648. hda_nid_t conn[5] = { 0x0c, 0x0d, 0x0e, 0x0f, 0x26 };
  1649. snd_hda_override_conn_list(codec, 0x14, 5, conn);
  1650. snd_hda_override_conn_list(codec, 0x15, 5, conn);
  1651. snd_hda_override_conn_list(codec, 0x18, 5, conn);
  1652. snd_hda_override_conn_list(codec, 0x1a, 5, conn);
  1653. }
  1654. }
  1655. /* Set VREF on HP pin */
  1656. static void alc889_fixup_mbp_vref(struct hda_codec *codec,
  1657. const struct hda_fixup *fix, int action)
  1658. {
  1659. struct alc_spec *spec = codec->spec;
  1660. static hda_nid_t nids[2] = { 0x14, 0x15 };
  1661. int i;
  1662. if (action != HDA_FIXUP_ACT_INIT)
  1663. return;
  1664. for (i = 0; i < ARRAY_SIZE(nids); i++) {
  1665. unsigned int val = snd_hda_codec_get_pincfg(codec, nids[i]);
  1666. if (get_defcfg_device(val) != AC_JACK_HP_OUT)
  1667. continue;
  1668. val = snd_hda_codec_get_pin_target(codec, nids[i]);
  1669. val |= AC_PINCTL_VREF_80;
  1670. snd_hda_set_pin_ctl(codec, nids[i], val);
  1671. spec->gen.keep_vref_in_automute = 1;
  1672. break;
  1673. }
  1674. }
  1675. /* Set VREF on speaker pins on imac91 */
  1676. static void alc889_fixup_imac91_vref(struct hda_codec *codec,
  1677. const struct hda_fixup *fix, int action)
  1678. {
  1679. struct alc_spec *spec = codec->spec;
  1680. static hda_nid_t nids[2] = { 0x18, 0x1a };
  1681. int i;
  1682. if (action != HDA_FIXUP_ACT_INIT)
  1683. return;
  1684. for (i = 0; i < ARRAY_SIZE(nids); i++) {
  1685. unsigned int val;
  1686. val = snd_hda_codec_get_pin_target(codec, nids[i]);
  1687. val |= AC_PINCTL_VREF_50;
  1688. snd_hda_set_pin_ctl(codec, nids[i], val);
  1689. }
  1690. spec->gen.keep_vref_in_automute = 1;
  1691. }
  1692. /* Don't take HP output as primary
  1693. * Strangely, the speaker output doesn't work on Vaio Z and some Vaio
  1694. * all-in-one desktop PCs (for example VGC-LN51JGB) through DAC 0x05
  1695. */
  1696. static void alc882_fixup_no_primary_hp(struct hda_codec *codec,
  1697. const struct hda_fixup *fix, int action)
  1698. {
  1699. struct alc_spec *spec = codec->spec;
  1700. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  1701. spec->gen.no_primary_hp = 1;
  1702. spec->gen.no_multi_io = 1;
  1703. }
  1704. }
  1705. static const struct hda_fixup alc882_fixups[] = {
  1706. [ALC882_FIXUP_ABIT_AW9D_MAX] = {
  1707. .type = HDA_FIXUP_PINS,
  1708. .v.pins = (const struct hda_pintbl[]) {
  1709. { 0x15, 0x01080104 }, /* side */
  1710. { 0x16, 0x01011012 }, /* rear */
  1711. { 0x17, 0x01016011 }, /* clfe */
  1712. { }
  1713. }
  1714. },
  1715. [ALC882_FIXUP_LENOVO_Y530] = {
  1716. .type = HDA_FIXUP_PINS,
  1717. .v.pins = (const struct hda_pintbl[]) {
  1718. { 0x15, 0x99130112 }, /* rear int speakers */
  1719. { 0x16, 0x99130111 }, /* subwoofer */
  1720. { }
  1721. }
  1722. },
  1723. [ALC882_FIXUP_PB_M5210] = {
  1724. .type = HDA_FIXUP_PINCTLS,
  1725. .v.pins = (const struct hda_pintbl[]) {
  1726. { 0x19, PIN_VREF50 },
  1727. {}
  1728. }
  1729. },
  1730. [ALC882_FIXUP_ACER_ASPIRE_7736] = {
  1731. .type = HDA_FIXUP_FUNC,
  1732. .v.func = alc_fixup_sku_ignore,
  1733. },
  1734. [ALC882_FIXUP_ASUS_W90V] = {
  1735. .type = HDA_FIXUP_PINS,
  1736. .v.pins = (const struct hda_pintbl[]) {
  1737. { 0x16, 0x99130110 }, /* fix sequence for CLFE */
  1738. { }
  1739. }
  1740. },
  1741. [ALC889_FIXUP_CD] = {
  1742. .type = HDA_FIXUP_PINS,
  1743. .v.pins = (const struct hda_pintbl[]) {
  1744. { 0x1c, 0x993301f0 }, /* CD */
  1745. { }
  1746. }
  1747. },
  1748. [ALC889_FIXUP_VAIO_TT] = {
  1749. .type = HDA_FIXUP_PINS,
  1750. .v.pins = (const struct hda_pintbl[]) {
  1751. { 0x17, 0x90170111 }, /* hidden surround speaker */
  1752. { }
  1753. }
  1754. },
  1755. [ALC888_FIXUP_EEE1601] = {
  1756. .type = HDA_FIXUP_VERBS,
  1757. .v.verbs = (const struct hda_verb[]) {
  1758. { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
  1759. { 0x20, AC_VERB_SET_PROC_COEF, 0x0838 },
  1760. { }
  1761. }
  1762. },
  1763. [ALC882_FIXUP_EAPD] = {
  1764. .type = HDA_FIXUP_VERBS,
  1765. .v.verbs = (const struct hda_verb[]) {
  1766. /* change to EAPD mode */
  1767. { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
  1768. { 0x20, AC_VERB_SET_PROC_COEF, 0x3060 },
  1769. { }
  1770. }
  1771. },
  1772. [ALC883_FIXUP_EAPD] = {
  1773. .type = HDA_FIXUP_VERBS,
  1774. .v.verbs = (const struct hda_verb[]) {
  1775. /* change to EAPD mode */
  1776. { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
  1777. { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
  1778. { }
  1779. }
  1780. },
  1781. [ALC883_FIXUP_ACER_EAPD] = {
  1782. .type = HDA_FIXUP_VERBS,
  1783. .v.verbs = (const struct hda_verb[]) {
  1784. /* eanable EAPD on Acer laptops */
  1785. { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
  1786. { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
  1787. { }
  1788. }
  1789. },
  1790. [ALC882_FIXUP_GPIO1] = {
  1791. .type = HDA_FIXUP_VERBS,
  1792. .v.verbs = alc_gpio1_init_verbs,
  1793. },
  1794. [ALC882_FIXUP_GPIO2] = {
  1795. .type = HDA_FIXUP_VERBS,
  1796. .v.verbs = alc_gpio2_init_verbs,
  1797. },
  1798. [ALC882_FIXUP_GPIO3] = {
  1799. .type = HDA_FIXUP_VERBS,
  1800. .v.verbs = alc_gpio3_init_verbs,
  1801. },
  1802. [ALC882_FIXUP_ASUS_W2JC] = {
  1803. .type = HDA_FIXUP_VERBS,
  1804. .v.verbs = alc_gpio1_init_verbs,
  1805. .chained = true,
  1806. .chain_id = ALC882_FIXUP_EAPD,
  1807. },
  1808. [ALC889_FIXUP_COEF] = {
  1809. .type = HDA_FIXUP_FUNC,
  1810. .v.func = alc889_fixup_coef,
  1811. },
  1812. [ALC882_FIXUP_ACER_ASPIRE_4930G] = {
  1813. .type = HDA_FIXUP_PINS,
  1814. .v.pins = (const struct hda_pintbl[]) {
  1815. { 0x16, 0x99130111 }, /* CLFE speaker */
  1816. { 0x17, 0x99130112 }, /* surround speaker */
  1817. { }
  1818. },
  1819. .chained = true,
  1820. .chain_id = ALC882_FIXUP_GPIO1,
  1821. },
  1822. [ALC882_FIXUP_ACER_ASPIRE_8930G] = {
  1823. .type = HDA_FIXUP_PINS,
  1824. .v.pins = (const struct hda_pintbl[]) {
  1825. { 0x16, 0x99130111 }, /* CLFE speaker */
  1826. { 0x1b, 0x99130112 }, /* surround speaker */
  1827. { }
  1828. },
  1829. .chained = true,
  1830. .chain_id = ALC882_FIXUP_ASPIRE_8930G_VERBS,
  1831. },
  1832. [ALC882_FIXUP_ASPIRE_8930G_VERBS] = {
  1833. /* additional init verbs for Acer Aspire 8930G */
  1834. .type = HDA_FIXUP_VERBS,
  1835. .v.verbs = (const struct hda_verb[]) {
  1836. /* Enable all DACs */
  1837. /* DAC DISABLE/MUTE 1? */
  1838. /* setting bits 1-5 disables DAC nids 0x02-0x06
  1839. * apparently. Init=0x38 */
  1840. { 0x20, AC_VERB_SET_COEF_INDEX, 0x03 },
  1841. { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
  1842. /* DAC DISABLE/MUTE 2? */
  1843. /* some bit here disables the other DACs.
  1844. * Init=0x4900 */
  1845. { 0x20, AC_VERB_SET_COEF_INDEX, 0x08 },
  1846. { 0x20, AC_VERB_SET_PROC_COEF, 0x0000 },
  1847. /* DMIC fix
  1848. * This laptop has a stereo digital microphone.
  1849. * The mics are only 1cm apart which makes the stereo
  1850. * useless. However, either the mic or the ALC889
  1851. * makes the signal become a difference/sum signal
  1852. * instead of standard stereo, which is annoying.
  1853. * So instead we flip this bit which makes the
  1854. * codec replicate the sum signal to both channels,
  1855. * turning it into a normal mono mic.
  1856. */
  1857. /* DMIC_CONTROL? Init value = 0x0001 */
  1858. { 0x20, AC_VERB_SET_COEF_INDEX, 0x0b },
  1859. { 0x20, AC_VERB_SET_PROC_COEF, 0x0003 },
  1860. { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
  1861. { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
  1862. { }
  1863. },
  1864. .chained = true,
  1865. .chain_id = ALC882_FIXUP_GPIO1,
  1866. },
  1867. [ALC885_FIXUP_MACPRO_GPIO] = {
  1868. .type = HDA_FIXUP_FUNC,
  1869. .v.func = alc885_fixup_macpro_gpio,
  1870. },
  1871. [ALC889_FIXUP_DAC_ROUTE] = {
  1872. .type = HDA_FIXUP_FUNC,
  1873. .v.func = alc889_fixup_dac_route,
  1874. },
  1875. [ALC889_FIXUP_MBP_VREF] = {
  1876. .type = HDA_FIXUP_FUNC,
  1877. .v.func = alc889_fixup_mbp_vref,
  1878. .chained = true,
  1879. .chain_id = ALC882_FIXUP_GPIO1,
  1880. },
  1881. [ALC889_FIXUP_IMAC91_VREF] = {
  1882. .type = HDA_FIXUP_FUNC,
  1883. .v.func = alc889_fixup_imac91_vref,
  1884. .chained = true,
  1885. .chain_id = ALC882_FIXUP_GPIO1,
  1886. },
  1887. [ALC882_FIXUP_INV_DMIC] = {
  1888. .type = HDA_FIXUP_FUNC,
  1889. .v.func = alc_fixup_inv_dmic_0x12,
  1890. },
  1891. [ALC882_FIXUP_NO_PRIMARY_HP] = {
  1892. .type = HDA_FIXUP_FUNC,
  1893. .v.func = alc882_fixup_no_primary_hp,
  1894. },
  1895. };
  1896. static const struct snd_pci_quirk alc882_fixup_tbl[] = {
  1897. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_FIXUP_ACER_EAPD),
  1898. SND_PCI_QUIRK(0x1025, 0x0090, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
  1899. SND_PCI_QUIRK(0x1025, 0x010a, "Acer Ferrari 5000", ALC883_FIXUP_ACER_EAPD),
  1900. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_FIXUP_ACER_EAPD),
  1901. SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_FIXUP_ACER_EAPD),
  1902. SND_PCI_QUIRK(0x1025, 0x0121, "Acer Aspire 5920G", ALC883_FIXUP_ACER_EAPD),
  1903. SND_PCI_QUIRK(0x1025, 0x013e, "Acer Aspire 4930G",
  1904. ALC882_FIXUP_ACER_ASPIRE_4930G),
  1905. SND_PCI_QUIRK(0x1025, 0x013f, "Acer Aspire 5930G",
  1906. ALC882_FIXUP_ACER_ASPIRE_4930G),
  1907. SND_PCI_QUIRK(0x1025, 0x0145, "Acer Aspire 8930G",
  1908. ALC882_FIXUP_ACER_ASPIRE_8930G),
  1909. SND_PCI_QUIRK(0x1025, 0x0146, "Acer Aspire 6935G",
  1910. ALC882_FIXUP_ACER_ASPIRE_8930G),
  1911. SND_PCI_QUIRK(0x1025, 0x015e, "Acer Aspire 6930G",
  1912. ALC882_FIXUP_ACER_ASPIRE_4930G),
  1913. SND_PCI_QUIRK(0x1025, 0x0166, "Acer Aspire 6530G",
  1914. ALC882_FIXUP_ACER_ASPIRE_4930G),
  1915. SND_PCI_QUIRK(0x1025, 0x0142, "Acer Aspire 7730G",
  1916. ALC882_FIXUP_ACER_ASPIRE_4930G),
  1917. SND_PCI_QUIRK(0x1025, 0x0155, "Packard-Bell M5120", ALC882_FIXUP_PB_M5210),
  1918. SND_PCI_QUIRK(0x1025, 0x021e, "Acer Aspire 5739G",
  1919. ALC882_FIXUP_ACER_ASPIRE_4930G),
  1920. SND_PCI_QUIRK(0x1025, 0x0259, "Acer Aspire 5935", ALC889_FIXUP_DAC_ROUTE),
  1921. SND_PCI_QUIRK(0x1025, 0x026b, "Acer Aspire 8940G", ALC882_FIXUP_ACER_ASPIRE_8930G),
  1922. SND_PCI_QUIRK(0x1025, 0x0296, "Acer Aspire 7736z", ALC882_FIXUP_ACER_ASPIRE_7736),
  1923. SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_FIXUP_EAPD),
  1924. SND_PCI_QUIRK(0x1043, 0x1873, "ASUS W90V", ALC882_FIXUP_ASUS_W90V),
  1925. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_FIXUP_ASUS_W2JC),
  1926. SND_PCI_QUIRK(0x1043, 0x835f, "Asus Eee 1601", ALC888_FIXUP_EEE1601),
  1927. SND_PCI_QUIRK(0x104d, 0x9047, "Sony Vaio TT", ALC889_FIXUP_VAIO_TT),
  1928. SND_PCI_QUIRK(0x104d, 0x905a, "Sony Vaio Z", ALC882_FIXUP_NO_PRIMARY_HP),
  1929. SND_PCI_QUIRK(0x104d, 0x9043, "Sony Vaio VGC-LN51JGB", ALC882_FIXUP_NO_PRIMARY_HP),
  1930. /* All Apple entries are in codec SSIDs */
  1931. SND_PCI_QUIRK(0x106b, 0x00a0, "MacBookPro 3,1", ALC889_FIXUP_MBP_VREF),
  1932. SND_PCI_QUIRK(0x106b, 0x00a1, "Macbook", ALC889_FIXUP_MBP_VREF),
  1933. SND_PCI_QUIRK(0x106b, 0x00a4, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
  1934. SND_PCI_QUIRK(0x106b, 0x0c00, "Mac Pro", ALC885_FIXUP_MACPRO_GPIO),
  1935. SND_PCI_QUIRK(0x106b, 0x1000, "iMac 24", ALC885_FIXUP_MACPRO_GPIO),
  1936. SND_PCI_QUIRK(0x106b, 0x2800, "AppleTV", ALC885_FIXUP_MACPRO_GPIO),
  1937. SND_PCI_QUIRK(0x106b, 0x2c00, "MacbookPro rev3", ALC889_FIXUP_MBP_VREF),
  1938. SND_PCI_QUIRK(0x106b, 0x3000, "iMac", ALC889_FIXUP_MBP_VREF),
  1939. SND_PCI_QUIRK(0x106b, 0x3200, "iMac 7,1 Aluminum", ALC882_FIXUP_EAPD),
  1940. SND_PCI_QUIRK(0x106b, 0x3400, "MacBookAir 1,1", ALC889_FIXUP_MBP_VREF),
  1941. SND_PCI_QUIRK(0x106b, 0x3500, "MacBookAir 2,1", ALC889_FIXUP_MBP_VREF),
  1942. SND_PCI_QUIRK(0x106b, 0x3600, "Macbook 3,1", ALC889_FIXUP_MBP_VREF),
  1943. SND_PCI_QUIRK(0x106b, 0x3800, "MacbookPro 4,1", ALC889_FIXUP_MBP_VREF),
  1944. SND_PCI_QUIRK(0x106b, 0x3e00, "iMac 24 Aluminum", ALC885_FIXUP_MACPRO_GPIO),
  1945. SND_PCI_QUIRK(0x106b, 0x3f00, "Macbook 5,1", ALC889_FIXUP_IMAC91_VREF),
  1946. SND_PCI_QUIRK(0x106b, 0x4000, "MacbookPro 5,1", ALC889_FIXUP_IMAC91_VREF),
  1947. SND_PCI_QUIRK(0x106b, 0x4100, "Macmini 3,1", ALC889_FIXUP_IMAC91_VREF),
  1948. SND_PCI_QUIRK(0x106b, 0x4200, "Mac Pro 5,1", ALC885_FIXUP_MACPRO_GPIO),
  1949. SND_PCI_QUIRK(0x106b, 0x4300, "iMac 9,1", ALC889_FIXUP_IMAC91_VREF),
  1950. SND_PCI_QUIRK(0x106b, 0x4600, "MacbookPro 5,2", ALC889_FIXUP_IMAC91_VREF),
  1951. SND_PCI_QUIRK(0x106b, 0x4900, "iMac 9,1 Aluminum", ALC889_FIXUP_IMAC91_VREF),
  1952. SND_PCI_QUIRK(0x106b, 0x4a00, "Macbook 5,2", ALC889_FIXUP_IMAC91_VREF),
  1953. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC882_FIXUP_EAPD),
  1954. SND_PCI_QUIRK(0x1462, 0x7350, "MSI-7350", ALC889_FIXUP_CD),
  1955. SND_PCI_QUIRK_VENDOR(0x1462, "MSI", ALC882_FIXUP_GPIO3),
  1956. SND_PCI_QUIRK(0x1458, 0xa002, "Gigabyte EP45-DS3", ALC889_FIXUP_CD),
  1957. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", ALC882_FIXUP_ABIT_AW9D_MAX),
  1958. SND_PCI_QUIRK_VENDOR(0x1558, "Clevo laptop", ALC882_FIXUP_EAPD),
  1959. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_FIXUP_EAPD),
  1960. SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Y530", ALC882_FIXUP_LENOVO_Y530),
  1961. SND_PCI_QUIRK(0x8086, 0x0022, "DX58SO", ALC889_FIXUP_COEF),
  1962. {}
  1963. };
  1964. static const struct hda_model_fixup alc882_fixup_models[] = {
  1965. {.id = ALC882_FIXUP_ACER_ASPIRE_4930G, .name = "acer-aspire-4930g"},
  1966. {.id = ALC882_FIXUP_ACER_ASPIRE_8930G, .name = "acer-aspire-8930g"},
  1967. {.id = ALC883_FIXUP_ACER_EAPD, .name = "acer-aspire"},
  1968. {.id = ALC882_FIXUP_INV_DMIC, .name = "inv-dmic"},
  1969. {.id = ALC882_FIXUP_NO_PRIMARY_HP, .name = "no-primary-hp"},
  1970. {}
  1971. };
  1972. /*
  1973. * BIOS auto configuration
  1974. */
  1975. /* almost identical with ALC880 parser... */
  1976. static int alc882_parse_auto_config(struct hda_codec *codec)
  1977. {
  1978. static const hda_nid_t alc882_ignore[] = { 0x1d, 0 };
  1979. static const hda_nid_t alc882_ssids[] = { 0x15, 0x1b, 0x14, 0 };
  1980. return alc_parse_auto_config(codec, alc882_ignore, alc882_ssids);
  1981. }
  1982. /*
  1983. */
  1984. static int patch_alc882(struct hda_codec *codec)
  1985. {
  1986. struct alc_spec *spec;
  1987. int err;
  1988. err = alc_alloc_spec(codec, 0x0b);
  1989. if (err < 0)
  1990. return err;
  1991. spec = codec->spec;
  1992. switch (codec->vendor_id) {
  1993. case 0x10ec0882:
  1994. case 0x10ec0885:
  1995. break;
  1996. default:
  1997. /* ALC883 and variants */
  1998. alc_fix_pll_init(codec, 0x20, 0x0a, 10);
  1999. break;
  2000. }
  2001. snd_hda_pick_fixup(codec, alc882_fixup_models, alc882_fixup_tbl,
  2002. alc882_fixups);
  2003. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  2004. alc_auto_parse_customize_define(codec);
  2005. if (has_cdefine_beep(codec))
  2006. spec->gen.beep_nid = 0x01;
  2007. /* automatic parse from the BIOS config */
  2008. err = alc882_parse_auto_config(codec);
  2009. if (err < 0)
  2010. goto error;
  2011. if (!spec->gen.no_analog && spec->gen.beep_nid)
  2012. set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
  2013. codec->patch_ops = alc_patch_ops;
  2014. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  2015. return 0;
  2016. error:
  2017. alc_free(codec);
  2018. return err;
  2019. }
  2020. /*
  2021. * ALC262 support
  2022. */
  2023. static int alc262_parse_auto_config(struct hda_codec *codec)
  2024. {
  2025. static const hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  2026. static const hda_nid_t alc262_ssids[] = { 0x15, 0x1b, 0x14, 0 };
  2027. return alc_parse_auto_config(codec, alc262_ignore, alc262_ssids);
  2028. }
  2029. /*
  2030. * Pin config fixes
  2031. */
  2032. enum {
  2033. ALC262_FIXUP_FSC_H270,
  2034. ALC262_FIXUP_FSC_S7110,
  2035. ALC262_FIXUP_HP_Z200,
  2036. ALC262_FIXUP_TYAN,
  2037. ALC262_FIXUP_LENOVO_3000,
  2038. ALC262_FIXUP_BENQ,
  2039. ALC262_FIXUP_BENQ_T31,
  2040. ALC262_FIXUP_INV_DMIC,
  2041. };
  2042. static const struct hda_fixup alc262_fixups[] = {
  2043. [ALC262_FIXUP_FSC_H270] = {
  2044. .type = HDA_FIXUP_PINS,
  2045. .v.pins = (const struct hda_pintbl[]) {
  2046. { 0x14, 0x99130110 }, /* speaker */
  2047. { 0x15, 0x0221142f }, /* front HP */
  2048. { 0x1b, 0x0121141f }, /* rear HP */
  2049. { }
  2050. }
  2051. },
  2052. [ALC262_FIXUP_FSC_S7110] = {
  2053. .type = HDA_FIXUP_PINS,
  2054. .v.pins = (const struct hda_pintbl[]) {
  2055. { 0x15, 0x90170110 }, /* speaker */
  2056. { }
  2057. },
  2058. .chained = true,
  2059. .chain_id = ALC262_FIXUP_BENQ,
  2060. },
  2061. [ALC262_FIXUP_HP_Z200] = {
  2062. .type = HDA_FIXUP_PINS,
  2063. .v.pins = (const struct hda_pintbl[]) {
  2064. { 0x16, 0x99130120 }, /* internal speaker */
  2065. { }
  2066. }
  2067. },
  2068. [ALC262_FIXUP_TYAN] = {
  2069. .type = HDA_FIXUP_PINS,
  2070. .v.pins = (const struct hda_pintbl[]) {
  2071. { 0x14, 0x1993e1f0 }, /* int AUX */
  2072. { }
  2073. }
  2074. },
  2075. [ALC262_FIXUP_LENOVO_3000] = {
  2076. .type = HDA_FIXUP_PINCTLS,
  2077. .v.pins = (const struct hda_pintbl[]) {
  2078. { 0x19, PIN_VREF50 },
  2079. {}
  2080. },
  2081. .chained = true,
  2082. .chain_id = ALC262_FIXUP_BENQ,
  2083. },
  2084. [ALC262_FIXUP_BENQ] = {
  2085. .type = HDA_FIXUP_VERBS,
  2086. .v.verbs = (const struct hda_verb[]) {
  2087. { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
  2088. { 0x20, AC_VERB_SET_PROC_COEF, 0x3070 },
  2089. {}
  2090. }
  2091. },
  2092. [ALC262_FIXUP_BENQ_T31] = {
  2093. .type = HDA_FIXUP_VERBS,
  2094. .v.verbs = (const struct hda_verb[]) {
  2095. { 0x20, AC_VERB_SET_COEF_INDEX, 0x07 },
  2096. { 0x20, AC_VERB_SET_PROC_COEF, 0x3050 },
  2097. {}
  2098. }
  2099. },
  2100. [ALC262_FIXUP_INV_DMIC] = {
  2101. .type = HDA_FIXUP_FUNC,
  2102. .v.func = alc_fixup_inv_dmic_0x12,
  2103. },
  2104. };
  2105. static const struct snd_pci_quirk alc262_fixup_tbl[] = {
  2106. SND_PCI_QUIRK(0x103c, 0x170b, "HP Z200", ALC262_FIXUP_HP_Z200),
  2107. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu Lifebook S7110", ALC262_FIXUP_FSC_S7110),
  2108. SND_PCI_QUIRK(0x10cf, 0x142d, "Fujitsu Lifebook E8410", ALC262_FIXUP_BENQ),
  2109. SND_PCI_QUIRK(0x10f1, 0x2915, "Tyan Thunder n6650W", ALC262_FIXUP_TYAN),
  2110. SND_PCI_QUIRK(0x1734, 0x1147, "FSC Celsius H270", ALC262_FIXUP_FSC_H270),
  2111. SND_PCI_QUIRK(0x17aa, 0x384e, "Lenovo 3000", ALC262_FIXUP_LENOVO_3000),
  2112. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_FIXUP_BENQ),
  2113. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_FIXUP_BENQ_T31),
  2114. {}
  2115. };
  2116. static const struct hda_model_fixup alc262_fixup_models[] = {
  2117. {.id = ALC262_FIXUP_INV_DMIC, .name = "inv-dmic"},
  2118. {}
  2119. };
  2120. /*
  2121. */
  2122. static int patch_alc262(struct hda_codec *codec)
  2123. {
  2124. struct alc_spec *spec;
  2125. int err;
  2126. err = alc_alloc_spec(codec, 0x0b);
  2127. if (err < 0)
  2128. return err;
  2129. spec = codec->spec;
  2130. spec->gen.shared_mic_vref_pin = 0x18;
  2131. #if 0
  2132. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  2133. * under-run
  2134. */
  2135. {
  2136. int tmp;
  2137. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  2138. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  2139. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  2140. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  2141. }
  2142. #endif
  2143. alc_fix_pll_init(codec, 0x20, 0x0a, 10);
  2144. snd_hda_pick_fixup(codec, alc262_fixup_models, alc262_fixup_tbl,
  2145. alc262_fixups);
  2146. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  2147. alc_auto_parse_customize_define(codec);
  2148. if (has_cdefine_beep(codec))
  2149. spec->gen.beep_nid = 0x01;
  2150. /* automatic parse from the BIOS config */
  2151. err = alc262_parse_auto_config(codec);
  2152. if (err < 0)
  2153. goto error;
  2154. if (!spec->gen.no_analog && spec->gen.beep_nid)
  2155. set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
  2156. codec->patch_ops = alc_patch_ops;
  2157. spec->shutup = alc_eapd_shutup;
  2158. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  2159. return 0;
  2160. error:
  2161. alc_free(codec);
  2162. return err;
  2163. }
  2164. /*
  2165. * ALC268
  2166. */
  2167. /* bind Beep switches of both NID 0x0f and 0x10 */
  2168. static const struct hda_bind_ctls alc268_bind_beep_sw = {
  2169. .ops = &snd_hda_bind_sw,
  2170. .values = {
  2171. HDA_COMPOSE_AMP_VAL(0x0f, 3, 1, HDA_INPUT),
  2172. HDA_COMPOSE_AMP_VAL(0x10, 3, 1, HDA_INPUT),
  2173. 0
  2174. },
  2175. };
  2176. static const struct snd_kcontrol_new alc268_beep_mixer[] = {
  2177. HDA_CODEC_VOLUME("Beep Playback Volume", 0x1d, 0x0, HDA_INPUT),
  2178. HDA_BIND_SW("Beep Playback Switch", &alc268_bind_beep_sw),
  2179. { }
  2180. };
  2181. /* set PCBEEP vol = 0, mute connections */
  2182. static const struct hda_verb alc268_beep_init_verbs[] = {
  2183. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2184. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2185. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2186. { }
  2187. };
  2188. enum {
  2189. ALC268_FIXUP_INV_DMIC,
  2190. ALC268_FIXUP_HP_EAPD,
  2191. ALC268_FIXUP_SPDIF,
  2192. };
  2193. static const struct hda_fixup alc268_fixups[] = {
  2194. [ALC268_FIXUP_INV_DMIC] = {
  2195. .type = HDA_FIXUP_FUNC,
  2196. .v.func = alc_fixup_inv_dmic_0x12,
  2197. },
  2198. [ALC268_FIXUP_HP_EAPD] = {
  2199. .type = HDA_FIXUP_VERBS,
  2200. .v.verbs = (const struct hda_verb[]) {
  2201. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 0},
  2202. {}
  2203. }
  2204. },
  2205. [ALC268_FIXUP_SPDIF] = {
  2206. .type = HDA_FIXUP_PINS,
  2207. .v.pins = (const struct hda_pintbl[]) {
  2208. { 0x1e, 0x014b1180 }, /* enable SPDIF out */
  2209. {}
  2210. }
  2211. },
  2212. };
  2213. static const struct hda_model_fixup alc268_fixup_models[] = {
  2214. {.id = ALC268_FIXUP_INV_DMIC, .name = "inv-dmic"},
  2215. {.id = ALC268_FIXUP_HP_EAPD, .name = "hp-eapd"},
  2216. {}
  2217. };
  2218. static const struct snd_pci_quirk alc268_fixup_tbl[] = {
  2219. SND_PCI_QUIRK(0x1025, 0x0139, "Acer TravelMate 6293", ALC268_FIXUP_SPDIF),
  2220. SND_PCI_QUIRK(0x1025, 0x015b, "Acer AOA 150 (ZG5)", ALC268_FIXUP_INV_DMIC),
  2221. /* below is codec SSID since multiple Toshiba laptops have the
  2222. * same PCI SSID 1179:ff00
  2223. */
  2224. SND_PCI_QUIRK(0x1179, 0xff06, "Toshiba P200", ALC268_FIXUP_HP_EAPD),
  2225. {}
  2226. };
  2227. /*
  2228. * BIOS auto configuration
  2229. */
  2230. static int alc268_parse_auto_config(struct hda_codec *codec)
  2231. {
  2232. static const hda_nid_t alc268_ssids[] = { 0x15, 0x1b, 0x14, 0 };
  2233. return alc_parse_auto_config(codec, NULL, alc268_ssids);
  2234. }
  2235. /*
  2236. */
  2237. static int patch_alc268(struct hda_codec *codec)
  2238. {
  2239. struct alc_spec *spec;
  2240. int err;
  2241. /* ALC268 has no aa-loopback mixer */
  2242. err = alc_alloc_spec(codec, 0);
  2243. if (err < 0)
  2244. return err;
  2245. spec = codec->spec;
  2246. spec->gen.beep_nid = 0x01;
  2247. snd_hda_pick_fixup(codec, alc268_fixup_models, alc268_fixup_tbl, alc268_fixups);
  2248. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  2249. /* automatic parse from the BIOS config */
  2250. err = alc268_parse_auto_config(codec);
  2251. if (err < 0)
  2252. goto error;
  2253. if (err > 0 && !spec->gen.no_analog &&
  2254. spec->gen.autocfg.speaker_pins[0] != 0x1d) {
  2255. add_mixer(spec, alc268_beep_mixer);
  2256. snd_hda_add_verbs(codec, alc268_beep_init_verbs);
  2257. if (!query_amp_caps(codec, 0x1d, HDA_INPUT))
  2258. /* override the amp caps for beep generator */
  2259. snd_hda_override_amp_caps(codec, 0x1d, HDA_INPUT,
  2260. (0x0c << AC_AMPCAP_OFFSET_SHIFT) |
  2261. (0x0c << AC_AMPCAP_NUM_STEPS_SHIFT) |
  2262. (0x07 << AC_AMPCAP_STEP_SIZE_SHIFT) |
  2263. (0 << AC_AMPCAP_MUTE_SHIFT));
  2264. }
  2265. codec->patch_ops = alc_patch_ops;
  2266. spec->shutup = alc_eapd_shutup;
  2267. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  2268. return 0;
  2269. error:
  2270. alc_free(codec);
  2271. return err;
  2272. }
  2273. /*
  2274. * ALC269
  2275. */
  2276. static int playback_pcm_open(struct hda_pcm_stream *hinfo,
  2277. struct hda_codec *codec,
  2278. struct snd_pcm_substream *substream)
  2279. {
  2280. struct hda_gen_spec *spec = codec->spec;
  2281. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
  2282. hinfo);
  2283. }
  2284. static int playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  2285. struct hda_codec *codec,
  2286. unsigned int stream_tag,
  2287. unsigned int format,
  2288. struct snd_pcm_substream *substream)
  2289. {
  2290. struct hda_gen_spec *spec = codec->spec;
  2291. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  2292. stream_tag, format, substream);
  2293. }
  2294. static int playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2295. struct hda_codec *codec,
  2296. struct snd_pcm_substream *substream)
  2297. {
  2298. struct hda_gen_spec *spec = codec->spec;
  2299. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  2300. }
  2301. static const struct hda_pcm_stream alc269_44k_pcm_analog_playback = {
  2302. .substreams = 1,
  2303. .channels_min = 2,
  2304. .channels_max = 8,
  2305. .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
  2306. /* NID is set in alc_build_pcms */
  2307. .ops = {
  2308. .open = playback_pcm_open,
  2309. .prepare = playback_pcm_prepare,
  2310. .cleanup = playback_pcm_cleanup
  2311. },
  2312. };
  2313. static const struct hda_pcm_stream alc269_44k_pcm_analog_capture = {
  2314. .substreams = 1,
  2315. .channels_min = 2,
  2316. .channels_max = 2,
  2317. .rates = SNDRV_PCM_RATE_44100, /* fixed rate */
  2318. /* NID is set in alc_build_pcms */
  2319. };
  2320. /* different alc269-variants */
  2321. enum {
  2322. ALC269_TYPE_ALC269VA,
  2323. ALC269_TYPE_ALC269VB,
  2324. ALC269_TYPE_ALC269VC,
  2325. ALC269_TYPE_ALC269VD,
  2326. ALC269_TYPE_ALC280,
  2327. ALC269_TYPE_ALC282,
  2328. ALC269_TYPE_ALC283,
  2329. ALC269_TYPE_ALC284,
  2330. ALC269_TYPE_ALC285,
  2331. ALC269_TYPE_ALC286,
  2332. ALC269_TYPE_ALC255,
  2333. };
  2334. /*
  2335. * BIOS auto configuration
  2336. */
  2337. static int alc269_parse_auto_config(struct hda_codec *codec)
  2338. {
  2339. static const hda_nid_t alc269_ignore[] = { 0x1d, 0 };
  2340. static const hda_nid_t alc269_ssids[] = { 0, 0x1b, 0x14, 0x21 };
  2341. static const hda_nid_t alc269va_ssids[] = { 0x15, 0x1b, 0x14, 0 };
  2342. struct alc_spec *spec = codec->spec;
  2343. const hda_nid_t *ssids;
  2344. switch (spec->codec_variant) {
  2345. case ALC269_TYPE_ALC269VA:
  2346. case ALC269_TYPE_ALC269VC:
  2347. case ALC269_TYPE_ALC280:
  2348. case ALC269_TYPE_ALC284:
  2349. case ALC269_TYPE_ALC285:
  2350. ssids = alc269va_ssids;
  2351. break;
  2352. case ALC269_TYPE_ALC269VB:
  2353. case ALC269_TYPE_ALC269VD:
  2354. case ALC269_TYPE_ALC282:
  2355. case ALC269_TYPE_ALC283:
  2356. case ALC269_TYPE_ALC286:
  2357. case ALC269_TYPE_ALC255:
  2358. ssids = alc269_ssids;
  2359. break;
  2360. default:
  2361. ssids = alc269_ssids;
  2362. break;
  2363. }
  2364. return alc_parse_auto_config(codec, alc269_ignore, ssids);
  2365. }
  2366. static void alc269vb_toggle_power_output(struct hda_codec *codec, int power_up)
  2367. {
  2368. int val = alc_read_coef_idx(codec, 0x04);
  2369. if (power_up)
  2370. val |= 1 << 11;
  2371. else
  2372. val &= ~(1 << 11);
  2373. alc_write_coef_idx(codec, 0x04, val);
  2374. }
  2375. static void alc269_shutup(struct hda_codec *codec)
  2376. {
  2377. struct alc_spec *spec = codec->spec;
  2378. if (spec->codec_variant == ALC269_TYPE_ALC269VB)
  2379. alc269vb_toggle_power_output(codec, 0);
  2380. if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
  2381. (alc_get_coef0(codec) & 0x00ff) == 0x018) {
  2382. msleep(150);
  2383. }
  2384. snd_hda_shutup_pins(codec);
  2385. }
  2386. static void alc283_init(struct hda_codec *codec)
  2387. {
  2388. struct alc_spec *spec = codec->spec;
  2389. hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
  2390. bool hp_pin_sense;
  2391. int val;
  2392. if (!hp_pin)
  2393. return;
  2394. hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
  2395. /* Index 0x43 Direct Drive HP AMP LPM Control 1 */
  2396. /* Headphone capless set to high power mode */
  2397. alc_write_coef_idx(codec, 0x43, 0x9004);
  2398. snd_hda_codec_write(codec, hp_pin, 0,
  2399. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
  2400. if (hp_pin_sense)
  2401. msleep(85);
  2402. snd_hda_codec_write(codec, hp_pin, 0,
  2403. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  2404. if (hp_pin_sense)
  2405. msleep(85);
  2406. /* Index 0x46 Combo jack auto switch control 2 */
  2407. /* 3k pull low control for Headset jack. */
  2408. val = alc_read_coef_idx(codec, 0x46);
  2409. alc_write_coef_idx(codec, 0x46, val & ~(3 << 12));
  2410. /* Headphone capless set to normal mode */
  2411. alc_write_coef_idx(codec, 0x43, 0x9614);
  2412. }
  2413. static void alc283_shutup(struct hda_codec *codec)
  2414. {
  2415. struct alc_spec *spec = codec->spec;
  2416. hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
  2417. bool hp_pin_sense;
  2418. int val;
  2419. if (!hp_pin) {
  2420. alc269_shutup(codec);
  2421. return;
  2422. }
  2423. hp_pin_sense = snd_hda_jack_detect(codec, hp_pin);
  2424. alc_write_coef_idx(codec, 0x43, 0x9004);
  2425. snd_hda_codec_write(codec, hp_pin, 0,
  2426. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
  2427. if (hp_pin_sense)
  2428. msleep(100);
  2429. snd_hda_codec_write(codec, hp_pin, 0,
  2430. AC_VERB_SET_PIN_WIDGET_CONTROL, 0x0);
  2431. val = alc_read_coef_idx(codec, 0x46);
  2432. alc_write_coef_idx(codec, 0x46, val | (3 << 12));
  2433. if (hp_pin_sense)
  2434. msleep(100);
  2435. snd_hda_shutup_pins(codec);
  2436. alc_write_coef_idx(codec, 0x43, 0x9614);
  2437. }
  2438. static void alc5505_coef_set(struct hda_codec *codec, unsigned int index_reg,
  2439. unsigned int val)
  2440. {
  2441. snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
  2442. snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val & 0xffff); /* LSB */
  2443. snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_PROC_COEF, val >> 16); /* MSB */
  2444. }
  2445. static int alc5505_coef_get(struct hda_codec *codec, unsigned int index_reg)
  2446. {
  2447. unsigned int val;
  2448. snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_COEF_INDEX, index_reg >> 1);
  2449. val = snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
  2450. & 0xffff;
  2451. val |= snd_hda_codec_read(codec, 0x51, 0, AC_VERB_GET_PROC_COEF, 0)
  2452. << 16;
  2453. return val;
  2454. }
  2455. static void alc5505_dsp_halt(struct hda_codec *codec)
  2456. {
  2457. unsigned int val;
  2458. alc5505_coef_set(codec, 0x3000, 0x000c); /* DSP CPU stop */
  2459. alc5505_coef_set(codec, 0x880c, 0x0008); /* DDR enter self refresh */
  2460. alc5505_coef_set(codec, 0x61c0, 0x11110080); /* Clock control for PLL and CPU */
  2461. alc5505_coef_set(codec, 0x6230, 0xfc0d4011); /* Disable Input OP */
  2462. alc5505_coef_set(codec, 0x61b4, 0x040a2b03); /* Stop PLL2 */
  2463. alc5505_coef_set(codec, 0x61b0, 0x00005b17); /* Stop PLL1 */
  2464. alc5505_coef_set(codec, 0x61b8, 0x04133303); /* Stop PLL3 */
  2465. val = alc5505_coef_get(codec, 0x6220);
  2466. alc5505_coef_set(codec, 0x6220, (val | 0x3000)); /* switch Ringbuffer clock to DBUS clock */
  2467. }
  2468. static void alc5505_dsp_back_from_halt(struct hda_codec *codec)
  2469. {
  2470. alc5505_coef_set(codec, 0x61b8, 0x04133302);
  2471. alc5505_coef_set(codec, 0x61b0, 0x00005b16);
  2472. alc5505_coef_set(codec, 0x61b4, 0x040a2b02);
  2473. alc5505_coef_set(codec, 0x6230, 0xf80d4011);
  2474. alc5505_coef_set(codec, 0x6220, 0x2002010f);
  2475. alc5505_coef_set(codec, 0x880c, 0x00000004);
  2476. }
  2477. static void alc5505_dsp_init(struct hda_codec *codec)
  2478. {
  2479. unsigned int val;
  2480. alc5505_dsp_halt(codec);
  2481. alc5505_dsp_back_from_halt(codec);
  2482. alc5505_coef_set(codec, 0x61b0, 0x5b14); /* PLL1 control */
  2483. alc5505_coef_set(codec, 0x61b0, 0x5b16);
  2484. alc5505_coef_set(codec, 0x61b4, 0x04132b00); /* PLL2 control */
  2485. alc5505_coef_set(codec, 0x61b4, 0x04132b02);
  2486. alc5505_coef_set(codec, 0x61b8, 0x041f3300); /* PLL3 control*/
  2487. alc5505_coef_set(codec, 0x61b8, 0x041f3302);
  2488. snd_hda_codec_write(codec, 0x51, 0, AC_VERB_SET_CODEC_RESET, 0); /* Function reset */
  2489. alc5505_coef_set(codec, 0x61b8, 0x041b3302);
  2490. alc5505_coef_set(codec, 0x61b8, 0x04173302);
  2491. alc5505_coef_set(codec, 0x61b8, 0x04163302);
  2492. alc5505_coef_set(codec, 0x8800, 0x348b328b); /* DRAM control */
  2493. alc5505_coef_set(codec, 0x8808, 0x00020022); /* DRAM control */
  2494. alc5505_coef_set(codec, 0x8818, 0x00000400); /* DRAM control */
  2495. val = alc5505_coef_get(codec, 0x6200) >> 16; /* Read revision ID */
  2496. if (val <= 3)
  2497. alc5505_coef_set(codec, 0x6220, 0x2002010f); /* I/O PAD Configuration */
  2498. else
  2499. alc5505_coef_set(codec, 0x6220, 0x6002018f);
  2500. alc5505_coef_set(codec, 0x61ac, 0x055525f0); /**/
  2501. alc5505_coef_set(codec, 0x61c0, 0x12230080); /* Clock control */
  2502. alc5505_coef_set(codec, 0x61b4, 0x040e2b02); /* PLL2 control */
  2503. alc5505_coef_set(codec, 0x61bc, 0x010234f8); /* OSC Control */
  2504. alc5505_coef_set(codec, 0x880c, 0x00000004); /* DRAM Function control */
  2505. alc5505_coef_set(codec, 0x880c, 0x00000003);
  2506. alc5505_coef_set(codec, 0x880c, 0x00000010);
  2507. #ifdef HALT_REALTEK_ALC5505
  2508. alc5505_dsp_halt(codec);
  2509. #endif
  2510. }
  2511. #ifdef HALT_REALTEK_ALC5505
  2512. #define alc5505_dsp_suspend(codec) /* NOP */
  2513. #define alc5505_dsp_resume(codec) /* NOP */
  2514. #else
  2515. #define alc5505_dsp_suspend(codec) alc5505_dsp_halt(codec)
  2516. #define alc5505_dsp_resume(codec) alc5505_dsp_back_from_halt(codec)
  2517. #endif
  2518. #ifdef CONFIG_PM
  2519. static int alc269_suspend(struct hda_codec *codec)
  2520. {
  2521. struct alc_spec *spec = codec->spec;
  2522. if (spec->has_alc5505_dsp)
  2523. alc5505_dsp_suspend(codec);
  2524. return alc_suspend(codec);
  2525. }
  2526. static int alc269_resume(struct hda_codec *codec)
  2527. {
  2528. struct alc_spec *spec = codec->spec;
  2529. if (spec->codec_variant == ALC269_TYPE_ALC269VB)
  2530. alc269vb_toggle_power_output(codec, 0);
  2531. if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
  2532. (alc_get_coef0(codec) & 0x00ff) == 0x018) {
  2533. msleep(150);
  2534. }
  2535. codec->patch_ops.init(codec);
  2536. if (spec->codec_variant == ALC269_TYPE_ALC269VB)
  2537. alc269vb_toggle_power_output(codec, 1);
  2538. if (spec->codec_variant == ALC269_TYPE_ALC269VB &&
  2539. (alc_get_coef0(codec) & 0x00ff) == 0x017) {
  2540. msleep(200);
  2541. }
  2542. snd_hda_codec_resume_amp(codec);
  2543. snd_hda_codec_resume_cache(codec);
  2544. alc_inv_dmic_sync(codec, true);
  2545. hda_call_check_power_status(codec, 0x01);
  2546. if (spec->has_alc5505_dsp)
  2547. alc5505_dsp_resume(codec);
  2548. return 0;
  2549. }
  2550. #endif /* CONFIG_PM */
  2551. static void alc269_fixup_pincfg_no_hp_to_lineout(struct hda_codec *codec,
  2552. const struct hda_fixup *fix, int action)
  2553. {
  2554. struct alc_spec *spec = codec->spec;
  2555. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  2556. spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
  2557. }
  2558. static void alc269_fixup_hweq(struct hda_codec *codec,
  2559. const struct hda_fixup *fix, int action)
  2560. {
  2561. int coef;
  2562. if (action != HDA_FIXUP_ACT_INIT)
  2563. return;
  2564. coef = alc_read_coef_idx(codec, 0x1e);
  2565. alc_write_coef_idx(codec, 0x1e, coef | 0x80);
  2566. }
  2567. static void alc269_fixup_headset_mic(struct hda_codec *codec,
  2568. const struct hda_fixup *fix, int action)
  2569. {
  2570. struct alc_spec *spec = codec->spec;
  2571. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  2572. spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
  2573. }
  2574. static void alc271_fixup_dmic(struct hda_codec *codec,
  2575. const struct hda_fixup *fix, int action)
  2576. {
  2577. static const struct hda_verb verbs[] = {
  2578. {0x20, AC_VERB_SET_COEF_INDEX, 0x0d},
  2579. {0x20, AC_VERB_SET_PROC_COEF, 0x4000},
  2580. {}
  2581. };
  2582. unsigned int cfg;
  2583. if (strcmp(codec->chip_name, "ALC271X") &&
  2584. strcmp(codec->chip_name, "ALC269VB"))
  2585. return;
  2586. cfg = snd_hda_codec_get_pincfg(codec, 0x12);
  2587. if (get_defcfg_connect(cfg) == AC_JACK_PORT_FIXED)
  2588. snd_hda_sequence_write(codec, verbs);
  2589. }
  2590. static void alc269_fixup_pcm_44k(struct hda_codec *codec,
  2591. const struct hda_fixup *fix, int action)
  2592. {
  2593. struct alc_spec *spec = codec->spec;
  2594. if (action != HDA_FIXUP_ACT_PROBE)
  2595. return;
  2596. /* Due to a hardware problem on Lenovo Ideadpad, we need to
  2597. * fix the sample rate of analog I/O to 44.1kHz
  2598. */
  2599. spec->gen.stream_analog_playback = &alc269_44k_pcm_analog_playback;
  2600. spec->gen.stream_analog_capture = &alc269_44k_pcm_analog_capture;
  2601. }
  2602. static void alc269_fixup_stereo_dmic(struct hda_codec *codec,
  2603. const struct hda_fixup *fix, int action)
  2604. {
  2605. int coef;
  2606. if (action != HDA_FIXUP_ACT_INIT)
  2607. return;
  2608. /* The digital-mic unit sends PDM (differential signal) instead of
  2609. * the standard PCM, thus you can't record a valid mono stream as is.
  2610. * Below is a workaround specific to ALC269 to control the dmic
  2611. * signal source as mono.
  2612. */
  2613. coef = alc_read_coef_idx(codec, 0x07);
  2614. alc_write_coef_idx(codec, 0x07, coef | 0x80);
  2615. }
  2616. static void alc269_quanta_automute(struct hda_codec *codec)
  2617. {
  2618. snd_hda_gen_update_outputs(codec);
  2619. snd_hda_codec_write(codec, 0x20, 0,
  2620. AC_VERB_SET_COEF_INDEX, 0x0c);
  2621. snd_hda_codec_write(codec, 0x20, 0,
  2622. AC_VERB_SET_PROC_COEF, 0x680);
  2623. snd_hda_codec_write(codec, 0x20, 0,
  2624. AC_VERB_SET_COEF_INDEX, 0x0c);
  2625. snd_hda_codec_write(codec, 0x20, 0,
  2626. AC_VERB_SET_PROC_COEF, 0x480);
  2627. }
  2628. static void alc269_fixup_quanta_mute(struct hda_codec *codec,
  2629. const struct hda_fixup *fix, int action)
  2630. {
  2631. struct alc_spec *spec = codec->spec;
  2632. if (action != HDA_FIXUP_ACT_PROBE)
  2633. return;
  2634. spec->gen.automute_hook = alc269_quanta_automute;
  2635. }
  2636. static void alc269_x101_hp_automute_hook(struct hda_codec *codec,
  2637. struct hda_jack_tbl *jack)
  2638. {
  2639. struct alc_spec *spec = codec->spec;
  2640. int vref;
  2641. msleep(200);
  2642. snd_hda_gen_hp_automute(codec, jack);
  2643. vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
  2644. msleep(100);
  2645. snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2646. vref);
  2647. msleep(500);
  2648. snd_hda_codec_write(codec, 0x18, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2649. vref);
  2650. }
  2651. static void alc269_fixup_x101_headset_mic(struct hda_codec *codec,
  2652. const struct hda_fixup *fix, int action)
  2653. {
  2654. struct alc_spec *spec = codec->spec;
  2655. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  2656. spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
  2657. spec->gen.hp_automute_hook = alc269_x101_hp_automute_hook;
  2658. }
  2659. }
  2660. /* update mute-LED according to the speaker mute state via mic VREF pin */
  2661. static void alc269_fixup_mic_mute_hook(void *private_data, int enabled)
  2662. {
  2663. struct hda_codec *codec = private_data;
  2664. struct alc_spec *spec = codec->spec;
  2665. unsigned int pinval;
  2666. if (spec->mute_led_polarity)
  2667. enabled = !enabled;
  2668. pinval = AC_PINCTL_IN_EN |
  2669. (enabled ? AC_PINCTL_VREF_HIZ : AC_PINCTL_VREF_80);
  2670. if (spec->mute_led_nid)
  2671. snd_hda_set_pin_ctl_cache(codec, spec->mute_led_nid, pinval);
  2672. }
  2673. /* Make sure the led works even in runtime suspend */
  2674. static unsigned int led_power_filter(struct hda_codec *codec,
  2675. hda_nid_t nid,
  2676. unsigned int power_state)
  2677. {
  2678. struct alc_spec *spec = codec->spec;
  2679. if (power_state != AC_PWRST_D3 || nid != spec->mute_led_nid)
  2680. return power_state;
  2681. /* Set pin ctl again, it might have just been set to 0 */
  2682. snd_hda_set_pin_ctl(codec, nid,
  2683. snd_hda_codec_get_pin_target(codec, nid));
  2684. return AC_PWRST_D0;
  2685. }
  2686. static void alc269_fixup_hp_mute_led(struct hda_codec *codec,
  2687. const struct hda_fixup *fix, int action)
  2688. {
  2689. struct alc_spec *spec = codec->spec;
  2690. const struct dmi_device *dev = NULL;
  2691. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  2692. return;
  2693. while ((dev = dmi_find_device(DMI_DEV_TYPE_OEM_STRING, NULL, dev))) {
  2694. int pol, pin;
  2695. if (sscanf(dev->name, "HP_Mute_LED_%d_%x", &pol, &pin) != 2)
  2696. continue;
  2697. if (pin < 0x0a || pin >= 0x10)
  2698. break;
  2699. spec->mute_led_polarity = pol;
  2700. spec->mute_led_nid = pin - 0x0a + 0x18;
  2701. spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
  2702. spec->gen.vmaster_mute_enum = 1;
  2703. codec->power_filter = led_power_filter;
  2704. snd_printd("Detected mute LED for %x:%d\n", spec->mute_led_nid,
  2705. spec->mute_led_polarity);
  2706. break;
  2707. }
  2708. }
  2709. static void alc269_fixup_hp_mute_led_mic1(struct hda_codec *codec,
  2710. const struct hda_fixup *fix, int action)
  2711. {
  2712. struct alc_spec *spec = codec->spec;
  2713. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  2714. spec->mute_led_polarity = 0;
  2715. spec->mute_led_nid = 0x18;
  2716. spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
  2717. spec->gen.vmaster_mute_enum = 1;
  2718. codec->power_filter = led_power_filter;
  2719. }
  2720. }
  2721. static void alc269_fixup_hp_mute_led_mic2(struct hda_codec *codec,
  2722. const struct hda_fixup *fix, int action)
  2723. {
  2724. struct alc_spec *spec = codec->spec;
  2725. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  2726. spec->mute_led_polarity = 0;
  2727. spec->mute_led_nid = 0x19;
  2728. spec->gen.vmaster_mute.hook = alc269_fixup_mic_mute_hook;
  2729. spec->gen.vmaster_mute_enum = 1;
  2730. codec->power_filter = led_power_filter;
  2731. }
  2732. }
  2733. /* turn on/off mute LED per vmaster hook */
  2734. static void alc269_fixup_hp_gpio_mute_hook(void *private_data, int enabled)
  2735. {
  2736. struct hda_codec *codec = private_data;
  2737. struct alc_spec *spec = codec->spec;
  2738. unsigned int oldval = spec->gpio_led;
  2739. if (enabled)
  2740. spec->gpio_led &= ~0x08;
  2741. else
  2742. spec->gpio_led |= 0x08;
  2743. if (spec->gpio_led != oldval)
  2744. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
  2745. spec->gpio_led);
  2746. }
  2747. /* turn on/off mic-mute LED per capture hook */
  2748. static void alc269_fixup_hp_gpio_mic_mute_hook(struct hda_codec *codec,
  2749. struct snd_ctl_elem_value *ucontrol)
  2750. {
  2751. struct alc_spec *spec = codec->spec;
  2752. unsigned int oldval = spec->gpio_led;
  2753. if (!ucontrol)
  2754. return;
  2755. if (ucontrol->value.integer.value[0] ||
  2756. ucontrol->value.integer.value[1])
  2757. spec->gpio_led &= ~0x10;
  2758. else
  2759. spec->gpio_led |= 0x10;
  2760. if (spec->gpio_led != oldval)
  2761. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
  2762. spec->gpio_led);
  2763. }
  2764. static void alc269_fixup_hp_gpio_led(struct hda_codec *codec,
  2765. const struct hda_fixup *fix, int action)
  2766. {
  2767. struct alc_spec *spec = codec->spec;
  2768. static const struct hda_verb gpio_init[] = {
  2769. { 0x01, AC_VERB_SET_GPIO_MASK, 0x18 },
  2770. { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x18 },
  2771. {}
  2772. };
  2773. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  2774. spec->gen.vmaster_mute.hook = alc269_fixup_hp_gpio_mute_hook;
  2775. spec->gen.cap_sync_hook = alc269_fixup_hp_gpio_mic_mute_hook;
  2776. spec->gpio_led = 0;
  2777. snd_hda_add_verbs(codec, gpio_init);
  2778. }
  2779. }
  2780. static void alc_headset_mode_unplugged(struct hda_codec *codec)
  2781. {
  2782. int val;
  2783. switch (codec->vendor_id) {
  2784. case 0x10ec0283:
  2785. alc_write_coef_idx(codec, 0x1b, 0x0c0b);
  2786. alc_write_coef_idx(codec, 0x45, 0xc429);
  2787. val = alc_read_coef_idx(codec, 0x35);
  2788. alc_write_coef_idx(codec, 0x35, val & 0xbfff);
  2789. alc_write_coef_idx(codec, 0x06, 0x2104);
  2790. alc_write_coef_idx(codec, 0x1a, 0x0001);
  2791. alc_write_coef_idx(codec, 0x26, 0x0004);
  2792. alc_write_coef_idx(codec, 0x32, 0x42a3);
  2793. break;
  2794. case 0x10ec0292:
  2795. alc_write_coef_idx(codec, 0x76, 0x000e);
  2796. alc_write_coef_idx(codec, 0x6c, 0x2400);
  2797. alc_write_coef_idx(codec, 0x18, 0x7308);
  2798. alc_write_coef_idx(codec, 0x6b, 0xc429);
  2799. break;
  2800. case 0x10ec0668:
  2801. alc_write_coef_idx(codec, 0x15, 0x0d40);
  2802. alc_write_coef_idx(codec, 0xb7, 0x802b);
  2803. break;
  2804. }
  2805. snd_printdd("Headset jack set to unplugged mode.\n");
  2806. }
  2807. static void alc_headset_mode_mic_in(struct hda_codec *codec, hda_nid_t hp_pin,
  2808. hda_nid_t mic_pin)
  2809. {
  2810. int val;
  2811. switch (codec->vendor_id) {
  2812. case 0x10ec0283:
  2813. alc_write_coef_idx(codec, 0x45, 0xc429);
  2814. snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
  2815. val = alc_read_coef_idx(codec, 0x35);
  2816. alc_write_coef_idx(codec, 0x35, val | 1<<14);
  2817. alc_write_coef_idx(codec, 0x06, 0x2100);
  2818. alc_write_coef_idx(codec, 0x1a, 0x0021);
  2819. alc_write_coef_idx(codec, 0x26, 0x008c);
  2820. snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
  2821. break;
  2822. case 0x10ec0292:
  2823. snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
  2824. alc_write_coef_idx(codec, 0x19, 0xa208);
  2825. alc_write_coef_idx(codec, 0x2e, 0xacf0);
  2826. break;
  2827. case 0x10ec0668:
  2828. alc_write_coef_idx(codec, 0x11, 0x0001);
  2829. snd_hda_set_pin_ctl_cache(codec, hp_pin, 0);
  2830. alc_write_coef_idx(codec, 0xb7, 0x802b);
  2831. alc_write_coef_idx(codec, 0xb5, 0x1040);
  2832. val = alc_read_coef_idx(codec, 0xc3);
  2833. alc_write_coef_idx(codec, 0xc3, val | 1<<12);
  2834. snd_hda_set_pin_ctl_cache(codec, mic_pin, PIN_VREF50);
  2835. break;
  2836. }
  2837. snd_printdd("Headset jack set to mic-in mode.\n");
  2838. }
  2839. static void alc_headset_mode_default(struct hda_codec *codec)
  2840. {
  2841. switch (codec->vendor_id) {
  2842. case 0x10ec0283:
  2843. alc_write_coef_idx(codec, 0x06, 0x2100);
  2844. alc_write_coef_idx(codec, 0x32, 0x4ea3);
  2845. break;
  2846. case 0x10ec0292:
  2847. alc_write_coef_idx(codec, 0x76, 0x000e);
  2848. alc_write_coef_idx(codec, 0x6c, 0x2400);
  2849. alc_write_coef_idx(codec, 0x6b, 0xc429);
  2850. alc_write_coef_idx(codec, 0x18, 0x7308);
  2851. break;
  2852. case 0x10ec0668:
  2853. alc_write_coef_idx(codec, 0x11, 0x0041);
  2854. alc_write_coef_idx(codec, 0x15, 0x0d40);
  2855. alc_write_coef_idx(codec, 0xb7, 0x802b);
  2856. break;
  2857. }
  2858. snd_printdd("Headset jack set to headphone (default) mode.\n");
  2859. }
  2860. /* Iphone type */
  2861. static void alc_headset_mode_ctia(struct hda_codec *codec)
  2862. {
  2863. switch (codec->vendor_id) {
  2864. case 0x10ec0283:
  2865. alc_write_coef_idx(codec, 0x45, 0xd429);
  2866. alc_write_coef_idx(codec, 0x1b, 0x0c2b);
  2867. alc_write_coef_idx(codec, 0x32, 0x4ea3);
  2868. break;
  2869. case 0x10ec0292:
  2870. alc_write_coef_idx(codec, 0x6b, 0xd429);
  2871. alc_write_coef_idx(codec, 0x76, 0x0008);
  2872. alc_write_coef_idx(codec, 0x18, 0x7388);
  2873. break;
  2874. case 0x10ec0668:
  2875. alc_write_coef_idx(codec, 0x15, 0x0d60);
  2876. alc_write_coef_idx(codec, 0xc3, 0x0000);
  2877. break;
  2878. }
  2879. snd_printdd("Headset jack set to iPhone-style headset mode.\n");
  2880. }
  2881. /* Nokia type */
  2882. static void alc_headset_mode_omtp(struct hda_codec *codec)
  2883. {
  2884. switch (codec->vendor_id) {
  2885. case 0x10ec0283:
  2886. alc_write_coef_idx(codec, 0x45, 0xe429);
  2887. alc_write_coef_idx(codec, 0x1b, 0x0c2b);
  2888. alc_write_coef_idx(codec, 0x32, 0x4ea3);
  2889. break;
  2890. case 0x10ec0292:
  2891. alc_write_coef_idx(codec, 0x6b, 0xe429);
  2892. alc_write_coef_idx(codec, 0x76, 0x0008);
  2893. alc_write_coef_idx(codec, 0x18, 0x7388);
  2894. break;
  2895. case 0x10ec0668:
  2896. alc_write_coef_idx(codec, 0x15, 0x0d50);
  2897. alc_write_coef_idx(codec, 0xc3, 0x0000);
  2898. break;
  2899. }
  2900. snd_printdd("Headset jack set to Nokia-style headset mode.\n");
  2901. }
  2902. static void alc_determine_headset_type(struct hda_codec *codec)
  2903. {
  2904. int val;
  2905. bool is_ctia = false;
  2906. struct alc_spec *spec = codec->spec;
  2907. switch (codec->vendor_id) {
  2908. case 0x10ec0283:
  2909. alc_write_coef_idx(codec, 0x45, 0xd029);
  2910. msleep(300);
  2911. val = alc_read_coef_idx(codec, 0x46);
  2912. is_ctia = (val & 0x0070) == 0x0070;
  2913. break;
  2914. case 0x10ec0292:
  2915. alc_write_coef_idx(codec, 0x6b, 0xd429);
  2916. msleep(300);
  2917. val = alc_read_coef_idx(codec, 0x6c);
  2918. is_ctia = (val & 0x001c) == 0x001c;
  2919. break;
  2920. case 0x10ec0668:
  2921. alc_write_coef_idx(codec, 0x11, 0x0001);
  2922. alc_write_coef_idx(codec, 0xb7, 0x802b);
  2923. alc_write_coef_idx(codec, 0x15, 0x0d60);
  2924. alc_write_coef_idx(codec, 0xc3, 0x0c00);
  2925. msleep(300);
  2926. val = alc_read_coef_idx(codec, 0xbe);
  2927. is_ctia = (val & 0x1c02) == 0x1c02;
  2928. break;
  2929. }
  2930. snd_printdd("Headset jack detected iPhone-style headset: %s\n",
  2931. is_ctia ? "yes" : "no");
  2932. spec->current_headset_type = is_ctia ? ALC_HEADSET_TYPE_CTIA : ALC_HEADSET_TYPE_OMTP;
  2933. }
  2934. static void alc_update_headset_mode(struct hda_codec *codec)
  2935. {
  2936. struct alc_spec *spec = codec->spec;
  2937. hda_nid_t mux_pin = spec->gen.imux_pins[spec->gen.cur_mux[0]];
  2938. hda_nid_t hp_pin = spec->gen.autocfg.hp_pins[0];
  2939. int new_headset_mode;
  2940. if (!snd_hda_jack_detect(codec, hp_pin))
  2941. new_headset_mode = ALC_HEADSET_MODE_UNPLUGGED;
  2942. else if (mux_pin == spec->headset_mic_pin)
  2943. new_headset_mode = ALC_HEADSET_MODE_HEADSET;
  2944. else if (mux_pin == spec->headphone_mic_pin)
  2945. new_headset_mode = ALC_HEADSET_MODE_MIC;
  2946. else
  2947. new_headset_mode = ALC_HEADSET_MODE_HEADPHONE;
  2948. if (new_headset_mode == spec->current_headset_mode)
  2949. return;
  2950. switch (new_headset_mode) {
  2951. case ALC_HEADSET_MODE_UNPLUGGED:
  2952. alc_headset_mode_unplugged(codec);
  2953. spec->gen.hp_jack_present = false;
  2954. break;
  2955. case ALC_HEADSET_MODE_HEADSET:
  2956. if (spec->current_headset_type == ALC_HEADSET_TYPE_UNKNOWN)
  2957. alc_determine_headset_type(codec);
  2958. if (spec->current_headset_type == ALC_HEADSET_TYPE_CTIA)
  2959. alc_headset_mode_ctia(codec);
  2960. else if (spec->current_headset_type == ALC_HEADSET_TYPE_OMTP)
  2961. alc_headset_mode_omtp(codec);
  2962. spec->gen.hp_jack_present = true;
  2963. break;
  2964. case ALC_HEADSET_MODE_MIC:
  2965. alc_headset_mode_mic_in(codec, hp_pin, spec->headphone_mic_pin);
  2966. spec->gen.hp_jack_present = false;
  2967. break;
  2968. case ALC_HEADSET_MODE_HEADPHONE:
  2969. alc_headset_mode_default(codec);
  2970. spec->gen.hp_jack_present = true;
  2971. break;
  2972. }
  2973. if (new_headset_mode != ALC_HEADSET_MODE_MIC) {
  2974. snd_hda_set_pin_ctl_cache(codec, hp_pin,
  2975. AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
  2976. if (spec->headphone_mic_pin)
  2977. snd_hda_set_pin_ctl_cache(codec, spec->headphone_mic_pin,
  2978. PIN_VREFHIZ);
  2979. }
  2980. spec->current_headset_mode = new_headset_mode;
  2981. snd_hda_gen_update_outputs(codec);
  2982. }
  2983. static void alc_update_headset_mode_hook(struct hda_codec *codec,
  2984. struct snd_ctl_elem_value *ucontrol)
  2985. {
  2986. alc_update_headset_mode(codec);
  2987. }
  2988. static void alc_update_headset_jack_cb(struct hda_codec *codec, struct hda_jack_tbl *jack)
  2989. {
  2990. struct alc_spec *spec = codec->spec;
  2991. spec->current_headset_type = ALC_HEADSET_MODE_UNKNOWN;
  2992. snd_hda_gen_hp_automute(codec, jack);
  2993. }
  2994. static void alc_probe_headset_mode(struct hda_codec *codec)
  2995. {
  2996. int i;
  2997. struct alc_spec *spec = codec->spec;
  2998. struct auto_pin_cfg *cfg = &spec->gen.autocfg;
  2999. /* Find mic pins */
  3000. for (i = 0; i < cfg->num_inputs; i++) {
  3001. if (cfg->inputs[i].is_headset_mic && !spec->headset_mic_pin)
  3002. spec->headset_mic_pin = cfg->inputs[i].pin;
  3003. if (cfg->inputs[i].is_headphone_mic && !spec->headphone_mic_pin)
  3004. spec->headphone_mic_pin = cfg->inputs[i].pin;
  3005. }
  3006. spec->gen.cap_sync_hook = alc_update_headset_mode_hook;
  3007. spec->gen.automute_hook = alc_update_headset_mode;
  3008. spec->gen.hp_automute_hook = alc_update_headset_jack_cb;
  3009. }
  3010. static void alc_fixup_headset_mode(struct hda_codec *codec,
  3011. const struct hda_fixup *fix, int action)
  3012. {
  3013. struct alc_spec *spec = codec->spec;
  3014. switch (action) {
  3015. case HDA_FIXUP_ACT_PRE_PROBE:
  3016. spec->parse_flags |= HDA_PINCFG_HEADSET_MIC | HDA_PINCFG_HEADPHONE_MIC;
  3017. break;
  3018. case HDA_FIXUP_ACT_PROBE:
  3019. alc_probe_headset_mode(codec);
  3020. break;
  3021. case HDA_FIXUP_ACT_INIT:
  3022. spec->current_headset_mode = 0;
  3023. alc_update_headset_mode(codec);
  3024. break;
  3025. }
  3026. }
  3027. static void alc_fixup_headset_mode_no_hp_mic(struct hda_codec *codec,
  3028. const struct hda_fixup *fix, int action)
  3029. {
  3030. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  3031. struct alc_spec *spec = codec->spec;
  3032. spec->parse_flags |= HDA_PINCFG_HEADSET_MIC;
  3033. }
  3034. else
  3035. alc_fixup_headset_mode(codec, fix, action);
  3036. }
  3037. static void alc_fixup_headset_mode_alc668(struct hda_codec *codec,
  3038. const struct hda_fixup *fix, int action)
  3039. {
  3040. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  3041. int val;
  3042. alc_write_coef_idx(codec, 0xc4, 0x8000);
  3043. val = alc_read_coef_idx(codec, 0xc2);
  3044. alc_write_coef_idx(codec, 0xc2, val & 0xfe);
  3045. snd_hda_set_pin_ctl_cache(codec, 0x18, 0);
  3046. }
  3047. alc_fixup_headset_mode(codec, fix, action);
  3048. }
  3049. /* Returns the nid of the external mic input pin, or 0 if it cannot be found. */
  3050. static int find_ext_mic_pin(struct hda_codec *codec)
  3051. {
  3052. struct alc_spec *spec = codec->spec;
  3053. struct auto_pin_cfg *cfg = &spec->gen.autocfg;
  3054. hda_nid_t nid;
  3055. unsigned int defcfg;
  3056. int i;
  3057. for (i = 0; i < cfg->num_inputs; i++) {
  3058. if (cfg->inputs[i].type != AUTO_PIN_MIC)
  3059. continue;
  3060. nid = cfg->inputs[i].pin;
  3061. defcfg = snd_hda_codec_get_pincfg(codec, nid);
  3062. if (snd_hda_get_input_pin_attr(defcfg) == INPUT_PIN_ATTR_INT)
  3063. continue;
  3064. return nid;
  3065. }
  3066. return 0;
  3067. }
  3068. static void alc271_hp_gate_mic_jack(struct hda_codec *codec,
  3069. const struct hda_fixup *fix,
  3070. int action)
  3071. {
  3072. struct alc_spec *spec = codec->spec;
  3073. if (action == HDA_FIXUP_ACT_PROBE) {
  3074. int mic_pin = find_ext_mic_pin(codec);
  3075. int hp_pin = spec->gen.autocfg.hp_pins[0];
  3076. if (snd_BUG_ON(!mic_pin || !hp_pin))
  3077. return;
  3078. snd_hda_jack_set_gating_jack(codec, mic_pin, hp_pin);
  3079. }
  3080. }
  3081. static void alc269_fixup_limit_int_mic_boost(struct hda_codec *codec,
  3082. const struct hda_fixup *fix,
  3083. int action)
  3084. {
  3085. struct alc_spec *spec = codec->spec;
  3086. struct auto_pin_cfg *cfg = &spec->gen.autocfg;
  3087. int i;
  3088. /* The mic boosts on level 2 and 3 are too noisy
  3089. on the internal mic input.
  3090. Therefore limit the boost to 0 or 1. */
  3091. if (action != HDA_FIXUP_ACT_PROBE)
  3092. return;
  3093. for (i = 0; i < cfg->num_inputs; i++) {
  3094. hda_nid_t nid = cfg->inputs[i].pin;
  3095. unsigned int defcfg;
  3096. if (cfg->inputs[i].type != AUTO_PIN_MIC)
  3097. continue;
  3098. defcfg = snd_hda_codec_get_pincfg(codec, nid);
  3099. if (snd_hda_get_input_pin_attr(defcfg) != INPUT_PIN_ATTR_INT)
  3100. continue;
  3101. snd_hda_override_amp_caps(codec, nid, HDA_INPUT,
  3102. (0x00 << AC_AMPCAP_OFFSET_SHIFT) |
  3103. (0x01 << AC_AMPCAP_NUM_STEPS_SHIFT) |
  3104. (0x2f << AC_AMPCAP_STEP_SIZE_SHIFT) |
  3105. (0 << AC_AMPCAP_MUTE_SHIFT));
  3106. }
  3107. }
  3108. static void alc283_hp_automute_hook(struct hda_codec *codec,
  3109. struct hda_jack_tbl *jack)
  3110. {
  3111. struct alc_spec *spec = codec->spec;
  3112. int vref;
  3113. msleep(200);
  3114. snd_hda_gen_hp_automute(codec, jack);
  3115. vref = spec->gen.hp_jack_present ? PIN_VREF80 : 0;
  3116. msleep(600);
  3117. snd_hda_codec_write(codec, 0x19, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3118. vref);
  3119. }
  3120. static void alc283_chromebook_caps(struct hda_codec *codec)
  3121. {
  3122. snd_hda_override_wcaps(codec, 0x03, 0);
  3123. }
  3124. static void alc283_fixup_chromebook(struct hda_codec *codec,
  3125. const struct hda_fixup *fix, int action)
  3126. {
  3127. struct alc_spec *spec = codec->spec;
  3128. int val;
  3129. switch (action) {
  3130. case HDA_FIXUP_ACT_PRE_PROBE:
  3131. alc283_chromebook_caps(codec);
  3132. /* Disable AA-loopback as it causes white noise */
  3133. spec->gen.mixer_nid = 0;
  3134. spec->gen.hp_automute_hook = alc283_hp_automute_hook;
  3135. /* MIC2-VREF control */
  3136. /* Set to manual mode */
  3137. val = alc_read_coef_idx(codec, 0x06);
  3138. alc_write_coef_idx(codec, 0x06, val & ~0x000c);
  3139. /* Enable Line1 input control by verb */
  3140. val = alc_read_coef_idx(codec, 0x1a);
  3141. alc_write_coef_idx(codec, 0x1a, val | (1 << 4));
  3142. break;
  3143. }
  3144. }
  3145. /* mute tablet speaker pin (0x14) via dock plugging in addition */
  3146. static void asus_tx300_automute(struct hda_codec *codec)
  3147. {
  3148. struct alc_spec *spec = codec->spec;
  3149. snd_hda_gen_update_outputs(codec);
  3150. if (snd_hda_jack_detect(codec, 0x1b))
  3151. spec->gen.mute_bits |= (1ULL << 0x14);
  3152. }
  3153. static void alc282_fixup_asus_tx300(struct hda_codec *codec,
  3154. const struct hda_fixup *fix, int action)
  3155. {
  3156. struct alc_spec *spec = codec->spec;
  3157. /* TX300 needs to set up GPIO2 for the speaker amp */
  3158. static const struct hda_verb gpio2_verbs[] = {
  3159. { 0x01, AC_VERB_SET_GPIO_MASK, 0x04 },
  3160. { 0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04 },
  3161. { 0x01, AC_VERB_SET_GPIO_DATA, 0x04 },
  3162. {}
  3163. };
  3164. static const struct hda_pintbl dock_pins[] = {
  3165. { 0x1b, 0x21114000 }, /* dock speaker pin */
  3166. {}
  3167. };
  3168. struct snd_kcontrol *kctl;
  3169. switch (action) {
  3170. case HDA_FIXUP_ACT_PRE_PROBE:
  3171. snd_hda_add_verbs(codec, gpio2_verbs);
  3172. snd_hda_apply_pincfgs(codec, dock_pins);
  3173. spec->gen.auto_mute_via_amp = 1;
  3174. spec->gen.automute_hook = asus_tx300_automute;
  3175. snd_hda_jack_detect_enable_callback(codec, 0x1b,
  3176. HDA_GEN_HP_EVENT,
  3177. snd_hda_gen_hp_automute);
  3178. break;
  3179. case HDA_FIXUP_ACT_BUILD:
  3180. /* this is a bit tricky; give more sane names for the main
  3181. * (tablet) speaker and the dock speaker, respectively
  3182. */
  3183. kctl = snd_hda_find_mixer_ctl(codec, "Speaker Playback Switch");
  3184. if (kctl)
  3185. strcpy(kctl->id.name, "Dock Speaker Playback Switch");
  3186. kctl = snd_hda_find_mixer_ctl(codec, "Bass Speaker Playback Switch");
  3187. if (kctl)
  3188. strcpy(kctl->id.name, "Speaker Playback Switch");
  3189. break;
  3190. }
  3191. }
  3192. static void alc290_fixup_mono_speakers(struct hda_codec *codec,
  3193. const struct hda_fixup *fix, int action)
  3194. {
  3195. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  3196. /* Remove DAC node 0x03, as it seems to be
  3197. giving mono output */
  3198. snd_hda_override_wcaps(codec, 0x03, 0);
  3199. }
  3200. #if IS_ENABLED(CONFIG_THINKPAD_ACPI)
  3201. #include <linux/thinkpad_acpi.h>
  3202. static int (*led_set_func)(int, bool);
  3203. static void update_tpacpi_mute_led(void *private_data, int enabled)
  3204. {
  3205. if (led_set_func)
  3206. led_set_func(TPACPI_LED_MUTE, !enabled);
  3207. }
  3208. static void update_tpacpi_micmute_led(struct hda_codec *codec,
  3209. struct snd_ctl_elem_value *ucontrol)
  3210. {
  3211. if (!ucontrol || !led_set_func)
  3212. return;
  3213. if (strcmp("Capture Switch", ucontrol->id.name) == 0 && ucontrol->id.index == 0) {
  3214. /* TODO: How do I verify if it's a mono or stereo here? */
  3215. bool val = ucontrol->value.integer.value[0] || ucontrol->value.integer.value[1];
  3216. led_set_func(TPACPI_LED_MICMUTE, !val);
  3217. }
  3218. }
  3219. static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
  3220. const struct hda_fixup *fix, int action)
  3221. {
  3222. struct alc_spec *spec = codec->spec;
  3223. bool removefunc = false;
  3224. if (action == HDA_FIXUP_ACT_PROBE) {
  3225. if (!led_set_func)
  3226. led_set_func = symbol_request(tpacpi_led_set);
  3227. if (!led_set_func) {
  3228. snd_printk(KERN_WARNING "Failed to find thinkpad-acpi symbol tpacpi_led_set\n");
  3229. return;
  3230. }
  3231. removefunc = true;
  3232. if (led_set_func(TPACPI_LED_MUTE, false) >= 0) {
  3233. spec->gen.vmaster_mute.hook = update_tpacpi_mute_led;
  3234. removefunc = false;
  3235. }
  3236. if (led_set_func(TPACPI_LED_MICMUTE, false) >= 0) {
  3237. if (spec->gen.num_adc_nids > 1)
  3238. snd_printdd("Skipping micmute LED control due to several ADCs");
  3239. else {
  3240. spec->gen.cap_sync_hook = update_tpacpi_micmute_led;
  3241. removefunc = false;
  3242. }
  3243. }
  3244. }
  3245. if (led_set_func && (action == HDA_FIXUP_ACT_FREE || removefunc)) {
  3246. symbol_put(tpacpi_led_set);
  3247. led_set_func = NULL;
  3248. }
  3249. }
  3250. #else
  3251. static void alc_fixup_thinkpad_acpi(struct hda_codec *codec,
  3252. const struct hda_fixup *fix, int action)
  3253. {
  3254. }
  3255. #endif
  3256. enum {
  3257. ALC269_FIXUP_SONY_VAIO,
  3258. ALC275_FIXUP_SONY_VAIO_GPIO2,
  3259. ALC269_FIXUP_DELL_M101Z,
  3260. ALC269_FIXUP_SKU_IGNORE,
  3261. ALC269_FIXUP_ASUS_G73JW,
  3262. ALC269_FIXUP_LENOVO_EAPD,
  3263. ALC275_FIXUP_SONY_HWEQ,
  3264. ALC271_FIXUP_DMIC,
  3265. ALC269_FIXUP_PCM_44K,
  3266. ALC269_FIXUP_STEREO_DMIC,
  3267. ALC269_FIXUP_HEADSET_MIC,
  3268. ALC269_FIXUP_QUANTA_MUTE,
  3269. ALC269_FIXUP_LIFEBOOK,
  3270. ALC269_FIXUP_AMIC,
  3271. ALC269_FIXUP_DMIC,
  3272. ALC269VB_FIXUP_AMIC,
  3273. ALC269VB_FIXUP_DMIC,
  3274. ALC269_FIXUP_HP_MUTE_LED,
  3275. ALC269_FIXUP_HP_MUTE_LED_MIC1,
  3276. ALC269_FIXUP_HP_MUTE_LED_MIC2,
  3277. ALC269_FIXUP_HP_GPIO_LED,
  3278. ALC269_FIXUP_INV_DMIC,
  3279. ALC269_FIXUP_LENOVO_DOCK,
  3280. ALC286_FIXUP_SONY_MIC_NO_PRESENCE,
  3281. ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT,
  3282. ALC269_FIXUP_DELL1_MIC_NO_PRESENCE,
  3283. ALC269_FIXUP_DELL2_MIC_NO_PRESENCE,
  3284. ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
  3285. ALC269_FIXUP_HEADSET_MODE,
  3286. ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC,
  3287. ALC269_FIXUP_ASUS_X101_FUNC,
  3288. ALC269_FIXUP_ASUS_X101_VERB,
  3289. ALC269_FIXUP_ASUS_X101,
  3290. ALC271_FIXUP_AMIC_MIC2,
  3291. ALC271_FIXUP_HP_GATE_MIC_JACK,
  3292. ALC269_FIXUP_ACER_AC700,
  3293. ALC269_FIXUP_LIMIT_INT_MIC_BOOST,
  3294. ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED,
  3295. ALC269VB_FIXUP_ORDISSIMO_EVE2,
  3296. ALC283_FIXUP_CHROME_BOOK,
  3297. ALC282_FIXUP_ASUS_TX300,
  3298. ALC283_FIXUP_INT_MIC,
  3299. ALC290_FIXUP_MONO_SPEAKERS,
  3300. ALC269_FIXUP_THINKPAD_ACPI,
  3301. };
  3302. static const struct hda_fixup alc269_fixups[] = {
  3303. [ALC269_FIXUP_SONY_VAIO] = {
  3304. .type = HDA_FIXUP_PINCTLS,
  3305. .v.pins = (const struct hda_pintbl[]) {
  3306. {0x19, PIN_VREFGRD},
  3307. {}
  3308. }
  3309. },
  3310. [ALC275_FIXUP_SONY_VAIO_GPIO2] = {
  3311. .type = HDA_FIXUP_VERBS,
  3312. .v.verbs = (const struct hda_verb[]) {
  3313. {0x01, AC_VERB_SET_GPIO_MASK, 0x04},
  3314. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x04},
  3315. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3316. { }
  3317. },
  3318. .chained = true,
  3319. .chain_id = ALC269_FIXUP_SONY_VAIO
  3320. },
  3321. [ALC269_FIXUP_DELL_M101Z] = {
  3322. .type = HDA_FIXUP_VERBS,
  3323. .v.verbs = (const struct hda_verb[]) {
  3324. /* Enables internal speaker */
  3325. {0x20, AC_VERB_SET_COEF_INDEX, 13},
  3326. {0x20, AC_VERB_SET_PROC_COEF, 0x4040},
  3327. {}
  3328. }
  3329. },
  3330. [ALC269_FIXUP_SKU_IGNORE] = {
  3331. .type = HDA_FIXUP_FUNC,
  3332. .v.func = alc_fixup_sku_ignore,
  3333. },
  3334. [ALC269_FIXUP_ASUS_G73JW] = {
  3335. .type = HDA_FIXUP_PINS,
  3336. .v.pins = (const struct hda_pintbl[]) {
  3337. { 0x17, 0x99130111 }, /* subwoofer */
  3338. { }
  3339. }
  3340. },
  3341. [ALC269_FIXUP_LENOVO_EAPD] = {
  3342. .type = HDA_FIXUP_VERBS,
  3343. .v.verbs = (const struct hda_verb[]) {
  3344. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
  3345. {}
  3346. }
  3347. },
  3348. [ALC275_FIXUP_SONY_HWEQ] = {
  3349. .type = HDA_FIXUP_FUNC,
  3350. .v.func = alc269_fixup_hweq,
  3351. .chained = true,
  3352. .chain_id = ALC275_FIXUP_SONY_VAIO_GPIO2
  3353. },
  3354. [ALC271_FIXUP_DMIC] = {
  3355. .type = HDA_FIXUP_FUNC,
  3356. .v.func = alc271_fixup_dmic,
  3357. },
  3358. [ALC269_FIXUP_PCM_44K] = {
  3359. .type = HDA_FIXUP_FUNC,
  3360. .v.func = alc269_fixup_pcm_44k,
  3361. .chained = true,
  3362. .chain_id = ALC269_FIXUP_QUANTA_MUTE
  3363. },
  3364. [ALC269_FIXUP_STEREO_DMIC] = {
  3365. .type = HDA_FIXUP_FUNC,
  3366. .v.func = alc269_fixup_stereo_dmic,
  3367. },
  3368. [ALC269_FIXUP_HEADSET_MIC] = {
  3369. .type = HDA_FIXUP_FUNC,
  3370. .v.func = alc269_fixup_headset_mic,
  3371. },
  3372. [ALC269_FIXUP_QUANTA_MUTE] = {
  3373. .type = HDA_FIXUP_FUNC,
  3374. .v.func = alc269_fixup_quanta_mute,
  3375. },
  3376. [ALC269_FIXUP_LIFEBOOK] = {
  3377. .type = HDA_FIXUP_PINS,
  3378. .v.pins = (const struct hda_pintbl[]) {
  3379. { 0x1a, 0x2101103f }, /* dock line-out */
  3380. { 0x1b, 0x23a11040 }, /* dock mic-in */
  3381. { }
  3382. },
  3383. .chained = true,
  3384. .chain_id = ALC269_FIXUP_QUANTA_MUTE
  3385. },
  3386. [ALC269_FIXUP_AMIC] = {
  3387. .type = HDA_FIXUP_PINS,
  3388. .v.pins = (const struct hda_pintbl[]) {
  3389. { 0x14, 0x99130110 }, /* speaker */
  3390. { 0x15, 0x0121401f }, /* HP out */
  3391. { 0x18, 0x01a19c20 }, /* mic */
  3392. { 0x19, 0x99a3092f }, /* int-mic */
  3393. { }
  3394. },
  3395. },
  3396. [ALC269_FIXUP_DMIC] = {
  3397. .type = HDA_FIXUP_PINS,
  3398. .v.pins = (const struct hda_pintbl[]) {
  3399. { 0x12, 0x99a3092f }, /* int-mic */
  3400. { 0x14, 0x99130110 }, /* speaker */
  3401. { 0x15, 0x0121401f }, /* HP out */
  3402. { 0x18, 0x01a19c20 }, /* mic */
  3403. { }
  3404. },
  3405. },
  3406. [ALC269VB_FIXUP_AMIC] = {
  3407. .type = HDA_FIXUP_PINS,
  3408. .v.pins = (const struct hda_pintbl[]) {
  3409. { 0x14, 0x99130110 }, /* speaker */
  3410. { 0x18, 0x01a19c20 }, /* mic */
  3411. { 0x19, 0x99a3092f }, /* int-mic */
  3412. { 0x21, 0x0121401f }, /* HP out */
  3413. { }
  3414. },
  3415. },
  3416. [ALC269VB_FIXUP_DMIC] = {
  3417. .type = HDA_FIXUP_PINS,
  3418. .v.pins = (const struct hda_pintbl[]) {
  3419. { 0x12, 0x99a3092f }, /* int-mic */
  3420. { 0x14, 0x99130110 }, /* speaker */
  3421. { 0x18, 0x01a19c20 }, /* mic */
  3422. { 0x21, 0x0121401f }, /* HP out */
  3423. { }
  3424. },
  3425. },
  3426. [ALC269_FIXUP_HP_MUTE_LED] = {
  3427. .type = HDA_FIXUP_FUNC,
  3428. .v.func = alc269_fixup_hp_mute_led,
  3429. },
  3430. [ALC269_FIXUP_HP_MUTE_LED_MIC1] = {
  3431. .type = HDA_FIXUP_FUNC,
  3432. .v.func = alc269_fixup_hp_mute_led_mic1,
  3433. },
  3434. [ALC269_FIXUP_HP_MUTE_LED_MIC2] = {
  3435. .type = HDA_FIXUP_FUNC,
  3436. .v.func = alc269_fixup_hp_mute_led_mic2,
  3437. },
  3438. [ALC269_FIXUP_HP_GPIO_LED] = {
  3439. .type = HDA_FIXUP_FUNC,
  3440. .v.func = alc269_fixup_hp_gpio_led,
  3441. },
  3442. [ALC269_FIXUP_INV_DMIC] = {
  3443. .type = HDA_FIXUP_FUNC,
  3444. .v.func = alc_fixup_inv_dmic_0x12,
  3445. },
  3446. [ALC269_FIXUP_LENOVO_DOCK] = {
  3447. .type = HDA_FIXUP_PINS,
  3448. .v.pins = (const struct hda_pintbl[]) {
  3449. { 0x19, 0x23a11040 }, /* dock mic */
  3450. { 0x1b, 0x2121103f }, /* dock headphone */
  3451. { }
  3452. },
  3453. .chained = true,
  3454. .chain_id = ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT
  3455. },
  3456. [ALC269_FIXUP_PINCFG_NO_HP_TO_LINEOUT] = {
  3457. .type = HDA_FIXUP_FUNC,
  3458. .v.func = alc269_fixup_pincfg_no_hp_to_lineout,
  3459. },
  3460. [ALC269_FIXUP_DELL1_MIC_NO_PRESENCE] = {
  3461. .type = HDA_FIXUP_PINS,
  3462. .v.pins = (const struct hda_pintbl[]) {
  3463. { 0x19, 0x01a1913c }, /* use as headset mic, without its own jack detect */
  3464. { 0x1a, 0x01a1913d }, /* use as headphone mic, without its own jack detect */
  3465. { }
  3466. },
  3467. .chained = true,
  3468. .chain_id = ALC269_FIXUP_HEADSET_MODE
  3469. },
  3470. [ALC269_FIXUP_DELL2_MIC_NO_PRESENCE] = {
  3471. .type = HDA_FIXUP_PINS,
  3472. .v.pins = (const struct hda_pintbl[]) {
  3473. { 0x16, 0x21014020 }, /* dock line out */
  3474. { 0x19, 0x21a19030 }, /* dock mic */
  3475. { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
  3476. { }
  3477. },
  3478. .chained = true,
  3479. .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
  3480. },
  3481. [ALC269_FIXUP_DELL3_MIC_NO_PRESENCE] = {
  3482. .type = HDA_FIXUP_PINS,
  3483. .v.pins = (const struct hda_pintbl[]) {
  3484. { 0x1a, 0x01a1913c }, /* use as headset mic, without its own jack detect */
  3485. { }
  3486. },
  3487. .chained = true,
  3488. .chain_id = ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC
  3489. },
  3490. [ALC269_FIXUP_HEADSET_MODE] = {
  3491. .type = HDA_FIXUP_FUNC,
  3492. .v.func = alc_fixup_headset_mode,
  3493. },
  3494. [ALC269_FIXUP_HEADSET_MODE_NO_HP_MIC] = {
  3495. .type = HDA_FIXUP_FUNC,
  3496. .v.func = alc_fixup_headset_mode_no_hp_mic,
  3497. },
  3498. [ALC286_FIXUP_SONY_MIC_NO_PRESENCE] = {
  3499. .type = HDA_FIXUP_PINS,
  3500. .v.pins = (const struct hda_pintbl[]) {
  3501. { 0x18, 0x01a1913c }, /* use as headset mic, without its own jack detect */
  3502. { }
  3503. },
  3504. .chained = true,
  3505. .chain_id = ALC269_FIXUP_HEADSET_MIC
  3506. },
  3507. [ALC269_FIXUP_ASUS_X101_FUNC] = {
  3508. .type = HDA_FIXUP_FUNC,
  3509. .v.func = alc269_fixup_x101_headset_mic,
  3510. },
  3511. [ALC269_FIXUP_ASUS_X101_VERB] = {
  3512. .type = HDA_FIXUP_VERBS,
  3513. .v.verbs = (const struct hda_verb[]) {
  3514. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3515. {0x20, AC_VERB_SET_COEF_INDEX, 0x08},
  3516. {0x20, AC_VERB_SET_PROC_COEF, 0x0310},
  3517. { }
  3518. },
  3519. .chained = true,
  3520. .chain_id = ALC269_FIXUP_ASUS_X101_FUNC
  3521. },
  3522. [ALC269_FIXUP_ASUS_X101] = {
  3523. .type = HDA_FIXUP_PINS,
  3524. .v.pins = (const struct hda_pintbl[]) {
  3525. { 0x18, 0x04a1182c }, /* Headset mic */
  3526. { }
  3527. },
  3528. .chained = true,
  3529. .chain_id = ALC269_FIXUP_ASUS_X101_VERB
  3530. },
  3531. [ALC271_FIXUP_AMIC_MIC2] = {
  3532. .type = HDA_FIXUP_PINS,
  3533. .v.pins = (const struct hda_pintbl[]) {
  3534. { 0x14, 0x99130110 }, /* speaker */
  3535. { 0x19, 0x01a19c20 }, /* mic */
  3536. { 0x1b, 0x99a7012f }, /* int-mic */
  3537. { 0x21, 0x0121401f }, /* HP out */
  3538. { }
  3539. },
  3540. },
  3541. [ALC271_FIXUP_HP_GATE_MIC_JACK] = {
  3542. .type = HDA_FIXUP_FUNC,
  3543. .v.func = alc271_hp_gate_mic_jack,
  3544. .chained = true,
  3545. .chain_id = ALC271_FIXUP_AMIC_MIC2,
  3546. },
  3547. [ALC269_FIXUP_ACER_AC700] = {
  3548. .type = HDA_FIXUP_PINS,
  3549. .v.pins = (const struct hda_pintbl[]) {
  3550. { 0x12, 0x99a3092f }, /* int-mic */
  3551. { 0x14, 0x99130110 }, /* speaker */
  3552. { 0x18, 0x03a11c20 }, /* mic */
  3553. { 0x1e, 0x0346101e }, /* SPDIF1 */
  3554. { 0x21, 0x0321101f }, /* HP out */
  3555. { }
  3556. },
  3557. .chained = true,
  3558. .chain_id = ALC271_FIXUP_DMIC,
  3559. },
  3560. [ALC269_FIXUP_LIMIT_INT_MIC_BOOST] = {
  3561. .type = HDA_FIXUP_FUNC,
  3562. .v.func = alc269_fixup_limit_int_mic_boost,
  3563. },
  3564. [ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED] = {
  3565. .type = HDA_FIXUP_FUNC,
  3566. .v.func = alc269_fixup_limit_int_mic_boost,
  3567. .chained = true,
  3568. .chain_id = ALC269_FIXUP_HP_MUTE_LED_MIC1,
  3569. },
  3570. [ALC269VB_FIXUP_ORDISSIMO_EVE2] = {
  3571. .type = HDA_FIXUP_PINS,
  3572. .v.pins = (const struct hda_pintbl[]) {
  3573. { 0x12, 0x99a3092f }, /* int-mic */
  3574. { 0x18, 0x03a11d20 }, /* mic */
  3575. { 0x19, 0x411111f0 }, /* Unused bogus pin */
  3576. { }
  3577. },
  3578. },
  3579. [ALC283_FIXUP_CHROME_BOOK] = {
  3580. .type = HDA_FIXUP_FUNC,
  3581. .v.func = alc283_fixup_chromebook,
  3582. },
  3583. [ALC282_FIXUP_ASUS_TX300] = {
  3584. .type = HDA_FIXUP_FUNC,
  3585. .v.func = alc282_fixup_asus_tx300,
  3586. },
  3587. [ALC283_FIXUP_INT_MIC] = {
  3588. .type = HDA_FIXUP_VERBS,
  3589. .v.verbs = (const struct hda_verb[]) {
  3590. {0x20, AC_VERB_SET_COEF_INDEX, 0x1a},
  3591. {0x20, AC_VERB_SET_PROC_COEF, 0x0011},
  3592. { }
  3593. },
  3594. .chained = true,
  3595. .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
  3596. },
  3597. [ALC290_FIXUP_MONO_SPEAKERS] = {
  3598. .type = HDA_FIXUP_FUNC,
  3599. .v.func = alc290_fixup_mono_speakers,
  3600. .chained = true,
  3601. .chain_id = ALC269_FIXUP_DELL3_MIC_NO_PRESENCE,
  3602. },
  3603. [ALC269_FIXUP_THINKPAD_ACPI] = {
  3604. .type = HDA_FIXUP_FUNC,
  3605. .v.func = alc_fixup_thinkpad_acpi,
  3606. .chained = true,
  3607. .chain_id = ALC269_FIXUP_LIMIT_INT_MIC_BOOST
  3608. },
  3609. };
  3610. static const struct snd_pci_quirk alc269_fixup_tbl[] = {
  3611. SND_PCI_QUIRK(0x1025, 0x029b, "Acer 1810TZ", ALC269_FIXUP_INV_DMIC),
  3612. SND_PCI_QUIRK(0x1025, 0x0349, "Acer AOD260", ALC269_FIXUP_INV_DMIC),
  3613. SND_PCI_QUIRK(0x1025, 0x047c, "Acer AC700", ALC269_FIXUP_ACER_AC700),
  3614. SND_PCI_QUIRK(0x1025, 0x0740, "Acer AO725", ALC271_FIXUP_HP_GATE_MIC_JACK),
  3615. SND_PCI_QUIRK(0x1025, 0x0742, "Acer AO756", ALC271_FIXUP_HP_GATE_MIC_JACK),
  3616. SND_PCI_QUIRK_VENDOR(0x1025, "Acer Aspire", ALC271_FIXUP_DMIC),
  3617. SND_PCI_QUIRK(0x1028, 0x0470, "Dell M101z", ALC269_FIXUP_DELL_M101Z),
  3618. SND_PCI_QUIRK(0x1028, 0x05bd, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
  3619. SND_PCI_QUIRK(0x1028, 0x05be, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
  3620. SND_PCI_QUIRK(0x1028, 0x05c4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3621. SND_PCI_QUIRK(0x1028, 0x05c5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3622. SND_PCI_QUIRK(0x1028, 0x05c6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3623. SND_PCI_QUIRK(0x1028, 0x05c7, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3624. SND_PCI_QUIRK(0x1028, 0x05c8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3625. SND_PCI_QUIRK(0x1028, 0x05c9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3626. SND_PCI_QUIRK(0x1028, 0x05ca, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
  3627. SND_PCI_QUIRK(0x1028, 0x05cb, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
  3628. SND_PCI_QUIRK(0x1028, 0x05cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
  3629. SND_PCI_QUIRK(0x1028, 0x05cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
  3630. SND_PCI_QUIRK(0x1028, 0x05de, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
  3631. SND_PCI_QUIRK(0x1028, 0x05e0, "Dell", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
  3632. SND_PCI_QUIRK(0x1028, 0x05e9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3633. SND_PCI_QUIRK(0x1028, 0x05ea, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3634. SND_PCI_QUIRK(0x1028, 0x05eb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3635. SND_PCI_QUIRK(0x1028, 0x05ec, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3636. SND_PCI_QUIRK(0x1028, 0x05ed, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3637. SND_PCI_QUIRK(0x1028, 0x05ee, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3638. SND_PCI_QUIRK(0x1028, 0x05f3, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3639. SND_PCI_QUIRK(0x1028, 0x05f4, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3640. SND_PCI_QUIRK(0x1028, 0x05f5, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3641. SND_PCI_QUIRK(0x1028, 0x05f6, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3642. SND_PCI_QUIRK(0x1028, 0x05f8, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3643. SND_PCI_QUIRK(0x1028, 0x05f9, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3644. SND_PCI_QUIRK(0x1028, 0x05fb, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3645. SND_PCI_QUIRK(0x1028, 0x0606, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3646. SND_PCI_QUIRK(0x1028, 0x0608, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3647. SND_PCI_QUIRK(0x1028, 0x0609, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3648. SND_PCI_QUIRK(0x1028, 0x0613, "Dell", ALC269_FIXUP_DELL1_MIC_NO_PRESENCE),
  3649. SND_PCI_QUIRK(0x1028, 0x0616, "Dell Vostro 5470", ALC290_FIXUP_MONO_SPEAKERS),
  3650. SND_PCI_QUIRK(0x1028, 0x15cc, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
  3651. SND_PCI_QUIRK(0x1028, 0x15cd, "Dell X5 Precision", ALC269_FIXUP_DELL2_MIC_NO_PRESENCE),
  3652. SND_PCI_QUIRK(0x103c, 0x1586, "HP", ALC269_FIXUP_HP_MUTE_LED_MIC2),
  3653. SND_PCI_QUIRK(0x103c, 0x18e6, "HP", ALC269_FIXUP_HP_GPIO_LED),
  3654. SND_PCI_QUIRK(0x103c, 0x1973, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
  3655. SND_PCI_QUIRK(0x103c, 0x1983, "HP Pavilion", ALC269_FIXUP_HP_MUTE_LED_MIC1),
  3656. SND_PCI_QUIRK(0x103c, 0x218b, "HP", ALC269_FIXUP_LIMIT_INT_MIC_BOOST_MUTE_LED),
  3657. SND_PCI_QUIRK(0x103c, 0x21ed, "HP Falco Chromebook", ALC283_FIXUP_CHROME_BOOK),
  3658. SND_PCI_QUIRK_VENDOR(0x103c, "HP", ALC269_FIXUP_HP_MUTE_LED),
  3659. SND_PCI_QUIRK(0x1043, 0x103f, "ASUS TX300", ALC282_FIXUP_ASUS_TX300),
  3660. SND_PCI_QUIRK(0x1043, 0x106d, "Asus K53BE", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
  3661. SND_PCI_QUIRK(0x1043, 0x115d, "Asus 1015E", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
  3662. SND_PCI_QUIRK(0x1043, 0x1427, "Asus Zenbook UX31E", ALC269VB_FIXUP_DMIC),
  3663. SND_PCI_QUIRK(0x1043, 0x1517, "Asus Zenbook UX31A", ALC269VB_FIXUP_DMIC),
  3664. SND_PCI_QUIRK(0x1043, 0x16e3, "ASUS UX50", ALC269_FIXUP_STEREO_DMIC),
  3665. SND_PCI_QUIRK(0x1043, 0x1a13, "Asus G73Jw", ALC269_FIXUP_ASUS_G73JW),
  3666. SND_PCI_QUIRK(0x1043, 0x1b13, "Asus U41SV", ALC269_FIXUP_INV_DMIC),
  3667. SND_PCI_QUIRK(0x1043, 0x1c23, "Asus X55U", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
  3668. SND_PCI_QUIRK(0x1043, 0x831a, "ASUS P901", ALC269_FIXUP_STEREO_DMIC),
  3669. SND_PCI_QUIRK(0x1043, 0x834a, "ASUS S101", ALC269_FIXUP_STEREO_DMIC),
  3670. SND_PCI_QUIRK(0x1043, 0x8398, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
  3671. SND_PCI_QUIRK(0x1043, 0x83ce, "ASUS P1005", ALC269_FIXUP_STEREO_DMIC),
  3672. SND_PCI_QUIRK(0x1043, 0x8516, "ASUS X101CH", ALC269_FIXUP_ASUS_X101),
  3673. SND_PCI_QUIRK(0x104d, 0x90b6, "Sony VAIO Pro 13", ALC286_FIXUP_SONY_MIC_NO_PRESENCE),
  3674. SND_PCI_QUIRK(0x104d, 0x9073, "Sony VAIO", ALC275_FIXUP_SONY_VAIO_GPIO2),
  3675. SND_PCI_QUIRK(0x104d, 0x907b, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
  3676. SND_PCI_QUIRK(0x104d, 0x9084, "Sony VAIO", ALC275_FIXUP_SONY_HWEQ),
  3677. SND_PCI_QUIRK_VENDOR(0x104d, "Sony VAIO", ALC269_FIXUP_SONY_VAIO),
  3678. SND_PCI_QUIRK(0x10cf, 0x1475, "Lifebook", ALC269_FIXUP_LIFEBOOK),
  3679. SND_PCI_QUIRK(0x17aa, 0x20f2, "Thinkpad SL410/510", ALC269_FIXUP_SKU_IGNORE),
  3680. SND_PCI_QUIRK(0x17aa, 0x215e, "Thinkpad L512", ALC269_FIXUP_SKU_IGNORE),
  3681. SND_PCI_QUIRK(0x17aa, 0x21b8, "Thinkpad Edge 14", ALC269_FIXUP_SKU_IGNORE),
  3682. SND_PCI_QUIRK(0x17aa, 0x21ca, "Thinkpad L412", ALC269_FIXUP_SKU_IGNORE),
  3683. SND_PCI_QUIRK(0x17aa, 0x21e9, "Thinkpad Edge 15", ALC269_FIXUP_SKU_IGNORE),
  3684. SND_PCI_QUIRK(0x17aa, 0x21f6, "Thinkpad T530", ALC269_FIXUP_LENOVO_DOCK),
  3685. SND_PCI_QUIRK(0x17aa, 0x21fa, "Thinkpad X230", ALC269_FIXUP_LENOVO_DOCK),
  3686. SND_PCI_QUIRK(0x17aa, 0x21f3, "Thinkpad T430", ALC269_FIXUP_LENOVO_DOCK),
  3687. SND_PCI_QUIRK(0x17aa, 0x21fb, "Thinkpad T430s", ALC269_FIXUP_LENOVO_DOCK),
  3688. SND_PCI_QUIRK(0x17aa, 0x2203, "Thinkpad X230 Tablet", ALC269_FIXUP_LENOVO_DOCK),
  3689. SND_PCI_QUIRK(0x17aa, 0x2208, "Thinkpad T431s", ALC269_FIXUP_LENOVO_DOCK),
  3690. SND_PCI_QUIRK(0x17aa, 0x220c, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
  3691. SND_PCI_QUIRK(0x17aa, 0x2212, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
  3692. SND_PCI_QUIRK(0x17aa, 0x2214, "Thinkpad", ALC269_FIXUP_THINKPAD_ACPI),
  3693. SND_PCI_QUIRK(0x17aa, 0x2215, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
  3694. SND_PCI_QUIRK(0x17aa, 0x5013, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
  3695. SND_PCI_QUIRK(0x17aa, 0x501a, "Thinkpad", ALC283_FIXUP_INT_MIC),
  3696. SND_PCI_QUIRK(0x17aa, 0x5026, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
  3697. SND_PCI_QUIRK(0x17aa, 0x5109, "Thinkpad", ALC269_FIXUP_LIMIT_INT_MIC_BOOST),
  3698. SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_PCM_44K),
  3699. SND_PCI_QUIRK(0x17aa, 0x9e54, "LENOVO NB", ALC269_FIXUP_LENOVO_EAPD),
  3700. SND_PCI_QUIRK(0x1b7d, 0xa831, "Ordissimo EVE2 ", ALC269VB_FIXUP_ORDISSIMO_EVE2), /* Also known as Malata PC-B1303 */
  3701. #if 0
  3702. /* Below is a quirk table taken from the old code.
  3703. * Basically the device should work as is without the fixup table.
  3704. * If BIOS doesn't give a proper info, enable the corresponding
  3705. * fixup entry.
  3706. */
  3707. SND_PCI_QUIRK(0x1043, 0x8330, "ASUS Eeepc P703 P900A",
  3708. ALC269_FIXUP_AMIC),
  3709. SND_PCI_QUIRK(0x1043, 0x1013, "ASUS N61Da", ALC269_FIXUP_AMIC),
  3710. SND_PCI_QUIRK(0x1043, 0x1143, "ASUS B53f", ALC269_FIXUP_AMIC),
  3711. SND_PCI_QUIRK(0x1043, 0x1133, "ASUS UJ20ft", ALC269_FIXUP_AMIC),
  3712. SND_PCI_QUIRK(0x1043, 0x1183, "ASUS K72DR", ALC269_FIXUP_AMIC),
  3713. SND_PCI_QUIRK(0x1043, 0x11b3, "ASUS K52DR", ALC269_FIXUP_AMIC),
  3714. SND_PCI_QUIRK(0x1043, 0x11e3, "ASUS U33Jc", ALC269_FIXUP_AMIC),
  3715. SND_PCI_QUIRK(0x1043, 0x1273, "ASUS UL80Jt", ALC269_FIXUP_AMIC),
  3716. SND_PCI_QUIRK(0x1043, 0x1283, "ASUS U53Jc", ALC269_FIXUP_AMIC),
  3717. SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS N82JV", ALC269_FIXUP_AMIC),
  3718. SND_PCI_QUIRK(0x1043, 0x12d3, "ASUS N61Jv", ALC269_FIXUP_AMIC),
  3719. SND_PCI_QUIRK(0x1043, 0x13a3, "ASUS UL30Vt", ALC269_FIXUP_AMIC),
  3720. SND_PCI_QUIRK(0x1043, 0x1373, "ASUS G73JX", ALC269_FIXUP_AMIC),
  3721. SND_PCI_QUIRK(0x1043, 0x1383, "ASUS UJ30Jc", ALC269_FIXUP_AMIC),
  3722. SND_PCI_QUIRK(0x1043, 0x13d3, "ASUS N61JA", ALC269_FIXUP_AMIC),
  3723. SND_PCI_QUIRK(0x1043, 0x1413, "ASUS UL50", ALC269_FIXUP_AMIC),
  3724. SND_PCI_QUIRK(0x1043, 0x1443, "ASUS UL30", ALC269_FIXUP_AMIC),
  3725. SND_PCI_QUIRK(0x1043, 0x1453, "ASUS M60Jv", ALC269_FIXUP_AMIC),
  3726. SND_PCI_QUIRK(0x1043, 0x1483, "ASUS UL80", ALC269_FIXUP_AMIC),
  3727. SND_PCI_QUIRK(0x1043, 0x14f3, "ASUS F83Vf", ALC269_FIXUP_AMIC),
  3728. SND_PCI_QUIRK(0x1043, 0x14e3, "ASUS UL20", ALC269_FIXUP_AMIC),
  3729. SND_PCI_QUIRK(0x1043, 0x1513, "ASUS UX30", ALC269_FIXUP_AMIC),
  3730. SND_PCI_QUIRK(0x1043, 0x1593, "ASUS N51Vn", ALC269_FIXUP_AMIC),
  3731. SND_PCI_QUIRK(0x1043, 0x15a3, "ASUS N60Jv", ALC269_FIXUP_AMIC),
  3732. SND_PCI_QUIRK(0x1043, 0x15b3, "ASUS N60Dp", ALC269_FIXUP_AMIC),
  3733. SND_PCI_QUIRK(0x1043, 0x15c3, "ASUS N70De", ALC269_FIXUP_AMIC),
  3734. SND_PCI_QUIRK(0x1043, 0x15e3, "ASUS F83T", ALC269_FIXUP_AMIC),
  3735. SND_PCI_QUIRK(0x1043, 0x1643, "ASUS M60J", ALC269_FIXUP_AMIC),
  3736. SND_PCI_QUIRK(0x1043, 0x1653, "ASUS U50", ALC269_FIXUP_AMIC),
  3737. SND_PCI_QUIRK(0x1043, 0x1693, "ASUS F50N", ALC269_FIXUP_AMIC),
  3738. SND_PCI_QUIRK(0x1043, 0x16a3, "ASUS F5Q", ALC269_FIXUP_AMIC),
  3739. SND_PCI_QUIRK(0x1043, 0x1723, "ASUS P80", ALC269_FIXUP_AMIC),
  3740. SND_PCI_QUIRK(0x1043, 0x1743, "ASUS U80", ALC269_FIXUP_AMIC),
  3741. SND_PCI_QUIRK(0x1043, 0x1773, "ASUS U20A", ALC269_FIXUP_AMIC),
  3742. SND_PCI_QUIRK(0x1043, 0x1883, "ASUS F81Se", ALC269_FIXUP_AMIC),
  3743. SND_PCI_QUIRK(0x152d, 0x1778, "Quanta ON1", ALC269_FIXUP_DMIC),
  3744. SND_PCI_QUIRK(0x17aa, 0x3be9, "Quanta Wistron", ALC269_FIXUP_AMIC),
  3745. SND_PCI_QUIRK(0x17aa, 0x3bf8, "Quanta FL1", ALC269_FIXUP_AMIC),
  3746. SND_PCI_QUIRK(0x17ff, 0x059a, "Quanta EL3", ALC269_FIXUP_DMIC),
  3747. SND_PCI_QUIRK(0x17ff, 0x059b, "Quanta JR1", ALC269_FIXUP_DMIC),
  3748. #endif
  3749. {}
  3750. };
  3751. static const struct hda_model_fixup alc269_fixup_models[] = {
  3752. {.id = ALC269_FIXUP_AMIC, .name = "laptop-amic"},
  3753. {.id = ALC269_FIXUP_DMIC, .name = "laptop-dmic"},
  3754. {.id = ALC269_FIXUP_STEREO_DMIC, .name = "alc269-dmic"},
  3755. {.id = ALC271_FIXUP_DMIC, .name = "alc271-dmic"},
  3756. {.id = ALC269_FIXUP_INV_DMIC, .name = "inv-dmic"},
  3757. {.id = ALC269_FIXUP_HEADSET_MIC, .name = "headset-mic"},
  3758. {.id = ALC269_FIXUP_LENOVO_DOCK, .name = "lenovo-dock"},
  3759. {.id = ALC269_FIXUP_HP_GPIO_LED, .name = "hp-gpio-led"},
  3760. {.id = ALC269_FIXUP_DELL1_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
  3761. {.id = ALC269_FIXUP_DELL2_MIC_NO_PRESENCE, .name = "dell-headset-dock"},
  3762. {}
  3763. };
  3764. static void alc269_fill_coef(struct hda_codec *codec)
  3765. {
  3766. struct alc_spec *spec = codec->spec;
  3767. int val;
  3768. if (spec->codec_variant != ALC269_TYPE_ALC269VB)
  3769. return;
  3770. if ((alc_get_coef0(codec) & 0x00ff) < 0x015) {
  3771. alc_write_coef_idx(codec, 0xf, 0x960b);
  3772. alc_write_coef_idx(codec, 0xe, 0x8817);
  3773. }
  3774. if ((alc_get_coef0(codec) & 0x00ff) == 0x016) {
  3775. alc_write_coef_idx(codec, 0xf, 0x960b);
  3776. alc_write_coef_idx(codec, 0xe, 0x8814);
  3777. }
  3778. if ((alc_get_coef0(codec) & 0x00ff) == 0x017) {
  3779. val = alc_read_coef_idx(codec, 0x04);
  3780. /* Power up output pin */
  3781. alc_write_coef_idx(codec, 0x04, val | (1<<11));
  3782. }
  3783. if ((alc_get_coef0(codec) & 0x00ff) == 0x018) {
  3784. val = alc_read_coef_idx(codec, 0xd);
  3785. if ((val & 0x0c00) >> 10 != 0x1) {
  3786. /* Capless ramp up clock control */
  3787. alc_write_coef_idx(codec, 0xd, val | (1<<10));
  3788. }
  3789. val = alc_read_coef_idx(codec, 0x17);
  3790. if ((val & 0x01c0) >> 6 != 0x4) {
  3791. /* Class D power on reset */
  3792. alc_write_coef_idx(codec, 0x17, val | (1<<7));
  3793. }
  3794. }
  3795. val = alc_read_coef_idx(codec, 0xd); /* Class D */
  3796. alc_write_coef_idx(codec, 0xd, val | (1<<14));
  3797. val = alc_read_coef_idx(codec, 0x4); /* HP */
  3798. alc_write_coef_idx(codec, 0x4, val | (1<<11));
  3799. }
  3800. /*
  3801. */
  3802. static int patch_alc269(struct hda_codec *codec)
  3803. {
  3804. struct alc_spec *spec;
  3805. int err;
  3806. err = alc_alloc_spec(codec, 0x0b);
  3807. if (err < 0)
  3808. return err;
  3809. spec = codec->spec;
  3810. spec->gen.shared_mic_vref_pin = 0x18;
  3811. snd_hda_pick_fixup(codec, alc269_fixup_models,
  3812. alc269_fixup_tbl, alc269_fixups);
  3813. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  3814. alc_auto_parse_customize_define(codec);
  3815. if (has_cdefine_beep(codec))
  3816. spec->gen.beep_nid = 0x01;
  3817. switch (codec->vendor_id) {
  3818. case 0x10ec0269:
  3819. spec->codec_variant = ALC269_TYPE_ALC269VA;
  3820. switch (alc_get_coef0(codec) & 0x00f0) {
  3821. case 0x0010:
  3822. if (codec->bus->pci->subsystem_vendor == 0x1025 &&
  3823. spec->cdefine.platform_type == 1)
  3824. err = alc_codec_rename(codec, "ALC271X");
  3825. spec->codec_variant = ALC269_TYPE_ALC269VB;
  3826. break;
  3827. case 0x0020:
  3828. if (codec->bus->pci->subsystem_vendor == 0x17aa &&
  3829. codec->bus->pci->subsystem_device == 0x21f3)
  3830. err = alc_codec_rename(codec, "ALC3202");
  3831. spec->codec_variant = ALC269_TYPE_ALC269VC;
  3832. break;
  3833. case 0x0030:
  3834. spec->codec_variant = ALC269_TYPE_ALC269VD;
  3835. break;
  3836. default:
  3837. alc_fix_pll_init(codec, 0x20, 0x04, 15);
  3838. }
  3839. if (err < 0)
  3840. goto error;
  3841. spec->init_hook = alc269_fill_coef;
  3842. alc269_fill_coef(codec);
  3843. break;
  3844. case 0x10ec0280:
  3845. case 0x10ec0290:
  3846. spec->codec_variant = ALC269_TYPE_ALC280;
  3847. break;
  3848. case 0x10ec0282:
  3849. spec->codec_variant = ALC269_TYPE_ALC282;
  3850. break;
  3851. case 0x10ec0233:
  3852. case 0x10ec0283:
  3853. spec->codec_variant = ALC269_TYPE_ALC283;
  3854. spec->shutup = alc283_shutup;
  3855. spec->init_hook = alc283_init;
  3856. break;
  3857. case 0x10ec0284:
  3858. case 0x10ec0292:
  3859. spec->codec_variant = ALC269_TYPE_ALC284;
  3860. break;
  3861. case 0x10ec0285:
  3862. case 0x10ec0293:
  3863. spec->codec_variant = ALC269_TYPE_ALC285;
  3864. break;
  3865. case 0x10ec0286:
  3866. spec->codec_variant = ALC269_TYPE_ALC286;
  3867. break;
  3868. case 0x10ec0255:
  3869. spec->codec_variant = ALC269_TYPE_ALC255;
  3870. break;
  3871. }
  3872. if (snd_hda_codec_read(codec, 0x51, 0, AC_VERB_PARAMETERS, 0) == 0x10ec5505) {
  3873. spec->has_alc5505_dsp = true;
  3874. spec->init_hook = alc5505_dsp_init;
  3875. }
  3876. /* automatic parse from the BIOS config */
  3877. err = alc269_parse_auto_config(codec);
  3878. if (err < 0)
  3879. goto error;
  3880. if (!spec->gen.no_analog && spec->gen.beep_nid)
  3881. set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
  3882. codec->patch_ops = alc_patch_ops;
  3883. #ifdef CONFIG_PM
  3884. codec->patch_ops.suspend = alc269_suspend;
  3885. codec->patch_ops.resume = alc269_resume;
  3886. #endif
  3887. if (!spec->shutup)
  3888. spec->shutup = alc269_shutup;
  3889. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  3890. return 0;
  3891. error:
  3892. alc_free(codec);
  3893. return err;
  3894. }
  3895. /*
  3896. * ALC861
  3897. */
  3898. static int alc861_parse_auto_config(struct hda_codec *codec)
  3899. {
  3900. static const hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  3901. static const hda_nid_t alc861_ssids[] = { 0x0e, 0x0f, 0x0b, 0 };
  3902. return alc_parse_auto_config(codec, alc861_ignore, alc861_ssids);
  3903. }
  3904. /* Pin config fixes */
  3905. enum {
  3906. ALC861_FIXUP_FSC_AMILO_PI1505,
  3907. ALC861_FIXUP_AMP_VREF_0F,
  3908. ALC861_FIXUP_NO_JACK_DETECT,
  3909. ALC861_FIXUP_ASUS_A6RP,
  3910. };
  3911. /* On some laptops, VREF of pin 0x0f is abused for controlling the main amp */
  3912. static void alc861_fixup_asus_amp_vref_0f(struct hda_codec *codec,
  3913. const struct hda_fixup *fix, int action)
  3914. {
  3915. struct alc_spec *spec = codec->spec;
  3916. unsigned int val;
  3917. if (action != HDA_FIXUP_ACT_INIT)
  3918. return;
  3919. val = snd_hda_codec_get_pin_target(codec, 0x0f);
  3920. if (!(val & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN)))
  3921. val |= AC_PINCTL_IN_EN;
  3922. val |= AC_PINCTL_VREF_50;
  3923. snd_hda_set_pin_ctl(codec, 0x0f, val);
  3924. spec->gen.keep_vref_in_automute = 1;
  3925. }
  3926. /* suppress the jack-detection */
  3927. static void alc_fixup_no_jack_detect(struct hda_codec *codec,
  3928. const struct hda_fixup *fix, int action)
  3929. {
  3930. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  3931. codec->no_jack_detect = 1;
  3932. }
  3933. static const struct hda_fixup alc861_fixups[] = {
  3934. [ALC861_FIXUP_FSC_AMILO_PI1505] = {
  3935. .type = HDA_FIXUP_PINS,
  3936. .v.pins = (const struct hda_pintbl[]) {
  3937. { 0x0b, 0x0221101f }, /* HP */
  3938. { 0x0f, 0x90170310 }, /* speaker */
  3939. { }
  3940. }
  3941. },
  3942. [ALC861_FIXUP_AMP_VREF_0F] = {
  3943. .type = HDA_FIXUP_FUNC,
  3944. .v.func = alc861_fixup_asus_amp_vref_0f,
  3945. },
  3946. [ALC861_FIXUP_NO_JACK_DETECT] = {
  3947. .type = HDA_FIXUP_FUNC,
  3948. .v.func = alc_fixup_no_jack_detect,
  3949. },
  3950. [ALC861_FIXUP_ASUS_A6RP] = {
  3951. .type = HDA_FIXUP_FUNC,
  3952. .v.func = alc861_fixup_asus_amp_vref_0f,
  3953. .chained = true,
  3954. .chain_id = ALC861_FIXUP_NO_JACK_DETECT,
  3955. }
  3956. };
  3957. static const struct snd_pci_quirk alc861_fixup_tbl[] = {
  3958. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS A6Rp", ALC861_FIXUP_ASUS_A6RP),
  3959. SND_PCI_QUIRK_VENDOR(0x1043, "ASUS laptop", ALC861_FIXUP_AMP_VREF_0F),
  3960. SND_PCI_QUIRK(0x1462, 0x7254, "HP DX2200", ALC861_FIXUP_NO_JACK_DETECT),
  3961. SND_PCI_QUIRK(0x1584, 0x2b01, "Haier W18", ALC861_FIXUP_AMP_VREF_0F),
  3962. SND_PCI_QUIRK(0x1584, 0x0000, "Uniwill ECS M31EI", ALC861_FIXUP_AMP_VREF_0F),
  3963. SND_PCI_QUIRK(0x1734, 0x10c7, "FSC Amilo Pi1505", ALC861_FIXUP_FSC_AMILO_PI1505),
  3964. {}
  3965. };
  3966. /*
  3967. */
  3968. static int patch_alc861(struct hda_codec *codec)
  3969. {
  3970. struct alc_spec *spec;
  3971. int err;
  3972. err = alc_alloc_spec(codec, 0x15);
  3973. if (err < 0)
  3974. return err;
  3975. spec = codec->spec;
  3976. spec->gen.beep_nid = 0x23;
  3977. snd_hda_pick_fixup(codec, NULL, alc861_fixup_tbl, alc861_fixups);
  3978. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  3979. /* automatic parse from the BIOS config */
  3980. err = alc861_parse_auto_config(codec);
  3981. if (err < 0)
  3982. goto error;
  3983. if (!spec->gen.no_analog)
  3984. set_beep_amp(spec, 0x23, 0, HDA_OUTPUT);
  3985. codec->patch_ops = alc_patch_ops;
  3986. #ifdef CONFIG_PM
  3987. spec->power_hook = alc_power_eapd;
  3988. #endif
  3989. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  3990. return 0;
  3991. error:
  3992. alc_free(codec);
  3993. return err;
  3994. }
  3995. /*
  3996. * ALC861-VD support
  3997. *
  3998. * Based on ALC882
  3999. *
  4000. * In addition, an independent DAC
  4001. */
  4002. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  4003. {
  4004. static const hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  4005. static const hda_nid_t alc861vd_ssids[] = { 0x15, 0x1b, 0x14, 0 };
  4006. return alc_parse_auto_config(codec, alc861vd_ignore, alc861vd_ssids);
  4007. }
  4008. enum {
  4009. ALC660VD_FIX_ASUS_GPIO1,
  4010. ALC861VD_FIX_DALLAS,
  4011. };
  4012. /* exclude VREF80 */
  4013. static void alc861vd_fixup_dallas(struct hda_codec *codec,
  4014. const struct hda_fixup *fix, int action)
  4015. {
  4016. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  4017. snd_hda_override_pin_caps(codec, 0x18, 0x00000734);
  4018. snd_hda_override_pin_caps(codec, 0x19, 0x0000073c);
  4019. }
  4020. }
  4021. static const struct hda_fixup alc861vd_fixups[] = {
  4022. [ALC660VD_FIX_ASUS_GPIO1] = {
  4023. .type = HDA_FIXUP_VERBS,
  4024. .v.verbs = (const struct hda_verb[]) {
  4025. /* reset GPIO1 */
  4026. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4027. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  4028. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  4029. { }
  4030. }
  4031. },
  4032. [ALC861VD_FIX_DALLAS] = {
  4033. .type = HDA_FIXUP_FUNC,
  4034. .v.func = alc861vd_fixup_dallas,
  4035. },
  4036. };
  4037. static const struct snd_pci_quirk alc861vd_fixup_tbl[] = {
  4038. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_FIX_DALLAS),
  4039. SND_PCI_QUIRK(0x1043, 0x1339, "ASUS A7-K", ALC660VD_FIX_ASUS_GPIO1),
  4040. SND_PCI_QUIRK(0x1179, 0xff31, "Toshiba L30-149", ALC861VD_FIX_DALLAS),
  4041. {}
  4042. };
  4043. /*
  4044. */
  4045. static int patch_alc861vd(struct hda_codec *codec)
  4046. {
  4047. struct alc_spec *spec;
  4048. int err;
  4049. err = alc_alloc_spec(codec, 0x0b);
  4050. if (err < 0)
  4051. return err;
  4052. spec = codec->spec;
  4053. spec->gen.beep_nid = 0x23;
  4054. snd_hda_pick_fixup(codec, NULL, alc861vd_fixup_tbl, alc861vd_fixups);
  4055. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  4056. /* automatic parse from the BIOS config */
  4057. err = alc861vd_parse_auto_config(codec);
  4058. if (err < 0)
  4059. goto error;
  4060. if (!spec->gen.no_analog)
  4061. set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
  4062. codec->patch_ops = alc_patch_ops;
  4063. spec->shutup = alc_eapd_shutup;
  4064. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  4065. return 0;
  4066. error:
  4067. alc_free(codec);
  4068. return err;
  4069. }
  4070. /*
  4071. * ALC662 support
  4072. *
  4073. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  4074. * configuration. Each pin widget can choose any input DACs and a mixer.
  4075. * Each ADC is connected from a mixer of all inputs. This makes possible
  4076. * 6-channel independent captures.
  4077. *
  4078. * In addition, an independent DAC for the multi-playback (not used in this
  4079. * driver yet).
  4080. */
  4081. /*
  4082. * BIOS auto configuration
  4083. */
  4084. static int alc662_parse_auto_config(struct hda_codec *codec)
  4085. {
  4086. static const hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  4087. static const hda_nid_t alc663_ssids[] = { 0x15, 0x1b, 0x14, 0x21 };
  4088. static const hda_nid_t alc662_ssids[] = { 0x15, 0x1b, 0x14, 0 };
  4089. const hda_nid_t *ssids;
  4090. if (codec->vendor_id == 0x10ec0272 || codec->vendor_id == 0x10ec0663 ||
  4091. codec->vendor_id == 0x10ec0665 || codec->vendor_id == 0x10ec0670 ||
  4092. codec->vendor_id == 0x10ec0671)
  4093. ssids = alc663_ssids;
  4094. else
  4095. ssids = alc662_ssids;
  4096. return alc_parse_auto_config(codec, alc662_ignore, ssids);
  4097. }
  4098. static void alc272_fixup_mario(struct hda_codec *codec,
  4099. const struct hda_fixup *fix, int action)
  4100. {
  4101. if (action != HDA_FIXUP_ACT_PRE_PROBE)
  4102. return;
  4103. if (snd_hda_override_amp_caps(codec, 0x2, HDA_OUTPUT,
  4104. (0x3b << AC_AMPCAP_OFFSET_SHIFT) |
  4105. (0x3b << AC_AMPCAP_NUM_STEPS_SHIFT) |
  4106. (0x03 << AC_AMPCAP_STEP_SIZE_SHIFT) |
  4107. (0 << AC_AMPCAP_MUTE_SHIFT)))
  4108. printk(KERN_WARNING
  4109. "hda_codec: failed to override amp caps for NID 0x2\n");
  4110. }
  4111. static const struct snd_pcm_chmap_elem asus_pcm_2_1_chmaps[] = {
  4112. { .channels = 2,
  4113. .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR } },
  4114. { .channels = 4,
  4115. .map = { SNDRV_CHMAP_FL, SNDRV_CHMAP_FR,
  4116. SNDRV_CHMAP_NA, SNDRV_CHMAP_LFE } }, /* LFE only on right */
  4117. { }
  4118. };
  4119. /* override the 2.1 chmap */
  4120. static void alc662_fixup_bass_chmap(struct hda_codec *codec,
  4121. const struct hda_fixup *fix, int action)
  4122. {
  4123. if (action == HDA_FIXUP_ACT_BUILD) {
  4124. struct alc_spec *spec = codec->spec;
  4125. spec->gen.pcm_rec[0].stream[0].chmap = asus_pcm_2_1_chmaps;
  4126. }
  4127. }
  4128. enum {
  4129. ALC662_FIXUP_ASPIRE,
  4130. ALC662_FIXUP_IDEAPAD,
  4131. ALC272_FIXUP_MARIO,
  4132. ALC662_FIXUP_CZC_P10T,
  4133. ALC662_FIXUP_SKU_IGNORE,
  4134. ALC662_FIXUP_HP_RP5800,
  4135. ALC662_FIXUP_ASUS_MODE1,
  4136. ALC662_FIXUP_ASUS_MODE2,
  4137. ALC662_FIXUP_ASUS_MODE3,
  4138. ALC662_FIXUP_ASUS_MODE4,
  4139. ALC662_FIXUP_ASUS_MODE5,
  4140. ALC662_FIXUP_ASUS_MODE6,
  4141. ALC662_FIXUP_ASUS_MODE7,
  4142. ALC662_FIXUP_ASUS_MODE8,
  4143. ALC662_FIXUP_NO_JACK_DETECT,
  4144. ALC662_FIXUP_ZOTAC_Z68,
  4145. ALC662_FIXUP_INV_DMIC,
  4146. ALC668_FIXUP_DELL_MIC_NO_PRESENCE,
  4147. ALC668_FIXUP_HEADSET_MODE,
  4148. ALC662_FIXUP_BASS_CHMAP,
  4149. };
  4150. static const struct hda_fixup alc662_fixups[] = {
  4151. [ALC662_FIXUP_ASPIRE] = {
  4152. .type = HDA_FIXUP_PINS,
  4153. .v.pins = (const struct hda_pintbl[]) {
  4154. { 0x15, 0x99130112 }, /* subwoofer */
  4155. { }
  4156. }
  4157. },
  4158. [ALC662_FIXUP_IDEAPAD] = {
  4159. .type = HDA_FIXUP_PINS,
  4160. .v.pins = (const struct hda_pintbl[]) {
  4161. { 0x17, 0x99130112 }, /* subwoofer */
  4162. { }
  4163. }
  4164. },
  4165. [ALC272_FIXUP_MARIO] = {
  4166. .type = HDA_FIXUP_FUNC,
  4167. .v.func = alc272_fixup_mario,
  4168. },
  4169. [ALC662_FIXUP_CZC_P10T] = {
  4170. .type = HDA_FIXUP_VERBS,
  4171. .v.verbs = (const struct hda_verb[]) {
  4172. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 0},
  4173. {}
  4174. }
  4175. },
  4176. [ALC662_FIXUP_SKU_IGNORE] = {
  4177. .type = HDA_FIXUP_FUNC,
  4178. .v.func = alc_fixup_sku_ignore,
  4179. },
  4180. [ALC662_FIXUP_HP_RP5800] = {
  4181. .type = HDA_FIXUP_PINS,
  4182. .v.pins = (const struct hda_pintbl[]) {
  4183. { 0x14, 0x0221201f }, /* HP out */
  4184. { }
  4185. },
  4186. .chained = true,
  4187. .chain_id = ALC662_FIXUP_SKU_IGNORE
  4188. },
  4189. [ALC662_FIXUP_ASUS_MODE1] = {
  4190. .type = HDA_FIXUP_PINS,
  4191. .v.pins = (const struct hda_pintbl[]) {
  4192. { 0x14, 0x99130110 }, /* speaker */
  4193. { 0x18, 0x01a19c20 }, /* mic */
  4194. { 0x19, 0x99a3092f }, /* int-mic */
  4195. { 0x21, 0x0121401f }, /* HP out */
  4196. { }
  4197. },
  4198. .chained = true,
  4199. .chain_id = ALC662_FIXUP_SKU_IGNORE
  4200. },
  4201. [ALC662_FIXUP_ASUS_MODE2] = {
  4202. .type = HDA_FIXUP_PINS,
  4203. .v.pins = (const struct hda_pintbl[]) {
  4204. { 0x14, 0x99130110 }, /* speaker */
  4205. { 0x18, 0x01a19820 }, /* mic */
  4206. { 0x19, 0x99a3092f }, /* int-mic */
  4207. { 0x1b, 0x0121401f }, /* HP out */
  4208. { }
  4209. },
  4210. .chained = true,
  4211. .chain_id = ALC662_FIXUP_SKU_IGNORE
  4212. },
  4213. [ALC662_FIXUP_ASUS_MODE3] = {
  4214. .type = HDA_FIXUP_PINS,
  4215. .v.pins = (const struct hda_pintbl[]) {
  4216. { 0x14, 0x99130110 }, /* speaker */
  4217. { 0x15, 0x0121441f }, /* HP */
  4218. { 0x18, 0x01a19840 }, /* mic */
  4219. { 0x19, 0x99a3094f }, /* int-mic */
  4220. { 0x21, 0x01211420 }, /* HP2 */
  4221. { }
  4222. },
  4223. .chained = true,
  4224. .chain_id = ALC662_FIXUP_SKU_IGNORE
  4225. },
  4226. [ALC662_FIXUP_ASUS_MODE4] = {
  4227. .type = HDA_FIXUP_PINS,
  4228. .v.pins = (const struct hda_pintbl[]) {
  4229. { 0x14, 0x99130110 }, /* speaker */
  4230. { 0x16, 0x99130111 }, /* speaker */
  4231. { 0x18, 0x01a19840 }, /* mic */
  4232. { 0x19, 0x99a3094f }, /* int-mic */
  4233. { 0x21, 0x0121441f }, /* HP */
  4234. { }
  4235. },
  4236. .chained = true,
  4237. .chain_id = ALC662_FIXUP_SKU_IGNORE
  4238. },
  4239. [ALC662_FIXUP_ASUS_MODE5] = {
  4240. .type = HDA_FIXUP_PINS,
  4241. .v.pins = (const struct hda_pintbl[]) {
  4242. { 0x14, 0x99130110 }, /* speaker */
  4243. { 0x15, 0x0121441f }, /* HP */
  4244. { 0x16, 0x99130111 }, /* speaker */
  4245. { 0x18, 0x01a19840 }, /* mic */
  4246. { 0x19, 0x99a3094f }, /* int-mic */
  4247. { }
  4248. },
  4249. .chained = true,
  4250. .chain_id = ALC662_FIXUP_SKU_IGNORE
  4251. },
  4252. [ALC662_FIXUP_ASUS_MODE6] = {
  4253. .type = HDA_FIXUP_PINS,
  4254. .v.pins = (const struct hda_pintbl[]) {
  4255. { 0x14, 0x99130110 }, /* speaker */
  4256. { 0x15, 0x01211420 }, /* HP2 */
  4257. { 0x18, 0x01a19840 }, /* mic */
  4258. { 0x19, 0x99a3094f }, /* int-mic */
  4259. { 0x1b, 0x0121441f }, /* HP */
  4260. { }
  4261. },
  4262. .chained = true,
  4263. .chain_id = ALC662_FIXUP_SKU_IGNORE
  4264. },
  4265. [ALC662_FIXUP_ASUS_MODE7] = {
  4266. .type = HDA_FIXUP_PINS,
  4267. .v.pins = (const struct hda_pintbl[]) {
  4268. { 0x14, 0x99130110 }, /* speaker */
  4269. { 0x17, 0x99130111 }, /* speaker */
  4270. { 0x18, 0x01a19840 }, /* mic */
  4271. { 0x19, 0x99a3094f }, /* int-mic */
  4272. { 0x1b, 0x01214020 }, /* HP */
  4273. { 0x21, 0x0121401f }, /* HP */
  4274. { }
  4275. },
  4276. .chained = true,
  4277. .chain_id = ALC662_FIXUP_SKU_IGNORE
  4278. },
  4279. [ALC662_FIXUP_ASUS_MODE8] = {
  4280. .type = HDA_FIXUP_PINS,
  4281. .v.pins = (const struct hda_pintbl[]) {
  4282. { 0x14, 0x99130110 }, /* speaker */
  4283. { 0x12, 0x99a30970 }, /* int-mic */
  4284. { 0x15, 0x01214020 }, /* HP */
  4285. { 0x17, 0x99130111 }, /* speaker */
  4286. { 0x18, 0x01a19840 }, /* mic */
  4287. { 0x21, 0x0121401f }, /* HP */
  4288. { }
  4289. },
  4290. .chained = true,
  4291. .chain_id = ALC662_FIXUP_SKU_IGNORE
  4292. },
  4293. [ALC662_FIXUP_NO_JACK_DETECT] = {
  4294. .type = HDA_FIXUP_FUNC,
  4295. .v.func = alc_fixup_no_jack_detect,
  4296. },
  4297. [ALC662_FIXUP_ZOTAC_Z68] = {
  4298. .type = HDA_FIXUP_PINS,
  4299. .v.pins = (const struct hda_pintbl[]) {
  4300. { 0x1b, 0x02214020 }, /* Front HP */
  4301. { }
  4302. }
  4303. },
  4304. [ALC662_FIXUP_INV_DMIC] = {
  4305. .type = HDA_FIXUP_FUNC,
  4306. .v.func = alc_fixup_inv_dmic_0x12,
  4307. },
  4308. [ALC668_FIXUP_DELL_MIC_NO_PRESENCE] = {
  4309. .type = HDA_FIXUP_PINS,
  4310. .v.pins = (const struct hda_pintbl[]) {
  4311. { 0x19, 0x03a1913d }, /* use as headphone mic, without its own jack detect */
  4312. { 0x1b, 0x03a1113c }, /* use as headset mic, without its own jack detect */
  4313. { }
  4314. },
  4315. .chained = true,
  4316. .chain_id = ALC668_FIXUP_HEADSET_MODE
  4317. },
  4318. [ALC668_FIXUP_HEADSET_MODE] = {
  4319. .type = HDA_FIXUP_FUNC,
  4320. .v.func = alc_fixup_headset_mode_alc668,
  4321. },
  4322. [ALC662_FIXUP_BASS_CHMAP] = {
  4323. .type = HDA_FIXUP_FUNC,
  4324. .v.func = alc662_fixup_bass_chmap,
  4325. .chained = true,
  4326. .chain_id = ALC662_FIXUP_ASUS_MODE4
  4327. },
  4328. };
  4329. static const struct snd_pci_quirk alc662_fixup_tbl[] = {
  4330. SND_PCI_QUIRK(0x1019, 0x9087, "ECS", ALC662_FIXUP_ASUS_MODE2),
  4331. SND_PCI_QUIRK(0x1025, 0x022f, "Acer Aspire One", ALC662_FIXUP_INV_DMIC),
  4332. SND_PCI_QUIRK(0x1025, 0x0308, "Acer Aspire 8942G", ALC662_FIXUP_ASPIRE),
  4333. SND_PCI_QUIRK(0x1025, 0x031c, "Gateway NV79", ALC662_FIXUP_SKU_IGNORE),
  4334. SND_PCI_QUIRK(0x1025, 0x0349, "eMachines eM250", ALC662_FIXUP_INV_DMIC),
  4335. SND_PCI_QUIRK(0x1025, 0x034a, "Gateway LT27", ALC662_FIXUP_INV_DMIC),
  4336. SND_PCI_QUIRK(0x1025, 0x038b, "Acer Aspire 8943G", ALC662_FIXUP_ASPIRE),
  4337. SND_PCI_QUIRK(0x1028, 0x05d8, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
  4338. SND_PCI_QUIRK(0x1028, 0x05db, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
  4339. SND_PCI_QUIRK(0x1028, 0x0626, "Dell", ALC668_FIXUP_DELL_MIC_NO_PRESENCE),
  4340. SND_PCI_QUIRK(0x103c, 0x1632, "HP RP5800", ALC662_FIXUP_HP_RP5800),
  4341. SND_PCI_QUIRK(0x1043, 0x1477, "ASUS N56VZ", ALC662_FIXUP_BASS_CHMAP),
  4342. SND_PCI_QUIRK(0x1043, 0x1bf3, "ASUS N76VZ", ALC662_FIXUP_BASS_CHMAP),
  4343. SND_PCI_QUIRK(0x1043, 0x8469, "ASUS mobo", ALC662_FIXUP_NO_JACK_DETECT),
  4344. SND_PCI_QUIRK(0x105b, 0x0cd6, "Foxconn", ALC662_FIXUP_ASUS_MODE2),
  4345. SND_PCI_QUIRK(0x144d, 0xc051, "Samsung R720", ALC662_FIXUP_IDEAPAD),
  4346. SND_PCI_QUIRK(0x17aa, 0x38af, "Lenovo Ideapad Y550P", ALC662_FIXUP_IDEAPAD),
  4347. SND_PCI_QUIRK(0x17aa, 0x3a0d, "Lenovo Ideapad Y550", ALC662_FIXUP_IDEAPAD),
  4348. SND_PCI_QUIRK(0x19da, 0xa130, "Zotac Z68", ALC662_FIXUP_ZOTAC_Z68),
  4349. SND_PCI_QUIRK(0x1b35, 0x2206, "CZC P10T", ALC662_FIXUP_CZC_P10T),
  4350. #if 0
  4351. /* Below is a quirk table taken from the old code.
  4352. * Basically the device should work as is without the fixup table.
  4353. * If BIOS doesn't give a proper info, enable the corresponding
  4354. * fixup entry.
  4355. */
  4356. SND_PCI_QUIRK(0x1043, 0x1000, "ASUS N50Vm", ALC662_FIXUP_ASUS_MODE1),
  4357. SND_PCI_QUIRK(0x1043, 0x1092, "ASUS NB", ALC662_FIXUP_ASUS_MODE3),
  4358. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS K73Jn", ALC662_FIXUP_ASUS_MODE1),
  4359. SND_PCI_QUIRK(0x1043, 0x11c3, "ASUS M70V", ALC662_FIXUP_ASUS_MODE3),
  4360. SND_PCI_QUIRK(0x1043, 0x11d3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
  4361. SND_PCI_QUIRK(0x1043, 0x11f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
  4362. SND_PCI_QUIRK(0x1043, 0x1203, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
  4363. SND_PCI_QUIRK(0x1043, 0x1303, "ASUS G60J", ALC662_FIXUP_ASUS_MODE1),
  4364. SND_PCI_QUIRK(0x1043, 0x1333, "ASUS G60Jx", ALC662_FIXUP_ASUS_MODE1),
  4365. SND_PCI_QUIRK(0x1043, 0x1339, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
  4366. SND_PCI_QUIRK(0x1043, 0x13e3, "ASUS N71JA", ALC662_FIXUP_ASUS_MODE7),
  4367. SND_PCI_QUIRK(0x1043, 0x1463, "ASUS N71", ALC662_FIXUP_ASUS_MODE7),
  4368. SND_PCI_QUIRK(0x1043, 0x14d3, "ASUS G72", ALC662_FIXUP_ASUS_MODE8),
  4369. SND_PCI_QUIRK(0x1043, 0x1563, "ASUS N90", ALC662_FIXUP_ASUS_MODE3),
  4370. SND_PCI_QUIRK(0x1043, 0x15d3, "ASUS N50SF F50SF", ALC662_FIXUP_ASUS_MODE1),
  4371. SND_PCI_QUIRK(0x1043, 0x16c3, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
  4372. SND_PCI_QUIRK(0x1043, 0x16f3, "ASUS K40C K50C", ALC662_FIXUP_ASUS_MODE2),
  4373. SND_PCI_QUIRK(0x1043, 0x1733, "ASUS N81De", ALC662_FIXUP_ASUS_MODE1),
  4374. SND_PCI_QUIRK(0x1043, 0x1753, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
  4375. SND_PCI_QUIRK(0x1043, 0x1763, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
  4376. SND_PCI_QUIRK(0x1043, 0x1765, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
  4377. SND_PCI_QUIRK(0x1043, 0x1783, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
  4378. SND_PCI_QUIRK(0x1043, 0x1793, "ASUS F50GX", ALC662_FIXUP_ASUS_MODE1),
  4379. SND_PCI_QUIRK(0x1043, 0x17b3, "ASUS F70SL", ALC662_FIXUP_ASUS_MODE3),
  4380. SND_PCI_QUIRK(0x1043, 0x17f3, "ASUS X58LE", ALC662_FIXUP_ASUS_MODE2),
  4381. SND_PCI_QUIRK(0x1043, 0x1813, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
  4382. SND_PCI_QUIRK(0x1043, 0x1823, "ASUS NB", ALC662_FIXUP_ASUS_MODE5),
  4383. SND_PCI_QUIRK(0x1043, 0x1833, "ASUS NB", ALC662_FIXUP_ASUS_MODE6),
  4384. SND_PCI_QUIRK(0x1043, 0x1843, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
  4385. SND_PCI_QUIRK(0x1043, 0x1853, "ASUS F50Z", ALC662_FIXUP_ASUS_MODE1),
  4386. SND_PCI_QUIRK(0x1043, 0x1864, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
  4387. SND_PCI_QUIRK(0x1043, 0x1876, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
  4388. SND_PCI_QUIRK(0x1043, 0x1893, "ASUS M50Vm", ALC662_FIXUP_ASUS_MODE3),
  4389. SND_PCI_QUIRK(0x1043, 0x1894, "ASUS X55", ALC662_FIXUP_ASUS_MODE3),
  4390. SND_PCI_QUIRK(0x1043, 0x18b3, "ASUS N80Vc", ALC662_FIXUP_ASUS_MODE1),
  4391. SND_PCI_QUIRK(0x1043, 0x18c3, "ASUS VX5", ALC662_FIXUP_ASUS_MODE1),
  4392. SND_PCI_QUIRK(0x1043, 0x18d3, "ASUS N81Te", ALC662_FIXUP_ASUS_MODE1),
  4393. SND_PCI_QUIRK(0x1043, 0x18f3, "ASUS N505Tp", ALC662_FIXUP_ASUS_MODE1),
  4394. SND_PCI_QUIRK(0x1043, 0x1903, "ASUS F5GL", ALC662_FIXUP_ASUS_MODE1),
  4395. SND_PCI_QUIRK(0x1043, 0x1913, "ASUS NB", ALC662_FIXUP_ASUS_MODE2),
  4396. SND_PCI_QUIRK(0x1043, 0x1933, "ASUS F80Q", ALC662_FIXUP_ASUS_MODE2),
  4397. SND_PCI_QUIRK(0x1043, 0x1943, "ASUS Vx3V", ALC662_FIXUP_ASUS_MODE1),
  4398. SND_PCI_QUIRK(0x1043, 0x1953, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
  4399. SND_PCI_QUIRK(0x1043, 0x1963, "ASUS X71C", ALC662_FIXUP_ASUS_MODE3),
  4400. SND_PCI_QUIRK(0x1043, 0x1983, "ASUS N5051A", ALC662_FIXUP_ASUS_MODE1),
  4401. SND_PCI_QUIRK(0x1043, 0x1993, "ASUS N20", ALC662_FIXUP_ASUS_MODE1),
  4402. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS F7Z", ALC662_FIXUP_ASUS_MODE1),
  4403. SND_PCI_QUIRK(0x1043, 0x19c3, "ASUS F5Z/F6x", ALC662_FIXUP_ASUS_MODE2),
  4404. SND_PCI_QUIRK(0x1043, 0x19e3, "ASUS NB", ALC662_FIXUP_ASUS_MODE1),
  4405. SND_PCI_QUIRK(0x1043, 0x19f3, "ASUS NB", ALC662_FIXUP_ASUS_MODE4),
  4406. #endif
  4407. {}
  4408. };
  4409. static const struct hda_model_fixup alc662_fixup_models[] = {
  4410. {.id = ALC272_FIXUP_MARIO, .name = "mario"},
  4411. {.id = ALC662_FIXUP_ASUS_MODE1, .name = "asus-mode1"},
  4412. {.id = ALC662_FIXUP_ASUS_MODE2, .name = "asus-mode2"},
  4413. {.id = ALC662_FIXUP_ASUS_MODE3, .name = "asus-mode3"},
  4414. {.id = ALC662_FIXUP_ASUS_MODE4, .name = "asus-mode4"},
  4415. {.id = ALC662_FIXUP_ASUS_MODE5, .name = "asus-mode5"},
  4416. {.id = ALC662_FIXUP_ASUS_MODE6, .name = "asus-mode6"},
  4417. {.id = ALC662_FIXUP_ASUS_MODE7, .name = "asus-mode7"},
  4418. {.id = ALC662_FIXUP_ASUS_MODE8, .name = "asus-mode8"},
  4419. {.id = ALC662_FIXUP_INV_DMIC, .name = "inv-dmic"},
  4420. {.id = ALC668_FIXUP_DELL_MIC_NO_PRESENCE, .name = "dell-headset-multi"},
  4421. {}
  4422. };
  4423. static void alc662_fill_coef(struct hda_codec *codec)
  4424. {
  4425. int val, coef;
  4426. coef = alc_get_coef0(codec);
  4427. switch (codec->vendor_id) {
  4428. case 0x10ec0662:
  4429. if ((coef & 0x00f0) == 0x0030) {
  4430. val = alc_read_coef_idx(codec, 0x4); /* EAPD Ctrl */
  4431. alc_write_coef_idx(codec, 0x4, val & ~(1<<10));
  4432. }
  4433. break;
  4434. case 0x10ec0272:
  4435. case 0x10ec0273:
  4436. case 0x10ec0663:
  4437. case 0x10ec0665:
  4438. case 0x10ec0670:
  4439. case 0x10ec0671:
  4440. case 0x10ec0672:
  4441. val = alc_read_coef_idx(codec, 0xd); /* EAPD Ctrl */
  4442. alc_write_coef_idx(codec, 0xd, val | (1<<14));
  4443. break;
  4444. }
  4445. }
  4446. /*
  4447. */
  4448. static int patch_alc662(struct hda_codec *codec)
  4449. {
  4450. struct alc_spec *spec;
  4451. int err;
  4452. err = alc_alloc_spec(codec, 0x0b);
  4453. if (err < 0)
  4454. return err;
  4455. spec = codec->spec;
  4456. /* handle multiple HPs as is */
  4457. spec->parse_flags = HDA_PINCFG_NO_HP_FIXUP;
  4458. alc_fix_pll_init(codec, 0x20, 0x04, 15);
  4459. spec->init_hook = alc662_fill_coef;
  4460. alc662_fill_coef(codec);
  4461. snd_hda_pick_fixup(codec, alc662_fixup_models,
  4462. alc662_fixup_tbl, alc662_fixups);
  4463. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  4464. alc_auto_parse_customize_define(codec);
  4465. if (has_cdefine_beep(codec))
  4466. spec->gen.beep_nid = 0x01;
  4467. if ((alc_get_coef0(codec) & (1 << 14)) &&
  4468. codec->bus->pci->subsystem_vendor == 0x1025 &&
  4469. spec->cdefine.platform_type == 1) {
  4470. err = alc_codec_rename(codec, "ALC272X");
  4471. if (err < 0)
  4472. goto error;
  4473. }
  4474. /* automatic parse from the BIOS config */
  4475. err = alc662_parse_auto_config(codec);
  4476. if (err < 0)
  4477. goto error;
  4478. if (!spec->gen.no_analog && spec->gen.beep_nid) {
  4479. switch (codec->vendor_id) {
  4480. case 0x10ec0662:
  4481. set_beep_amp(spec, 0x0b, 0x05, HDA_INPUT);
  4482. break;
  4483. case 0x10ec0272:
  4484. case 0x10ec0663:
  4485. case 0x10ec0665:
  4486. set_beep_amp(spec, 0x0b, 0x04, HDA_INPUT);
  4487. break;
  4488. case 0x10ec0273:
  4489. set_beep_amp(spec, 0x0b, 0x03, HDA_INPUT);
  4490. break;
  4491. }
  4492. }
  4493. codec->patch_ops = alc_patch_ops;
  4494. spec->shutup = alc_eapd_shutup;
  4495. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  4496. return 0;
  4497. error:
  4498. alc_free(codec);
  4499. return err;
  4500. }
  4501. /*
  4502. * ALC680 support
  4503. */
  4504. static int alc680_parse_auto_config(struct hda_codec *codec)
  4505. {
  4506. return alc_parse_auto_config(codec, NULL, NULL);
  4507. }
  4508. /*
  4509. */
  4510. static int patch_alc680(struct hda_codec *codec)
  4511. {
  4512. int err;
  4513. /* ALC680 has no aa-loopback mixer */
  4514. err = alc_alloc_spec(codec, 0);
  4515. if (err < 0)
  4516. return err;
  4517. /* automatic parse from the BIOS config */
  4518. err = alc680_parse_auto_config(codec);
  4519. if (err < 0) {
  4520. alc_free(codec);
  4521. return err;
  4522. }
  4523. codec->patch_ops = alc_patch_ops;
  4524. return 0;
  4525. }
  4526. /*
  4527. * patch entries
  4528. */
  4529. static const struct hda_codec_preset snd_hda_preset_realtek[] = {
  4530. { .id = 0x10ec0221, .name = "ALC221", .patch = patch_alc269 },
  4531. { .id = 0x10ec0233, .name = "ALC233", .patch = patch_alc269 },
  4532. { .id = 0x10ec0255, .name = "ALC255", .patch = patch_alc269 },
  4533. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  4534. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  4535. { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
  4536. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  4537. { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
  4538. { .id = 0x10ec0270, .name = "ALC270", .patch = patch_alc269 },
  4539. { .id = 0x10ec0272, .name = "ALC272", .patch = patch_alc662 },
  4540. { .id = 0x10ec0275, .name = "ALC275", .patch = patch_alc269 },
  4541. { .id = 0x10ec0276, .name = "ALC276", .patch = patch_alc269 },
  4542. { .id = 0x10ec0280, .name = "ALC280", .patch = patch_alc269 },
  4543. { .id = 0x10ec0282, .name = "ALC282", .patch = patch_alc269 },
  4544. { .id = 0x10ec0283, .name = "ALC283", .patch = patch_alc269 },
  4545. { .id = 0x10ec0284, .name = "ALC284", .patch = patch_alc269 },
  4546. { .id = 0x10ec0285, .name = "ALC285", .patch = patch_alc269 },
  4547. { .id = 0x10ec0286, .name = "ALC286", .patch = patch_alc269 },
  4548. { .id = 0x10ec0290, .name = "ALC290", .patch = patch_alc269 },
  4549. { .id = 0x10ec0292, .name = "ALC292", .patch = patch_alc269 },
  4550. { .id = 0x10ec0293, .name = "ALC293", .patch = patch_alc269 },
  4551. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  4552. .patch = patch_alc861 },
  4553. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  4554. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  4555. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  4556. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  4557. .patch = patch_alc882 },
  4558. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  4559. .patch = patch_alc662 },
  4560. { .id = 0x10ec0662, .rev = 0x100300, .name = "ALC662 rev3",
  4561. .patch = patch_alc662 },
  4562. { .id = 0x10ec0663, .name = "ALC663", .patch = patch_alc662 },
  4563. { .id = 0x10ec0665, .name = "ALC665", .patch = patch_alc662 },
  4564. { .id = 0x10ec0668, .name = "ALC668", .patch = patch_alc662 },
  4565. { .id = 0x10ec0670, .name = "ALC670", .patch = patch_alc662 },
  4566. { .id = 0x10ec0671, .name = "ALC671", .patch = patch_alc662 },
  4567. { .id = 0x10ec0680, .name = "ALC680", .patch = patch_alc680 },
  4568. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  4569. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  4570. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
  4571. { .id = 0x10ec0885, .rev = 0x100101, .name = "ALC889A",
  4572. .patch = patch_alc882 },
  4573. { .id = 0x10ec0885, .rev = 0x100103, .name = "ALC889A",
  4574. .patch = patch_alc882 },
  4575. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  4576. { .id = 0x10ec0887, .name = "ALC887", .patch = patch_alc882 },
  4577. { .id = 0x10ec0888, .rev = 0x100101, .name = "ALC1200",
  4578. .patch = patch_alc882 },
  4579. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc882 },
  4580. { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc882 },
  4581. { .id = 0x10ec0892, .name = "ALC892", .patch = patch_alc662 },
  4582. { .id = 0x10ec0899, .name = "ALC898", .patch = patch_alc882 },
  4583. { .id = 0x10ec0900, .name = "ALC1150", .patch = patch_alc882 },
  4584. {} /* terminator */
  4585. };
  4586. MODULE_ALIAS("snd-hda-codec-id:10ec*");
  4587. MODULE_LICENSE("GPL");
  4588. MODULE_DESCRIPTION("Realtek HD-audio codec");
  4589. static struct hda_codec_preset_list realtek_list = {
  4590. .preset = snd_hda_preset_realtek,
  4591. .owner = THIS_MODULE,
  4592. };
  4593. static int __init patch_realtek_init(void)
  4594. {
  4595. return snd_hda_add_codec_preset(&realtek_list);
  4596. }
  4597. static void __exit patch_realtek_exit(void)
  4598. {
  4599. snd_hda_delete_codec_preset(&realtek_list);
  4600. }
  4601. module_init(patch_realtek_init)
  4602. module_exit(patch_realtek_exit)