patch_analog.c 30 KB

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