patch_realtek.c 153 KB

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