patch_realtek.c 134 KB

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