patch_realtek.c 110 KB

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