patch_realtek.c 143 KB

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