patch_realtek.c 158 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. *
  10. * This driver is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version.
  14. *
  15. * This driver is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. #include <sound/driver.h>
  25. #include <linux/init.h>
  26. #include <linux/delay.h>
  27. #include <linux/slab.h>
  28. #include <linux/pci.h>
  29. #include <sound/core.h>
  30. #include "hda_codec.h"
  31. #include "hda_local.h"
  32. /* ALC880 board config type */
  33. enum {
  34. ALC880_3ST,
  35. ALC880_3ST_DIG,
  36. ALC880_5ST,
  37. ALC880_5ST_DIG,
  38. ALC880_W810,
  39. ALC880_Z71V,
  40. ALC880_6ST,
  41. ALC880_6ST_DIG,
  42. ALC880_F1734,
  43. ALC880_ASUS,
  44. ALC880_ASUS_DIG,
  45. ALC880_ASUS_W1V,
  46. ALC880_ASUS_DIG2,
  47. ALC880_UNIWILL_DIG,
  48. ALC880_CLEVO,
  49. ALC880_TCL_S700,
  50. #ifdef CONFIG_SND_DEBUG
  51. ALC880_TEST,
  52. #endif
  53. ALC880_AUTO,
  54. ALC880_MODEL_LAST /* last tag */
  55. };
  56. /* ALC260 models */
  57. enum {
  58. ALC260_BASIC,
  59. ALC260_HP,
  60. ALC260_HP_3013,
  61. ALC260_FUJITSU_S702X,
  62. ALC260_AUTO,
  63. ALC260_MODEL_LAST /* last tag */
  64. };
  65. /* ALC262 models */
  66. enum {
  67. ALC262_BASIC,
  68. ALC262_AUTO,
  69. ALC262_MODEL_LAST /* last tag */
  70. };
  71. /* ALC861 models */
  72. enum {
  73. ALC861_3ST,
  74. ALC861_3ST_DIG,
  75. ALC861_6ST_DIG,
  76. ALC861_AUTO,
  77. ALC861_MODEL_LAST,
  78. };
  79. /* ALC882 models */
  80. enum {
  81. ALC882_3ST_DIG,
  82. ALC882_6ST_DIG,
  83. ALC882_AUTO,
  84. ALC882_MODEL_LAST,
  85. };
  86. /* for GPIO Poll */
  87. #define GPIO_MASK 0x03
  88. struct alc_spec {
  89. /* codec parameterization */
  90. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  91. unsigned int num_mixers;
  92. const struct hda_verb *init_verbs[5]; /* initialization verbs
  93. * don't forget NULL termination!
  94. */
  95. unsigned int num_init_verbs;
  96. char *stream_name_analog; /* analog PCM stream */
  97. struct hda_pcm_stream *stream_analog_playback;
  98. struct hda_pcm_stream *stream_analog_capture;
  99. char *stream_name_digital; /* digital PCM stream */
  100. struct hda_pcm_stream *stream_digital_playback;
  101. struct hda_pcm_stream *stream_digital_capture;
  102. /* playback */
  103. struct hda_multi_out multiout; /* playback set-up
  104. * max_channels, dacs must be set
  105. * dig_out_nid and hp_nid are optional
  106. */
  107. /* capture */
  108. unsigned int num_adc_nids;
  109. hda_nid_t *adc_nids;
  110. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  111. /* capture source */
  112. const struct hda_input_mux *input_mux;
  113. unsigned int cur_mux[3];
  114. /* channel model */
  115. const struct hda_channel_mode *channel_mode;
  116. int num_channel_mode;
  117. /* PCM information */
  118. struct hda_pcm pcm_rec[2]; /* used in alc_build_pcms() */
  119. /* dynamic controls, init_verbs and input_mux */
  120. struct auto_pin_cfg autocfg;
  121. unsigned int num_kctl_alloc, num_kctl_used;
  122. struct snd_kcontrol_new *kctl_alloc;
  123. struct hda_input_mux private_imux;
  124. hda_nid_t private_dac_nids[5];
  125. };
  126. /*
  127. * configuration template - to be copied to the spec instance
  128. */
  129. struct alc_config_preset {
  130. struct snd_kcontrol_new *mixers[5]; /* should be identical size with spec */
  131. const struct hda_verb *init_verbs[5];
  132. unsigned int num_dacs;
  133. hda_nid_t *dac_nids;
  134. hda_nid_t dig_out_nid; /* optional */
  135. hda_nid_t hp_nid; /* optional */
  136. unsigned int num_adc_nids;
  137. hda_nid_t *adc_nids;
  138. hda_nid_t dig_in_nid;
  139. unsigned int num_channel_mode;
  140. const struct hda_channel_mode *channel_mode;
  141. const struct hda_input_mux *input_mux;
  142. };
  143. /*
  144. * input MUX handling
  145. */
  146. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  147. {
  148. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  149. struct alc_spec *spec = codec->spec;
  150. return snd_hda_input_mux_info(spec->input_mux, uinfo);
  151. }
  152. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  153. {
  154. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  155. struct alc_spec *spec = codec->spec;
  156. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  157. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  158. return 0;
  159. }
  160. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  161. {
  162. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  163. struct alc_spec *spec = codec->spec;
  164. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  165. return snd_hda_input_mux_put(codec, spec->input_mux, ucontrol,
  166. spec->adc_nids[adc_idx], &spec->cur_mux[adc_idx]);
  167. }
  168. /*
  169. * channel mode setting
  170. */
  171. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  172. {
  173. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  174. struct alc_spec *spec = codec->spec;
  175. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  176. spec->num_channel_mode);
  177. }
  178. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  179. {
  180. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  181. struct alc_spec *spec = codec->spec;
  182. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  183. spec->num_channel_mode, spec->multiout.max_channels);
  184. }
  185. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  186. {
  187. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  188. struct alc_spec *spec = codec->spec;
  189. return snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  190. spec->num_channel_mode, &spec->multiout.max_channels);
  191. }
  192. /*
  193. * Control of pin widget settings via the mixer. Only boolean settings are
  194. * supported, so VrefEn can't be controlled using these functions as they
  195. * stand.
  196. */
  197. static int alc_pinctl_switch_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  198. {
  199. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  200. uinfo->count = 1;
  201. uinfo->value.integer.min = 0;
  202. uinfo->value.integer.max = 1;
  203. return 0;
  204. }
  205. static int alc_pinctl_switch_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  206. {
  207. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  208. hda_nid_t nid = kcontrol->private_value & 0xffff;
  209. long mask = (kcontrol->private_value >> 16) & 0xff;
  210. long *valp = ucontrol->value.integer.value;
  211. *valp = 0;
  212. if (snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00) & mask)
  213. *valp = 1;
  214. return 0;
  215. }
  216. static int alc_pinctl_switch_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  217. {
  218. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  219. hda_nid_t nid = kcontrol->private_value & 0xffff;
  220. long mask = (kcontrol->private_value >> 16) & 0xff;
  221. long *valp = ucontrol->value.integer.value;
  222. unsigned int pinctl = snd_hda_codec_read(codec,nid,0,AC_VERB_GET_PIN_WIDGET_CONTROL,0x00);
  223. int change = ((pinctl & mask)!=0) != *valp;
  224. if (change)
  225. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  226. *valp?(pinctl|mask):(pinctl&~mask));
  227. return change;
  228. }
  229. #define ALC_PINCTL_SWITCH(xname, nid, mask) \
  230. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  231. .info = alc_pinctl_switch_info, \
  232. .get = alc_pinctl_switch_get, \
  233. .put = alc_pinctl_switch_put, \
  234. .private_value = (nid) | (mask<<16) }
  235. /*
  236. * set up from the preset table
  237. */
  238. static void setup_preset(struct alc_spec *spec, const struct alc_config_preset *preset)
  239. {
  240. int i;
  241. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  242. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  243. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i]; i++)
  244. spec->init_verbs[spec->num_init_verbs++] = preset->init_verbs[i];
  245. spec->channel_mode = preset->channel_mode;
  246. spec->num_channel_mode = preset->num_channel_mode;
  247. spec->multiout.max_channels = spec->channel_mode[0].channels;
  248. spec->multiout.num_dacs = preset->num_dacs;
  249. spec->multiout.dac_nids = preset->dac_nids;
  250. spec->multiout.dig_out_nid = preset->dig_out_nid;
  251. spec->multiout.hp_nid = preset->hp_nid;
  252. spec->input_mux = preset->input_mux;
  253. spec->num_adc_nids = preset->num_adc_nids;
  254. spec->adc_nids = preset->adc_nids;
  255. spec->dig_in_nid = preset->dig_in_nid;
  256. }
  257. /*
  258. * ALC880 3-stack model
  259. *
  260. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  261. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18, F-Mic = 0x1b
  262. * HP = 0x19
  263. */
  264. static hda_nid_t alc880_dac_nids[4] = {
  265. /* front, rear, clfe, rear_surr */
  266. 0x02, 0x05, 0x04, 0x03
  267. };
  268. static hda_nid_t alc880_adc_nids[3] = {
  269. /* ADC0-2 */
  270. 0x07, 0x08, 0x09,
  271. };
  272. /* The datasheet says the node 0x07 is connected from inputs,
  273. * but it shows zero connection in the real implementation on some devices.
  274. * Note: this is a 915GAV bug, fixed on 915GLV
  275. */
  276. static hda_nid_t alc880_adc_nids_alt[2] = {
  277. /* ADC1-2 */
  278. 0x08, 0x09,
  279. };
  280. #define ALC880_DIGOUT_NID 0x06
  281. #define ALC880_DIGIN_NID 0x0a
  282. static struct hda_input_mux alc880_capture_source = {
  283. .num_items = 4,
  284. .items = {
  285. { "Mic", 0x0 },
  286. { "Front Mic", 0x3 },
  287. { "Line", 0x2 },
  288. { "CD", 0x4 },
  289. },
  290. };
  291. /* channel source setting (2/6 channel selection for 3-stack) */
  292. /* 2ch mode */
  293. static struct hda_verb alc880_threestack_ch2_init[] = {
  294. /* set line-in to input, mute it */
  295. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  296. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  297. /* set mic-in to input vref 80%, mute it */
  298. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  299. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  300. { } /* end */
  301. };
  302. /* 6ch mode */
  303. static struct hda_verb alc880_threestack_ch6_init[] = {
  304. /* set line-in to output, unmute it */
  305. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  306. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  307. /* set mic-in to output, unmute it */
  308. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  309. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  310. { } /* end */
  311. };
  312. static struct hda_channel_mode alc880_threestack_modes[2] = {
  313. { 2, alc880_threestack_ch2_init },
  314. { 6, alc880_threestack_ch6_init },
  315. };
  316. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  317. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  318. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  319. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  320. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  321. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  322. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  323. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  324. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  325. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  326. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  327. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  328. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  329. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  330. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  331. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  332. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  333. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  334. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  335. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  336. {
  337. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  338. .name = "Channel Mode",
  339. .info = alc_ch_mode_info,
  340. .get = alc_ch_mode_get,
  341. .put = alc_ch_mode_put,
  342. },
  343. { } /* end */
  344. };
  345. /* capture mixer elements */
  346. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  347. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  348. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  349. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  350. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  351. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  352. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  353. {
  354. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  355. /* The multiple "Capture Source" controls confuse alsamixer
  356. * So call somewhat different..
  357. * FIXME: the controls appear in the "playback" view!
  358. */
  359. /* .name = "Capture Source", */
  360. .name = "Input Source",
  361. .count = 3,
  362. .info = alc_mux_enum_info,
  363. .get = alc_mux_enum_get,
  364. .put = alc_mux_enum_put,
  365. },
  366. { } /* end */
  367. };
  368. /* capture mixer elements (in case NID 0x07 not available) */
  369. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  370. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  371. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  372. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  373. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  374. {
  375. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  376. /* The multiple "Capture Source" controls confuse alsamixer
  377. * So call somewhat different..
  378. * FIXME: the controls appear in the "playback" view!
  379. */
  380. /* .name = "Capture Source", */
  381. .name = "Input Source",
  382. .count = 2,
  383. .info = alc_mux_enum_info,
  384. .get = alc_mux_enum_get,
  385. .put = alc_mux_enum_put,
  386. },
  387. { } /* end */
  388. };
  389. /*
  390. * ALC880 5-stack model
  391. *
  392. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d), Side = 0x02 (0xd)
  393. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  394. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  395. */
  396. /* additional mixers to alc880_three_stack_mixer */
  397. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  398. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  399. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  400. { } /* end */
  401. };
  402. /* channel source setting (6/8 channel selection for 5-stack) */
  403. /* 6ch mode */
  404. static struct hda_verb alc880_fivestack_ch6_init[] = {
  405. /* set line-in to input, mute it */
  406. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  407. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  408. { } /* end */
  409. };
  410. /* 8ch mode */
  411. static struct hda_verb alc880_fivestack_ch8_init[] = {
  412. /* set line-in to output, unmute it */
  413. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  414. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  415. { } /* end */
  416. };
  417. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  418. { 6, alc880_fivestack_ch6_init },
  419. { 8, alc880_fivestack_ch8_init },
  420. };
  421. /*
  422. * ALC880 6-stack model
  423. *
  424. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e), Side = 0x05 (0x0f)
  425. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  426. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  427. */
  428. static hda_nid_t alc880_6st_dac_nids[4] = {
  429. /* front, rear, clfe, rear_surr */
  430. 0x02, 0x03, 0x04, 0x05
  431. };
  432. static struct hda_input_mux alc880_6stack_capture_source = {
  433. .num_items = 4,
  434. .items = {
  435. { "Mic", 0x0 },
  436. { "Front Mic", 0x1 },
  437. { "Line", 0x2 },
  438. { "CD", 0x4 },
  439. },
  440. };
  441. /* fixed 8-channels */
  442. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  443. { 8, NULL },
  444. };
  445. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  446. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  447. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  448. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  449. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  450. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  451. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  452. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  453. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  454. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  455. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  456. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  457. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  458. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  459. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  460. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  461. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  462. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  463. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  464. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  465. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  466. {
  467. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  468. .name = "Channel Mode",
  469. .info = alc_ch_mode_info,
  470. .get = alc_ch_mode_get,
  471. .put = alc_ch_mode_put,
  472. },
  473. { } /* end */
  474. };
  475. /*
  476. * ALC880 W810 model
  477. *
  478. * W810 has rear IO for:
  479. * Front (DAC 02)
  480. * Surround (DAC 03)
  481. * Center/LFE (DAC 04)
  482. * Digital out (06)
  483. *
  484. * The system also has a pair of internal speakers, and a headphone jack.
  485. * These are both connected to Line2 on the codec, hence to DAC 02.
  486. *
  487. * There is a variable resistor to control the speaker or headphone
  488. * volume. This is a hardware-only device without a software API.
  489. *
  490. * Plugging headphones in will disable the internal speakers. This is
  491. * implemented in hardware, not via the driver using jack sense. In
  492. * a similar fashion, plugging into the rear socket marked "front" will
  493. * disable both the speakers and headphones.
  494. *
  495. * For input, there's a microphone jack, and an "audio in" jack.
  496. * These may not do anything useful with this driver yet, because I
  497. * haven't setup any initialization verbs for these yet...
  498. */
  499. static hda_nid_t alc880_w810_dac_nids[3] = {
  500. /* front, rear/surround, clfe */
  501. 0x02, 0x03, 0x04
  502. };
  503. /* fixed 6 channels */
  504. static struct hda_channel_mode alc880_w810_modes[1] = {
  505. { 6, NULL }
  506. };
  507. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  508. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  509. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  510. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  511. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  512. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  513. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  514. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  515. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  516. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  517. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  518. { } /* end */
  519. };
  520. /*
  521. * Z710V model
  522. *
  523. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  524. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?), Line = 0x1a
  525. */
  526. static hda_nid_t alc880_z71v_dac_nids[1] = {
  527. 0x02
  528. };
  529. #define ALC880_Z71V_HP_DAC 0x03
  530. /* fixed 2 channels */
  531. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  532. { 2, NULL }
  533. };
  534. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  535. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  536. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  537. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  538. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  539. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  540. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  541. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  542. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  543. { } /* end */
  544. };
  545. /* FIXME! */
  546. /*
  547. * ALC880 F1734 model
  548. *
  549. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  550. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  551. */
  552. static hda_nid_t alc880_f1734_dac_nids[1] = {
  553. 0x03
  554. };
  555. #define ALC880_F1734_HP_DAC 0x02
  556. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  557. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  558. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  559. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  560. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  561. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  562. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  563. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  564. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  565. { } /* end */
  566. };
  567. /* FIXME! */
  568. /*
  569. * ALC880 ASUS model
  570. *
  571. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  572. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  573. * Mic = 0x18, Line = 0x1a
  574. */
  575. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  576. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  577. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  578. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  579. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  580. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  581. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  582. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  583. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  584. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  585. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  586. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  587. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  588. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  589. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  590. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  591. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  592. {
  593. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  594. .name = "Channel Mode",
  595. .info = alc_ch_mode_info,
  596. .get = alc_ch_mode_get,
  597. .put = alc_ch_mode_put,
  598. },
  599. { } /* end */
  600. };
  601. /* FIXME! */
  602. /*
  603. * ALC880 ASUS W1V model
  604. *
  605. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  606. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  607. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  608. */
  609. /* additional mixers to alc880_asus_mixer */
  610. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  611. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  612. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  613. { } /* end */
  614. };
  615. /* additional mixers to alc880_asus_mixer */
  616. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  617. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  618. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  619. { } /* end */
  620. };
  621. /* TCL S700 */
  622. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  623. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  624. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  625. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  626. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  627. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  628. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  629. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  630. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  631. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  632. {
  633. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  634. /* The multiple "Capture Source" controls confuse alsamixer
  635. * So call somewhat different..
  636. * FIXME: the controls appear in the "playback" view!
  637. */
  638. /* .name = "Capture Source", */
  639. .name = "Input Source",
  640. .count = 1,
  641. .info = alc_mux_enum_info,
  642. .get = alc_mux_enum_get,
  643. .put = alc_mux_enum_put,
  644. },
  645. { } /* end */
  646. };
  647. /*
  648. * build control elements
  649. */
  650. static int alc_build_controls(struct hda_codec *codec)
  651. {
  652. struct alc_spec *spec = codec->spec;
  653. int err;
  654. int i;
  655. for (i = 0; i < spec->num_mixers; i++) {
  656. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  657. if (err < 0)
  658. return err;
  659. }
  660. if (spec->multiout.dig_out_nid) {
  661. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  662. if (err < 0)
  663. return err;
  664. }
  665. if (spec->dig_in_nid) {
  666. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  667. if (err < 0)
  668. return err;
  669. }
  670. return 0;
  671. }
  672. /*
  673. * initialize the codec volumes, etc
  674. */
  675. /*
  676. * generic initialization of ADC, input mixers and output mixers
  677. */
  678. static struct hda_verb alc880_volume_init_verbs[] = {
  679. /*
  680. * Unmute ADC0-2 and set the default input to mic-in
  681. */
  682. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  683. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  684. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  685. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  686. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  687. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  688. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  689. * mixer widget
  690. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  691. * mic (mic 2)
  692. */
  693. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  694. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  695. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  696. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  697. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  698. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  699. /*
  700. * Set up output mixers (0x0c - 0x0f)
  701. */
  702. /* set vol=0 to output mixers */
  703. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  704. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  705. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  706. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  707. /* set up input amps for analog loopback */
  708. /* Amp Indices: DAC = 0, mixer = 1 */
  709. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  710. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  711. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  712. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  713. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  714. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  715. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  716. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  717. { }
  718. };
  719. /*
  720. * 3-stack pin configuration:
  721. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  722. */
  723. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  724. /*
  725. * preset connection lists of input pins
  726. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  727. */
  728. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  729. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  730. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  731. /*
  732. * Set pin mode and muting
  733. */
  734. /* set front pin widgets 0x14 for output */
  735. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  736. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  737. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  738. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  739. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  740. /* Mic2 (as headphone out) for HP output */
  741. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  742. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  743. /* Line In pin widget for input */
  744. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  745. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  746. /* Line2 (as front mic) pin widget for input and vref at 80% */
  747. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  748. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  749. /* CD pin widget for input */
  750. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  751. { }
  752. };
  753. /*
  754. * 5-stack pin configuration:
  755. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  756. * line-in/side = 0x1a, f-mic = 0x1b
  757. */
  758. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  759. /*
  760. * preset connection lists of input pins
  761. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  762. */
  763. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  764. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  765. /*
  766. * Set pin mode and muting
  767. */
  768. /* set pin widgets 0x14-0x17 for output */
  769. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  770. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  771. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  772. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  773. /* unmute pins for output (no gain on this amp) */
  774. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  775. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  776. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  777. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  778. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  779. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  780. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  781. /* Mic2 (as headphone out) for HP output */
  782. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  783. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  784. /* Line In pin widget for input */
  785. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  786. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  787. /* Line2 (as front mic) pin widget for input and vref at 80% */
  788. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  789. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  790. /* CD pin widget for input */
  791. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  792. { }
  793. };
  794. /*
  795. * W810 pin configuration:
  796. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  797. */
  798. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  799. /* hphone/speaker input selector: front DAC */
  800. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  801. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  802. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  803. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  804. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  805. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  806. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  807. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  808. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  809. { }
  810. };
  811. /*
  812. * Z71V pin configuration:
  813. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  814. */
  815. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  816. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  817. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  818. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  819. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  820. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  821. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  822. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  823. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  824. { }
  825. };
  826. /*
  827. * 6-stack pin configuration:
  828. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18, f-mic = 0x19,
  829. * line = 0x1a, HP = 0x1b
  830. */
  831. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  832. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  833. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  834. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  835. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  836. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  837. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  838. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  839. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  840. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  841. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  842. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  843. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  844. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  845. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  846. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  847. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  848. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  849. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  850. { }
  851. };
  852. /* FIXME! */
  853. /*
  854. * F1734 pin configuration:
  855. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  856. */
  857. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  858. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  859. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  860. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  861. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  862. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  863. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  864. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  865. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  866. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  867. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  868. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  869. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  870. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  871. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  872. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  873. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  874. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  875. { }
  876. };
  877. /* FIXME! */
  878. /*
  879. * ASUS pin configuration:
  880. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  881. */
  882. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  883. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  884. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  885. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  886. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  887. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  888. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  889. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  890. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  891. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  892. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  893. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  894. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  895. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  896. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  897. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  898. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  899. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  900. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  901. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  902. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  903. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  904. { }
  905. };
  906. /* Enable GPIO mask and set output */
  907. static struct hda_verb alc880_gpio1_init_verbs[] = {
  908. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  909. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  910. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  911. { }
  912. };
  913. /* Enable GPIO mask and set output */
  914. static struct hda_verb alc880_gpio2_init_verbs[] = {
  915. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  916. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  917. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  918. { }
  919. };
  920. /* Clevo m520g init */
  921. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  922. /* headphone output */
  923. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  924. /* line-out */
  925. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  926. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  927. /* Line-in */
  928. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  929. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  930. /* CD */
  931. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  932. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  933. /* Mic1 (rear panel) */
  934. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  935. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  936. /* Mic2 (front panel) */
  937. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  938. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  939. /* headphone */
  940. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  941. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  942. /* change to EAPD mode */
  943. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  944. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  945. { }
  946. };
  947. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  948. /* Headphone output */
  949. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  950. /* Front output*/
  951. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  952. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  953. /* Line In pin widget for input */
  954. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  955. /* CD pin widget for input */
  956. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  957. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  958. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  959. /* change to EAPD mode */
  960. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  961. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  962. { }
  963. };
  964. /*
  965. */
  966. static int alc_init(struct hda_codec *codec)
  967. {
  968. struct alc_spec *spec = codec->spec;
  969. unsigned int i;
  970. for (i = 0; i < spec->num_init_verbs; i++)
  971. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  972. return 0;
  973. }
  974. #ifdef CONFIG_PM
  975. /*
  976. * resume
  977. */
  978. static int alc_resume(struct hda_codec *codec)
  979. {
  980. struct alc_spec *spec = codec->spec;
  981. int i;
  982. alc_init(codec);
  983. for (i = 0; i < spec->num_mixers; i++)
  984. snd_hda_resume_ctls(codec, spec->mixers[i]);
  985. if (spec->multiout.dig_out_nid)
  986. snd_hda_resume_spdif_out(codec);
  987. if (spec->dig_in_nid)
  988. snd_hda_resume_spdif_in(codec);
  989. return 0;
  990. }
  991. #endif
  992. /*
  993. * Analog playback callbacks
  994. */
  995. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  996. struct hda_codec *codec,
  997. struct snd_pcm_substream *substream)
  998. {
  999. struct alc_spec *spec = codec->spec;
  1000. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1001. }
  1002. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1003. struct hda_codec *codec,
  1004. unsigned int stream_tag,
  1005. unsigned int format,
  1006. struct snd_pcm_substream *substream)
  1007. {
  1008. struct alc_spec *spec = codec->spec;
  1009. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout, stream_tag,
  1010. format, substream);
  1011. }
  1012. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1013. struct hda_codec *codec,
  1014. struct snd_pcm_substream *substream)
  1015. {
  1016. struct alc_spec *spec = codec->spec;
  1017. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1018. }
  1019. /*
  1020. * Digital out
  1021. */
  1022. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1023. struct hda_codec *codec,
  1024. struct snd_pcm_substream *substream)
  1025. {
  1026. struct alc_spec *spec = codec->spec;
  1027. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1028. }
  1029. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1030. struct hda_codec *codec,
  1031. struct snd_pcm_substream *substream)
  1032. {
  1033. struct alc_spec *spec = codec->spec;
  1034. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1035. }
  1036. /*
  1037. * Analog capture
  1038. */
  1039. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1040. struct hda_codec *codec,
  1041. unsigned int stream_tag,
  1042. unsigned int format,
  1043. struct snd_pcm_substream *substream)
  1044. {
  1045. struct alc_spec *spec = codec->spec;
  1046. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1047. stream_tag, 0, format);
  1048. return 0;
  1049. }
  1050. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1051. struct hda_codec *codec,
  1052. struct snd_pcm_substream *substream)
  1053. {
  1054. struct alc_spec *spec = codec->spec;
  1055. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number], 0, 0, 0);
  1056. return 0;
  1057. }
  1058. /*
  1059. */
  1060. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1061. .substreams = 1,
  1062. .channels_min = 2,
  1063. .channels_max = 8,
  1064. /* NID is set in alc_build_pcms */
  1065. .ops = {
  1066. .open = alc880_playback_pcm_open,
  1067. .prepare = alc880_playback_pcm_prepare,
  1068. .cleanup = alc880_playback_pcm_cleanup
  1069. },
  1070. };
  1071. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1072. .substreams = 2,
  1073. .channels_min = 2,
  1074. .channels_max = 2,
  1075. /* NID is set in alc_build_pcms */
  1076. .ops = {
  1077. .prepare = alc880_capture_pcm_prepare,
  1078. .cleanup = alc880_capture_pcm_cleanup
  1079. },
  1080. };
  1081. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1082. .substreams = 1,
  1083. .channels_min = 2,
  1084. .channels_max = 2,
  1085. /* NID is set in alc_build_pcms */
  1086. .ops = {
  1087. .open = alc880_dig_playback_pcm_open,
  1088. .close = alc880_dig_playback_pcm_close
  1089. },
  1090. };
  1091. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1092. .substreams = 1,
  1093. .channels_min = 2,
  1094. .channels_max = 2,
  1095. /* NID is set in alc_build_pcms */
  1096. };
  1097. static int alc_build_pcms(struct hda_codec *codec)
  1098. {
  1099. struct alc_spec *spec = codec->spec;
  1100. struct hda_pcm *info = spec->pcm_rec;
  1101. int i;
  1102. codec->num_pcms = 1;
  1103. codec->pcm_info = info;
  1104. info->name = spec->stream_name_analog;
  1105. if (spec->stream_analog_playback) {
  1106. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1107. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1108. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1109. }
  1110. if (spec->stream_analog_capture) {
  1111. snd_assert(spec->adc_nids, return -EINVAL);
  1112. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1113. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1114. }
  1115. if (spec->channel_mode) {
  1116. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1117. for (i = 0; i < spec->num_channel_mode; i++) {
  1118. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1119. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1120. }
  1121. }
  1122. }
  1123. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1124. codec->num_pcms++;
  1125. info++;
  1126. info->name = spec->stream_name_digital;
  1127. if (spec->multiout.dig_out_nid &&
  1128. spec->stream_digital_playback) {
  1129. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1130. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1131. }
  1132. if (spec->dig_in_nid &&
  1133. spec->stream_digital_capture) {
  1134. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1135. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1136. }
  1137. }
  1138. return 0;
  1139. }
  1140. static void alc_free(struct hda_codec *codec)
  1141. {
  1142. struct alc_spec *spec = codec->spec;
  1143. unsigned int i;
  1144. if (! spec)
  1145. return;
  1146. if (spec->kctl_alloc) {
  1147. for (i = 0; i < spec->num_kctl_used; i++)
  1148. kfree(spec->kctl_alloc[i].name);
  1149. kfree(spec->kctl_alloc);
  1150. }
  1151. kfree(spec);
  1152. }
  1153. /*
  1154. */
  1155. static struct hda_codec_ops alc_patch_ops = {
  1156. .build_controls = alc_build_controls,
  1157. .build_pcms = alc_build_pcms,
  1158. .init = alc_init,
  1159. .free = alc_free,
  1160. #ifdef CONFIG_PM
  1161. .resume = alc_resume,
  1162. #endif
  1163. };
  1164. /*
  1165. * Test configuration for debugging
  1166. *
  1167. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1168. * enum controls.
  1169. */
  1170. #ifdef CONFIG_SND_DEBUG
  1171. static hda_nid_t alc880_test_dac_nids[4] = {
  1172. 0x02, 0x03, 0x04, 0x05
  1173. };
  1174. static struct hda_input_mux alc880_test_capture_source = {
  1175. .num_items = 5,
  1176. .items = {
  1177. { "In-1", 0x0 },
  1178. { "In-2", 0x1 },
  1179. { "In-3", 0x2 },
  1180. { "In-4", 0x3 },
  1181. { "CD", 0x4 },
  1182. },
  1183. };
  1184. static struct hda_channel_mode alc880_test_modes[4] = {
  1185. { 2, NULL },
  1186. { 4, NULL },
  1187. { 6, NULL },
  1188. { 8, NULL },
  1189. };
  1190. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  1191. {
  1192. static char *texts[] = {
  1193. "N/A", "Line Out", "HP Out",
  1194. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1195. };
  1196. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1197. uinfo->count = 1;
  1198. uinfo->value.enumerated.items = 8;
  1199. if (uinfo->value.enumerated.item >= 8)
  1200. uinfo->value.enumerated.item = 7;
  1201. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1202. return 0;
  1203. }
  1204. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1205. {
  1206. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1207. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1208. unsigned int pin_ctl, item = 0;
  1209. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1210. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1211. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1212. if (pin_ctl & AC_PINCTL_HP_EN)
  1213. item = 2;
  1214. else
  1215. item = 1;
  1216. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1217. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1218. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1219. case AC_PINCTL_VREF_50: item = 4; break;
  1220. case AC_PINCTL_VREF_GRD: item = 5; break;
  1221. case AC_PINCTL_VREF_80: item = 6; break;
  1222. case AC_PINCTL_VREF_100: item = 7; break;
  1223. }
  1224. }
  1225. ucontrol->value.enumerated.item[0] = item;
  1226. return 0;
  1227. }
  1228. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1229. {
  1230. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1231. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1232. static unsigned int ctls[] = {
  1233. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1234. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1235. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1236. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1237. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1238. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1239. };
  1240. unsigned int old_ctl, new_ctl;
  1241. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1242. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1243. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1244. if (old_ctl != new_ctl) {
  1245. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1246. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1247. ucontrol->value.enumerated.item[0] >= 3 ? 0xb080 : 0xb000);
  1248. return 1;
  1249. }
  1250. return 0;
  1251. }
  1252. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo)
  1253. {
  1254. static char *texts[] = {
  1255. "Front", "Surround", "CLFE", "Side"
  1256. };
  1257. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1258. uinfo->count = 1;
  1259. uinfo->value.enumerated.items = 4;
  1260. if (uinfo->value.enumerated.item >= 4)
  1261. uinfo->value.enumerated.item = 3;
  1262. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1263. return 0;
  1264. }
  1265. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1266. {
  1267. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1268. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1269. unsigned int sel;
  1270. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1271. ucontrol->value.enumerated.item[0] = sel & 3;
  1272. return 0;
  1273. }
  1274. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  1275. {
  1276. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1277. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1278. unsigned int sel;
  1279. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1280. if (ucontrol->value.enumerated.item[0] != sel) {
  1281. sel = ucontrol->value.enumerated.item[0] & 3;
  1282. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1283. return 1;
  1284. }
  1285. return 0;
  1286. }
  1287. #define PIN_CTL_TEST(xname,nid) { \
  1288. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1289. .name = xname, \
  1290. .info = alc_test_pin_ctl_info, \
  1291. .get = alc_test_pin_ctl_get, \
  1292. .put = alc_test_pin_ctl_put, \
  1293. .private_value = nid \
  1294. }
  1295. #define PIN_SRC_TEST(xname,nid) { \
  1296. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1297. .name = xname, \
  1298. .info = alc_test_pin_src_info, \
  1299. .get = alc_test_pin_src_get, \
  1300. .put = alc_test_pin_src_put, \
  1301. .private_value = nid \
  1302. }
  1303. static struct snd_kcontrol_new alc880_test_mixer[] = {
  1304. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1305. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1306. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  1307. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1308. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1309. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1310. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  1311. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1312. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1313. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1314. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1315. PIN_CTL_TEST("Side Pin Mode", 0x17),
  1316. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  1317. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  1318. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  1319. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  1320. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  1321. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  1322. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  1323. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  1324. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1325. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1326. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1327. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1328. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  1329. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  1330. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  1331. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  1332. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  1333. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  1334. {
  1335. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1336. .name = "Channel Mode",
  1337. .info = alc_ch_mode_info,
  1338. .get = alc_ch_mode_get,
  1339. .put = alc_ch_mode_put,
  1340. },
  1341. { } /* end */
  1342. };
  1343. static struct hda_verb alc880_test_init_verbs[] = {
  1344. /* Unmute inputs of 0x0c - 0x0f */
  1345. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1346. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1347. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1348. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1349. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1350. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1351. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1352. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1353. /* Vol output for 0x0c-0x0f */
  1354. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1355. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1356. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1357. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1358. /* Set output pins 0x14-0x17 */
  1359. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1360. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1361. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1362. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1363. /* Unmute output pins 0x14-0x17 */
  1364. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1365. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1366. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1367. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1368. /* Set input pins 0x18-0x1c */
  1369. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1370. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1371. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1372. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1373. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1374. /* Mute input pins 0x18-0x1b */
  1375. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1376. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1377. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1378. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1379. /* ADC set up */
  1380. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1381. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1382. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1383. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1384. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1385. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1386. /* Analog input/passthru */
  1387. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1388. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1389. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1390. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1391. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1392. { }
  1393. };
  1394. #endif
  1395. /*
  1396. */
  1397. static struct hda_board_config alc880_cfg_tbl[] = {
  1398. /* Back 3 jack, front 2 jack */
  1399. { .modelname = "3stack", .config = ALC880_3ST },
  1400. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe200, .config = ALC880_3ST },
  1401. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe201, .config = ALC880_3ST },
  1402. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe202, .config = ALC880_3ST },
  1403. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe203, .config = ALC880_3ST },
  1404. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe204, .config = ALC880_3ST },
  1405. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe205, .config = ALC880_3ST },
  1406. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe206, .config = ALC880_3ST },
  1407. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe207, .config = ALC880_3ST },
  1408. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe208, .config = ALC880_3ST },
  1409. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe209, .config = ALC880_3ST },
  1410. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20a, .config = ALC880_3ST },
  1411. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20b, .config = ALC880_3ST },
  1412. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20c, .config = ALC880_3ST },
  1413. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20d, .config = ALC880_3ST },
  1414. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20e, .config = ALC880_3ST },
  1415. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe20f, .config = ALC880_3ST },
  1416. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe210, .config = ALC880_3ST },
  1417. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe211, .config = ALC880_3ST },
  1418. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe214, .config = ALC880_3ST },
  1419. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe302, .config = ALC880_3ST },
  1420. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe303, .config = ALC880_3ST },
  1421. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe304, .config = ALC880_3ST },
  1422. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe306, .config = ALC880_3ST },
  1423. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe307, .config = ALC880_3ST },
  1424. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe404, .config = ALC880_3ST },
  1425. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa101, .config = ALC880_3ST },
  1426. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3031, .config = ALC880_3ST },
  1427. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4036, .config = ALC880_3ST },
  1428. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4037, .config = ALC880_3ST },
  1429. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4038, .config = ALC880_3ST },
  1430. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4040, .config = ALC880_3ST },
  1431. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4041, .config = ALC880_3ST },
  1432. /* TCL S700 */
  1433. { .pci_subvendor = 0x19db, .pci_subdevice = 0x4188, .config = ALC880_TCL_S700 },
  1434. /* Back 3 jack, front 2 jack (Internal add Aux-In) */
  1435. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe310, .config = ALC880_3ST },
  1436. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81d6, .config = ALC880_3ST },
  1437. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81a0, .config = ALC880_3ST },
  1438. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack */
  1439. { .modelname = "3stack-digout", .config = ALC880_3ST_DIG },
  1440. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe308, .config = ALC880_3ST_DIG },
  1441. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0070, .config = ALC880_3ST_DIG },
  1442. /* Clevo m520G NB */
  1443. { .pci_subvendor = 0x1558, .pci_subdevice = 0x0520, .config = ALC880_CLEVO },
  1444. /* Back 3 jack plus 1 SPDIF out jack, front 2 jack (Internal add Aux-In)*/
  1445. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe305, .config = ALC880_3ST_DIG },
  1446. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd402, .config = ALC880_3ST_DIG },
  1447. { .pci_subvendor = 0x1025, .pci_subdevice = 0xe309, .config = ALC880_3ST_DIG },
  1448. /* Back 5 jack, front 2 jack */
  1449. { .modelname = "5stack", .config = ALC880_5ST },
  1450. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3033, .config = ALC880_5ST },
  1451. { .pci_subvendor = 0x107b, .pci_subdevice = 0x4039, .config = ALC880_5ST },
  1452. { .pci_subvendor = 0x107b, .pci_subdevice = 0x3032, .config = ALC880_5ST },
  1453. { .pci_subvendor = 0x103c, .pci_subdevice = 0x2a09, .config = ALC880_5ST },
  1454. { .pci_subvendor = 0x1043, .pci_subdevice = 0x814e, .config = ALC880_5ST },
  1455. /* Back 5 jack plus 1 SPDIF out jack, front 2 jack */
  1456. { .modelname = "5stack-digout", .config = ALC880_5ST_DIG },
  1457. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe224, .config = ALC880_5ST_DIG },
  1458. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe400, .config = ALC880_5ST_DIG },
  1459. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe401, .config = ALC880_5ST_DIG },
  1460. { .pci_subvendor = 0x8086, .pci_subdevice = 0xe402, .config = ALC880_5ST_DIG },
  1461. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd400, .config = ALC880_5ST_DIG },
  1462. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd401, .config = ALC880_5ST_DIG },
  1463. { .pci_subvendor = 0x8086, .pci_subdevice = 0xa100, .config = ALC880_5ST_DIG },
  1464. { .pci_subvendor = 0x1565, .pci_subdevice = 0x8202, .config = ALC880_5ST_DIG },
  1465. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa880, .config = ALC880_5ST_DIG },
  1466. /* { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_5ST_DIG }, */ /* conflict with 6stack */
  1467. { .pci_subvendor = 0x1695, .pci_subdevice = 0x400d, .config = ALC880_5ST_DIG },
  1468. /* note subvendor = 0 below */
  1469. /* { .pci_subvendor = 0x0000, .pci_subdevice = 0x8086, .config = ALC880_5ST_DIG }, */
  1470. { .modelname = "w810", .config = ALC880_W810 },
  1471. { .pci_subvendor = 0x161f, .pci_subdevice = 0x203d, .config = ALC880_W810 },
  1472. { .modelname = "z71v", .config = ALC880_Z71V },
  1473. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_Z71V },
  1474. { .modelname = "6stack", .config = ALC880_6ST },
  1475. { .pci_subvendor = 0x1043, .pci_subdevice = 0x8196, .config = ALC880_6ST }, /* ASUS P5GD1-HVM */
  1476. { .pci_subvendor = 0x1043, .pci_subdevice = 0x81b4, .config = ALC880_6ST },
  1477. { .pci_subvendor = 0x1019, .pci_subdevice = 0xa884, .config = ALC880_6ST }, /* Acer APFV */
  1478. { .pci_subvendor = 0x1458, .pci_subdevice = 0xa102, .config = ALC880_6ST }, /* Gigabyte K8N51 */
  1479. { .modelname = "6stack-digout", .config = ALC880_6ST_DIG },
  1480. { .pci_subvendor = 0x2668, .pci_subdevice = 0x8086, .config = ALC880_6ST_DIG },
  1481. { .pci_subvendor = 0x8086, .pci_subdevice = 0x2668, .config = ALC880_6ST_DIG },
  1482. { .pci_subvendor = 0x1462, .pci_subdevice = 0x1150, .config = ALC880_6ST_DIG },
  1483. { .pci_subvendor = 0xe803, .pci_subdevice = 0x1019, .config = ALC880_6ST_DIG },
  1484. { .pci_subvendor = 0x1039, .pci_subdevice = 0x1234, .config = ALC880_6ST_DIG },
  1485. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0077, .config = ALC880_6ST_DIG },
  1486. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0078, .config = ALC880_6ST_DIG },
  1487. { .pci_subvendor = 0x1025, .pci_subdevice = 0x0087, .config = ALC880_6ST_DIG },
  1488. { .pci_subvendor = 0x1297, .pci_subdevice = 0xc790, .config = ALC880_6ST_DIG }, /* Shuttle ST20G5 */
  1489. { .modelname = "asus", .config = ALC880_ASUS },
  1490. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1964, .config = ALC880_ASUS_DIG },
  1491. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1973, .config = ALC880_ASUS_DIG },
  1492. { .pci_subvendor = 0x1043, .pci_subdevice = 0x19b3, .config = ALC880_ASUS_DIG },
  1493. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1113, .config = ALC880_ASUS_DIG },
  1494. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1173, .config = ALC880_ASUS_DIG },
  1495. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1993, .config = ALC880_ASUS },
  1496. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10c3, .config = ALC880_ASUS_DIG },
  1497. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1133, .config = ALC880_ASUS },
  1498. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1123, .config = ALC880_ASUS_DIG },
  1499. { .pci_subvendor = 0x1043, .pci_subdevice = 0x1143, .config = ALC880_ASUS },
  1500. { .pci_subvendor = 0x1043, .pci_subdevice = 0x10b3, .config = ALC880_ASUS_W1V },
  1501. { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
  1502. { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
  1503. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
  1504. { .modelname = "F1734", .config = ALC880_F1734 },
  1505. { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
  1506. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
  1507. #ifdef CONFIG_SND_DEBUG
  1508. { .modelname = "test", .config = ALC880_TEST },
  1509. #endif
  1510. { .modelname = "auto", .config = ALC880_AUTO },
  1511. {}
  1512. };
  1513. /*
  1514. * ALC880 codec presets
  1515. */
  1516. static struct alc_config_preset alc880_presets[] = {
  1517. [ALC880_3ST] = {
  1518. .mixers = { alc880_three_stack_mixer },
  1519. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1520. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1521. .dac_nids = alc880_dac_nids,
  1522. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1523. .channel_mode = alc880_threestack_modes,
  1524. .input_mux = &alc880_capture_source,
  1525. },
  1526. [ALC880_3ST_DIG] = {
  1527. .mixers = { alc880_three_stack_mixer },
  1528. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1529. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1530. .dac_nids = alc880_dac_nids,
  1531. .dig_out_nid = ALC880_DIGOUT_NID,
  1532. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1533. .channel_mode = alc880_threestack_modes,
  1534. .input_mux = &alc880_capture_source,
  1535. },
  1536. [ALC880_TCL_S700] = {
  1537. .mixers = { alc880_tcl_s700_mixer },
  1538. .init_verbs = { alc880_volume_init_verbs,
  1539. alc880_pin_tcl_S700_init_verbs,
  1540. alc880_gpio2_init_verbs },
  1541. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1542. .dac_nids = alc880_dac_nids,
  1543. .hp_nid = 0x03,
  1544. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1545. .channel_mode = alc880_2_jack_modes,
  1546. .input_mux = &alc880_capture_source,
  1547. },
  1548. [ALC880_5ST] = {
  1549. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  1550. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1551. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1552. .dac_nids = alc880_dac_nids,
  1553. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1554. .channel_mode = alc880_fivestack_modes,
  1555. .input_mux = &alc880_capture_source,
  1556. },
  1557. [ALC880_5ST_DIG] = {
  1558. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  1559. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1560. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1561. .dac_nids = alc880_dac_nids,
  1562. .dig_out_nid = ALC880_DIGOUT_NID,
  1563. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1564. .channel_mode = alc880_fivestack_modes,
  1565. .input_mux = &alc880_capture_source,
  1566. },
  1567. [ALC880_6ST] = {
  1568. .mixers = { alc880_six_stack_mixer },
  1569. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1570. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1571. .dac_nids = alc880_6st_dac_nids,
  1572. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1573. .channel_mode = alc880_sixstack_modes,
  1574. .input_mux = &alc880_6stack_capture_source,
  1575. },
  1576. [ALC880_6ST_DIG] = {
  1577. .mixers = { alc880_six_stack_mixer },
  1578. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1579. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1580. .dac_nids = alc880_6st_dac_nids,
  1581. .dig_out_nid = ALC880_DIGOUT_NID,
  1582. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1583. .channel_mode = alc880_sixstack_modes,
  1584. .input_mux = &alc880_6stack_capture_source,
  1585. },
  1586. [ALC880_W810] = {
  1587. .mixers = { alc880_w810_base_mixer },
  1588. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  1589. alc880_gpio2_init_verbs },
  1590. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  1591. .dac_nids = alc880_w810_dac_nids,
  1592. .dig_out_nid = ALC880_DIGOUT_NID,
  1593. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  1594. .channel_mode = alc880_w810_modes,
  1595. .input_mux = &alc880_capture_source,
  1596. },
  1597. [ALC880_Z71V] = {
  1598. .mixers = { alc880_z71v_mixer },
  1599. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  1600. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  1601. .dac_nids = alc880_z71v_dac_nids,
  1602. .dig_out_nid = ALC880_DIGOUT_NID,
  1603. .hp_nid = 0x03,
  1604. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1605. .channel_mode = alc880_2_jack_modes,
  1606. .input_mux = &alc880_capture_source,
  1607. },
  1608. [ALC880_F1734] = {
  1609. .mixers = { alc880_f1734_mixer },
  1610. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  1611. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  1612. .dac_nids = alc880_f1734_dac_nids,
  1613. .hp_nid = 0x02,
  1614. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1615. .channel_mode = alc880_2_jack_modes,
  1616. .input_mux = &alc880_capture_source,
  1617. },
  1618. [ALC880_ASUS] = {
  1619. .mixers = { alc880_asus_mixer },
  1620. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1621. alc880_gpio1_init_verbs },
  1622. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1623. .dac_nids = alc880_asus_dac_nids,
  1624. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1625. .channel_mode = alc880_asus_modes,
  1626. .input_mux = &alc880_capture_source,
  1627. },
  1628. [ALC880_ASUS_DIG] = {
  1629. .mixers = { alc880_asus_mixer },
  1630. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1631. alc880_gpio1_init_verbs },
  1632. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1633. .dac_nids = alc880_asus_dac_nids,
  1634. .dig_out_nid = ALC880_DIGOUT_NID,
  1635. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1636. .channel_mode = alc880_asus_modes,
  1637. .input_mux = &alc880_capture_source,
  1638. },
  1639. [ALC880_ASUS_DIG2] = {
  1640. .mixers = { alc880_asus_mixer },
  1641. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1642. alc880_gpio2_init_verbs }, /* use GPIO2 */
  1643. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1644. .dac_nids = alc880_asus_dac_nids,
  1645. .dig_out_nid = ALC880_DIGOUT_NID,
  1646. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1647. .channel_mode = alc880_asus_modes,
  1648. .input_mux = &alc880_capture_source,
  1649. },
  1650. [ALC880_ASUS_W1V] = {
  1651. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  1652. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1653. alc880_gpio1_init_verbs },
  1654. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1655. .dac_nids = alc880_asus_dac_nids,
  1656. .dig_out_nid = ALC880_DIGOUT_NID,
  1657. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1658. .channel_mode = alc880_asus_modes,
  1659. .input_mux = &alc880_capture_source,
  1660. },
  1661. [ALC880_UNIWILL_DIG] = {
  1662. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  1663. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
  1664. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1665. .dac_nids = alc880_asus_dac_nids,
  1666. .dig_out_nid = ALC880_DIGOUT_NID,
  1667. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1668. .channel_mode = alc880_asus_modes,
  1669. .input_mux = &alc880_capture_source,
  1670. },
  1671. [ALC880_CLEVO] = {
  1672. .mixers = { alc880_three_stack_mixer },
  1673. .init_verbs = { alc880_volume_init_verbs,
  1674. alc880_pin_clevo_init_verbs },
  1675. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1676. .dac_nids = alc880_dac_nids,
  1677. .hp_nid = 0x03,
  1678. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1679. .channel_mode = alc880_threestack_modes,
  1680. .input_mux = &alc880_capture_source,
  1681. },
  1682. #ifdef CONFIG_SND_DEBUG
  1683. [ALC880_TEST] = {
  1684. .mixers = { alc880_test_mixer },
  1685. .init_verbs = { alc880_test_init_verbs },
  1686. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  1687. .dac_nids = alc880_test_dac_nids,
  1688. .dig_out_nid = ALC880_DIGOUT_NID,
  1689. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  1690. .channel_mode = alc880_test_modes,
  1691. .input_mux = &alc880_test_capture_source,
  1692. },
  1693. #endif
  1694. };
  1695. /*
  1696. * Automatic parse of I/O pins from the BIOS configuration
  1697. */
  1698. #define NUM_CONTROL_ALLOC 32
  1699. #define NUM_VERB_ALLOC 32
  1700. enum {
  1701. ALC_CTL_WIDGET_VOL,
  1702. ALC_CTL_WIDGET_MUTE,
  1703. ALC_CTL_BIND_MUTE,
  1704. };
  1705. static struct snd_kcontrol_new alc880_control_templates[] = {
  1706. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  1707. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  1708. HDA_BIND_MUTE(NULL, 0, 0, 0),
  1709. };
  1710. /* add dynamic controls */
  1711. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  1712. {
  1713. struct snd_kcontrol_new *knew;
  1714. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  1715. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  1716. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  1717. if (! knew)
  1718. return -ENOMEM;
  1719. if (spec->kctl_alloc) {
  1720. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  1721. kfree(spec->kctl_alloc);
  1722. }
  1723. spec->kctl_alloc = knew;
  1724. spec->num_kctl_alloc = num;
  1725. }
  1726. knew = &spec->kctl_alloc[spec->num_kctl_used];
  1727. *knew = alc880_control_templates[type];
  1728. knew->name = kstrdup(name, GFP_KERNEL);
  1729. if (! knew->name)
  1730. return -ENOMEM;
  1731. knew->private_value = val;
  1732. spec->num_kctl_used++;
  1733. return 0;
  1734. }
  1735. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  1736. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  1737. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  1738. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  1739. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  1740. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  1741. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  1742. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  1743. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  1744. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  1745. #define ALC880_PIN_CD_NID 0x1c
  1746. /* fill in the dac_nids table from the parsed pin configuration */
  1747. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  1748. {
  1749. hda_nid_t nid;
  1750. int assigned[4];
  1751. int i, j;
  1752. memset(assigned, 0, sizeof(assigned));
  1753. spec->multiout.dac_nids = spec->private_dac_nids;
  1754. /* check the pins hardwired to audio widget */
  1755. for (i = 0; i < cfg->line_outs; i++) {
  1756. nid = cfg->line_out_pins[i];
  1757. if (alc880_is_fixed_pin(nid)) {
  1758. int idx = alc880_fixed_pin_idx(nid);
  1759. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  1760. assigned[idx] = 1;
  1761. }
  1762. }
  1763. /* left pins can be connect to any audio widget */
  1764. for (i = 0; i < cfg->line_outs; i++) {
  1765. nid = cfg->line_out_pins[i];
  1766. if (alc880_is_fixed_pin(nid))
  1767. continue;
  1768. /* search for an empty channel */
  1769. for (j = 0; j < cfg->line_outs; j++) {
  1770. if (! assigned[j]) {
  1771. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  1772. assigned[j] = 1;
  1773. break;
  1774. }
  1775. }
  1776. }
  1777. spec->multiout.num_dacs = cfg->line_outs;
  1778. return 0;
  1779. }
  1780. /* add playback controls from the parsed DAC table */
  1781. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  1782. const struct auto_pin_cfg *cfg)
  1783. {
  1784. char name[32];
  1785. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  1786. hda_nid_t nid;
  1787. int i, err;
  1788. for (i = 0; i < cfg->line_outs; i++) {
  1789. if (! spec->multiout.dac_nids[i])
  1790. continue;
  1791. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  1792. if (i == 2) {
  1793. /* Center/LFE */
  1794. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  1795. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  1796. return err;
  1797. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  1798. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  1799. return err;
  1800. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  1801. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  1802. return err;
  1803. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  1804. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  1805. return err;
  1806. } else {
  1807. sprintf(name, "%s Playback Volume", chname[i]);
  1808. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  1809. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  1810. return err;
  1811. sprintf(name, "%s Playback Switch", chname[i]);
  1812. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  1813. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  1814. return err;
  1815. }
  1816. }
  1817. return 0;
  1818. }
  1819. /* add playback controls for speaker and HP outputs */
  1820. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  1821. const char *pfx)
  1822. {
  1823. hda_nid_t nid;
  1824. int err;
  1825. char name[32];
  1826. if (! pin)
  1827. return 0;
  1828. if (alc880_is_fixed_pin(pin)) {
  1829. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  1830. if (! spec->multiout.dac_nids[0]) {
  1831. /* use this as the primary output */
  1832. spec->multiout.dac_nids[0] = nid;
  1833. if (! spec->multiout.num_dacs)
  1834. spec->multiout.num_dacs = 1;
  1835. } else
  1836. /* specify the DAC as the extra output */
  1837. spec->multiout.hp_nid = nid;
  1838. /* control HP volume/switch on the output mixer amp */
  1839. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  1840. sprintf(name, "%s Playback Volume", pfx);
  1841. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  1842. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  1843. return err;
  1844. sprintf(name, "%s Playback Switch", pfx);
  1845. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  1846. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  1847. return err;
  1848. } else if (alc880_is_multi_pin(pin)) {
  1849. /* set manual connection */
  1850. if (! spec->multiout.dac_nids[0]) {
  1851. /* use this as the primary output */
  1852. spec->multiout.dac_nids[0] = alc880_idx_to_dac(alc880_multi_pin_idx(pin));
  1853. if (! spec->multiout.num_dacs)
  1854. spec->multiout.num_dacs = 1;
  1855. }
  1856. /* we have only a switch on HP-out PIN */
  1857. sprintf(name, "%s Playback Switch", pfx);
  1858. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  1859. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  1860. return err;
  1861. }
  1862. return 0;
  1863. }
  1864. /* create input playback/capture controls for the given pin */
  1865. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  1866. int idx, hda_nid_t mix_nid)
  1867. {
  1868. char name[32];
  1869. int err;
  1870. sprintf(name, "%s Playback Volume", ctlname);
  1871. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  1872. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  1873. return err;
  1874. sprintf(name, "%s Playback Switch", ctlname);
  1875. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  1876. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  1877. return err;
  1878. return 0;
  1879. }
  1880. /* create playback/capture controls for input pins */
  1881. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  1882. const struct auto_pin_cfg *cfg)
  1883. {
  1884. struct hda_input_mux *imux = &spec->private_imux;
  1885. int i, err, idx;
  1886. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1887. if (alc880_is_input_pin(cfg->input_pins[i])) {
  1888. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  1889. err = new_analog_input(spec, cfg->input_pins[i],
  1890. auto_pin_cfg_labels[i],
  1891. idx, 0x0b);
  1892. if (err < 0)
  1893. return err;
  1894. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  1895. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  1896. imux->num_items++;
  1897. }
  1898. }
  1899. return 0;
  1900. }
  1901. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  1902. hda_nid_t nid, int pin_type,
  1903. int dac_idx)
  1904. {
  1905. /* set as output */
  1906. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  1907. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  1908. /* need the manual connection? */
  1909. if (alc880_is_multi_pin(nid)) {
  1910. struct alc_spec *spec = codec->spec;
  1911. int idx = alc880_multi_pin_idx(nid);
  1912. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  1913. AC_VERB_SET_CONNECT_SEL,
  1914. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  1915. }
  1916. }
  1917. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  1918. {
  1919. struct alc_spec *spec = codec->spec;
  1920. int i;
  1921. for (i = 0; i < spec->autocfg.line_outs; i++) {
  1922. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  1923. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  1924. }
  1925. }
  1926. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  1927. {
  1928. struct alc_spec *spec = codec->spec;
  1929. hda_nid_t pin;
  1930. pin = spec->autocfg.speaker_pin;
  1931. if (pin) /* connect to front */
  1932. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  1933. pin = spec->autocfg.hp_pin;
  1934. if (pin) /* connect to front */
  1935. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  1936. }
  1937. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  1938. {
  1939. struct alc_spec *spec = codec->spec;
  1940. int i;
  1941. for (i = 0; i < AUTO_PIN_LAST; i++) {
  1942. hda_nid_t nid = spec->autocfg.input_pins[i];
  1943. if (alc880_is_input_pin(nid)) {
  1944. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  1945. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  1946. if (nid != ALC880_PIN_CD_NID)
  1947. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1948. AMP_OUT_MUTE);
  1949. }
  1950. }
  1951. }
  1952. /* parse the BIOS configuration and set up the alc_spec */
  1953. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  1954. static int alc880_parse_auto_config(struct hda_codec *codec)
  1955. {
  1956. struct alc_spec *spec = codec->spec;
  1957. int err;
  1958. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  1959. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  1960. alc880_ignore)) < 0)
  1961. return err;
  1962. if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
  1963. ! spec->autocfg.hp_pin)
  1964. return 0; /* can't find valid BIOS pin config */
  1965. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  1966. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  1967. (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
  1968. "Speaker")) < 0 ||
  1969. (err = alc880_auto_create_extra_out(spec, spec->autocfg.speaker_pin,
  1970. "Headphone")) < 0 ||
  1971. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  1972. return err;
  1973. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  1974. if (spec->autocfg.dig_out_pin)
  1975. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  1976. if (spec->autocfg.dig_in_pin)
  1977. spec->dig_in_nid = ALC880_DIGIN_NID;
  1978. if (spec->kctl_alloc)
  1979. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  1980. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  1981. spec->input_mux = &spec->private_imux;
  1982. return 1;
  1983. }
  1984. /* init callback for auto-configuration model -- overriding the default init */
  1985. static int alc880_auto_init(struct hda_codec *codec)
  1986. {
  1987. alc_init(codec);
  1988. alc880_auto_init_multi_out(codec);
  1989. alc880_auto_init_extra_out(codec);
  1990. alc880_auto_init_analog_input(codec);
  1991. return 0;
  1992. }
  1993. /*
  1994. * OK, here we have finally the patch for ALC880
  1995. */
  1996. static int patch_alc880(struct hda_codec *codec)
  1997. {
  1998. struct alc_spec *spec;
  1999. int board_config;
  2000. int err;
  2001. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2002. if (spec == NULL)
  2003. return -ENOMEM;
  2004. codec->spec = spec;
  2005. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  2006. if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
  2007. printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
  2008. board_config = ALC880_AUTO;
  2009. }
  2010. if (board_config == ALC880_AUTO) {
  2011. /* automatic parse from the BIOS config */
  2012. err = alc880_parse_auto_config(codec);
  2013. if (err < 0) {
  2014. alc_free(codec);
  2015. return err;
  2016. } else if (! err) {
  2017. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
  2018. board_config = ALC880_3ST;
  2019. }
  2020. }
  2021. if (board_config != ALC880_AUTO)
  2022. setup_preset(spec, &alc880_presets[board_config]);
  2023. spec->stream_name_analog = "ALC880 Analog";
  2024. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2025. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2026. spec->stream_name_digital = "ALC880 Digital";
  2027. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2028. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2029. if (! spec->adc_nids && spec->input_mux) {
  2030. /* check whether NID 0x07 is valid */
  2031. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2032. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2033. if (wcap != AC_WID_AUD_IN) {
  2034. spec->adc_nids = alc880_adc_nids_alt;
  2035. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2036. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2037. spec->num_mixers++;
  2038. } else {
  2039. spec->adc_nids = alc880_adc_nids;
  2040. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2041. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2042. spec->num_mixers++;
  2043. }
  2044. }
  2045. codec->patch_ops = alc_patch_ops;
  2046. if (board_config == ALC880_AUTO)
  2047. codec->patch_ops.init = alc880_auto_init;
  2048. return 0;
  2049. }
  2050. /*
  2051. * ALC260 support
  2052. */
  2053. static hda_nid_t alc260_dac_nids[1] = {
  2054. /* front */
  2055. 0x02,
  2056. };
  2057. static hda_nid_t alc260_adc_nids[1] = {
  2058. /* ADC0 */
  2059. 0x04,
  2060. };
  2061. static hda_nid_t alc260_adc_nids_alt[1] = {
  2062. /* ADC1 */
  2063. 0x05,
  2064. };
  2065. static hda_nid_t alc260_hp_adc_nids[2] = {
  2066. /* ADC1, 0 */
  2067. 0x05, 0x04
  2068. };
  2069. #define ALC260_DIGOUT_NID 0x03
  2070. #define ALC260_DIGIN_NID 0x06
  2071. static struct hda_input_mux alc260_capture_source = {
  2072. .num_items = 4,
  2073. .items = {
  2074. { "Mic", 0x0 },
  2075. { "Front Mic", 0x1 },
  2076. { "Line", 0x2 },
  2077. { "CD", 0x4 },
  2078. },
  2079. };
  2080. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack
  2081. * and the internal CD lines.
  2082. */
  2083. static struct hda_input_mux alc260_fujitsu_capture_source = {
  2084. .num_items = 2,
  2085. .items = {
  2086. { "Mic/Line", 0x0 },
  2087. { "CD", 0x4 },
  2088. },
  2089. };
  2090. /*
  2091. * This is just place-holder, so there's something for alc_build_pcms to look
  2092. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2093. * element which allows changing the channel mode, so the verb list is
  2094. * never used.
  2095. */
  2096. static struct hda_channel_mode alc260_modes[1] = {
  2097. { 2, NULL },
  2098. };
  2099. /* Mixer combinations
  2100. *
  2101. * basic: base_output + input + pc_beep + capture
  2102. * HP: base_output + input + capture_alt
  2103. * HP_3013: hp_3013 + input + capture
  2104. * fujitsu: fujitsu + capture
  2105. */
  2106. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2107. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2108. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2109. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2110. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2111. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2112. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2113. { } /* end */
  2114. };
  2115. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2116. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2117. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2118. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2119. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2120. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2121. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2122. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2123. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2124. { } /* end */
  2125. };
  2126. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2127. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2128. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2129. { } /* end */
  2130. };
  2131. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2132. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2133. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2134. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2135. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2136. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2137. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2138. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2139. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2140. { } /* end */
  2141. };
  2142. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2143. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2144. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2145. ALC_PINCTL_SWITCH("Headphone Amp Switch", 0x14, PIN_HP_AMP),
  2146. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2147. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2148. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2149. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2150. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2151. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2152. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2153. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2154. { } /* end */
  2155. };
  2156. /* capture mixer elements */
  2157. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  2158. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  2159. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  2160. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  2161. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  2162. {
  2163. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2164. /* The multiple "Capture Source" controls confuse alsamixer
  2165. * So call somewhat different..
  2166. * FIXME: the controls appear in the "playback" view!
  2167. */
  2168. /* .name = "Capture Source", */
  2169. .name = "Input Source",
  2170. .count = 2,
  2171. .info = alc_mux_enum_info,
  2172. .get = alc_mux_enum_get,
  2173. .put = alc_mux_enum_put,
  2174. },
  2175. { } /* end */
  2176. };
  2177. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  2178. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  2179. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  2180. {
  2181. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2182. /* The multiple "Capture Source" controls confuse alsamixer
  2183. * So call somewhat different..
  2184. * FIXME: the controls appear in the "playback" view!
  2185. */
  2186. /* .name = "Capture Source", */
  2187. .name = "Input Source",
  2188. .count = 1,
  2189. .info = alc_mux_enum_info,
  2190. .get = alc_mux_enum_get,
  2191. .put = alc_mux_enum_put,
  2192. },
  2193. { } /* end */
  2194. };
  2195. /*
  2196. * initialization verbs
  2197. */
  2198. static struct hda_verb alc260_init_verbs[] = {
  2199. /* Line In pin widget for input */
  2200. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2201. /* CD pin widget for input */
  2202. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2203. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2204. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2205. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2206. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2207. /* LINE-2 is used for line-out in rear */
  2208. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2209. /* select line-out */
  2210. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  2211. /* LINE-OUT pin */
  2212. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2213. /* enable HP */
  2214. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2215. /* enable Mono */
  2216. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2217. /* mute capture amp left and right */
  2218. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2219. /* set connection select to line in (default select for this ADC) */
  2220. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2221. /* mute capture amp left and right */
  2222. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2223. /* set connection select to line in (default select for this ADC) */
  2224. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2225. /* set vol=0 Line-Out mixer amp left and right */
  2226. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2227. /* unmute pin widget amp left and right (no gain on this amp) */
  2228. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2229. /* set vol=0 HP mixer amp left and right */
  2230. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2231. /* unmute pin widget amp left and right (no gain on this amp) */
  2232. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2233. /* set vol=0 Mono mixer amp left and right */
  2234. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2235. /* unmute pin widget amp left and right (no gain on this amp) */
  2236. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2237. /* unmute LINE-2 out pin */
  2238. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2239. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2240. /* mute CD */
  2241. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2242. /* mute Line In */
  2243. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2244. /* mute Mic */
  2245. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2246. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2247. /* mute Front out path */
  2248. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2249. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2250. /* mute Headphone out path */
  2251. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2252. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2253. /* mute Mono out path */
  2254. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2255. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2256. { }
  2257. };
  2258. static struct hda_verb alc260_hp_init_verbs[] = {
  2259. /* Headphone and output */
  2260. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2261. /* mono output */
  2262. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2263. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2264. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2265. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2266. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2267. /* Line In pin widget for input */
  2268. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2269. /* Line-2 pin widget for output */
  2270. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2271. /* CD pin widget for input */
  2272. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2273. /* unmute amp left and right */
  2274. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2275. /* set connection select to line in (default select for this ADC) */
  2276. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2277. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2278. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2279. /* mute pin widget amp left and right (no gain on this amp) */
  2280. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2281. /* unmute HP mixer amp left and right (volume = 0) */
  2282. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2283. /* mute pin widget amp left and right (no gain on this amp) */
  2284. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2285. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2286. /* unmute CD */
  2287. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2288. /* unmute Line In */
  2289. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2290. /* unmute Mic */
  2291. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2292. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2293. /* Unmute Front out path */
  2294. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2295. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2296. /* Unmute Headphone out path */
  2297. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2298. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2299. /* Unmute Mono out path */
  2300. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2301. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2302. { }
  2303. };
  2304. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  2305. /* Line out and output */
  2306. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2307. /* mono output */
  2308. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2309. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2310. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2311. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2312. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2313. /* Line In pin widget for input */
  2314. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2315. /* Headphone pin widget for output */
  2316. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2317. /* CD pin widget for input */
  2318. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2319. /* unmute amp left and right */
  2320. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2321. /* set connection select to line in (default select for this ADC) */
  2322. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2323. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2324. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2325. /* mute pin widget amp left and right (no gain on this amp) */
  2326. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2327. /* unmute HP mixer amp left and right (volume = 0) */
  2328. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2329. /* mute pin widget amp left and right (no gain on this amp) */
  2330. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2331. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2332. /* unmute CD */
  2333. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2334. /* unmute Line In */
  2335. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2336. /* unmute Mic */
  2337. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2338. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2339. /* Unmute Front out path */
  2340. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2341. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2342. /* Unmute Headphone out path */
  2343. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2344. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2345. /* Unmute Mono out path */
  2346. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2347. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2348. { }
  2349. };
  2350. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  2351. * laptops.
  2352. */
  2353. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  2354. /* Disable all GPIOs */
  2355. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  2356. /* Internal speaker is connected to headphone pin */
  2357. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2358. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  2359. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2360. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  2361. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2362. /* Ensure all other unused pins are disabled and muted.
  2363. * Note: trying to set widget 0x15 to anything blocks all audio
  2364. * output for some reason, so just leave that at the default.
  2365. */
  2366. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2367. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2368. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2369. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2370. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2371. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2372. /* Disable digital (SPDIF) pins */
  2373. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2374. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2375. /* Start with mixer outputs muted */
  2376. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2377. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2378. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2379. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  2380. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2381. /* Unmute Line1 pin widget amp left and right (no equiv mixer ctrl) */
  2382. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2383. /* Unmute pin widget used for Line-in (no equiv mixer ctrl) */
  2384. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2385. /* Mute capture amp left and right */
  2386. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2387. /* Set ADC connection select to line in (on mic1 pin) */
  2388. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  2389. /* Mute all inputs to mixer widget (even unconnected ones) */
  2390. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  2391. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  2392. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  2393. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  2394. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  2395. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  2396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  2397. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  2398. { }
  2399. };
  2400. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  2401. .substreams = 1,
  2402. .channels_min = 2,
  2403. .channels_max = 2,
  2404. };
  2405. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  2406. .substreams = 1,
  2407. .channels_min = 2,
  2408. .channels_max = 2,
  2409. };
  2410. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  2411. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  2412. /*
  2413. * for BIOS auto-configuration
  2414. */
  2415. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  2416. const char *pfx)
  2417. {
  2418. hda_nid_t nid_vol;
  2419. unsigned long vol_val, sw_val;
  2420. char name[32];
  2421. int err;
  2422. if (nid >= 0x0f && nid < 0x11) {
  2423. nid_vol = nid - 0x7;
  2424. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  2425. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  2426. } else if (nid == 0x11) {
  2427. nid_vol = nid - 0x7;
  2428. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  2429. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  2430. } else if (nid >= 0x12 && nid <= 0x15) {
  2431. nid_vol = 0x08;
  2432. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  2433. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  2434. } else
  2435. return 0; /* N/A */
  2436. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  2437. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  2438. return err;
  2439. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  2440. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  2441. return err;
  2442. return 1;
  2443. }
  2444. /* add playback controls from the parsed DAC table */
  2445. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  2446. const struct auto_pin_cfg *cfg)
  2447. {
  2448. hda_nid_t nid;
  2449. int err;
  2450. spec->multiout.num_dacs = 1;
  2451. spec->multiout.dac_nids = spec->private_dac_nids;
  2452. spec->multiout.dac_nids[0] = 0x02;
  2453. nid = cfg->line_out_pins[0];
  2454. if (nid) {
  2455. err = alc260_add_playback_controls(spec, nid, "Front");
  2456. if (err < 0)
  2457. return err;
  2458. }
  2459. nid = cfg->speaker_pin;
  2460. if (nid) {
  2461. err = alc260_add_playback_controls(spec, nid, "Speaker");
  2462. if (err < 0)
  2463. return err;
  2464. }
  2465. nid = cfg->hp_pin;
  2466. if (nid) {
  2467. err = alc260_add_playback_controls(spec, nid, "Headphone");
  2468. if (err < 0)
  2469. return err;
  2470. }
  2471. return 0;
  2472. }
  2473. /* create playback/capture controls for input pins */
  2474. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  2475. const struct auto_pin_cfg *cfg)
  2476. {
  2477. struct hda_input_mux *imux = &spec->private_imux;
  2478. int i, err, idx;
  2479. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2480. if (cfg->input_pins[i] >= 0x12) {
  2481. idx = cfg->input_pins[i] - 0x12;
  2482. err = new_analog_input(spec, cfg->input_pins[i],
  2483. auto_pin_cfg_labels[i], idx, 0x07);
  2484. if (err < 0)
  2485. return err;
  2486. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2487. imux->items[imux->num_items].index = idx;
  2488. imux->num_items++;
  2489. }
  2490. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  2491. idx = cfg->input_pins[i] - 0x09;
  2492. err = new_analog_input(spec, cfg->input_pins[i],
  2493. auto_pin_cfg_labels[i], idx, 0x07);
  2494. if (err < 0)
  2495. return err;
  2496. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2497. imux->items[imux->num_items].index = idx;
  2498. imux->num_items++;
  2499. }
  2500. }
  2501. return 0;
  2502. }
  2503. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  2504. hda_nid_t nid, int pin_type,
  2505. int sel_idx)
  2506. {
  2507. /* set as output */
  2508. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2509. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2510. /* need the manual connection? */
  2511. if (nid >= 0x12) {
  2512. int idx = nid - 0x12;
  2513. snd_hda_codec_write(codec, idx + 0x0b, 0,
  2514. AC_VERB_SET_CONNECT_SEL, sel_idx);
  2515. }
  2516. }
  2517. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  2518. {
  2519. struct alc_spec *spec = codec->spec;
  2520. hda_nid_t nid;
  2521. nid = spec->autocfg.line_out_pins[0];
  2522. if (nid)
  2523. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  2524. nid = spec->autocfg.speaker_pin;
  2525. if (nid)
  2526. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  2527. nid = spec->autocfg.hp_pin;
  2528. if (nid)
  2529. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  2530. }
  2531. #define ALC260_PIN_CD_NID 0x16
  2532. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  2533. {
  2534. struct alc_spec *spec = codec->spec;
  2535. int i;
  2536. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2537. hda_nid_t nid = spec->autocfg.input_pins[i];
  2538. if (nid >= 0x12) {
  2539. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2540. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2541. if (nid != ALC260_PIN_CD_NID)
  2542. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2543. AMP_OUT_MUTE);
  2544. }
  2545. }
  2546. }
  2547. /*
  2548. * generic initialization of ADC, input mixers and output mixers
  2549. */
  2550. static struct hda_verb alc260_volume_init_verbs[] = {
  2551. /*
  2552. * Unmute ADC0-1 and set the default input to mic-in
  2553. */
  2554. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  2555. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2556. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  2557. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2558. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  2559. * mixer widget
  2560. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  2561. * mic (mic 2)
  2562. */
  2563. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  2564. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2565. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2566. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2567. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  2568. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2569. /*
  2570. * Set up output mixers (0x08 - 0x0a)
  2571. */
  2572. /* set vol=0 to output mixers */
  2573. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2574. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2575. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2576. /* set up input amps for analog loopback */
  2577. /* Amp Indices: DAC = 0, mixer = 1 */
  2578. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2579. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2580. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2581. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2582. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2583. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2584. { }
  2585. };
  2586. static int alc260_parse_auto_config(struct hda_codec *codec)
  2587. {
  2588. struct alc_spec *spec = codec->spec;
  2589. unsigned int wcap;
  2590. int err;
  2591. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  2592. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2593. alc260_ignore)) < 0)
  2594. return err;
  2595. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  2596. return err;
  2597. if (! spec->kctl_alloc)
  2598. return 0; /* can't find valid BIOS pin config */
  2599. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2600. return err;
  2601. spec->multiout.max_channels = 2;
  2602. if (spec->autocfg.dig_out_pin)
  2603. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  2604. if (spec->kctl_alloc)
  2605. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2606. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  2607. spec->input_mux = &spec->private_imux;
  2608. /* check whether NID 0x04 is valid */
  2609. wcap = get_wcaps(codec, 0x04);
  2610. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2611. if (wcap != AC_WID_AUD_IN) {
  2612. spec->adc_nids = alc260_adc_nids_alt;
  2613. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  2614. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  2615. } else {
  2616. spec->adc_nids = alc260_adc_nids;
  2617. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  2618. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  2619. }
  2620. spec->num_mixers++;
  2621. return 1;
  2622. }
  2623. /* init callback for auto-configuration model -- overriding the default init */
  2624. static int alc260_auto_init(struct hda_codec *codec)
  2625. {
  2626. alc_init(codec);
  2627. alc260_auto_init_multi_out(codec);
  2628. alc260_auto_init_analog_input(codec);
  2629. return 0;
  2630. }
  2631. /*
  2632. * ALC260 configurations
  2633. */
  2634. static struct hda_board_config alc260_cfg_tbl[] = {
  2635. { .modelname = "basic", .config = ALC260_BASIC },
  2636. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
  2637. .config = ALC260_BASIC }, /* Sony VAIO */
  2638. { .modelname = "hp", .config = ALC260_HP },
  2639. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
  2640. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
  2641. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
  2642. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
  2643. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
  2644. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
  2645. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
  2646. { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
  2647. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
  2648. { .modelname = "auto", .config = ALC260_AUTO },
  2649. {}
  2650. };
  2651. static struct alc_config_preset alc260_presets[] = {
  2652. [ALC260_BASIC] = {
  2653. .mixers = { alc260_base_output_mixer,
  2654. alc260_input_mixer,
  2655. alc260_pc_beep_mixer,
  2656. alc260_capture_mixer },
  2657. .init_verbs = { alc260_init_verbs },
  2658. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  2659. .dac_nids = alc260_dac_nids,
  2660. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  2661. .adc_nids = alc260_adc_nids,
  2662. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  2663. .channel_mode = alc260_modes,
  2664. .input_mux = &alc260_capture_source,
  2665. },
  2666. [ALC260_HP] = {
  2667. .mixers = { alc260_base_output_mixer,
  2668. alc260_input_mixer,
  2669. alc260_capture_alt_mixer },
  2670. .init_verbs = { alc260_hp_init_verbs },
  2671. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  2672. .dac_nids = alc260_dac_nids,
  2673. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  2674. .adc_nids = alc260_hp_adc_nids,
  2675. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  2676. .channel_mode = alc260_modes,
  2677. .input_mux = &alc260_capture_source,
  2678. },
  2679. [ALC260_HP_3013] = {
  2680. .mixers = { alc260_hp_3013_mixer,
  2681. alc260_input_mixer,
  2682. alc260_capture_alt_mixer },
  2683. .init_verbs = { alc260_hp_3013_init_verbs },
  2684. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  2685. .dac_nids = alc260_dac_nids,
  2686. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  2687. .adc_nids = alc260_hp_adc_nids,
  2688. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  2689. .channel_mode = alc260_modes,
  2690. .input_mux = &alc260_capture_source,
  2691. },
  2692. [ALC260_FUJITSU_S702X] = {
  2693. .mixers = { alc260_fujitsu_mixer,
  2694. alc260_capture_mixer },
  2695. .init_verbs = { alc260_fujitsu_init_verbs },
  2696. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  2697. .dac_nids = alc260_dac_nids,
  2698. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  2699. .adc_nids = alc260_adc_nids,
  2700. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  2701. .channel_mode = alc260_modes,
  2702. .input_mux = &alc260_fujitsu_capture_source,
  2703. },
  2704. };
  2705. static int patch_alc260(struct hda_codec *codec)
  2706. {
  2707. struct alc_spec *spec;
  2708. int err, board_config;
  2709. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2710. if (spec == NULL)
  2711. return -ENOMEM;
  2712. codec->spec = spec;
  2713. board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
  2714. if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
  2715. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
  2716. board_config = ALC260_AUTO;
  2717. }
  2718. if (board_config == ALC260_AUTO) {
  2719. /* automatic parse from the BIOS config */
  2720. err = alc260_parse_auto_config(codec);
  2721. if (err < 0) {
  2722. alc_free(codec);
  2723. return err;
  2724. } else if (! err) {
  2725. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  2726. board_config = ALC260_BASIC;
  2727. }
  2728. }
  2729. if (board_config != ALC260_AUTO)
  2730. setup_preset(spec, &alc260_presets[board_config]);
  2731. spec->stream_name_analog = "ALC260 Analog";
  2732. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  2733. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  2734. spec->stream_name_digital = "ALC260 Digital";
  2735. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  2736. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  2737. codec->patch_ops = alc_patch_ops;
  2738. if (board_config == ALC260_AUTO)
  2739. codec->patch_ops.init = alc260_auto_init;
  2740. return 0;
  2741. }
  2742. /*
  2743. * ALC882 support
  2744. *
  2745. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  2746. * configuration. Each pin widget can choose any input DACs and a mixer.
  2747. * Each ADC is connected from a mixer of all inputs. This makes possible
  2748. * 6-channel independent captures.
  2749. *
  2750. * In addition, an independent DAC for the multi-playback (not used in this
  2751. * driver yet).
  2752. */
  2753. #define ALC882_DIGOUT_NID 0x06
  2754. #define ALC882_DIGIN_NID 0x0a
  2755. static struct hda_channel_mode alc882_ch_modes[1] = {
  2756. { 8, NULL }
  2757. };
  2758. static hda_nid_t alc882_dac_nids[4] = {
  2759. /* front, rear, clfe, rear_surr */
  2760. 0x02, 0x03, 0x04, 0x05
  2761. };
  2762. /* identical with ALC880 */
  2763. #define alc882_adc_nids alc880_adc_nids
  2764. #define alc882_adc_nids_alt alc880_adc_nids_alt
  2765. /* input MUX */
  2766. /* FIXME: should be a matrix-type input source selection */
  2767. static struct hda_input_mux alc882_capture_source = {
  2768. .num_items = 4,
  2769. .items = {
  2770. { "Mic", 0x0 },
  2771. { "Front Mic", 0x1 },
  2772. { "Line", 0x2 },
  2773. { "CD", 0x4 },
  2774. },
  2775. };
  2776. #define alc882_mux_enum_info alc_mux_enum_info
  2777. #define alc882_mux_enum_get alc_mux_enum_get
  2778. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  2779. {
  2780. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2781. struct alc_spec *spec = codec->spec;
  2782. const struct hda_input_mux *imux = spec->input_mux;
  2783. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  2784. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  2785. hda_nid_t nid = capture_mixers[adc_idx];
  2786. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  2787. unsigned int i, idx;
  2788. idx = ucontrol->value.enumerated.item[0];
  2789. if (idx >= imux->num_items)
  2790. idx = imux->num_items - 1;
  2791. if (*cur_val == idx && ! codec->in_resume)
  2792. return 0;
  2793. for (i = 0; i < imux->num_items; i++) {
  2794. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  2795. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2796. v | (imux->items[i].index << 8));
  2797. }
  2798. *cur_val = idx;
  2799. return 1;
  2800. }
  2801. /*
  2802. * 6ch mode
  2803. */
  2804. static struct hda_verb alc882_sixstack_ch6_init[] = {
  2805. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  2806. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  2807. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  2808. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  2809. { } /* end */
  2810. };
  2811. /*
  2812. * 8ch mode
  2813. */
  2814. static struct hda_verb alc882_sixstack_ch8_init[] = {
  2815. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  2816. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  2817. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  2818. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  2819. { } /* end */
  2820. };
  2821. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  2822. { 6, alc882_sixstack_ch6_init },
  2823. { 8, alc882_sixstack_ch8_init },
  2824. };
  2825. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  2826. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  2827. */
  2828. static struct snd_kcontrol_new alc882_base_mixer[] = {
  2829. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2830. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2831. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2832. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2833. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  2834. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  2835. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  2836. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  2837. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2838. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2839. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  2840. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  2841. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  2842. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  2843. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  2844. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2845. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2846. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2847. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2848. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  2849. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  2850. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  2851. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  2852. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  2853. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  2854. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  2855. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  2856. {
  2857. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2858. /* .name = "Capture Source", */
  2859. .name = "Input Source",
  2860. .count = 3,
  2861. .info = alc882_mux_enum_info,
  2862. .get = alc882_mux_enum_get,
  2863. .put = alc882_mux_enum_put,
  2864. },
  2865. { } /* end */
  2866. };
  2867. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  2868. {
  2869. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2870. .name = "Channel Mode",
  2871. .info = alc_ch_mode_info,
  2872. .get = alc_ch_mode_get,
  2873. .put = alc_ch_mode_put,
  2874. },
  2875. { } /* end */
  2876. };
  2877. static struct hda_verb alc882_init_verbs[] = {
  2878. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  2879. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2880. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2881. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2882. /* Rear mixer */
  2883. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2884. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2885. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2886. /* CLFE mixer */
  2887. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2888. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2889. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2890. /* Side mixer */
  2891. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2892. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2893. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2894. /* Front Pin: output 0 (0x0c) */
  2895. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2896. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2897. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  2898. /* Rear Pin: output 1 (0x0d) */
  2899. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2900. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2901. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  2902. /* CLFE Pin: output 2 (0x0e) */
  2903. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2904. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2905. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  2906. /* Side Pin: output 3 (0x0f) */
  2907. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2908. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2909. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  2910. /* Mic (rear) pin: input vref at 80% */
  2911. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2912. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2913. /* Front Mic pin: input vref at 80% */
  2914. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2915. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2916. /* Line In pin: input */
  2917. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2918. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2919. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  2920. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2921. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2922. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  2923. /* CD pin widget for input */
  2924. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2925. /* FIXME: use matrix-type input source selection */
  2926. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  2927. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  2928. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2929. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2930. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2931. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2932. /* Input mixer2 */
  2933. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2934. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2935. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2936. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2937. /* Input mixer3 */
  2938. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2939. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2940. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2941. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2942. /* ADC1: mute amp left and right */
  2943. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2944. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2945. /* ADC2: mute amp left and right */
  2946. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2947. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2948. /* ADC3: mute amp left and right */
  2949. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2950. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2951. { }
  2952. };
  2953. /*
  2954. * generic initialization of ADC, input mixers and output mixers
  2955. */
  2956. static struct hda_verb alc882_auto_init_verbs[] = {
  2957. /*
  2958. * Unmute ADC0-2 and set the default input to mic-in
  2959. */
  2960. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2961. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2962. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2963. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2964. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2965. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2966. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  2967. * mixer widget
  2968. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  2969. * mic (mic 2)
  2970. */
  2971. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  2972. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2973. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2974. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2975. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  2976. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2977. /*
  2978. * Set up output mixers (0x0c - 0x0f)
  2979. */
  2980. /* set vol=0 to output mixers */
  2981. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2982. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2983. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2984. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2985. /* set up input amps for analog loopback */
  2986. /* Amp Indices: DAC = 0, mixer = 1 */
  2987. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2988. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2989. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2990. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2991. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2992. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2993. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2994. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2995. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2996. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2997. /* FIXME: use matrix-type input source selection */
  2998. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  2999. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3000. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3001. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3002. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3003. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3004. /* Input mixer2 */
  3005. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3006. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3007. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3008. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3009. /* Input mixer3 */
  3010. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3011. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3012. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3013. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3014. { }
  3015. };
  3016. /* capture mixer elements */
  3017. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  3018. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3019. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3020. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  3021. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  3022. {
  3023. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3024. /* The multiple "Capture Source" controls confuse alsamixer
  3025. * So call somewhat different..
  3026. * FIXME: the controls appear in the "playback" view!
  3027. */
  3028. /* .name = "Capture Source", */
  3029. .name = "Input Source",
  3030. .count = 2,
  3031. .info = alc882_mux_enum_info,
  3032. .get = alc882_mux_enum_get,
  3033. .put = alc882_mux_enum_put,
  3034. },
  3035. { } /* end */
  3036. };
  3037. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  3038. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  3039. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  3040. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  3041. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  3042. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  3043. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  3044. {
  3045. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3046. /* The multiple "Capture Source" controls confuse alsamixer
  3047. * So call somewhat different..
  3048. * FIXME: the controls appear in the "playback" view!
  3049. */
  3050. /* .name = "Capture Source", */
  3051. .name = "Input Source",
  3052. .count = 3,
  3053. .info = alc882_mux_enum_info,
  3054. .get = alc882_mux_enum_get,
  3055. .put = alc882_mux_enum_put,
  3056. },
  3057. { } /* end */
  3058. };
  3059. /* pcm configuration: identiacal with ALC880 */
  3060. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  3061. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  3062. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  3063. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  3064. /*
  3065. * configuration and preset
  3066. */
  3067. static struct hda_board_config alc882_cfg_tbl[] = {
  3068. { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
  3069. { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
  3070. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
  3071. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
  3072. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
  3073. { .modelname = "auto", .config = ALC882_AUTO },
  3074. {}
  3075. };
  3076. static struct alc_config_preset alc882_presets[] = {
  3077. [ALC882_3ST_DIG] = {
  3078. .mixers = { alc882_base_mixer },
  3079. .init_verbs = { alc882_init_verbs },
  3080. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  3081. .dac_nids = alc882_dac_nids,
  3082. .dig_out_nid = ALC882_DIGOUT_NID,
  3083. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  3084. .adc_nids = alc882_adc_nids,
  3085. .dig_in_nid = ALC882_DIGIN_NID,
  3086. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  3087. .channel_mode = alc882_ch_modes,
  3088. .input_mux = &alc882_capture_source,
  3089. },
  3090. [ALC882_6ST_DIG] = {
  3091. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  3092. .init_verbs = { alc882_init_verbs },
  3093. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  3094. .dac_nids = alc882_dac_nids,
  3095. .dig_out_nid = ALC882_DIGOUT_NID,
  3096. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  3097. .adc_nids = alc882_adc_nids,
  3098. .dig_in_nid = ALC882_DIGIN_NID,
  3099. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  3100. .channel_mode = alc882_sixstack_modes,
  3101. .input_mux = &alc882_capture_source,
  3102. },
  3103. };
  3104. /*
  3105. * BIOS auto configuration
  3106. */
  3107. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  3108. hda_nid_t nid, int pin_type,
  3109. int dac_idx)
  3110. {
  3111. /* set as output */
  3112. struct alc_spec *spec = codec->spec;
  3113. int idx;
  3114. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  3115. idx = 4;
  3116. else
  3117. idx = spec->multiout.dac_nids[dac_idx] - 2;
  3118. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3119. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3120. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  3121. }
  3122. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  3123. {
  3124. struct alc_spec *spec = codec->spec;
  3125. int i;
  3126. for (i = 0; i <= HDA_SIDE; i++) {
  3127. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3128. if (nid)
  3129. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  3130. }
  3131. }
  3132. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  3133. {
  3134. struct alc_spec *spec = codec->spec;
  3135. hda_nid_t pin;
  3136. pin = spec->autocfg.hp_pin;
  3137. if (pin) /* connect to front */
  3138. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  3139. }
  3140. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  3141. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  3142. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  3143. {
  3144. struct alc_spec *spec = codec->spec;
  3145. int i;
  3146. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3147. hda_nid_t nid = spec->autocfg.input_pins[i];
  3148. if (alc882_is_input_pin(nid)) {
  3149. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3150. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3151. if (nid != ALC882_PIN_CD_NID)
  3152. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3153. AMP_OUT_MUTE);
  3154. }
  3155. }
  3156. }
  3157. /* almost identical with ALC880 parser... */
  3158. static int alc882_parse_auto_config(struct hda_codec *codec)
  3159. {
  3160. struct alc_spec *spec = codec->spec;
  3161. int err = alc880_parse_auto_config(codec);
  3162. if (err < 0)
  3163. return err;
  3164. else if (err > 0)
  3165. /* hack - override the init verbs */
  3166. spec->init_verbs[0] = alc882_auto_init_verbs;
  3167. return err;
  3168. }
  3169. /* init callback for auto-configuration model -- overriding the default init */
  3170. static int alc882_auto_init(struct hda_codec *codec)
  3171. {
  3172. alc_init(codec);
  3173. alc882_auto_init_multi_out(codec);
  3174. alc882_auto_init_hp_out(codec);
  3175. alc882_auto_init_analog_input(codec);
  3176. return 0;
  3177. }
  3178. /*
  3179. * ALC882 Headphone poll in 3.5.1a or 3.5.2
  3180. */
  3181. static int patch_alc882(struct hda_codec *codec)
  3182. {
  3183. struct alc_spec *spec;
  3184. int err, board_config;
  3185. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3186. if (spec == NULL)
  3187. return -ENOMEM;
  3188. codec->spec = spec;
  3189. board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
  3190. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  3191. printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
  3192. board_config = ALC882_AUTO;
  3193. }
  3194. if (board_config == ALC882_AUTO) {
  3195. /* automatic parse from the BIOS config */
  3196. err = alc882_parse_auto_config(codec);
  3197. if (err < 0) {
  3198. alc_free(codec);
  3199. return err;
  3200. } else if (! err) {
  3201. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  3202. board_config = ALC882_3ST_DIG;
  3203. }
  3204. }
  3205. if (board_config != ALC882_AUTO)
  3206. setup_preset(spec, &alc882_presets[board_config]);
  3207. spec->stream_name_analog = "ALC882 Analog";
  3208. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  3209. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  3210. spec->stream_name_digital = "ALC882 Digital";
  3211. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  3212. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  3213. if (! spec->adc_nids && spec->input_mux) {
  3214. /* check whether NID 0x07 is valid */
  3215. unsigned int wcap = get_wcaps(codec, 0x07);
  3216. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3217. if (wcap != AC_WID_AUD_IN) {
  3218. spec->adc_nids = alc882_adc_nids_alt;
  3219. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  3220. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  3221. spec->num_mixers++;
  3222. } else {
  3223. spec->adc_nids = alc882_adc_nids;
  3224. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  3225. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  3226. spec->num_mixers++;
  3227. }
  3228. }
  3229. codec->patch_ops = alc_patch_ops;
  3230. if (board_config == ALC882_AUTO)
  3231. codec->patch_ops.init = alc882_auto_init;
  3232. return 0;
  3233. }
  3234. /*
  3235. * ALC262 support
  3236. */
  3237. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  3238. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  3239. #define alc262_dac_nids alc260_dac_nids
  3240. #define alc262_adc_nids alc882_adc_nids
  3241. #define alc262_adc_nids_alt alc882_adc_nids_alt
  3242. #define alc262_modes alc260_modes
  3243. #define alc262_capture_source alc882_capture_source
  3244. static struct snd_kcontrol_new alc262_base_mixer[] = {
  3245. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3246. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  3247. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3248. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3249. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3250. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3251. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3252. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3253. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  3254. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  3255. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3256. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  3257. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  3258. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3259. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3260. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  3261. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3262. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3263. {
  3264. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3265. .name = "Capture Source",
  3266. .count = 1,
  3267. .info = alc882_mux_enum_info,
  3268. .get = alc882_mux_enum_get,
  3269. .put = alc882_mux_enum_put,
  3270. },
  3271. { } /* end */
  3272. };
  3273. #define alc262_capture_mixer alc882_capture_mixer
  3274. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  3275. /*
  3276. * generic initialization of ADC, input mixers and output mixers
  3277. */
  3278. static struct hda_verb alc262_init_verbs[] = {
  3279. /*
  3280. * Unmute ADC0-2 and set the default input to mic-in
  3281. */
  3282. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3283. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3284. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3285. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3286. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3287. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3288. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3289. * mixer widget
  3290. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3291. * mic (mic 2)
  3292. */
  3293. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3294. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3295. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3296. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3297. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3298. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3299. /*
  3300. * Set up output mixers (0x0c - 0x0e)
  3301. */
  3302. /* set vol=0 to output mixers */
  3303. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3304. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3305. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3306. /* set up input amps for analog loopback */
  3307. /* Amp Indices: DAC = 0, mixer = 1 */
  3308. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3309. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3310. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3311. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3312. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3313. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3314. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3315. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3316. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3317. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3318. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3319. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3320. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3321. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3322. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3323. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3324. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3325. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  3326. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  3327. /* FIXME: use matrix-type input source selection */
  3328. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3329. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3330. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3331. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3332. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3333. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3334. /* Input mixer2 */
  3335. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3336. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3337. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3338. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3339. /* Input mixer3 */
  3340. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3341. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3342. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3343. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3344. { }
  3345. };
  3346. /* add playback controls from the parsed DAC table */
  3347. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  3348. {
  3349. hda_nid_t nid;
  3350. int err;
  3351. spec->multiout.num_dacs = 1; /* only use one dac */
  3352. spec->multiout.dac_nids = spec->private_dac_nids;
  3353. spec->multiout.dac_nids[0] = 2;
  3354. nid = cfg->line_out_pins[0];
  3355. if (nid) {
  3356. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  3357. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  3358. return err;
  3359. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  3360. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  3361. return err;
  3362. }
  3363. nid = cfg->speaker_pin;
  3364. if (nid) {
  3365. if (nid == 0x16) {
  3366. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  3367. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  3368. return err;
  3369. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  3370. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  3371. return err;
  3372. } else {
  3373. if (! cfg->line_out_pins[0])
  3374. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  3375. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  3376. return err;
  3377. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  3378. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  3379. return err;
  3380. }
  3381. }
  3382. nid = cfg->hp_pin;
  3383. if (nid) {
  3384. /* spec->multiout.hp_nid = 2; */
  3385. if (nid == 0x16) {
  3386. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  3387. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  3388. return err;
  3389. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  3390. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  3391. return err;
  3392. } else {
  3393. if (! cfg->line_out_pins[0])
  3394. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  3395. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  3396. return err;
  3397. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  3398. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  3399. return err;
  3400. }
  3401. }
  3402. return 0;
  3403. }
  3404. /* identical with ALC880 */
  3405. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  3406. /*
  3407. * generic initialization of ADC, input mixers and output mixers
  3408. */
  3409. static struct hda_verb alc262_volume_init_verbs[] = {
  3410. /*
  3411. * Unmute ADC0-2 and set the default input to mic-in
  3412. */
  3413. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3414. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3415. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3416. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3417. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3418. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3419. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3420. * mixer widget
  3421. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3422. * mic (mic 2)
  3423. */
  3424. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3425. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3426. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3427. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3428. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3429. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3430. /*
  3431. * Set up output mixers (0x0c - 0x0f)
  3432. */
  3433. /* set vol=0 to output mixers */
  3434. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3435. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3436. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3437. /* set up input amps for analog loopback */
  3438. /* Amp Indices: DAC = 0, mixer = 1 */
  3439. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3440. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3441. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3442. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3443. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3444. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3445. /* FIXME: use matrix-type input source selection */
  3446. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3447. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3448. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3449. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3450. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3451. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3452. /* Input mixer2 */
  3453. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3454. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3455. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3456. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3457. /* Input mixer3 */
  3458. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3459. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3460. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3461. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3462. { }
  3463. };
  3464. /* pcm configuration: identiacal with ALC880 */
  3465. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  3466. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  3467. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  3468. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  3469. /*
  3470. * BIOS auto configuration
  3471. */
  3472. static int alc262_parse_auto_config(struct hda_codec *codec)
  3473. {
  3474. struct alc_spec *spec = codec->spec;
  3475. int err;
  3476. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  3477. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3478. alc262_ignore)) < 0)
  3479. return err;
  3480. if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
  3481. ! spec->autocfg.hp_pin)
  3482. return 0; /* can't find valid BIOS pin config */
  3483. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  3484. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3485. return err;
  3486. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  3487. if (spec->autocfg.dig_out_pin)
  3488. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  3489. if (spec->autocfg.dig_in_pin)
  3490. spec->dig_in_nid = ALC262_DIGIN_NID;
  3491. if (spec->kctl_alloc)
  3492. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3493. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  3494. spec->input_mux = &spec->private_imux;
  3495. return 1;
  3496. }
  3497. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  3498. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  3499. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  3500. /* init callback for auto-configuration model -- overriding the default init */
  3501. static int alc262_auto_init(struct hda_codec *codec)
  3502. {
  3503. alc_init(codec);
  3504. alc262_auto_init_multi_out(codec);
  3505. alc262_auto_init_hp_out(codec);
  3506. alc262_auto_init_analog_input(codec);
  3507. return 0;
  3508. }
  3509. /*
  3510. * configuration and preset
  3511. */
  3512. static struct hda_board_config alc262_cfg_tbl[] = {
  3513. { .modelname = "basic", .config = ALC262_BASIC },
  3514. { .modelname = "auto", .config = ALC262_AUTO },
  3515. {}
  3516. };
  3517. static struct alc_config_preset alc262_presets[] = {
  3518. [ALC262_BASIC] = {
  3519. .mixers = { alc262_base_mixer },
  3520. .init_verbs = { alc262_init_verbs },
  3521. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  3522. .dac_nids = alc262_dac_nids,
  3523. .hp_nid = 0x03,
  3524. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  3525. .channel_mode = alc262_modes,
  3526. .input_mux = &alc262_capture_source,
  3527. },
  3528. };
  3529. static int patch_alc262(struct hda_codec *codec)
  3530. {
  3531. struct alc_spec *spec;
  3532. int board_config;
  3533. int err;
  3534. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  3535. if (spec == NULL)
  3536. return -ENOMEM;
  3537. codec->spec = spec;
  3538. #if 0
  3539. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  3540. {
  3541. int tmp;
  3542. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  3543. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  3544. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  3545. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  3546. }
  3547. #endif
  3548. board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
  3549. if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
  3550. printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
  3551. board_config = ALC262_AUTO;
  3552. }
  3553. if (board_config == ALC262_AUTO) {
  3554. /* automatic parse from the BIOS config */
  3555. err = alc262_parse_auto_config(codec);
  3556. if (err < 0) {
  3557. alc_free(codec);
  3558. return err;
  3559. } else if (! err) {
  3560. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  3561. board_config = ALC262_BASIC;
  3562. }
  3563. }
  3564. if (board_config != ALC262_AUTO)
  3565. setup_preset(spec, &alc262_presets[board_config]);
  3566. spec->stream_name_analog = "ALC262 Analog";
  3567. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  3568. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  3569. spec->stream_name_digital = "ALC262 Digital";
  3570. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  3571. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  3572. if (! spec->adc_nids && spec->input_mux) {
  3573. /* check whether NID 0x07 is valid */
  3574. unsigned int wcap = get_wcaps(codec, 0x07);
  3575. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3576. if (wcap != AC_WID_AUD_IN) {
  3577. spec->adc_nids = alc262_adc_nids_alt;
  3578. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  3579. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  3580. spec->num_mixers++;
  3581. } else {
  3582. spec->adc_nids = alc262_adc_nids;
  3583. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  3584. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  3585. spec->num_mixers++;
  3586. }
  3587. }
  3588. codec->patch_ops = alc_patch_ops;
  3589. if (board_config == ALC262_AUTO)
  3590. codec->patch_ops.init = alc262_auto_init;
  3591. return 0;
  3592. }
  3593. /*
  3594. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  3595. */
  3596. /*
  3597. * set the path ways for 2 channel output
  3598. * need to set the codec line out and mic 1 pin widgets to inputs
  3599. */
  3600. static struct hda_verb alc861_threestack_ch2_init[] = {
  3601. /* set pin widget 1Ah (line in) for input */
  3602. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  3603. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  3604. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  3605. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  3606. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
  3607. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
  3608. { } /* end */
  3609. };
  3610. /*
  3611. * 6ch mode
  3612. * need to set the codec line out and mic 1 pin widgets to outputs
  3613. */
  3614. static struct hda_verb alc861_threestack_ch6_init[] = {
  3615. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  3616. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3617. /* set pin widget 18h (mic1) for output (CLFE)*/
  3618. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3619. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3620. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3621. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  3622. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
  3623. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
  3624. { } /* end */
  3625. };
  3626. static struct hda_channel_mode alc861_threestack_modes[2] = {
  3627. { 2, alc861_threestack_ch2_init },
  3628. { 6, alc861_threestack_ch6_init },
  3629. };
  3630. /* patch-ALC861 */
  3631. static struct snd_kcontrol_new alc861_base_mixer[] = {
  3632. /* output mixer control */
  3633. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  3634. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  3635. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  3636. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  3637. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  3638. /*Input mixer control */
  3639. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  3640. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  3641. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  3642. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  3643. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  3644. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  3645. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  3646. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  3647. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  3648. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  3649. /* Capture mixer control */
  3650. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3651. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3652. {
  3653. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3654. .name = "Capture Source",
  3655. .count = 1,
  3656. .info = alc_mux_enum_info,
  3657. .get = alc_mux_enum_get,
  3658. .put = alc_mux_enum_put,
  3659. },
  3660. { } /* end */
  3661. };
  3662. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  3663. /* output mixer control */
  3664. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  3665. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  3666. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  3667. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  3668. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  3669. /* Input mixer control */
  3670. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  3671. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  3672. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  3673. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  3674. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  3675. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  3676. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  3677. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  3678. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  3679. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  3680. /* Capture mixer control */
  3681. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3682. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3683. {
  3684. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3685. .name = "Capture Source",
  3686. .count = 1,
  3687. .info = alc_mux_enum_info,
  3688. .get = alc_mux_enum_get,
  3689. .put = alc_mux_enum_put,
  3690. },
  3691. {
  3692. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3693. .name = "Channel Mode",
  3694. .info = alc_ch_mode_info,
  3695. .get = alc_ch_mode_get,
  3696. .put = alc_ch_mode_put,
  3697. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  3698. },
  3699. { } /* end */
  3700. };
  3701. /*
  3702. * generic initialization of ADC, input mixers and output mixers
  3703. */
  3704. static struct hda_verb alc861_base_init_verbs[] = {
  3705. /*
  3706. * Unmute ADC0 and set the default input to mic-in
  3707. */
  3708. /* port-A for surround (rear panel) */
  3709. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3710. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3711. /* port-B for mic-in (rear panel) with vref */
  3712. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  3713. /* port-C for line-in (rear panel) */
  3714. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  3715. /* port-D for Front */
  3716. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3717. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3718. /* port-E for HP out (front panel) */
  3719. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  3720. /* route front PCM to HP */
  3721. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  3722. /* port-F for mic-in (front panel) with vref */
  3723. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  3724. /* port-G for CLFE (rear panel) */
  3725. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3726. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3727. /* port-H for side (rear panel) */
  3728. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3729. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3730. /* CD-in */
  3731. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  3732. /* route front mic to ADC1*/
  3733. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3734. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3735. /* Unmute DAC0~3 & spdif out*/
  3736. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3737. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3738. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3739. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3740. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3741. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  3742. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3743. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3744. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3745. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3746. /* Unmute Stereo Mixer 15 */
  3747. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3748. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3749. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3750. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  3751. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3752. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3753. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3754. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3755. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3756. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3757. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3758. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3759. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  3760. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3761. { }
  3762. };
  3763. static struct hda_verb alc861_threestack_init_verbs[] = {
  3764. /*
  3765. * Unmute ADC0 and set the default input to mic-in
  3766. */
  3767. /* port-A for surround (rear panel) */
  3768. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3769. /* port-B for mic-in (rear panel) with vref */
  3770. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  3771. /* port-C for line-in (rear panel) */
  3772. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  3773. /* port-D for Front */
  3774. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  3775. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  3776. /* port-E for HP out (front panel) */
  3777. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  3778. /* route front PCM to HP */
  3779. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  3780. /* port-F for mic-in (front panel) with vref */
  3781. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  3782. /* port-G for CLFE (rear panel) */
  3783. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3784. /* port-H for side (rear panel) */
  3785. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3786. /* CD-in */
  3787. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  3788. /* route front mic to ADC1*/
  3789. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3790. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3791. /* Unmute DAC0~3 & spdif out*/
  3792. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3793. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3794. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3795. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3796. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3797. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  3798. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3799. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3800. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3801. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3802. /* Unmute Stereo Mixer 15 */
  3803. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3804. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3805. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3806. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  3807. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3808. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3809. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3810. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3811. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3812. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3813. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3814. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3815. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  3816. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3817. { }
  3818. };
  3819. /*
  3820. * generic initialization of ADC, input mixers and output mixers
  3821. */
  3822. static struct hda_verb alc861_auto_init_verbs[] = {
  3823. /*
  3824. * Unmute ADC0 and set the default input to mic-in
  3825. */
  3826. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3827. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3828. /* Unmute DAC0~3 & spdif out*/
  3829. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3830. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3831. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3832. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3833. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3834. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  3835. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3836. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3837. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3838. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3839. /* Unmute Stereo Mixer 15 */
  3840. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3841. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3842. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3843. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  3844. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3845. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3846. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3847. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3848. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3849. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3850. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3851. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3852. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3853. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3854. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3855. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3856. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3857. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3858. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3859. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3860. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  3861. { }
  3862. };
  3863. /* pcm configuration: identiacal with ALC880 */
  3864. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  3865. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  3866. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  3867. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  3868. #define ALC861_DIGOUT_NID 0x07
  3869. static struct hda_channel_mode alc861_8ch_modes[1] = {
  3870. { 8, NULL }
  3871. };
  3872. static hda_nid_t alc861_dac_nids[4] = {
  3873. /* front, surround, clfe, side */
  3874. 0x03, 0x06, 0x05, 0x04
  3875. };
  3876. static hda_nid_t alc861_adc_nids[1] = {
  3877. /* ADC0-2 */
  3878. 0x08,
  3879. };
  3880. static struct hda_input_mux alc861_capture_source = {
  3881. .num_items = 5,
  3882. .items = {
  3883. { "Mic", 0x0 },
  3884. { "Front Mic", 0x3 },
  3885. { "Line", 0x1 },
  3886. { "CD", 0x4 },
  3887. { "Mixer", 0x5 },
  3888. },
  3889. };
  3890. /* fill in the dac_nids table from the parsed pin configuration */
  3891. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  3892. {
  3893. int i;
  3894. hda_nid_t nid;
  3895. spec->multiout.dac_nids = spec->private_dac_nids;
  3896. for (i = 0; i < cfg->line_outs; i++) {
  3897. nid = cfg->line_out_pins[i];
  3898. if (nid) {
  3899. if (i >= ARRAY_SIZE(alc861_dac_nids))
  3900. continue;
  3901. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  3902. }
  3903. }
  3904. spec->multiout.num_dacs = cfg->line_outs;
  3905. return 0;
  3906. }
  3907. /* add playback controls from the parsed DAC table */
  3908. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  3909. const struct auto_pin_cfg *cfg)
  3910. {
  3911. char name[32];
  3912. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  3913. hda_nid_t nid;
  3914. int i, idx, err;
  3915. for (i = 0; i < cfg->line_outs; i++) {
  3916. nid = spec->multiout.dac_nids[i];
  3917. if (! nid)
  3918. continue;
  3919. if (nid == 0x05) {
  3920. /* Center/LFE */
  3921. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  3922. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  3923. return err;
  3924. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  3925. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  3926. return err;
  3927. } else {
  3928. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  3929. if (nid == alc861_dac_nids[idx])
  3930. break;
  3931. sprintf(name, "%s Playback Switch", chname[idx]);
  3932. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  3933. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  3934. return err;
  3935. }
  3936. }
  3937. return 0;
  3938. }
  3939. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  3940. {
  3941. int err;
  3942. hda_nid_t nid;
  3943. if (! pin)
  3944. return 0;
  3945. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  3946. nid = 0x03;
  3947. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  3948. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  3949. return err;
  3950. spec->multiout.hp_nid = nid;
  3951. }
  3952. return 0;
  3953. }
  3954. /* create playback/capture controls for input pins */
  3955. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  3956. {
  3957. struct hda_input_mux *imux = &spec->private_imux;
  3958. int i, err, idx, idx1;
  3959. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3960. switch(cfg->input_pins[i]) {
  3961. case 0x0c:
  3962. idx1 = 1;
  3963. idx = 2; // Line In
  3964. break;
  3965. case 0x0f:
  3966. idx1 = 2;
  3967. idx = 2; // Line In
  3968. break;
  3969. case 0x0d:
  3970. idx1 = 0;
  3971. idx = 1; // Mic In
  3972. break;
  3973. case 0x10:
  3974. idx1 = 3;
  3975. idx = 1; // Mic In
  3976. break;
  3977. case 0x11:
  3978. idx1 = 4;
  3979. idx = 0; // CD
  3980. break;
  3981. default:
  3982. continue;
  3983. }
  3984. err = new_analog_input(spec, cfg->input_pins[i],
  3985. auto_pin_cfg_labels[i], idx, 0x15);
  3986. if (err < 0)
  3987. return err;
  3988. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3989. imux->items[imux->num_items].index = idx1;
  3990. imux->num_items++;
  3991. }
  3992. return 0;
  3993. }
  3994. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  3995. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3996. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3997. {
  3998. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3999. /* The multiple "Capture Source" controls confuse alsamixer
  4000. * So call somewhat different..
  4001. *FIXME: the controls appear in the "playback" view!
  4002. */
  4003. /* .name = "Capture Source", */
  4004. .name = "Input Source",
  4005. .count = 1,
  4006. .info = alc_mux_enum_info,
  4007. .get = alc_mux_enum_get,
  4008. .put = alc_mux_enum_put,
  4009. },
  4010. { } /* end */
  4011. };
  4012. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  4013. int pin_type, int dac_idx)
  4014. {
  4015. /* set as output */
  4016. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4017. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4018. }
  4019. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  4020. {
  4021. struct alc_spec *spec = codec->spec;
  4022. int i;
  4023. for (i = 0; i < spec->autocfg.line_outs; i++) {
  4024. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4025. if (nid)
  4026. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  4027. }
  4028. }
  4029. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  4030. {
  4031. struct alc_spec *spec = codec->spec;
  4032. hda_nid_t pin;
  4033. pin = spec->autocfg.hp_pin;
  4034. if (pin) /* connect to front */
  4035. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  4036. }
  4037. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  4038. {
  4039. struct alc_spec *spec = codec->spec;
  4040. int i;
  4041. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4042. hda_nid_t nid = spec->autocfg.input_pins[i];
  4043. if ((nid>=0x0c) && (nid <=0x11)) {
  4044. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4045. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4046. }
  4047. }
  4048. }
  4049. /* parse the BIOS configuration and set up the alc_spec */
  4050. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  4051. static int alc861_parse_auto_config(struct hda_codec *codec)
  4052. {
  4053. struct alc_spec *spec = codec->spec;
  4054. int err;
  4055. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  4056. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4057. alc861_ignore)) < 0)
  4058. return err;
  4059. if (! spec->autocfg.line_outs && ! spec->autocfg.speaker_pin &&
  4060. ! spec->autocfg.hp_pin)
  4061. return 0; /* can't find valid BIOS pin config */
  4062. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  4063. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  4064. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
  4065. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  4066. return err;
  4067. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  4068. if (spec->autocfg.dig_out_pin)
  4069. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  4070. if (spec->kctl_alloc)
  4071. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4072. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  4073. spec->input_mux = &spec->private_imux;
  4074. spec->adc_nids = alc861_adc_nids;
  4075. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  4076. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  4077. spec->num_mixers++;
  4078. return 1;
  4079. }
  4080. /* init callback for auto-configuration model -- overriding the default init */
  4081. static int alc861_auto_init(struct hda_codec *codec)
  4082. {
  4083. alc_init(codec);
  4084. alc861_auto_init_multi_out(codec);
  4085. alc861_auto_init_hp_out(codec);
  4086. alc861_auto_init_analog_input(codec);
  4087. return 0;
  4088. }
  4089. /*
  4090. * configuration and preset
  4091. */
  4092. static struct hda_board_config alc861_cfg_tbl[] = {
  4093. { .modelname = "3stack", .config = ALC861_3ST },
  4094. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
  4095. { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
  4096. { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
  4097. { .modelname = "auto", .config = ALC861_AUTO },
  4098. {}
  4099. };
  4100. static struct alc_config_preset alc861_presets[] = {
  4101. [ALC861_3ST] = {
  4102. .mixers = { alc861_3ST_mixer },
  4103. .init_verbs = { alc861_threestack_init_verbs },
  4104. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  4105. .dac_nids = alc861_dac_nids,
  4106. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  4107. .channel_mode = alc861_threestack_modes,
  4108. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  4109. .adc_nids = alc861_adc_nids,
  4110. .input_mux = &alc861_capture_source,
  4111. },
  4112. [ALC861_3ST_DIG] = {
  4113. .mixers = { alc861_base_mixer },
  4114. .init_verbs = { alc861_threestack_init_verbs },
  4115. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  4116. .dac_nids = alc861_dac_nids,
  4117. .dig_out_nid = ALC861_DIGOUT_NID,
  4118. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  4119. .channel_mode = alc861_threestack_modes,
  4120. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  4121. .adc_nids = alc861_adc_nids,
  4122. .input_mux = &alc861_capture_source,
  4123. },
  4124. [ALC861_6ST_DIG] = {
  4125. .mixers = { alc861_base_mixer },
  4126. .init_verbs = { alc861_base_init_verbs },
  4127. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  4128. .dac_nids = alc861_dac_nids,
  4129. .dig_out_nid = ALC861_DIGOUT_NID,
  4130. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  4131. .channel_mode = alc861_8ch_modes,
  4132. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  4133. .adc_nids = alc861_adc_nids,
  4134. .input_mux = &alc861_capture_source,
  4135. },
  4136. };
  4137. static int patch_alc861(struct hda_codec *codec)
  4138. {
  4139. struct alc_spec *spec;
  4140. int board_config;
  4141. int err;
  4142. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  4143. if (spec == NULL)
  4144. return -ENOMEM;
  4145. codec->spec = spec;
  4146. board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
  4147. if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
  4148. printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
  4149. board_config = ALC861_AUTO;
  4150. }
  4151. if (board_config == ALC861_AUTO) {
  4152. /* automatic parse from the BIOS config */
  4153. err = alc861_parse_auto_config(codec);
  4154. if (err < 0) {
  4155. alc_free(codec);
  4156. return err;
  4157. } else if (! err) {
  4158. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  4159. board_config = ALC861_3ST_DIG;
  4160. }
  4161. }
  4162. if (board_config != ALC861_AUTO)
  4163. setup_preset(spec, &alc861_presets[board_config]);
  4164. spec->stream_name_analog = "ALC861 Analog";
  4165. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  4166. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  4167. spec->stream_name_digital = "ALC861 Digital";
  4168. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  4169. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  4170. codec->patch_ops = alc_patch_ops;
  4171. if (board_config == ALC861_AUTO)
  4172. codec->patch_ops.init = alc861_auto_init;
  4173. return 0;
  4174. }
  4175. /*
  4176. * patch entries
  4177. */
  4178. struct hda_codec_preset snd_hda_preset_realtek[] = {
  4179. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  4180. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  4181. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  4182. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  4183. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
  4184. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  4185. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  4186. {} /* terminator */
  4187. };