patch_analog.c 29 KB

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