patch_realtek.c 127 KB

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