patch_sigmatel.c 85 KB

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