patch_realtek.c 112 KB

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