patch_realtek.c 111 KB

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