patch_sigmatel.c 60 KB

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