patch_realtek.c 112 KB

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