patch_sigmatel.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654
  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. #define STAC_MACMINI 3
  42. #define STAC_D965_2112 4
  43. #define STAC_D965_284B 5
  44. #define STAC_922X_MODELS 6 /* number of 922x models */
  45. struct sigmatel_spec {
  46. struct snd_kcontrol_new *mixers[4];
  47. unsigned int num_mixers;
  48. int board_config;
  49. unsigned int surr_switch: 1;
  50. unsigned int line_switch: 1;
  51. unsigned int mic_switch: 1;
  52. unsigned int alt_switch: 1;
  53. unsigned int hp_detect: 1;
  54. unsigned int gpio_mute: 1;
  55. /* playback */
  56. struct hda_multi_out multiout;
  57. hda_nid_t dac_nids[5];
  58. /* capture */
  59. hda_nid_t *adc_nids;
  60. unsigned int num_adcs;
  61. hda_nid_t *mux_nids;
  62. unsigned int num_muxes;
  63. hda_nid_t dig_in_nid;
  64. /* pin widgets */
  65. hda_nid_t *pin_nids;
  66. unsigned int num_pins;
  67. unsigned int *pin_configs;
  68. /* codec specific stuff */
  69. struct hda_verb *init;
  70. struct snd_kcontrol_new *mixer;
  71. /* capture source */
  72. struct hda_input_mux *input_mux;
  73. unsigned int cur_mux[3];
  74. /* i/o switches */
  75. unsigned int io_switch[2];
  76. struct hda_pcm pcm_rec[2]; /* PCM information */
  77. /* dynamic controls and input_mux */
  78. struct auto_pin_cfg autocfg;
  79. unsigned int num_kctl_alloc, num_kctl_used;
  80. struct snd_kcontrol_new *kctl_alloc;
  81. struct hda_input_mux private_imux;
  82. };
  83. static hda_nid_t stac9200_adc_nids[1] = {
  84. 0x03,
  85. };
  86. static hda_nid_t stac9200_mux_nids[1] = {
  87. 0x0c,
  88. };
  89. static hda_nid_t stac9200_dac_nids[1] = {
  90. 0x02,
  91. };
  92. static hda_nid_t stac922x_adc_nids[2] = {
  93. 0x06, 0x07,
  94. };
  95. static hda_nid_t stac9227_adc_nids[2] = {
  96. 0x07, 0x08,
  97. };
  98. #if 0
  99. static hda_nid_t d965_2112_dac_nids[3] = {
  100. 0x02, 0x03, 0x05,
  101. };
  102. #endif
  103. static hda_nid_t stac922x_mux_nids[2] = {
  104. 0x12, 0x13,
  105. };
  106. static hda_nid_t stac9227_mux_nids[2] = {
  107. 0x15, 0x16,
  108. };
  109. static hda_nid_t stac927x_adc_nids[3] = {
  110. 0x07, 0x08, 0x09
  111. };
  112. static hda_nid_t stac927x_mux_nids[3] = {
  113. 0x15, 0x16, 0x17
  114. };
  115. static hda_nid_t stac9205_adc_nids[2] = {
  116. 0x12, 0x13
  117. };
  118. static hda_nid_t stac9205_mux_nids[2] = {
  119. 0x19, 0x1a
  120. };
  121. static hda_nid_t stac9200_pin_nids[8] = {
  122. 0x08, 0x09, 0x0d, 0x0e, 0x0f, 0x10, 0x11, 0x12,
  123. };
  124. static hda_nid_t stac922x_pin_nids[10] = {
  125. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  126. 0x0f, 0x10, 0x11, 0x15, 0x1b,
  127. };
  128. static hda_nid_t stac927x_pin_nids[14] = {
  129. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  130. 0x0f, 0x10, 0x11, 0x12, 0x13,
  131. 0x14, 0x21, 0x22, 0x23,
  132. };
  133. static hda_nid_t stac9205_pin_nids[12] = {
  134. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  135. 0x0f, 0x14, 0x16, 0x17, 0x18,
  136. 0x21, 0x22,
  137. };
  138. static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  139. {
  140. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  141. struct sigmatel_spec *spec = codec->spec;
  142. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  143. }
  144. static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  145. {
  146. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  147. struct sigmatel_spec *spec = codec->spec;
  148. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  149. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  150. return 0;
  151. }
  152. static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  153. {
  154. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  155. struct sigmatel_spec *spec = codec->spec;
  156. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  157. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  158. spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
  159. }
  160. static struct hda_verb stac9200_core_init[] = {
  161. /* set dac0mux for dac converter */
  162. { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  163. {}
  164. };
  165. static struct hda_verb stac922x_core_init[] = {
  166. /* set master volume and direct control */
  167. { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  168. {}
  169. };
  170. static struct hda_verb stac9227_core_init[] = {
  171. /* set master volume and direct control */
  172. { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  173. /* unmute node 0x1b */
  174. { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  175. {}
  176. };
  177. static struct hda_verb d965_2112_core_init[] = {
  178. /* set master volume and direct control */
  179. { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  180. /* unmute node 0x1b */
  181. { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  182. /* select node 0x03 as DAC */
  183. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
  184. {}
  185. };
  186. static struct hda_verb stac927x_core_init[] = {
  187. /* set master volume and direct control */
  188. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  189. {}
  190. };
  191. static struct hda_verb stac9205_core_init[] = {
  192. /* set master volume and direct control */
  193. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  194. {}
  195. };
  196. static struct snd_kcontrol_new stac9200_mixer[] = {
  197. HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
  198. HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
  199. {
  200. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  201. .name = "Input Source",
  202. .count = 1,
  203. .info = stac92xx_mux_enum_info,
  204. .get = stac92xx_mux_enum_get,
  205. .put = stac92xx_mux_enum_put,
  206. },
  207. HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
  208. HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
  209. HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
  210. { } /* end */
  211. };
  212. /* This needs to be generated dynamically based on sequence */
  213. static struct snd_kcontrol_new stac922x_mixer[] = {
  214. {
  215. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  216. .name = "Input Source",
  217. .count = 1,
  218. .info = stac92xx_mux_enum_info,
  219. .get = stac92xx_mux_enum_get,
  220. .put = stac92xx_mux_enum_put,
  221. },
  222. HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
  223. HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
  224. HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
  225. { } /* end */
  226. };
  227. /* This needs to be generated dynamically based on sequence */
  228. static struct snd_kcontrol_new stac9227_mixer[] = {
  229. {
  230. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  231. .name = "Input Source",
  232. .count = 1,
  233. .info = stac92xx_mux_enum_info,
  234. .get = stac92xx_mux_enum_get,
  235. .put = stac92xx_mux_enum_put,
  236. },
  237. HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
  238. HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
  239. { } /* end */
  240. };
  241. static snd_kcontrol_new_t stac927x_mixer[] = {
  242. {
  243. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  244. .name = "Input Source",
  245. .count = 1,
  246. .info = stac92xx_mux_enum_info,
  247. .get = stac92xx_mux_enum_get,
  248. .put = stac92xx_mux_enum_put,
  249. },
  250. HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
  251. HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
  252. HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
  253. { } /* end */
  254. };
  255. static snd_kcontrol_new_t stac9205_mixer[] = {
  256. {
  257. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  258. .name = "Input Source",
  259. .count = 1,
  260. .info = stac92xx_mux_enum_info,
  261. .get = stac92xx_mux_enum_get,
  262. .put = stac92xx_mux_enum_put,
  263. },
  264. HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT),
  265. HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT),
  266. HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT),
  267. { } /* end */
  268. };
  269. static int stac92xx_build_controls(struct hda_codec *codec)
  270. {
  271. struct sigmatel_spec *spec = codec->spec;
  272. int err;
  273. int i;
  274. err = snd_hda_add_new_ctls(codec, spec->mixer);
  275. if (err < 0)
  276. return err;
  277. for (i = 0; i < spec->num_mixers; i++) {
  278. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  279. if (err < 0)
  280. return err;
  281. }
  282. if (spec->multiout.dig_out_nid) {
  283. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  284. if (err < 0)
  285. return err;
  286. }
  287. if (spec->dig_in_nid) {
  288. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  289. if (err < 0)
  290. return err;
  291. }
  292. return 0;
  293. }
  294. static unsigned int ref9200_pin_configs[8] = {
  295. 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
  296. 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
  297. };
  298. static unsigned int *stac9200_brd_tbl[] = {
  299. ref9200_pin_configs,
  300. };
  301. static struct hda_board_config stac9200_cfg_tbl[] = {
  302. { .modelname = "ref",
  303. .pci_subvendor = PCI_VENDOR_ID_INTEL,
  304. .pci_subdevice = 0x2668, /* DFI LanParty */
  305. .config = STAC_REF },
  306. {} /* terminator */
  307. };
  308. static unsigned int ref922x_pin_configs[10] = {
  309. 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
  310. 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
  311. 0x40000100, 0x40000100,
  312. };
  313. static unsigned int d945gtp3_pin_configs[10] = {
  314. 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
  315. 0x40000100, 0x40000100, 0x40000100, 0x40000100,
  316. 0x02a19120, 0x40000100,
  317. };
  318. static unsigned int d945gtp5_pin_configs[10] = {
  319. 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
  320. 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
  321. 0x02a19320, 0x40000100,
  322. };
  323. static unsigned int d965_2112_pin_configs[10] = {
  324. 0x0221401f, 0x40000100, 0x40000100, 0x01014011,
  325. 0x01a19021, 0x01813024, 0x01452130, 0x40000100,
  326. 0x02a19320, 0x40000100,
  327. };
  328. static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
  329. [STAC_REF] = ref922x_pin_configs,
  330. [STAC_D945GTP3] = d945gtp3_pin_configs,
  331. [STAC_D945GTP5] = d945gtp5_pin_configs,
  332. [STAC_MACMINI] = d945gtp5_pin_configs,
  333. [STAC_D965_2112] = d965_2112_pin_configs,
  334. };
  335. static struct hda_board_config stac922x_cfg_tbl[] = {
  336. { .modelname = "ref",
  337. .pci_subvendor = PCI_VENDOR_ID_INTEL,
  338. .pci_subdevice = 0x2668, /* DFI LanParty */
  339. .config = STAC_REF }, /* SigmaTel reference board */
  340. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  341. .pci_subdevice = 0x0101,
  342. .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */
  343. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  344. .pci_subdevice = 0x0202,
  345. .config = STAC_D945GTP3 }, /* Intel D945GNT - 3 Stack, 9221 A1 */
  346. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  347. .pci_subdevice = 0x0b0b,
  348. .config = STAC_D945GTP3 }, /* Intel D945PSN - 3 Stack, 9221 A1 */
  349. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  350. .pci_subdevice = 0x0707,
  351. .config = STAC_D945GTP5 }, /* Intel D945PSV - 5 Stack */
  352. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  353. .pci_subdevice = 0x0404,
  354. .config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */
  355. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  356. .pci_subdevice = 0x0303,
  357. .config = STAC_D945GTP5 }, /* Intel D945GNT - 5 Stack */
  358. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  359. .pci_subdevice = 0x0013,
  360. .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */
  361. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  362. .pci_subdevice = 0x0417,
  363. .config = STAC_D945GTP5 }, /* Intel D975XBK - 5 Stack */
  364. { .pci_subvendor = 0x8384,
  365. .pci_subdevice = 0x7680,
  366. .config = STAC_MACMINI }, /* Apple Mac Mini (early 2006) */
  367. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  368. .pci_subdevice = 0x2112,
  369. .config = STAC_D965_2112 },
  370. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  371. .pci_subdevice = 0x284b,
  372. .config = STAC_D965_284B },
  373. {} /* terminator */
  374. };
  375. static unsigned int ref927x_pin_configs[14] = {
  376. 0x01813122, 0x01a19021, 0x01014010, 0x01016011,
  377. 0x01012012, 0x01011014, 0x40000100, 0x40000100,
  378. 0x40000100, 0x40000100, 0x40000100, 0x01441030,
  379. 0x01c41030, 0x40000100,
  380. };
  381. static unsigned int *stac927x_brd_tbl[] = {
  382. ref927x_pin_configs,
  383. };
  384. static struct hda_board_config stac927x_cfg_tbl[] = {
  385. { .modelname = "ref",
  386. .pci_subvendor = PCI_VENDOR_ID_INTEL,
  387. .pci_subdevice = 0x2668, /* DFI LanParty */
  388. .config = STAC_REF }, /* SigmaTel reference board */
  389. {} /* terminator */
  390. };
  391. static unsigned int ref9205_pin_configs[12] = {
  392. 0x40000100, 0x40000100, 0x01016011, 0x01014010,
  393. 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
  394. 0x40000100, 0x40000100, 0x01441030, 0x01c41030
  395. };
  396. static unsigned int *stac9205_brd_tbl[] = {
  397. ref9205_pin_configs,
  398. };
  399. static struct hda_board_config stac9205_cfg_tbl[] = {
  400. { .modelname = "ref",
  401. .pci_subvendor = PCI_VENDOR_ID_INTEL,
  402. .pci_subdevice = 0x2668, /* DFI LanParty */
  403. .config = STAC_REF }, /* SigmaTel reference board */
  404. {} /* terminator */
  405. };
  406. static void stac92xx_set_config_regs(struct hda_codec *codec)
  407. {
  408. int i;
  409. struct sigmatel_spec *spec = codec->spec;
  410. unsigned int pin_cfg;
  411. for (i=0; i < spec->num_pins; i++) {
  412. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  413. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
  414. spec->pin_configs[i] & 0x000000ff);
  415. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  416. AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
  417. (spec->pin_configs[i] & 0x0000ff00) >> 8);
  418. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  419. AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
  420. (spec->pin_configs[i] & 0x00ff0000) >> 16);
  421. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  422. AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
  423. spec->pin_configs[i] >> 24);
  424. pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
  425. AC_VERB_GET_CONFIG_DEFAULT,
  426. 0x00);
  427. snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg);
  428. }
  429. }
  430. /*
  431. * Analog playback callbacks
  432. */
  433. static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
  434. struct hda_codec *codec,
  435. struct snd_pcm_substream *substream)
  436. {
  437. struct sigmatel_spec *spec = codec->spec;
  438. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  439. }
  440. static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  441. struct hda_codec *codec,
  442. unsigned int stream_tag,
  443. unsigned int format,
  444. struct snd_pcm_substream *substream)
  445. {
  446. struct sigmatel_spec *spec = codec->spec;
  447. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
  448. }
  449. static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  450. struct hda_codec *codec,
  451. struct snd_pcm_substream *substream)
  452. {
  453. struct sigmatel_spec *spec = codec->spec;
  454. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  455. }
  456. /*
  457. * Digital playback callbacks
  458. */
  459. static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  460. struct hda_codec *codec,
  461. struct snd_pcm_substream *substream)
  462. {
  463. struct sigmatel_spec *spec = codec->spec;
  464. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  465. }
  466. static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  467. struct hda_codec *codec,
  468. struct snd_pcm_substream *substream)
  469. {
  470. struct sigmatel_spec *spec = codec->spec;
  471. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  472. }
  473. /*
  474. * Analog capture callbacks
  475. */
  476. static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  477. struct hda_codec *codec,
  478. unsigned int stream_tag,
  479. unsigned int format,
  480. struct snd_pcm_substream *substream)
  481. {
  482. struct sigmatel_spec *spec = codec->spec;
  483. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  484. stream_tag, 0, format);
  485. return 0;
  486. }
  487. static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  488. struct hda_codec *codec,
  489. struct snd_pcm_substream *substream)
  490. {
  491. struct sigmatel_spec *spec = codec->spec;
  492. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
  493. return 0;
  494. }
  495. static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
  496. .substreams = 1,
  497. .channels_min = 2,
  498. .channels_max = 2,
  499. /* NID is set in stac92xx_build_pcms */
  500. .ops = {
  501. .open = stac92xx_dig_playback_pcm_open,
  502. .close = stac92xx_dig_playback_pcm_close
  503. },
  504. };
  505. static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
  506. .substreams = 1,
  507. .channels_min = 2,
  508. .channels_max = 2,
  509. /* NID is set in stac92xx_build_pcms */
  510. };
  511. static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
  512. .substreams = 1,
  513. .channels_min = 2,
  514. .channels_max = 8,
  515. .nid = 0x02, /* NID to query formats and rates */
  516. .ops = {
  517. .open = stac92xx_playback_pcm_open,
  518. .prepare = stac92xx_playback_pcm_prepare,
  519. .cleanup = stac92xx_playback_pcm_cleanup
  520. },
  521. };
  522. static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
  523. .substreams = 1,
  524. .channels_min = 2,
  525. .channels_max = 2,
  526. .nid = 0x06, /* NID to query formats and rates */
  527. .ops = {
  528. .open = stac92xx_playback_pcm_open,
  529. .prepare = stac92xx_playback_pcm_prepare,
  530. .cleanup = stac92xx_playback_pcm_cleanup
  531. },
  532. };
  533. static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
  534. .substreams = 2,
  535. .channels_min = 2,
  536. .channels_max = 2,
  537. /* NID is set in stac92xx_build_pcms */
  538. .ops = {
  539. .prepare = stac92xx_capture_pcm_prepare,
  540. .cleanup = stac92xx_capture_pcm_cleanup
  541. },
  542. };
  543. static int stac92xx_build_pcms(struct hda_codec *codec)
  544. {
  545. struct sigmatel_spec *spec = codec->spec;
  546. struct hda_pcm *info = spec->pcm_rec;
  547. codec->num_pcms = 1;
  548. codec->pcm_info = info;
  549. info->name = "STAC92xx Analog";
  550. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
  551. info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
  552. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  553. if (spec->alt_switch) {
  554. codec->num_pcms++;
  555. info++;
  556. info->name = "STAC92xx Analog Alt";
  557. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
  558. }
  559. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  560. codec->num_pcms++;
  561. info++;
  562. info->name = "STAC92xx Digital";
  563. if (spec->multiout.dig_out_nid) {
  564. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
  565. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  566. }
  567. if (spec->dig_in_nid) {
  568. info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
  569. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  570. }
  571. }
  572. return 0;
  573. }
  574. static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
  575. {
  576. unsigned int pincap = snd_hda_param_read(codec, nid,
  577. AC_PAR_PIN_CAP);
  578. pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
  579. if (pincap & AC_PINCAP_VREF_100)
  580. return AC_PINCTL_VREF_100;
  581. if (pincap & AC_PINCAP_VREF_80)
  582. return AC_PINCTL_VREF_80;
  583. if (pincap & AC_PINCAP_VREF_50)
  584. return AC_PINCTL_VREF_50;
  585. if (pincap & AC_PINCAP_VREF_GRD)
  586. return AC_PINCTL_VREF_GRD;
  587. return 0;
  588. }
  589. static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
  590. {
  591. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  592. }
  593. static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  594. {
  595. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  596. uinfo->count = 1;
  597. uinfo->value.integer.min = 0;
  598. uinfo->value.integer.max = 1;
  599. return 0;
  600. }
  601. static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  602. {
  603. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  604. struct sigmatel_spec *spec = codec->spec;
  605. int io_idx = kcontrol-> private_value & 0xff;
  606. ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
  607. return 0;
  608. }
  609. static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  610. {
  611. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  612. struct sigmatel_spec *spec = codec->spec;
  613. hda_nid_t nid = kcontrol->private_value >> 8;
  614. int io_idx = kcontrol-> private_value & 0xff;
  615. unsigned short val = ucontrol->value.integer.value[0];
  616. spec->io_switch[io_idx] = val;
  617. if (val)
  618. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  619. else {
  620. unsigned int pinctl = AC_PINCTL_IN_EN;
  621. if (io_idx) /* set VREF for mic */
  622. pinctl |= stac92xx_get_vref(codec, nid);
  623. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  624. }
  625. return 1;
  626. }
  627. #define STAC_CODEC_IO_SWITCH(xname, xpval) \
  628. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  629. .name = xname, \
  630. .index = 0, \
  631. .info = stac92xx_io_switch_info, \
  632. .get = stac92xx_io_switch_get, \
  633. .put = stac92xx_io_switch_put, \
  634. .private_value = xpval, \
  635. }
  636. enum {
  637. STAC_CTL_WIDGET_VOL,
  638. STAC_CTL_WIDGET_MUTE,
  639. STAC_CTL_WIDGET_IO_SWITCH,
  640. };
  641. static struct snd_kcontrol_new stac92xx_control_templates[] = {
  642. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  643. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  644. STAC_CODEC_IO_SWITCH(NULL, 0),
  645. };
  646. /* add dynamic controls */
  647. static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
  648. {
  649. struct snd_kcontrol_new *knew;
  650. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  651. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  652. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  653. if (! knew)
  654. return -ENOMEM;
  655. if (spec->kctl_alloc) {
  656. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  657. kfree(spec->kctl_alloc);
  658. }
  659. spec->kctl_alloc = knew;
  660. spec->num_kctl_alloc = num;
  661. }
  662. knew = &spec->kctl_alloc[spec->num_kctl_used];
  663. *knew = stac92xx_control_templates[type];
  664. knew->name = kstrdup(name, GFP_KERNEL);
  665. if (! knew->name)
  666. return -ENOMEM;
  667. knew->private_value = val;
  668. spec->num_kctl_used++;
  669. return 0;
  670. }
  671. /* flag inputs as additional dynamic lineouts */
  672. static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
  673. {
  674. struct sigmatel_spec *spec = codec->spec;
  675. switch (cfg->line_outs) {
  676. case 3:
  677. /* add line-in as side */
  678. if (cfg->input_pins[AUTO_PIN_LINE]) {
  679. cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
  680. spec->line_switch = 1;
  681. cfg->line_outs++;
  682. }
  683. break;
  684. case 2:
  685. /* add line-in as clfe and mic as side */
  686. if (cfg->input_pins[AUTO_PIN_LINE]) {
  687. cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
  688. spec->line_switch = 1;
  689. cfg->line_outs++;
  690. }
  691. if (cfg->input_pins[AUTO_PIN_MIC]) {
  692. cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
  693. spec->mic_switch = 1;
  694. cfg->line_outs++;
  695. }
  696. break;
  697. case 1:
  698. /* add line-in as surr and mic as clfe */
  699. if (cfg->input_pins[AUTO_PIN_LINE]) {
  700. cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
  701. spec->line_switch = 1;
  702. cfg->line_outs++;
  703. }
  704. if (cfg->input_pins[AUTO_PIN_MIC]) {
  705. cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
  706. spec->mic_switch = 1;
  707. cfg->line_outs++;
  708. }
  709. break;
  710. }
  711. return 0;
  712. }
  713. /*
  714. * XXX The line_out pin widget connection list may not be set to the
  715. * desired DAC nid. This is the case on 927x where ports A and B can
  716. * be routed to several DACs.
  717. *
  718. * This requires an analysis of the line-out/hp pin configuration
  719. * to provide a best fit for pin/DAC configurations that are routable.
  720. * For now, 927x DAC4 is not supported and 927x DAC1 output to ports
  721. * A and B is not supported.
  722. */
  723. /* fill in the dac_nids table from the parsed pin configuration */
  724. static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
  725. const struct auto_pin_cfg *cfg)
  726. {
  727. struct sigmatel_spec *spec = codec->spec;
  728. hda_nid_t nid;
  729. int i;
  730. /* check the pins hardwired to audio widget */
  731. for (i = 0; i < cfg->line_outs; i++) {
  732. nid = cfg->line_out_pins[i];
  733. spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0,
  734. AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
  735. }
  736. spec->multiout.num_dacs = cfg->line_outs;
  737. return 0;
  738. }
  739. /* add playback controls from the parsed DAC table */
  740. static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
  741. const struct auto_pin_cfg *cfg)
  742. {
  743. char name[32];
  744. static const char *chname[4] = {
  745. "Front", "Surround", NULL /*CLFE*/, "Side"
  746. };
  747. hda_nid_t nid;
  748. int i, err;
  749. for (i = 0; i < cfg->line_outs; i++) {
  750. if (!spec->multiout.dac_nids[i])
  751. continue;
  752. nid = spec->multiout.dac_nids[i];
  753. if (i == 2) {
  754. /* Center/LFE */
  755. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Center Playback Volume",
  756. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  757. return err;
  758. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "LFE Playback Volume",
  759. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  760. return err;
  761. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Center Playback Switch",
  762. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  763. return err;
  764. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "LFE Playback Switch",
  765. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  766. return err;
  767. } else {
  768. sprintf(name, "%s Playback Volume", chname[i]);
  769. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
  770. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  771. return err;
  772. sprintf(name, "%s Playback Switch", chname[i]);
  773. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
  774. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  775. return err;
  776. }
  777. }
  778. if (spec->line_switch)
  779. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
  780. return err;
  781. if (spec->mic_switch)
  782. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
  783. return err;
  784. return 0;
  785. }
  786. /* add playback controls for HP output */
  787. static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin_cfg *cfg)
  788. {
  789. struct sigmatel_spec *spec = codec->spec;
  790. hda_nid_t pin = cfg->hp_pin;
  791. hda_nid_t nid;
  792. int i, err;
  793. unsigned int wid_caps;
  794. if (! pin)
  795. return 0;
  796. wid_caps = get_wcaps(codec, pin);
  797. if (wid_caps & AC_WCAP_UNSOL_CAP)
  798. spec->hp_detect = 1;
  799. nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
  800. for (i = 0; i < cfg->line_outs; i++) {
  801. if (! spec->multiout.dac_nids[i])
  802. continue;
  803. if (spec->multiout.dac_nids[i] == nid)
  804. return 0;
  805. }
  806. spec->multiout.hp_nid = nid;
  807. /* control HP volume/switch on the output mixer amp */
  808. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  809. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  810. return err;
  811. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  812. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  813. return err;
  814. return 0;
  815. }
  816. /* create playback/capture controls for input pins */
  817. static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
  818. {
  819. struct sigmatel_spec *spec = codec->spec;
  820. struct hda_input_mux *imux = &spec->private_imux;
  821. hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
  822. int i, j, k;
  823. for (i = 0; i < AUTO_PIN_LAST; i++) {
  824. int index = -1;
  825. if (cfg->input_pins[i]) {
  826. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  827. for (j=0; j<spec->num_muxes; j++) {
  828. int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS);
  829. for (k=0; k<num_cons; k++)
  830. if (con_lst[k] == cfg->input_pins[i]) {
  831. index = k;
  832. break;
  833. }
  834. if (index >= 0)
  835. break;
  836. }
  837. imux->items[imux->num_items].index = index;
  838. imux->num_items++;
  839. }
  840. }
  841. if (imux->num_items == 1) {
  842. /*
  843. * Set the current input for the muxes.
  844. * The STAC9221 has two input muxes with identical source
  845. * NID lists. Hopefully this won't get confused.
  846. */
  847. for (i = 0; i < spec->num_muxes; i++) {
  848. snd_hda_codec_write(codec, spec->mux_nids[i], 0,
  849. AC_VERB_SET_CONNECT_SEL,
  850. imux->items[0].index);
  851. }
  852. }
  853. return 0;
  854. }
  855. static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
  856. {
  857. struct sigmatel_spec *spec = codec->spec;
  858. int i;
  859. for (i = 0; i < spec->autocfg.line_outs; i++) {
  860. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  861. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  862. }
  863. }
  864. static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
  865. {
  866. struct sigmatel_spec *spec = codec->spec;
  867. hda_nid_t pin;
  868. pin = spec->autocfg.hp_pin;
  869. if (pin) /* connect to front */
  870. stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
  871. }
  872. static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
  873. {
  874. struct sigmatel_spec *spec = codec->spec;
  875. int err;
  876. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
  877. return err;
  878. if (! spec->autocfg.line_outs)
  879. return 0; /* can't find valid pin config */
  880. if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
  881. return err;
  882. if (spec->multiout.num_dacs == 0)
  883. if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
  884. return err;
  885. if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  886. (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
  887. (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
  888. return err;
  889. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  890. if (spec->multiout.max_channels > 2)
  891. spec->surr_switch = 1;
  892. if (spec->autocfg.dig_out_pin)
  893. spec->multiout.dig_out_nid = dig_out;
  894. if (spec->autocfg.dig_in_pin)
  895. spec->dig_in_nid = dig_in;
  896. if (spec->kctl_alloc)
  897. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  898. spec->input_mux = &spec->private_imux;
  899. return 1;
  900. }
  901. /* add playback controls for HP output */
  902. static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
  903. struct auto_pin_cfg *cfg)
  904. {
  905. struct sigmatel_spec *spec = codec->spec;
  906. hda_nid_t pin = cfg->hp_pin;
  907. unsigned int wid_caps;
  908. if (! pin)
  909. return 0;
  910. wid_caps = get_wcaps(codec, pin);
  911. if (wid_caps & AC_WCAP_UNSOL_CAP)
  912. spec->hp_detect = 1;
  913. return 0;
  914. }
  915. static int stac9200_parse_auto_config(struct hda_codec *codec)
  916. {
  917. struct sigmatel_spec *spec = codec->spec;
  918. int err;
  919. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
  920. return err;
  921. if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
  922. return err;
  923. if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
  924. return err;
  925. if (spec->autocfg.dig_out_pin)
  926. spec->multiout.dig_out_nid = 0x05;
  927. if (spec->autocfg.dig_in_pin)
  928. spec->dig_in_nid = 0x04;
  929. if (spec->kctl_alloc)
  930. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  931. spec->input_mux = &spec->private_imux;
  932. return 1;
  933. }
  934. /*
  935. * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
  936. * funky external mute control using GPIO pins.
  937. */
  938. static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
  939. {
  940. unsigned int gpiostate, gpiomask, gpiodir;
  941. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  942. AC_VERB_GET_GPIO_DATA, 0);
  943. if (!muted)
  944. gpiostate |= (1 << pin);
  945. else
  946. gpiostate &= ~(1 << pin);
  947. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  948. AC_VERB_GET_GPIO_MASK, 0);
  949. gpiomask |= (1 << pin);
  950. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  951. AC_VERB_GET_GPIO_DIRECTION, 0);
  952. gpiodir |= (1 << pin);
  953. /* AppleHDA seems to do this -- WTF is this verb?? */
  954. snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
  955. snd_hda_codec_write(codec, codec->afg, 0,
  956. AC_VERB_SET_GPIO_MASK, gpiomask);
  957. snd_hda_codec_write(codec, codec->afg, 0,
  958. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  959. msleep(1);
  960. snd_hda_codec_write(codec, codec->afg, 0,
  961. AC_VERB_SET_GPIO_DATA, gpiostate);
  962. }
  963. static int stac92xx_init(struct hda_codec *codec)
  964. {
  965. struct sigmatel_spec *spec = codec->spec;
  966. struct auto_pin_cfg *cfg = &spec->autocfg;
  967. int i;
  968. snd_hda_sequence_write(codec, spec->init);
  969. /* set up pins */
  970. if (spec->hp_detect) {
  971. /* Enable unsolicited responses on the HP widget */
  972. snd_hda_codec_write(codec, cfg->hp_pin, 0,
  973. AC_VERB_SET_UNSOLICITED_ENABLE,
  974. STAC_UNSOL_ENABLE);
  975. /* fake event to set up pins */
  976. codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
  977. /* enable the headphones by default. If/when unsol_event detection works, this will be ignored */
  978. stac92xx_auto_init_hp_out(codec);
  979. } else {
  980. stac92xx_auto_init_multi_out(codec);
  981. stac92xx_auto_init_hp_out(codec);
  982. }
  983. for (i = 0; i < AUTO_PIN_LAST; i++) {
  984. hda_nid_t nid = cfg->input_pins[i];
  985. if (nid) {
  986. unsigned int pinctl = AC_PINCTL_IN_EN;
  987. if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
  988. pinctl |= stac92xx_get_vref(codec, nid);
  989. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  990. }
  991. }
  992. if (cfg->dig_out_pin)
  993. stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
  994. AC_PINCTL_OUT_EN);
  995. if (cfg->dig_in_pin)
  996. stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
  997. AC_PINCTL_IN_EN);
  998. if (spec->gpio_mute) {
  999. stac922x_gpio_mute(codec, 0, 0);
  1000. stac922x_gpio_mute(codec, 1, 0);
  1001. }
  1002. return 0;
  1003. }
  1004. static void stac92xx_free(struct hda_codec *codec)
  1005. {
  1006. struct sigmatel_spec *spec = codec->spec;
  1007. int i;
  1008. if (! spec)
  1009. return;
  1010. if (spec->kctl_alloc) {
  1011. for (i = 0; i < spec->num_kctl_used; i++)
  1012. kfree(spec->kctl_alloc[i].name);
  1013. kfree(spec->kctl_alloc);
  1014. }
  1015. kfree(spec);
  1016. }
  1017. static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
  1018. unsigned int flag)
  1019. {
  1020. unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
  1021. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  1022. snd_hda_codec_write(codec, nid, 0,
  1023. AC_VERB_SET_PIN_WIDGET_CONTROL,
  1024. pin_ctl | flag);
  1025. }
  1026. static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
  1027. unsigned int flag)
  1028. {
  1029. unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
  1030. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  1031. snd_hda_codec_write(codec, nid, 0,
  1032. AC_VERB_SET_PIN_WIDGET_CONTROL,
  1033. pin_ctl & ~flag);
  1034. }
  1035. static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
  1036. {
  1037. struct sigmatel_spec *spec = codec->spec;
  1038. struct auto_pin_cfg *cfg = &spec->autocfg;
  1039. int i, presence;
  1040. if ((res >> 26) != STAC_HP_EVENT)
  1041. return;
  1042. presence = snd_hda_codec_read(codec, cfg->hp_pin, 0,
  1043. AC_VERB_GET_PIN_SENSE, 0x00) >> 31;
  1044. if (presence) {
  1045. /* disable lineouts, enable hp */
  1046. for (i = 0; i < cfg->line_outs; i++)
  1047. stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
  1048. AC_PINCTL_OUT_EN);
  1049. stac92xx_set_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
  1050. } else {
  1051. /* enable lineouts, disable hp */
  1052. for (i = 0; i < cfg->line_outs; i++)
  1053. stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
  1054. AC_PINCTL_OUT_EN);
  1055. stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
  1056. }
  1057. }
  1058. #ifdef CONFIG_PM
  1059. static int stac92xx_resume(struct hda_codec *codec)
  1060. {
  1061. struct sigmatel_spec *spec = codec->spec;
  1062. int i;
  1063. stac92xx_init(codec);
  1064. for (i = 0; i < spec->num_mixers; i++)
  1065. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1066. if (spec->multiout.dig_out_nid)
  1067. snd_hda_resume_spdif_out(codec);
  1068. if (spec->dig_in_nid)
  1069. snd_hda_resume_spdif_in(codec);
  1070. return 0;
  1071. }
  1072. #endif
  1073. static struct hda_codec_ops stac92xx_patch_ops = {
  1074. .build_controls = stac92xx_build_controls,
  1075. .build_pcms = stac92xx_build_pcms,
  1076. .init = stac92xx_init,
  1077. .free = stac92xx_free,
  1078. .unsol_event = stac92xx_unsol_event,
  1079. #ifdef CONFIG_PM
  1080. .resume = stac92xx_resume,
  1081. #endif
  1082. };
  1083. static int patch_stac9200(struct hda_codec *codec)
  1084. {
  1085. struct sigmatel_spec *spec;
  1086. int err;
  1087. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1088. if (spec == NULL)
  1089. return -ENOMEM;
  1090. codec->spec = spec;
  1091. spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl);
  1092. if (spec->board_config < 0)
  1093. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
  1094. else {
  1095. spec->num_pins = 8;
  1096. spec->pin_nids = stac9200_pin_nids;
  1097. spec->pin_configs = stac9200_brd_tbl[spec->board_config];
  1098. stac92xx_set_config_regs(codec);
  1099. }
  1100. spec->multiout.max_channels = 2;
  1101. spec->multiout.num_dacs = 1;
  1102. spec->multiout.dac_nids = stac9200_dac_nids;
  1103. spec->adc_nids = stac9200_adc_nids;
  1104. spec->mux_nids = stac9200_mux_nids;
  1105. spec->num_muxes = 1;
  1106. spec->init = stac9200_core_init;
  1107. spec->mixer = stac9200_mixer;
  1108. err = stac9200_parse_auto_config(codec);
  1109. if (err < 0) {
  1110. stac92xx_free(codec);
  1111. return err;
  1112. }
  1113. codec->patch_ops = stac92xx_patch_ops;
  1114. return 0;
  1115. }
  1116. static int patch_stac922x(struct hda_codec *codec)
  1117. {
  1118. struct sigmatel_spec *spec;
  1119. int err;
  1120. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1121. if (spec == NULL)
  1122. return -ENOMEM;
  1123. codec->spec = spec;
  1124. spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl);
  1125. if (spec->board_config < 0)
  1126. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
  1127. "using BIOS defaults\n");
  1128. else if (stac922x_brd_tbl[spec->board_config] != NULL) {
  1129. spec->num_pins = 10;
  1130. spec->pin_nids = stac922x_pin_nids;
  1131. spec->pin_configs = stac922x_brd_tbl[spec->board_config];
  1132. stac92xx_set_config_regs(codec);
  1133. }
  1134. spec->adc_nids = stac922x_adc_nids;
  1135. spec->mux_nids = stac922x_mux_nids;
  1136. spec->num_muxes = 2;
  1137. spec->init = stac922x_core_init;
  1138. spec->mixer = stac922x_mixer;
  1139. spec->multiout.dac_nids = spec->dac_nids;
  1140. switch (spec->board_config) {
  1141. case STAC_D965_2112:
  1142. spec->adc_nids = stac9227_adc_nids;
  1143. spec->mux_nids = stac9227_mux_nids;
  1144. #if 0
  1145. spec->multiout.dac_nids = d965_2112_dac_nids;
  1146. spec->multiout.num_dacs = ARRAY_SIZE(d965_2112_dac_nids);
  1147. #endif
  1148. spec->init = d965_2112_core_init;
  1149. spec->mixer = stac9227_mixer;
  1150. break;
  1151. case STAC_D965_284B:
  1152. spec->adc_nids = stac9227_adc_nids;
  1153. spec->mux_nids = stac9227_mux_nids;
  1154. spec->init = stac9227_core_init;
  1155. spec->mixer = stac9227_mixer;
  1156. break;
  1157. }
  1158. err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
  1159. if (err < 0) {
  1160. stac92xx_free(codec);
  1161. return err;
  1162. }
  1163. if (spec->board_config == STAC_MACMINI)
  1164. spec->gpio_mute = 1;
  1165. codec->patch_ops = stac92xx_patch_ops;
  1166. return 0;
  1167. }
  1168. static int patch_stac927x(struct hda_codec *codec)
  1169. {
  1170. struct sigmatel_spec *spec;
  1171. int err;
  1172. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1173. if (spec == NULL)
  1174. return -ENOMEM;
  1175. codec->spec = spec;
  1176. spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl);
  1177. if (spec->board_config < 0)
  1178. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
  1179. else {
  1180. spec->num_pins = 14;
  1181. spec->pin_nids = stac927x_pin_nids;
  1182. spec->pin_configs = stac927x_brd_tbl[spec->board_config];
  1183. stac92xx_set_config_regs(codec);
  1184. }
  1185. spec->adc_nids = stac927x_adc_nids;
  1186. spec->mux_nids = stac927x_mux_nids;
  1187. spec->num_muxes = 3;
  1188. spec->init = stac927x_core_init;
  1189. spec->mixer = stac927x_mixer;
  1190. spec->multiout.dac_nids = spec->dac_nids;
  1191. err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
  1192. if (err < 0) {
  1193. stac92xx_free(codec);
  1194. return err;
  1195. }
  1196. codec->patch_ops = stac92xx_patch_ops;
  1197. return 0;
  1198. }
  1199. static int patch_stac9205(struct hda_codec *codec)
  1200. {
  1201. struct sigmatel_spec *spec;
  1202. int err;
  1203. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1204. if (spec == NULL)
  1205. return -ENOMEM;
  1206. codec->spec = spec;
  1207. spec->board_config = snd_hda_check_board_config(codec, stac9205_cfg_tbl);
  1208. if (spec->board_config < 0)
  1209. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
  1210. else {
  1211. spec->num_pins = 14;
  1212. spec->pin_nids = stac9205_pin_nids;
  1213. spec->pin_configs = stac9205_brd_tbl[spec->board_config];
  1214. stac92xx_set_config_regs(codec);
  1215. }
  1216. spec->adc_nids = stac9205_adc_nids;
  1217. spec->mux_nids = stac9205_mux_nids;
  1218. spec->num_muxes = 3;
  1219. spec->init = stac9205_core_init;
  1220. spec->mixer = stac9205_mixer;
  1221. spec->multiout.dac_nids = spec->dac_nids;
  1222. err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
  1223. if (err < 0) {
  1224. stac92xx_free(codec);
  1225. return err;
  1226. }
  1227. codec->patch_ops = stac92xx_patch_ops;
  1228. return 0;
  1229. }
  1230. /*
  1231. * STAC 7661(?) and 7664 hack
  1232. */
  1233. /* static config for Sony VAIO FE550G and Sony VAIO AR */
  1234. static hda_nid_t vaio_dacs[] = { 0x2 };
  1235. #define VAIO_HP_DAC 0x5
  1236. static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
  1237. static hda_nid_t vaio_mux_nids[] = { 0x15 };
  1238. static struct hda_input_mux vaio_mux = {
  1239. .num_items = 2,
  1240. .items = {
  1241. /* { "HP", 0x0 }, */
  1242. { "Line", 0x1 },
  1243. { "Mic", 0x2 },
  1244. { "PCM", 0x3 },
  1245. }
  1246. };
  1247. static struct hda_verb vaio_init[] = {
  1248. {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
  1249. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
  1250. {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
  1251. {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
  1252. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
  1253. {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
  1254. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
  1255. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
  1256. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
  1257. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
  1258. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
  1259. {}
  1260. };
  1261. /* bind volumes of both NID 0x02 and 0x05 */
  1262. static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
  1263. struct snd_ctl_elem_value *ucontrol)
  1264. {
  1265. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1266. long *valp = ucontrol->value.integer.value;
  1267. int change;
  1268. change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
  1269. 0x7f, valp[0] & 0x7f);
  1270. change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
  1271. 0x7f, valp[1] & 0x7f);
  1272. snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
  1273. 0x7f, valp[0] & 0x7f);
  1274. snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
  1275. 0x7f, valp[1] & 0x7f);
  1276. return change;
  1277. }
  1278. /* bind volumes of both NID 0x02 and 0x05 */
  1279. static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
  1280. struct snd_ctl_elem_value *ucontrol)
  1281. {
  1282. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1283. long *valp = ucontrol->value.integer.value;
  1284. int change;
  1285. change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
  1286. 0x80, (valp[0] ? 0 : 0x80));
  1287. change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
  1288. 0x80, (valp[1] ? 0 : 0x80));
  1289. snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
  1290. 0x80, (valp[0] ? 0 : 0x80));
  1291. snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
  1292. 0x80, (valp[1] ? 0 : 0x80));
  1293. return change;
  1294. }
  1295. static struct snd_kcontrol_new vaio_mixer[] = {
  1296. {
  1297. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1298. .name = "Master Playback Volume",
  1299. .info = snd_hda_mixer_amp_volume_info,
  1300. .get = snd_hda_mixer_amp_volume_get,
  1301. .put = vaio_master_vol_put,
  1302. .tlv = { .c = snd_hda_mixer_amp_tlv },
  1303. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  1304. },
  1305. {
  1306. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1307. .name = "Master Playback Switch",
  1308. .info = snd_hda_mixer_amp_switch_info,
  1309. .get = snd_hda_mixer_amp_switch_get,
  1310. .put = vaio_master_sw_put,
  1311. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  1312. },
  1313. /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
  1314. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
  1315. HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
  1316. {
  1317. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1318. .name = "Capture Source",
  1319. .count = 1,
  1320. .info = stac92xx_mux_enum_info,
  1321. .get = stac92xx_mux_enum_get,
  1322. .put = stac92xx_mux_enum_put,
  1323. },
  1324. {}
  1325. };
  1326. static struct hda_codec_ops stac766x_patch_ops = {
  1327. .build_controls = stac92xx_build_controls,
  1328. .build_pcms = stac92xx_build_pcms,
  1329. .init = stac92xx_init,
  1330. .free = stac92xx_free,
  1331. #ifdef CONFIG_PM
  1332. .resume = stac92xx_resume,
  1333. #endif
  1334. };
  1335. enum { STAC766x_VAIO };
  1336. static struct hda_board_config stac766x_cfg_tbl[] = {
  1337. { .modelname = "vaio", .config = STAC766x_VAIO },
  1338. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81e6,
  1339. .config = STAC766x_VAIO },
  1340. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81ef,
  1341. .config = STAC766x_VAIO },
  1342. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81fd,
  1343. .config = STAC766x_VAIO },
  1344. {}
  1345. };
  1346. static int patch_stac766x(struct hda_codec *codec)
  1347. {
  1348. struct sigmatel_spec *spec;
  1349. int board_config;
  1350. board_config = snd_hda_check_board_config(codec, stac766x_cfg_tbl);
  1351. if (board_config < 0)
  1352. /* unknown config, let generic-parser do its job... */
  1353. return snd_hda_parse_generic_codec(codec);
  1354. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1355. if (spec == NULL)
  1356. return -ENOMEM;
  1357. codec->spec = spec;
  1358. switch (board_config) {
  1359. case STAC766x_VAIO:
  1360. spec->mixer = vaio_mixer;
  1361. spec->init = vaio_init;
  1362. spec->multiout.max_channels = 2;
  1363. spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
  1364. spec->multiout.dac_nids = vaio_dacs;
  1365. spec->multiout.hp_nid = VAIO_HP_DAC;
  1366. spec->num_adcs = ARRAY_SIZE(vaio_adcs);
  1367. spec->adc_nids = vaio_adcs;
  1368. spec->input_mux = &vaio_mux;
  1369. spec->mux_nids = vaio_mux_nids;
  1370. break;
  1371. }
  1372. codec->patch_ops = stac766x_patch_ops;
  1373. return 0;
  1374. }
  1375. /*
  1376. * patch entries
  1377. */
  1378. struct hda_codec_preset snd_hda_preset_sigmatel[] = {
  1379. { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
  1380. { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
  1381. { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
  1382. { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
  1383. { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
  1384. { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
  1385. { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
  1386. { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
  1387. { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
  1388. { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
  1389. { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
  1390. { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
  1391. { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
  1392. { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
  1393. { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
  1394. { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
  1395. { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
  1396. { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
  1397. { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
  1398. { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
  1399. { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
  1400. { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
  1401. { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
  1402. { .id = 0x83847661, .name = "STAC7661", .patch = patch_stac766x },
  1403. { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
  1404. { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
  1405. { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
  1406. { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
  1407. { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
  1408. { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
  1409. { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
  1410. { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
  1411. { .id = 0x83847664, .name = "STAC7664", .patch = patch_stac766x },
  1412. {} /* terminator */
  1413. };