patch_realtek.c 109 KB

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