patch_realtek.c 129 KB

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