patch_sigmatel.c 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983
  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. /* add playback controls from the parsed DAC table */
  899. static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
  900. const struct auto_pin_cfg *cfg)
  901. {
  902. char name[32];
  903. static const char *chname[4] = {
  904. "Front", "Surround", NULL /*CLFE*/, "Side"
  905. };
  906. hda_nid_t nid;
  907. int i, err;
  908. for (i = 0; i < cfg->line_outs; i++) {
  909. if (!spec->multiout.dac_nids[i])
  910. continue;
  911. nid = spec->multiout.dac_nids[i];
  912. if (i == 2) {
  913. /* Center/LFE */
  914. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Center Playback Volume",
  915. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  916. return err;
  917. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "LFE Playback Volume",
  918. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  919. return err;
  920. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Center Playback Switch",
  921. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  922. return err;
  923. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "LFE Playback Switch",
  924. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  925. return err;
  926. } else {
  927. sprintf(name, "%s Playback Volume", chname[i]);
  928. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
  929. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  930. return err;
  931. sprintf(name, "%s Playback Switch", chname[i]);
  932. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
  933. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  934. return err;
  935. }
  936. }
  937. if (spec->line_switch)
  938. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
  939. return err;
  940. if (spec->mic_switch)
  941. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
  942. return err;
  943. return 0;
  944. }
  945. /* add playback controls for HP output */
  946. static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec, struct auto_pin_cfg *cfg)
  947. {
  948. struct sigmatel_spec *spec = codec->spec;
  949. hda_nid_t pin = cfg->hp_pin;
  950. hda_nid_t nid;
  951. int i, err;
  952. unsigned int wid_caps;
  953. if (! pin)
  954. return 0;
  955. wid_caps = get_wcaps(codec, pin);
  956. if (wid_caps & AC_WCAP_UNSOL_CAP)
  957. spec->hp_detect = 1;
  958. nid = snd_hda_codec_read(codec, pin, 0, AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
  959. for (i = 0; i < cfg->line_outs; i++) {
  960. if (! spec->multiout.dac_nids[i])
  961. continue;
  962. if (spec->multiout.dac_nids[i] == nid)
  963. return 0;
  964. }
  965. spec->multiout.hp_nid = nid;
  966. /* control HP volume/switch on the output mixer amp */
  967. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  968. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  969. return err;
  970. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  971. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  972. return err;
  973. return 0;
  974. }
  975. /* create playback/capture controls for input pins */
  976. static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
  977. {
  978. struct sigmatel_spec *spec = codec->spec;
  979. struct hda_input_mux *imux = &spec->private_imux;
  980. hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
  981. int i, j, k;
  982. for (i = 0; i < AUTO_PIN_LAST; i++) {
  983. int index = -1;
  984. if (cfg->input_pins[i]) {
  985. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  986. for (j=0; j<spec->num_muxes; j++) {
  987. int num_cons = snd_hda_get_connections(codec, spec->mux_nids[j], con_lst, HDA_MAX_NUM_INPUTS);
  988. for (k=0; k<num_cons; k++)
  989. if (con_lst[k] == cfg->input_pins[i]) {
  990. index = k;
  991. break;
  992. }
  993. if (index >= 0)
  994. break;
  995. }
  996. imux->items[imux->num_items].index = index;
  997. imux->num_items++;
  998. }
  999. }
  1000. if (imux->num_items == 1) {
  1001. /*
  1002. * Set the current input for the muxes.
  1003. * The STAC9221 has two input muxes with identical source
  1004. * NID lists. Hopefully this won't get confused.
  1005. */
  1006. for (i = 0; i < spec->num_muxes; i++) {
  1007. snd_hda_codec_write(codec, spec->mux_nids[i], 0,
  1008. AC_VERB_SET_CONNECT_SEL,
  1009. imux->items[0].index);
  1010. }
  1011. }
  1012. return 0;
  1013. }
  1014. static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
  1015. {
  1016. struct sigmatel_spec *spec = codec->spec;
  1017. int i;
  1018. for (i = 0; i < spec->autocfg.line_outs; i++) {
  1019. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  1020. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  1021. }
  1022. }
  1023. static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
  1024. {
  1025. struct sigmatel_spec *spec = codec->spec;
  1026. hda_nid_t pin;
  1027. pin = spec->autocfg.hp_pin;
  1028. if (pin) /* connect to front */
  1029. stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
  1030. }
  1031. static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
  1032. {
  1033. struct sigmatel_spec *spec = codec->spec;
  1034. int err;
  1035. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
  1036. return err;
  1037. if (! spec->autocfg.line_outs)
  1038. return 0; /* can't find valid pin config */
  1039. if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
  1040. return err;
  1041. if (spec->multiout.num_dacs == 0)
  1042. if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
  1043. return err;
  1044. if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  1045. (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
  1046. (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
  1047. return err;
  1048. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  1049. if (spec->multiout.max_channels > 2)
  1050. spec->surr_switch = 1;
  1051. if (spec->autocfg.dig_out_pin)
  1052. spec->multiout.dig_out_nid = dig_out;
  1053. if (spec->autocfg.dig_in_pin)
  1054. spec->dig_in_nid = dig_in;
  1055. if (spec->kctl_alloc)
  1056. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  1057. spec->input_mux = &spec->private_imux;
  1058. return 1;
  1059. }
  1060. /* add playback controls for HP output */
  1061. static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
  1062. struct auto_pin_cfg *cfg)
  1063. {
  1064. struct sigmatel_spec *spec = codec->spec;
  1065. hda_nid_t pin = cfg->hp_pin;
  1066. unsigned int wid_caps;
  1067. if (! pin)
  1068. return 0;
  1069. wid_caps = get_wcaps(codec, pin);
  1070. if (wid_caps & AC_WCAP_UNSOL_CAP)
  1071. spec->hp_detect = 1;
  1072. return 0;
  1073. }
  1074. /* add playback controls for LFE output */
  1075. static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
  1076. struct auto_pin_cfg *cfg)
  1077. {
  1078. struct sigmatel_spec *spec = codec->spec;
  1079. int err;
  1080. hda_nid_t lfe_pin = 0x0;
  1081. int i;
  1082. /*
  1083. * search speaker outs and line outs for a mono speaker pin
  1084. * with an amp. If one is found, add LFE controls
  1085. * for it.
  1086. */
  1087. for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
  1088. hda_nid_t pin = spec->autocfg.speaker_pins[i];
  1089. unsigned long wcaps = get_wcaps(codec, pin);
  1090. wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
  1091. if (wcaps == AC_WCAP_OUT_AMP)
  1092. /* found a mono speaker with an amp, must be lfe */
  1093. lfe_pin = pin;
  1094. }
  1095. /* if speaker_outs is 0, then speakers may be in line_outs */
  1096. if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
  1097. for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
  1098. hda_nid_t pin = spec->autocfg.line_out_pins[i];
  1099. unsigned long cfg;
  1100. cfg = snd_hda_codec_read(codec, pin, 0,
  1101. AC_VERB_GET_CONFIG_DEFAULT,
  1102. 0x00);
  1103. if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
  1104. unsigned long wcaps = get_wcaps(codec, pin);
  1105. wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
  1106. if (wcaps == AC_WCAP_OUT_AMP)
  1107. /* found a mono speaker with an amp,
  1108. must be lfe */
  1109. lfe_pin = pin;
  1110. }
  1111. }
  1112. }
  1113. if (lfe_pin) {
  1114. err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL,
  1115. "LFE Playback Volume",
  1116. HDA_COMPOSE_AMP_VAL(lfe_pin, 1, 0,
  1117. HDA_OUTPUT));
  1118. if (err < 0)
  1119. return err;
  1120. err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE,
  1121. "LFE Playback Switch",
  1122. HDA_COMPOSE_AMP_VAL(lfe_pin, 1, 0,
  1123. HDA_OUTPUT));
  1124. if (err < 0)
  1125. return err;
  1126. }
  1127. return 0;
  1128. }
  1129. static int stac9200_parse_auto_config(struct hda_codec *codec)
  1130. {
  1131. struct sigmatel_spec *spec = codec->spec;
  1132. int err;
  1133. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
  1134. return err;
  1135. if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
  1136. return err;
  1137. if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
  1138. return err;
  1139. if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
  1140. return err;
  1141. if (spec->autocfg.dig_out_pin)
  1142. spec->multiout.dig_out_nid = 0x05;
  1143. if (spec->autocfg.dig_in_pin)
  1144. spec->dig_in_nid = 0x04;
  1145. if (spec->kctl_alloc)
  1146. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  1147. spec->input_mux = &spec->private_imux;
  1148. return 1;
  1149. }
  1150. /*
  1151. * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
  1152. * funky external mute control using GPIO pins.
  1153. */
  1154. static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
  1155. {
  1156. unsigned int gpiostate, gpiomask, gpiodir;
  1157. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  1158. AC_VERB_GET_GPIO_DATA, 0);
  1159. if (!muted)
  1160. gpiostate |= (1 << pin);
  1161. else
  1162. gpiostate &= ~(1 << pin);
  1163. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  1164. AC_VERB_GET_GPIO_MASK, 0);
  1165. gpiomask |= (1 << pin);
  1166. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  1167. AC_VERB_GET_GPIO_DIRECTION, 0);
  1168. gpiodir |= (1 << pin);
  1169. /* AppleHDA seems to do this -- WTF is this verb?? */
  1170. snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
  1171. snd_hda_codec_write(codec, codec->afg, 0,
  1172. AC_VERB_SET_GPIO_MASK, gpiomask);
  1173. snd_hda_codec_write(codec, codec->afg, 0,
  1174. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  1175. msleep(1);
  1176. snd_hda_codec_write(codec, codec->afg, 0,
  1177. AC_VERB_SET_GPIO_DATA, gpiostate);
  1178. }
  1179. static int stac92xx_init(struct hda_codec *codec)
  1180. {
  1181. struct sigmatel_spec *spec = codec->spec;
  1182. struct auto_pin_cfg *cfg = &spec->autocfg;
  1183. int i;
  1184. snd_hda_sequence_write(codec, spec->init);
  1185. /* set up pins */
  1186. if (spec->hp_detect) {
  1187. /* Enable unsolicited responses on the HP widget */
  1188. snd_hda_codec_write(codec, cfg->hp_pin, 0,
  1189. AC_VERB_SET_UNSOLICITED_ENABLE,
  1190. STAC_UNSOL_ENABLE);
  1191. /* fake event to set up pins */
  1192. codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
  1193. /* enable the headphones by default. If/when unsol_event detection works, this will be ignored */
  1194. stac92xx_auto_init_hp_out(codec);
  1195. } else {
  1196. stac92xx_auto_init_multi_out(codec);
  1197. stac92xx_auto_init_hp_out(codec);
  1198. }
  1199. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1200. hda_nid_t nid = cfg->input_pins[i];
  1201. if (nid) {
  1202. unsigned int pinctl = AC_PINCTL_IN_EN;
  1203. if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
  1204. pinctl |= stac92xx_get_vref(codec, nid);
  1205. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  1206. }
  1207. }
  1208. if (cfg->dig_out_pin)
  1209. stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
  1210. AC_PINCTL_OUT_EN);
  1211. if (cfg->dig_in_pin)
  1212. stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
  1213. AC_PINCTL_IN_EN);
  1214. if (spec->gpio_mute) {
  1215. stac922x_gpio_mute(codec, 0, 0);
  1216. stac922x_gpio_mute(codec, 1, 0);
  1217. }
  1218. return 0;
  1219. }
  1220. static void stac92xx_free(struct hda_codec *codec)
  1221. {
  1222. struct sigmatel_spec *spec = codec->spec;
  1223. int i;
  1224. if (! spec)
  1225. return;
  1226. if (spec->kctl_alloc) {
  1227. for (i = 0; i < spec->num_kctl_used; i++)
  1228. kfree(spec->kctl_alloc[i].name);
  1229. kfree(spec->kctl_alloc);
  1230. }
  1231. if (spec->bios_pin_configs)
  1232. kfree(spec->bios_pin_configs);
  1233. kfree(spec);
  1234. }
  1235. static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
  1236. unsigned int flag)
  1237. {
  1238. unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
  1239. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  1240. snd_hda_codec_write(codec, nid, 0,
  1241. AC_VERB_SET_PIN_WIDGET_CONTROL,
  1242. pin_ctl | flag);
  1243. }
  1244. static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
  1245. unsigned int flag)
  1246. {
  1247. unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
  1248. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  1249. snd_hda_codec_write(codec, nid, 0,
  1250. AC_VERB_SET_PIN_WIDGET_CONTROL,
  1251. pin_ctl & ~flag);
  1252. }
  1253. static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
  1254. {
  1255. struct sigmatel_spec *spec = codec->spec;
  1256. struct auto_pin_cfg *cfg = &spec->autocfg;
  1257. int i, presence;
  1258. if ((res >> 26) != STAC_HP_EVENT)
  1259. return;
  1260. presence = snd_hda_codec_read(codec, cfg->hp_pin, 0,
  1261. AC_VERB_GET_PIN_SENSE, 0x00) >> 31;
  1262. if (presence) {
  1263. /* disable lineouts, enable hp */
  1264. for (i = 0; i < cfg->line_outs; i++)
  1265. stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
  1266. AC_PINCTL_OUT_EN);
  1267. stac92xx_set_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
  1268. } else {
  1269. /* enable lineouts, disable hp */
  1270. for (i = 0; i < cfg->line_outs; i++)
  1271. stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
  1272. AC_PINCTL_OUT_EN);
  1273. stac92xx_reset_pinctl(codec, cfg->hp_pin, AC_PINCTL_OUT_EN);
  1274. }
  1275. }
  1276. #ifdef CONFIG_PM
  1277. static int stac92xx_resume(struct hda_codec *codec)
  1278. {
  1279. struct sigmatel_spec *spec = codec->spec;
  1280. int i;
  1281. stac92xx_init(codec);
  1282. stac92xx_set_config_regs(codec);
  1283. for (i = 0; i < spec->num_mixers; i++)
  1284. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1285. if (spec->multiout.dig_out_nid)
  1286. snd_hda_resume_spdif_out(codec);
  1287. if (spec->dig_in_nid)
  1288. snd_hda_resume_spdif_in(codec);
  1289. return 0;
  1290. }
  1291. #endif
  1292. static struct hda_codec_ops stac92xx_patch_ops = {
  1293. .build_controls = stac92xx_build_controls,
  1294. .build_pcms = stac92xx_build_pcms,
  1295. .init = stac92xx_init,
  1296. .free = stac92xx_free,
  1297. .unsol_event = stac92xx_unsol_event,
  1298. #ifdef CONFIG_PM
  1299. .resume = stac92xx_resume,
  1300. #endif
  1301. };
  1302. static int patch_stac9200(struct hda_codec *codec)
  1303. {
  1304. struct sigmatel_spec *spec;
  1305. int err;
  1306. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1307. if (spec == NULL)
  1308. return -ENOMEM;
  1309. codec->spec = spec;
  1310. spec->num_pins = 8;
  1311. spec->pin_nids = stac9200_pin_nids;
  1312. spec->board_config = snd_hda_check_board_config(codec, stac9200_cfg_tbl);
  1313. if (spec->board_config < 0) {
  1314. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
  1315. err = stac92xx_save_bios_config_regs(codec);
  1316. if (err < 0) {
  1317. stac92xx_free(codec);
  1318. return err;
  1319. }
  1320. spec->pin_configs = spec->bios_pin_configs;
  1321. } else {
  1322. spec->pin_configs = stac9200_brd_tbl[spec->board_config];
  1323. stac92xx_set_config_regs(codec);
  1324. }
  1325. spec->multiout.max_channels = 2;
  1326. spec->multiout.num_dacs = 1;
  1327. spec->multiout.dac_nids = stac9200_dac_nids;
  1328. spec->adc_nids = stac9200_adc_nids;
  1329. spec->mux_nids = stac9200_mux_nids;
  1330. spec->num_muxes = 1;
  1331. spec->init = stac9200_core_init;
  1332. spec->mixer = stac9200_mixer;
  1333. err = stac9200_parse_auto_config(codec);
  1334. if (err < 0) {
  1335. stac92xx_free(codec);
  1336. return err;
  1337. }
  1338. codec->patch_ops = stac92xx_patch_ops;
  1339. return 0;
  1340. }
  1341. static int patch_stac922x(struct hda_codec *codec)
  1342. {
  1343. struct sigmatel_spec *spec;
  1344. int err;
  1345. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1346. if (spec == NULL)
  1347. return -ENOMEM;
  1348. codec->spec = spec;
  1349. spec->num_pins = 10;
  1350. spec->pin_nids = stac922x_pin_nids;
  1351. spec->board_config = snd_hda_check_board_config(codec, stac922x_cfg_tbl);
  1352. if (spec->board_config < 0) {
  1353. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
  1354. "using BIOS defaults\n");
  1355. err = stac92xx_save_bios_config_regs(codec);
  1356. if (err < 0) {
  1357. stac92xx_free(codec);
  1358. return err;
  1359. }
  1360. spec->pin_configs = spec->bios_pin_configs;
  1361. } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
  1362. spec->pin_configs = stac922x_brd_tbl[spec->board_config];
  1363. stac92xx_set_config_regs(codec);
  1364. }
  1365. spec->adc_nids = stac922x_adc_nids;
  1366. spec->mux_nids = stac922x_mux_nids;
  1367. spec->num_muxes = 2;
  1368. spec->init = stac922x_core_init;
  1369. spec->mixer = stac922x_mixer;
  1370. spec->multiout.dac_nids = spec->dac_nids;
  1371. err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
  1372. if (err < 0) {
  1373. stac92xx_free(codec);
  1374. return err;
  1375. }
  1376. if (spec->board_config == STAC_MACMINI)
  1377. spec->gpio_mute = 1;
  1378. codec->patch_ops = stac92xx_patch_ops;
  1379. return 0;
  1380. }
  1381. static int patch_stac927x(struct hda_codec *codec)
  1382. {
  1383. struct sigmatel_spec *spec;
  1384. int err;
  1385. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1386. if (spec == NULL)
  1387. return -ENOMEM;
  1388. codec->spec = spec;
  1389. spec->num_pins = 14;
  1390. spec->pin_nids = stac927x_pin_nids;
  1391. spec->board_config = snd_hda_check_board_config(codec, stac927x_cfg_tbl);
  1392. if (spec->board_config < 0) {
  1393. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
  1394. err = stac92xx_save_bios_config_regs(codec);
  1395. if (err < 0) {
  1396. stac92xx_free(codec);
  1397. return err;
  1398. }
  1399. spec->pin_configs = spec->bios_pin_configs;
  1400. } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
  1401. spec->pin_configs = stac927x_brd_tbl[spec->board_config];
  1402. stac92xx_set_config_regs(codec);
  1403. }
  1404. switch (spec->board_config) {
  1405. case STAC_D965_3ST:
  1406. spec->adc_nids = stac927x_adc_nids;
  1407. spec->mux_nids = stac927x_mux_nids;
  1408. spec->num_muxes = 3;
  1409. spec->init = d965_core_init;
  1410. spec->mixer = stac9227_mixer;
  1411. break;
  1412. case STAC_D965_5ST:
  1413. spec->adc_nids = stac927x_adc_nids;
  1414. spec->mux_nids = stac927x_mux_nids;
  1415. spec->num_muxes = 3;
  1416. spec->init = d965_core_init;
  1417. spec->mixer = stac9227_mixer;
  1418. break;
  1419. default:
  1420. spec->adc_nids = stac927x_adc_nids;
  1421. spec->mux_nids = stac927x_mux_nids;
  1422. spec->num_muxes = 3;
  1423. spec->init = stac927x_core_init;
  1424. spec->mixer = stac927x_mixer;
  1425. }
  1426. spec->multiout.dac_nids = spec->dac_nids;
  1427. err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
  1428. if (err < 0) {
  1429. stac92xx_free(codec);
  1430. return err;
  1431. }
  1432. codec->patch_ops = stac92xx_patch_ops;
  1433. return 0;
  1434. }
  1435. static int patch_stac9205(struct hda_codec *codec)
  1436. {
  1437. struct sigmatel_spec *spec;
  1438. int err;
  1439. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1440. if (spec == NULL)
  1441. return -ENOMEM;
  1442. codec->spec = spec;
  1443. spec->num_pins = 14;
  1444. spec->pin_nids = stac9205_pin_nids;
  1445. spec->board_config = snd_hda_check_board_config(codec, stac9205_cfg_tbl);
  1446. if (spec->board_config < 0) {
  1447. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
  1448. err = stac92xx_save_bios_config_regs(codec);
  1449. if (err < 0) {
  1450. stac92xx_free(codec);
  1451. return err;
  1452. }
  1453. spec->pin_configs = spec->bios_pin_configs;
  1454. } else {
  1455. spec->pin_configs = stac9205_brd_tbl[spec->board_config];
  1456. stac92xx_set_config_regs(codec);
  1457. }
  1458. spec->adc_nids = stac9205_adc_nids;
  1459. spec->mux_nids = stac9205_mux_nids;
  1460. spec->num_muxes = 3;
  1461. spec->init = stac9205_core_init;
  1462. spec->mixer = stac9205_mixer;
  1463. spec->multiout.dac_nids = spec->dac_nids;
  1464. err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
  1465. if (err < 0) {
  1466. stac92xx_free(codec);
  1467. return err;
  1468. }
  1469. codec->patch_ops = stac92xx_patch_ops;
  1470. return 0;
  1471. }
  1472. /*
  1473. * STAC9872 hack
  1474. */
  1475. /* static config for Sony VAIO FE550G and Sony VAIO AR */
  1476. static hda_nid_t vaio_dacs[] = { 0x2 };
  1477. #define VAIO_HP_DAC 0x5
  1478. static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
  1479. static hda_nid_t vaio_mux_nids[] = { 0x15 };
  1480. static struct hda_input_mux vaio_mux = {
  1481. .num_items = 2,
  1482. .items = {
  1483. /* { "HP", 0x0 }, */
  1484. { "Line", 0x1 },
  1485. { "Mic", 0x2 },
  1486. { "PCM", 0x3 },
  1487. }
  1488. };
  1489. static struct hda_verb vaio_init[] = {
  1490. {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
  1491. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
  1492. {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
  1493. {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
  1494. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
  1495. {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
  1496. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
  1497. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
  1498. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
  1499. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
  1500. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
  1501. {}
  1502. };
  1503. static struct hda_verb vaio_ar_init[] = {
  1504. {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
  1505. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
  1506. {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
  1507. {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
  1508. /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
  1509. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
  1510. {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
  1511. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
  1512. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
  1513. /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
  1514. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
  1515. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
  1516. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
  1517. {}
  1518. };
  1519. /* bind volumes of both NID 0x02 and 0x05 */
  1520. static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
  1521. struct snd_ctl_elem_value *ucontrol)
  1522. {
  1523. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1524. long *valp = ucontrol->value.integer.value;
  1525. int change;
  1526. change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
  1527. 0x7f, valp[0] & 0x7f);
  1528. change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
  1529. 0x7f, valp[1] & 0x7f);
  1530. snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
  1531. 0x7f, valp[0] & 0x7f);
  1532. snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
  1533. 0x7f, valp[1] & 0x7f);
  1534. return change;
  1535. }
  1536. /* bind volumes of both NID 0x02 and 0x05 */
  1537. static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
  1538. struct snd_ctl_elem_value *ucontrol)
  1539. {
  1540. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1541. long *valp = ucontrol->value.integer.value;
  1542. int change;
  1543. change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
  1544. 0x80, (valp[0] ? 0 : 0x80));
  1545. change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
  1546. 0x80, (valp[1] ? 0 : 0x80));
  1547. snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
  1548. 0x80, (valp[0] ? 0 : 0x80));
  1549. snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
  1550. 0x80, (valp[1] ? 0 : 0x80));
  1551. return change;
  1552. }
  1553. static struct snd_kcontrol_new vaio_mixer[] = {
  1554. {
  1555. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1556. .name = "Master Playback Volume",
  1557. .info = snd_hda_mixer_amp_volume_info,
  1558. .get = snd_hda_mixer_amp_volume_get,
  1559. .put = vaio_master_vol_put,
  1560. .tlv = { .c = snd_hda_mixer_amp_tlv },
  1561. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  1562. },
  1563. {
  1564. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1565. .name = "Master Playback Switch",
  1566. .info = snd_hda_mixer_amp_switch_info,
  1567. .get = snd_hda_mixer_amp_switch_get,
  1568. .put = vaio_master_sw_put,
  1569. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  1570. },
  1571. /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
  1572. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
  1573. HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
  1574. {
  1575. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1576. .name = "Capture Source",
  1577. .count = 1,
  1578. .info = stac92xx_mux_enum_info,
  1579. .get = stac92xx_mux_enum_get,
  1580. .put = stac92xx_mux_enum_put,
  1581. },
  1582. {}
  1583. };
  1584. static struct snd_kcontrol_new vaio_ar_mixer[] = {
  1585. {
  1586. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1587. .name = "Master Playback Volume",
  1588. .info = snd_hda_mixer_amp_volume_info,
  1589. .get = snd_hda_mixer_amp_volume_get,
  1590. .put = vaio_master_vol_put,
  1591. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  1592. },
  1593. {
  1594. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1595. .name = "Master Playback Switch",
  1596. .info = snd_hda_mixer_amp_switch_info,
  1597. .get = snd_hda_mixer_amp_switch_get,
  1598. .put = vaio_master_sw_put,
  1599. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  1600. },
  1601. /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
  1602. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
  1603. HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
  1604. /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
  1605. HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
  1606. {
  1607. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1608. .name = "Capture Source",
  1609. .count = 1,
  1610. .info = stac92xx_mux_enum_info,
  1611. .get = stac92xx_mux_enum_get,
  1612. .put = stac92xx_mux_enum_put,
  1613. },
  1614. {}
  1615. };
  1616. static struct hda_codec_ops stac9872_patch_ops = {
  1617. .build_controls = stac92xx_build_controls,
  1618. .build_pcms = stac92xx_build_pcms,
  1619. .init = stac92xx_init,
  1620. .free = stac92xx_free,
  1621. #ifdef CONFIG_PM
  1622. .resume = stac92xx_resume,
  1623. #endif
  1624. };
  1625. enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
  1626. CXD9872RD_VAIO,
  1627. /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
  1628. STAC9872AK_VAIO,
  1629. /* Unknown. id=0x83847661 and subsys=0x104D1200. */
  1630. STAC9872K_VAIO,
  1631. /* AR Series. id=0x83847664 and subsys=104D1300 */
  1632. CXD9872AKD_VAIO
  1633. };
  1634. static struct hda_board_config stac9872_cfg_tbl[] = {
  1635. { .modelname = "vaio", .config = CXD9872RD_VAIO },
  1636. { .modelname = "vaio-ar", .config = CXD9872AKD_VAIO },
  1637. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81e6,
  1638. .config = CXD9872RD_VAIO },
  1639. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81ef,
  1640. .config = CXD9872RD_VAIO },
  1641. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81fd,
  1642. .config = CXD9872AKD_VAIO },
  1643. {}
  1644. };
  1645. static int patch_stac9872(struct hda_codec *codec)
  1646. {
  1647. struct sigmatel_spec *spec;
  1648. int board_config;
  1649. board_config = snd_hda_check_board_config(codec, stac9872_cfg_tbl);
  1650. if (board_config < 0)
  1651. /* unknown config, let generic-parser do its job... */
  1652. return snd_hda_parse_generic_codec(codec);
  1653. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1654. if (spec == NULL)
  1655. return -ENOMEM;
  1656. codec->spec = spec;
  1657. switch (board_config) {
  1658. case CXD9872RD_VAIO:
  1659. case STAC9872AK_VAIO:
  1660. case STAC9872K_VAIO:
  1661. spec->mixer = vaio_mixer;
  1662. spec->init = vaio_init;
  1663. spec->multiout.max_channels = 2;
  1664. spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
  1665. spec->multiout.dac_nids = vaio_dacs;
  1666. spec->multiout.hp_nid = VAIO_HP_DAC;
  1667. spec->num_adcs = ARRAY_SIZE(vaio_adcs);
  1668. spec->adc_nids = vaio_adcs;
  1669. spec->input_mux = &vaio_mux;
  1670. spec->mux_nids = vaio_mux_nids;
  1671. break;
  1672. case CXD9872AKD_VAIO:
  1673. spec->mixer = vaio_ar_mixer;
  1674. spec->init = vaio_ar_init;
  1675. spec->multiout.max_channels = 2;
  1676. spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
  1677. spec->multiout.dac_nids = vaio_dacs;
  1678. spec->multiout.hp_nid = VAIO_HP_DAC;
  1679. spec->num_adcs = ARRAY_SIZE(vaio_adcs);
  1680. spec->adc_nids = vaio_adcs;
  1681. spec->input_mux = &vaio_mux;
  1682. spec->mux_nids = vaio_mux_nids;
  1683. break;
  1684. }
  1685. codec->patch_ops = stac9872_patch_ops;
  1686. return 0;
  1687. }
  1688. /*
  1689. * patch entries
  1690. */
  1691. struct hda_codec_preset snd_hda_preset_sigmatel[] = {
  1692. { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
  1693. { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
  1694. { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
  1695. { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
  1696. { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
  1697. { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
  1698. { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
  1699. { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
  1700. { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
  1701. { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
  1702. { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
  1703. { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
  1704. { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
  1705. { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
  1706. { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
  1707. { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
  1708. { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
  1709. { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
  1710. { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
  1711. { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
  1712. { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
  1713. { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
  1714. { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
  1715. /* The following does not take into account .id=0x83847661 when subsys =
  1716. * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
  1717. * currently not fully supported.
  1718. */
  1719. { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
  1720. { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
  1721. { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
  1722. { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
  1723. { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
  1724. { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
  1725. { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
  1726. { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
  1727. { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
  1728. { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
  1729. { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
  1730. {} /* terminator */
  1731. };