patch_realtek.c 133 KB

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