patch_sigmatel.c 84 KB

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