patch_realtek.c 134 KB

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