patch_realtek.c 189 KB

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