patch_realtek.c 151 KB

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