patch_sigmatel.c 84 KB

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