patch_analog.c 57 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097
  1. /*
  2. * HD audio interface patch for AD1882, AD1884, AD1981HD, AD1983, AD1984,
  3. * AD1986A, AD1988
  4. *
  5. * Copyright (c) 2005-2007 Takashi Iwai <tiwai@suse.de>
  6. *
  7. * This driver is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This driver is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  20. */
  21. #include <linux/init.h>
  22. #include <linux/slab.h>
  23. #include <linux/pci.h>
  24. #include <linux/module.h>
  25. #include <sound/core.h>
  26. #include "hda_codec.h"
  27. #include "hda_local.h"
  28. #include "hda_auto_parser.h"
  29. #include "hda_beep.h"
  30. #include "hda_jack.h"
  31. #include "hda_generic.h"
  32. #define ENABLE_AD_STATIC_QUIRKS
  33. struct ad198x_spec {
  34. struct hda_gen_spec gen;
  35. /* for auto parser */
  36. int smux_paths[4];
  37. unsigned int cur_smux;
  38. hda_nid_t eapd_nid;
  39. unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
  40. #ifdef ENABLE_AD_STATIC_QUIRKS
  41. const struct snd_kcontrol_new *mixers[6];
  42. int num_mixers;
  43. const struct hda_verb *init_verbs[6]; /* initialization verbs
  44. * don't forget NULL termination!
  45. */
  46. unsigned int num_init_verbs;
  47. /* playback */
  48. struct hda_multi_out multiout; /* playback set-up
  49. * max_channels, dacs must be set
  50. * dig_out_nid and hp_nid are optional
  51. */
  52. unsigned int cur_eapd;
  53. unsigned int need_dac_fix;
  54. /* capture */
  55. unsigned int num_adc_nids;
  56. const hda_nid_t *adc_nids;
  57. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  58. /* capture source */
  59. const struct hda_input_mux *input_mux;
  60. const hda_nid_t *capsrc_nids;
  61. unsigned int cur_mux[3];
  62. /* channel model */
  63. const struct hda_channel_mode *channel_mode;
  64. int num_channel_mode;
  65. /* PCM information */
  66. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  67. unsigned int spdif_route;
  68. unsigned int jack_present: 1;
  69. unsigned int inv_jack_detect: 1;/* inverted jack-detection */
  70. unsigned int analog_beep: 1; /* analog beep input present */
  71. unsigned int avoid_init_slave_vol:1;
  72. #ifdef CONFIG_PM
  73. struct hda_loopback_check loopback;
  74. #endif
  75. /* for virtual master */
  76. hda_nid_t vmaster_nid;
  77. const char * const *slave_vols;
  78. const char * const *slave_sws;
  79. #endif /* ENABLE_AD_STATIC_QUIRKS */
  80. };
  81. #ifdef ENABLE_AD_STATIC_QUIRKS
  82. /*
  83. * input MUX handling (common part)
  84. */
  85. static int ad198x_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  86. {
  87. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  88. struct ad198x_spec *spec = codec->spec;
  89. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  90. }
  91. static int ad198x_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  92. {
  93. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  94. struct ad198x_spec *spec = codec->spec;
  95. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  96. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  97. return 0;
  98. }
  99. static int ad198x_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  100. {
  101. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  102. struct ad198x_spec *spec = codec->spec;
  103. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  104. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  105. spec->capsrc_nids[adc_idx],
  106. &spec->cur_mux[adc_idx]);
  107. }
  108. /*
  109. * initialization (common callbacks)
  110. */
  111. static int ad198x_init(struct hda_codec *codec)
  112. {
  113. struct ad198x_spec *spec = codec->spec;
  114. int i;
  115. for (i = 0; i < spec->num_init_verbs; i++)
  116. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  117. return 0;
  118. }
  119. static const char * const ad_slave_pfxs[] = {
  120. "Front", "Surround", "Center", "LFE", "Side",
  121. "Headphone", "Mono", "Speaker", "IEC958",
  122. NULL
  123. };
  124. static const char * const ad1988_6stack_fp_slave_pfxs[] = {
  125. "Front", "Surround", "Center", "LFE", "Side", "IEC958",
  126. NULL
  127. };
  128. #endif /* ENABLE_AD_STATIC_QUIRKS */
  129. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  130. /* additional beep mixers; the actual parameters are overwritten at build */
  131. static const struct snd_kcontrol_new ad_beep_mixer[] = {
  132. HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT),
  133. HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_OUTPUT),
  134. { } /* end */
  135. };
  136. static const struct snd_kcontrol_new ad_beep2_mixer[] = {
  137. HDA_CODEC_VOLUME("Digital Beep Playback Volume", 0, 0, HDA_OUTPUT),
  138. HDA_CODEC_MUTE_BEEP("Digital Beep Playback Switch", 0, 0, HDA_OUTPUT),
  139. { } /* end */
  140. };
  141. #define set_beep_amp(spec, nid, idx, dir) \
  142. ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
  143. #else
  144. #define set_beep_amp(spec, nid, idx, dir) /* NOP */
  145. #endif
  146. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  147. static int create_beep_ctls(struct hda_codec *codec)
  148. {
  149. struct ad198x_spec *spec = codec->spec;
  150. const struct snd_kcontrol_new *knew;
  151. if (!spec->beep_amp)
  152. return 0;
  153. knew = spec->analog_beep ? ad_beep2_mixer : ad_beep_mixer;
  154. for ( ; knew->name; knew++) {
  155. int err;
  156. struct snd_kcontrol *kctl;
  157. kctl = snd_ctl_new1(knew, codec);
  158. if (!kctl)
  159. return -ENOMEM;
  160. kctl->private_value = spec->beep_amp;
  161. err = snd_hda_ctl_add(codec, 0, kctl);
  162. if (err < 0)
  163. return err;
  164. }
  165. return 0;
  166. }
  167. #else
  168. #define create_beep_ctls(codec) 0
  169. #endif
  170. #ifdef ENABLE_AD_STATIC_QUIRKS
  171. static int ad198x_build_controls(struct hda_codec *codec)
  172. {
  173. struct ad198x_spec *spec = codec->spec;
  174. struct snd_kcontrol *kctl;
  175. unsigned int i;
  176. int err;
  177. for (i = 0; i < spec->num_mixers; i++) {
  178. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  179. if (err < 0)
  180. return err;
  181. }
  182. if (spec->multiout.dig_out_nid) {
  183. err = snd_hda_create_spdif_out_ctls(codec,
  184. spec->multiout.dig_out_nid,
  185. spec->multiout.dig_out_nid);
  186. if (err < 0)
  187. return err;
  188. err = snd_hda_create_spdif_share_sw(codec,
  189. &spec->multiout);
  190. if (err < 0)
  191. return err;
  192. spec->multiout.share_spdif = 1;
  193. }
  194. if (spec->dig_in_nid) {
  195. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  196. if (err < 0)
  197. return err;
  198. }
  199. /* create beep controls if needed */
  200. err = create_beep_ctls(codec);
  201. if (err < 0)
  202. return err;
  203. /* if we have no master control, let's create it */
  204. if (!snd_hda_find_mixer_ctl(codec, "Master Playback Volume")) {
  205. unsigned int vmaster_tlv[4];
  206. snd_hda_set_vmaster_tlv(codec, spec->vmaster_nid,
  207. HDA_OUTPUT, vmaster_tlv);
  208. err = __snd_hda_add_vmaster(codec, "Master Playback Volume",
  209. vmaster_tlv,
  210. (spec->slave_vols ?
  211. spec->slave_vols : ad_slave_pfxs),
  212. "Playback Volume",
  213. !spec->avoid_init_slave_vol, NULL);
  214. if (err < 0)
  215. return err;
  216. }
  217. if (!snd_hda_find_mixer_ctl(codec, "Master Playback Switch")) {
  218. err = snd_hda_add_vmaster(codec, "Master Playback Switch",
  219. NULL,
  220. (spec->slave_sws ?
  221. spec->slave_sws : ad_slave_pfxs),
  222. "Playback Switch");
  223. if (err < 0)
  224. return err;
  225. }
  226. /* assign Capture Source enums to NID */
  227. kctl = snd_hda_find_mixer_ctl(codec, "Capture Source");
  228. if (!kctl)
  229. kctl = snd_hda_find_mixer_ctl(codec, "Input Source");
  230. for (i = 0; kctl && i < kctl->count; i++) {
  231. err = snd_hda_add_nid(codec, kctl, i, spec->capsrc_nids[i]);
  232. if (err < 0)
  233. return err;
  234. }
  235. /* assign IEC958 enums to NID */
  236. kctl = snd_hda_find_mixer_ctl(codec,
  237. SNDRV_CTL_NAME_IEC958("",PLAYBACK,NONE) "Source");
  238. if (kctl) {
  239. err = snd_hda_add_nid(codec, kctl, 0,
  240. spec->multiout.dig_out_nid);
  241. if (err < 0)
  242. return err;
  243. }
  244. return 0;
  245. }
  246. #ifdef CONFIG_PM
  247. static int ad198x_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  248. {
  249. struct ad198x_spec *spec = codec->spec;
  250. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  251. }
  252. #endif
  253. /*
  254. * Analog playback callbacks
  255. */
  256. static int ad198x_playback_pcm_open(struct hda_pcm_stream *hinfo,
  257. struct hda_codec *codec,
  258. struct snd_pcm_substream *substream)
  259. {
  260. struct ad198x_spec *spec = codec->spec;
  261. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
  262. hinfo);
  263. }
  264. static int ad198x_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  265. struct hda_codec *codec,
  266. unsigned int stream_tag,
  267. unsigned int format,
  268. struct snd_pcm_substream *substream)
  269. {
  270. struct ad198x_spec *spec = codec->spec;
  271. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
  272. format, substream);
  273. }
  274. static int ad198x_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  275. struct hda_codec *codec,
  276. struct snd_pcm_substream *substream)
  277. {
  278. struct ad198x_spec *spec = codec->spec;
  279. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  280. }
  281. /*
  282. * Digital out
  283. */
  284. static int ad198x_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  285. struct hda_codec *codec,
  286. struct snd_pcm_substream *substream)
  287. {
  288. struct ad198x_spec *spec = codec->spec;
  289. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  290. }
  291. static int ad198x_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  292. struct hda_codec *codec,
  293. struct snd_pcm_substream *substream)
  294. {
  295. struct ad198x_spec *spec = codec->spec;
  296. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  297. }
  298. static int ad198x_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  299. struct hda_codec *codec,
  300. unsigned int stream_tag,
  301. unsigned int format,
  302. struct snd_pcm_substream *substream)
  303. {
  304. struct ad198x_spec *spec = codec->spec;
  305. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
  306. format, substream);
  307. }
  308. static int ad198x_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  309. struct hda_codec *codec,
  310. struct snd_pcm_substream *substream)
  311. {
  312. struct ad198x_spec *spec = codec->spec;
  313. return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
  314. }
  315. /*
  316. * Analog capture
  317. */
  318. static int ad198x_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  319. struct hda_codec *codec,
  320. unsigned int stream_tag,
  321. unsigned int format,
  322. struct snd_pcm_substream *substream)
  323. {
  324. struct ad198x_spec *spec = codec->spec;
  325. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  326. stream_tag, 0, format);
  327. return 0;
  328. }
  329. static int ad198x_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  330. struct hda_codec *codec,
  331. struct snd_pcm_substream *substream)
  332. {
  333. struct ad198x_spec *spec = codec->spec;
  334. snd_hda_codec_cleanup_stream(codec, spec->adc_nids[substream->number]);
  335. return 0;
  336. }
  337. /*
  338. */
  339. static const struct hda_pcm_stream ad198x_pcm_analog_playback = {
  340. .substreams = 1,
  341. .channels_min = 2,
  342. .channels_max = 6, /* changed later */
  343. .nid = 0, /* fill later */
  344. .ops = {
  345. .open = ad198x_playback_pcm_open,
  346. .prepare = ad198x_playback_pcm_prepare,
  347. .cleanup = ad198x_playback_pcm_cleanup,
  348. },
  349. };
  350. static const struct hda_pcm_stream ad198x_pcm_analog_capture = {
  351. .substreams = 1,
  352. .channels_min = 2,
  353. .channels_max = 2,
  354. .nid = 0, /* fill later */
  355. .ops = {
  356. .prepare = ad198x_capture_pcm_prepare,
  357. .cleanup = ad198x_capture_pcm_cleanup
  358. },
  359. };
  360. static const struct hda_pcm_stream ad198x_pcm_digital_playback = {
  361. .substreams = 1,
  362. .channels_min = 2,
  363. .channels_max = 2,
  364. .nid = 0, /* fill later */
  365. .ops = {
  366. .open = ad198x_dig_playback_pcm_open,
  367. .close = ad198x_dig_playback_pcm_close,
  368. .prepare = ad198x_dig_playback_pcm_prepare,
  369. .cleanup = ad198x_dig_playback_pcm_cleanup
  370. },
  371. };
  372. static const struct hda_pcm_stream ad198x_pcm_digital_capture = {
  373. .substreams = 1,
  374. .channels_min = 2,
  375. .channels_max = 2,
  376. /* NID is set in alc_build_pcms */
  377. };
  378. static int ad198x_build_pcms(struct hda_codec *codec)
  379. {
  380. struct ad198x_spec *spec = codec->spec;
  381. struct hda_pcm *info = spec->pcm_rec;
  382. codec->num_pcms = 1;
  383. codec->pcm_info = info;
  384. info->name = "AD198x Analog";
  385. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_analog_playback;
  386. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->multiout.max_channels;
  387. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  388. info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_analog_capture;
  389. info->stream[SNDRV_PCM_STREAM_CAPTURE].substreams = spec->num_adc_nids;
  390. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  391. if (spec->multiout.dig_out_nid) {
  392. info++;
  393. codec->num_pcms++;
  394. codec->spdif_status_reset = 1;
  395. info->name = "AD198x Digital";
  396. info->pcm_type = HDA_PCM_TYPE_SPDIF;
  397. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = ad198x_pcm_digital_playback;
  398. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  399. if (spec->dig_in_nid) {
  400. info->stream[SNDRV_PCM_STREAM_CAPTURE] = ad198x_pcm_digital_capture;
  401. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  402. }
  403. }
  404. return 0;
  405. }
  406. #endif /* ENABLE_AD_STATIC_QUIRKS */
  407. static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front,
  408. hda_nid_t hp)
  409. {
  410. if (snd_hda_query_pin_caps(codec, front) & AC_PINCAP_EAPD)
  411. snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE,
  412. !codec->inv_eapd ? 0x00 : 0x02);
  413. if (snd_hda_query_pin_caps(codec, hp) & AC_PINCAP_EAPD)
  414. snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE,
  415. !codec->inv_eapd ? 0x00 : 0x02);
  416. }
  417. static void ad198x_power_eapd(struct hda_codec *codec)
  418. {
  419. /* We currently only handle front, HP */
  420. switch (codec->vendor_id) {
  421. case 0x11d41882:
  422. case 0x11d4882a:
  423. case 0x11d41884:
  424. case 0x11d41984:
  425. case 0x11d41883:
  426. case 0x11d4184a:
  427. case 0x11d4194a:
  428. case 0x11d4194b:
  429. case 0x11d41988:
  430. case 0x11d4198b:
  431. case 0x11d4989a:
  432. case 0x11d4989b:
  433. ad198x_power_eapd_write(codec, 0x12, 0x11);
  434. break;
  435. case 0x11d41981:
  436. case 0x11d41983:
  437. ad198x_power_eapd_write(codec, 0x05, 0x06);
  438. break;
  439. case 0x11d41986:
  440. ad198x_power_eapd_write(codec, 0x1b, 0x1a);
  441. break;
  442. }
  443. }
  444. static void ad198x_shutup(struct hda_codec *codec)
  445. {
  446. snd_hda_shutup_pins(codec);
  447. ad198x_power_eapd(codec);
  448. }
  449. static void ad198x_free(struct hda_codec *codec)
  450. {
  451. struct ad198x_spec *spec = codec->spec;
  452. if (!spec)
  453. return;
  454. snd_hda_gen_spec_free(&spec->gen);
  455. kfree(spec);
  456. snd_hda_detach_beep_device(codec);
  457. }
  458. #ifdef CONFIG_PM
  459. static int ad198x_suspend(struct hda_codec *codec)
  460. {
  461. ad198x_shutup(codec);
  462. return 0;
  463. }
  464. #endif
  465. #ifdef ENABLE_AD_STATIC_QUIRKS
  466. static const struct hda_codec_ops ad198x_patch_ops = {
  467. .build_controls = ad198x_build_controls,
  468. .build_pcms = ad198x_build_pcms,
  469. .init = ad198x_init,
  470. .free = ad198x_free,
  471. #ifdef CONFIG_PM
  472. .check_power_status = ad198x_check_power_status,
  473. .suspend = ad198x_suspend,
  474. #endif
  475. .reboot_notify = ad198x_shutup,
  476. };
  477. /*
  478. * EAPD control
  479. * the private value = nid
  480. */
  481. #define ad198x_eapd_info snd_ctl_boolean_mono_info
  482. static int ad198x_eapd_get(struct snd_kcontrol *kcontrol,
  483. struct snd_ctl_elem_value *ucontrol)
  484. {
  485. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  486. struct ad198x_spec *spec = codec->spec;
  487. if (codec->inv_eapd)
  488. ucontrol->value.integer.value[0] = ! spec->cur_eapd;
  489. else
  490. ucontrol->value.integer.value[0] = spec->cur_eapd;
  491. return 0;
  492. }
  493. static int ad198x_eapd_put(struct snd_kcontrol *kcontrol,
  494. struct snd_ctl_elem_value *ucontrol)
  495. {
  496. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  497. struct ad198x_spec *spec = codec->spec;
  498. hda_nid_t nid = kcontrol->private_value & 0xff;
  499. unsigned int eapd;
  500. eapd = !!ucontrol->value.integer.value[0];
  501. if (codec->inv_eapd)
  502. eapd = !eapd;
  503. if (eapd == spec->cur_eapd)
  504. return 0;
  505. spec->cur_eapd = eapd;
  506. snd_hda_codec_write_cache(codec, nid,
  507. 0, AC_VERB_SET_EAPD_BTLENABLE,
  508. eapd ? 0x02 : 0x00);
  509. return 1;
  510. }
  511. static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
  512. struct snd_ctl_elem_info *uinfo);
  513. static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
  514. struct snd_ctl_elem_value *ucontrol);
  515. static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
  516. struct snd_ctl_elem_value *ucontrol);
  517. #endif /* ENABLE_AD_STATIC_QUIRKS */
  518. /*
  519. * Automatic parse of I/O pins from the BIOS configuration
  520. */
  521. static int ad198x_auto_build_controls(struct hda_codec *codec)
  522. {
  523. int err;
  524. err = snd_hda_gen_build_controls(codec);
  525. if (err < 0)
  526. return err;
  527. err = create_beep_ctls(codec);
  528. if (err < 0)
  529. return err;
  530. return 0;
  531. }
  532. static const struct hda_codec_ops ad198x_auto_patch_ops = {
  533. .build_controls = ad198x_auto_build_controls,
  534. .build_pcms = snd_hda_gen_build_pcms,
  535. .init = snd_hda_gen_init,
  536. .free = snd_hda_gen_free,
  537. .unsol_event = snd_hda_jack_unsol_event,
  538. #ifdef CONFIG_PM
  539. .check_power_status = snd_hda_gen_check_power_status,
  540. .suspend = ad198x_suspend,
  541. #endif
  542. .reboot_notify = ad198x_shutup,
  543. };
  544. static int ad198x_parse_auto_config(struct hda_codec *codec)
  545. {
  546. struct ad198x_spec *spec = codec->spec;
  547. struct auto_pin_cfg *cfg = &spec->gen.autocfg;
  548. int err;
  549. codec->spdif_status_reset = 1;
  550. codec->no_trigger_sense = 1;
  551. codec->no_sticky_stream = 1;
  552. spec->gen.indep_hp = 1;
  553. err = snd_hda_parse_pin_defcfg(codec, cfg, NULL, 0);
  554. if (err < 0)
  555. return err;
  556. err = snd_hda_gen_parse_auto_config(codec, cfg);
  557. if (err < 0)
  558. return err;
  559. codec->patch_ops = ad198x_auto_patch_ops;
  560. return 0;
  561. }
  562. /*
  563. * AD1986A specific
  564. */
  565. #ifdef ENABLE_AD_STATIC_QUIRKS
  566. #define AD1986A_SPDIF_OUT 0x02
  567. #define AD1986A_FRONT_DAC 0x03
  568. #define AD1986A_SURR_DAC 0x04
  569. #define AD1986A_CLFE_DAC 0x05
  570. #define AD1986A_ADC 0x06
  571. static const hda_nid_t ad1986a_dac_nids[3] = {
  572. AD1986A_FRONT_DAC, AD1986A_SURR_DAC, AD1986A_CLFE_DAC
  573. };
  574. static const hda_nid_t ad1986a_adc_nids[1] = { AD1986A_ADC };
  575. static const hda_nid_t ad1986a_capsrc_nids[1] = { 0x12 };
  576. static const struct hda_input_mux ad1986a_capture_source = {
  577. .num_items = 7,
  578. .items = {
  579. { "Mic", 0x0 },
  580. { "CD", 0x1 },
  581. { "Aux", 0x3 },
  582. { "Line", 0x4 },
  583. { "Mix", 0x5 },
  584. { "Mono", 0x6 },
  585. { "Phone", 0x7 },
  586. },
  587. };
  588. static const struct hda_bind_ctls ad1986a_bind_pcm_vol = {
  589. .ops = &snd_hda_bind_vol,
  590. .values = {
  591. HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
  592. HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
  593. HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
  594. 0
  595. },
  596. };
  597. static const struct hda_bind_ctls ad1986a_bind_pcm_sw = {
  598. .ops = &snd_hda_bind_sw,
  599. .values = {
  600. HDA_COMPOSE_AMP_VAL(AD1986A_FRONT_DAC, 3, 0, HDA_OUTPUT),
  601. HDA_COMPOSE_AMP_VAL(AD1986A_SURR_DAC, 3, 0, HDA_OUTPUT),
  602. HDA_COMPOSE_AMP_VAL(AD1986A_CLFE_DAC, 3, 0, HDA_OUTPUT),
  603. 0
  604. },
  605. };
  606. /*
  607. * mixers
  608. */
  609. static const struct snd_kcontrol_new ad1986a_mixers[] = {
  610. /*
  611. * bind volumes/mutes of 3 DACs as a single PCM control for simplicity
  612. */
  613. HDA_BIND_VOL("PCM Playback Volume", &ad1986a_bind_pcm_vol),
  614. HDA_BIND_SW("PCM Playback Switch", &ad1986a_bind_pcm_sw),
  615. HDA_CODEC_VOLUME("Front Playback Volume", 0x1b, 0x0, HDA_OUTPUT),
  616. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  617. HDA_CODEC_VOLUME("Surround Playback Volume", 0x1c, 0x0, HDA_OUTPUT),
  618. HDA_CODEC_MUTE("Surround Playback Switch", 0x1c, 0x0, HDA_OUTPUT),
  619. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x1d, 1, 0x0, HDA_OUTPUT),
  620. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x1d, 2, 0x0, HDA_OUTPUT),
  621. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x1d, 1, 0x0, HDA_OUTPUT),
  622. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x1d, 2, 0x0, HDA_OUTPUT),
  623. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x1a, 0x0, HDA_OUTPUT),
  624. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x0, HDA_OUTPUT),
  625. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  626. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  627. HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
  628. HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
  629. HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
  630. HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  631. HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
  632. HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
  633. HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT),
  634. HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
  635. HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT),
  636. HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
  637. HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
  638. {
  639. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  640. .name = "Capture Source",
  641. .info = ad198x_mux_enum_info,
  642. .get = ad198x_mux_enum_get,
  643. .put = ad198x_mux_enum_put,
  644. },
  645. HDA_CODEC_MUTE("Stereo Downmix Switch", 0x09, 0x0, HDA_OUTPUT),
  646. { } /* end */
  647. };
  648. /* additional mixers for 3stack mode */
  649. static const struct snd_kcontrol_new ad1986a_3st_mixers[] = {
  650. {
  651. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  652. .name = "Channel Mode",
  653. .info = ad198x_ch_mode_info,
  654. .get = ad198x_ch_mode_get,
  655. .put = ad198x_ch_mode_put,
  656. },
  657. { } /* end */
  658. };
  659. /* laptop model - 2ch only */
  660. static const hda_nid_t ad1986a_laptop_dac_nids[1] = { AD1986A_FRONT_DAC };
  661. /* master controls both pins 0x1a and 0x1b */
  662. static const struct hda_bind_ctls ad1986a_laptop_master_vol = {
  663. .ops = &snd_hda_bind_vol,
  664. .values = {
  665. HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
  666. HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
  667. 0,
  668. },
  669. };
  670. static const struct hda_bind_ctls ad1986a_laptop_master_sw = {
  671. .ops = &snd_hda_bind_sw,
  672. .values = {
  673. HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
  674. HDA_COMPOSE_AMP_VAL(0x1b, 3, 0, HDA_OUTPUT),
  675. 0,
  676. },
  677. };
  678. static const struct snd_kcontrol_new ad1986a_laptop_mixers[] = {
  679. HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  680. HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  681. HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
  682. HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
  683. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  684. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  685. HDA_CODEC_VOLUME("Line Playback Volume", 0x17, 0x0, HDA_OUTPUT),
  686. HDA_CODEC_MUTE("Line Playback Switch", 0x17, 0x0, HDA_OUTPUT),
  687. HDA_CODEC_VOLUME("Aux Playback Volume", 0x16, 0x0, HDA_OUTPUT),
  688. HDA_CODEC_MUTE("Aux Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  689. HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
  690. HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
  691. HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT),
  692. /*
  693. HDA_CODEC_VOLUME("Mono Playback Volume", 0x1e, 0x0, HDA_OUTPUT),
  694. HDA_CODEC_MUTE("Mono Playback Switch", 0x1e, 0x0, HDA_OUTPUT), */
  695. HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
  696. HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
  697. {
  698. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  699. .name = "Capture Source",
  700. .info = ad198x_mux_enum_info,
  701. .get = ad198x_mux_enum_get,
  702. .put = ad198x_mux_enum_put,
  703. },
  704. { } /* end */
  705. };
  706. /* laptop-eapd model - 2ch only */
  707. static const struct hda_input_mux ad1986a_laptop_eapd_capture_source = {
  708. .num_items = 3,
  709. .items = {
  710. { "Mic", 0x0 },
  711. { "Internal Mic", 0x4 },
  712. { "Mix", 0x5 },
  713. },
  714. };
  715. static const struct hda_input_mux ad1986a_automic_capture_source = {
  716. .num_items = 2,
  717. .items = {
  718. { "Mic", 0x0 },
  719. { "Mix", 0x5 },
  720. },
  721. };
  722. static const struct snd_kcontrol_new ad1986a_laptop_master_mixers[] = {
  723. HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
  724. HDA_BIND_SW("Master Playback Switch", &ad1986a_laptop_master_sw),
  725. { } /* end */
  726. };
  727. static const struct snd_kcontrol_new ad1986a_laptop_eapd_mixers[] = {
  728. HDA_CODEC_VOLUME("PCM Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  729. HDA_CODEC_MUTE("PCM Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  730. HDA_CODEC_VOLUME("Mic Playback Volume", 0x13, 0x0, HDA_OUTPUT),
  731. HDA_CODEC_MUTE("Mic Playback Switch", 0x13, 0x0, HDA_OUTPUT),
  732. HDA_CODEC_VOLUME("Mic Boost Volume", 0x0f, 0x0, HDA_OUTPUT),
  733. HDA_CODEC_VOLUME("Capture Volume", 0x12, 0x0, HDA_OUTPUT),
  734. HDA_CODEC_MUTE("Capture Switch", 0x12, 0x0, HDA_OUTPUT),
  735. {
  736. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  737. .name = "Capture Source",
  738. .info = ad198x_mux_enum_info,
  739. .get = ad198x_mux_enum_get,
  740. .put = ad198x_mux_enum_put,
  741. },
  742. {
  743. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  744. .name = "External Amplifier",
  745. .subdevice = HDA_SUBDEV_NID_FLAG | 0x1b,
  746. .info = ad198x_eapd_info,
  747. .get = ad198x_eapd_get,
  748. .put = ad198x_eapd_put,
  749. .private_value = 0x1b, /* port-D */
  750. },
  751. { } /* end */
  752. };
  753. static const struct snd_kcontrol_new ad1986a_laptop_intmic_mixers[] = {
  754. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x17, 0, HDA_OUTPUT),
  755. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x17, 0, HDA_OUTPUT),
  756. { } /* end */
  757. };
  758. /* laptop-automute - 2ch only */
  759. static void ad1986a_update_hp(struct hda_codec *codec)
  760. {
  761. struct ad198x_spec *spec = codec->spec;
  762. unsigned int mute;
  763. if (spec->jack_present)
  764. mute = HDA_AMP_MUTE; /* mute internal speaker */
  765. else
  766. /* unmute internal speaker if necessary */
  767. mute = snd_hda_codec_amp_read(codec, 0x1a, 0, HDA_OUTPUT, 0);
  768. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  769. HDA_AMP_MUTE, mute);
  770. }
  771. static void ad1986a_hp_automute(struct hda_codec *codec)
  772. {
  773. struct ad198x_spec *spec = codec->spec;
  774. spec->jack_present = snd_hda_jack_detect(codec, 0x1a);
  775. if (spec->inv_jack_detect)
  776. spec->jack_present = !spec->jack_present;
  777. ad1986a_update_hp(codec);
  778. }
  779. #define AD1986A_HP_EVENT 0x37
  780. static void ad1986a_hp_unsol_event(struct hda_codec *codec, unsigned int res)
  781. {
  782. if ((res >> 26) != AD1986A_HP_EVENT)
  783. return;
  784. ad1986a_hp_automute(codec);
  785. }
  786. static int ad1986a_hp_init(struct hda_codec *codec)
  787. {
  788. ad198x_init(codec);
  789. ad1986a_hp_automute(codec);
  790. return 0;
  791. }
  792. /* bind hp and internal speaker mute (with plug check) */
  793. static int ad1986a_hp_master_sw_put(struct snd_kcontrol *kcontrol,
  794. struct snd_ctl_elem_value *ucontrol)
  795. {
  796. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  797. int change = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
  798. if (change)
  799. ad1986a_update_hp(codec);
  800. return change;
  801. }
  802. static const struct snd_kcontrol_new ad1986a_automute_master_mixers[] = {
  803. HDA_BIND_VOL("Master Playback Volume", &ad1986a_laptop_master_vol),
  804. {
  805. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  806. .name = "Master Playback Switch",
  807. .subdevice = HDA_SUBDEV_AMP_FLAG,
  808. .info = snd_hda_mixer_amp_switch_info,
  809. .get = snd_hda_mixer_amp_switch_get,
  810. .put = ad1986a_hp_master_sw_put,
  811. .private_value = HDA_COMPOSE_AMP_VAL(0x1a, 3, 0, HDA_OUTPUT),
  812. },
  813. { } /* end */
  814. };
  815. /*
  816. * initialization verbs
  817. */
  818. static const struct hda_verb ad1986a_init_verbs[] = {
  819. /* Front, Surround, CLFE DAC; mute as default */
  820. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  821. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  822. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  823. /* Downmix - off */
  824. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  825. /* HP, Line-Out, Surround, CLFE selectors */
  826. {0x0a, AC_VERB_SET_CONNECT_SEL, 0x0},
  827. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x0},
  828. {0x0c, AC_VERB_SET_CONNECT_SEL, 0x0},
  829. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x0},
  830. /* Mono selector */
  831. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x0},
  832. /* Mic selector: Mic 1/2 pin */
  833. {0x0f, AC_VERB_SET_CONNECT_SEL, 0x0},
  834. /* Line-in selector: Line-in */
  835. {0x10, AC_VERB_SET_CONNECT_SEL, 0x0},
  836. /* Mic 1/2 swap */
  837. {0x11, AC_VERB_SET_CONNECT_SEL, 0x0},
  838. /* Record selector: mic */
  839. {0x12, AC_VERB_SET_CONNECT_SEL, 0x0},
  840. /* Mic, Phone, CD, Aux, Line-In amp; mute as default */
  841. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  842. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  843. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  844. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  845. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  846. /* PC beep */
  847. {0x18, AC_VERB_SET_CONNECT_SEL, 0x0},
  848. /* HP, Line-Out, Surround, CLFE, Mono pins; mute as default */
  849. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  850. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  851. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  852. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  853. {0x1e, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080},
  854. /* HP Pin */
  855. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  856. /* Front, Surround, CLFE Pins */
  857. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  858. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  859. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  860. /* Mono Pin */
  861. {0x1e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  862. /* Mic Pin */
  863. {0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  864. /* Line, Aux, CD, Beep-In Pin */
  865. {0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  866. {0x21, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  867. {0x22, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  868. {0x23, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  869. {0x24, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  870. { } /* end */
  871. };
  872. static const struct hda_verb ad1986a_ch2_init[] = {
  873. /* Surround out -> Line In */
  874. { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  875. /* Line-in selectors */
  876. { 0x10, AC_VERB_SET_CONNECT_SEL, 0x1 },
  877. /* CLFE -> Mic in */
  878. { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  879. /* Mic selector, mix C/LFE (backmic) and Mic (frontmic) */
  880. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
  881. { } /* end */
  882. };
  883. static const struct hda_verb ad1986a_ch4_init[] = {
  884. /* Surround out -> Surround */
  885. { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  886. { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
  887. /* CLFE -> Mic in */
  888. { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  889. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x4 },
  890. { } /* end */
  891. };
  892. static const struct hda_verb ad1986a_ch6_init[] = {
  893. /* Surround out -> Surround out */
  894. { 0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  895. { 0x10, AC_VERB_SET_CONNECT_SEL, 0x0 },
  896. /* CLFE -> CLFE */
  897. { 0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  898. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x0 },
  899. { } /* end */
  900. };
  901. static const struct hda_channel_mode ad1986a_modes[3] = {
  902. { 2, ad1986a_ch2_init },
  903. { 4, ad1986a_ch4_init },
  904. { 6, ad1986a_ch6_init },
  905. };
  906. /* eapd initialization */
  907. static const struct hda_verb ad1986a_eapd_init_verbs[] = {
  908. {0x1b, AC_VERB_SET_EAPD_BTLENABLE, 0x00 },
  909. {}
  910. };
  911. /* pin sensing on HP jack */
  912. static const struct hda_verb ad1986a_hp_init_verbs[] = {
  913. {0x1a, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | AD1986A_HP_EVENT},
  914. {}
  915. };
  916. /* models */
  917. enum {
  918. AD1986A_AUTO,
  919. AD1986A_6STACK,
  920. AD1986A_3STACK,
  921. AD1986A_LAPTOP,
  922. AD1986A_LAPTOP_EAPD,
  923. AD1986A_LAPTOP_AUTOMUTE,
  924. AD1986A_MODELS
  925. };
  926. static const char * const ad1986a_models[AD1986A_MODELS] = {
  927. [AD1986A_AUTO] = "auto",
  928. [AD1986A_6STACK] = "6stack",
  929. [AD1986A_3STACK] = "3stack",
  930. [AD1986A_LAPTOP] = "laptop",
  931. [AD1986A_LAPTOP_EAPD] = "laptop-eapd",
  932. [AD1986A_LAPTOP_AUTOMUTE] = "laptop-automute",
  933. };
  934. static const struct snd_pci_quirk ad1986a_cfg_tbl[] = {
  935. SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_LAPTOP_EAPD),
  936. SND_PCI_QUIRK(0x1043, 0x1153, "ASUS M9", AD1986A_LAPTOP_EAPD),
  937. SND_PCI_QUIRK(0x1043, 0x11f7, "ASUS U5A", AD1986A_LAPTOP_EAPD),
  938. SND_PCI_QUIRK(0x1043, 0x1213, "ASUS A6J", AD1986A_LAPTOP_EAPD),
  939. SND_PCI_QUIRK(0x1043, 0x1263, "ASUS U5F", AD1986A_LAPTOP_EAPD),
  940. SND_PCI_QUIRK(0x1043, 0x1297, "ASUS Z62F", AD1986A_LAPTOP_EAPD),
  941. SND_PCI_QUIRK(0x1043, 0x12b3, "ASUS V1j", AD1986A_LAPTOP_EAPD),
  942. SND_PCI_QUIRK(0x1043, 0x1302, "ASUS W3j", AD1986A_LAPTOP_EAPD),
  943. SND_PCI_QUIRK(0x1043, 0x1443, "ASUS VX1", AD1986A_LAPTOP),
  944. SND_PCI_QUIRK(0x1043, 0x1447, "ASUS A8J", AD1986A_3STACK),
  945. SND_PCI_QUIRK(0x1043, 0x817f, "ASUS P5", AD1986A_3STACK),
  946. SND_PCI_QUIRK(0x1043, 0x818f, "ASUS P5", AD1986A_LAPTOP),
  947. SND_PCI_QUIRK(0x1043, 0x81b3, "ASUS P5", AD1986A_3STACK),
  948. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS M2N", AD1986A_3STACK),
  949. SND_PCI_QUIRK(0x1043, 0x8234, "ASUS M2N", AD1986A_3STACK),
  950. SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_3STACK),
  951. SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_LAPTOP),
  952. SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_LAPTOP),
  953. SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_3STACK),
  954. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_LAPTOP_AUTOMUTE),
  955. {}
  956. };
  957. #ifdef CONFIG_PM
  958. static const struct hda_amp_list ad1986a_loopbacks[] = {
  959. { 0x13, HDA_OUTPUT, 0 }, /* Mic */
  960. { 0x14, HDA_OUTPUT, 0 }, /* Phone */
  961. { 0x15, HDA_OUTPUT, 0 }, /* CD */
  962. { 0x16, HDA_OUTPUT, 0 }, /* Aux */
  963. { 0x17, HDA_OUTPUT, 0 }, /* Line */
  964. { } /* end */
  965. };
  966. #endif
  967. static int is_jack_available(struct hda_codec *codec, hda_nid_t nid)
  968. {
  969. unsigned int conf = snd_hda_codec_get_pincfg(codec, nid);
  970. return get_defcfg_connect(conf) != AC_JACK_PORT_NONE;
  971. }
  972. #endif /* ENABLE_AD_STATIC_QUIRKS */
  973. static int alloc_ad_spec(struct hda_codec *codec)
  974. {
  975. struct ad198x_spec *spec;
  976. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  977. if (!spec)
  978. return -ENOMEM;
  979. codec->spec = spec;
  980. snd_hda_gen_spec_init(&spec->gen);
  981. return 0;
  982. }
  983. /*
  984. * AD1986A fixup codes
  985. */
  986. /* Lenovo N100 seems to report the reversed bit for HP jack-sensing */
  987. static void ad_fixup_inv_jack_detect(struct hda_codec *codec,
  988. const struct hda_fixup *fix, int action)
  989. {
  990. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  991. codec->inv_jack_detect = 1;
  992. }
  993. enum {
  994. AD1986A_FIXUP_INV_JACK_DETECT,
  995. AD1986A_FIXUP_ULTRA,
  996. AD1986A_FIXUP_SAMSUNG,
  997. };
  998. static const struct hda_fixup ad1986a_fixups[] = {
  999. [AD1986A_FIXUP_INV_JACK_DETECT] = {
  1000. .type = HDA_FIXUP_FUNC,
  1001. .v.func = ad_fixup_inv_jack_detect,
  1002. },
  1003. [AD1986A_FIXUP_ULTRA] = {
  1004. .type = HDA_FIXUP_PINS,
  1005. .v.pins = (const struct hda_pintbl[]) {
  1006. { 0x1b, 0x90170110 }, /* speaker */
  1007. { 0x1d, 0x90a7013e }, /* int mic */
  1008. {}
  1009. },
  1010. },
  1011. [AD1986A_FIXUP_SAMSUNG] = {
  1012. .type = HDA_FIXUP_PINS,
  1013. .v.pins = (const struct hda_pintbl[]) {
  1014. { 0x1b, 0x90170110 }, /* speaker */
  1015. { 0x1d, 0x90a7013e }, /* int mic */
  1016. { 0x20, 0x411111f0 }, /* N/A */
  1017. { 0x24, 0x411111f0 }, /* N/A */
  1018. {}
  1019. },
  1020. },
  1021. };
  1022. static const struct snd_pci_quirk ad1986a_fixup_tbl[] = {
  1023. SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_FIXUP_SAMSUNG),
  1024. SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_FIXUP_ULTRA),
  1025. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_FIXUP_INV_JACK_DETECT),
  1026. {}
  1027. };
  1028. /*
  1029. */
  1030. static int ad1986a_parse_auto_config(struct hda_codec *codec)
  1031. {
  1032. int err;
  1033. struct ad198x_spec *spec;
  1034. err = alloc_ad_spec(codec);
  1035. if (err < 0)
  1036. return err;
  1037. spec = codec->spec;
  1038. /* AD1986A has the inverted EAPD implementation */
  1039. codec->inv_eapd = 1;
  1040. spec->gen.mixer_nid = 0x07;
  1041. spec->gen.beep_nid = 0x19;
  1042. set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
  1043. /* AD1986A has a hardware problem that it can't share a stream
  1044. * with multiple output pins. The copy of front to surrounds
  1045. * causes noisy or silent outputs at a certain timing, e.g.
  1046. * changing the volume.
  1047. * So, let's disable the shared stream.
  1048. */
  1049. spec->gen.multiout.no_share_stream = 1;
  1050. snd_hda_pick_fixup(codec, NULL, ad1986a_fixup_tbl, ad1986a_fixups);
  1051. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  1052. err = ad198x_parse_auto_config(codec);
  1053. if (err < 0) {
  1054. snd_hda_gen_free(codec);
  1055. return err;
  1056. }
  1057. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  1058. return 0;
  1059. }
  1060. #ifdef ENABLE_AD_STATIC_QUIRKS
  1061. static int patch_ad1986a(struct hda_codec *codec)
  1062. {
  1063. struct ad198x_spec *spec;
  1064. int err, board_config;
  1065. board_config = snd_hda_check_board_config(codec, AD1986A_MODELS,
  1066. ad1986a_models,
  1067. ad1986a_cfg_tbl);
  1068. if (board_config < 0) {
  1069. printk(KERN_INFO "hda_codec: %s: BIOS auto-probing.\n",
  1070. codec->chip_name);
  1071. board_config = AD1986A_AUTO;
  1072. }
  1073. if (board_config == AD1986A_AUTO)
  1074. return ad1986a_parse_auto_config(codec);
  1075. err = alloc_ad_spec(codec);
  1076. if (err < 0)
  1077. return err;
  1078. spec = codec->spec;
  1079. err = snd_hda_attach_beep_device(codec, 0x19);
  1080. if (err < 0) {
  1081. ad198x_free(codec);
  1082. return err;
  1083. }
  1084. set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
  1085. spec->multiout.max_channels = 6;
  1086. spec->multiout.num_dacs = ARRAY_SIZE(ad1986a_dac_nids);
  1087. spec->multiout.dac_nids = ad1986a_dac_nids;
  1088. spec->multiout.dig_out_nid = AD1986A_SPDIF_OUT;
  1089. spec->num_adc_nids = 1;
  1090. spec->adc_nids = ad1986a_adc_nids;
  1091. spec->capsrc_nids = ad1986a_capsrc_nids;
  1092. spec->input_mux = &ad1986a_capture_source;
  1093. spec->num_mixers = 1;
  1094. spec->mixers[0] = ad1986a_mixers;
  1095. spec->num_init_verbs = 1;
  1096. spec->init_verbs[0] = ad1986a_init_verbs;
  1097. #ifdef CONFIG_PM
  1098. spec->loopback.amplist = ad1986a_loopbacks;
  1099. #endif
  1100. spec->vmaster_nid = 0x1b;
  1101. codec->inv_eapd = 1; /* AD1986A has the inverted EAPD implementation */
  1102. codec->patch_ops = ad198x_patch_ops;
  1103. /* override some parameters */
  1104. switch (board_config) {
  1105. case AD1986A_3STACK:
  1106. spec->num_mixers = 2;
  1107. spec->mixers[1] = ad1986a_3st_mixers;
  1108. spec->num_init_verbs = 2;
  1109. spec->init_verbs[1] = ad1986a_ch2_init;
  1110. spec->channel_mode = ad1986a_modes;
  1111. spec->num_channel_mode = ARRAY_SIZE(ad1986a_modes);
  1112. spec->need_dac_fix = 1;
  1113. spec->multiout.max_channels = 2;
  1114. spec->multiout.num_dacs = 1;
  1115. break;
  1116. case AD1986A_LAPTOP:
  1117. spec->mixers[0] = ad1986a_laptop_mixers;
  1118. spec->multiout.max_channels = 2;
  1119. spec->multiout.num_dacs = 1;
  1120. spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
  1121. break;
  1122. case AD1986A_LAPTOP_EAPD:
  1123. spec->num_mixers = 3;
  1124. spec->mixers[0] = ad1986a_laptop_master_mixers;
  1125. spec->mixers[1] = ad1986a_laptop_eapd_mixers;
  1126. spec->mixers[2] = ad1986a_laptop_intmic_mixers;
  1127. spec->num_init_verbs = 2;
  1128. spec->init_verbs[1] = ad1986a_eapd_init_verbs;
  1129. spec->multiout.max_channels = 2;
  1130. spec->multiout.num_dacs = 1;
  1131. spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
  1132. if (!is_jack_available(codec, 0x25))
  1133. spec->multiout.dig_out_nid = 0;
  1134. spec->input_mux = &ad1986a_laptop_eapd_capture_source;
  1135. break;
  1136. case AD1986A_LAPTOP_AUTOMUTE:
  1137. spec->num_mixers = 3;
  1138. spec->mixers[0] = ad1986a_automute_master_mixers;
  1139. spec->mixers[1] = ad1986a_laptop_eapd_mixers;
  1140. spec->mixers[2] = ad1986a_laptop_intmic_mixers;
  1141. spec->num_init_verbs = 3;
  1142. spec->init_verbs[1] = ad1986a_eapd_init_verbs;
  1143. spec->init_verbs[2] = ad1986a_hp_init_verbs;
  1144. spec->multiout.max_channels = 2;
  1145. spec->multiout.num_dacs = 1;
  1146. spec->multiout.dac_nids = ad1986a_laptop_dac_nids;
  1147. if (!is_jack_available(codec, 0x25))
  1148. spec->multiout.dig_out_nid = 0;
  1149. spec->input_mux = &ad1986a_laptop_eapd_capture_source;
  1150. codec->patch_ops.unsol_event = ad1986a_hp_unsol_event;
  1151. codec->patch_ops.init = ad1986a_hp_init;
  1152. /* Lenovo N100 seems to report the reversed bit
  1153. * for HP jack-sensing
  1154. */
  1155. spec->inv_jack_detect = 1;
  1156. break;
  1157. }
  1158. /* AD1986A has a hardware problem that it can't share a stream
  1159. * with multiple output pins. The copy of front to surrounds
  1160. * causes noisy or silent outputs at a certain timing, e.g.
  1161. * changing the volume.
  1162. * So, let's disable the shared stream.
  1163. */
  1164. spec->multiout.no_share_stream = 1;
  1165. codec->no_trigger_sense = 1;
  1166. codec->no_sticky_stream = 1;
  1167. return 0;
  1168. }
  1169. #else /* ENABLE_AD_STATIC_QUIRKS */
  1170. #define patch_ad1986a ad1986a_parse_auto_config
  1171. #endif /* ENABLE_AD_STATIC_QUIRKS */
  1172. /*
  1173. * AD1983 specific
  1174. */
  1175. /*
  1176. * SPDIF mux control for AD1983 auto-parser
  1177. */
  1178. static int ad1983_auto_smux_enum_info(struct snd_kcontrol *kcontrol,
  1179. struct snd_ctl_elem_info *uinfo)
  1180. {
  1181. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1182. struct ad198x_spec *spec = codec->spec;
  1183. static const char * const texts2[] = { "PCM", "ADC" };
  1184. static const char * const texts3[] = { "PCM", "ADC1", "ADC2" };
  1185. hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
  1186. int num_conns = snd_hda_get_num_conns(codec, dig_out);
  1187. if (num_conns == 2)
  1188. return snd_hda_enum_helper_info(kcontrol, uinfo, 2, texts2);
  1189. else if (num_conns == 3)
  1190. return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3);
  1191. else
  1192. return -EINVAL;
  1193. }
  1194. static int ad1983_auto_smux_enum_get(struct snd_kcontrol *kcontrol,
  1195. struct snd_ctl_elem_value *ucontrol)
  1196. {
  1197. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1198. struct ad198x_spec *spec = codec->spec;
  1199. ucontrol->value.enumerated.item[0] = spec->cur_smux;
  1200. return 0;
  1201. }
  1202. static int ad1983_auto_smux_enum_put(struct snd_kcontrol *kcontrol,
  1203. struct snd_ctl_elem_value *ucontrol)
  1204. {
  1205. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1206. struct ad198x_spec *spec = codec->spec;
  1207. unsigned int val = ucontrol->value.enumerated.item[0];
  1208. hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
  1209. int num_conns = snd_hda_get_num_conns(codec, dig_out);
  1210. if (val >= num_conns)
  1211. return -EINVAL;
  1212. if (spec->cur_smux == val)
  1213. return 0;
  1214. spec->cur_smux = val;
  1215. snd_hda_codec_write_cache(codec, dig_out, 0,
  1216. AC_VERB_SET_CONNECT_SEL, val);
  1217. return 1;
  1218. }
  1219. static struct snd_kcontrol_new ad1983_auto_smux_mixer = {
  1220. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1221. .name = "IEC958 Playback Source",
  1222. .info = ad1983_auto_smux_enum_info,
  1223. .get = ad1983_auto_smux_enum_get,
  1224. .put = ad1983_auto_smux_enum_put,
  1225. };
  1226. static int ad1983_add_spdif_mux_ctl(struct hda_codec *codec)
  1227. {
  1228. struct ad198x_spec *spec = codec->spec;
  1229. hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
  1230. int num_conns;
  1231. if (!dig_out)
  1232. return 0;
  1233. num_conns = snd_hda_get_num_conns(codec, dig_out);
  1234. if (num_conns != 2 && num_conns != 3)
  1235. return 0;
  1236. if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1983_auto_smux_mixer))
  1237. return -ENOMEM;
  1238. return 0;
  1239. }
  1240. static int patch_ad1983(struct hda_codec *codec)
  1241. {
  1242. struct ad198x_spec *spec;
  1243. int err;
  1244. err = alloc_ad_spec(codec);
  1245. if (err < 0)
  1246. return err;
  1247. spec = codec->spec;
  1248. spec->gen.beep_nid = 0x10;
  1249. set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
  1250. err = ad198x_parse_auto_config(codec);
  1251. if (err < 0)
  1252. goto error;
  1253. err = ad1983_add_spdif_mux_ctl(codec);
  1254. if (err < 0)
  1255. goto error;
  1256. return 0;
  1257. error:
  1258. snd_hda_gen_free(codec);
  1259. return err;
  1260. }
  1261. /*
  1262. * AD1981 HD specific
  1263. */
  1264. /* follow EAPD via vmaster hook */
  1265. static void ad_vmaster_eapd_hook(void *private_data, int enabled)
  1266. {
  1267. struct hda_codec *codec = private_data;
  1268. struct ad198x_spec *spec = codec->spec;
  1269. if (!spec->eapd_nid)
  1270. return;
  1271. snd_hda_codec_update_cache(codec, spec->eapd_nid, 0,
  1272. AC_VERB_SET_EAPD_BTLENABLE,
  1273. enabled ? 0x02 : 0x00);
  1274. }
  1275. static void ad1981_fixup_hp_eapd(struct hda_codec *codec,
  1276. const struct hda_fixup *fix, int action)
  1277. {
  1278. struct ad198x_spec *spec = codec->spec;
  1279. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  1280. spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook;
  1281. spec->eapd_nid = 0x05;
  1282. }
  1283. }
  1284. /* set the upper-limit for mixer amp to 0dB for avoiding the possible
  1285. * damage by overloading
  1286. */
  1287. static void ad1981_fixup_amp_override(struct hda_codec *codec,
  1288. const struct hda_fixup *fix, int action)
  1289. {
  1290. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  1291. snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT,
  1292. (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
  1293. (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
  1294. (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
  1295. (1 << AC_AMPCAP_MUTE_SHIFT));
  1296. }
  1297. enum {
  1298. AD1981_FIXUP_AMP_OVERRIDE,
  1299. AD1981_FIXUP_HP_EAPD,
  1300. };
  1301. static const struct hda_fixup ad1981_fixups[] = {
  1302. [AD1981_FIXUP_AMP_OVERRIDE] = {
  1303. .type = HDA_FIXUP_FUNC,
  1304. .v.func = ad1981_fixup_amp_override,
  1305. },
  1306. [AD1981_FIXUP_HP_EAPD] = {
  1307. .type = HDA_FIXUP_FUNC,
  1308. .v.func = ad1981_fixup_hp_eapd,
  1309. .chained = true,
  1310. .chain_id = AD1981_FIXUP_AMP_OVERRIDE,
  1311. },
  1312. };
  1313. static const struct snd_pci_quirk ad1981_fixup_tbl[] = {
  1314. SND_PCI_QUIRK_VENDOR(0x1014, "Lenovo", AD1981_FIXUP_AMP_OVERRIDE),
  1315. SND_PCI_QUIRK_VENDOR(0x103c, "HP", AD1981_FIXUP_HP_EAPD),
  1316. SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", AD1981_FIXUP_AMP_OVERRIDE),
  1317. /* HP nx6320 (reversed SSID, H/W bug) */
  1318. SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_FIXUP_HP_EAPD),
  1319. {}
  1320. };
  1321. static int patch_ad1981(struct hda_codec *codec)
  1322. {
  1323. struct ad198x_spec *spec;
  1324. int err;
  1325. err = alloc_ad_spec(codec);
  1326. if (err < 0)
  1327. return -ENOMEM;
  1328. spec = codec->spec;
  1329. spec->gen.mixer_nid = 0x0e;
  1330. spec->gen.beep_nid = 0x10;
  1331. set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT);
  1332. snd_hda_pick_fixup(codec, NULL, ad1981_fixup_tbl, ad1981_fixups);
  1333. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  1334. err = ad198x_parse_auto_config(codec);
  1335. if (err < 0)
  1336. goto error;
  1337. err = ad1983_add_spdif_mux_ctl(codec);
  1338. if (err < 0)
  1339. goto error;
  1340. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  1341. return 0;
  1342. error:
  1343. snd_hda_gen_free(codec);
  1344. return err;
  1345. }
  1346. /*
  1347. * AD1988
  1348. *
  1349. * Output pins and routes
  1350. *
  1351. * Pin Mix Sel DAC (*)
  1352. * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
  1353. * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
  1354. * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
  1355. * port-D 0x12 (mute/hp) <- 0x29 <- 04
  1356. * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
  1357. * port-F 0x16 (mute) <- 0x2a <- 06
  1358. * port-G 0x24 (mute) <- 0x27 <- 05
  1359. * port-H 0x25 (mute) <- 0x28 <- 0a
  1360. * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
  1361. *
  1362. * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
  1363. * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
  1364. *
  1365. * Input pins and routes
  1366. *
  1367. * pin boost mix input # / adc input #
  1368. * port-A 0x11 -> 0x38 -> mix 2, ADC 0
  1369. * port-B 0x14 -> 0x39 -> mix 0, ADC 1
  1370. * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
  1371. * port-D 0x12 -> 0x3d -> mix 3, ADC 8
  1372. * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
  1373. * port-F 0x16 -> 0x3b -> mix 5, ADC 3
  1374. * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
  1375. * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
  1376. *
  1377. *
  1378. * DAC assignment
  1379. * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
  1380. * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
  1381. *
  1382. * Inputs of Analog Mix (0x20)
  1383. * 0:Port-B (front mic)
  1384. * 1:Port-C/G/H (line-in)
  1385. * 2:Port-A
  1386. * 3:Port-D (line-in/2)
  1387. * 4:Port-E/G/H (mic-in)
  1388. * 5:Port-F (mic2-in)
  1389. * 6:CD
  1390. * 7:Beep
  1391. *
  1392. * ADC selection
  1393. * 0:Port-A
  1394. * 1:Port-B (front mic-in)
  1395. * 2:Port-C (line-in)
  1396. * 3:Port-F (mic2-in)
  1397. * 4:Port-E (mic-in)
  1398. * 5:CD
  1399. * 6:Port-G
  1400. * 7:Port-H
  1401. * 8:Port-D (line-in/2)
  1402. * 9:Mix
  1403. *
  1404. * Proposed pin assignments by the datasheet
  1405. *
  1406. * 6-stack
  1407. * Port-A front headphone
  1408. * B front mic-in
  1409. * C rear line-in
  1410. * D rear front-out
  1411. * E rear mic-in
  1412. * F rear surround
  1413. * G rear CLFE
  1414. * H rear side
  1415. *
  1416. * 3-stack
  1417. * Port-A front headphone
  1418. * B front mic
  1419. * C rear line-in/surround
  1420. * D rear front-out
  1421. * E rear mic-in/CLFE
  1422. *
  1423. * laptop
  1424. * Port-A headphone
  1425. * B mic-in
  1426. * C docking station
  1427. * D internal speaker (with EAPD)
  1428. * E/F quad mic array
  1429. */
  1430. #ifdef ENABLE_AD_STATIC_QUIRKS
  1431. static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
  1432. struct snd_ctl_elem_info *uinfo)
  1433. {
  1434. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1435. struct ad198x_spec *spec = codec->spec;
  1436. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  1437. spec->num_channel_mode);
  1438. }
  1439. static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
  1440. struct snd_ctl_elem_value *ucontrol)
  1441. {
  1442. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1443. struct ad198x_spec *spec = codec->spec;
  1444. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  1445. spec->num_channel_mode, spec->multiout.max_channels);
  1446. }
  1447. static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
  1448. struct snd_ctl_elem_value *ucontrol)
  1449. {
  1450. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1451. struct ad198x_spec *spec = codec->spec;
  1452. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  1453. spec->num_channel_mode,
  1454. &spec->multiout.max_channels);
  1455. if (err >= 0 && spec->need_dac_fix)
  1456. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  1457. return err;
  1458. }
  1459. #endif /* ENABLE_AD_STATIC_QUIRKS */
  1460. static int ad1988_auto_smux_enum_info(struct snd_kcontrol *kcontrol,
  1461. struct snd_ctl_elem_info *uinfo)
  1462. {
  1463. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1464. static const char * const texts[] = {
  1465. "PCM", "ADC1", "ADC2", "ADC3",
  1466. };
  1467. int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
  1468. if (num_conns > 4)
  1469. num_conns = 4;
  1470. return snd_hda_enum_helper_info(kcontrol, uinfo, num_conns, texts);
  1471. }
  1472. static int ad1988_auto_smux_enum_get(struct snd_kcontrol *kcontrol,
  1473. struct snd_ctl_elem_value *ucontrol)
  1474. {
  1475. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1476. struct ad198x_spec *spec = codec->spec;
  1477. ucontrol->value.enumerated.item[0] = spec->cur_smux;
  1478. return 0;
  1479. }
  1480. static int ad1988_auto_smux_enum_put(struct snd_kcontrol *kcontrol,
  1481. struct snd_ctl_elem_value *ucontrol)
  1482. {
  1483. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1484. struct ad198x_spec *spec = codec->spec;
  1485. unsigned int val = ucontrol->value.enumerated.item[0];
  1486. struct nid_path *path;
  1487. int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
  1488. if (val >= num_conns)
  1489. return -EINVAL;
  1490. if (spec->cur_smux == val)
  1491. return 0;
  1492. mutex_lock(&codec->control_mutex);
  1493. codec->cached_write = 1;
  1494. path = snd_hda_get_path_from_idx(codec,
  1495. spec->smux_paths[spec->cur_smux]);
  1496. if (path)
  1497. snd_hda_activate_path(codec, path, false, true);
  1498. path = snd_hda_get_path_from_idx(codec, spec->smux_paths[val]);
  1499. if (path)
  1500. snd_hda_activate_path(codec, path, true, true);
  1501. spec->cur_smux = val;
  1502. codec->cached_write = 0;
  1503. mutex_unlock(&codec->control_mutex);
  1504. snd_hda_codec_flush_cache(codec); /* flush the updates */
  1505. return 1;
  1506. }
  1507. static struct snd_kcontrol_new ad1988_auto_smux_mixer = {
  1508. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1509. .name = "IEC958 Playback Source",
  1510. .info = ad1988_auto_smux_enum_info,
  1511. .get = ad1988_auto_smux_enum_get,
  1512. .put = ad1988_auto_smux_enum_put,
  1513. };
  1514. static int ad1988_auto_init(struct hda_codec *codec)
  1515. {
  1516. struct ad198x_spec *spec = codec->spec;
  1517. int i, err;
  1518. err = snd_hda_gen_init(codec);
  1519. if (err < 0)
  1520. return err;
  1521. if (!spec->gen.autocfg.dig_outs)
  1522. return 0;
  1523. for (i = 0; i < 4; i++) {
  1524. struct nid_path *path;
  1525. path = snd_hda_get_path_from_idx(codec, spec->smux_paths[i]);
  1526. if (path)
  1527. snd_hda_activate_path(codec, path, path->active, false);
  1528. }
  1529. return 0;
  1530. }
  1531. static int ad1988_add_spdif_mux_ctl(struct hda_codec *codec)
  1532. {
  1533. struct ad198x_spec *spec = codec->spec;
  1534. int i, num_conns;
  1535. /* we create four static faked paths, since AD codecs have odd
  1536. * widget connections regarding the SPDIF out source
  1537. */
  1538. static struct nid_path fake_paths[4] = {
  1539. {
  1540. .depth = 3,
  1541. .path = { 0x02, 0x1d, 0x1b },
  1542. .idx = { 0, 0, 0 },
  1543. .multi = { 0, 0, 0 },
  1544. },
  1545. {
  1546. .depth = 4,
  1547. .path = { 0x08, 0x0b, 0x1d, 0x1b },
  1548. .idx = { 0, 0, 1, 0 },
  1549. .multi = { 0, 1, 0, 0 },
  1550. },
  1551. {
  1552. .depth = 4,
  1553. .path = { 0x09, 0x0b, 0x1d, 0x1b },
  1554. .idx = { 0, 1, 1, 0 },
  1555. .multi = { 0, 1, 0, 0 },
  1556. },
  1557. {
  1558. .depth = 4,
  1559. .path = { 0x0f, 0x0b, 0x1d, 0x1b },
  1560. .idx = { 0, 2, 1, 0 },
  1561. .multi = { 0, 1, 0, 0 },
  1562. },
  1563. };
  1564. /* SPDIF source mux appears to be present only on AD1988A */
  1565. if (!spec->gen.autocfg.dig_outs ||
  1566. get_wcaps_type(get_wcaps(codec, 0x1d)) != AC_WID_AUD_MIX)
  1567. return 0;
  1568. num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
  1569. if (num_conns != 3 && num_conns != 4)
  1570. return 0;
  1571. for (i = 0; i < num_conns; i++) {
  1572. struct nid_path *path = snd_array_new(&spec->gen.paths);
  1573. if (!path)
  1574. return -ENOMEM;
  1575. *path = fake_paths[i];
  1576. if (!i)
  1577. path->active = 1;
  1578. spec->smux_paths[i] = snd_hda_get_path_idx(codec, path);
  1579. }
  1580. if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1988_auto_smux_mixer))
  1581. return -ENOMEM;
  1582. codec->patch_ops.init = ad1988_auto_init;
  1583. return 0;
  1584. }
  1585. /*
  1586. */
  1587. enum {
  1588. AD1988_FIXUP_6STACK_DIG,
  1589. };
  1590. static const struct hda_fixup ad1988_fixups[] = {
  1591. [AD1988_FIXUP_6STACK_DIG] = {
  1592. .type = HDA_FIXUP_PINS,
  1593. .v.pins = (const struct hda_pintbl[]) {
  1594. { 0x11, 0x02214130 }, /* front-hp */
  1595. { 0x12, 0x01014010 }, /* line-out */
  1596. { 0x14, 0x02a19122 }, /* front-mic */
  1597. { 0x15, 0x01813021 }, /* line-in */
  1598. { 0x16, 0x01011012 }, /* line-out */
  1599. { 0x17, 0x01a19020 }, /* mic */
  1600. { 0x1b, 0x0145f1f0 }, /* SPDIF */
  1601. { 0x24, 0x01016011 }, /* line-out */
  1602. { 0x25, 0x01012013 }, /* line-out */
  1603. { }
  1604. }
  1605. },
  1606. };
  1607. static const struct hda_model_fixup ad1988_fixup_models[] = {
  1608. { .id = AD1988_FIXUP_6STACK_DIG, .name = "6stack-dig" },
  1609. {}
  1610. };
  1611. static int patch_ad1988(struct hda_codec *codec)
  1612. {
  1613. struct ad198x_spec *spec;
  1614. int err;
  1615. err = alloc_ad_spec(codec);
  1616. if (err < 0)
  1617. return err;
  1618. spec = codec->spec;
  1619. spec->gen.mixer_nid = 0x20;
  1620. spec->gen.mixer_merge_nid = 0x21;
  1621. spec->gen.beep_nid = 0x10;
  1622. set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
  1623. snd_hda_pick_fixup(codec, ad1988_fixup_models, NULL, ad1988_fixups);
  1624. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  1625. err = ad198x_parse_auto_config(codec);
  1626. if (err < 0)
  1627. goto error;
  1628. err = ad1988_add_spdif_mux_ctl(codec);
  1629. if (err < 0)
  1630. goto error;
  1631. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  1632. return 0;
  1633. error:
  1634. snd_hda_gen_free(codec);
  1635. return err;
  1636. }
  1637. /*
  1638. * AD1884 / AD1984
  1639. *
  1640. * port-B - front line/mic-in
  1641. * port-E - aux in/out
  1642. * port-F - aux in/out
  1643. * port-C - rear line/mic-in
  1644. * port-D - rear line/hp-out
  1645. * port-A - front line/hp-out
  1646. *
  1647. * AD1984 = AD1884 + two digital mic-ins
  1648. *
  1649. * AD1883 / AD1884A / AD1984A / AD1984B
  1650. *
  1651. * port-B (0x14) - front mic-in
  1652. * port-E (0x1c) - rear mic-in
  1653. * port-F (0x16) - CD / ext out
  1654. * port-C (0x15) - rear line-in
  1655. * port-D (0x12) - rear line-out
  1656. * port-A (0x11) - front hp-out
  1657. *
  1658. * AD1984A = AD1884A + digital-mic
  1659. * AD1883 = equivalent with AD1984A
  1660. * AD1984B = AD1984A + extra SPDIF-out
  1661. */
  1662. /* set the upper-limit for mixer amp to 0dB for avoiding the possible
  1663. * damage by overloading
  1664. */
  1665. static void ad1884_fixup_amp_override(struct hda_codec *codec,
  1666. const struct hda_fixup *fix, int action)
  1667. {
  1668. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  1669. snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
  1670. (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
  1671. (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
  1672. (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
  1673. (1 << AC_AMPCAP_MUTE_SHIFT));
  1674. }
  1675. /* toggle GPIO1 according to the mute state */
  1676. static void ad1884_vmaster_hp_gpio_hook(void *private_data, int enabled)
  1677. {
  1678. struct hda_codec *codec = private_data;
  1679. struct ad198x_spec *spec = codec->spec;
  1680. if (spec->eapd_nid)
  1681. ad_vmaster_eapd_hook(private_data, enabled);
  1682. snd_hda_codec_update_cache(codec, 0x01, 0,
  1683. AC_VERB_SET_GPIO_DATA,
  1684. enabled ? 0x00 : 0x02);
  1685. }
  1686. static void ad1884_fixup_hp_eapd(struct hda_codec *codec,
  1687. const struct hda_fixup *fix, int action)
  1688. {
  1689. struct ad198x_spec *spec = codec->spec;
  1690. static const struct hda_verb gpio_init_verbs[] = {
  1691. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  1692. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  1693. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  1694. {},
  1695. };
  1696. switch (action) {
  1697. case HDA_FIXUP_ACT_PRE_PROBE:
  1698. spec->gen.vmaster_mute.hook = ad1884_vmaster_hp_gpio_hook;
  1699. snd_hda_sequence_write_cache(codec, gpio_init_verbs);
  1700. break;
  1701. case HDA_FIXUP_ACT_PROBE:
  1702. if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
  1703. spec->eapd_nid = spec->gen.autocfg.line_out_pins[0];
  1704. else
  1705. spec->eapd_nid = spec->gen.autocfg.speaker_pins[0];
  1706. break;
  1707. }
  1708. }
  1709. /* set magic COEFs for dmic */
  1710. static const struct hda_verb ad1884_dmic_init_verbs[] = {
  1711. {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
  1712. {0x01, AC_VERB_SET_PROC_COEF, 0x08},
  1713. {}
  1714. };
  1715. enum {
  1716. AD1884_FIXUP_AMP_OVERRIDE,
  1717. AD1884_FIXUP_HP_EAPD,
  1718. AD1884_FIXUP_DMIC_COEF,
  1719. AD1884_FIXUP_HP_TOUCHSMART,
  1720. };
  1721. static const struct hda_fixup ad1884_fixups[] = {
  1722. [AD1884_FIXUP_AMP_OVERRIDE] = {
  1723. .type = HDA_FIXUP_FUNC,
  1724. .v.func = ad1884_fixup_amp_override,
  1725. },
  1726. [AD1884_FIXUP_HP_EAPD] = {
  1727. .type = HDA_FIXUP_FUNC,
  1728. .v.func = ad1884_fixup_hp_eapd,
  1729. .chained = true,
  1730. .chain_id = AD1884_FIXUP_AMP_OVERRIDE,
  1731. },
  1732. [AD1884_FIXUP_DMIC_COEF] = {
  1733. .type = HDA_FIXUP_VERBS,
  1734. .v.verbs = ad1884_dmic_init_verbs,
  1735. },
  1736. [AD1884_FIXUP_HP_TOUCHSMART] = {
  1737. .type = HDA_FIXUP_VERBS,
  1738. .v.verbs = ad1884_dmic_init_verbs,
  1739. .chained = true,
  1740. .chain_id = AD1884_FIXUP_HP_EAPD,
  1741. },
  1742. };
  1743. static const struct snd_pci_quirk ad1884_fixup_tbl[] = {
  1744. SND_PCI_QUIRK(0x103c, 0x2a82, "HP Touchsmart", AD1884_FIXUP_HP_TOUCHSMART),
  1745. SND_PCI_QUIRK_VENDOR(0x103c, "HP", AD1884_FIXUP_HP_EAPD),
  1746. SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1884_FIXUP_DMIC_COEF),
  1747. {}
  1748. };
  1749. static int patch_ad1884(struct hda_codec *codec)
  1750. {
  1751. struct ad198x_spec *spec;
  1752. int err;
  1753. err = alloc_ad_spec(codec);
  1754. if (err < 0)
  1755. return err;
  1756. spec = codec->spec;
  1757. spec->gen.mixer_nid = 0x20;
  1758. spec->gen.beep_nid = 0x10;
  1759. set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
  1760. snd_hda_pick_fixup(codec, NULL, ad1884_fixup_tbl, ad1884_fixups);
  1761. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  1762. err = ad198x_parse_auto_config(codec);
  1763. if (err < 0)
  1764. goto error;
  1765. err = ad1983_add_spdif_mux_ctl(codec);
  1766. if (err < 0)
  1767. goto error;
  1768. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  1769. return 0;
  1770. error:
  1771. snd_hda_gen_free(codec);
  1772. return err;
  1773. }
  1774. /*
  1775. * AD1882 / AD1882A
  1776. *
  1777. * port-A - front hp-out
  1778. * port-B - front mic-in
  1779. * port-C - rear line-in, shared surr-out (3stack)
  1780. * port-D - rear line-out
  1781. * port-E - rear mic-in, shared clfe-out (3stack)
  1782. * port-F - rear surr-out (6stack)
  1783. * port-G - rear clfe-out (6stack)
  1784. */
  1785. static int patch_ad1882(struct hda_codec *codec)
  1786. {
  1787. struct ad198x_spec *spec;
  1788. int err;
  1789. err = alloc_ad_spec(codec);
  1790. if (err < 0)
  1791. return err;
  1792. spec = codec->spec;
  1793. spec->gen.mixer_nid = 0x20;
  1794. spec->gen.mixer_merge_nid = 0x21;
  1795. spec->gen.beep_nid = 0x10;
  1796. set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
  1797. err = ad198x_parse_auto_config(codec);
  1798. if (err < 0)
  1799. goto error;
  1800. err = ad1988_add_spdif_mux_ctl(codec);
  1801. if (err < 0)
  1802. goto error;
  1803. return 0;
  1804. error:
  1805. snd_hda_gen_free(codec);
  1806. return err;
  1807. }
  1808. /*
  1809. * patch entries
  1810. */
  1811. static const struct hda_codec_preset snd_hda_preset_analog[] = {
  1812. { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884 },
  1813. { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
  1814. { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884 },
  1815. { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
  1816. { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884 },
  1817. { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884 },
  1818. { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
  1819. { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
  1820. { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1884 },
  1821. { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
  1822. { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
  1823. { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
  1824. { .id = 0x11d4882a, .name = "AD1882A", .patch = patch_ad1882 },
  1825. { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 },
  1826. { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 },
  1827. {} /* terminator */
  1828. };
  1829. MODULE_ALIAS("snd-hda-codec-id:11d4*");
  1830. MODULE_LICENSE("GPL");
  1831. MODULE_DESCRIPTION("Analog Devices HD-audio codec");
  1832. static struct hda_codec_preset_list analog_list = {
  1833. .preset = snd_hda_preset_analog,
  1834. .owner = THIS_MODULE,
  1835. };
  1836. static int __init patch_analog_init(void)
  1837. {
  1838. return snd_hda_add_codec_preset(&analog_list);
  1839. }
  1840. static void __exit patch_analog_exit(void)
  1841. {
  1842. snd_hda_delete_codec_preset(&analog_list);
  1843. }
  1844. module_init(patch_analog_init)
  1845. module_exit(patch_analog_exit)