patch_analog.c 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200
  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. struct ad198x_spec {
  33. struct hda_gen_spec gen;
  34. /* for auto parser */
  35. int smux_paths[4];
  36. unsigned int cur_smux;
  37. hda_nid_t eapd_nid;
  38. unsigned int beep_amp; /* beep amp value, set via set_beep_amp() */
  39. };
  40. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  41. /* additional beep mixers; the actual parameters are overwritten at build */
  42. static const struct snd_kcontrol_new ad_beep_mixer[] = {
  43. HDA_CODEC_VOLUME("Beep Playback Volume", 0, 0, HDA_OUTPUT),
  44. HDA_CODEC_MUTE_BEEP("Beep Playback Switch", 0, 0, HDA_OUTPUT),
  45. { } /* end */
  46. };
  47. #define set_beep_amp(spec, nid, idx, dir) \
  48. ((spec)->beep_amp = HDA_COMPOSE_AMP_VAL(nid, 1, idx, dir)) /* mono */
  49. #else
  50. #define set_beep_amp(spec, nid, idx, dir) /* NOP */
  51. #endif
  52. #ifdef CONFIG_SND_HDA_INPUT_BEEP
  53. static int create_beep_ctls(struct hda_codec *codec)
  54. {
  55. struct ad198x_spec *spec = codec->spec;
  56. const struct snd_kcontrol_new *knew;
  57. if (!spec->beep_amp)
  58. return 0;
  59. for (knew = ad_beep_mixer ; knew->name; knew++) {
  60. int err;
  61. struct snd_kcontrol *kctl;
  62. kctl = snd_ctl_new1(knew, codec);
  63. if (!kctl)
  64. return -ENOMEM;
  65. kctl->private_value = spec->beep_amp;
  66. err = snd_hda_ctl_add(codec, 0, kctl);
  67. if (err < 0)
  68. return err;
  69. }
  70. return 0;
  71. }
  72. #else
  73. #define create_beep_ctls(codec) 0
  74. #endif
  75. static void ad198x_power_eapd_write(struct hda_codec *codec, hda_nid_t front,
  76. hda_nid_t hp)
  77. {
  78. if (snd_hda_query_pin_caps(codec, front) & AC_PINCAP_EAPD)
  79. snd_hda_codec_write(codec, front, 0, AC_VERB_SET_EAPD_BTLENABLE,
  80. !codec->inv_eapd ? 0x00 : 0x02);
  81. if (snd_hda_query_pin_caps(codec, hp) & AC_PINCAP_EAPD)
  82. snd_hda_codec_write(codec, hp, 0, AC_VERB_SET_EAPD_BTLENABLE,
  83. !codec->inv_eapd ? 0x00 : 0x02);
  84. }
  85. static void ad198x_power_eapd(struct hda_codec *codec)
  86. {
  87. /* We currently only handle front, HP */
  88. switch (codec->vendor_id) {
  89. case 0x11d41882:
  90. case 0x11d4882a:
  91. case 0x11d41884:
  92. case 0x11d41984:
  93. case 0x11d41883:
  94. case 0x11d4184a:
  95. case 0x11d4194a:
  96. case 0x11d4194b:
  97. case 0x11d41988:
  98. case 0x11d4198b:
  99. case 0x11d4989a:
  100. case 0x11d4989b:
  101. ad198x_power_eapd_write(codec, 0x12, 0x11);
  102. break;
  103. case 0x11d41981:
  104. case 0x11d41983:
  105. ad198x_power_eapd_write(codec, 0x05, 0x06);
  106. break;
  107. case 0x11d41986:
  108. ad198x_power_eapd_write(codec, 0x1b, 0x1a);
  109. break;
  110. }
  111. }
  112. static void ad198x_shutup(struct hda_codec *codec)
  113. {
  114. snd_hda_shutup_pins(codec);
  115. ad198x_power_eapd(codec);
  116. }
  117. #ifdef CONFIG_PM
  118. static int ad198x_suspend(struct hda_codec *codec)
  119. {
  120. ad198x_shutup(codec);
  121. return 0;
  122. }
  123. #endif
  124. /* follow EAPD via vmaster hook */
  125. static void ad_vmaster_eapd_hook(void *private_data, int enabled)
  126. {
  127. struct hda_codec *codec = private_data;
  128. struct ad198x_spec *spec = codec->spec;
  129. if (!spec->eapd_nid)
  130. return;
  131. if (codec->inv_eapd)
  132. enabled = !enabled;
  133. snd_hda_codec_update_cache(codec, spec->eapd_nid, 0,
  134. AC_VERB_SET_EAPD_BTLENABLE,
  135. enabled ? 0x02 : 0x00);
  136. }
  137. /*
  138. * Automatic parse of I/O pins from the BIOS configuration
  139. */
  140. static int ad198x_auto_build_controls(struct hda_codec *codec)
  141. {
  142. int err;
  143. err = snd_hda_gen_build_controls(codec);
  144. if (err < 0)
  145. return err;
  146. err = create_beep_ctls(codec);
  147. if (err < 0)
  148. return err;
  149. return 0;
  150. }
  151. static const struct hda_codec_ops ad198x_auto_patch_ops = {
  152. .build_controls = ad198x_auto_build_controls,
  153. .build_pcms = snd_hda_gen_build_pcms,
  154. .init = snd_hda_gen_init,
  155. .free = snd_hda_gen_free,
  156. .unsol_event = snd_hda_jack_unsol_event,
  157. #ifdef CONFIG_PM
  158. .check_power_status = snd_hda_gen_check_power_status,
  159. .suspend = ad198x_suspend,
  160. #endif
  161. .reboot_notify = ad198x_shutup,
  162. };
  163. static int ad198x_parse_auto_config(struct hda_codec *codec, bool indep_hp)
  164. {
  165. struct ad198x_spec *spec = codec->spec;
  166. struct auto_pin_cfg *cfg = &spec->gen.autocfg;
  167. int err;
  168. codec->spdif_status_reset = 1;
  169. codec->no_trigger_sense = 1;
  170. codec->no_sticky_stream = 1;
  171. spec->gen.indep_hp = indep_hp;
  172. spec->gen.add_stereo_mix_input = 1;
  173. err = snd_hda_parse_pin_defcfg(codec, cfg, NULL, 0);
  174. if (err < 0)
  175. return err;
  176. err = snd_hda_gen_parse_auto_config(codec, cfg);
  177. if (err < 0)
  178. return err;
  179. codec->patch_ops = ad198x_auto_patch_ops;
  180. return 0;
  181. }
  182. /*
  183. * AD1986A specific
  184. */
  185. static int alloc_ad_spec(struct hda_codec *codec)
  186. {
  187. struct ad198x_spec *spec;
  188. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  189. if (!spec)
  190. return -ENOMEM;
  191. codec->spec = spec;
  192. snd_hda_gen_spec_init(&spec->gen);
  193. return 0;
  194. }
  195. /*
  196. * AD1986A fixup codes
  197. */
  198. /* Lenovo N100 seems to report the reversed bit for HP jack-sensing */
  199. static void ad_fixup_inv_jack_detect(struct hda_codec *codec,
  200. const struct hda_fixup *fix, int action)
  201. {
  202. struct ad198x_spec *spec = codec->spec;
  203. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  204. codec->inv_jack_detect = 1;
  205. spec->gen.keep_eapd_on = 1;
  206. spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook;
  207. spec->eapd_nid = 0x1b;
  208. }
  209. }
  210. /* Toshiba Satellite L40 implements EAPD in a standard way unlike others */
  211. static void ad1986a_fixup_eapd(struct hda_codec *codec,
  212. const struct hda_fixup *fix, int action)
  213. {
  214. struct ad198x_spec *spec = codec->spec;
  215. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  216. codec->inv_eapd = 0;
  217. spec->gen.keep_eapd_on = 1;
  218. spec->eapd_nid = 0x1b;
  219. }
  220. }
  221. enum {
  222. AD1986A_FIXUP_INV_JACK_DETECT,
  223. AD1986A_FIXUP_ULTRA,
  224. AD1986A_FIXUP_SAMSUNG,
  225. AD1986A_FIXUP_3STACK,
  226. AD1986A_FIXUP_LAPTOP,
  227. AD1986A_FIXUP_LAPTOP_IMIC,
  228. AD1986A_FIXUP_EAPD,
  229. };
  230. static const struct hda_fixup ad1986a_fixups[] = {
  231. [AD1986A_FIXUP_INV_JACK_DETECT] = {
  232. .type = HDA_FIXUP_FUNC,
  233. .v.func = ad_fixup_inv_jack_detect,
  234. },
  235. [AD1986A_FIXUP_ULTRA] = {
  236. .type = HDA_FIXUP_PINS,
  237. .v.pins = (const struct hda_pintbl[]) {
  238. { 0x1b, 0x90170110 }, /* speaker */
  239. { 0x1d, 0x90a7013e }, /* int mic */
  240. {}
  241. },
  242. },
  243. [AD1986A_FIXUP_SAMSUNG] = {
  244. .type = HDA_FIXUP_PINS,
  245. .v.pins = (const struct hda_pintbl[]) {
  246. { 0x1b, 0x90170110 }, /* speaker */
  247. { 0x1d, 0x90a7013e }, /* int mic */
  248. { 0x20, 0x411111f0 }, /* N/A */
  249. { 0x24, 0x411111f0 }, /* N/A */
  250. {}
  251. },
  252. },
  253. [AD1986A_FIXUP_3STACK] = {
  254. .type = HDA_FIXUP_PINS,
  255. .v.pins = (const struct hda_pintbl[]) {
  256. { 0x1a, 0x02214021 }, /* headphone */
  257. { 0x1b, 0x01014011 }, /* front */
  258. { 0x1c, 0x01813030 }, /* line-in */
  259. { 0x1d, 0x01a19020 }, /* rear mic */
  260. { 0x1e, 0x411111f0 }, /* N/A */
  261. { 0x1f, 0x02a190f0 }, /* mic */
  262. { 0x20, 0x411111f0 }, /* N/A */
  263. {}
  264. },
  265. },
  266. [AD1986A_FIXUP_LAPTOP] = {
  267. .type = HDA_FIXUP_PINS,
  268. .v.pins = (const struct hda_pintbl[]) {
  269. { 0x1a, 0x02214021 }, /* headphone */
  270. { 0x1b, 0x90170110 }, /* speaker */
  271. { 0x1c, 0x411111f0 }, /* N/A */
  272. { 0x1d, 0x411111f0 }, /* N/A */
  273. { 0x1e, 0x411111f0 }, /* N/A */
  274. { 0x1f, 0x02a191f0 }, /* mic */
  275. { 0x20, 0x411111f0 }, /* N/A */
  276. {}
  277. },
  278. },
  279. [AD1986A_FIXUP_LAPTOP_IMIC] = {
  280. .type = HDA_FIXUP_PINS,
  281. .v.pins = (const struct hda_pintbl[]) {
  282. { 0x1d, 0x90a7013e }, /* int mic */
  283. {}
  284. },
  285. .chained_before = 1,
  286. .chain_id = AD1986A_FIXUP_LAPTOP,
  287. },
  288. [AD1986A_FIXUP_EAPD] = {
  289. .type = HDA_FIXUP_FUNC,
  290. .v.func = ad1986a_fixup_eapd,
  291. },
  292. };
  293. static const struct snd_pci_quirk ad1986a_fixup_tbl[] = {
  294. SND_PCI_QUIRK(0x103c, 0x30af, "HP B2800", AD1986A_FIXUP_LAPTOP_IMIC),
  295. SND_PCI_QUIRK_MASK(0x1043, 0xff00, 0x8100, "ASUS P5", AD1986A_FIXUP_3STACK),
  296. SND_PCI_QUIRK_MASK(0x1043, 0xff00, 0x8200, "ASUS M2", AD1986A_FIXUP_3STACK),
  297. SND_PCI_QUIRK(0x10de, 0xcb84, "ASUS A8N-VM", AD1986A_FIXUP_3STACK),
  298. SND_PCI_QUIRK(0x1179, 0xff40, "Toshiba Satellite L40", AD1986A_FIXUP_EAPD),
  299. SND_PCI_QUIRK(0x144d, 0xc01e, "FSC V2060", AD1986A_FIXUP_LAPTOP),
  300. SND_PCI_QUIRK_MASK(0x144d, 0xff00, 0xc000, "Samsung", AD1986A_FIXUP_SAMSUNG),
  301. SND_PCI_QUIRK(0x144d, 0xc027, "Samsung Q1", AD1986A_FIXUP_ULTRA),
  302. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo N100", AD1986A_FIXUP_INV_JACK_DETECT),
  303. SND_PCI_QUIRK(0x17aa, 0x1011, "Lenovo M55", AD1986A_FIXUP_3STACK),
  304. SND_PCI_QUIRK(0x17aa, 0x1017, "Lenovo A60", AD1986A_FIXUP_3STACK),
  305. {}
  306. };
  307. static const struct hda_model_fixup ad1986a_fixup_models[] = {
  308. { .id = AD1986A_FIXUP_3STACK, .name = "3stack" },
  309. { .id = AD1986A_FIXUP_LAPTOP, .name = "laptop" },
  310. { .id = AD1986A_FIXUP_LAPTOP_IMIC, .name = "laptop-imic" },
  311. { .id = AD1986A_FIXUP_LAPTOP_IMIC, .name = "laptop-eapd" }, /* alias */
  312. {}
  313. };
  314. /*
  315. */
  316. static int patch_ad1986a(struct hda_codec *codec)
  317. {
  318. int err;
  319. struct ad198x_spec *spec;
  320. static hda_nid_t preferred_pairs[] = {
  321. 0x1a, 0x03,
  322. 0x1b, 0x03,
  323. 0x1c, 0x04,
  324. 0x1d, 0x05,
  325. 0x1e, 0x03,
  326. 0
  327. };
  328. err = alloc_ad_spec(codec);
  329. if (err < 0)
  330. return err;
  331. spec = codec->spec;
  332. /* AD1986A has the inverted EAPD implementation */
  333. codec->inv_eapd = 1;
  334. spec->gen.mixer_nid = 0x07;
  335. spec->gen.beep_nid = 0x19;
  336. set_beep_amp(spec, 0x18, 0, HDA_OUTPUT);
  337. /* AD1986A has a hardware problem that it can't share a stream
  338. * with multiple output pins. The copy of front to surrounds
  339. * causes noisy or silent outputs at a certain timing, e.g.
  340. * changing the volume.
  341. * So, let's disable the shared stream.
  342. */
  343. spec->gen.multiout.no_share_stream = 1;
  344. /* give fixed DAC/pin pairs */
  345. spec->gen.preferred_dacs = preferred_pairs;
  346. /* AD1986A can't manage the dynamic pin on/off smoothly */
  347. spec->gen.auto_mute_via_amp = 1;
  348. snd_hda_pick_fixup(codec, ad1986a_fixup_models, ad1986a_fixup_tbl,
  349. ad1986a_fixups);
  350. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  351. err = ad198x_parse_auto_config(codec, false);
  352. if (err < 0) {
  353. snd_hda_gen_free(codec);
  354. return err;
  355. }
  356. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  357. return 0;
  358. }
  359. /*
  360. * AD1983 specific
  361. */
  362. /*
  363. * SPDIF mux control for AD1983 auto-parser
  364. */
  365. static int ad1983_auto_smux_enum_info(struct snd_kcontrol *kcontrol,
  366. struct snd_ctl_elem_info *uinfo)
  367. {
  368. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  369. struct ad198x_spec *spec = codec->spec;
  370. static const char * const texts2[] = { "PCM", "ADC" };
  371. static const char * const texts3[] = { "PCM", "ADC1", "ADC2" };
  372. hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
  373. int num_conns = snd_hda_get_num_conns(codec, dig_out);
  374. if (num_conns == 2)
  375. return snd_hda_enum_helper_info(kcontrol, uinfo, 2, texts2);
  376. else if (num_conns == 3)
  377. return snd_hda_enum_helper_info(kcontrol, uinfo, 3, texts3);
  378. else
  379. return -EINVAL;
  380. }
  381. static int ad1983_auto_smux_enum_get(struct snd_kcontrol *kcontrol,
  382. struct snd_ctl_elem_value *ucontrol)
  383. {
  384. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  385. struct ad198x_spec *spec = codec->spec;
  386. ucontrol->value.enumerated.item[0] = spec->cur_smux;
  387. return 0;
  388. }
  389. static int ad1983_auto_smux_enum_put(struct snd_kcontrol *kcontrol,
  390. struct snd_ctl_elem_value *ucontrol)
  391. {
  392. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  393. struct ad198x_spec *spec = codec->spec;
  394. unsigned int val = ucontrol->value.enumerated.item[0];
  395. hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
  396. int num_conns = snd_hda_get_num_conns(codec, dig_out);
  397. if (val >= num_conns)
  398. return -EINVAL;
  399. if (spec->cur_smux == val)
  400. return 0;
  401. spec->cur_smux = val;
  402. snd_hda_codec_write_cache(codec, dig_out, 0,
  403. AC_VERB_SET_CONNECT_SEL, val);
  404. return 1;
  405. }
  406. static struct snd_kcontrol_new ad1983_auto_smux_mixer = {
  407. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  408. .name = "IEC958 Playback Source",
  409. .info = ad1983_auto_smux_enum_info,
  410. .get = ad1983_auto_smux_enum_get,
  411. .put = ad1983_auto_smux_enum_put,
  412. };
  413. static int ad1983_add_spdif_mux_ctl(struct hda_codec *codec)
  414. {
  415. struct ad198x_spec *spec = codec->spec;
  416. hda_nid_t dig_out = spec->gen.multiout.dig_out_nid;
  417. int num_conns;
  418. if (!dig_out)
  419. return 0;
  420. num_conns = snd_hda_get_num_conns(codec, dig_out);
  421. if (num_conns != 2 && num_conns != 3)
  422. return 0;
  423. if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1983_auto_smux_mixer))
  424. return -ENOMEM;
  425. return 0;
  426. }
  427. static int patch_ad1983(struct hda_codec *codec)
  428. {
  429. struct ad198x_spec *spec;
  430. static hda_nid_t conn_0c[] = { 0x08 };
  431. static hda_nid_t conn_0d[] = { 0x09 };
  432. int err;
  433. err = alloc_ad_spec(codec);
  434. if (err < 0)
  435. return err;
  436. spec = codec->spec;
  437. spec->gen.mixer_nid = 0x0e;
  438. spec->gen.beep_nid = 0x10;
  439. set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
  440. /* limit the loopback routes not to confuse the parser */
  441. snd_hda_override_conn_list(codec, 0x0c, ARRAY_SIZE(conn_0c), conn_0c);
  442. snd_hda_override_conn_list(codec, 0x0d, ARRAY_SIZE(conn_0d), conn_0d);
  443. err = ad198x_parse_auto_config(codec, false);
  444. if (err < 0)
  445. goto error;
  446. err = ad1983_add_spdif_mux_ctl(codec);
  447. if (err < 0)
  448. goto error;
  449. return 0;
  450. error:
  451. snd_hda_gen_free(codec);
  452. return err;
  453. }
  454. /*
  455. * AD1981 HD specific
  456. */
  457. static void ad1981_fixup_hp_eapd(struct hda_codec *codec,
  458. const struct hda_fixup *fix, int action)
  459. {
  460. struct ad198x_spec *spec = codec->spec;
  461. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  462. spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook;
  463. spec->eapd_nid = 0x05;
  464. }
  465. }
  466. /* set the upper-limit for mixer amp to 0dB for avoiding the possible
  467. * damage by overloading
  468. */
  469. static void ad1981_fixup_amp_override(struct hda_codec *codec,
  470. const struct hda_fixup *fix, int action)
  471. {
  472. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  473. snd_hda_override_amp_caps(codec, 0x11, HDA_INPUT,
  474. (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
  475. (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
  476. (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
  477. (1 << AC_AMPCAP_MUTE_SHIFT));
  478. }
  479. enum {
  480. AD1981_FIXUP_AMP_OVERRIDE,
  481. AD1981_FIXUP_HP_EAPD,
  482. };
  483. static const struct hda_fixup ad1981_fixups[] = {
  484. [AD1981_FIXUP_AMP_OVERRIDE] = {
  485. .type = HDA_FIXUP_FUNC,
  486. .v.func = ad1981_fixup_amp_override,
  487. },
  488. [AD1981_FIXUP_HP_EAPD] = {
  489. .type = HDA_FIXUP_FUNC,
  490. .v.func = ad1981_fixup_hp_eapd,
  491. .chained = true,
  492. .chain_id = AD1981_FIXUP_AMP_OVERRIDE,
  493. },
  494. };
  495. static const struct snd_pci_quirk ad1981_fixup_tbl[] = {
  496. SND_PCI_QUIRK_VENDOR(0x1014, "Lenovo", AD1981_FIXUP_AMP_OVERRIDE),
  497. SND_PCI_QUIRK_VENDOR(0x103c, "HP", AD1981_FIXUP_HP_EAPD),
  498. SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo", AD1981_FIXUP_AMP_OVERRIDE),
  499. /* HP nx6320 (reversed SSID, H/W bug) */
  500. SND_PCI_QUIRK(0x30b0, 0x103c, "HP nx6320", AD1981_FIXUP_HP_EAPD),
  501. {}
  502. };
  503. static int patch_ad1981(struct hda_codec *codec)
  504. {
  505. struct ad198x_spec *spec;
  506. int err;
  507. err = alloc_ad_spec(codec);
  508. if (err < 0)
  509. return -ENOMEM;
  510. spec = codec->spec;
  511. spec->gen.mixer_nid = 0x0e;
  512. spec->gen.beep_nid = 0x10;
  513. set_beep_amp(spec, 0x0d, 0, HDA_OUTPUT);
  514. snd_hda_pick_fixup(codec, NULL, ad1981_fixup_tbl, ad1981_fixups);
  515. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  516. err = ad198x_parse_auto_config(codec, false);
  517. if (err < 0)
  518. goto error;
  519. err = ad1983_add_spdif_mux_ctl(codec);
  520. if (err < 0)
  521. goto error;
  522. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  523. return 0;
  524. error:
  525. snd_hda_gen_free(codec);
  526. return err;
  527. }
  528. /*
  529. * AD1988
  530. *
  531. * Output pins and routes
  532. *
  533. * Pin Mix Sel DAC (*)
  534. * port-A 0x11 (mute/hp) <- 0x22 <- 0x37 <- 03/04/06
  535. * port-B 0x14 (mute/hp) <- 0x2b <- 0x30 <- 03/04/06
  536. * port-C 0x15 (mute) <- 0x2c <- 0x31 <- 05/0a
  537. * port-D 0x12 (mute/hp) <- 0x29 <- 04
  538. * port-E 0x17 (mute/hp) <- 0x26 <- 0x32 <- 05/0a
  539. * port-F 0x16 (mute) <- 0x2a <- 06
  540. * port-G 0x24 (mute) <- 0x27 <- 05
  541. * port-H 0x25 (mute) <- 0x28 <- 0a
  542. * mono 0x13 (mute/amp)<- 0x1e <- 0x36 <- 03/04/06
  543. *
  544. * DAC0 = 03h, DAC1 = 04h, DAC2 = 05h, DAC3 = 06h, DAC4 = 0ah
  545. * (*) DAC2/3/4 are swapped to DAC3/4/2 on AD198A rev.2 due to a h/w bug.
  546. *
  547. * Input pins and routes
  548. *
  549. * pin boost mix input # / adc input #
  550. * port-A 0x11 -> 0x38 -> mix 2, ADC 0
  551. * port-B 0x14 -> 0x39 -> mix 0, ADC 1
  552. * port-C 0x15 -> 0x3a -> 33:0 - mix 1, ADC 2
  553. * port-D 0x12 -> 0x3d -> mix 3, ADC 8
  554. * port-E 0x17 -> 0x3c -> 34:0 - mix 4, ADC 4
  555. * port-F 0x16 -> 0x3b -> mix 5, ADC 3
  556. * port-G 0x24 -> N/A -> 33:1 - mix 1, 34:1 - mix 4, ADC 6
  557. * port-H 0x25 -> N/A -> 33:2 - mix 1, 34:2 - mix 4, ADC 7
  558. *
  559. *
  560. * DAC assignment
  561. * 6stack - front/surr/CLFE/side/opt DACs - 04/06/05/0a/03
  562. * 3stack - front/surr/CLFE/opt DACs - 04/05/0a/03
  563. *
  564. * Inputs of Analog Mix (0x20)
  565. * 0:Port-B (front mic)
  566. * 1:Port-C/G/H (line-in)
  567. * 2:Port-A
  568. * 3:Port-D (line-in/2)
  569. * 4:Port-E/G/H (mic-in)
  570. * 5:Port-F (mic2-in)
  571. * 6:CD
  572. * 7:Beep
  573. *
  574. * ADC selection
  575. * 0:Port-A
  576. * 1:Port-B (front mic-in)
  577. * 2:Port-C (line-in)
  578. * 3:Port-F (mic2-in)
  579. * 4:Port-E (mic-in)
  580. * 5:CD
  581. * 6:Port-G
  582. * 7:Port-H
  583. * 8:Port-D (line-in/2)
  584. * 9:Mix
  585. *
  586. * Proposed pin assignments by the datasheet
  587. *
  588. * 6-stack
  589. * Port-A front headphone
  590. * B front mic-in
  591. * C rear line-in
  592. * D rear front-out
  593. * E rear mic-in
  594. * F rear surround
  595. * G rear CLFE
  596. * H rear side
  597. *
  598. * 3-stack
  599. * Port-A front headphone
  600. * B front mic
  601. * C rear line-in/surround
  602. * D rear front-out
  603. * E rear mic-in/CLFE
  604. *
  605. * laptop
  606. * Port-A headphone
  607. * B mic-in
  608. * C docking station
  609. * D internal speaker (with EAPD)
  610. * E/F quad mic array
  611. */
  612. #ifdef ENABLE_AD_STATIC_QUIRKS
  613. static int ad198x_ch_mode_info(struct snd_kcontrol *kcontrol,
  614. struct snd_ctl_elem_info *uinfo)
  615. {
  616. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  617. struct ad198x_spec *spec = codec->spec;
  618. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  619. spec->num_channel_mode);
  620. }
  621. static int ad198x_ch_mode_get(struct snd_kcontrol *kcontrol,
  622. struct snd_ctl_elem_value *ucontrol)
  623. {
  624. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  625. struct ad198x_spec *spec = codec->spec;
  626. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  627. spec->num_channel_mode, spec->multiout.max_channels);
  628. }
  629. static int ad198x_ch_mode_put(struct snd_kcontrol *kcontrol,
  630. struct snd_ctl_elem_value *ucontrol)
  631. {
  632. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  633. struct ad198x_spec *spec = codec->spec;
  634. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  635. spec->num_channel_mode,
  636. &spec->multiout.max_channels);
  637. if (err >= 0 && spec->need_dac_fix)
  638. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  639. return err;
  640. }
  641. #endif /* ENABLE_AD_STATIC_QUIRKS */
  642. static int ad1988_auto_smux_enum_info(struct snd_kcontrol *kcontrol,
  643. struct snd_ctl_elem_info *uinfo)
  644. {
  645. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  646. static const char * const texts[] = {
  647. "PCM", "ADC1", "ADC2", "ADC3",
  648. };
  649. int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
  650. if (num_conns > 4)
  651. num_conns = 4;
  652. return snd_hda_enum_helper_info(kcontrol, uinfo, num_conns, texts);
  653. }
  654. static int ad1988_auto_smux_enum_get(struct snd_kcontrol *kcontrol,
  655. struct snd_ctl_elem_value *ucontrol)
  656. {
  657. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  658. struct ad198x_spec *spec = codec->spec;
  659. ucontrol->value.enumerated.item[0] = spec->cur_smux;
  660. return 0;
  661. }
  662. static int ad1988_auto_smux_enum_put(struct snd_kcontrol *kcontrol,
  663. struct snd_ctl_elem_value *ucontrol)
  664. {
  665. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  666. struct ad198x_spec *spec = codec->spec;
  667. unsigned int val = ucontrol->value.enumerated.item[0];
  668. struct nid_path *path;
  669. int num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
  670. if (val >= num_conns)
  671. return -EINVAL;
  672. if (spec->cur_smux == val)
  673. return 0;
  674. mutex_lock(&codec->control_mutex);
  675. codec->cached_write = 1;
  676. path = snd_hda_get_path_from_idx(codec,
  677. spec->smux_paths[spec->cur_smux]);
  678. if (path)
  679. snd_hda_activate_path(codec, path, false, true);
  680. path = snd_hda_get_path_from_idx(codec, spec->smux_paths[val]);
  681. if (path)
  682. snd_hda_activate_path(codec, path, true, true);
  683. spec->cur_smux = val;
  684. codec->cached_write = 0;
  685. mutex_unlock(&codec->control_mutex);
  686. snd_hda_codec_flush_cache(codec); /* flush the updates */
  687. return 1;
  688. }
  689. static struct snd_kcontrol_new ad1988_auto_smux_mixer = {
  690. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  691. .name = "IEC958 Playback Source",
  692. .info = ad1988_auto_smux_enum_info,
  693. .get = ad1988_auto_smux_enum_get,
  694. .put = ad1988_auto_smux_enum_put,
  695. };
  696. static int ad1988_auto_init(struct hda_codec *codec)
  697. {
  698. struct ad198x_spec *spec = codec->spec;
  699. int i, err;
  700. err = snd_hda_gen_init(codec);
  701. if (err < 0)
  702. return err;
  703. if (!spec->gen.autocfg.dig_outs)
  704. return 0;
  705. for (i = 0; i < 4; i++) {
  706. struct nid_path *path;
  707. path = snd_hda_get_path_from_idx(codec, spec->smux_paths[i]);
  708. if (path)
  709. snd_hda_activate_path(codec, path, path->active, false);
  710. }
  711. return 0;
  712. }
  713. static int ad1988_add_spdif_mux_ctl(struct hda_codec *codec)
  714. {
  715. struct ad198x_spec *spec = codec->spec;
  716. int i, num_conns;
  717. /* we create four static faked paths, since AD codecs have odd
  718. * widget connections regarding the SPDIF out source
  719. */
  720. static struct nid_path fake_paths[4] = {
  721. {
  722. .depth = 3,
  723. .path = { 0x02, 0x1d, 0x1b },
  724. .idx = { 0, 0, 0 },
  725. .multi = { 0, 0, 0 },
  726. },
  727. {
  728. .depth = 4,
  729. .path = { 0x08, 0x0b, 0x1d, 0x1b },
  730. .idx = { 0, 0, 1, 0 },
  731. .multi = { 0, 1, 0, 0 },
  732. },
  733. {
  734. .depth = 4,
  735. .path = { 0x09, 0x0b, 0x1d, 0x1b },
  736. .idx = { 0, 1, 1, 0 },
  737. .multi = { 0, 1, 0, 0 },
  738. },
  739. {
  740. .depth = 4,
  741. .path = { 0x0f, 0x0b, 0x1d, 0x1b },
  742. .idx = { 0, 2, 1, 0 },
  743. .multi = { 0, 1, 0, 0 },
  744. },
  745. };
  746. /* SPDIF source mux appears to be present only on AD1988A */
  747. if (!spec->gen.autocfg.dig_outs ||
  748. get_wcaps_type(get_wcaps(codec, 0x1d)) != AC_WID_AUD_MIX)
  749. return 0;
  750. num_conns = snd_hda_get_num_conns(codec, 0x0b) + 1;
  751. if (num_conns != 3 && num_conns != 4)
  752. return 0;
  753. for (i = 0; i < num_conns; i++) {
  754. struct nid_path *path = snd_array_new(&spec->gen.paths);
  755. if (!path)
  756. return -ENOMEM;
  757. *path = fake_paths[i];
  758. if (!i)
  759. path->active = 1;
  760. spec->smux_paths[i] = snd_hda_get_path_idx(codec, path);
  761. }
  762. if (!snd_hda_gen_add_kctl(&spec->gen, NULL, &ad1988_auto_smux_mixer))
  763. return -ENOMEM;
  764. codec->patch_ops.init = ad1988_auto_init;
  765. return 0;
  766. }
  767. /*
  768. */
  769. enum {
  770. AD1988_FIXUP_6STACK_DIG,
  771. };
  772. static const struct hda_fixup ad1988_fixups[] = {
  773. [AD1988_FIXUP_6STACK_DIG] = {
  774. .type = HDA_FIXUP_PINS,
  775. .v.pins = (const struct hda_pintbl[]) {
  776. { 0x11, 0x02214130 }, /* front-hp */
  777. { 0x12, 0x01014010 }, /* line-out */
  778. { 0x14, 0x02a19122 }, /* front-mic */
  779. { 0x15, 0x01813021 }, /* line-in */
  780. { 0x16, 0x01011012 }, /* line-out */
  781. { 0x17, 0x01a19020 }, /* mic */
  782. { 0x1b, 0x0145f1f0 }, /* SPDIF */
  783. { 0x24, 0x01016011 }, /* line-out */
  784. { 0x25, 0x01012013 }, /* line-out */
  785. { }
  786. }
  787. },
  788. };
  789. static const struct hda_model_fixup ad1988_fixup_models[] = {
  790. { .id = AD1988_FIXUP_6STACK_DIG, .name = "6stack-dig" },
  791. {}
  792. };
  793. static int patch_ad1988(struct hda_codec *codec)
  794. {
  795. struct ad198x_spec *spec;
  796. int err;
  797. err = alloc_ad_spec(codec);
  798. if (err < 0)
  799. return err;
  800. spec = codec->spec;
  801. spec->gen.mixer_nid = 0x20;
  802. spec->gen.mixer_merge_nid = 0x21;
  803. spec->gen.beep_nid = 0x10;
  804. set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
  805. snd_hda_pick_fixup(codec, ad1988_fixup_models, NULL, ad1988_fixups);
  806. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  807. err = ad198x_parse_auto_config(codec, true);
  808. if (err < 0)
  809. goto error;
  810. err = ad1988_add_spdif_mux_ctl(codec);
  811. if (err < 0)
  812. goto error;
  813. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  814. return 0;
  815. error:
  816. snd_hda_gen_free(codec);
  817. return err;
  818. }
  819. /*
  820. * AD1884 / AD1984
  821. *
  822. * port-B - front line/mic-in
  823. * port-E - aux in/out
  824. * port-F - aux in/out
  825. * port-C - rear line/mic-in
  826. * port-D - rear line/hp-out
  827. * port-A - front line/hp-out
  828. *
  829. * AD1984 = AD1884 + two digital mic-ins
  830. *
  831. * AD1883 / AD1884A / AD1984A / AD1984B
  832. *
  833. * port-B (0x14) - front mic-in
  834. * port-E (0x1c) - rear mic-in
  835. * port-F (0x16) - CD / ext out
  836. * port-C (0x15) - rear line-in
  837. * port-D (0x12) - rear line-out
  838. * port-A (0x11) - front hp-out
  839. *
  840. * AD1984A = AD1884A + digital-mic
  841. * AD1883 = equivalent with AD1984A
  842. * AD1984B = AD1984A + extra SPDIF-out
  843. */
  844. /* set the upper-limit for mixer amp to 0dB for avoiding the possible
  845. * damage by overloading
  846. */
  847. static void ad1884_fixup_amp_override(struct hda_codec *codec,
  848. const struct hda_fixup *fix, int action)
  849. {
  850. if (action == HDA_FIXUP_ACT_PRE_PROBE)
  851. snd_hda_override_amp_caps(codec, 0x20, HDA_INPUT,
  852. (0x17 << AC_AMPCAP_OFFSET_SHIFT) |
  853. (0x17 << AC_AMPCAP_NUM_STEPS_SHIFT) |
  854. (0x05 << AC_AMPCAP_STEP_SIZE_SHIFT) |
  855. (1 << AC_AMPCAP_MUTE_SHIFT));
  856. }
  857. /* toggle GPIO1 according to the mute state */
  858. static void ad1884_vmaster_hp_gpio_hook(void *private_data, int enabled)
  859. {
  860. struct hda_codec *codec = private_data;
  861. struct ad198x_spec *spec = codec->spec;
  862. if (spec->eapd_nid)
  863. ad_vmaster_eapd_hook(private_data, enabled);
  864. snd_hda_codec_update_cache(codec, 0x01, 0,
  865. AC_VERB_SET_GPIO_DATA,
  866. enabled ? 0x00 : 0x02);
  867. }
  868. static void ad1884_fixup_hp_eapd(struct hda_codec *codec,
  869. const struct hda_fixup *fix, int action)
  870. {
  871. struct ad198x_spec *spec = codec->spec;
  872. static const struct hda_verb gpio_init_verbs[] = {
  873. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  874. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  875. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  876. {},
  877. };
  878. switch (action) {
  879. case HDA_FIXUP_ACT_PRE_PROBE:
  880. spec->gen.vmaster_mute.hook = ad1884_vmaster_hp_gpio_hook;
  881. spec->gen.own_eapd_ctl = 1;
  882. snd_hda_sequence_write_cache(codec, gpio_init_verbs);
  883. break;
  884. case HDA_FIXUP_ACT_PROBE:
  885. if (spec->gen.autocfg.line_out_type == AUTO_PIN_SPEAKER_OUT)
  886. spec->eapd_nid = spec->gen.autocfg.line_out_pins[0];
  887. else
  888. spec->eapd_nid = spec->gen.autocfg.speaker_pins[0];
  889. break;
  890. }
  891. }
  892. static void ad1884_fixup_thinkpad(struct hda_codec *codec,
  893. const struct hda_fixup *fix, int action)
  894. {
  895. struct ad198x_spec *spec = codec->spec;
  896. if (action == HDA_FIXUP_ACT_PRE_PROBE) {
  897. spec->gen.keep_eapd_on = 1;
  898. spec->gen.vmaster_mute.hook = ad_vmaster_eapd_hook;
  899. spec->eapd_nid = 0x12;
  900. }
  901. }
  902. /* set magic COEFs for dmic */
  903. static const struct hda_verb ad1884_dmic_init_verbs[] = {
  904. {0x01, AC_VERB_SET_COEF_INDEX, 0x13f7},
  905. {0x01, AC_VERB_SET_PROC_COEF, 0x08},
  906. {}
  907. };
  908. enum {
  909. AD1884_FIXUP_AMP_OVERRIDE,
  910. AD1884_FIXUP_HP_EAPD,
  911. AD1884_FIXUP_DMIC_COEF,
  912. AD1884_FIXUP_THINKPAD,
  913. AD1884_FIXUP_HP_TOUCHSMART,
  914. };
  915. static const struct hda_fixup ad1884_fixups[] = {
  916. [AD1884_FIXUP_AMP_OVERRIDE] = {
  917. .type = HDA_FIXUP_FUNC,
  918. .v.func = ad1884_fixup_amp_override,
  919. },
  920. [AD1884_FIXUP_HP_EAPD] = {
  921. .type = HDA_FIXUP_FUNC,
  922. .v.func = ad1884_fixup_hp_eapd,
  923. .chained = true,
  924. .chain_id = AD1884_FIXUP_AMP_OVERRIDE,
  925. },
  926. [AD1884_FIXUP_DMIC_COEF] = {
  927. .type = HDA_FIXUP_VERBS,
  928. .v.verbs = ad1884_dmic_init_verbs,
  929. },
  930. [AD1884_FIXUP_THINKPAD] = {
  931. .type = HDA_FIXUP_FUNC,
  932. .v.func = ad1884_fixup_thinkpad,
  933. .chained = true,
  934. .chain_id = AD1884_FIXUP_DMIC_COEF,
  935. },
  936. [AD1884_FIXUP_HP_TOUCHSMART] = {
  937. .type = HDA_FIXUP_VERBS,
  938. .v.verbs = ad1884_dmic_init_verbs,
  939. .chained = true,
  940. .chain_id = AD1884_FIXUP_HP_EAPD,
  941. },
  942. };
  943. static const struct snd_pci_quirk ad1884_fixup_tbl[] = {
  944. SND_PCI_QUIRK(0x103c, 0x2a82, "HP Touchsmart", AD1884_FIXUP_HP_TOUCHSMART),
  945. SND_PCI_QUIRK_VENDOR(0x103c, "HP", AD1884_FIXUP_HP_EAPD),
  946. SND_PCI_QUIRK_VENDOR(0x17aa, "Lenovo Thinkpad", AD1884_FIXUP_THINKPAD),
  947. {}
  948. };
  949. static int patch_ad1884(struct hda_codec *codec)
  950. {
  951. struct ad198x_spec *spec;
  952. int err;
  953. err = alloc_ad_spec(codec);
  954. if (err < 0)
  955. return err;
  956. spec = codec->spec;
  957. spec->gen.mixer_nid = 0x20;
  958. spec->gen.beep_nid = 0x10;
  959. set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
  960. snd_hda_pick_fixup(codec, NULL, ad1884_fixup_tbl, ad1884_fixups);
  961. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PRE_PROBE);
  962. err = ad198x_parse_auto_config(codec, true);
  963. if (err < 0)
  964. goto error;
  965. err = ad1983_add_spdif_mux_ctl(codec);
  966. if (err < 0)
  967. goto error;
  968. snd_hda_apply_fixup(codec, HDA_FIXUP_ACT_PROBE);
  969. return 0;
  970. error:
  971. snd_hda_gen_free(codec);
  972. return err;
  973. }
  974. /*
  975. * AD1882 / AD1882A
  976. *
  977. * port-A - front hp-out
  978. * port-B - front mic-in
  979. * port-C - rear line-in, shared surr-out (3stack)
  980. * port-D - rear line-out
  981. * port-E - rear mic-in, shared clfe-out (3stack)
  982. * port-F - rear surr-out (6stack)
  983. * port-G - rear clfe-out (6stack)
  984. */
  985. static int patch_ad1882(struct hda_codec *codec)
  986. {
  987. struct ad198x_spec *spec;
  988. int err;
  989. err = alloc_ad_spec(codec);
  990. if (err < 0)
  991. return err;
  992. spec = codec->spec;
  993. spec->gen.mixer_nid = 0x20;
  994. spec->gen.mixer_merge_nid = 0x21;
  995. spec->gen.beep_nid = 0x10;
  996. set_beep_amp(spec, 0x10, 0, HDA_OUTPUT);
  997. err = ad198x_parse_auto_config(codec, true);
  998. if (err < 0)
  999. goto error;
  1000. err = ad1988_add_spdif_mux_ctl(codec);
  1001. if (err < 0)
  1002. goto error;
  1003. return 0;
  1004. error:
  1005. snd_hda_gen_free(codec);
  1006. return err;
  1007. }
  1008. /*
  1009. * patch entries
  1010. */
  1011. static const struct hda_codec_preset snd_hda_preset_analog[] = {
  1012. { .id = 0x11d4184a, .name = "AD1884A", .patch = patch_ad1884 },
  1013. { .id = 0x11d41882, .name = "AD1882", .patch = patch_ad1882 },
  1014. { .id = 0x11d41883, .name = "AD1883", .patch = patch_ad1884 },
  1015. { .id = 0x11d41884, .name = "AD1884", .patch = patch_ad1884 },
  1016. { .id = 0x11d4194a, .name = "AD1984A", .patch = patch_ad1884 },
  1017. { .id = 0x11d4194b, .name = "AD1984B", .patch = patch_ad1884 },
  1018. { .id = 0x11d41981, .name = "AD1981", .patch = patch_ad1981 },
  1019. { .id = 0x11d41983, .name = "AD1983", .patch = patch_ad1983 },
  1020. { .id = 0x11d41984, .name = "AD1984", .patch = patch_ad1884 },
  1021. { .id = 0x11d41986, .name = "AD1986A", .patch = patch_ad1986a },
  1022. { .id = 0x11d41988, .name = "AD1988", .patch = patch_ad1988 },
  1023. { .id = 0x11d4198b, .name = "AD1988B", .patch = patch_ad1988 },
  1024. { .id = 0x11d4882a, .name = "AD1882A", .patch = patch_ad1882 },
  1025. { .id = 0x11d4989a, .name = "AD1989A", .patch = patch_ad1988 },
  1026. { .id = 0x11d4989b, .name = "AD1989B", .patch = patch_ad1988 },
  1027. {} /* terminator */
  1028. };
  1029. MODULE_ALIAS("snd-hda-codec-id:11d4*");
  1030. MODULE_LICENSE("GPL");
  1031. MODULE_DESCRIPTION("Analog Devices HD-audio codec");
  1032. static struct hda_codec_preset_list analog_list = {
  1033. .preset = snd_hda_preset_analog,
  1034. .owner = THIS_MODULE,
  1035. };
  1036. static int __init patch_analog_init(void)
  1037. {
  1038. return snd_hda_add_codec_preset(&analog_list);
  1039. }
  1040. static void __exit patch_analog_exit(void)
  1041. {
  1042. snd_hda_delete_codec_preset(&analog_list);
  1043. }
  1044. module_init(patch_analog_init)
  1045. module_exit(patch_analog_exit)