patch_realtek.c 110 KB

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