patch_sigmatel.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for SigmaTel STAC92xx
  5. *
  6. * Copyright (c) 2005 Embedded Alley Solutions, Inc.
  7. * Matt Porter <mporter@embeddedalley.com>
  8. *
  9. * Based on patch_cmedia.c and patch_realtek.c
  10. * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
  11. *
  12. * This driver is free software; you can redistribute it and/or modify
  13. * it under the terms of the GNU General Public License as published by
  14. * the Free Software Foundation; either version 2 of the License, or
  15. * (at your option) any later version.
  16. *
  17. * This driver is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU General Public License
  23. * along with this program; if not, write to the Free Software
  24. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  25. */
  26. #include <sound/driver.h>
  27. #include <linux/init.h>
  28. #include <linux/delay.h>
  29. #include <linux/slab.h>
  30. #include <linux/pci.h>
  31. #include <sound/core.h>
  32. #include <sound/asoundef.h>
  33. #include "hda_codec.h"
  34. #include "hda_local.h"
  35. #define NUM_CONTROL_ALLOC 32
  36. #define STAC_HP_EVENT 0x37
  37. #define STAC_UNSOL_ENABLE (AC_USRSP_EN | STAC_HP_EVENT)
  38. #define STAC_REF 0
  39. #define STAC_D945GTP3 1
  40. #define STAC_D945GTP5 2
  41. struct sigmatel_spec {
  42. struct snd_kcontrol_new *mixers[4];
  43. unsigned int num_mixers;
  44. int board_config;
  45. unsigned int surr_switch: 1;
  46. unsigned int line_switch: 1;
  47. unsigned int mic_switch: 1;
  48. unsigned int alt_switch: 1;
  49. /* playback */
  50. struct hda_multi_out multiout;
  51. hda_nid_t dac_nids[5];
  52. /* capture */
  53. hda_nid_t *adc_nids;
  54. unsigned int num_adcs;
  55. hda_nid_t *mux_nids;
  56. unsigned int num_muxes;
  57. hda_nid_t dig_in_nid;
  58. /* pin widgets */
  59. hda_nid_t *pin_nids;
  60. unsigned int num_pins;
  61. unsigned int *pin_configs;
  62. /* codec specific stuff */
  63. struct hda_verb *init;
  64. struct snd_kcontrol_new *mixer;
  65. /* capture source */
  66. struct hda_input_mux *input_mux;
  67. unsigned int cur_mux[3];
  68. /* i/o switches */
  69. unsigned int io_switch[2];
  70. struct hda_pcm pcm_rec[2]; /* PCM information */
  71. /* dynamic controls and input_mux */
  72. struct auto_pin_cfg autocfg;
  73. unsigned int num_kctl_alloc, num_kctl_used;
  74. struct snd_kcontrol_new *kctl_alloc;
  75. struct hda_input_mux private_imux;
  76. };
  77. static hda_nid_t stac9200_adc_nids[1] = {
  78. 0x03,
  79. };
  80. static hda_nid_t stac9200_mux_nids[1] = {
  81. 0x0c,
  82. };
  83. static hda_nid_t stac9200_dac_nids[1] = {
  84. 0x02,
  85. };
  86. static hda_nid_t stac922x_adc_nids[2] = {
  87. 0x06, 0x07,
  88. };
  89. static hda_nid_t stac922x_mux_nids[2] = {
  90. 0x12, 0x13,
  91. };
  92. static hda_nid_t stac927x_adc_nids[3] = {
  93. 0x07, 0x08, 0x09
  94. };
  95. static hda_nid_t stac927x_mux_nids[3] = {
  96. 0x15, 0x16, 0x17
  97. };
  98. static hda_nid_t stac9200_pin_nids[8] = {
  99. 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
  100. };
  101. static hda_nid_t stac922x_pin_nids[10] = {
  102. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  103. 0x0f, 0x10, 0x11, 0x15, 0x1b,
  104. };
  105. static hda_nid_t stac927x_pin_nids[14] = {
  106. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  107. 0x0f, 0x10, 0x11, 0x12, 0x13,
  108. 0x14, 0x21, 0x22, 0x23,
  109. };
  110. static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  111. {
  112. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  113. struct sigmatel_spec *spec = codec->spec;
  114. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  115. }
  116. static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  117. {
  118. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  119. struct sigmatel_spec *spec = codec->spec;
  120. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  121. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  122. return 0;
  123. }
  124. static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  125. {
  126. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  127. struct sigmatel_spec *spec = codec->spec;
  128. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  129. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  130. spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
  131. }
  132. static struct hda_verb stac9200_core_init[] = {
  133. /* set dac0mux for dac converter */
  134. { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  135. {}
  136. };
  137. static struct hda_verb stac922x_core_init[] = {
  138. /* set master volume and direct control */
  139. { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  140. {}
  141. };
  142. static struct hda_verb stac927x_core_init[] = {
  143. /* set master volume and direct control */
  144. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  145. {}
  146. };
  147. static struct snd_kcontrol_new stac9200_mixer[] = {
  148. HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
  149. HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
  150. {
  151. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  152. .name = "Input Source",
  153. .count = 1,
  154. .info = stac92xx_mux_enum_info,
  155. .get = stac92xx_mux_enum_get,
  156. .put = stac92xx_mux_enum_put,
  157. },
  158. HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
  159. HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
  160. HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
  161. { } /* end */
  162. };
  163. /* This needs to be generated dynamically based on sequence */
  164. static struct snd_kcontrol_new stac922x_mixer[] = {
  165. {
  166. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  167. .name = "Input Source",
  168. .count = 1,
  169. .info = stac92xx_mux_enum_info,
  170. .get = stac92xx_mux_enum_get,
  171. .put = stac92xx_mux_enum_put,
  172. },
  173. HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
  174. HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
  175. HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
  176. { } /* end */
  177. };
  178. static snd_kcontrol_new_t stac927x_mixer[] = {
  179. {
  180. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  181. .name = "Input Source",
  182. .count = 1,
  183. .info = stac92xx_mux_enum_info,
  184. .get = stac92xx_mux_enum_get,
  185. .put = stac92xx_mux_enum_put,
  186. },
  187. HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
  188. HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
  189. HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
  190. { } /* end */
  191. };
  192. static int stac92xx_build_controls(struct hda_codec *codec)
  193. {
  194. struct sigmatel_spec *spec = codec->spec;
  195. int err;
  196. int i;
  197. err = snd_hda_add_new_ctls(codec, spec->mixer);
  198. if (err < 0)
  199. return err;
  200. for (i = 0; i < spec->num_mixers; i++) {
  201. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  202. if (err < 0)
  203. return err;
  204. }
  205. if (spec->multiout.dig_out_nid) {
  206. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  207. if (err < 0)
  208. return err;
  209. }
  210. if (spec->dig_in_nid) {
  211. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  212. if (err < 0)
  213. return err;
  214. }
  215. return 0;
  216. }
  217. static unsigned int ref9200_pin_configs[8] = {
  218. 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
  219. 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
  220. };
  221. static unsigned int *stac9200_brd_tbl[] = {
  222. ref9200_pin_configs,
  223. };
  224. static struct hda_board_config stac9200_cfg_tbl[] = {
  225. { .modelname = "ref",
  226. .pci_subvendor = PCI_VENDOR_ID_INTEL,
  227. .pci_subdevice = 0x2668, /* DFI LanParty */
  228. .config = STAC_REF },
  229. {} /* terminator */
  230. };
  231. static unsigned int ref922x_pin_configs[10] = {
  232. 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
  233. 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
  234. 0x40000100, 0x40000100,
  235. };
  236. static unsigned int d945gtp3_pin_configs[10] = {
  237. 0x0221401f, 0x01a19022, 0x01813021, 0x01114010,
  238. 0x40000100, 0x40000100, 0x40000100, 0x40000100,
  239. 0x02a19120, 0x40000100,
  240. };
  241. static unsigned int d945gtp5_pin_configs[10] = {
  242. 0x0221401f, 0x01111012, 0x01813024, 0x01114010,
  243. 0x01a19021, 0x01116011, 0x01452130, 0x40000100,
  244. 0x02a19320, 0x40000100,
  245. };
  246. static unsigned int *stac922x_brd_tbl[] = {
  247. ref922x_pin_configs,
  248. d945gtp3_pin_configs,
  249. d945gtp5_pin_configs,
  250. };
  251. static struct hda_board_config stac922x_cfg_tbl[] = {
  252. { .modelname = "ref",
  253. .pci_subvendor = PCI_VENDOR_ID_INTEL,
  254. .pci_subdevice = 0x2668, /* DFI LanParty */
  255. .config = STAC_REF }, /* SigmaTel reference board */
  256. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  257. .pci_subdevice = 0x0101,
  258. .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */
  259. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  260. .pci_subdevice = 0x0404,
  261. .config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */
  262. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  263. .pci_subdevice = 0x0303,
  264. .config = STAC_D945GTP5 }, /* Intel D945GNT - 5 Stack */
  265. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  266. .pci_subdevice = 0x0013,
  267. .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */
  268. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  269. .pci_subdevice = 0x0417,
  270. .config = STAC_D945GTP5 }, /* Intel D975XBK - 5 Stack */
  271. {} /* terminator */
  272. };
  273. static unsigned int ref927x_pin_configs[14] = {
  274. 0x01813122, 0x01a19021, 0x01014010, 0x01016011,
  275. 0x01012012, 0x01011014, 0x40000100, 0x40000100,
  276. 0x40000100, 0x40000100, 0x40000100, 0x01441030,
  277. 0x01c41030, 0x40000100,
  278. };
  279. static unsigned int *stac927x_brd_tbl[] = {
  280. ref927x_pin_configs,
  281. };
  282. static struct hda_board_config stac927x_cfg_tbl[] = {
  283. { .modelname = "ref",
  284. .pci_subvendor = PCI_VENDOR_ID_INTEL,
  285. .pci_subdevice = 0x2668, /* DFI LanParty */
  286. .config = STAC_REF }, /* SigmaTel reference board */
  287. {} /* terminator */
  288. };
  289. static void stac92xx_set_config_regs(struct hda_codec *codec)
  290. {
  291. int i;
  292. struct sigmatel_spec *spec = codec->spec;
  293. unsigned int pin_cfg;
  294. for (i=0; i < spec->num_pins; i++) {
  295. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  296. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
  297. spec->pin_configs[i] & 0x000000ff);
  298. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  299. AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
  300. (spec->pin_configs[i] & 0x0000ff00) >> 8);
  301. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  302. AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
  303. (spec->pin_configs[i] & 0x00ff0000) >> 16);
  304. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  305. AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
  306. spec->pin_configs[i] >> 24);
  307. pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
  308. AC_VERB_GET_CONFIG_DEFAULT,
  309. 0x00);
  310. snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg);
  311. }
  312. }
  313. /*
  314. * Analog playback callbacks
  315. */
  316. static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
  317. struct hda_codec *codec,
  318. struct snd_pcm_substream *substream)
  319. {
  320. struct sigmatel_spec *spec = codec->spec;
  321. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  322. }
  323. static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  324. struct hda_codec *codec,
  325. unsigned int stream_tag,
  326. unsigned int format,
  327. struct snd_pcm_substream *substream)
  328. {
  329. struct sigmatel_spec *spec = codec->spec;
  330. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
  331. }
  332. static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  333. struct hda_codec *codec,
  334. struct snd_pcm_substream *substream)
  335. {
  336. struct sigmatel_spec *spec = codec->spec;
  337. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  338. }
  339. /*
  340. * Digital playback callbacks
  341. */
  342. static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  343. struct hda_codec *codec,
  344. struct snd_pcm_substream *substream)
  345. {
  346. struct sigmatel_spec *spec = codec->spec;
  347. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  348. }
  349. static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  350. struct hda_codec *codec,
  351. struct snd_pcm_substream *substream)
  352. {
  353. struct sigmatel_spec *spec = codec->spec;
  354. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  355. }
  356. /*
  357. * Analog capture callbacks
  358. */
  359. static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  360. struct hda_codec *codec,
  361. unsigned int stream_tag,
  362. unsigned int format,
  363. struct snd_pcm_substream *substream)
  364. {
  365. struct sigmatel_spec *spec = codec->spec;
  366. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  367. stream_tag, 0, format);
  368. return 0;
  369. }
  370. static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  371. struct hda_codec *codec,
  372. struct snd_pcm_substream *substream)
  373. {
  374. struct sigmatel_spec *spec = codec->spec;
  375. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
  376. return 0;
  377. }
  378. static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
  379. .substreams = 1,
  380. .channels_min = 2,
  381. .channels_max = 2,
  382. /* NID is set in stac92xx_build_pcms */
  383. .ops = {
  384. .open = stac92xx_dig_playback_pcm_open,
  385. .close = stac92xx_dig_playback_pcm_close
  386. },
  387. };
  388. static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
  389. .substreams = 1,
  390. .channels_min = 2,
  391. .channels_max = 2,
  392. /* NID is set in stac92xx_build_pcms */
  393. };
  394. static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
  395. .substreams = 1,
  396. .channels_min = 2,
  397. .channels_max = 8,
  398. .nid = 0x02, /* NID to query formats and rates */
  399. .ops = {
  400. .open = stac92xx_playback_pcm_open,
  401. .prepare = stac92xx_playback_pcm_prepare,
  402. .cleanup = stac92xx_playback_pcm_cleanup
  403. },
  404. };
  405. static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
  406. .substreams = 1,
  407. .channels_min = 2,
  408. .channels_max = 2,
  409. .nid = 0x06, /* NID to query formats and rates */
  410. .ops = {
  411. .open = stac92xx_playback_pcm_open,
  412. .prepare = stac92xx_playback_pcm_prepare,
  413. .cleanup = stac92xx_playback_pcm_cleanup
  414. },
  415. };
  416. static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
  417. .substreams = 2,
  418. .channels_min = 2,
  419. .channels_max = 2,
  420. /* NID is set in stac92xx_build_pcms */
  421. .ops = {
  422. .prepare = stac92xx_capture_pcm_prepare,
  423. .cleanup = stac92xx_capture_pcm_cleanup
  424. },
  425. };
  426. static int stac92xx_build_pcms(struct hda_codec *codec)
  427. {
  428. struct sigmatel_spec *spec = codec->spec;
  429. struct hda_pcm *info = spec->pcm_rec;
  430. codec->num_pcms = 1;
  431. codec->pcm_info = info;
  432. info->name = "STAC92xx Analog";
  433. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
  434. info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
  435. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  436. if (spec->alt_switch) {
  437. codec->num_pcms++;
  438. info++;
  439. info->name = "STAC92xx Analog Alt";
  440. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
  441. }
  442. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  443. codec->num_pcms++;
  444. info++;
  445. info->name = "STAC92xx Digital";
  446. if (spec->multiout.dig_out_nid) {
  447. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
  448. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  449. }
  450. if (spec->dig_in_nid) {
  451. info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
  452. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  453. }
  454. }
  455. return 0;
  456. }
  457. static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
  458. {
  459. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  460. }
  461. static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  462. {
  463. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  464. uinfo->count = 1;
  465. uinfo->value.integer.min = 0;
  466. uinfo->value.integer.max = 1;
  467. return 0;
  468. }
  469. static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  470. {
  471. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  472. struct sigmatel_spec *spec = codec->spec;
  473. int io_idx = kcontrol-> private_value & 0xff;
  474. ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
  475. return 0;
  476. }
  477. static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  478. {
  479. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  480. struct sigmatel_spec *spec = codec->spec;
  481. hda_nid_t nid = kcontrol->private_value >> 8;
  482. int io_idx = kcontrol-> private_value & 0xff;
  483. unsigned short val = ucontrol->value.integer.value[0];
  484. spec->io_switch[io_idx] = val;
  485. if (val)
  486. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  487. else
  488. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_IN_EN);
  489. return 1;
  490. }
  491. #define STAC_CODEC_IO_SWITCH(xname, xpval) \
  492. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  493. .name = xname, \
  494. .index = 0, \
  495. .info = stac92xx_io_switch_info, \
  496. .get = stac92xx_io_switch_get, \
  497. .put = stac92xx_io_switch_put, \
  498. .private_value = xpval, \
  499. }
  500. enum {
  501. STAC_CTL_WIDGET_VOL,
  502. STAC_CTL_WIDGET_MUTE,
  503. STAC_CTL_WIDGET_IO_SWITCH,
  504. };
  505. static struct snd_kcontrol_new stac92xx_control_templates[] = {
  506. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  507. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  508. STAC_CODEC_IO_SWITCH(NULL, 0),
  509. };
  510. /* add dynamic controls */
  511. static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
  512. {
  513. struct snd_kcontrol_new *knew;
  514. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  515. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  516. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  517. if (! knew)
  518. return -ENOMEM;
  519. if (spec->kctl_alloc) {
  520. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  521. kfree(spec->kctl_alloc);
  522. }
  523. spec->kctl_alloc = knew;
  524. spec->num_kctl_alloc = num;
  525. }
  526. knew = &spec->kctl_alloc[spec->num_kctl_used];
  527. *knew = stac92xx_control_templates[type];
  528. knew->name = kstrdup(name, GFP_KERNEL);
  529. if (! knew->name)
  530. return -ENOMEM;
  531. knew->private_value = val;
  532. spec->num_kctl_used++;
  533. return 0;
  534. }
  535. /* flag inputs as additional dynamic lineouts */
  536. static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
  537. {
  538. struct sigmatel_spec *spec = codec->spec;
  539. switch (cfg->line_outs) {
  540. case 3:
  541. /* add line-in as side */
  542. if (cfg->input_pins[AUTO_PIN_LINE]) {
  543. cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
  544. spec->line_switch = 1;
  545. cfg->line_outs++;
  546. }
  547. break;
  548. case 2:
  549. /* add line-in as clfe and mic as side */
  550. if (cfg->input_pins[AUTO_PIN_LINE]) {
  551. cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
  552. spec->line_switch = 1;
  553. cfg->line_outs++;
  554. }
  555. if (cfg->input_pins[AUTO_PIN_MIC]) {
  556. cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
  557. spec->mic_switch = 1;
  558. cfg->line_outs++;
  559. }
  560. break;
  561. case 1:
  562. /* add line-in as surr and mic as clfe */
  563. if (cfg->input_pins[AUTO_PIN_LINE]) {
  564. cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
  565. spec->line_switch = 1;
  566. cfg->line_outs++;
  567. }
  568. if (cfg->input_pins[AUTO_PIN_MIC]) {
  569. cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
  570. spec->mic_switch = 1;
  571. cfg->line_outs++;
  572. }
  573. break;
  574. }
  575. return 0;
  576. }
  577. /*
  578. * XXX The line_out pin widget connection list may not be set to the
  579. * desired DAC nid. This is the case on 927x where ports A and B can
  580. * be routed to several DACs.
  581. *
  582. * This requires an analysis of the line-out/hp pin configuration
  583. * to provide a best fit for pin/DAC configurations that are routable.
  584. * For now, 927x DAC4 is not supported and 927x DAC1 output to ports
  585. * A and B is not supported.
  586. */
  587. /* fill in the dac_nids table from the parsed pin configuration */
  588. static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
  589. {
  590. struct sigmatel_spec *spec = codec->spec;
  591. hda_nid_t nid;
  592. int i;
  593. /* check the pins hardwired to audio widget */
  594. for (i = 0; i < cfg->line_outs; i++) {
  595. nid = cfg->line_out_pins[i];
  596. spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0,
  597. AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
  598. }
  599. spec->multiout.num_dacs = cfg->line_outs;
  600. return 0;
  601. }
  602. /* add playback controls from the parsed DAC table */
  603. static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec, const struct auto_pin_cfg *cfg)
  604. {
  605. char name[32];
  606. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  607. hda_nid_t nid;
  608. int i, err;
  609. for (i = 0; i < cfg->line_outs; i++) {
  610. if (!spec->multiout.dac_nids[i])
  611. continue;
  612. nid = spec->multiout.dac_nids[i];
  613. if (i == 2) {
  614. /* Center/LFE */
  615. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Center Playback Volume",
  616. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  617. return err;
  618. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "LFE Playback Volume",
  619. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  620. return err;
  621. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Center Playback Switch",
  622. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  623. return err;
  624. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "LFE Playback Switch",
  625. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  626. return err;
  627. } else {
  628. sprintf(name, "%s Playback Volume", chname[i]);
  629. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
  630. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  631. return err;
  632. sprintf(name, "%s Playback Switch", chname[i]);
  633. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
  634. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  635. return err;
  636. }
  637. }
  638. if (spec->line_switch)
  639. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
  640. return err;
  641. if (spec->mic_switch)
  642. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
  643. return err;
  644. return 0;
  645. }
  646. /* add playback controls for HP output */
  647. static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin_cfg *cfg)
  648. {
  649. struct sigmatel_spec *spec = codec->spec;
  650. hda_nid_t pin = cfg->hp_pin;
  651. hda_nid_t nid;
  652. int i, err;
  653. unsigned int wid_caps;
  654. if (! pin)
  655. return 0;
  656. wid_caps = get_wcaps(codec, pin);
  657. if (wid_caps & AC_WCAP_UNSOL_CAP)
  658. /* Enable unsolicited responses on the HP widget */
  659. snd_hda_codec_write(codec, pin, 0,
  660. AC_VERB_SET_UNSOLICITED_ENABLE,
  661. STAC_UNSOL_ENABLE);
  662. nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
  663. for (i = 0; i < cfg->line_outs; i++) {
  664. if (! spec->multiout.dac_nids[i])
  665. continue;
  666. if (spec->multiout.dac_nids[i] == nid)
  667. return 0;
  668. }
  669. spec->multiout.hp_nid = nid;
  670. /* control HP volume/switch on the output mixer amp */
  671. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  672. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  673. return err;
  674. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  675. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  676. return err;
  677. return 0;
  678. }
  679. /* create playback/capture controls for input pins */
  680. static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
  681. {
  682. struct sigmatel_spec *spec = codec->spec;
  683. struct hda_input_mux *imux = &spec->private_imux;
  684. hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
  685. int i, j, k;
  686. for (i = 0; i < AUTO_PIN_LAST; i++) {
  687. int index = -1;
  688. if (cfg->input_pins[i]) {
  689. /* Enable active pin widget as an input */
  690. stac92xx_auto_set_pinctl(codec, cfg->input_pins[i], AC_PINCTL_IN_EN);
  691. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  692. for (j=0; j<spec->num_muxes; j++) {
  693. int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS);
  694. for (k=0; k<num_cons; k++)
  695. if (con_lst[k] == cfg->input_pins[i]) {
  696. index = k;
  697. break;
  698. }
  699. if (index >= 0)
  700. break;
  701. }
  702. imux->items[imux->num_items].index = index;
  703. imux->num_items++;
  704. }
  705. }
  706. return 0;
  707. }
  708. static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
  709. {
  710. struct sigmatel_spec *spec = codec->spec;
  711. int i;
  712. for (i = 0; i < spec->autocfg.line_outs; i++) {
  713. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  714. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  715. }
  716. }
  717. static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
  718. {
  719. struct sigmatel_spec *spec = codec->spec;
  720. hda_nid_t pin;
  721. pin = spec->autocfg.hp_pin;
  722. if (pin) /* connect to front */
  723. stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
  724. }
  725. static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
  726. {
  727. struct sigmatel_spec *spec = codec->spec;
  728. int err;
  729. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
  730. return err;
  731. if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
  732. return err;
  733. if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
  734. return err;
  735. if (! spec->autocfg.line_outs && ! spec->autocfg.hp_pin)
  736. return 0; /* can't find valid pin config */
  737. if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  738. (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
  739. (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
  740. return err;
  741. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  742. if (spec->multiout.max_channels > 2)
  743. spec->surr_switch = 1;
  744. if (spec->autocfg.dig_out_pin) {
  745. spec->multiout.dig_out_nid = dig_out;
  746. stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN);
  747. }
  748. if (spec->autocfg.dig_in_pin) {
  749. spec->dig_in_nid = dig_in;
  750. stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN);
  751. }
  752. if (spec->kctl_alloc)
  753. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  754. spec->input_mux = &spec->private_imux;
  755. return 1;
  756. }
  757. static int stac9200_parse_auto_config(struct hda_codec *codec)
  758. {
  759. struct sigmatel_spec *spec = codec->spec;
  760. int err;
  761. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
  762. return err;
  763. if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
  764. return err;
  765. if (spec->autocfg.dig_out_pin) {
  766. spec->multiout.dig_out_nid = 0x05;
  767. stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_out_pin, AC_PINCTL_OUT_EN);
  768. }
  769. if (spec->autocfg.dig_in_pin) {
  770. spec->dig_in_nid = 0x04;
  771. stac92xx_auto_set_pinctl(codec, spec->autocfg.dig_in_pin, AC_PINCTL_IN_EN);
  772. }
  773. if (spec->kctl_alloc)
  774. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  775. spec->input_mux = &spec->private_imux;
  776. return 1;
  777. }
  778. static int stac92xx_init(struct hda_codec *codec)
  779. {
  780. struct sigmatel_spec *spec = codec->spec;
  781. snd_hda_sequence_write(codec, spec->init);
  782. stac92xx_auto_init_multi_out(codec);
  783. stac92xx_auto_init_hp_out(codec);
  784. return 0;
  785. }
  786. static void stac92xx_free(struct hda_codec *codec)
  787. {
  788. struct sigmatel_spec *spec = codec->spec;
  789. int i;
  790. if (! spec)
  791. return;
  792. if (spec->kctl_alloc) {
  793. for (i = 0; i < spec->num_kctl_used; i++)
  794. kfree(spec->kctl_alloc[i].name);
  795. kfree(spec->kctl_alloc);
  796. }
  797. kfree(spec);
  798. }
  799. static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
  800. unsigned int flag)
  801. {
  802. unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
  803. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  804. snd_hda_codec_write(codec, nid, 0,
  805. AC_VERB_SET_PIN_WIDGET_CONTROL,
  806. pin_ctl | flag);
  807. }
  808. static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
  809. unsigned int flag)
  810. {
  811. unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
  812. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  813. snd_hda_codec_write(codec, nid, 0,
  814. AC_VERB_SET_PIN_WIDGET_CONTROL,
  815. pin_ctl & ~flag);
  816. }
  817. static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
  818. {
  819. struct sigmatel_spec *spec = codec->spec;
  820. struct auto_pin_cfg *cfg = &spec->autocfg;
  821. int i, presence;
  822. if ((res >> 26) != STAC_HP_EVENT)
  823. return;
  824. presence = snd_hda_codec_read(codec, cfg->hp_pin, 0,
  825. AC_VERB_GET_PIN_SENSE, 0x00) >> 31;
  826. if (presence) {
  827. /* disable lineouts, enable hp */
  828. for (i = 0; i < cfg->line_outs; i++)
  829. stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
  830. AC_PINCTL_OUT_EN);
  831. stac92xx_set_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
  832. } else {
  833. /* enable lineouts, disable hp */
  834. for (i = 0; i < cfg->line_outs; i++)
  835. stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
  836. AC_PINCTL_OUT_EN);
  837. stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
  838. }
  839. }
  840. #ifdef CONFIG_PM
  841. static int stac92xx_resume(struct hda_codec *codec)
  842. {
  843. struct sigmatel_spec *spec = codec->spec;
  844. int i;
  845. stac92xx_init(codec);
  846. for (i = 0; i < spec->num_mixers; i++)
  847. snd_hda_resume_ctls(codec, spec->mixers[i]);
  848. if (spec->multiout.dig_out_nid)
  849. snd_hda_resume_spdif_out(codec);
  850. if (spec->dig_in_nid)
  851. snd_hda_resume_spdif_in(codec);
  852. return 0;
  853. }
  854. #endif
  855. static struct hda_codec_ops stac92xx_patch_ops = {
  856. .build_controls = stac92xx_build_controls,
  857. .build_pcms = stac92xx_build_pcms,
  858. .init = stac92xx_init,
  859. .free = stac92xx_free,
  860. .unsol_event = stac92xx_unsol_event,
  861. #ifdef CONFIG_PM
  862. .resume = stac92xx_resume,
  863. #endif
  864. };
  865. static int patch_stac9200(struct hda_codec *codec)
  866. {
  867. struct sigmatel_spec *spec;
  868. int err;
  869. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  870. if (spec == NULL)
  871. return -ENOMEM;
  872. codec->spec = spec;
  873. spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl);
  874. if (spec->board_config < 0)
  875. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
  876. else {
  877. spec->num_pins = 8;
  878. spec->pin_nids = stac9200_pin_nids;
  879. spec->pin_configs = stac9200_brd_tbl[spec->board_config];
  880. stac92xx_set_config_regs(codec);
  881. }
  882. spec->multiout.max_channels = 2;
  883. spec->multiout.num_dacs = 1;
  884. spec->multiout.dac_nids = stac9200_dac_nids;
  885. spec->adc_nids = stac9200_adc_nids;
  886. spec->mux_nids = stac9200_mux_nids;
  887. spec->num_muxes = 1;
  888. spec->init = stac9200_core_init;
  889. spec->mixer = stac9200_mixer;
  890. err = stac9200_parse_auto_config(codec);
  891. if (err < 0) {
  892. stac92xx_free(codec);
  893. return err;
  894. }
  895. codec->patch_ops = stac92xx_patch_ops;
  896. return 0;
  897. }
  898. static int patch_stac922x(struct hda_codec *codec)
  899. {
  900. struct sigmatel_spec *spec;
  901. int err;
  902. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  903. if (spec == NULL)
  904. return -ENOMEM;
  905. codec->spec = spec;
  906. spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl);
  907. if (spec->board_config < 0)
  908. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, using BIOS defaults\n");
  909. else {
  910. spec->num_pins = 10;
  911. spec->pin_nids = stac922x_pin_nids;
  912. spec->pin_configs = stac922x_brd_tbl[spec->board_config];
  913. stac92xx_set_config_regs(codec);
  914. }
  915. spec->adc_nids = stac922x_adc_nids;
  916. spec->mux_nids = stac922x_mux_nids;
  917. spec->num_muxes = 2;
  918. spec->init = stac922x_core_init;
  919. spec->mixer = stac922x_mixer;
  920. spec->multiout.dac_nids = spec->dac_nids;
  921. err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
  922. if (err < 0) {
  923. stac92xx_free(codec);
  924. return err;
  925. }
  926. codec->patch_ops = stac92xx_patch_ops;
  927. return 0;
  928. }
  929. static int patch_stac927x(struct hda_codec *codec)
  930. {
  931. struct sigmatel_spec *spec;
  932. int err;
  933. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  934. if (spec == NULL)
  935. return -ENOMEM;
  936. codec->spec = spec;
  937. spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl);
  938. if (spec->board_config < 0)
  939. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
  940. else {
  941. spec->num_pins = 14;
  942. spec->pin_nids = stac927x_pin_nids;
  943. spec->pin_configs = stac927x_brd_tbl[spec->board_config];
  944. stac92xx_set_config_regs(codec);
  945. }
  946. spec->adc_nids = stac927x_adc_nids;
  947. spec->mux_nids = stac927x_mux_nids;
  948. spec->num_muxes = 3;
  949. spec->init = stac927x_core_init;
  950. spec->mixer = stac927x_mixer;
  951. spec->multiout.dac_nids = spec->dac_nids;
  952. err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
  953. if (err < 0) {
  954. stac92xx_free(codec);
  955. return err;
  956. }
  957. codec->patch_ops = stac92xx_patch_ops;
  958. return 0;
  959. }
  960. /*
  961. * patch entries
  962. */
  963. struct hda_codec_preset snd_hda_preset_sigmatel[] = {
  964. { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
  965. { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
  966. { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
  967. { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
  968. { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
  969. { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
  970. { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
  971. { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
  972. { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
  973. { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
  974. { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
  975. { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
  976. { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
  977. { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
  978. { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
  979. { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
  980. { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
  981. {} /* terminator */
  982. };