patch_realtek.c 109 KB

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