patch_sigmatel.c 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053
  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_922X_MODELS 4 /* number of 922x models */
  43. #define STAC_D965_3ST 4
  44. #define STAC_D965_5ST 5
  45. #define STAC_927X_MODELS 6 /* number of 922x models */
  46. struct sigmatel_spec {
  47. struct snd_kcontrol_new *mixers[4];
  48. unsigned int num_mixers;
  49. int board_config;
  50. unsigned int surr_switch: 1;
  51. unsigned int line_switch: 1;
  52. unsigned int mic_switch: 1;
  53. unsigned int alt_switch: 1;
  54. unsigned int hp_detect: 1;
  55. unsigned int gpio_mute: 1;
  56. /* playback */
  57. struct hda_multi_out multiout;
  58. hda_nid_t dac_nids[5];
  59. /* capture */
  60. hda_nid_t *adc_nids;
  61. unsigned int num_adcs;
  62. hda_nid_t *mux_nids;
  63. unsigned int num_muxes;
  64. hda_nid_t dig_in_nid;
  65. /* pin widgets */
  66. hda_nid_t *pin_nids;
  67. unsigned int num_pins;
  68. unsigned int *pin_configs;
  69. unsigned int *bios_pin_configs;
  70. /* codec specific stuff */
  71. struct hda_verb *init;
  72. struct snd_kcontrol_new *mixer;
  73. /* capture source */
  74. struct hda_input_mux *input_mux;
  75. unsigned int cur_mux[3];
  76. /* i/o switches */
  77. unsigned int io_switch[2];
  78. struct hda_pcm pcm_rec[2]; /* PCM information */
  79. /* dynamic controls and input_mux */
  80. struct auto_pin_cfg autocfg;
  81. unsigned int num_kctl_alloc, num_kctl_used;
  82. struct snd_kcontrol_new *kctl_alloc;
  83. struct hda_input_mux private_imux;
  84. };
  85. static hda_nid_t stac9200_adc_nids[1] = {
  86. 0x03,
  87. };
  88. static hda_nid_t stac9200_mux_nids[1] = {
  89. 0x0c,
  90. };
  91. static hda_nid_t stac9200_dac_nids[1] = {
  92. 0x02,
  93. };
  94. static hda_nid_t stac922x_adc_nids[2] = {
  95. 0x06, 0x07,
  96. };
  97. static hda_nid_t stac922x_mux_nids[2] = {
  98. 0x12, 0x13,
  99. };
  100. static hda_nid_t stac927x_adc_nids[3] = {
  101. 0x07, 0x08, 0x09
  102. };
  103. static hda_nid_t stac927x_mux_nids[3] = {
  104. 0x15, 0x16, 0x17
  105. };
  106. static hda_nid_t stac9205_adc_nids[2] = {
  107. 0x12, 0x13
  108. };
  109. static hda_nid_t stac9205_mux_nids[2] = {
  110. 0x19, 0x1a
  111. };
  112. static hda_nid_t stac9200_pin_nids[8] = {
  113. 0x08, 0x09, 0x0d, 0x0e,
  114. 0x0f, 0x10, 0x11, 0x12,
  115. };
  116. static hda_nid_t stac922x_pin_nids[10] = {
  117. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  118. 0x0f, 0x10, 0x11, 0x15, 0x1b,
  119. };
  120. static hda_nid_t stac927x_pin_nids[14] = {
  121. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  122. 0x0f, 0x10, 0x11, 0x12, 0x13,
  123. 0x14, 0x21, 0x22, 0x23,
  124. };
  125. static hda_nid_t stac9205_pin_nids[12] = {
  126. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  127. 0x0f, 0x14, 0x16, 0x17, 0x18,
  128. 0x21, 0x22,
  129. };
  130. static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  131. {
  132. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  133. struct sigmatel_spec *spec = codec->spec;
  134. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  135. }
  136. static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  137. {
  138. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  139. struct sigmatel_spec *spec = codec->spec;
  140. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  141. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  142. return 0;
  143. }
  144. static int stac92xx_mux_enum_put(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. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  150. spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
  151. }
  152. static struct hda_verb stac9200_core_init[] = {
  153. /* set dac0mux for dac converter */
  154. { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  155. {}
  156. };
  157. static struct hda_verb stac922x_core_init[] = {
  158. /* set master volume and direct control */
  159. { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  160. {}
  161. };
  162. static struct hda_verb d965_core_init[] = {
  163. /* set master volume and direct control */
  164. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  165. /* unmute node 0x1b */
  166. { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  167. /* select node 0x03 as DAC */
  168. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
  169. {}
  170. };
  171. static struct hda_verb stac927x_core_init[] = {
  172. /* set master volume and direct control */
  173. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  174. {}
  175. };
  176. static struct hda_verb stac9205_core_init[] = {
  177. /* set master volume and direct control */
  178. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  179. {}
  180. };
  181. static struct snd_kcontrol_new stac9200_mixer[] = {
  182. HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
  183. HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
  184. {
  185. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  186. .name = "Input Source",
  187. .count = 1,
  188. .info = stac92xx_mux_enum_info,
  189. .get = stac92xx_mux_enum_get,
  190. .put = stac92xx_mux_enum_put,
  191. },
  192. HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
  193. HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
  194. HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
  195. { } /* end */
  196. };
  197. /* This needs to be generated dynamically based on sequence */
  198. static struct snd_kcontrol_new stac922x_mixer[] = {
  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", 0x17, 0x0, HDA_INPUT),
  208. HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
  209. HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
  210. { } /* end */
  211. };
  212. /* This needs to be generated dynamically based on sequence */
  213. static struct snd_kcontrol_new stac9227_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", 0x15, 0x0, HDA_OUTPUT),
  223. HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
  224. { } /* end */
  225. };
  226. static snd_kcontrol_new_t stac927x_mixer[] = {
  227. {
  228. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  229. .name = "Input Source",
  230. .count = 1,
  231. .info = stac92xx_mux_enum_info,
  232. .get = stac92xx_mux_enum_get,
  233. .put = stac92xx_mux_enum_put,
  234. },
  235. HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
  236. HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
  237. HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
  238. { } /* end */
  239. };
  240. static snd_kcontrol_new_t stac9205_mixer[] = {
  241. {
  242. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  243. .name = "Input Source",
  244. .count = 1,
  245. .info = stac92xx_mux_enum_info,
  246. .get = stac92xx_mux_enum_get,
  247. .put = stac92xx_mux_enum_put,
  248. },
  249. HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT),
  250. HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT),
  251. HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT),
  252. { } /* end */
  253. };
  254. static int stac92xx_build_controls(struct hda_codec *codec)
  255. {
  256. struct sigmatel_spec *spec = codec->spec;
  257. int err;
  258. int i;
  259. err = snd_hda_add_new_ctls(codec, spec->mixer);
  260. if (err < 0)
  261. return err;
  262. for (i = 0; i < spec->num_mixers; i++) {
  263. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  264. if (err < 0)
  265. return err;
  266. }
  267. if (spec->multiout.dig_out_nid) {
  268. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  269. if (err < 0)
  270. return err;
  271. }
  272. if (spec->dig_in_nid) {
  273. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  274. if (err < 0)
  275. return err;
  276. }
  277. return 0;
  278. }
  279. static unsigned int ref9200_pin_configs[8] = {
  280. 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
  281. 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
  282. };
  283. static unsigned int *stac9200_brd_tbl[] = {
  284. ref9200_pin_configs,
  285. };
  286. static struct hda_board_config stac9200_cfg_tbl[] = {
  287. { .modelname = "ref",
  288. .pci_subvendor = PCI_VENDOR_ID_INTEL,
  289. .pci_subdevice = 0x2668, /* DFI LanParty */
  290. .config = STAC_REF },
  291. {} /* terminator */
  292. };
  293. static unsigned int ref922x_pin_configs[10] = {
  294. 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
  295. 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
  296. 0x40000100, 0x40000100,
  297. };
  298. static unsigned int d945gtp3_pin_configs[10] = {
  299. 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
  300. 0x40000100, 0x40000100, 0x40000100, 0x40000100,
  301. 0x02a19120, 0x40000100,
  302. };
  303. static unsigned int d945gtp5_pin_configs[10] = {
  304. 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
  305. 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
  306. 0x02a19320, 0x40000100,
  307. };
  308. static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
  309. [STAC_REF] = ref922x_pin_configs,
  310. [STAC_D945GTP3] = d945gtp3_pin_configs,
  311. [STAC_D945GTP5] = d945gtp5_pin_configs,
  312. [STAC_MACMINI] = d945gtp5_pin_configs,
  313. };
  314. static struct hda_board_config stac922x_cfg_tbl[] = {
  315. { .modelname = "5stack", .config = STAC_D945GTP5 },
  316. { .modelname = "3stack", .config = STAC_D945GTP3 },
  317. { .modelname = "ref",
  318. .pci_subvendor = PCI_VENDOR_ID_INTEL,
  319. .pci_subdevice = 0x2668, /* DFI LanParty */
  320. .config = STAC_REF }, /* SigmaTel reference board */
  321. /* Intel 945G based systems */
  322. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  323. .pci_subdevice = 0x0101,
  324. .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */
  325. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  326. .pci_subdevice = 0x0202,
  327. .config = STAC_D945GTP3 }, /* Intel D945GNT - 3 Stack */
  328. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  329. .pci_subdevice = 0x0606,
  330. .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */
  331. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  332. .pci_subdevice = 0x0601,
  333. .config = STAC_D945GTP3 }, /* Intel D945GTP - 3 Stack */
  334. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  335. .pci_subdevice = 0x0111,
  336. .config = STAC_D945GTP3 }, /* Intel D945GZP - 3 Stack */
  337. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  338. .pci_subdevice = 0x1115,
  339. .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
  340. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  341. .pci_subdevice = 0x1116,
  342. .config = STAC_D945GTP3 }, /* Intel D945GBO - 3 Stack */
  343. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  344. .pci_subdevice = 0x1117,
  345. .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
  346. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  347. .pci_subdevice = 0x1118,
  348. .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
  349. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  350. .pci_subdevice = 0x1119,
  351. .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
  352. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  353. .pci_subdevice = 0x8826,
  354. .config = STAC_D945GTP3 }, /* Intel D945GPM - 3 Stack */
  355. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  356. .pci_subdevice = 0x5049,
  357. .config = STAC_D945GTP3 }, /* Intel D945GCZ - 3 Stack */
  358. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  359. .pci_subdevice = 0x5055,
  360. .config = STAC_D945GTP3 }, /* Intel D945GCZ - 3 Stack */
  361. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  362. .pci_subdevice = 0x5048,
  363. .config = STAC_D945GTP3 }, /* Intel D945GPB - 3 Stack */
  364. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  365. .pci_subdevice = 0x0110,
  366. .config = STAC_D945GTP3 }, /* Intel D945GLR - 3 Stack */
  367. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  368. .pci_subdevice = 0x0404,
  369. .config = STAC_D945GTP5 }, /* Intel D945GTP - 5 Stack */
  370. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  371. .pci_subdevice = 0x0303,
  372. .config = STAC_D945GTP5 }, /* Intel D945GNT - 5 Stack */
  373. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  374. .pci_subdevice = 0x0013,
  375. .config = STAC_D945GTP5 }, /* Intel D955XBK - 5 Stack */
  376. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  377. .pci_subdevice = 0x0417,
  378. .config = STAC_D945GTP5 }, /* Intel D975XBK - 5 Stack */
  379. /* Intel 945P based systems */
  380. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  381. .pci_subdevice = 0x0b0b,
  382. .config = STAC_D945GTP3 }, /* Intel D945PSN - 3 Stack */
  383. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  384. .pci_subdevice = 0x0112,
  385. .config = STAC_D945GTP3 }, /* Intel D945PLN - 3 Stack */
  386. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  387. .pci_subdevice = 0x0d0d,
  388. .config = STAC_D945GTP3 }, /* Intel D945PLM - 3 Stack */
  389. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  390. .pci_subdevice = 0x0909,
  391. .config = STAC_D945GTP3 }, /* Intel D945PAW - 3 Stack */
  392. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  393. .pci_subdevice = 0x0505,
  394. .config = STAC_D945GTP3 }, /* Intel D945PLM - 3 Stack */
  395. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  396. .pci_subdevice = 0x0707,
  397. .config = STAC_D945GTP5 }, /* Intel D945PSV - 5 Stack */
  398. /* other systems */
  399. { .pci_subvendor = 0x8384,
  400. .pci_subdevice = 0x7680,
  401. .config = STAC_MACMINI }, /* Apple Mac Mini (early 2006) */
  402. {} /* terminator */
  403. };
  404. static unsigned int ref927x_pin_configs[14] = {
  405. 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
  406. 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
  407. 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
  408. 0x01c42190, 0x40000100,
  409. };
  410. static unsigned int d965_3st_pin_configs[14] = {
  411. 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
  412. 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
  413. 0x40000100, 0x40000100, 0x40000100, 0x40000100,
  414. 0x40000100, 0x40000100
  415. };
  416. static unsigned int d965_5st_pin_configs[14] = {
  417. 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
  418. 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
  419. 0x40000100, 0x40000100, 0x40000100, 0x01442070,
  420. 0x40000100, 0x40000100
  421. };
  422. static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
  423. [STAC_REF] = ref927x_pin_configs,
  424. [STAC_D965_3ST] = d965_3st_pin_configs,
  425. [STAC_D965_5ST] = d965_5st_pin_configs,
  426. };
  427. static struct hda_board_config stac927x_cfg_tbl[] = {
  428. { .modelname = "5stack", .config = STAC_D965_5ST },
  429. { .modelname = "3stack", .config = STAC_D965_3ST },
  430. { .modelname = "ref",
  431. .pci_subvendor = PCI_VENDOR_ID_INTEL,
  432. .pci_subdevice = 0x2668, /* DFI LanParty */
  433. .config = STAC_REF }, /* SigmaTel reference board */
  434. /* Intel 946 based systems */
  435. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  436. .pci_subdevice = 0x3d01,
  437. .config = STAC_D965_3ST }, /* D946 configuration */
  438. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  439. .pci_subdevice = 0xa301,
  440. .config = STAC_D965_3ST }, /* Intel D946GZT - 3 stack */
  441. /* 965 based 3 stack systems */
  442. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  443. .pci_subdevice = 0x2116,
  444. .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
  445. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  446. .pci_subdevice = 0x2115,
  447. .config = STAC_D965_3ST }, /* Intel DQ965WC - 3 Stack */
  448. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  449. .pci_subdevice = 0x2114,
  450. .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
  451. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  452. .pci_subdevice = 0x2113,
  453. .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
  454. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  455. .pci_subdevice = 0x2112,
  456. .config = STAC_D965_3ST }, /* Intel DG965MS - 3 Stack */
  457. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  458. .pci_subdevice = 0x2111,
  459. .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
  460. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  461. .pci_subdevice = 0x2110,
  462. .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
  463. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  464. .pci_subdevice = 0x2009,
  465. .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
  466. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  467. .pci_subdevice = 0x2008,
  468. .config = STAC_D965_3ST }, /* Intel DQ965GF - 3 Stack */
  469. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  470. .pci_subdevice = 0x2007,
  471. .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
  472. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  473. .pci_subdevice = 0x2006,
  474. .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
  475. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  476. .pci_subdevice = 0x2005,
  477. .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
  478. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  479. .pci_subdevice = 0x2004,
  480. .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
  481. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  482. .pci_subdevice = 0x2003,
  483. .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
  484. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  485. .pci_subdevice = 0x2002,
  486. .config = STAC_D965_3ST }, /* Intel D965 3Stack config */
  487. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  488. .pci_subdevice = 0x2001,
  489. .config = STAC_D965_3ST }, /* Intel DQ965GF - 3 Stack */
  490. /* 965 based 5 stack systems */
  491. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  492. .pci_subdevice = 0x2301,
  493. .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
  494. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  495. .pci_subdevice = 0x2302,
  496. .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
  497. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  498. .pci_subdevice = 0x2303,
  499. .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
  500. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  501. .pci_subdevice = 0x2304,
  502. .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
  503. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  504. .pci_subdevice = 0x2305,
  505. .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
  506. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  507. .pci_subdevice = 0x2501,
  508. .config = STAC_D965_5ST }, /* Intel DG965MQ - 5 Stack */
  509. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  510. .pci_subdevice = 0x2502,
  511. .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
  512. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  513. .pci_subdevice = 0x2503,
  514. .config = STAC_D965_5ST }, /* Intel DG965 - 5 Stack */
  515. { .pci_subvendor = PCI_VENDOR_ID_INTEL,
  516. .pci_subdevice = 0x2504,
  517. .config = STAC_D965_5ST }, /* Intel DQ965GF - 5 Stack */
  518. {} /* terminator */
  519. };
  520. static unsigned int ref9205_pin_configs[12] = {
  521. 0x40000100, 0x40000100, 0x01016011, 0x01014010,
  522. 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
  523. 0x40000100, 0x40000100, 0x01441030, 0x01c41030
  524. };
  525. static unsigned int *stac9205_brd_tbl[] = {
  526. ref9205_pin_configs,
  527. };
  528. static struct hda_board_config stac9205_cfg_tbl[] = {
  529. { .modelname = "ref",
  530. .pci_subvendor = PCI_VENDOR_ID_INTEL,
  531. .pci_subdevice = 0x2668, /* DFI LanParty */
  532. .config = STAC_REF }, /* SigmaTel reference board */
  533. /* Dell laptops have BIOS problem */
  534. { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01b5,
  535. .config = STAC_REF }, /* Dell Inspiron 630m */
  536. { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01c2,
  537. .config = STAC_REF }, /* Dell Latitude D620 */
  538. { .pci_subvendor = PCI_VENDOR_ID_DELL, .pci_subdevice = 0x01cb,
  539. .config = STAC_REF }, /* Dell Latitude 120L */
  540. {} /* terminator */
  541. };
  542. static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
  543. {
  544. int i;
  545. struct sigmatel_spec *spec = codec->spec;
  546. if (! spec->bios_pin_configs) {
  547. spec->bios_pin_configs = kcalloc(spec->num_pins,
  548. sizeof(*spec->bios_pin_configs), GFP_KERNEL);
  549. if (! spec->bios_pin_configs)
  550. return -ENOMEM;
  551. }
  552. for (i = 0; i < spec->num_pins; i++) {
  553. hda_nid_t nid = spec->pin_nids[i];
  554. unsigned int pin_cfg;
  555. pin_cfg = snd_hda_codec_read(codec, nid, 0,
  556. AC_VERB_GET_CONFIG_DEFAULT, 0x00);
  557. snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
  558. nid, pin_cfg);
  559. spec->bios_pin_configs[i] = pin_cfg;
  560. }
  561. return 0;
  562. }
  563. static void stac92xx_set_config_regs(struct hda_codec *codec)
  564. {
  565. int i;
  566. struct sigmatel_spec *spec = codec->spec;
  567. unsigned int pin_cfg;
  568. if (! spec->pin_nids || ! spec->pin_configs)
  569. return;
  570. for (i = 0; i < spec->num_pins; i++) {
  571. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  572. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
  573. spec->pin_configs[i] & 0x000000ff);
  574. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  575. AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
  576. (spec->pin_configs[i] & 0x0000ff00) >> 8);
  577. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  578. AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
  579. (spec->pin_configs[i] & 0x00ff0000) >> 16);
  580. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  581. AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
  582. spec->pin_configs[i] >> 24);
  583. pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
  584. AC_VERB_GET_CONFIG_DEFAULT,
  585. 0x00);
  586. snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg);
  587. }
  588. }
  589. /*
  590. * Analog playback callbacks
  591. */
  592. static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
  593. struct hda_codec *codec,
  594. struct snd_pcm_substream *substream)
  595. {
  596. struct sigmatel_spec *spec = codec->spec;
  597. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  598. }
  599. static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  600. struct hda_codec *codec,
  601. unsigned int stream_tag,
  602. unsigned int format,
  603. struct snd_pcm_substream *substream)
  604. {
  605. struct sigmatel_spec *spec = codec->spec;
  606. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
  607. }
  608. static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  609. struct hda_codec *codec,
  610. struct snd_pcm_substream *substream)
  611. {
  612. struct sigmatel_spec *spec = codec->spec;
  613. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  614. }
  615. /*
  616. * Digital playback callbacks
  617. */
  618. static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  619. struct hda_codec *codec,
  620. struct snd_pcm_substream *substream)
  621. {
  622. struct sigmatel_spec *spec = codec->spec;
  623. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  624. }
  625. static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  626. struct hda_codec *codec,
  627. struct snd_pcm_substream *substream)
  628. {
  629. struct sigmatel_spec *spec = codec->spec;
  630. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  631. }
  632. /*
  633. * Analog capture callbacks
  634. */
  635. static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  636. struct hda_codec *codec,
  637. unsigned int stream_tag,
  638. unsigned int format,
  639. struct snd_pcm_substream *substream)
  640. {
  641. struct sigmatel_spec *spec = codec->spec;
  642. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  643. stream_tag, 0, format);
  644. return 0;
  645. }
  646. static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  647. struct hda_codec *codec,
  648. struct snd_pcm_substream *substream)
  649. {
  650. struct sigmatel_spec *spec = codec->spec;
  651. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
  652. return 0;
  653. }
  654. static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
  655. .substreams = 1,
  656. .channels_min = 2,
  657. .channels_max = 2,
  658. /* NID is set in stac92xx_build_pcms */
  659. .ops = {
  660. .open = stac92xx_dig_playback_pcm_open,
  661. .close = stac92xx_dig_playback_pcm_close
  662. },
  663. };
  664. static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
  665. .substreams = 1,
  666. .channels_min = 2,
  667. .channels_max = 2,
  668. /* NID is set in stac92xx_build_pcms */
  669. };
  670. static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
  671. .substreams = 1,
  672. .channels_min = 2,
  673. .channels_max = 8,
  674. .nid = 0x02, /* NID to query formats and rates */
  675. .ops = {
  676. .open = stac92xx_playback_pcm_open,
  677. .prepare = stac92xx_playback_pcm_prepare,
  678. .cleanup = stac92xx_playback_pcm_cleanup
  679. },
  680. };
  681. static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
  682. .substreams = 1,
  683. .channels_min = 2,
  684. .channels_max = 2,
  685. .nid = 0x06, /* NID to query formats and rates */
  686. .ops = {
  687. .open = stac92xx_playback_pcm_open,
  688. .prepare = stac92xx_playback_pcm_prepare,
  689. .cleanup = stac92xx_playback_pcm_cleanup
  690. },
  691. };
  692. static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
  693. .substreams = 2,
  694. .channels_min = 2,
  695. .channels_max = 2,
  696. /* NID is set in stac92xx_build_pcms */
  697. .ops = {
  698. .prepare = stac92xx_capture_pcm_prepare,
  699. .cleanup = stac92xx_capture_pcm_cleanup
  700. },
  701. };
  702. static int stac92xx_build_pcms(struct hda_codec *codec)
  703. {
  704. struct sigmatel_spec *spec = codec->spec;
  705. struct hda_pcm *info = spec->pcm_rec;
  706. codec->num_pcms = 1;
  707. codec->pcm_info = info;
  708. info->name = "STAC92xx Analog";
  709. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
  710. info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
  711. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  712. if (spec->alt_switch) {
  713. codec->num_pcms++;
  714. info++;
  715. info->name = "STAC92xx Analog Alt";
  716. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
  717. }
  718. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  719. codec->num_pcms++;
  720. info++;
  721. info->name = "STAC92xx Digital";
  722. if (spec->multiout.dig_out_nid) {
  723. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
  724. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  725. }
  726. if (spec->dig_in_nid) {
  727. info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
  728. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  729. }
  730. }
  731. return 0;
  732. }
  733. static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
  734. {
  735. unsigned int pincap = snd_hda_param_read(codec, nid,
  736. AC_PAR_PIN_CAP);
  737. pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
  738. if (pincap & AC_PINCAP_VREF_100)
  739. return AC_PINCTL_VREF_100;
  740. if (pincap & AC_PINCAP_VREF_80)
  741. return AC_PINCTL_VREF_80;
  742. if (pincap & AC_PINCAP_VREF_50)
  743. return AC_PINCTL_VREF_50;
  744. if (pincap & AC_PINCAP_VREF_GRD)
  745. return AC_PINCTL_VREF_GRD;
  746. return 0;
  747. }
  748. static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
  749. {
  750. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  751. }
  752. static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  753. {
  754. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  755. uinfo->count = 1;
  756. uinfo->value.integer.min = 0;
  757. uinfo->value.integer.max = 1;
  758. return 0;
  759. }
  760. static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  761. {
  762. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  763. struct sigmatel_spec *spec = codec->spec;
  764. int io_idx = kcontrol-> private_value & 0xff;
  765. ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
  766. return 0;
  767. }
  768. static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  769. {
  770. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  771. struct sigmatel_spec *spec = codec->spec;
  772. hda_nid_t nid = kcontrol->private_value >> 8;
  773. int io_idx = kcontrol-> private_value & 0xff;
  774. unsigned short val = ucontrol->value.integer.value[0];
  775. spec->io_switch[io_idx] = val;
  776. if (val)
  777. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  778. else {
  779. unsigned int pinctl = AC_PINCTL_IN_EN;
  780. if (io_idx) /* set VREF for mic */
  781. pinctl |= stac92xx_get_vref(codec, nid);
  782. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  783. }
  784. return 1;
  785. }
  786. #define STAC_CODEC_IO_SWITCH(xname, xpval) \
  787. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  788. .name = xname, \
  789. .index = 0, \
  790. .info = stac92xx_io_switch_info, \
  791. .get = stac92xx_io_switch_get, \
  792. .put = stac92xx_io_switch_put, \
  793. .private_value = xpval, \
  794. }
  795. enum {
  796. STAC_CTL_WIDGET_VOL,
  797. STAC_CTL_WIDGET_MUTE,
  798. STAC_CTL_WIDGET_IO_SWITCH,
  799. };
  800. static struct snd_kcontrol_new stac92xx_control_templates[] = {
  801. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  802. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  803. STAC_CODEC_IO_SWITCH(NULL, 0),
  804. };
  805. /* add dynamic controls */
  806. static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
  807. {
  808. struct snd_kcontrol_new *knew;
  809. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  810. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  811. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  812. if (! knew)
  813. return -ENOMEM;
  814. if (spec->kctl_alloc) {
  815. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  816. kfree(spec->kctl_alloc);
  817. }
  818. spec->kctl_alloc = knew;
  819. spec->num_kctl_alloc = num;
  820. }
  821. knew = &spec->kctl_alloc[spec->num_kctl_used];
  822. *knew = stac92xx_control_templates[type];
  823. knew->name = kstrdup(name, GFP_KERNEL);
  824. if (! knew->name)
  825. return -ENOMEM;
  826. knew->private_value = val;
  827. spec->num_kctl_used++;
  828. return 0;
  829. }
  830. /* flag inputs as additional dynamic lineouts */
  831. static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
  832. {
  833. struct sigmatel_spec *spec = codec->spec;
  834. switch (cfg->line_outs) {
  835. case 3:
  836. /* add line-in as side */
  837. if (cfg->input_pins[AUTO_PIN_LINE]) {
  838. cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
  839. spec->line_switch = 1;
  840. cfg->line_outs++;
  841. }
  842. break;
  843. case 2:
  844. /* add line-in as clfe and mic as side */
  845. if (cfg->input_pins[AUTO_PIN_LINE]) {
  846. cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
  847. spec->line_switch = 1;
  848. cfg->line_outs++;
  849. }
  850. if (cfg->input_pins[AUTO_PIN_MIC]) {
  851. cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
  852. spec->mic_switch = 1;
  853. cfg->line_outs++;
  854. }
  855. break;
  856. case 1:
  857. /* add line-in as surr and mic as clfe */
  858. if (cfg->input_pins[AUTO_PIN_LINE]) {
  859. cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
  860. spec->line_switch = 1;
  861. cfg->line_outs++;
  862. }
  863. if (cfg->input_pins[AUTO_PIN_MIC]) {
  864. cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
  865. spec->mic_switch = 1;
  866. cfg->line_outs++;
  867. }
  868. break;
  869. }
  870. return 0;
  871. }
  872. /*
  873. * XXX The line_out pin widget connection list may not be set to the
  874. * desired DAC nid. This is the case on 927x where ports A and B can
  875. * be routed to several DACs.
  876. *
  877. * This requires an analysis of the line-out/hp pin configuration
  878. * to provide a best fit for pin/DAC configurations that are routable.
  879. * For now, 927x DAC4 is not supported and 927x DAC1 output to ports
  880. * A and B is not supported.
  881. */
  882. /* fill in the dac_nids table from the parsed pin configuration */
  883. static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
  884. const struct auto_pin_cfg *cfg)
  885. {
  886. struct sigmatel_spec *spec = codec->spec;
  887. hda_nid_t nid;
  888. int i;
  889. /* check the pins hardwired to audio widget */
  890. for (i = 0; i < cfg->line_outs; i++) {
  891. nid = cfg->line_out_pins[i];
  892. spec->multiout.dac_nids[i] = snd_hda_codec_read(codec, nid, 0,
  893. AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
  894. }
  895. spec->multiout.num_dacs = cfg->line_outs;
  896. return 0;
  897. }
  898. /* create volume control/switch for the given prefx type */
  899. static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
  900. {
  901. char name[32];
  902. int err;
  903. sprintf(name, "%s Playback Volume", pfx);
  904. err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
  905. HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
  906. if (err < 0)
  907. return err;
  908. sprintf(name, "%s Playback Switch", pfx);
  909. err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
  910. HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
  911. if (err < 0)
  912. return err;
  913. return 0;
  914. }
  915. /* add playback controls from the parsed DAC table */
  916. static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
  917. const struct auto_pin_cfg *cfg)
  918. {
  919. static const char *chname[4] = {
  920. "Front", "Surround", NULL /*CLFE*/, "Side"
  921. };
  922. hda_nid_t nid;
  923. int i, err;
  924. for (i = 0; i < cfg->line_outs; i++) {
  925. if (!spec->multiout.dac_nids[i])
  926. continue;
  927. nid = spec->multiout.dac_nids[i];
  928. if (i == 2) {
  929. /* Center/LFE */
  930. err = create_controls(spec, "Center", nid, 1);
  931. if (err < 0)
  932. return err;
  933. err = create_controls(spec, "LFE", nid, 2);
  934. if (err < 0)
  935. return err;
  936. } else {
  937. err = create_controls(spec, chname[i], nid, 3);
  938. if (err < 0)
  939. return err;
  940. }
  941. }
  942. if (spec->line_switch)
  943. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
  944. return err;
  945. if (spec->mic_switch)
  946. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
  947. return err;
  948. return 0;
  949. }
  950. static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
  951. {
  952. int i;
  953. for (i = 0; i < spec->multiout.num_dacs; i++) {
  954. if (spec->multiout.dac_nids[i] == nid)
  955. return 1;
  956. }
  957. if (spec->multiout.hp_nid == nid)
  958. return 1;
  959. return 0;
  960. }
  961. static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
  962. {
  963. if (!spec->multiout.hp_nid)
  964. spec->multiout.hp_nid = nid;
  965. else if (spec->multiout.num_dacs > 4) {
  966. printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
  967. return 1;
  968. } else {
  969. spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
  970. spec->multiout.num_dacs++;
  971. }
  972. return 0;
  973. }
  974. /* add playback controls for Speaker and HP outputs */
  975. static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
  976. struct auto_pin_cfg *cfg)
  977. {
  978. struct sigmatel_spec *spec = codec->spec;
  979. hda_nid_t nid;
  980. int i, old_num_dacs, err;
  981. old_num_dacs = spec->multiout.num_dacs;
  982. for (i = 0; i < cfg->hp_outs; i++) {
  983. unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
  984. if (wid_caps & AC_WCAP_UNSOL_CAP)
  985. spec->hp_detect = 1;
  986. nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
  987. AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
  988. if (check_in_dac_nids(spec, nid))
  989. nid = 0;
  990. if (! nid)
  991. continue;
  992. add_spec_dacs(spec, nid);
  993. }
  994. for (i = 0; i < cfg->speaker_outs; i++) {
  995. nid = snd_hda_codec_read(codec, cfg->speaker_pins[0], 0,
  996. AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
  997. if (check_in_dac_nids(spec, nid))
  998. nid = 0;
  999. if (check_in_dac_nids(spec, nid))
  1000. nid = 0;
  1001. if (! nid)
  1002. continue;
  1003. add_spec_dacs(spec, nid);
  1004. }
  1005. for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
  1006. static const char *pfxs[] = {
  1007. "Speaker", "External Speaker", "Speaker2",
  1008. };
  1009. err = create_controls(spec, pfxs[i - old_num_dacs],
  1010. spec->multiout.dac_nids[i], 3);
  1011. if (err < 0)
  1012. return err;
  1013. }
  1014. if (spec->multiout.hp_nid) {
  1015. const char *pfx;
  1016. if (old_num_dacs == spec->multiout.num_dacs)
  1017. pfx = "Master";
  1018. else
  1019. pfx = "Headphone";
  1020. err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
  1021. if (err < 0)
  1022. return err;
  1023. }
  1024. return 0;
  1025. }
  1026. /* create playback/capture controls for input pins */
  1027. static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
  1028. {
  1029. struct sigmatel_spec *spec = codec->spec;
  1030. struct hda_input_mux *imux = &spec->private_imux;
  1031. hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
  1032. int i, j, k;
  1033. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1034. int index = -1;
  1035. if (cfg->input_pins[i]) {
  1036. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  1037. for (j=0; j<spec->num_muxes; j++) {
  1038. int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS);
  1039. for (k=0; k<num_cons; k++)
  1040. if (con_lst[k] == cfg->input_pins[i]) {
  1041. index = k;
  1042. break;
  1043. }
  1044. if (index >= 0)
  1045. break;
  1046. }
  1047. imux->items[imux->num_items].index = index;
  1048. imux->num_items++;
  1049. }
  1050. }
  1051. if (imux->num_items == 1) {
  1052. /*
  1053. * Set the current input for the muxes.
  1054. * The STAC9221 has two input muxes with identical source
  1055. * NID lists. Hopefully this won't get confused.
  1056. */
  1057. for (i = 0; i < spec->num_muxes; i++) {
  1058. snd_hda_codec_write(codec, spec->mux_nids[i], 0,
  1059. AC_VERB_SET_CONNECT_SEL,
  1060. imux->items[0].index);
  1061. }
  1062. }
  1063. return 0;
  1064. }
  1065. static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
  1066. {
  1067. struct sigmatel_spec *spec = codec->spec;
  1068. int i;
  1069. for (i = 0; i < spec->autocfg.line_outs; i++) {
  1070. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  1071. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  1072. }
  1073. }
  1074. static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
  1075. {
  1076. struct sigmatel_spec *spec = codec->spec;
  1077. int i;
  1078. for (i = 0; i < spec->autocfg.hp_outs; i++) {
  1079. hda_nid_t pin;
  1080. pin = spec->autocfg.hp_pins[i];
  1081. if (pin) /* connect to front */
  1082. stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
  1083. }
  1084. for (i = 0; i < spec->autocfg.speaker_outs; i++) {
  1085. hda_nid_t pin;
  1086. pin = spec->autocfg.speaker_pins[i];
  1087. if (pin) /* connect to front */
  1088. stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
  1089. }
  1090. }
  1091. static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
  1092. {
  1093. struct sigmatel_spec *spec = codec->spec;
  1094. int err;
  1095. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
  1096. return err;
  1097. if (! spec->autocfg.line_outs)
  1098. return 0; /* can't find valid pin config */
  1099. if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
  1100. return err;
  1101. if (spec->multiout.num_dacs == 0)
  1102. if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
  1103. return err;
  1104. if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  1105. (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
  1106. (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
  1107. return err;
  1108. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  1109. if (spec->multiout.max_channels > 2)
  1110. spec->surr_switch = 1;
  1111. if (spec->autocfg.dig_out_pin)
  1112. spec->multiout.dig_out_nid = dig_out;
  1113. if (spec->autocfg.dig_in_pin)
  1114. spec->dig_in_nid = dig_in;
  1115. if (spec->kctl_alloc)
  1116. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  1117. spec->input_mux = &spec->private_imux;
  1118. return 1;
  1119. }
  1120. /* add playback controls for HP output */
  1121. static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
  1122. struct auto_pin_cfg *cfg)
  1123. {
  1124. struct sigmatel_spec *spec = codec->spec;
  1125. hda_nid_t pin = cfg->hp_pins[0];
  1126. unsigned int wid_caps;
  1127. if (! pin)
  1128. return 0;
  1129. wid_caps = get_wcaps(codec, pin);
  1130. if (wid_caps & AC_WCAP_UNSOL_CAP)
  1131. spec->hp_detect = 1;
  1132. return 0;
  1133. }
  1134. /* add playback controls for LFE output */
  1135. static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
  1136. struct auto_pin_cfg *cfg)
  1137. {
  1138. struct sigmatel_spec *spec = codec->spec;
  1139. int err;
  1140. hda_nid_t lfe_pin = 0x0;
  1141. int i;
  1142. /*
  1143. * search speaker outs and line outs for a mono speaker pin
  1144. * with an amp. If one is found, add LFE controls
  1145. * for it.
  1146. */
  1147. for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
  1148. hda_nid_t pin = spec->autocfg.speaker_pins[i];
  1149. unsigned long wcaps = get_wcaps(codec, pin);
  1150. wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
  1151. if (wcaps == AC_WCAP_OUT_AMP)
  1152. /* found a mono speaker with an amp, must be lfe */
  1153. lfe_pin = pin;
  1154. }
  1155. /* if speaker_outs is 0, then speakers may be in line_outs */
  1156. if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
  1157. for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
  1158. hda_nid_t pin = spec->autocfg.line_out_pins[i];
  1159. unsigned long cfg;
  1160. cfg = snd_hda_codec_read(codec, pin, 0,
  1161. AC_VERB_GET_CONFIG_DEFAULT,
  1162. 0x00);
  1163. if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
  1164. unsigned long wcaps = get_wcaps(codec, pin);
  1165. wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
  1166. if (wcaps == AC_WCAP_OUT_AMP)
  1167. /* found a mono speaker with an amp,
  1168. must be lfe */
  1169. lfe_pin = pin;
  1170. }
  1171. }
  1172. }
  1173. if (lfe_pin) {
  1174. err = create_controls(spec, "LFE", lfe_pin, 1);
  1175. if (err < 0)
  1176. return err;
  1177. }
  1178. return 0;
  1179. }
  1180. static int stac9200_parse_auto_config(struct hda_codec *codec)
  1181. {
  1182. struct sigmatel_spec *spec = codec->spec;
  1183. int err;
  1184. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
  1185. return err;
  1186. if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
  1187. return err;
  1188. if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
  1189. return err;
  1190. if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
  1191. return err;
  1192. if (spec->autocfg.dig_out_pin)
  1193. spec->multiout.dig_out_nid = 0x05;
  1194. if (spec->autocfg.dig_in_pin)
  1195. spec->dig_in_nid = 0x04;
  1196. if (spec->kctl_alloc)
  1197. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  1198. spec->input_mux = &spec->private_imux;
  1199. return 1;
  1200. }
  1201. /*
  1202. * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
  1203. * funky external mute control using GPIO pins.
  1204. */
  1205. static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
  1206. {
  1207. unsigned int gpiostate, gpiomask, gpiodir;
  1208. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  1209. AC_VERB_GET_GPIO_DATA, 0);
  1210. if (!muted)
  1211. gpiostate |= (1 << pin);
  1212. else
  1213. gpiostate &= ~(1 << pin);
  1214. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  1215. AC_VERB_GET_GPIO_MASK, 0);
  1216. gpiomask |= (1 << pin);
  1217. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  1218. AC_VERB_GET_GPIO_DIRECTION, 0);
  1219. gpiodir |= (1 << pin);
  1220. /* AppleHDA seems to do this -- WTF is this verb?? */
  1221. snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
  1222. snd_hda_codec_write(codec, codec->afg, 0,
  1223. AC_VERB_SET_GPIO_MASK, gpiomask);
  1224. snd_hda_codec_write(codec, codec->afg, 0,
  1225. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  1226. msleep(1);
  1227. snd_hda_codec_write(codec, codec->afg, 0,
  1228. AC_VERB_SET_GPIO_DATA, gpiostate);
  1229. }
  1230. static int stac92xx_init(struct hda_codec *codec)
  1231. {
  1232. struct sigmatel_spec *spec = codec->spec;
  1233. struct auto_pin_cfg *cfg = &spec->autocfg;
  1234. int i;
  1235. snd_hda_sequence_write(codec, spec->init);
  1236. /* set up pins */
  1237. if (spec->hp_detect) {
  1238. /* Enable unsolicited responses on the HP widget */
  1239. for (i = 0; i < cfg->hp_outs; i++)
  1240. if (get_wcaps(codec, cfg->hp_pins[i]) & AC_WCAP_UNSOL_CAP)
  1241. snd_hda_codec_write(codec, cfg->hp_pins[i], 0,
  1242. AC_VERB_SET_UNSOLICITED_ENABLE,
  1243. STAC_UNSOL_ENABLE);
  1244. /* fake event to set up pins */
  1245. codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
  1246. /* enable the headphones by default. If/when unsol_event detection works, this will be ignored */
  1247. stac92xx_auto_init_hp_out(codec);
  1248. } else {
  1249. stac92xx_auto_init_multi_out(codec);
  1250. stac92xx_auto_init_hp_out(codec);
  1251. }
  1252. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1253. hda_nid_t nid = cfg->input_pins[i];
  1254. if (nid) {
  1255. unsigned int pinctl = AC_PINCTL_IN_EN;
  1256. if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
  1257. pinctl |= stac92xx_get_vref(codec, nid);
  1258. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  1259. }
  1260. }
  1261. if (cfg->dig_out_pin)
  1262. stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
  1263. AC_PINCTL_OUT_EN);
  1264. if (cfg->dig_in_pin)
  1265. stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
  1266. AC_PINCTL_IN_EN);
  1267. if (spec->gpio_mute) {
  1268. stac922x_gpio_mute(codec, 0, 0);
  1269. stac922x_gpio_mute(codec, 1, 0);
  1270. }
  1271. return 0;
  1272. }
  1273. static void stac92xx_free(struct hda_codec *codec)
  1274. {
  1275. struct sigmatel_spec *spec = codec->spec;
  1276. int i;
  1277. if (! spec)
  1278. return;
  1279. if (spec->kctl_alloc) {
  1280. for (i = 0; i < spec->num_kctl_used; i++)
  1281. kfree(spec->kctl_alloc[i].name);
  1282. kfree(spec->kctl_alloc);
  1283. }
  1284. if (spec->bios_pin_configs)
  1285. kfree(spec->bios_pin_configs);
  1286. kfree(spec);
  1287. }
  1288. static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
  1289. unsigned int flag)
  1290. {
  1291. unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
  1292. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  1293. snd_hda_codec_write(codec, nid, 0,
  1294. AC_VERB_SET_PIN_WIDGET_CONTROL,
  1295. pin_ctl | flag);
  1296. }
  1297. static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
  1298. unsigned int flag)
  1299. {
  1300. unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
  1301. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  1302. snd_hda_codec_write(codec, nid, 0,
  1303. AC_VERB_SET_PIN_WIDGET_CONTROL,
  1304. pin_ctl & ~flag);
  1305. }
  1306. static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
  1307. {
  1308. struct sigmatel_spec *spec = codec->spec;
  1309. struct auto_pin_cfg *cfg = &spec->autocfg;
  1310. int i, presence;
  1311. if ((res >> 26) != STAC_HP_EVENT)
  1312. return;
  1313. presence = 0;
  1314. for (i = 0; i < cfg->hp_outs; i++) {
  1315. int p = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
  1316. AC_VERB_GET_PIN_SENSE, 0x00);
  1317. if (p & (1 << 31))
  1318. presence++;
  1319. }
  1320. if (presence) {
  1321. /* disable lineouts, enable hp */
  1322. for (i = 0; i < cfg->line_outs; i++)
  1323. stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
  1324. AC_PINCTL_OUT_EN);
  1325. for (i = 0; i < cfg->speaker_outs; i++)
  1326. stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
  1327. AC_PINCTL_OUT_EN);
  1328. for (i = 0; i < cfg->hp_outs; i++)
  1329. stac92xx_set_pinctl(codec, cfg->hp_pins[i],
  1330. AC_PINCTL_OUT_EN);
  1331. } else {
  1332. /* enable lineouts, disable hp */
  1333. for (i = 0; i < cfg->line_outs; i++)
  1334. stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
  1335. AC_PINCTL_OUT_EN);
  1336. for (i = 0; i < cfg->speaker_outs; i++)
  1337. stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
  1338. AC_PINCTL_OUT_EN);
  1339. for (i = 0; i < cfg->hp_outs; i++)
  1340. stac92xx_reset_pinctl(codec, cfg->hp_pins[i],
  1341. AC_PINCTL_OUT_EN);
  1342. }
  1343. }
  1344. #ifdef CONFIG_PM
  1345. static int stac92xx_resume(struct hda_codec *codec)
  1346. {
  1347. struct sigmatel_spec *spec = codec->spec;
  1348. int i;
  1349. stac92xx_init(codec);
  1350. stac92xx_set_config_regs(codec);
  1351. for (i = 0; i < spec->num_mixers; i++)
  1352. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1353. if (spec->multiout.dig_out_nid)
  1354. snd_hda_resume_spdif_out(codec);
  1355. if (spec->dig_in_nid)
  1356. snd_hda_resume_spdif_in(codec);
  1357. return 0;
  1358. }
  1359. #endif
  1360. static struct hda_codec_ops stac92xx_patch_ops = {
  1361. .build_controls = stac92xx_build_controls,
  1362. .build_pcms = stac92xx_build_pcms,
  1363. .init = stac92xx_init,
  1364. .free = stac92xx_free,
  1365. .unsol_event = stac92xx_unsol_event,
  1366. #ifdef CONFIG_PM
  1367. .resume = stac92xx_resume,
  1368. #endif
  1369. };
  1370. static int patch_stac9200(struct hda_codec *codec)
  1371. {
  1372. struct sigmatel_spec *spec;
  1373. int err;
  1374. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1375. if (spec == NULL)
  1376. return -ENOMEM;
  1377. codec->spec = spec;
  1378. spec->num_pins = 8;
  1379. spec->pin_nids = stac9200_pin_nids;
  1380. spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl);
  1381. if (spec->board_config < 0) {
  1382. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
  1383. err = stac92xx_save_bios_config_regs(codec);
  1384. if (err < 0) {
  1385. stac92xx_free(codec);
  1386. return err;
  1387. }
  1388. spec->pin_configs = spec->bios_pin_configs;
  1389. } else {
  1390. spec->pin_configs = stac9200_brd_tbl[spec->board_config];
  1391. stac92xx_set_config_regs(codec);
  1392. }
  1393. spec->multiout.max_channels = 2;
  1394. spec->multiout.num_dacs = 1;
  1395. spec->multiout.dac_nids = stac9200_dac_nids;
  1396. spec->adc_nids = stac9200_adc_nids;
  1397. spec->mux_nids = stac9200_mux_nids;
  1398. spec->num_muxes = 1;
  1399. spec->init = stac9200_core_init;
  1400. spec->mixer = stac9200_mixer;
  1401. err = stac9200_parse_auto_config(codec);
  1402. if (err < 0) {
  1403. stac92xx_free(codec);
  1404. return err;
  1405. }
  1406. codec->patch_ops = stac92xx_patch_ops;
  1407. return 0;
  1408. }
  1409. static int patch_stac922x(struct hda_codec *codec)
  1410. {
  1411. struct sigmatel_spec *spec;
  1412. int err;
  1413. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1414. if (spec == NULL)
  1415. return -ENOMEM;
  1416. codec->spec = spec;
  1417. spec->num_pins = 10;
  1418. spec->pin_nids = stac922x_pin_nids;
  1419. spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl);
  1420. if (spec->board_config < 0) {
  1421. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
  1422. "using BIOS defaults\n");
  1423. err = stac92xx_save_bios_config_regs(codec);
  1424. if (err < 0) {
  1425. stac92xx_free(codec);
  1426. return err;
  1427. }
  1428. spec->pin_configs = spec->bios_pin_configs;
  1429. } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
  1430. spec->pin_configs = stac922x_brd_tbl[spec->board_config];
  1431. stac92xx_set_config_regs(codec);
  1432. }
  1433. spec->adc_nids = stac922x_adc_nids;
  1434. spec->mux_nids = stac922x_mux_nids;
  1435. spec->num_muxes = 2;
  1436. spec->init = stac922x_core_init;
  1437. spec->mixer = stac922x_mixer;
  1438. spec->multiout.dac_nids = spec->dac_nids;
  1439. err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
  1440. if (err < 0) {
  1441. stac92xx_free(codec);
  1442. return err;
  1443. }
  1444. if (spec->board_config == STAC_MACMINI)
  1445. spec->gpio_mute = 1;
  1446. codec->patch_ops = stac92xx_patch_ops;
  1447. return 0;
  1448. }
  1449. static int patch_stac927x(struct hda_codec *codec)
  1450. {
  1451. struct sigmatel_spec *spec;
  1452. int err;
  1453. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1454. if (spec == NULL)
  1455. return -ENOMEM;
  1456. codec->spec = spec;
  1457. spec->num_pins = 14;
  1458. spec->pin_nids = stac927x_pin_nids;
  1459. spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl);
  1460. if (spec->board_config < 0) {
  1461. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
  1462. err = stac92xx_save_bios_config_regs(codec);
  1463. if (err < 0) {
  1464. stac92xx_free(codec);
  1465. return err;
  1466. }
  1467. spec->pin_configs = spec->bios_pin_configs;
  1468. } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
  1469. spec->pin_configs = stac927x_brd_tbl[spec->board_config];
  1470. stac92xx_set_config_regs(codec);
  1471. }
  1472. switch (spec->board_config) {
  1473. case STAC_D965_3ST:
  1474. spec->adc_nids = stac927x_adc_nids;
  1475. spec->mux_nids = stac927x_mux_nids;
  1476. spec->num_muxes = 3;
  1477. spec->init = d965_core_init;
  1478. spec->mixer = stac9227_mixer;
  1479. break;
  1480. case STAC_D965_5ST:
  1481. spec->adc_nids = stac927x_adc_nids;
  1482. spec->mux_nids = stac927x_mux_nids;
  1483. spec->num_muxes = 3;
  1484. spec->init = d965_core_init;
  1485. spec->mixer = stac9227_mixer;
  1486. break;
  1487. default:
  1488. spec->adc_nids = stac927x_adc_nids;
  1489. spec->mux_nids = stac927x_mux_nids;
  1490. spec->num_muxes = 3;
  1491. spec->init = stac927x_core_init;
  1492. spec->mixer = stac927x_mixer;
  1493. }
  1494. spec->multiout.dac_nids = spec->dac_nids;
  1495. err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
  1496. if (err < 0) {
  1497. stac92xx_free(codec);
  1498. return err;
  1499. }
  1500. codec->patch_ops = stac92xx_patch_ops;
  1501. return 0;
  1502. }
  1503. static int patch_stac9205(struct hda_codec *codec)
  1504. {
  1505. struct sigmatel_spec *spec;
  1506. int err;
  1507. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1508. if (spec == NULL)
  1509. return -ENOMEM;
  1510. codec->spec = spec;
  1511. spec->num_pins = 14;
  1512. spec->pin_nids = stac9205_pin_nids;
  1513. spec->board_config = snd_hda_check_board_config(codec, stac9205_cfg_tbl);
  1514. if (spec->board_config < 0) {
  1515. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
  1516. err = stac92xx_save_bios_config_regs(codec);
  1517. if (err < 0) {
  1518. stac92xx_free(codec);
  1519. return err;
  1520. }
  1521. spec->pin_configs = spec->bios_pin_configs;
  1522. } else {
  1523. spec->pin_configs = stac9205_brd_tbl[spec->board_config];
  1524. stac92xx_set_config_regs(codec);
  1525. }
  1526. spec->adc_nids = stac9205_adc_nids;
  1527. spec->mux_nids = stac9205_mux_nids;
  1528. spec->num_muxes = 3;
  1529. spec->init = stac9205_core_init;
  1530. spec->mixer = stac9205_mixer;
  1531. spec->multiout.dac_nids = spec->dac_nids;
  1532. err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
  1533. if (err < 0) {
  1534. stac92xx_free(codec);
  1535. return err;
  1536. }
  1537. codec->patch_ops = stac92xx_patch_ops;
  1538. return 0;
  1539. }
  1540. /*
  1541. * STAC9872 hack
  1542. */
  1543. /* static config for Sony VAIO FE550G and Sony VAIO AR */
  1544. static hda_nid_t vaio_dacs[] = { 0x2 };
  1545. #define VAIO_HP_DAC 0x5
  1546. static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
  1547. static hda_nid_t vaio_mux_nids[] = { 0x15 };
  1548. static struct hda_input_mux vaio_mux = {
  1549. .num_items = 2,
  1550. .items = {
  1551. /* { "HP", 0x0 }, */
  1552. { "Line", 0x1 },
  1553. { "Mic", 0x2 },
  1554. { "PCM", 0x3 },
  1555. }
  1556. };
  1557. static struct hda_verb vaio_init[] = {
  1558. {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
  1559. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
  1560. {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
  1561. {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
  1562. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
  1563. {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
  1564. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
  1565. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
  1566. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
  1567. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
  1568. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
  1569. {}
  1570. };
  1571. static struct hda_verb vaio_ar_init[] = {
  1572. {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
  1573. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
  1574. {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
  1575. {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
  1576. /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
  1577. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
  1578. {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
  1579. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
  1580. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
  1581. /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
  1582. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
  1583. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
  1584. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
  1585. {}
  1586. };
  1587. /* bind volumes of both NID 0x02 and 0x05 */
  1588. static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
  1589. struct snd_ctl_elem_value *ucontrol)
  1590. {
  1591. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1592. long *valp = ucontrol->value.integer.value;
  1593. int change;
  1594. change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
  1595. 0x7f, valp[0] & 0x7f);
  1596. change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
  1597. 0x7f, valp[1] & 0x7f);
  1598. snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
  1599. 0x7f, valp[0] & 0x7f);
  1600. snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
  1601. 0x7f, valp[1] & 0x7f);
  1602. return change;
  1603. }
  1604. /* bind volumes of both NID 0x02 and 0x05 */
  1605. static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
  1606. struct snd_ctl_elem_value *ucontrol)
  1607. {
  1608. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1609. long *valp = ucontrol->value.integer.value;
  1610. int change;
  1611. change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
  1612. 0x80, (valp[0] ? 0 : 0x80));
  1613. change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
  1614. 0x80, (valp[1] ? 0 : 0x80));
  1615. snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
  1616. 0x80, (valp[0] ? 0 : 0x80));
  1617. snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
  1618. 0x80, (valp[1] ? 0 : 0x80));
  1619. return change;
  1620. }
  1621. static struct snd_kcontrol_new vaio_mixer[] = {
  1622. {
  1623. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1624. .name = "Master Playback Volume",
  1625. .info = snd_hda_mixer_amp_volume_info,
  1626. .get = snd_hda_mixer_amp_volume_get,
  1627. .put = vaio_master_vol_put,
  1628. .tlv = { .c = snd_hda_mixer_amp_tlv },
  1629. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  1630. },
  1631. {
  1632. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1633. .name = "Master Playback Switch",
  1634. .info = snd_hda_mixer_amp_switch_info,
  1635. .get = snd_hda_mixer_amp_switch_get,
  1636. .put = vaio_master_sw_put,
  1637. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  1638. },
  1639. /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
  1640. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
  1641. HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
  1642. {
  1643. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1644. .name = "Capture Source",
  1645. .count = 1,
  1646. .info = stac92xx_mux_enum_info,
  1647. .get = stac92xx_mux_enum_get,
  1648. .put = stac92xx_mux_enum_put,
  1649. },
  1650. {}
  1651. };
  1652. static struct snd_kcontrol_new vaio_ar_mixer[] = {
  1653. {
  1654. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1655. .name = "Master Playback Volume",
  1656. .info = snd_hda_mixer_amp_volume_info,
  1657. .get = snd_hda_mixer_amp_volume_get,
  1658. .put = vaio_master_vol_put,
  1659. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  1660. },
  1661. {
  1662. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1663. .name = "Master Playback Switch",
  1664. .info = snd_hda_mixer_amp_switch_info,
  1665. .get = snd_hda_mixer_amp_switch_get,
  1666. .put = vaio_master_sw_put,
  1667. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  1668. },
  1669. /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
  1670. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
  1671. HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
  1672. /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
  1673. HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
  1674. {
  1675. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1676. .name = "Capture Source",
  1677. .count = 1,
  1678. .info = stac92xx_mux_enum_info,
  1679. .get = stac92xx_mux_enum_get,
  1680. .put = stac92xx_mux_enum_put,
  1681. },
  1682. {}
  1683. };
  1684. static struct hda_codec_ops stac9872_patch_ops = {
  1685. .build_controls = stac92xx_build_controls,
  1686. .build_pcms = stac92xx_build_pcms,
  1687. .init = stac92xx_init,
  1688. .free = stac92xx_free,
  1689. #ifdef CONFIG_PM
  1690. .resume = stac92xx_resume,
  1691. #endif
  1692. };
  1693. enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
  1694. CXD9872RD_VAIO,
  1695. /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
  1696. STAC9872AK_VAIO,
  1697. /* Unknown. id=0x83847661 and subsys=0x104D1200. */
  1698. STAC9872K_VAIO,
  1699. /* AR Series. id=0x83847664 and subsys=104D1300 */
  1700. CXD9872AKD_VAIO
  1701. };
  1702. static struct hda_board_config stac9872_cfg_tbl[] = {
  1703. { .modelname = "vaio", .config = CXD9872RD_VAIO },
  1704. { .modelname = "vaio-ar", .config = CXD9872AKD_VAIO },
  1705. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81e6,
  1706. .config = CXD9872RD_VAIO },
  1707. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81ef,
  1708. .config = CXD9872RD_VAIO },
  1709. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81fd,
  1710. .config = CXD9872AKD_VAIO },
  1711. {}
  1712. };
  1713. static int patch_stac9872(struct hda_codec *codec)
  1714. {
  1715. struct sigmatel_spec *spec;
  1716. int board_config;
  1717. board_config = snd_hda_check_board_config(codec, stac9872_cfg_tbl);
  1718. if (board_config < 0)
  1719. /* unknown config, let generic-parser do its job... */
  1720. return snd_hda_parse_generic_codec(codec);
  1721. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1722. if (spec == NULL)
  1723. return -ENOMEM;
  1724. codec->spec = spec;
  1725. switch (board_config) {
  1726. case CXD9872RD_VAIO:
  1727. case STAC9872AK_VAIO:
  1728. case STAC9872K_VAIO:
  1729. spec->mixer = vaio_mixer;
  1730. spec->init = vaio_init;
  1731. spec->multiout.max_channels = 2;
  1732. spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
  1733. spec->multiout.dac_nids = vaio_dacs;
  1734. spec->multiout.hp_nid = VAIO_HP_DAC;
  1735. spec->num_adcs = ARRAY_SIZE(vaio_adcs);
  1736. spec->adc_nids = vaio_adcs;
  1737. spec->input_mux = &vaio_mux;
  1738. spec->mux_nids = vaio_mux_nids;
  1739. break;
  1740. case CXD9872AKD_VAIO:
  1741. spec->mixer = vaio_ar_mixer;
  1742. spec->init = vaio_ar_init;
  1743. spec->multiout.max_channels = 2;
  1744. spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
  1745. spec->multiout.dac_nids = vaio_dacs;
  1746. spec->multiout.hp_nid = VAIO_HP_DAC;
  1747. spec->num_adcs = ARRAY_SIZE(vaio_adcs);
  1748. spec->adc_nids = vaio_adcs;
  1749. spec->input_mux = &vaio_mux;
  1750. spec->mux_nids = vaio_mux_nids;
  1751. break;
  1752. }
  1753. codec->patch_ops = stac9872_patch_ops;
  1754. return 0;
  1755. }
  1756. /*
  1757. * patch entries
  1758. */
  1759. struct hda_codec_preset snd_hda_preset_sigmatel[] = {
  1760. { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
  1761. { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
  1762. { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
  1763. { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
  1764. { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
  1765. { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
  1766. { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
  1767. { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
  1768. { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
  1769. { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
  1770. { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
  1771. { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
  1772. { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
  1773. { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
  1774. { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
  1775. { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
  1776. { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
  1777. { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
  1778. { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
  1779. { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
  1780. { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
  1781. { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
  1782. { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
  1783. /* The following does not take into account .id=0x83847661 when subsys =
  1784. * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
  1785. * currently not fully supported.
  1786. */
  1787. { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
  1788. { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
  1789. { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
  1790. { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
  1791. { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
  1792. { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
  1793. { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
  1794. { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
  1795. { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
  1796. { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
  1797. { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
  1798. {} /* terminator */
  1799. };