patch_sigmatel.c 72 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535
  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. enum {
  38. STAC_REF,
  39. STAC_9200_MODELS
  40. };
  41. enum {
  42. STAC_9205_REF,
  43. STAC_9205_MODELS
  44. };
  45. enum {
  46. STAC_925x_REF,
  47. STAC_M2_2,
  48. STAC_MA6,
  49. STAC_PA6,
  50. STAC_925x_MODELS
  51. };
  52. enum {
  53. STAC_D945_REF,
  54. STAC_D945GTP3,
  55. STAC_D945GTP5,
  56. STAC_MACMINI,
  57. STAC_MACBOOK,
  58. STAC_MACBOOK_PRO_V1,
  59. STAC_MACBOOK_PRO_V2,
  60. STAC_IMAC_INTEL,
  61. STAC_922X_MODELS
  62. };
  63. enum {
  64. STAC_D965_REF,
  65. STAC_D965_3ST,
  66. STAC_D965_5ST,
  67. STAC_927X_MODELS
  68. };
  69. struct sigmatel_spec {
  70. struct snd_kcontrol_new *mixers[4];
  71. unsigned int num_mixers;
  72. int board_config;
  73. unsigned int surr_switch: 1;
  74. unsigned int line_switch: 1;
  75. unsigned int mic_switch: 1;
  76. unsigned int alt_switch: 1;
  77. unsigned int hp_detect: 1;
  78. unsigned int gpio_mute: 1;
  79. /* playback */
  80. struct hda_multi_out multiout;
  81. hda_nid_t dac_nids[5];
  82. /* capture */
  83. hda_nid_t *adc_nids;
  84. unsigned int num_adcs;
  85. hda_nid_t *mux_nids;
  86. unsigned int num_muxes;
  87. hda_nid_t *dmic_nids;
  88. unsigned int num_dmics;
  89. hda_nid_t dmux_nid;
  90. hda_nid_t dig_in_nid;
  91. /* pin widgets */
  92. hda_nid_t *pin_nids;
  93. unsigned int num_pins;
  94. unsigned int *pin_configs;
  95. unsigned int *bios_pin_configs;
  96. /* codec specific stuff */
  97. struct hda_verb *init;
  98. struct snd_kcontrol_new *mixer;
  99. /* capture source */
  100. struct hda_input_mux *dinput_mux;
  101. unsigned int cur_dmux;
  102. struct hda_input_mux *input_mux;
  103. unsigned int cur_mux[3];
  104. /* i/o switches */
  105. unsigned int io_switch[2];
  106. struct hda_pcm pcm_rec[2]; /* PCM information */
  107. /* dynamic controls and input_mux */
  108. struct auto_pin_cfg autocfg;
  109. unsigned int num_kctl_alloc, num_kctl_used;
  110. struct snd_kcontrol_new *kctl_alloc;
  111. struct hda_input_mux private_dimux;
  112. struct hda_input_mux private_imux;
  113. };
  114. static hda_nid_t stac9200_adc_nids[1] = {
  115. 0x03,
  116. };
  117. static hda_nid_t stac9200_mux_nids[1] = {
  118. 0x0c,
  119. };
  120. static hda_nid_t stac9200_dac_nids[1] = {
  121. 0x02,
  122. };
  123. static hda_nid_t stac925x_adc_nids[1] = {
  124. 0x03,
  125. };
  126. static hda_nid_t stac925x_mux_nids[1] = {
  127. 0x0f,
  128. };
  129. static hda_nid_t stac925x_dac_nids[1] = {
  130. 0x02,
  131. };
  132. static hda_nid_t stac925x_dmic_nids[1] = {
  133. 0x15,
  134. };
  135. static hda_nid_t stac922x_adc_nids[2] = {
  136. 0x06, 0x07,
  137. };
  138. static hda_nid_t stac922x_mux_nids[2] = {
  139. 0x12, 0x13,
  140. };
  141. static hda_nid_t stac927x_adc_nids[3] = {
  142. 0x07, 0x08, 0x09
  143. };
  144. static hda_nid_t stac927x_mux_nids[3] = {
  145. 0x15, 0x16, 0x17
  146. };
  147. static hda_nid_t stac9205_adc_nids[2] = {
  148. 0x12, 0x13
  149. };
  150. static hda_nid_t stac9205_mux_nids[2] = {
  151. 0x19, 0x1a
  152. };
  153. static hda_nid_t stac9205_dmic_nids[2] = {
  154. 0x17, 0x18,
  155. };
  156. static hda_nid_t stac9200_pin_nids[8] = {
  157. 0x08, 0x09, 0x0d, 0x0e,
  158. 0x0f, 0x10, 0x11, 0x12,
  159. };
  160. static hda_nid_t stac925x_pin_nids[8] = {
  161. 0x07, 0x08, 0x0a, 0x0b,
  162. 0x0c, 0x0d, 0x10, 0x11,
  163. };
  164. static hda_nid_t stac922x_pin_nids[10] = {
  165. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  166. 0x0f, 0x10, 0x11, 0x15, 0x1b,
  167. };
  168. static hda_nid_t stac927x_pin_nids[14] = {
  169. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  170. 0x0f, 0x10, 0x11, 0x12, 0x13,
  171. 0x14, 0x21, 0x22, 0x23,
  172. };
  173. static hda_nid_t stac9205_pin_nids[12] = {
  174. 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
  175. 0x0f, 0x14, 0x16, 0x17, 0x18,
  176. 0x21, 0x22,
  177. };
  178. static int stac92xx_dmux_enum_info(struct snd_kcontrol *kcontrol,
  179. struct snd_ctl_elem_info *uinfo)
  180. {
  181. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  182. struct sigmatel_spec *spec = codec->spec;
  183. return snd_hda_input_mux_info(spec->dinput_mux, uinfo);
  184. }
  185. static int stac92xx_dmux_enum_get(struct snd_kcontrol *kcontrol,
  186. struct snd_ctl_elem_value *ucontrol)
  187. {
  188. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  189. struct sigmatel_spec *spec = codec->spec;
  190. ucontrol->value.enumerated.item[0] = spec->cur_dmux;
  191. return 0;
  192. }
  193. static int stac92xx_dmux_enum_put(struct snd_kcontrol *kcontrol,
  194. struct snd_ctl_elem_value *ucontrol)
  195. {
  196. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  197. struct sigmatel_spec *spec = codec->spec;
  198. return snd_hda_input_mux_put(codec, spec->dinput_mux, ucontrol,
  199. spec->dmux_nid, &spec->cur_dmux);
  200. }
  201. static int stac92xx_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  202. {
  203. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  204. struct sigmatel_spec *spec = codec->spec;
  205. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  206. }
  207. static int stac92xx_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  208. {
  209. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  210. struct sigmatel_spec *spec = codec->spec;
  211. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  212. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  213. return 0;
  214. }
  215. static int stac92xx_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  216. {
  217. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  218. struct sigmatel_spec *spec = codec->spec;
  219. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  220. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  221. spec->mux_nids[adc_idx], &spec->cur_mux[adc_idx]);
  222. }
  223. static struct hda_verb stac9200_core_init[] = {
  224. /* set dac0mux for dac converter */
  225. { 0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  226. {}
  227. };
  228. static struct hda_verb stac925x_core_init[] = {
  229. /* set dac0mux for dac converter */
  230. { 0x06, AC_VERB_SET_CONNECT_SEL, 0x00},
  231. {}
  232. };
  233. static struct hda_verb stac922x_core_init[] = {
  234. /* set master volume and direct control */
  235. { 0x16, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  236. {}
  237. };
  238. static struct hda_verb d965_core_init[] = {
  239. /* set master volume and direct control */
  240. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  241. /* unmute node 0x1b */
  242. { 0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  243. /* select node 0x03 as DAC */
  244. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x01},
  245. {}
  246. };
  247. static struct hda_verb stac927x_core_init[] = {
  248. /* set master volume and direct control */
  249. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  250. {}
  251. };
  252. static struct hda_verb stac9205_core_init[] = {
  253. /* set master volume and direct control */
  254. { 0x24, AC_VERB_SET_VOLUME_KNOB_CONTROL, 0xff},
  255. {}
  256. };
  257. static struct snd_kcontrol_new stac9200_mixer[] = {
  258. HDA_CODEC_VOLUME("Master Playback Volume", 0xb, 0, HDA_OUTPUT),
  259. HDA_CODEC_MUTE("Master Playback Switch", 0xb, 0, HDA_OUTPUT),
  260. {
  261. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  262. .name = "Input Source",
  263. .count = 1,
  264. .info = stac92xx_mux_enum_info,
  265. .get = stac92xx_mux_enum_get,
  266. .put = stac92xx_mux_enum_put,
  267. },
  268. HDA_CODEC_VOLUME("Capture Volume", 0x0a, 0, HDA_OUTPUT),
  269. HDA_CODEC_MUTE("Capture Switch", 0x0a, 0, HDA_OUTPUT),
  270. HDA_CODEC_VOLUME("Capture Mux Volume", 0x0c, 0, HDA_OUTPUT),
  271. { } /* end */
  272. };
  273. static struct snd_kcontrol_new stac925x_mixer[] = {
  274. HDA_CODEC_VOLUME("Master Playback Volume", 0xe, 0, HDA_OUTPUT),
  275. HDA_CODEC_MUTE("Master Playback Switch", 0xe, 0, HDA_OUTPUT),
  276. {
  277. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  278. .name = "Input Source",
  279. .count = 1,
  280. .info = stac92xx_mux_enum_info,
  281. .get = stac92xx_mux_enum_get,
  282. .put = stac92xx_mux_enum_put,
  283. },
  284. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_OUTPUT),
  285. HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_OUTPUT),
  286. HDA_CODEC_VOLUME("Capture Mux Volume", 0x0f, 0, HDA_OUTPUT),
  287. { } /* end */
  288. };
  289. /* This needs to be generated dynamically based on sequence */
  290. static struct snd_kcontrol_new stac922x_mixer[] = {
  291. {
  292. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  293. .name = "Input Source",
  294. .count = 1,
  295. .info = stac92xx_mux_enum_info,
  296. .get = stac92xx_mux_enum_get,
  297. .put = stac92xx_mux_enum_put,
  298. },
  299. HDA_CODEC_VOLUME("Capture Volume", 0x17, 0x0, HDA_INPUT),
  300. HDA_CODEC_MUTE("Capture Switch", 0x17, 0x0, HDA_INPUT),
  301. HDA_CODEC_VOLUME("Mux Capture Volume", 0x12, 0x0, HDA_OUTPUT),
  302. { } /* end */
  303. };
  304. /* This needs to be generated dynamically based on sequence */
  305. static struct snd_kcontrol_new stac9227_mixer[] = {
  306. {
  307. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  308. .name = "Input Source",
  309. .count = 1,
  310. .info = stac92xx_mux_enum_info,
  311. .get = stac92xx_mux_enum_get,
  312. .put = stac92xx_mux_enum_put,
  313. },
  314. HDA_CODEC_VOLUME("Capture Volume", 0x15, 0x0, HDA_OUTPUT),
  315. HDA_CODEC_MUTE("Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
  316. { } /* end */
  317. };
  318. static struct snd_kcontrol_new stac927x_mixer[] = {
  319. {
  320. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  321. .name = "Input Source",
  322. .count = 1,
  323. .info = stac92xx_mux_enum_info,
  324. .get = stac92xx_mux_enum_get,
  325. .put = stac92xx_mux_enum_put,
  326. },
  327. HDA_CODEC_VOLUME("InMux Capture Volume", 0x15, 0x0, HDA_OUTPUT),
  328. HDA_CODEC_VOLUME("InVol Capture Volume", 0x18, 0x0, HDA_INPUT),
  329. HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1b, 0x0, HDA_OUTPUT),
  330. { } /* end */
  331. };
  332. static struct snd_kcontrol_new stac9205_mixer[] = {
  333. {
  334. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  335. .name = "Digital Input Source",
  336. .count = 1,
  337. .info = stac92xx_dmux_enum_info,
  338. .get = stac92xx_dmux_enum_get,
  339. .put = stac92xx_dmux_enum_put,
  340. },
  341. {
  342. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  343. .name = "Input Source",
  344. .count = 1,
  345. .info = stac92xx_mux_enum_info,
  346. .get = stac92xx_mux_enum_get,
  347. .put = stac92xx_mux_enum_put,
  348. },
  349. HDA_CODEC_VOLUME("InMux Capture Volume", 0x19, 0x0, HDA_OUTPUT),
  350. HDA_CODEC_VOLUME("InVol Capture Volume", 0x1b, 0x0, HDA_INPUT),
  351. HDA_CODEC_MUTE("ADCMux Capture Switch", 0x1d, 0x0, HDA_OUTPUT),
  352. { } /* end */
  353. };
  354. static int stac92xx_build_controls(struct hda_codec *codec)
  355. {
  356. struct sigmatel_spec *spec = codec->spec;
  357. int err;
  358. int i;
  359. err = snd_hda_add_new_ctls(codec, spec->mixer);
  360. if (err < 0)
  361. return err;
  362. for (i = 0; i < spec->num_mixers; i++) {
  363. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  364. if (err < 0)
  365. return err;
  366. }
  367. if (spec->multiout.dig_out_nid) {
  368. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  369. if (err < 0)
  370. return err;
  371. }
  372. if (spec->dig_in_nid) {
  373. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  374. if (err < 0)
  375. return err;
  376. }
  377. return 0;
  378. }
  379. static unsigned int ref9200_pin_configs[8] = {
  380. 0x01c47010, 0x01447010, 0x0221401f, 0x01114010,
  381. 0x02a19020, 0x01a19021, 0x90100140, 0x01813122,
  382. };
  383. static unsigned int *stac9200_brd_tbl[STAC_9200_MODELS] = {
  384. [STAC_REF] = ref9200_pin_configs,
  385. };
  386. static const char *stac9200_models[STAC_9200_MODELS] = {
  387. [STAC_REF] = "ref",
  388. };
  389. static struct snd_pci_quirk stac9200_cfg_tbl[] = {
  390. /* SigmaTel reference board */
  391. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  392. "DFI LanParty", STAC_REF),
  393. /* Dell laptops have BIOS problem */
  394. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01b5,
  395. "Dell Inspiron 630m", STAC_REF),
  396. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01c2,
  397. "Dell Latitude D620", STAC_REF),
  398. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cb,
  399. "Dell Latitude 120L", STAC_REF),
  400. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cc,
  401. "Dell Latitude D820", STAC_REF),
  402. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cd,
  403. "Dell Inspiron E1705/9400", STAC_REF),
  404. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01ce,
  405. "Dell XPS M1710", STAC_REF),
  406. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01cf,
  407. "Dell Precision M90", STAC_REF),
  408. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d6,
  409. "unknown Dell", STAC_REF),
  410. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01d8,
  411. "Dell Inspiron 640m", STAC_REF),
  412. SND_PCI_QUIRK(PCI_VENDOR_ID_DELL, 0x01f5,
  413. "Dell Inspiron 1501", STAC_REF),
  414. /* Panasonic */
  415. SND_PCI_QUIRK(0x10f7, 0x8338, "Panasonic CF-74", STAC_REF),
  416. {} /* terminator */
  417. };
  418. static unsigned int ref925x_pin_configs[8] = {
  419. 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
  420. 0x90a70320, 0x02214210, 0x400003f1, 0x9033032e,
  421. };
  422. static unsigned int stac925x_MA6_pin_configs[8] = {
  423. 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
  424. 0x90a70320, 0x90100211, 0x400003f1, 0x9033032e,
  425. };
  426. static unsigned int stac925x_PA6_pin_configs[8] = {
  427. 0x40c003f0, 0x424503f2, 0x01813022, 0x02a19021,
  428. 0x50a103f0, 0x90100211, 0x400003f1, 0x9033032e,
  429. };
  430. static unsigned int stac925xM2_2_pin_configs[8] = {
  431. 0x40c003f3, 0x424503f2, 0x04180011, 0x02a19020,
  432. 0x50a103f0, 0x90100212, 0x400003f1, 0x9033032e,
  433. };
  434. static unsigned int *stac925x_brd_tbl[STAC_925x_MODELS] = {
  435. [STAC_REF] = ref925x_pin_configs,
  436. [STAC_M2_2] = stac925xM2_2_pin_configs,
  437. [STAC_MA6] = stac925x_MA6_pin_configs,
  438. [STAC_PA6] = stac925x_PA6_pin_configs,
  439. };
  440. static const char *stac925x_models[STAC_925x_MODELS] = {
  441. [STAC_REF] = "ref",
  442. [STAC_M2_2] = "m2-2",
  443. [STAC_MA6] = "m6",
  444. [STAC_PA6] = "pa6",
  445. };
  446. static struct snd_pci_quirk stac925x_cfg_tbl[] = {
  447. /* SigmaTel reference board */
  448. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668, "DFI LanParty", STAC_REF),
  449. SND_PCI_QUIRK(0x8384, 0x7632, "Stac9202 Reference Board", STAC_REF),
  450. SND_PCI_QUIRK(0x107b, 0x0316, "Gateway M255", STAC_REF),
  451. SND_PCI_QUIRK(0x107b, 0x0366, "Gateway MP6954", STAC_REF),
  452. SND_PCI_QUIRK(0x107b, 0x0461, "Gateway NX560XL", STAC_MA6),
  453. SND_PCI_QUIRK(0x107b, 0x0681, "Gateway NX860", STAC_PA6),
  454. SND_PCI_QUIRK(0x1002, 0x437b, "Gateway MX6453", STAC_M2_2),
  455. {} /* terminator */
  456. };
  457. static unsigned int ref922x_pin_configs[10] = {
  458. 0x01014010, 0x01016011, 0x01012012, 0x0221401f,
  459. 0x01813122, 0x01011014, 0x01441030, 0x01c41030,
  460. 0x40000100, 0x40000100,
  461. };
  462. static unsigned int d945gtp3_pin_configs[10] = {
  463. 0x0221401f, 0x01a19022, 0x01813021, 0x01014010,
  464. 0x40000100, 0x40000100, 0x40000100, 0x40000100,
  465. 0x02a19120, 0x40000100,
  466. };
  467. static unsigned int d945gtp5_pin_configs[10] = {
  468. 0x0221401f, 0x01011012, 0x01813024, 0x01014010,
  469. 0x01a19021, 0x01016011, 0x01452130, 0x40000100,
  470. 0x02a19320, 0x40000100,
  471. };
  472. static unsigned int macbook_pro_v1_pin_configs[10] = {
  473. 0x0321e230, 0x03a1e020, 0x9017e110, 0x01014010,
  474. 0x01a19021, 0x0381e021, 0x1345e240, 0x13c5e22e,
  475. 0x02a19320, 0x400000fb
  476. };
  477. static unsigned int macbook_pro_v2_pin_configs[10] = {
  478. 0x0221401f, 0x90a70120, 0x01813024, 0x01014010,
  479. 0x400000fd, 0x01016011, 0x1345e240, 0x13c5e22e,
  480. 0x400000fc, 0x400000fb,
  481. };
  482. static unsigned int imac_intel_pin_configs[10] = {
  483. 0x0121e230, 0x90a70120, 0x9017e110, 0x400000fe,
  484. 0x400000fd, 0x0181e021, 0x1145e040, 0x400000fa,
  485. 0x400000fc, 0x400000fb,
  486. };
  487. static unsigned int *stac922x_brd_tbl[STAC_922X_MODELS] = {
  488. [STAC_D945_REF] = ref922x_pin_configs,
  489. [STAC_D945GTP3] = d945gtp3_pin_configs,
  490. [STAC_D945GTP5] = d945gtp5_pin_configs,
  491. [STAC_MACMINI] = macbook_pro_v1_pin_configs,
  492. [STAC_MACBOOK] = macbook_pro_v1_pin_configs,
  493. [STAC_MACBOOK_PRO_V1] = macbook_pro_v1_pin_configs,
  494. [STAC_MACBOOK_PRO_V2] = macbook_pro_v2_pin_configs,
  495. [STAC_IMAC_INTEL] = imac_intel_pin_configs,
  496. };
  497. static const char *stac922x_models[STAC_922X_MODELS] = {
  498. [STAC_D945_REF] = "ref",
  499. [STAC_D945GTP5] = "5stack",
  500. [STAC_D945GTP3] = "3stack",
  501. [STAC_MACMINI] = "macmini",
  502. [STAC_MACBOOK] = "macbook",
  503. [STAC_MACBOOK_PRO_V1] = "macbook-pro-v1",
  504. [STAC_MACBOOK_PRO_V2] = "macbook-pro",
  505. [STAC_IMAC_INTEL] = "imac-intel",
  506. };
  507. static struct snd_pci_quirk stac922x_cfg_tbl[] = {
  508. /* SigmaTel reference board */
  509. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  510. "DFI LanParty", STAC_D945_REF),
  511. /* Intel 945G based systems */
  512. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0101,
  513. "Intel D945G", STAC_D945GTP3),
  514. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0202,
  515. "Intel D945G", STAC_D945GTP3),
  516. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0606,
  517. "Intel D945G", STAC_D945GTP3),
  518. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0601,
  519. "Intel D945G", STAC_D945GTP3),
  520. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0111,
  521. "Intel D945G", STAC_D945GTP3),
  522. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1115,
  523. "Intel D945G", STAC_D945GTP3),
  524. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1116,
  525. "Intel D945G", STAC_D945GTP3),
  526. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1117,
  527. "Intel D945G", STAC_D945GTP3),
  528. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1118,
  529. "Intel D945G", STAC_D945GTP3),
  530. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x1119,
  531. "Intel D945G", STAC_D945GTP3),
  532. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x8826,
  533. "Intel D945G", STAC_D945GTP3),
  534. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5049,
  535. "Intel D945G", STAC_D945GTP3),
  536. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5055,
  537. "Intel D945G", STAC_D945GTP3),
  538. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x5048,
  539. "Intel D945G", STAC_D945GTP3),
  540. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0110,
  541. "Intel D945G", STAC_D945GTP3),
  542. /* Intel D945G 5-stack systems */
  543. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0404,
  544. "Intel D945G", STAC_D945GTP5),
  545. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0303,
  546. "Intel D945G", STAC_D945GTP5),
  547. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0013,
  548. "Intel D945G", STAC_D945GTP5),
  549. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0417,
  550. "Intel D945G", STAC_D945GTP5),
  551. /* Intel 945P based systems */
  552. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0b0b,
  553. "Intel D945P", STAC_D945GTP3),
  554. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0112,
  555. "Intel D945P", STAC_D945GTP3),
  556. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0d0d,
  557. "Intel D945P", STAC_D945GTP3),
  558. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0909,
  559. "Intel D945P", STAC_D945GTP3),
  560. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0505,
  561. "Intel D945P", STAC_D945GTP3),
  562. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x0707,
  563. "Intel D945P", STAC_D945GTP5),
  564. /* other systems */
  565. /* Apple Mac Mini (early 2006) */
  566. SND_PCI_QUIRK(0x8384, 0x7680,
  567. "Mac Mini", STAC_MACMINI),
  568. {} /* terminator */
  569. };
  570. static unsigned int ref927x_pin_configs[14] = {
  571. 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
  572. 0x01a19040, 0x01011012, 0x01016011, 0x0101201f,
  573. 0x183301f0, 0x18a001f0, 0x18a001f0, 0x01442070,
  574. 0x01c42190, 0x40000100,
  575. };
  576. static unsigned int d965_3st_pin_configs[14] = {
  577. 0x0221401f, 0x02a19120, 0x40000100, 0x01014011,
  578. 0x01a19021, 0x01813024, 0x40000100, 0x40000100,
  579. 0x40000100, 0x40000100, 0x40000100, 0x40000100,
  580. 0x40000100, 0x40000100
  581. };
  582. static unsigned int d965_5st_pin_configs[14] = {
  583. 0x02214020, 0x02a19080, 0x0181304e, 0x01014010,
  584. 0x01a19040, 0x01011012, 0x01016011, 0x40000100,
  585. 0x40000100, 0x40000100, 0x40000100, 0x01442070,
  586. 0x40000100, 0x40000100
  587. };
  588. static unsigned int *stac927x_brd_tbl[STAC_927X_MODELS] = {
  589. [STAC_D965_REF] = ref927x_pin_configs,
  590. [STAC_D965_3ST] = d965_3st_pin_configs,
  591. [STAC_D965_5ST] = d965_5st_pin_configs,
  592. };
  593. static const char *stac927x_models[STAC_927X_MODELS] = {
  594. [STAC_D965_REF] = "ref",
  595. [STAC_D965_3ST] = "3stack",
  596. [STAC_D965_5ST] = "5stack",
  597. };
  598. static struct snd_pci_quirk stac927x_cfg_tbl[] = {
  599. /* SigmaTel reference board */
  600. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  601. "DFI LanParty", STAC_D965_REF),
  602. /* Intel 946 based systems */
  603. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x3d01, "Intel D946", STAC_D965_3ST),
  604. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0xa301, "Intel D946", STAC_D965_3ST),
  605. /* 965 based 3 stack systems */
  606. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2116, "Intel D965", STAC_D965_3ST),
  607. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2115, "Intel D965", STAC_D965_3ST),
  608. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2114, "Intel D965", STAC_D965_3ST),
  609. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2113, "Intel D965", STAC_D965_3ST),
  610. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2112, "Intel D965", STAC_D965_3ST),
  611. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2111, "Intel D965", STAC_D965_3ST),
  612. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2110, "Intel D965", STAC_D965_3ST),
  613. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2009, "Intel D965", STAC_D965_3ST),
  614. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2008, "Intel D965", STAC_D965_3ST),
  615. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2007, "Intel D965", STAC_D965_3ST),
  616. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2006, "Intel D965", STAC_D965_3ST),
  617. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2005, "Intel D965", STAC_D965_3ST),
  618. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2004, "Intel D965", STAC_D965_3ST),
  619. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2003, "Intel D965", STAC_D965_3ST),
  620. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2002, "Intel D965", STAC_D965_3ST),
  621. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2001, "Intel D965", STAC_D965_3ST),
  622. /* 965 based 5 stack systems */
  623. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2301, "Intel D965", STAC_D965_5ST),
  624. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2302, "Intel D965", STAC_D965_5ST),
  625. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2303, "Intel D965", STAC_D965_5ST),
  626. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2304, "Intel D965", STAC_D965_5ST),
  627. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2305, "Intel D965", STAC_D965_5ST),
  628. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2501, "Intel D965", STAC_D965_5ST),
  629. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2502, "Intel D965", STAC_D965_5ST),
  630. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2503, "Intel D965", STAC_D965_5ST),
  631. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2504, "Intel D965", STAC_D965_5ST),
  632. {} /* terminator */
  633. };
  634. static unsigned int ref9205_pin_configs[12] = {
  635. 0x40000100, 0x40000100, 0x01016011, 0x01014010,
  636. 0x01813122, 0x01a19021, 0x40000100, 0x40000100,
  637. 0x90a000f0, 0x90a000f0, 0x01441030, 0x01c41030
  638. };
  639. static unsigned int *stac9205_brd_tbl[STAC_9205_MODELS] = {
  640. ref9205_pin_configs,
  641. };
  642. static const char *stac9205_models[STAC_9205_MODELS] = {
  643. [STAC_9205_REF] = "ref",
  644. };
  645. static struct snd_pci_quirk stac9205_cfg_tbl[] = {
  646. /* SigmaTel reference board */
  647. SND_PCI_QUIRK(PCI_VENDOR_ID_INTEL, 0x2668,
  648. "DFI LanParty", STAC_9205_REF),
  649. {} /* terminator */
  650. };
  651. static int stac92xx_save_bios_config_regs(struct hda_codec *codec)
  652. {
  653. int i;
  654. struct sigmatel_spec *spec = codec->spec;
  655. if (! spec->bios_pin_configs) {
  656. spec->bios_pin_configs = kcalloc(spec->num_pins,
  657. sizeof(*spec->bios_pin_configs), GFP_KERNEL);
  658. if (! spec->bios_pin_configs)
  659. return -ENOMEM;
  660. }
  661. for (i = 0; i < spec->num_pins; i++) {
  662. hda_nid_t nid = spec->pin_nids[i];
  663. unsigned int pin_cfg;
  664. pin_cfg = snd_hda_codec_read(codec, nid, 0,
  665. AC_VERB_GET_CONFIG_DEFAULT, 0x00);
  666. snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x bios pin config %8.8x\n",
  667. nid, pin_cfg);
  668. spec->bios_pin_configs[i] = pin_cfg;
  669. }
  670. return 0;
  671. }
  672. static void stac92xx_set_config_regs(struct hda_codec *codec)
  673. {
  674. int i;
  675. struct sigmatel_spec *spec = codec->spec;
  676. unsigned int pin_cfg;
  677. if (! spec->pin_nids || ! spec->pin_configs)
  678. return;
  679. for (i = 0; i < spec->num_pins; i++) {
  680. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  681. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0,
  682. spec->pin_configs[i] & 0x000000ff);
  683. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  684. AC_VERB_SET_CONFIG_DEFAULT_BYTES_1,
  685. (spec->pin_configs[i] & 0x0000ff00) >> 8);
  686. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  687. AC_VERB_SET_CONFIG_DEFAULT_BYTES_2,
  688. (spec->pin_configs[i] & 0x00ff0000) >> 16);
  689. snd_hda_codec_write(codec, spec->pin_nids[i], 0,
  690. AC_VERB_SET_CONFIG_DEFAULT_BYTES_3,
  691. spec->pin_configs[i] >> 24);
  692. pin_cfg = snd_hda_codec_read(codec, spec->pin_nids[i], 0,
  693. AC_VERB_GET_CONFIG_DEFAULT,
  694. 0x00);
  695. snd_printdd(KERN_INFO "hda_codec: pin nid %2.2x pin config %8.8x\n", spec->pin_nids[i], pin_cfg);
  696. }
  697. }
  698. /*
  699. * Analog playback callbacks
  700. */
  701. static int stac92xx_playback_pcm_open(struct hda_pcm_stream *hinfo,
  702. struct hda_codec *codec,
  703. struct snd_pcm_substream *substream)
  704. {
  705. struct sigmatel_spec *spec = codec->spec;
  706. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  707. }
  708. static int stac92xx_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  709. struct hda_codec *codec,
  710. unsigned int stream_tag,
  711. unsigned int format,
  712. struct snd_pcm_substream *substream)
  713. {
  714. struct sigmatel_spec *spec = codec->spec;
  715. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag, format, substream);
  716. }
  717. static int stac92xx_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  718. struct hda_codec *codec,
  719. struct snd_pcm_substream *substream)
  720. {
  721. struct sigmatel_spec *spec = codec->spec;
  722. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  723. }
  724. /*
  725. * Digital playback callbacks
  726. */
  727. static int stac92xx_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  728. struct hda_codec *codec,
  729. struct snd_pcm_substream *substream)
  730. {
  731. struct sigmatel_spec *spec = codec->spec;
  732. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  733. }
  734. static int stac92xx_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  735. struct hda_codec *codec,
  736. struct snd_pcm_substream *substream)
  737. {
  738. struct sigmatel_spec *spec = codec->spec;
  739. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  740. }
  741. static int stac92xx_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  742. struct hda_codec *codec,
  743. unsigned int stream_tag,
  744. unsigned int format,
  745. struct snd_pcm_substream *substream)
  746. {
  747. struct sigmatel_spec *spec = codec->spec;
  748. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  749. stream_tag, format, substream);
  750. }
  751. /*
  752. * Analog capture callbacks
  753. */
  754. static int stac92xx_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  755. struct hda_codec *codec,
  756. unsigned int stream_tag,
  757. unsigned int format,
  758. struct snd_pcm_substream *substream)
  759. {
  760. struct sigmatel_spec *spec = codec->spec;
  761. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  762. stream_tag, 0, format);
  763. return 0;
  764. }
  765. static int stac92xx_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  766. struct hda_codec *codec,
  767. struct snd_pcm_substream *substream)
  768. {
  769. struct sigmatel_spec *spec = codec->spec;
  770. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
  771. return 0;
  772. }
  773. static struct hda_pcm_stream stac92xx_pcm_digital_playback = {
  774. .substreams = 1,
  775. .channels_min = 2,
  776. .channels_max = 2,
  777. /* NID is set in stac92xx_build_pcms */
  778. .ops = {
  779. .open = stac92xx_dig_playback_pcm_open,
  780. .close = stac92xx_dig_playback_pcm_close,
  781. .prepare = stac92xx_dig_playback_pcm_prepare
  782. },
  783. };
  784. static struct hda_pcm_stream stac92xx_pcm_digital_capture = {
  785. .substreams = 1,
  786. .channels_min = 2,
  787. .channels_max = 2,
  788. /* NID is set in stac92xx_build_pcms */
  789. };
  790. static struct hda_pcm_stream stac92xx_pcm_analog_playback = {
  791. .substreams = 1,
  792. .channels_min = 2,
  793. .channels_max = 8,
  794. .nid = 0x02, /* NID to query formats and rates */
  795. .ops = {
  796. .open = stac92xx_playback_pcm_open,
  797. .prepare = stac92xx_playback_pcm_prepare,
  798. .cleanup = stac92xx_playback_pcm_cleanup
  799. },
  800. };
  801. static struct hda_pcm_stream stac92xx_pcm_analog_alt_playback = {
  802. .substreams = 1,
  803. .channels_min = 2,
  804. .channels_max = 2,
  805. .nid = 0x06, /* NID to query formats and rates */
  806. .ops = {
  807. .open = stac92xx_playback_pcm_open,
  808. .prepare = stac92xx_playback_pcm_prepare,
  809. .cleanup = stac92xx_playback_pcm_cleanup
  810. },
  811. };
  812. static struct hda_pcm_stream stac92xx_pcm_analog_capture = {
  813. .substreams = 2,
  814. .channels_min = 2,
  815. .channels_max = 2,
  816. /* NID is set in stac92xx_build_pcms */
  817. .ops = {
  818. .prepare = stac92xx_capture_pcm_prepare,
  819. .cleanup = stac92xx_capture_pcm_cleanup
  820. },
  821. };
  822. static int stac92xx_build_pcms(struct hda_codec *codec)
  823. {
  824. struct sigmatel_spec *spec = codec->spec;
  825. struct hda_pcm *info = spec->pcm_rec;
  826. codec->num_pcms = 1;
  827. codec->pcm_info = info;
  828. info->name = "STAC92xx Analog";
  829. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_playback;
  830. info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_analog_capture;
  831. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  832. if (spec->alt_switch) {
  833. codec->num_pcms++;
  834. info++;
  835. info->name = "STAC92xx Analog Alt";
  836. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_analog_alt_playback;
  837. }
  838. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  839. codec->num_pcms++;
  840. info++;
  841. info->name = "STAC92xx Digital";
  842. if (spec->multiout.dig_out_nid) {
  843. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = stac92xx_pcm_digital_playback;
  844. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  845. }
  846. if (spec->dig_in_nid) {
  847. info->stream[SNDRV_PCM_STREAM_CAPTURE] = stac92xx_pcm_digital_capture;
  848. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  849. }
  850. }
  851. return 0;
  852. }
  853. static unsigned int stac92xx_get_vref(struct hda_codec *codec, hda_nid_t nid)
  854. {
  855. unsigned int pincap = snd_hda_param_read(codec, nid,
  856. AC_PAR_PIN_CAP);
  857. pincap = (pincap & AC_PINCAP_VREF) >> AC_PINCAP_VREF_SHIFT;
  858. if (pincap & AC_PINCAP_VREF_100)
  859. return AC_PINCTL_VREF_100;
  860. if (pincap & AC_PINCAP_VREF_80)
  861. return AC_PINCTL_VREF_80;
  862. if (pincap & AC_PINCAP_VREF_50)
  863. return AC_PINCTL_VREF_50;
  864. if (pincap & AC_PINCAP_VREF_GRD)
  865. return AC_PINCTL_VREF_GRD;
  866. return 0;
  867. }
  868. static void stac92xx_auto_set_pinctl(struct hda_codec *codec, hda_nid_t nid, int pin_type)
  869. {
  870. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  871. }
  872. static int stac92xx_io_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  873. {
  874. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  875. uinfo->count = 1;
  876. uinfo->value.integer.min = 0;
  877. uinfo->value.integer.max = 1;
  878. return 0;
  879. }
  880. static int stac92xx_io_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  881. {
  882. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  883. struct sigmatel_spec *spec = codec->spec;
  884. int io_idx = kcontrol-> private_value & 0xff;
  885. ucontrol->value.integer.value[0] = spec->io_switch[io_idx];
  886. return 0;
  887. }
  888. static int stac92xx_io_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  889. {
  890. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  891. struct sigmatel_spec *spec = codec->spec;
  892. hda_nid_t nid = kcontrol->private_value >> 8;
  893. int io_idx = kcontrol-> private_value & 0xff;
  894. unsigned short val = ucontrol->value.integer.value[0];
  895. spec->io_switch[io_idx] = val;
  896. if (val)
  897. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  898. else {
  899. unsigned int pinctl = AC_PINCTL_IN_EN;
  900. if (io_idx) /* set VREF for mic */
  901. pinctl |= stac92xx_get_vref(codec, nid);
  902. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  903. }
  904. return 1;
  905. }
  906. #define STAC_CODEC_IO_SWITCH(xname, xpval) \
  907. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  908. .name = xname, \
  909. .index = 0, \
  910. .info = stac92xx_io_switch_info, \
  911. .get = stac92xx_io_switch_get, \
  912. .put = stac92xx_io_switch_put, \
  913. .private_value = xpval, \
  914. }
  915. enum {
  916. STAC_CTL_WIDGET_VOL,
  917. STAC_CTL_WIDGET_MUTE,
  918. STAC_CTL_WIDGET_IO_SWITCH,
  919. };
  920. static struct snd_kcontrol_new stac92xx_control_templates[] = {
  921. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  922. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  923. STAC_CODEC_IO_SWITCH(NULL, 0),
  924. };
  925. /* add dynamic controls */
  926. static int stac92xx_add_control(struct sigmatel_spec *spec, int type, const char *name, unsigned long val)
  927. {
  928. struct snd_kcontrol_new *knew;
  929. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  930. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  931. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  932. if (! knew)
  933. return -ENOMEM;
  934. if (spec->kctl_alloc) {
  935. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  936. kfree(spec->kctl_alloc);
  937. }
  938. spec->kctl_alloc = knew;
  939. spec->num_kctl_alloc = num;
  940. }
  941. knew = &spec->kctl_alloc[spec->num_kctl_used];
  942. *knew = stac92xx_control_templates[type];
  943. knew->name = kstrdup(name, GFP_KERNEL);
  944. if (! knew->name)
  945. return -ENOMEM;
  946. knew->private_value = val;
  947. spec->num_kctl_used++;
  948. return 0;
  949. }
  950. /* flag inputs as additional dynamic lineouts */
  951. static int stac92xx_add_dyn_out_pins(struct hda_codec *codec, struct auto_pin_cfg *cfg)
  952. {
  953. struct sigmatel_spec *spec = codec->spec;
  954. unsigned int wcaps, wtype;
  955. int i, num_dacs = 0;
  956. /* use the wcaps cache to count all DACs available for line-outs */
  957. for (i = 0; i < codec->num_nodes; i++) {
  958. wcaps = codec->wcaps[i];
  959. wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  960. if (wtype == AC_WID_AUD_OUT && !(wcaps & AC_WCAP_DIGITAL))
  961. num_dacs++;
  962. }
  963. snd_printdd("%s: total dac count=%d\n", __func__, num_dacs);
  964. switch (cfg->line_outs) {
  965. case 3:
  966. /* add line-in as side */
  967. if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 3) {
  968. cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_LINE];
  969. spec->line_switch = 1;
  970. cfg->line_outs++;
  971. }
  972. break;
  973. case 2:
  974. /* add line-in as clfe and mic as side */
  975. if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 2) {
  976. cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_LINE];
  977. spec->line_switch = 1;
  978. cfg->line_outs++;
  979. }
  980. if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 3) {
  981. cfg->line_out_pins[3] = cfg->input_pins[AUTO_PIN_MIC];
  982. spec->mic_switch = 1;
  983. cfg->line_outs++;
  984. }
  985. break;
  986. case 1:
  987. /* add line-in as surr and mic as clfe */
  988. if (cfg->input_pins[AUTO_PIN_LINE] && num_dacs > 1) {
  989. cfg->line_out_pins[1] = cfg->input_pins[AUTO_PIN_LINE];
  990. spec->line_switch = 1;
  991. cfg->line_outs++;
  992. }
  993. if (cfg->input_pins[AUTO_PIN_MIC] && num_dacs > 2) {
  994. cfg->line_out_pins[2] = cfg->input_pins[AUTO_PIN_MIC];
  995. spec->mic_switch = 1;
  996. cfg->line_outs++;
  997. }
  998. break;
  999. }
  1000. return 0;
  1001. }
  1002. static int is_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
  1003. {
  1004. int i;
  1005. for (i = 0; i < spec->multiout.num_dacs; i++) {
  1006. if (spec->multiout.dac_nids[i] == nid)
  1007. return 1;
  1008. }
  1009. return 0;
  1010. }
  1011. /*
  1012. * Fill in the dac_nids table from the parsed pin configuration
  1013. * This function only works when every pin in line_out_pins[]
  1014. * contains atleast one DAC in its connection list. Some 92xx
  1015. * codecs are not connected directly to a DAC, such as the 9200
  1016. * and 9202/925x. For those, dac_nids[] must be hard-coded.
  1017. */
  1018. static int stac92xx_auto_fill_dac_nids(struct hda_codec *codec,
  1019. const struct auto_pin_cfg *cfg)
  1020. {
  1021. struct sigmatel_spec *spec = codec->spec;
  1022. int i, j, conn_len = 0;
  1023. hda_nid_t nid, conn[HDA_MAX_CONNECTIONS];
  1024. unsigned int wcaps, wtype;
  1025. for (i = 0; i < cfg->line_outs; i++) {
  1026. nid = cfg->line_out_pins[i];
  1027. conn_len = snd_hda_get_connections(codec, nid, conn,
  1028. HDA_MAX_CONNECTIONS);
  1029. for (j = 0; j < conn_len; j++) {
  1030. wcaps = snd_hda_param_read(codec, conn[j],
  1031. AC_PAR_AUDIO_WIDGET_CAP);
  1032. wtype = (wcaps & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  1033. if (wtype != AC_WID_AUD_OUT ||
  1034. (wcaps & AC_WCAP_DIGITAL))
  1035. continue;
  1036. /* conn[j] is a DAC routed to this line-out */
  1037. if (!is_in_dac_nids(spec, conn[j]))
  1038. break;
  1039. }
  1040. if (j == conn_len) {
  1041. /* error out, no available DAC found */
  1042. snd_printk(KERN_ERR
  1043. "%s: No available DAC for pin 0x%x\n",
  1044. __func__, nid);
  1045. return -ENODEV;
  1046. }
  1047. spec->multiout.dac_nids[i] = conn[j];
  1048. spec->multiout.num_dacs++;
  1049. if (conn_len > 1) {
  1050. /* select this DAC in the pin's input mux */
  1051. snd_hda_codec_write(codec, nid, 0,
  1052. AC_VERB_SET_CONNECT_SEL, j);
  1053. }
  1054. }
  1055. snd_printd("dac_nids=%d (0x%x/0x%x/0x%x/0x%x/0x%x)\n",
  1056. spec->multiout.num_dacs,
  1057. spec->multiout.dac_nids[0],
  1058. spec->multiout.dac_nids[1],
  1059. spec->multiout.dac_nids[2],
  1060. spec->multiout.dac_nids[3],
  1061. spec->multiout.dac_nids[4]);
  1062. return 0;
  1063. }
  1064. /* create volume control/switch for the given prefx type */
  1065. static int create_controls(struct sigmatel_spec *spec, const char *pfx, hda_nid_t nid, int chs)
  1066. {
  1067. char name[32];
  1068. int err;
  1069. sprintf(name, "%s Playback Volume", pfx);
  1070. err = stac92xx_add_control(spec, STAC_CTL_WIDGET_VOL, name,
  1071. HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
  1072. if (err < 0)
  1073. return err;
  1074. sprintf(name, "%s Playback Switch", pfx);
  1075. err = stac92xx_add_control(spec, STAC_CTL_WIDGET_MUTE, name,
  1076. HDA_COMPOSE_AMP_VAL(nid, chs, 0, HDA_OUTPUT));
  1077. if (err < 0)
  1078. return err;
  1079. return 0;
  1080. }
  1081. /* add playback controls from the parsed DAC table */
  1082. static int stac92xx_auto_create_multi_out_ctls(struct sigmatel_spec *spec,
  1083. const struct auto_pin_cfg *cfg)
  1084. {
  1085. static const char *chname[4] = {
  1086. "Front", "Surround", NULL /*CLFE*/, "Side"
  1087. };
  1088. hda_nid_t nid;
  1089. int i, err;
  1090. for (i = 0; i < cfg->line_outs; i++) {
  1091. if (!spec->multiout.dac_nids[i])
  1092. continue;
  1093. nid = spec->multiout.dac_nids[i];
  1094. if (i == 2) {
  1095. /* Center/LFE */
  1096. err = create_controls(spec, "Center", nid, 1);
  1097. if (err < 0)
  1098. return err;
  1099. err = create_controls(spec, "LFE", nid, 2);
  1100. if (err < 0)
  1101. return err;
  1102. } else {
  1103. err = create_controls(spec, chname[i], nid, 3);
  1104. if (err < 0)
  1105. return err;
  1106. }
  1107. }
  1108. if (spec->line_switch)
  1109. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Line In as Output Switch", cfg->input_pins[AUTO_PIN_LINE] << 8)) < 0)
  1110. return err;
  1111. if (spec->mic_switch)
  1112. if ((err = stac92xx_add_control(spec, STAC_CTL_WIDGET_IO_SWITCH, "Mic as Output Switch", (cfg->input_pins[AUTO_PIN_MIC] << 8) | 1)) < 0)
  1113. return err;
  1114. return 0;
  1115. }
  1116. static int check_in_dac_nids(struct sigmatel_spec *spec, hda_nid_t nid)
  1117. {
  1118. if (is_in_dac_nids(spec, nid))
  1119. return 1;
  1120. if (spec->multiout.hp_nid == nid)
  1121. return 1;
  1122. return 0;
  1123. }
  1124. static int add_spec_dacs(struct sigmatel_spec *spec, hda_nid_t nid)
  1125. {
  1126. if (!spec->multiout.hp_nid)
  1127. spec->multiout.hp_nid = nid;
  1128. else if (spec->multiout.num_dacs > 4) {
  1129. printk(KERN_WARNING "stac92xx: No space for DAC 0x%x\n", nid);
  1130. return 1;
  1131. } else {
  1132. spec->multiout.dac_nids[spec->multiout.num_dacs] = nid;
  1133. spec->multiout.num_dacs++;
  1134. }
  1135. return 0;
  1136. }
  1137. /* add playback controls for Speaker and HP outputs */
  1138. static int stac92xx_auto_create_hp_ctls(struct hda_codec *codec,
  1139. struct auto_pin_cfg *cfg)
  1140. {
  1141. struct sigmatel_spec *spec = codec->spec;
  1142. hda_nid_t nid;
  1143. int i, old_num_dacs, err;
  1144. old_num_dacs = spec->multiout.num_dacs;
  1145. for (i = 0; i < cfg->hp_outs; i++) {
  1146. unsigned int wid_caps = get_wcaps(codec, cfg->hp_pins[i]);
  1147. if (wid_caps & AC_WCAP_UNSOL_CAP)
  1148. spec->hp_detect = 1;
  1149. nid = snd_hda_codec_read(codec, cfg->hp_pins[i], 0,
  1150. AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
  1151. if (check_in_dac_nids(spec, nid))
  1152. nid = 0;
  1153. if (! nid)
  1154. continue;
  1155. add_spec_dacs(spec, nid);
  1156. }
  1157. for (i = 0; i < cfg->speaker_outs; i++) {
  1158. nid = snd_hda_codec_read(codec, cfg->speaker_pins[i], 0,
  1159. AC_VERB_GET_CONNECT_LIST, 0) & 0xff;
  1160. if (check_in_dac_nids(spec, nid))
  1161. nid = 0;
  1162. if (! nid)
  1163. continue;
  1164. add_spec_dacs(spec, nid);
  1165. }
  1166. for (i = old_num_dacs; i < spec->multiout.num_dacs; i++) {
  1167. static const char *pfxs[] = {
  1168. "Speaker", "External Speaker", "Speaker2",
  1169. };
  1170. err = create_controls(spec, pfxs[i - old_num_dacs],
  1171. spec->multiout.dac_nids[i], 3);
  1172. if (err < 0)
  1173. return err;
  1174. }
  1175. if (spec->multiout.hp_nid) {
  1176. const char *pfx;
  1177. if (old_num_dacs == spec->multiout.num_dacs)
  1178. pfx = "Master";
  1179. else
  1180. pfx = "Headphone";
  1181. err = create_controls(spec, pfx, spec->multiout.hp_nid, 3);
  1182. if (err < 0)
  1183. return err;
  1184. }
  1185. return 0;
  1186. }
  1187. /* labels for dmic mux inputs */
  1188. static const char *stac92xx_dmic_labels[5] = {
  1189. "Analog Inputs", "Digital Mic 1", "Digital Mic 2",
  1190. "Digital Mic 3", "Digital Mic 4"
  1191. };
  1192. /* create playback/capture controls for input pins on dmic capable codecs */
  1193. static int stac92xx_auto_create_dmic_input_ctls(struct hda_codec *codec,
  1194. const struct auto_pin_cfg *cfg)
  1195. {
  1196. struct sigmatel_spec *spec = codec->spec;
  1197. struct hda_input_mux *dimux = &spec->private_dimux;
  1198. hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
  1199. int i, j;
  1200. dimux->items[dimux->num_items].label = stac92xx_dmic_labels[0];
  1201. dimux->items[dimux->num_items].index = 0;
  1202. dimux->num_items++;
  1203. for (i = 0; i < spec->num_dmics; i++) {
  1204. int index;
  1205. int num_cons;
  1206. unsigned int def_conf;
  1207. def_conf = snd_hda_codec_read(codec,
  1208. spec->dmic_nids[i],
  1209. 0,
  1210. AC_VERB_GET_CONFIG_DEFAULT,
  1211. 0);
  1212. if (get_defcfg_connect(def_conf) == AC_JACK_PORT_NONE)
  1213. continue;
  1214. num_cons = snd_hda_get_connections(codec,
  1215. spec->dmux_nid,
  1216. con_lst,
  1217. HDA_MAX_NUM_INPUTS);
  1218. for (j = 0; j < num_cons; j++)
  1219. if (con_lst[j] == spec->dmic_nids[i]) {
  1220. index = j;
  1221. goto found;
  1222. }
  1223. continue;
  1224. found:
  1225. dimux->items[dimux->num_items].label =
  1226. stac92xx_dmic_labels[dimux->num_items];
  1227. dimux->items[dimux->num_items].index = index;
  1228. dimux->num_items++;
  1229. }
  1230. return 0;
  1231. }
  1232. /* create playback/capture controls for input pins */
  1233. static int stac92xx_auto_create_analog_input_ctls(struct hda_codec *codec, const struct auto_pin_cfg *cfg)
  1234. {
  1235. struct sigmatel_spec *spec = codec->spec;
  1236. struct hda_input_mux *imux = &spec->private_imux;
  1237. hda_nid_t con_lst[HDA_MAX_NUM_INPUTS];
  1238. int i, j, k;
  1239. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1240. int index;
  1241. if (!cfg->input_pins[i])
  1242. continue;
  1243. index = -1;
  1244. for (j = 0; j < spec->num_muxes; j++) {
  1245. int num_cons;
  1246. num_cons = snd_hda_get_connections(codec,
  1247. spec->mux_nids[j],
  1248. con_lst,
  1249. HDA_MAX_NUM_INPUTS);
  1250. for (k = 0; k < num_cons; k++)
  1251. if (con_lst[k] == cfg->input_pins[i]) {
  1252. index = k;
  1253. goto found;
  1254. }
  1255. }
  1256. continue;
  1257. found:
  1258. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  1259. imux->items[imux->num_items].index = index;
  1260. imux->num_items++;
  1261. }
  1262. if (imux->num_items) {
  1263. /*
  1264. * Set the current input for the muxes.
  1265. * The STAC9221 has two input muxes with identical source
  1266. * NID lists. Hopefully this won't get confused.
  1267. */
  1268. for (i = 0; i < spec->num_muxes; i++) {
  1269. snd_hda_codec_write(codec, spec->mux_nids[i], 0,
  1270. AC_VERB_SET_CONNECT_SEL,
  1271. imux->items[0].index);
  1272. }
  1273. }
  1274. return 0;
  1275. }
  1276. static void stac92xx_auto_init_multi_out(struct hda_codec *codec)
  1277. {
  1278. struct sigmatel_spec *spec = codec->spec;
  1279. int i;
  1280. for (i = 0; i < spec->autocfg.line_outs; i++) {
  1281. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  1282. stac92xx_auto_set_pinctl(codec, nid, AC_PINCTL_OUT_EN);
  1283. }
  1284. }
  1285. static void stac92xx_auto_init_hp_out(struct hda_codec *codec)
  1286. {
  1287. struct sigmatel_spec *spec = codec->spec;
  1288. int i;
  1289. for (i = 0; i < spec->autocfg.hp_outs; i++) {
  1290. hda_nid_t pin;
  1291. pin = spec->autocfg.hp_pins[i];
  1292. if (pin) /* connect to front */
  1293. stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN);
  1294. }
  1295. for (i = 0; i < spec->autocfg.speaker_outs; i++) {
  1296. hda_nid_t pin;
  1297. pin = spec->autocfg.speaker_pins[i];
  1298. if (pin) /* connect to front */
  1299. stac92xx_auto_set_pinctl(codec, pin, AC_PINCTL_OUT_EN);
  1300. }
  1301. }
  1302. static int stac92xx_parse_auto_config(struct hda_codec *codec, hda_nid_t dig_out, hda_nid_t dig_in)
  1303. {
  1304. struct sigmatel_spec *spec = codec->spec;
  1305. int err;
  1306. if ((err = snd_hda_parse_pin_def_config(codec,
  1307. &spec->autocfg,
  1308. spec->dmic_nids)) < 0)
  1309. return err;
  1310. if (! spec->autocfg.line_outs)
  1311. return 0; /* can't find valid pin config */
  1312. if ((err = stac92xx_add_dyn_out_pins(codec, &spec->autocfg)) < 0)
  1313. return err;
  1314. if (spec->multiout.num_dacs == 0)
  1315. if ((err = stac92xx_auto_fill_dac_nids(codec, &spec->autocfg)) < 0)
  1316. return err;
  1317. if ((err = stac92xx_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  1318. (err = stac92xx_auto_create_hp_ctls(codec, &spec->autocfg)) < 0 ||
  1319. (err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
  1320. return err;
  1321. if (spec->num_dmics > 0)
  1322. if ((err = stac92xx_auto_create_dmic_input_ctls(codec,
  1323. &spec->autocfg)) < 0)
  1324. return err;
  1325. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  1326. if (spec->multiout.max_channels > 2)
  1327. spec->surr_switch = 1;
  1328. if (spec->autocfg.dig_out_pin)
  1329. spec->multiout.dig_out_nid = dig_out;
  1330. if (spec->autocfg.dig_in_pin)
  1331. spec->dig_in_nid = dig_in;
  1332. if (spec->kctl_alloc)
  1333. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  1334. spec->input_mux = &spec->private_imux;
  1335. spec->dinput_mux = &spec->private_dimux;
  1336. return 1;
  1337. }
  1338. /* add playback controls for HP output */
  1339. static int stac9200_auto_create_hp_ctls(struct hda_codec *codec,
  1340. struct auto_pin_cfg *cfg)
  1341. {
  1342. struct sigmatel_spec *spec = codec->spec;
  1343. hda_nid_t pin = cfg->hp_pins[0];
  1344. unsigned int wid_caps;
  1345. if (! pin)
  1346. return 0;
  1347. wid_caps = get_wcaps(codec, pin);
  1348. if (wid_caps & AC_WCAP_UNSOL_CAP)
  1349. spec->hp_detect = 1;
  1350. return 0;
  1351. }
  1352. /* add playback controls for LFE output */
  1353. static int stac9200_auto_create_lfe_ctls(struct hda_codec *codec,
  1354. struct auto_pin_cfg *cfg)
  1355. {
  1356. struct sigmatel_spec *spec = codec->spec;
  1357. int err;
  1358. hda_nid_t lfe_pin = 0x0;
  1359. int i;
  1360. /*
  1361. * search speaker outs and line outs for a mono speaker pin
  1362. * with an amp. If one is found, add LFE controls
  1363. * for it.
  1364. */
  1365. for (i = 0; i < spec->autocfg.speaker_outs && lfe_pin == 0x0; i++) {
  1366. hda_nid_t pin = spec->autocfg.speaker_pins[i];
  1367. unsigned long wcaps = get_wcaps(codec, pin);
  1368. wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
  1369. if (wcaps == AC_WCAP_OUT_AMP)
  1370. /* found a mono speaker with an amp, must be lfe */
  1371. lfe_pin = pin;
  1372. }
  1373. /* if speaker_outs is 0, then speakers may be in line_outs */
  1374. if (lfe_pin == 0 && spec->autocfg.speaker_outs == 0) {
  1375. for (i = 0; i < spec->autocfg.line_outs && lfe_pin == 0x0; i++) {
  1376. hda_nid_t pin = spec->autocfg.line_out_pins[i];
  1377. unsigned long cfg;
  1378. cfg = snd_hda_codec_read(codec, pin, 0,
  1379. AC_VERB_GET_CONFIG_DEFAULT,
  1380. 0x00);
  1381. if (get_defcfg_device(cfg) == AC_JACK_SPEAKER) {
  1382. unsigned long wcaps = get_wcaps(codec, pin);
  1383. wcaps &= (AC_WCAP_STEREO | AC_WCAP_OUT_AMP);
  1384. if (wcaps == AC_WCAP_OUT_AMP)
  1385. /* found a mono speaker with an amp,
  1386. must be lfe */
  1387. lfe_pin = pin;
  1388. }
  1389. }
  1390. }
  1391. if (lfe_pin) {
  1392. err = create_controls(spec, "LFE", lfe_pin, 1);
  1393. if (err < 0)
  1394. return err;
  1395. }
  1396. return 0;
  1397. }
  1398. static int stac9200_parse_auto_config(struct hda_codec *codec)
  1399. {
  1400. struct sigmatel_spec *spec = codec->spec;
  1401. int err;
  1402. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL)) < 0)
  1403. return err;
  1404. if ((err = stac92xx_auto_create_analog_input_ctls(codec, &spec->autocfg)) < 0)
  1405. return err;
  1406. if ((err = stac9200_auto_create_hp_ctls(codec, &spec->autocfg)) < 0)
  1407. return err;
  1408. if ((err = stac9200_auto_create_lfe_ctls(codec, &spec->autocfg)) < 0)
  1409. return err;
  1410. if (spec->autocfg.dig_out_pin)
  1411. spec->multiout.dig_out_nid = 0x05;
  1412. if (spec->autocfg.dig_in_pin)
  1413. spec->dig_in_nid = 0x04;
  1414. if (spec->kctl_alloc)
  1415. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  1416. spec->input_mux = &spec->private_imux;
  1417. spec->dinput_mux = &spec->private_dimux;
  1418. return 1;
  1419. }
  1420. /*
  1421. * Early 2006 Intel Macintoshes with STAC9220X5 codecs seem to have a
  1422. * funky external mute control using GPIO pins.
  1423. */
  1424. static void stac922x_gpio_mute(struct hda_codec *codec, int pin, int muted)
  1425. {
  1426. unsigned int gpiostate, gpiomask, gpiodir;
  1427. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  1428. AC_VERB_GET_GPIO_DATA, 0);
  1429. if (!muted)
  1430. gpiostate |= (1 << pin);
  1431. else
  1432. gpiostate &= ~(1 << pin);
  1433. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  1434. AC_VERB_GET_GPIO_MASK, 0);
  1435. gpiomask |= (1 << pin);
  1436. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  1437. AC_VERB_GET_GPIO_DIRECTION, 0);
  1438. gpiodir |= (1 << pin);
  1439. /* AppleHDA seems to do this -- WTF is this verb?? */
  1440. snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0);
  1441. snd_hda_codec_write(codec, codec->afg, 0,
  1442. AC_VERB_SET_GPIO_MASK, gpiomask);
  1443. snd_hda_codec_write(codec, codec->afg, 0,
  1444. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  1445. msleep(1);
  1446. snd_hda_codec_write(codec, codec->afg, 0,
  1447. AC_VERB_SET_GPIO_DATA, gpiostate);
  1448. }
  1449. static void enable_pin_detect(struct hda_codec *codec, hda_nid_t nid,
  1450. unsigned int event)
  1451. {
  1452. if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP)
  1453. snd_hda_codec_write(codec, nid, 0,
  1454. AC_VERB_SET_UNSOLICITED_ENABLE,
  1455. (AC_USRSP_EN | event));
  1456. }
  1457. static int stac92xx_init(struct hda_codec *codec)
  1458. {
  1459. struct sigmatel_spec *spec = codec->spec;
  1460. struct auto_pin_cfg *cfg = &spec->autocfg;
  1461. int i;
  1462. snd_hda_sequence_write(codec, spec->init);
  1463. /* set up pins */
  1464. if (spec->hp_detect) {
  1465. /* Enable unsolicited responses on the HP widget */
  1466. for (i = 0; i < cfg->hp_outs; i++)
  1467. enable_pin_detect(codec, cfg->hp_pins[i],
  1468. STAC_HP_EVENT);
  1469. /* force to enable the first line-out; the others are set up
  1470. * in unsol_event
  1471. */
  1472. stac92xx_auto_set_pinctl(codec, spec->autocfg.line_out_pins[0],
  1473. AC_PINCTL_OUT_EN);
  1474. stac92xx_auto_init_hp_out(codec);
  1475. /* fake event to set up pins */
  1476. codec->patch_ops.unsol_event(codec, STAC_HP_EVENT << 26);
  1477. } else {
  1478. stac92xx_auto_init_multi_out(codec);
  1479. stac92xx_auto_init_hp_out(codec);
  1480. }
  1481. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1482. hda_nid_t nid = cfg->input_pins[i];
  1483. if (nid) {
  1484. unsigned int pinctl = AC_PINCTL_IN_EN;
  1485. if (i == AUTO_PIN_MIC || i == AUTO_PIN_FRONT_MIC)
  1486. pinctl |= stac92xx_get_vref(codec, nid);
  1487. stac92xx_auto_set_pinctl(codec, nid, pinctl);
  1488. }
  1489. }
  1490. if (spec->num_dmics > 0)
  1491. for (i = 0; i < spec->num_dmics; i++)
  1492. stac92xx_auto_set_pinctl(codec, spec->dmic_nids[i],
  1493. AC_PINCTL_IN_EN);
  1494. if (cfg->dig_out_pin)
  1495. stac92xx_auto_set_pinctl(codec, cfg->dig_out_pin,
  1496. AC_PINCTL_OUT_EN);
  1497. if (cfg->dig_in_pin)
  1498. stac92xx_auto_set_pinctl(codec, cfg->dig_in_pin,
  1499. AC_PINCTL_IN_EN);
  1500. if (spec->gpio_mute) {
  1501. stac922x_gpio_mute(codec, 0, 0);
  1502. stac922x_gpio_mute(codec, 1, 0);
  1503. }
  1504. return 0;
  1505. }
  1506. static void stac92xx_free(struct hda_codec *codec)
  1507. {
  1508. struct sigmatel_spec *spec = codec->spec;
  1509. int i;
  1510. if (! spec)
  1511. return;
  1512. if (spec->kctl_alloc) {
  1513. for (i = 0; i < spec->num_kctl_used; i++)
  1514. kfree(spec->kctl_alloc[i].name);
  1515. kfree(spec->kctl_alloc);
  1516. }
  1517. if (spec->bios_pin_configs)
  1518. kfree(spec->bios_pin_configs);
  1519. kfree(spec);
  1520. }
  1521. static void stac92xx_set_pinctl(struct hda_codec *codec, hda_nid_t nid,
  1522. unsigned int flag)
  1523. {
  1524. unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
  1525. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  1526. if (pin_ctl & AC_PINCTL_IN_EN) {
  1527. /*
  1528. * we need to check the current set-up direction of
  1529. * shared input pins since they can be switched via
  1530. * "xxx as Output" mixer switch
  1531. */
  1532. struct sigmatel_spec *spec = codec->spec;
  1533. struct auto_pin_cfg *cfg = &spec->autocfg;
  1534. if ((nid == cfg->input_pins[AUTO_PIN_LINE] &&
  1535. spec->line_switch) ||
  1536. (nid == cfg->input_pins[AUTO_PIN_MIC] &&
  1537. spec->mic_switch))
  1538. return;
  1539. }
  1540. /* if setting pin direction bits, clear the current
  1541. direction bits first */
  1542. if (flag & (AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN))
  1543. pin_ctl &= ~(AC_PINCTL_IN_EN | AC_PINCTL_OUT_EN);
  1544. snd_hda_codec_write(codec, nid, 0,
  1545. AC_VERB_SET_PIN_WIDGET_CONTROL,
  1546. pin_ctl | flag);
  1547. }
  1548. static void stac92xx_reset_pinctl(struct hda_codec *codec, hda_nid_t nid,
  1549. unsigned int flag)
  1550. {
  1551. unsigned int pin_ctl = snd_hda_codec_read(codec, nid,
  1552. 0, AC_VERB_GET_PIN_WIDGET_CONTROL, 0x00);
  1553. snd_hda_codec_write(codec, nid, 0,
  1554. AC_VERB_SET_PIN_WIDGET_CONTROL,
  1555. pin_ctl & ~flag);
  1556. }
  1557. static int get_pin_presence(struct hda_codec *codec, hda_nid_t nid)
  1558. {
  1559. if (!nid)
  1560. return 0;
  1561. if (snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_PIN_SENSE, 0x00)
  1562. & (1 << 31))
  1563. return 1;
  1564. return 0;
  1565. }
  1566. static void stac92xx_hp_detect(struct hda_codec *codec, unsigned int res)
  1567. {
  1568. struct sigmatel_spec *spec = codec->spec;
  1569. struct auto_pin_cfg *cfg = &spec->autocfg;
  1570. int i, presence;
  1571. presence = 0;
  1572. for (i = 0; i < cfg->hp_outs; i++) {
  1573. presence = get_pin_presence(codec, cfg->hp_pins[i]);
  1574. if (presence)
  1575. break;
  1576. }
  1577. if (presence) {
  1578. /* disable lineouts, enable hp */
  1579. for (i = 0; i < cfg->line_outs; i++)
  1580. stac92xx_reset_pinctl(codec, cfg->line_out_pins[i],
  1581. AC_PINCTL_OUT_EN);
  1582. for (i = 0; i < cfg->speaker_outs; i++)
  1583. stac92xx_reset_pinctl(codec, cfg->speaker_pins[i],
  1584. AC_PINCTL_OUT_EN);
  1585. } else {
  1586. /* enable lineouts, disable hp */
  1587. for (i = 0; i < cfg->line_outs; i++)
  1588. stac92xx_set_pinctl(codec, cfg->line_out_pins[i],
  1589. AC_PINCTL_OUT_EN);
  1590. for (i = 0; i < cfg->speaker_outs; i++)
  1591. stac92xx_set_pinctl(codec, cfg->speaker_pins[i],
  1592. AC_PINCTL_OUT_EN);
  1593. }
  1594. }
  1595. static void stac92xx_unsol_event(struct hda_codec *codec, unsigned int res)
  1596. {
  1597. switch (res >> 26) {
  1598. case STAC_HP_EVENT:
  1599. stac92xx_hp_detect(codec, res);
  1600. break;
  1601. }
  1602. }
  1603. #ifdef CONFIG_PM
  1604. static int stac92xx_resume(struct hda_codec *codec)
  1605. {
  1606. struct sigmatel_spec *spec = codec->spec;
  1607. int i;
  1608. stac92xx_init(codec);
  1609. stac92xx_set_config_regs(codec);
  1610. snd_hda_resume_ctls(codec, spec->mixer);
  1611. for (i = 0; i < spec->num_mixers; i++)
  1612. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1613. if (spec->multiout.dig_out_nid)
  1614. snd_hda_resume_spdif_out(codec);
  1615. if (spec->dig_in_nid)
  1616. snd_hda_resume_spdif_in(codec);
  1617. return 0;
  1618. }
  1619. #endif
  1620. static struct hda_codec_ops stac92xx_patch_ops = {
  1621. .build_controls = stac92xx_build_controls,
  1622. .build_pcms = stac92xx_build_pcms,
  1623. .init = stac92xx_init,
  1624. .free = stac92xx_free,
  1625. .unsol_event = stac92xx_unsol_event,
  1626. #ifdef CONFIG_PM
  1627. .resume = stac92xx_resume,
  1628. #endif
  1629. };
  1630. static int patch_stac9200(struct hda_codec *codec)
  1631. {
  1632. struct sigmatel_spec *spec;
  1633. int err;
  1634. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1635. if (spec == NULL)
  1636. return -ENOMEM;
  1637. codec->spec = spec;
  1638. spec->num_pins = 8;
  1639. spec->pin_nids = stac9200_pin_nids;
  1640. spec->board_config = snd_hda_check_board_config(codec, STAC_9200_MODELS,
  1641. stac9200_models,
  1642. stac9200_cfg_tbl);
  1643. if (spec->board_config < 0) {
  1644. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9200, using BIOS defaults\n");
  1645. err = stac92xx_save_bios_config_regs(codec);
  1646. if (err < 0) {
  1647. stac92xx_free(codec);
  1648. return err;
  1649. }
  1650. spec->pin_configs = spec->bios_pin_configs;
  1651. } else {
  1652. spec->pin_configs = stac9200_brd_tbl[spec->board_config];
  1653. stac92xx_set_config_regs(codec);
  1654. }
  1655. spec->multiout.max_channels = 2;
  1656. spec->multiout.num_dacs = 1;
  1657. spec->multiout.dac_nids = stac9200_dac_nids;
  1658. spec->adc_nids = stac9200_adc_nids;
  1659. spec->mux_nids = stac9200_mux_nids;
  1660. spec->num_muxes = 1;
  1661. spec->num_dmics = 0;
  1662. spec->init = stac9200_core_init;
  1663. spec->mixer = stac9200_mixer;
  1664. err = stac9200_parse_auto_config(codec);
  1665. if (err < 0) {
  1666. stac92xx_free(codec);
  1667. return err;
  1668. }
  1669. codec->patch_ops = stac92xx_patch_ops;
  1670. return 0;
  1671. }
  1672. static int patch_stac925x(struct hda_codec *codec)
  1673. {
  1674. struct sigmatel_spec *spec;
  1675. int err;
  1676. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1677. if (spec == NULL)
  1678. return -ENOMEM;
  1679. codec->spec = spec;
  1680. spec->num_pins = 8;
  1681. spec->pin_nids = stac925x_pin_nids;
  1682. spec->board_config = snd_hda_check_board_config(codec, STAC_925x_MODELS,
  1683. stac925x_models,
  1684. stac925x_cfg_tbl);
  1685. again:
  1686. if (spec->board_config < 0) {
  1687. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC925x,"
  1688. "using BIOS defaults\n");
  1689. err = stac92xx_save_bios_config_regs(codec);
  1690. if (err < 0) {
  1691. stac92xx_free(codec);
  1692. return err;
  1693. }
  1694. spec->pin_configs = spec->bios_pin_configs;
  1695. } else if (stac925x_brd_tbl[spec->board_config] != NULL){
  1696. spec->pin_configs = stac925x_brd_tbl[spec->board_config];
  1697. stac92xx_set_config_regs(codec);
  1698. }
  1699. spec->multiout.max_channels = 2;
  1700. spec->multiout.num_dacs = 1;
  1701. spec->multiout.dac_nids = stac925x_dac_nids;
  1702. spec->adc_nids = stac925x_adc_nids;
  1703. spec->mux_nids = stac925x_mux_nids;
  1704. spec->num_muxes = 1;
  1705. switch (codec->vendor_id) {
  1706. case 0x83847632: /* STAC9202 */
  1707. case 0x83847633: /* STAC9202D */
  1708. case 0x83847636: /* STAC9251 */
  1709. case 0x83847637: /* STAC9251D */
  1710. spec->num_dmics = 1;
  1711. spec->dmic_nids = stac925x_dmic_nids;
  1712. break;
  1713. default:
  1714. spec->num_dmics = 0;
  1715. break;
  1716. }
  1717. spec->init = stac925x_core_init;
  1718. spec->mixer = stac925x_mixer;
  1719. err = stac92xx_parse_auto_config(codec, 0x8, 0x7);
  1720. if (!err) {
  1721. if (spec->board_config < 0) {
  1722. printk(KERN_WARNING "hda_codec: No auto-config is "
  1723. "available, default to model=ref\n");
  1724. spec->board_config = STAC_925x_REF;
  1725. goto again;
  1726. }
  1727. err = -EINVAL;
  1728. }
  1729. if (err < 0) {
  1730. stac92xx_free(codec);
  1731. return err;
  1732. }
  1733. codec->patch_ops = stac92xx_patch_ops;
  1734. return 0;
  1735. }
  1736. static int patch_stac922x(struct hda_codec *codec)
  1737. {
  1738. struct sigmatel_spec *spec;
  1739. int err;
  1740. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1741. if (spec == NULL)
  1742. return -ENOMEM;
  1743. codec->spec = spec;
  1744. spec->num_pins = 10;
  1745. spec->pin_nids = stac922x_pin_nids;
  1746. spec->board_config = snd_hda_check_board_config(codec, STAC_922X_MODELS,
  1747. stac922x_models,
  1748. stac922x_cfg_tbl);
  1749. if (spec->board_config == STAC_MACMINI) {
  1750. spec->gpio_mute = 1;
  1751. /* Intel Macs have all same PCI SSID, so we need to check
  1752. * codec SSID to distinguish the exact models
  1753. */
  1754. printk(KERN_INFO "hda_codec: STAC922x, Apple subsys_id=%x\n", codec->subsystem_id);
  1755. switch (codec->subsystem_id) {
  1756. case 0x106b0a00: /* MacBook First generatoin */
  1757. spec->board_config = STAC_MACBOOK;
  1758. break;
  1759. case 0x106b0200: /* MacBook Pro first generation */
  1760. spec->board_config = STAC_MACBOOK_PRO_V1;
  1761. break;
  1762. case 0x106b1e00: /* MacBook Pro second generation */
  1763. spec->board_config = STAC_MACBOOK_PRO_V2;
  1764. break;
  1765. case 0x106b0700: /* Intel-based iMac */
  1766. spec->board_config = STAC_IMAC_INTEL;
  1767. break;
  1768. }
  1769. }
  1770. again:
  1771. if (spec->board_config < 0) {
  1772. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC922x, "
  1773. "using BIOS defaults\n");
  1774. err = stac92xx_save_bios_config_regs(codec);
  1775. if (err < 0) {
  1776. stac92xx_free(codec);
  1777. return err;
  1778. }
  1779. spec->pin_configs = spec->bios_pin_configs;
  1780. } else if (stac922x_brd_tbl[spec->board_config] != NULL) {
  1781. spec->pin_configs = stac922x_brd_tbl[spec->board_config];
  1782. stac92xx_set_config_regs(codec);
  1783. }
  1784. spec->adc_nids = stac922x_adc_nids;
  1785. spec->mux_nids = stac922x_mux_nids;
  1786. spec->num_muxes = ARRAY_SIZE(stac922x_mux_nids);
  1787. spec->num_dmics = 0;
  1788. spec->init = stac922x_core_init;
  1789. spec->mixer = stac922x_mixer;
  1790. spec->multiout.dac_nids = spec->dac_nids;
  1791. err = stac92xx_parse_auto_config(codec, 0x08, 0x09);
  1792. if (!err) {
  1793. if (spec->board_config < 0) {
  1794. printk(KERN_WARNING "hda_codec: No auto-config is "
  1795. "available, default to model=ref\n");
  1796. spec->board_config = STAC_D945_REF;
  1797. goto again;
  1798. }
  1799. err = -EINVAL;
  1800. }
  1801. if (err < 0) {
  1802. stac92xx_free(codec);
  1803. return err;
  1804. }
  1805. codec->patch_ops = stac92xx_patch_ops;
  1806. return 0;
  1807. }
  1808. static int patch_stac927x(struct hda_codec *codec)
  1809. {
  1810. struct sigmatel_spec *spec;
  1811. int err;
  1812. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1813. if (spec == NULL)
  1814. return -ENOMEM;
  1815. codec->spec = spec;
  1816. spec->num_pins = 14;
  1817. spec->pin_nids = stac927x_pin_nids;
  1818. spec->board_config = snd_hda_check_board_config(codec, STAC_927X_MODELS,
  1819. stac927x_models,
  1820. stac927x_cfg_tbl);
  1821. again:
  1822. if (spec->board_config < 0) {
  1823. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC927x, using BIOS defaults\n");
  1824. err = stac92xx_save_bios_config_regs(codec);
  1825. if (err < 0) {
  1826. stac92xx_free(codec);
  1827. return err;
  1828. }
  1829. spec->pin_configs = spec->bios_pin_configs;
  1830. } else if (stac927x_brd_tbl[spec->board_config] != NULL) {
  1831. spec->pin_configs = stac927x_brd_tbl[spec->board_config];
  1832. stac92xx_set_config_regs(codec);
  1833. }
  1834. switch (spec->board_config) {
  1835. case STAC_D965_3ST:
  1836. spec->adc_nids = stac927x_adc_nids;
  1837. spec->mux_nids = stac927x_mux_nids;
  1838. spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
  1839. spec->num_dmics = 0;
  1840. spec->init = d965_core_init;
  1841. spec->mixer = stac9227_mixer;
  1842. break;
  1843. case STAC_D965_5ST:
  1844. spec->adc_nids = stac927x_adc_nids;
  1845. spec->mux_nids = stac927x_mux_nids;
  1846. spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
  1847. spec->num_dmics = 0;
  1848. spec->init = d965_core_init;
  1849. spec->mixer = stac9227_mixer;
  1850. break;
  1851. default:
  1852. spec->adc_nids = stac927x_adc_nids;
  1853. spec->mux_nids = stac927x_mux_nids;
  1854. spec->num_muxes = ARRAY_SIZE(stac927x_mux_nids);
  1855. spec->num_dmics = 0;
  1856. spec->init = stac927x_core_init;
  1857. spec->mixer = stac927x_mixer;
  1858. }
  1859. spec->multiout.dac_nids = spec->dac_nids;
  1860. err = stac92xx_parse_auto_config(codec, 0x1e, 0x20);
  1861. if (!err) {
  1862. if (spec->board_config < 0) {
  1863. printk(KERN_WARNING "hda_codec: No auto-config is "
  1864. "available, default to model=ref\n");
  1865. spec->board_config = STAC_D965_REF;
  1866. goto again;
  1867. }
  1868. err = -EINVAL;
  1869. }
  1870. if (err < 0) {
  1871. stac92xx_free(codec);
  1872. return err;
  1873. }
  1874. codec->patch_ops = stac92xx_patch_ops;
  1875. /* Fix Mux capture level; max to 2 */
  1876. snd_hda_override_amp_caps(codec, 0x12, HDA_OUTPUT,
  1877. (0 << AC_AMPCAP_OFFSET_SHIFT) |
  1878. (2 << AC_AMPCAP_NUM_STEPS_SHIFT) |
  1879. (0x27 << AC_AMPCAP_STEP_SIZE_SHIFT) |
  1880. (0 << AC_AMPCAP_MUTE_SHIFT));
  1881. return 0;
  1882. }
  1883. static int patch_stac9205(struct hda_codec *codec)
  1884. {
  1885. struct sigmatel_spec *spec;
  1886. int err;
  1887. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1888. if (spec == NULL)
  1889. return -ENOMEM;
  1890. codec->spec = spec;
  1891. spec->num_pins = 14;
  1892. spec->pin_nids = stac9205_pin_nids;
  1893. spec->board_config = snd_hda_check_board_config(codec, STAC_9205_MODELS,
  1894. stac9205_models,
  1895. stac9205_cfg_tbl);
  1896. again:
  1897. if (spec->board_config < 0) {
  1898. snd_printdd(KERN_INFO "hda_codec: Unknown model for STAC9205, using BIOS defaults\n");
  1899. err = stac92xx_save_bios_config_regs(codec);
  1900. if (err < 0) {
  1901. stac92xx_free(codec);
  1902. return err;
  1903. }
  1904. spec->pin_configs = spec->bios_pin_configs;
  1905. } else {
  1906. spec->pin_configs = stac9205_brd_tbl[spec->board_config];
  1907. stac92xx_set_config_regs(codec);
  1908. }
  1909. spec->adc_nids = stac9205_adc_nids;
  1910. spec->mux_nids = stac9205_mux_nids;
  1911. spec->num_muxes = ARRAY_SIZE(stac9205_mux_nids);
  1912. spec->dmic_nids = stac9205_dmic_nids;
  1913. spec->num_dmics = ARRAY_SIZE(stac9205_dmic_nids);
  1914. spec->dmux_nid = 0x1d;
  1915. spec->init = stac9205_core_init;
  1916. spec->mixer = stac9205_mixer;
  1917. spec->multiout.dac_nids = spec->dac_nids;
  1918. /* Configure GPIO0 as EAPD output */
  1919. snd_hda_codec_write(codec, codec->afg, 0,
  1920. AC_VERB_SET_GPIO_DIRECTION, 0x00000001);
  1921. /* Configure GPIO0 as CMOS */
  1922. snd_hda_codec_write(codec, codec->afg, 0, 0x7e7, 0x00000000);
  1923. /* Assert GPIO0 high */
  1924. snd_hda_codec_write(codec, codec->afg, 0,
  1925. AC_VERB_SET_GPIO_DATA, 0x00000001);
  1926. /* Enable GPIO0 */
  1927. snd_hda_codec_write(codec, codec->afg, 0,
  1928. AC_VERB_SET_GPIO_MASK, 0x00000001);
  1929. err = stac92xx_parse_auto_config(codec, 0x1f, 0x20);
  1930. if (!err) {
  1931. if (spec->board_config < 0) {
  1932. printk(KERN_WARNING "hda_codec: No auto-config is "
  1933. "available, default to model=ref\n");
  1934. spec->board_config = STAC_9205_REF;
  1935. goto again;
  1936. }
  1937. err = -EINVAL;
  1938. }
  1939. if (err < 0) {
  1940. stac92xx_free(codec);
  1941. return err;
  1942. }
  1943. codec->patch_ops = stac92xx_patch_ops;
  1944. return 0;
  1945. }
  1946. /*
  1947. * STAC9872 hack
  1948. */
  1949. /* static config for Sony VAIO FE550G and Sony VAIO AR */
  1950. static hda_nid_t vaio_dacs[] = { 0x2 };
  1951. #define VAIO_HP_DAC 0x5
  1952. static hda_nid_t vaio_adcs[] = { 0x8 /*,0x6*/ };
  1953. static hda_nid_t vaio_mux_nids[] = { 0x15 };
  1954. static struct hda_input_mux vaio_mux = {
  1955. .num_items = 2,
  1956. .items = {
  1957. /* { "HP", 0x0 }, */
  1958. { "Line", 0x1 },
  1959. { "Mic", 0x2 },
  1960. { "PCM", 0x3 },
  1961. }
  1962. };
  1963. static struct hda_verb vaio_init[] = {
  1964. {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
  1965. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
  1966. {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
  1967. {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
  1968. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
  1969. {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
  1970. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
  1971. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
  1972. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
  1973. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
  1974. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
  1975. {}
  1976. };
  1977. static struct hda_verb vaio_ar_init[] = {
  1978. {0x0a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP <- 0x2 */
  1979. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Speaker <- 0x5 */
  1980. {0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? (<- 0x2) */
  1981. {0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD */
  1982. /* {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },*/ /* Optical Out */
  1983. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Mic? */
  1984. {0x15, AC_VERB_SET_CONNECT_SEL, 0x2}, /* mic-sel: 0a,0d,14,02 */
  1985. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* HP */
  1986. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE}, /* Speaker */
  1987. /* {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},*/ /* Optical Out */
  1988. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* capture sw/vol -> 0x8 */
  1989. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)}, /* CD-in -> 0x6 */
  1990. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, /* Mic-in -> 0x9 */
  1991. {}
  1992. };
  1993. /* bind volumes of both NID 0x02 and 0x05 */
  1994. static int vaio_master_vol_put(struct snd_kcontrol *kcontrol,
  1995. struct snd_ctl_elem_value *ucontrol)
  1996. {
  1997. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1998. long *valp = ucontrol->value.integer.value;
  1999. int change;
  2000. change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
  2001. 0x7f, valp[0] & 0x7f);
  2002. change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
  2003. 0x7f, valp[1] & 0x7f);
  2004. snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
  2005. 0x7f, valp[0] & 0x7f);
  2006. snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
  2007. 0x7f, valp[1] & 0x7f);
  2008. return change;
  2009. }
  2010. /* bind volumes of both NID 0x02 and 0x05 */
  2011. static int vaio_master_sw_put(struct snd_kcontrol *kcontrol,
  2012. struct snd_ctl_elem_value *ucontrol)
  2013. {
  2014. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2015. long *valp = ucontrol->value.integer.value;
  2016. int change;
  2017. change = snd_hda_codec_amp_update(codec, 0x02, 0, HDA_OUTPUT, 0,
  2018. 0x80, (valp[0] ? 0 : 0x80));
  2019. change |= snd_hda_codec_amp_update(codec, 0x02, 1, HDA_OUTPUT, 0,
  2020. 0x80, (valp[1] ? 0 : 0x80));
  2021. snd_hda_codec_amp_update(codec, 0x05, 0, HDA_OUTPUT, 0,
  2022. 0x80, (valp[0] ? 0 : 0x80));
  2023. snd_hda_codec_amp_update(codec, 0x05, 1, HDA_OUTPUT, 0,
  2024. 0x80, (valp[1] ? 0 : 0x80));
  2025. return change;
  2026. }
  2027. static struct snd_kcontrol_new vaio_mixer[] = {
  2028. {
  2029. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2030. .name = "Master Playback Volume",
  2031. .info = snd_hda_mixer_amp_volume_info,
  2032. .get = snd_hda_mixer_amp_volume_get,
  2033. .put = vaio_master_vol_put,
  2034. .tlv = { .c = snd_hda_mixer_amp_tlv },
  2035. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  2036. },
  2037. {
  2038. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2039. .name = "Master Playback Switch",
  2040. .info = snd_hda_mixer_amp_switch_info,
  2041. .get = snd_hda_mixer_amp_switch_get,
  2042. .put = vaio_master_sw_put,
  2043. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  2044. },
  2045. /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
  2046. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
  2047. HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
  2048. {
  2049. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2050. .name = "Capture Source",
  2051. .count = 1,
  2052. .info = stac92xx_mux_enum_info,
  2053. .get = stac92xx_mux_enum_get,
  2054. .put = stac92xx_mux_enum_put,
  2055. },
  2056. {}
  2057. };
  2058. static struct snd_kcontrol_new vaio_ar_mixer[] = {
  2059. {
  2060. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2061. .name = "Master Playback Volume",
  2062. .info = snd_hda_mixer_amp_volume_info,
  2063. .get = snd_hda_mixer_amp_volume_get,
  2064. .put = vaio_master_vol_put,
  2065. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  2066. },
  2067. {
  2068. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2069. .name = "Master Playback Switch",
  2070. .info = snd_hda_mixer_amp_switch_info,
  2071. .get = snd_hda_mixer_amp_switch_get,
  2072. .put = vaio_master_sw_put,
  2073. .private_value = HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  2074. },
  2075. /* HDA_CODEC_VOLUME("CD Capture Volume", 0x07, 0, HDA_INPUT), */
  2076. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0, HDA_INPUT),
  2077. HDA_CODEC_MUTE("Capture Switch", 0x09, 0, HDA_INPUT),
  2078. /*HDA_CODEC_MUTE("Optical Out Switch", 0x10, 0, HDA_OUTPUT),
  2079. HDA_CODEC_VOLUME("Optical Out Volume", 0x10, 0, HDA_OUTPUT),*/
  2080. {
  2081. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2082. .name = "Capture Source",
  2083. .count = 1,
  2084. .info = stac92xx_mux_enum_info,
  2085. .get = stac92xx_mux_enum_get,
  2086. .put = stac92xx_mux_enum_put,
  2087. },
  2088. {}
  2089. };
  2090. static struct hda_codec_ops stac9872_patch_ops = {
  2091. .build_controls = stac92xx_build_controls,
  2092. .build_pcms = stac92xx_build_pcms,
  2093. .init = stac92xx_init,
  2094. .free = stac92xx_free,
  2095. #ifdef CONFIG_PM
  2096. .resume = stac92xx_resume,
  2097. #endif
  2098. };
  2099. enum { /* FE and SZ series. id=0x83847661 and subsys=0x104D0700 or 104D1000. */
  2100. CXD9872RD_VAIO,
  2101. /* Unknown. id=0x83847662 and subsys=0x104D1200 or 104D1000. */
  2102. STAC9872AK_VAIO,
  2103. /* Unknown. id=0x83847661 and subsys=0x104D1200. */
  2104. STAC9872K_VAIO,
  2105. /* AR Series. id=0x83847664 and subsys=104D1300 */
  2106. CXD9872AKD_VAIO,
  2107. STAC_9872_MODELS,
  2108. };
  2109. static const char *stac9872_models[STAC_9872_MODELS] = {
  2110. [CXD9872RD_VAIO] = "vaio",
  2111. [CXD9872AKD_VAIO] = "vaio-ar",
  2112. };
  2113. static struct snd_pci_quirk stac9872_cfg_tbl[] = {
  2114. SND_PCI_QUIRK(0x104d, 0x81e6, "Sony VAIO F/S", CXD9872RD_VAIO),
  2115. SND_PCI_QUIRK(0x104d, 0x81ef, "Sony VAIO F/S", CXD9872RD_VAIO),
  2116. SND_PCI_QUIRK(0x104d, 0x81fd, "Sony VAIO AR", CXD9872AKD_VAIO),
  2117. SND_PCI_QUIRK(0x104d, 0x8205, "Sony VAIO AR", CXD9872AKD_VAIO),
  2118. {}
  2119. };
  2120. static int patch_stac9872(struct hda_codec *codec)
  2121. {
  2122. struct sigmatel_spec *spec;
  2123. int board_config;
  2124. board_config = snd_hda_check_board_config(codec, STAC_9872_MODELS,
  2125. stac9872_models,
  2126. stac9872_cfg_tbl);
  2127. if (board_config < 0)
  2128. /* unknown config, let generic-parser do its job... */
  2129. return snd_hda_parse_generic_codec(codec);
  2130. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2131. if (spec == NULL)
  2132. return -ENOMEM;
  2133. codec->spec = spec;
  2134. switch (board_config) {
  2135. case CXD9872RD_VAIO:
  2136. case STAC9872AK_VAIO:
  2137. case STAC9872K_VAIO:
  2138. spec->mixer = vaio_mixer;
  2139. spec->init = vaio_init;
  2140. spec->multiout.max_channels = 2;
  2141. spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
  2142. spec->multiout.dac_nids = vaio_dacs;
  2143. spec->multiout.hp_nid = VAIO_HP_DAC;
  2144. spec->num_adcs = ARRAY_SIZE(vaio_adcs);
  2145. spec->adc_nids = vaio_adcs;
  2146. spec->input_mux = &vaio_mux;
  2147. spec->mux_nids = vaio_mux_nids;
  2148. break;
  2149. case CXD9872AKD_VAIO:
  2150. spec->mixer = vaio_ar_mixer;
  2151. spec->init = vaio_ar_init;
  2152. spec->multiout.max_channels = 2;
  2153. spec->multiout.num_dacs = ARRAY_SIZE(vaio_dacs);
  2154. spec->multiout.dac_nids = vaio_dacs;
  2155. spec->multiout.hp_nid = VAIO_HP_DAC;
  2156. spec->num_adcs = ARRAY_SIZE(vaio_adcs);
  2157. spec->adc_nids = vaio_adcs;
  2158. spec->input_mux = &vaio_mux;
  2159. spec->mux_nids = vaio_mux_nids;
  2160. break;
  2161. }
  2162. codec->patch_ops = stac9872_patch_ops;
  2163. return 0;
  2164. }
  2165. /*
  2166. * patch entries
  2167. */
  2168. struct hda_codec_preset snd_hda_preset_sigmatel[] = {
  2169. { .id = 0x83847690, .name = "STAC9200", .patch = patch_stac9200 },
  2170. { .id = 0x83847882, .name = "STAC9220 A1", .patch = patch_stac922x },
  2171. { .id = 0x83847680, .name = "STAC9221 A1", .patch = patch_stac922x },
  2172. { .id = 0x83847880, .name = "STAC9220 A2", .patch = patch_stac922x },
  2173. { .id = 0x83847681, .name = "STAC9220D/9223D A2", .patch = patch_stac922x },
  2174. { .id = 0x83847682, .name = "STAC9221 A2", .patch = patch_stac922x },
  2175. { .id = 0x83847683, .name = "STAC9221D A2", .patch = patch_stac922x },
  2176. { .id = 0x83847618, .name = "STAC9227", .patch = patch_stac927x },
  2177. { .id = 0x83847619, .name = "STAC9227", .patch = patch_stac927x },
  2178. { .id = 0x83847616, .name = "STAC9228", .patch = patch_stac927x },
  2179. { .id = 0x83847617, .name = "STAC9228", .patch = patch_stac927x },
  2180. { .id = 0x83847614, .name = "STAC9229", .patch = patch_stac927x },
  2181. { .id = 0x83847615, .name = "STAC9229", .patch = patch_stac927x },
  2182. { .id = 0x83847620, .name = "STAC9274", .patch = patch_stac927x },
  2183. { .id = 0x83847621, .name = "STAC9274D", .patch = patch_stac927x },
  2184. { .id = 0x83847622, .name = "STAC9273X", .patch = patch_stac927x },
  2185. { .id = 0x83847623, .name = "STAC9273D", .patch = patch_stac927x },
  2186. { .id = 0x83847624, .name = "STAC9272X", .patch = patch_stac927x },
  2187. { .id = 0x83847625, .name = "STAC9272D", .patch = patch_stac927x },
  2188. { .id = 0x83847626, .name = "STAC9271X", .patch = patch_stac927x },
  2189. { .id = 0x83847627, .name = "STAC9271D", .patch = patch_stac927x },
  2190. { .id = 0x83847628, .name = "STAC9274X5NH", .patch = patch_stac927x },
  2191. { .id = 0x83847629, .name = "STAC9274D5NH", .patch = patch_stac927x },
  2192. { .id = 0x83847632, .name = "STAC9202", .patch = patch_stac925x },
  2193. { .id = 0x83847633, .name = "STAC9202D", .patch = patch_stac925x },
  2194. { .id = 0x83847634, .name = "STAC9250", .patch = patch_stac925x },
  2195. { .id = 0x83847635, .name = "STAC9250D", .patch = patch_stac925x },
  2196. { .id = 0x83847636, .name = "STAC9251", .patch = patch_stac925x },
  2197. { .id = 0x83847637, .name = "STAC9250D", .patch = patch_stac925x },
  2198. /* The following does not take into account .id=0x83847661 when subsys =
  2199. * 104D0C00 which is STAC9225s. Because of this, some SZ Notebooks are
  2200. * currently not fully supported.
  2201. */
  2202. { .id = 0x83847661, .name = "CXD9872RD/K", .patch = patch_stac9872 },
  2203. { .id = 0x83847662, .name = "STAC9872AK", .patch = patch_stac9872 },
  2204. { .id = 0x83847664, .name = "CXD9872AKD", .patch = patch_stac9872 },
  2205. { .id = 0x838476a0, .name = "STAC9205", .patch = patch_stac9205 },
  2206. { .id = 0x838476a1, .name = "STAC9205D", .patch = patch_stac9205 },
  2207. { .id = 0x838476a2, .name = "STAC9204", .patch = patch_stac9205 },
  2208. { .id = 0x838476a3, .name = "STAC9204D", .patch = patch_stac9205 },
  2209. { .id = 0x838476a4, .name = "STAC9255", .patch = patch_stac9205 },
  2210. { .id = 0x838476a5, .name = "STAC9255D", .patch = patch_stac9205 },
  2211. { .id = 0x838476a6, .name = "STAC9254", .patch = patch_stac9205 },
  2212. { .id = 0x838476a7, .name = "STAC9254D", .patch = patch_stac9205 },
  2213. {} /* terminator */
  2214. };