patch_realtek.c 188 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539
  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 = 0x1043, .pci_subdevice = 0x8181, .config = ALC880_ASUS_DIG }, /* ASUS P4GPL-X */
  1841. { .pci_subvendor = 0x1558, .pci_subdevice = 0x5401, .config = ALC880_ASUS_DIG2 },
  1842. { .modelname = "uniwill", .config = ALC880_UNIWILL_DIG },
  1843. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9050, .config = ALC880_UNIWILL_DIG },
  1844. { .modelname = "F1734", .config = ALC880_F1734 },
  1845. { .pci_subvendor = 0x1734, .pci_subdevice = 0x107c, .config = ALC880_F1734 },
  1846. { .pci_subvendor = 0x1584, .pci_subdevice = 0x9054, .config = ALC880_F1734 },
  1847. { .modelname = "lg", .config = ALC880_LG },
  1848. { .pci_subvendor = 0x1854, .pci_subdevice = 0x003b, .config = ALC880_LG },
  1849. #ifdef CONFIG_SND_DEBUG
  1850. { .modelname = "test", .config = ALC880_TEST },
  1851. #endif
  1852. { .modelname = "auto", .config = ALC880_AUTO },
  1853. {}
  1854. };
  1855. /*
  1856. * ALC880 codec presets
  1857. */
  1858. static struct alc_config_preset alc880_presets[] = {
  1859. [ALC880_3ST] = {
  1860. .mixers = { alc880_three_stack_mixer },
  1861. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1862. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1863. .dac_nids = alc880_dac_nids,
  1864. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1865. .channel_mode = alc880_threestack_modes,
  1866. .input_mux = &alc880_capture_source,
  1867. },
  1868. [ALC880_3ST_DIG] = {
  1869. .mixers = { alc880_three_stack_mixer },
  1870. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  1871. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1872. .dac_nids = alc880_dac_nids,
  1873. .dig_out_nid = ALC880_DIGOUT_NID,
  1874. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  1875. .channel_mode = alc880_threestack_modes,
  1876. .input_mux = &alc880_capture_source,
  1877. },
  1878. [ALC880_TCL_S700] = {
  1879. .mixers = { alc880_tcl_s700_mixer },
  1880. .init_verbs = { alc880_volume_init_verbs,
  1881. alc880_pin_tcl_S700_init_verbs,
  1882. alc880_gpio2_init_verbs },
  1883. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1884. .dac_nids = alc880_dac_nids,
  1885. .hp_nid = 0x03,
  1886. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1887. .channel_mode = alc880_2_jack_modes,
  1888. .input_mux = &alc880_capture_source,
  1889. },
  1890. [ALC880_5ST] = {
  1891. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  1892. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1893. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1894. .dac_nids = alc880_dac_nids,
  1895. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1896. .channel_mode = alc880_fivestack_modes,
  1897. .input_mux = &alc880_capture_source,
  1898. },
  1899. [ALC880_5ST_DIG] = {
  1900. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  1901. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  1902. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  1903. .dac_nids = alc880_dac_nids,
  1904. .dig_out_nid = ALC880_DIGOUT_NID,
  1905. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  1906. .channel_mode = alc880_fivestack_modes,
  1907. .input_mux = &alc880_capture_source,
  1908. },
  1909. [ALC880_6ST] = {
  1910. .mixers = { alc880_six_stack_mixer },
  1911. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1912. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1913. .dac_nids = alc880_6st_dac_nids,
  1914. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1915. .channel_mode = alc880_sixstack_modes,
  1916. .input_mux = &alc880_6stack_capture_source,
  1917. },
  1918. [ALC880_6ST_DIG] = {
  1919. .mixers = { alc880_six_stack_mixer },
  1920. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  1921. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  1922. .dac_nids = alc880_6st_dac_nids,
  1923. .dig_out_nid = ALC880_DIGOUT_NID,
  1924. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  1925. .channel_mode = alc880_sixstack_modes,
  1926. .input_mux = &alc880_6stack_capture_source,
  1927. },
  1928. [ALC880_W810] = {
  1929. .mixers = { alc880_w810_base_mixer },
  1930. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  1931. alc880_gpio2_init_verbs },
  1932. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  1933. .dac_nids = alc880_w810_dac_nids,
  1934. .dig_out_nid = ALC880_DIGOUT_NID,
  1935. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  1936. .channel_mode = alc880_w810_modes,
  1937. .input_mux = &alc880_capture_source,
  1938. },
  1939. [ALC880_Z71V] = {
  1940. .mixers = { alc880_z71v_mixer },
  1941. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  1942. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  1943. .dac_nids = alc880_z71v_dac_nids,
  1944. .dig_out_nid = ALC880_DIGOUT_NID,
  1945. .hp_nid = 0x03,
  1946. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1947. .channel_mode = alc880_2_jack_modes,
  1948. .input_mux = &alc880_capture_source,
  1949. },
  1950. [ALC880_F1734] = {
  1951. .mixers = { alc880_f1734_mixer },
  1952. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  1953. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  1954. .dac_nids = alc880_f1734_dac_nids,
  1955. .hp_nid = 0x02,
  1956. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  1957. .channel_mode = alc880_2_jack_modes,
  1958. .input_mux = &alc880_capture_source,
  1959. },
  1960. [ALC880_ASUS] = {
  1961. .mixers = { alc880_asus_mixer },
  1962. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1963. alc880_gpio1_init_verbs },
  1964. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1965. .dac_nids = alc880_asus_dac_nids,
  1966. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1967. .channel_mode = alc880_asus_modes,
  1968. .input_mux = &alc880_capture_source,
  1969. },
  1970. [ALC880_ASUS_DIG] = {
  1971. .mixers = { alc880_asus_mixer },
  1972. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1973. alc880_gpio1_init_verbs },
  1974. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1975. .dac_nids = alc880_asus_dac_nids,
  1976. .dig_out_nid = ALC880_DIGOUT_NID,
  1977. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1978. .channel_mode = alc880_asus_modes,
  1979. .input_mux = &alc880_capture_source,
  1980. },
  1981. [ALC880_ASUS_DIG2] = {
  1982. .mixers = { alc880_asus_mixer },
  1983. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1984. alc880_gpio2_init_verbs }, /* use GPIO2 */
  1985. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1986. .dac_nids = alc880_asus_dac_nids,
  1987. .dig_out_nid = ALC880_DIGOUT_NID,
  1988. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  1989. .channel_mode = alc880_asus_modes,
  1990. .input_mux = &alc880_capture_source,
  1991. },
  1992. [ALC880_ASUS_W1V] = {
  1993. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  1994. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  1995. alc880_gpio1_init_verbs },
  1996. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  1997. .dac_nids = alc880_asus_dac_nids,
  1998. .dig_out_nid = ALC880_DIGOUT_NID,
  1999. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2000. .channel_mode = alc880_asus_modes,
  2001. .input_mux = &alc880_capture_source,
  2002. },
  2003. [ALC880_UNIWILL_DIG] = {
  2004. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2005. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs },
  2006. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2007. .dac_nids = alc880_asus_dac_nids,
  2008. .dig_out_nid = ALC880_DIGOUT_NID,
  2009. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2010. .channel_mode = alc880_asus_modes,
  2011. .input_mux = &alc880_capture_source,
  2012. },
  2013. [ALC880_CLEVO] = {
  2014. .mixers = { alc880_three_stack_mixer },
  2015. .init_verbs = { alc880_volume_init_verbs,
  2016. alc880_pin_clevo_init_verbs },
  2017. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2018. .dac_nids = alc880_dac_nids,
  2019. .hp_nid = 0x03,
  2020. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2021. .channel_mode = alc880_threestack_modes,
  2022. .input_mux = &alc880_capture_source,
  2023. },
  2024. [ALC880_LG] = {
  2025. .mixers = { alc880_lg_mixer },
  2026. .init_verbs = { alc880_volume_init_verbs,
  2027. alc880_lg_init_verbs },
  2028. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2029. .dac_nids = alc880_lg_dac_nids,
  2030. .dig_out_nid = ALC880_DIGOUT_NID,
  2031. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2032. .channel_mode = alc880_lg_ch_modes,
  2033. .input_mux = &alc880_lg_capture_source,
  2034. .unsol_event = alc880_lg_unsol_event,
  2035. .init_hook = alc880_lg_automute,
  2036. },
  2037. #ifdef CONFIG_SND_DEBUG
  2038. [ALC880_TEST] = {
  2039. .mixers = { alc880_test_mixer },
  2040. .init_verbs = { alc880_test_init_verbs },
  2041. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2042. .dac_nids = alc880_test_dac_nids,
  2043. .dig_out_nid = ALC880_DIGOUT_NID,
  2044. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2045. .channel_mode = alc880_test_modes,
  2046. .input_mux = &alc880_test_capture_source,
  2047. },
  2048. #endif
  2049. };
  2050. /*
  2051. * Automatic parse of I/O pins from the BIOS configuration
  2052. */
  2053. #define NUM_CONTROL_ALLOC 32
  2054. #define NUM_VERB_ALLOC 32
  2055. enum {
  2056. ALC_CTL_WIDGET_VOL,
  2057. ALC_CTL_WIDGET_MUTE,
  2058. ALC_CTL_BIND_MUTE,
  2059. };
  2060. static struct snd_kcontrol_new alc880_control_templates[] = {
  2061. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2062. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2063. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2064. };
  2065. /* add dynamic controls */
  2066. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  2067. {
  2068. struct snd_kcontrol_new *knew;
  2069. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2070. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2071. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  2072. if (! knew)
  2073. return -ENOMEM;
  2074. if (spec->kctl_alloc) {
  2075. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  2076. kfree(spec->kctl_alloc);
  2077. }
  2078. spec->kctl_alloc = knew;
  2079. spec->num_kctl_alloc = num;
  2080. }
  2081. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2082. *knew = alc880_control_templates[type];
  2083. knew->name = kstrdup(name, GFP_KERNEL);
  2084. if (! knew->name)
  2085. return -ENOMEM;
  2086. knew->private_value = val;
  2087. spec->num_kctl_used++;
  2088. return 0;
  2089. }
  2090. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2091. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2092. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2093. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2094. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2095. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2096. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2097. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2098. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2099. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2100. #define ALC880_PIN_CD_NID 0x1c
  2101. /* fill in the dac_nids table from the parsed pin configuration */
  2102. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  2103. {
  2104. hda_nid_t nid;
  2105. int assigned[4];
  2106. int i, j;
  2107. memset(assigned, 0, sizeof(assigned));
  2108. spec->multiout.dac_nids = spec->private_dac_nids;
  2109. /* check the pins hardwired to audio widget */
  2110. for (i = 0; i < cfg->line_outs; i++) {
  2111. nid = cfg->line_out_pins[i];
  2112. if (alc880_is_fixed_pin(nid)) {
  2113. int idx = alc880_fixed_pin_idx(nid);
  2114. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2115. assigned[idx] = 1;
  2116. }
  2117. }
  2118. /* left pins can be connect to any audio widget */
  2119. for (i = 0; i < cfg->line_outs; i++) {
  2120. nid = cfg->line_out_pins[i];
  2121. if (alc880_is_fixed_pin(nid))
  2122. continue;
  2123. /* search for an empty channel */
  2124. for (j = 0; j < cfg->line_outs; j++) {
  2125. if (! assigned[j]) {
  2126. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  2127. assigned[j] = 1;
  2128. break;
  2129. }
  2130. }
  2131. }
  2132. spec->multiout.num_dacs = cfg->line_outs;
  2133. return 0;
  2134. }
  2135. /* add playback controls from the parsed DAC table */
  2136. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2137. const struct auto_pin_cfg *cfg)
  2138. {
  2139. char name[32];
  2140. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  2141. hda_nid_t nid;
  2142. int i, err;
  2143. for (i = 0; i < cfg->line_outs; i++) {
  2144. if (! spec->multiout.dac_nids[i])
  2145. continue;
  2146. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2147. if (i == 2) {
  2148. /* Center/LFE */
  2149. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  2150. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  2151. return err;
  2152. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  2153. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  2154. return err;
  2155. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  2156. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  2157. return err;
  2158. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  2159. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  2160. return err;
  2161. } else {
  2162. sprintf(name, "%s Playback Volume", chname[i]);
  2163. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2164. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2165. return err;
  2166. sprintf(name, "%s Playback Switch", chname[i]);
  2167. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2168. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2169. return err;
  2170. }
  2171. }
  2172. return 0;
  2173. }
  2174. /* add playback controls for speaker and HP outputs */
  2175. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2176. const char *pfx)
  2177. {
  2178. hda_nid_t nid;
  2179. int err;
  2180. char name[32];
  2181. if (! pin)
  2182. return 0;
  2183. if (alc880_is_fixed_pin(pin)) {
  2184. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2185. /* specify the DAC as the extra output */
  2186. if (! spec->multiout.hp_nid)
  2187. spec->multiout.hp_nid = nid;
  2188. else
  2189. spec->multiout.extra_out_nid[0] = nid;
  2190. /* control HP volume/switch on the output mixer amp */
  2191. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2192. sprintf(name, "%s Playback Volume", pfx);
  2193. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2194. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2195. return err;
  2196. sprintf(name, "%s Playback Switch", pfx);
  2197. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2198. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2199. return err;
  2200. } else if (alc880_is_multi_pin(pin)) {
  2201. /* set manual connection */
  2202. /* we have only a switch on HP-out PIN */
  2203. sprintf(name, "%s Playback Switch", pfx);
  2204. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2205. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  2206. return err;
  2207. }
  2208. return 0;
  2209. }
  2210. /* create input playback/capture controls for the given pin */
  2211. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  2212. int idx, hda_nid_t mix_nid)
  2213. {
  2214. char name[32];
  2215. int err;
  2216. sprintf(name, "%s Playback Volume", ctlname);
  2217. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2218. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2219. return err;
  2220. sprintf(name, "%s Playback Switch", ctlname);
  2221. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2222. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2223. return err;
  2224. return 0;
  2225. }
  2226. /* create playback/capture controls for input pins */
  2227. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2228. const struct auto_pin_cfg *cfg)
  2229. {
  2230. struct hda_input_mux *imux = &spec->private_imux;
  2231. int i, err, idx;
  2232. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2233. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2234. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2235. err = new_analog_input(spec, cfg->input_pins[i],
  2236. auto_pin_cfg_labels[i],
  2237. idx, 0x0b);
  2238. if (err < 0)
  2239. return err;
  2240. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2241. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  2242. imux->num_items++;
  2243. }
  2244. }
  2245. return 0;
  2246. }
  2247. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2248. hda_nid_t nid, int pin_type,
  2249. int dac_idx)
  2250. {
  2251. /* set as output */
  2252. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2253. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2254. /* need the manual connection? */
  2255. if (alc880_is_multi_pin(nid)) {
  2256. struct alc_spec *spec = codec->spec;
  2257. int idx = alc880_multi_pin_idx(nid);
  2258. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2259. AC_VERB_SET_CONNECT_SEL,
  2260. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2261. }
  2262. }
  2263. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2264. {
  2265. struct alc_spec *spec = codec->spec;
  2266. int i;
  2267. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2268. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2269. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  2270. }
  2271. }
  2272. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2273. {
  2274. struct alc_spec *spec = codec->spec;
  2275. hda_nid_t pin;
  2276. pin = spec->autocfg.speaker_pins[0];
  2277. if (pin) /* connect to front */
  2278. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2279. pin = spec->autocfg.hp_pin;
  2280. if (pin) /* connect to front */
  2281. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2282. }
  2283. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2284. {
  2285. struct alc_spec *spec = codec->spec;
  2286. int i;
  2287. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2288. hda_nid_t nid = spec->autocfg.input_pins[i];
  2289. if (alc880_is_input_pin(nid)) {
  2290. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2291. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2292. if (nid != ALC880_PIN_CD_NID)
  2293. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2294. AMP_OUT_MUTE);
  2295. }
  2296. }
  2297. }
  2298. /* parse the BIOS configuration and set up the alc_spec */
  2299. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  2300. static int alc880_parse_auto_config(struct hda_codec *codec)
  2301. {
  2302. struct alc_spec *spec = codec->spec;
  2303. int err;
  2304. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2305. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2306. alc880_ignore)) < 0)
  2307. return err;
  2308. if (! spec->autocfg.line_outs)
  2309. return 0; /* can't find valid BIOS pin config */
  2310. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  2311. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  2312. (err = alc880_auto_create_extra_out(spec,
  2313. spec->autocfg.speaker_pins[0],
  2314. "Speaker")) < 0 ||
  2315. (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pin,
  2316. "Headphone")) < 0 ||
  2317. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2318. return err;
  2319. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2320. if (spec->autocfg.dig_out_pin)
  2321. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2322. if (spec->autocfg.dig_in_pin)
  2323. spec->dig_in_nid = ALC880_DIGIN_NID;
  2324. if (spec->kctl_alloc)
  2325. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2326. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2327. spec->input_mux = &spec->private_imux;
  2328. return 1;
  2329. }
  2330. /* additional initialization for auto-configuration model */
  2331. static void alc880_auto_init(struct hda_codec *codec)
  2332. {
  2333. alc880_auto_init_multi_out(codec);
  2334. alc880_auto_init_extra_out(codec);
  2335. alc880_auto_init_analog_input(codec);
  2336. }
  2337. /*
  2338. * OK, here we have finally the patch for ALC880
  2339. */
  2340. static int patch_alc880(struct hda_codec *codec)
  2341. {
  2342. struct alc_spec *spec;
  2343. int board_config;
  2344. int err;
  2345. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2346. if (spec == NULL)
  2347. return -ENOMEM;
  2348. codec->spec = spec;
  2349. board_config = snd_hda_check_board_config(codec, alc880_cfg_tbl);
  2350. if (board_config < 0 || board_config >= ALC880_MODEL_LAST) {
  2351. printk(KERN_INFO "hda_codec: Unknown model for ALC880, trying auto-probe from BIOS...\n");
  2352. board_config = ALC880_AUTO;
  2353. }
  2354. if (board_config == ALC880_AUTO) {
  2355. /* automatic parse from the BIOS config */
  2356. err = alc880_parse_auto_config(codec);
  2357. if (err < 0) {
  2358. alc_free(codec);
  2359. return err;
  2360. } else if (! err) {
  2361. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using 3-stack mode...\n");
  2362. board_config = ALC880_3ST;
  2363. }
  2364. }
  2365. if (board_config != ALC880_AUTO)
  2366. setup_preset(spec, &alc880_presets[board_config]);
  2367. spec->stream_name_analog = "ALC880 Analog";
  2368. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2369. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2370. spec->stream_name_digital = "ALC880 Digital";
  2371. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2372. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2373. if (! spec->adc_nids && spec->input_mux) {
  2374. /* check whether NID 0x07 is valid */
  2375. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2376. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2377. if (wcap != AC_WID_AUD_IN) {
  2378. spec->adc_nids = alc880_adc_nids_alt;
  2379. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2380. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2381. spec->num_mixers++;
  2382. } else {
  2383. spec->adc_nids = alc880_adc_nids;
  2384. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2385. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2386. spec->num_mixers++;
  2387. }
  2388. }
  2389. codec->patch_ops = alc_patch_ops;
  2390. if (board_config == ALC880_AUTO)
  2391. spec->init_hook = alc880_auto_init;
  2392. return 0;
  2393. }
  2394. /*
  2395. * ALC260 support
  2396. */
  2397. static hda_nid_t alc260_dac_nids[1] = {
  2398. /* front */
  2399. 0x02,
  2400. };
  2401. static hda_nid_t alc260_adc_nids[1] = {
  2402. /* ADC0 */
  2403. 0x04,
  2404. };
  2405. static hda_nid_t alc260_adc_nids_alt[1] = {
  2406. /* ADC1 */
  2407. 0x05,
  2408. };
  2409. static hda_nid_t alc260_hp_adc_nids[2] = {
  2410. /* ADC1, 0 */
  2411. 0x05, 0x04
  2412. };
  2413. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2414. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2415. */
  2416. static hda_nid_t alc260_dual_adc_nids[2] = {
  2417. /* ADC0, ADC1 */
  2418. 0x04, 0x05
  2419. };
  2420. #define ALC260_DIGOUT_NID 0x03
  2421. #define ALC260_DIGIN_NID 0x06
  2422. static struct hda_input_mux alc260_capture_source = {
  2423. .num_items = 4,
  2424. .items = {
  2425. { "Mic", 0x0 },
  2426. { "Front Mic", 0x1 },
  2427. { "Line", 0x2 },
  2428. { "CD", 0x4 },
  2429. },
  2430. };
  2431. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2432. * headphone jack and the internal CD lines.
  2433. */
  2434. static struct hda_input_mux alc260_fujitsu_capture_source = {
  2435. .num_items = 3,
  2436. .items = {
  2437. { "Mic/Line", 0x0 },
  2438. { "CD", 0x4 },
  2439. { "Headphone", 0x2 },
  2440. },
  2441. };
  2442. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configutation to
  2443. * the Fujitsu S702x, but jacks are marked differently. We won't allow
  2444. * retasking the Headphone jack, so it won't be available here.
  2445. */
  2446. static struct hda_input_mux alc260_acer_capture_source = {
  2447. .num_items = 3,
  2448. .items = {
  2449. { "Mic", 0x0 },
  2450. { "Line", 0x2 },
  2451. { "CD", 0x4 },
  2452. },
  2453. };
  2454. /*
  2455. * This is just place-holder, so there's something for alc_build_pcms to look
  2456. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2457. * element which allows changing the channel mode, so the verb list is
  2458. * never used.
  2459. */
  2460. static struct hda_channel_mode alc260_modes[1] = {
  2461. { 2, NULL },
  2462. };
  2463. /* Mixer combinations
  2464. *
  2465. * basic: base_output + input + pc_beep + capture
  2466. * HP: base_output + input + capture_alt
  2467. * HP_3013: hp_3013 + input + capture
  2468. * fujitsu: fujitsu + capture
  2469. * acer: acer + capture
  2470. */
  2471. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2472. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2473. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2474. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2475. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2476. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2477. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2478. { } /* end */
  2479. };
  2480. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2481. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2482. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2483. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2484. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2485. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2486. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2487. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2488. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2489. { } /* end */
  2490. };
  2491. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2492. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2493. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2494. { } /* end */
  2495. };
  2496. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2497. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2498. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2499. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2500. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2501. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2502. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2503. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2504. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2505. { } /* end */
  2506. };
  2507. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2508. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2509. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2510. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2511. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2512. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2513. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2514. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2515. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2516. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2517. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2518. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2519. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2520. { } /* end */
  2521. };
  2522. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  2523. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2524. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  2525. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2526. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2527. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2528. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2529. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2530. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2531. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2532. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2533. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2534. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2535. { } /* end */
  2536. };
  2537. /* capture mixer elements */
  2538. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  2539. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  2540. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  2541. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  2542. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  2543. {
  2544. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2545. /* The multiple "Capture Source" controls confuse alsamixer
  2546. * So call somewhat different..
  2547. * FIXME: the controls appear in the "playback" view!
  2548. */
  2549. /* .name = "Capture Source", */
  2550. .name = "Input Source",
  2551. .count = 2,
  2552. .info = alc_mux_enum_info,
  2553. .get = alc_mux_enum_get,
  2554. .put = alc_mux_enum_put,
  2555. },
  2556. { } /* end */
  2557. };
  2558. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  2559. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  2560. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  2561. {
  2562. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2563. /* The multiple "Capture Source" controls confuse alsamixer
  2564. * So call somewhat different..
  2565. * FIXME: the controls appear in the "playback" view!
  2566. */
  2567. /* .name = "Capture Source", */
  2568. .name = "Input Source",
  2569. .count = 1,
  2570. .info = alc_mux_enum_info,
  2571. .get = alc_mux_enum_get,
  2572. .put = alc_mux_enum_put,
  2573. },
  2574. { } /* end */
  2575. };
  2576. /*
  2577. * initialization verbs
  2578. */
  2579. static struct hda_verb alc260_init_verbs[] = {
  2580. /* Line In pin widget for input */
  2581. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2582. /* CD pin widget for input */
  2583. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2584. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2585. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2586. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2587. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2588. /* LINE-2 is used for line-out in rear */
  2589. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2590. /* select line-out */
  2591. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  2592. /* LINE-OUT pin */
  2593. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2594. /* enable HP */
  2595. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2596. /* enable Mono */
  2597. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2598. /* mute capture amp left and right */
  2599. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2600. /* set connection select to line in (default select for this ADC) */
  2601. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2602. /* mute capture amp left and right */
  2603. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2604. /* set connection select to line in (default select for this ADC) */
  2605. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2606. /* set vol=0 Line-Out mixer amp left and right */
  2607. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2608. /* unmute pin widget amp left and right (no gain on this amp) */
  2609. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2610. /* set vol=0 HP mixer amp left and right */
  2611. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2612. /* unmute pin widget amp left and right (no gain on this amp) */
  2613. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2614. /* set vol=0 Mono mixer amp left and right */
  2615. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2616. /* unmute pin widget amp left and right (no gain on this amp) */
  2617. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2618. /* unmute LINE-2 out pin */
  2619. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2620. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2621. /* mute CD */
  2622. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  2623. /* mute Line In */
  2624. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  2625. /* mute Mic */
  2626. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2627. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2628. /* mute Front out path */
  2629. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2630. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2631. /* mute Headphone out path */
  2632. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2633. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2634. /* mute Mono out path */
  2635. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2636. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2637. { }
  2638. };
  2639. static struct hda_verb alc260_hp_init_verbs[] = {
  2640. /* Headphone and output */
  2641. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2642. /* mono output */
  2643. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2644. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2645. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2646. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2647. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2648. /* Line In pin widget for input */
  2649. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2650. /* Line-2 pin widget for output */
  2651. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2652. /* CD pin widget for input */
  2653. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2654. /* unmute amp left and right */
  2655. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2656. /* set connection select to line in (default select for this ADC) */
  2657. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2658. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2659. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2660. /* mute pin widget amp left and right (no gain on this amp) */
  2661. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2662. /* unmute HP mixer amp left and right (volume = 0) */
  2663. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2664. /* mute pin widget amp left and right (no gain on this amp) */
  2665. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2666. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2667. /* unmute CD */
  2668. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2669. /* unmute Line In */
  2670. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2671. /* unmute Mic */
  2672. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2673. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2674. /* Unmute Front out path */
  2675. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2676. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2677. /* Unmute Headphone out path */
  2678. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2679. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2680. /* Unmute Mono out path */
  2681. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2682. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2683. { }
  2684. };
  2685. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  2686. /* Line out and output */
  2687. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2688. /* mono output */
  2689. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  2690. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  2691. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2692. /* Mic2 (front panel) pin widget for input and vref at 80% */
  2693. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  2694. /* Line In pin widget for input */
  2695. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2696. /* Headphone pin widget for output */
  2697. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  2698. /* CD pin widget for input */
  2699. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  2700. /* unmute amp left and right */
  2701. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  2702. /* set connection select to line in (default select for this ADC) */
  2703. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  2704. /* unmute Line-Out mixer amp left and right (volume = 0) */
  2705. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2706. /* mute pin widget amp left and right (no gain on this amp) */
  2707. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2708. /* unmute HP mixer amp left and right (volume = 0) */
  2709. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  2710. /* mute pin widget amp left and right (no gain on this amp) */
  2711. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  2712. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  2713. /* unmute CD */
  2714. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  2715. /* unmute Line In */
  2716. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  2717. /* unmute Mic */
  2718. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2719. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  2720. /* Unmute Front out path */
  2721. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2722. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2723. /* Unmute Headphone out path */
  2724. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2725. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2726. /* Unmute Mono out path */
  2727. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  2728. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  2729. { }
  2730. };
  2731. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  2732. * laptops.
  2733. */
  2734. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  2735. /* Disable all GPIOs */
  2736. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  2737. /* Internal speaker is connected to headphone pin */
  2738. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2739. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  2740. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2741. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  2742. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2743. /* Ensure all other unused pins are disabled and muted. */
  2744. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2745. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2746. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2747. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2748. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2749. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2750. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2751. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2752. /* Disable digital (SPDIF) pins */
  2753. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2754. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2755. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  2756. * when acting as an output.
  2757. */
  2758. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  2759. /* Start with output sum widgets muted and their output gains at min */
  2760. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2761. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2762. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2763. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2764. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2765. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2766. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2767. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2768. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2769. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  2770. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2771. /* Unmute Line1 pin widget output buffer since it starts as an output.
  2772. * If the pin mode is changed by the user the pin mode control will
  2773. * take care of enabling the pin's input/output buffers as needed.
  2774. * Therefore there's no need to enable the input buffer at this
  2775. * stage.
  2776. */
  2777. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2778. /* Unmute input buffer of pin widget used for Line-in (no equiv
  2779. * mixer ctrl)
  2780. */
  2781. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2782. /* Mute capture amp left and right */
  2783. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2784. /* Set ADC connection select to match default mixer setting - line
  2785. * in (on mic1 pin)
  2786. */
  2787. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  2788. /* Do the same for the second ADC: mute capture input amp and
  2789. * set ADC connection to line in (on mic1 pin)
  2790. */
  2791. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2792. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  2793. /* Mute all inputs to mixer widget (even unconnected ones) */
  2794. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  2795. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  2796. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  2797. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  2798. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  2799. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  2800. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  2801. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  2802. { }
  2803. };
  2804. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  2805. * similar laptops (adapted from Fujitsu init verbs).
  2806. */
  2807. static struct hda_verb alc260_acer_init_verbs[] = {
  2808. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  2809. * the headphone jack. Turn this on and rely on the standard mute
  2810. * methods whenever the user wants to turn these outputs off.
  2811. */
  2812. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  2813. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  2814. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  2815. /* Internal speaker/Headphone jack is connected to Line-out pin */
  2816. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  2817. /* Internal microphone/Mic jack is connected to Mic1 pin */
  2818. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  2819. /* Line In jack is connected to Line1 pin */
  2820. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2821. /* Ensure all other unused pins are disabled and muted. */
  2822. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2823. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2824. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2825. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2826. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2827. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2828. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  2829. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2830. /* Disable digital (SPDIF) pins */
  2831. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2832. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2833. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  2834. * bus when acting as outputs.
  2835. */
  2836. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  2837. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  2838. /* Start with output sum widgets muted and their output gains at min */
  2839. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2840. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2841. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2842. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2843. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2844. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2845. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2846. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2847. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2848. /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
  2849. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2850. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  2851. * inputs. If the pin mode is changed by the user the pin mode control
  2852. * will take care of enabling the pin's input/output buffers as needed.
  2853. * Therefore there's no need to enable the input buffer at this
  2854. * stage.
  2855. */
  2856. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2857. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2858. /* Mute capture amp left and right */
  2859. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2860. /* Set ADC connection select to match default mixer setting - mic
  2861. * (on mic1 pin)
  2862. */
  2863. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  2864. /* Do similar with the second ADC: mute capture input amp and
  2865. * set ADC connection to line (on line1 pin)
  2866. */
  2867. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2868. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  2869. /* Mute all inputs to mixer widget (even unconnected ones) */
  2870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  2871. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  2872. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  2873. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  2874. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  2875. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  2876. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  2877. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  2878. { }
  2879. };
  2880. /* Test configuration for debugging, modelled after the ALC880 test
  2881. * configuration.
  2882. */
  2883. #ifdef CONFIG_SND_DEBUG
  2884. static hda_nid_t alc260_test_dac_nids[1] = {
  2885. 0x02,
  2886. };
  2887. static hda_nid_t alc260_test_adc_nids[2] = {
  2888. 0x04, 0x05,
  2889. };
  2890. /* This is a bit messy since the two input muxes in the ALC260 have slight
  2891. * variations in their signal assignments. The ideal way to deal with this
  2892. * is to extend alc_spec.input_mux to allow a different input MUX for each
  2893. * ADC. For the purposes of the test model it's sufficient to just list
  2894. * both options for affected signal indices. The separate input mux
  2895. * functionality only needs to be considered if a model comes along which
  2896. * actually uses signals 0x5, 0x6 and 0x7 for something which makes sense to
  2897. * record.
  2898. */
  2899. static struct hda_input_mux alc260_test_capture_source = {
  2900. .num_items = 8,
  2901. .items = {
  2902. { "MIC1 pin", 0x0 },
  2903. { "MIC2 pin", 0x1 },
  2904. { "LINE1 pin", 0x2 },
  2905. { "LINE2 pin", 0x3 },
  2906. { "CD pin", 0x4 },
  2907. { "LINE-OUT pin (cap1), Mixer (cap2)", 0x5 },
  2908. { "HP-OUT pin (cap1), LINE-OUT pin (cap2)", 0x6 },
  2909. { "HP-OUT pin (cap2 only)", 0x7 },
  2910. },
  2911. };
  2912. static struct snd_kcontrol_new alc260_test_mixer[] = {
  2913. /* Output driver widgets */
  2914. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2915. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2916. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2917. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  2918. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2919. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  2920. /* Modes for retasking pin widgets */
  2921. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  2922. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  2923. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  2924. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  2925. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  2926. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  2927. /* Loopback mixer controls */
  2928. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  2929. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  2930. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  2931. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  2932. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  2933. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  2934. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  2935. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  2936. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2937. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2938. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2939. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2940. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  2941. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  2942. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  2943. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  2944. /* Controls for GPIO pins, assuming they are configured as outputs */
  2945. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  2946. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  2947. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  2948. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  2949. /* Switches to allow the digital IO pins to be enabled. The datasheet
  2950. * is ambigious as to which NID is which; testing on laptops which
  2951. * make this output available should provide clarification.
  2952. */
  2953. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  2954. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  2955. { } /* end */
  2956. };
  2957. static struct hda_verb alc260_test_init_verbs[] = {
  2958. /* Enable all GPIOs as outputs with an initial value of 0 */
  2959. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  2960. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  2961. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  2962. /* Enable retasking pins as output, initially without power amp */
  2963. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2964. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2965. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2966. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2967. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2968. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2969. /* Disable digital (SPDIF) pins initially, but users can enable
  2970. * them via a mixer switch. In the case of SPDIF-out, this initverb
  2971. * payload also sets the generation to 0, output to be in "consumer"
  2972. * PCM format, copyright asserted, no pre-emphasis and no validity
  2973. * control.
  2974. */
  2975. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2976. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  2977. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  2978. * OUT1 sum bus when acting as an output.
  2979. */
  2980. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  2981. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  2982. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  2983. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  2984. /* Start with output sum widgets muted and their output gains at min */
  2985. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2986. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2987. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2988. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2989. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2990. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2991. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2992. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2993. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2994. /* Unmute retasking pin widget output buffers since the default
  2995. * state appears to be output. As the pin mode is changed by the
  2996. * user the pin mode control will take care of enabling the pin's
  2997. * input/output buffers as needed.
  2998. */
  2999. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3000. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3001. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3002. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3003. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3004. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3005. /* Also unmute the mono-out pin widget */
  3006. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3007. /* Mute capture amp left and right */
  3008. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3009. /* Set ADC connection select to match default mixer setting (mic1
  3010. * pin)
  3011. */
  3012. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3013. /* Do the same for the second ADC: mute capture input amp and
  3014. * set ADC connection to mic1 pin
  3015. */
  3016. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3017. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3018. /* Mute all inputs to mixer widget (even unconnected ones) */
  3019. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3020. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3021. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3022. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3023. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3024. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3025. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3026. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3027. { }
  3028. };
  3029. #endif
  3030. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3031. .substreams = 1,
  3032. .channels_min = 2,
  3033. .channels_max = 2,
  3034. };
  3035. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3036. .substreams = 1,
  3037. .channels_min = 2,
  3038. .channels_max = 2,
  3039. };
  3040. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3041. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3042. /*
  3043. * for BIOS auto-configuration
  3044. */
  3045. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3046. const char *pfx)
  3047. {
  3048. hda_nid_t nid_vol;
  3049. unsigned long vol_val, sw_val;
  3050. char name[32];
  3051. int err;
  3052. if (nid >= 0x0f && nid < 0x11) {
  3053. nid_vol = nid - 0x7;
  3054. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3055. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3056. } else if (nid == 0x11) {
  3057. nid_vol = nid - 0x7;
  3058. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3059. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3060. } else if (nid >= 0x12 && nid <= 0x15) {
  3061. nid_vol = 0x08;
  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
  3065. return 0; /* N/A */
  3066. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3067. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  3068. return err;
  3069. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3070. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  3071. return err;
  3072. return 1;
  3073. }
  3074. /* add playback controls from the parsed DAC table */
  3075. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3076. const struct auto_pin_cfg *cfg)
  3077. {
  3078. hda_nid_t nid;
  3079. int err;
  3080. spec->multiout.num_dacs = 1;
  3081. spec->multiout.dac_nids = spec->private_dac_nids;
  3082. spec->multiout.dac_nids[0] = 0x02;
  3083. nid = cfg->line_out_pins[0];
  3084. if (nid) {
  3085. err = alc260_add_playback_controls(spec, nid, "Front");
  3086. if (err < 0)
  3087. return err;
  3088. }
  3089. nid = cfg->speaker_pins[0];
  3090. if (nid) {
  3091. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3092. if (err < 0)
  3093. return err;
  3094. }
  3095. nid = cfg->hp_pin;
  3096. if (nid) {
  3097. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3098. if (err < 0)
  3099. return err;
  3100. }
  3101. return 0;
  3102. }
  3103. /* create playback/capture controls for input pins */
  3104. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3105. const struct auto_pin_cfg *cfg)
  3106. {
  3107. struct hda_input_mux *imux = &spec->private_imux;
  3108. int i, err, idx;
  3109. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3110. if (cfg->input_pins[i] >= 0x12) {
  3111. idx = cfg->input_pins[i] - 0x12;
  3112. err = new_analog_input(spec, cfg->input_pins[i],
  3113. auto_pin_cfg_labels[i], idx, 0x07);
  3114. if (err < 0)
  3115. return err;
  3116. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3117. imux->items[imux->num_items].index = idx;
  3118. imux->num_items++;
  3119. }
  3120. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  3121. idx = cfg->input_pins[i] - 0x09;
  3122. err = new_analog_input(spec, cfg->input_pins[i],
  3123. auto_pin_cfg_labels[i], idx, 0x07);
  3124. if (err < 0)
  3125. return err;
  3126. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3127. imux->items[imux->num_items].index = idx;
  3128. imux->num_items++;
  3129. }
  3130. }
  3131. return 0;
  3132. }
  3133. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3134. hda_nid_t nid, int pin_type,
  3135. int sel_idx)
  3136. {
  3137. /* set as output */
  3138. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3139. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3140. /* need the manual connection? */
  3141. if (nid >= 0x12) {
  3142. int idx = nid - 0x12;
  3143. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3144. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3145. }
  3146. }
  3147. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3148. {
  3149. struct alc_spec *spec = codec->spec;
  3150. hda_nid_t nid;
  3151. nid = spec->autocfg.line_out_pins[0];
  3152. if (nid)
  3153. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3154. nid = spec->autocfg.speaker_pins[0];
  3155. if (nid)
  3156. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3157. nid = spec->autocfg.hp_pin;
  3158. if (nid)
  3159. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3160. }
  3161. #define ALC260_PIN_CD_NID 0x16
  3162. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3163. {
  3164. struct alc_spec *spec = codec->spec;
  3165. int i;
  3166. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3167. hda_nid_t nid = spec->autocfg.input_pins[i];
  3168. if (nid >= 0x12) {
  3169. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3170. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3171. if (nid != ALC260_PIN_CD_NID)
  3172. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3173. AMP_OUT_MUTE);
  3174. }
  3175. }
  3176. }
  3177. /*
  3178. * generic initialization of ADC, input mixers and output mixers
  3179. */
  3180. static struct hda_verb alc260_volume_init_verbs[] = {
  3181. /*
  3182. * Unmute ADC0-1 and set the default input to mic-in
  3183. */
  3184. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3185. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3186. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3187. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3188. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3189. * mixer widget
  3190. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3191. * mic (mic 2)
  3192. */
  3193. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3194. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3195. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3196. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3197. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3198. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3199. /*
  3200. * Set up output mixers (0x08 - 0x0a)
  3201. */
  3202. /* set vol=0 to output mixers */
  3203. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3204. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3205. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3206. /* set up input amps for analog loopback */
  3207. /* Amp Indices: DAC = 0, mixer = 1 */
  3208. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3209. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3210. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3211. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3212. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3213. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3214. { }
  3215. };
  3216. static int alc260_parse_auto_config(struct hda_codec *codec)
  3217. {
  3218. struct alc_spec *spec = codec->spec;
  3219. unsigned int wcap;
  3220. int err;
  3221. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3222. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3223. alc260_ignore)) < 0)
  3224. return err;
  3225. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  3226. return err;
  3227. if (! spec->kctl_alloc)
  3228. return 0; /* can't find valid BIOS pin config */
  3229. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3230. return err;
  3231. spec->multiout.max_channels = 2;
  3232. if (spec->autocfg.dig_out_pin)
  3233. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3234. if (spec->kctl_alloc)
  3235. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3236. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3237. spec->input_mux = &spec->private_imux;
  3238. /* check whether NID 0x04 is valid */
  3239. wcap = get_wcaps(codec, 0x04);
  3240. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3241. if (wcap != AC_WID_AUD_IN) {
  3242. spec->adc_nids = alc260_adc_nids_alt;
  3243. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  3244. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  3245. } else {
  3246. spec->adc_nids = alc260_adc_nids;
  3247. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  3248. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  3249. }
  3250. spec->num_mixers++;
  3251. return 1;
  3252. }
  3253. /* additional initialization for auto-configuration model */
  3254. static void alc260_auto_init(struct hda_codec *codec)
  3255. {
  3256. alc260_auto_init_multi_out(codec);
  3257. alc260_auto_init_analog_input(codec);
  3258. }
  3259. /*
  3260. * ALC260 configurations
  3261. */
  3262. static struct hda_board_config alc260_cfg_tbl[] = {
  3263. { .modelname = "basic", .config = ALC260_BASIC },
  3264. { .pci_subvendor = 0x104d, .pci_subdevice = 0x81bb,
  3265. .config = ALC260_BASIC }, /* Sony VAIO */
  3266. { .pci_subvendor = 0x152d, .pci_subdevice = 0x0729,
  3267. .config = ALC260_BASIC }, /* CTL Travel Master U553W */
  3268. { .modelname = "hp", .config = ALC260_HP },
  3269. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3010, .config = ALC260_HP },
  3270. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3011, .config = ALC260_HP },
  3271. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3012, .config = ALC260_HP },
  3272. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3013, .config = ALC260_HP_3013 },
  3273. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3014, .config = ALC260_HP },
  3274. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3015, .config = ALC260_HP },
  3275. { .pci_subvendor = 0x103c, .pci_subdevice = 0x3016, .config = ALC260_HP },
  3276. { .modelname = "fujitsu", .config = ALC260_FUJITSU_S702X },
  3277. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1326, .config = ALC260_FUJITSU_S702X },
  3278. { .modelname = "acer", .config = ALC260_ACER },
  3279. { .pci_subvendor = 0x1025, .pci_subdevice = 0x008f, .config = ALC260_ACER },
  3280. #ifdef CONFIG_SND_DEBUG
  3281. { .modelname = "test", .config = ALC260_TEST },
  3282. #endif
  3283. { .modelname = "auto", .config = ALC260_AUTO },
  3284. {}
  3285. };
  3286. static struct alc_config_preset alc260_presets[] = {
  3287. [ALC260_BASIC] = {
  3288. .mixers = { alc260_base_output_mixer,
  3289. alc260_input_mixer,
  3290. alc260_pc_beep_mixer,
  3291. alc260_capture_mixer },
  3292. .init_verbs = { alc260_init_verbs },
  3293. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3294. .dac_nids = alc260_dac_nids,
  3295. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  3296. .adc_nids = alc260_adc_nids,
  3297. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3298. .channel_mode = alc260_modes,
  3299. .input_mux = &alc260_capture_source,
  3300. },
  3301. [ALC260_HP] = {
  3302. .mixers = { alc260_base_output_mixer,
  3303. alc260_input_mixer,
  3304. alc260_capture_alt_mixer },
  3305. .init_verbs = { alc260_hp_init_verbs },
  3306. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3307. .dac_nids = alc260_dac_nids,
  3308. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3309. .adc_nids = alc260_hp_adc_nids,
  3310. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3311. .channel_mode = alc260_modes,
  3312. .input_mux = &alc260_capture_source,
  3313. },
  3314. [ALC260_HP_3013] = {
  3315. .mixers = { alc260_hp_3013_mixer,
  3316. alc260_input_mixer,
  3317. alc260_capture_alt_mixer },
  3318. .init_verbs = { alc260_hp_3013_init_verbs },
  3319. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3320. .dac_nids = alc260_dac_nids,
  3321. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3322. .adc_nids = alc260_hp_adc_nids,
  3323. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3324. .channel_mode = alc260_modes,
  3325. .input_mux = &alc260_capture_source,
  3326. },
  3327. [ALC260_FUJITSU_S702X] = {
  3328. .mixers = { alc260_fujitsu_mixer,
  3329. alc260_capture_mixer },
  3330. .init_verbs = { alc260_fujitsu_init_verbs },
  3331. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3332. .dac_nids = alc260_dac_nids,
  3333. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3334. .adc_nids = alc260_dual_adc_nids,
  3335. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3336. .channel_mode = alc260_modes,
  3337. .input_mux = &alc260_fujitsu_capture_source,
  3338. },
  3339. [ALC260_ACER] = {
  3340. .mixers = { alc260_acer_mixer,
  3341. alc260_capture_mixer },
  3342. .init_verbs = { alc260_acer_init_verbs },
  3343. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3344. .dac_nids = alc260_dac_nids,
  3345. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3346. .adc_nids = alc260_dual_adc_nids,
  3347. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3348. .channel_mode = alc260_modes,
  3349. .input_mux = &alc260_acer_capture_source,
  3350. },
  3351. #ifdef CONFIG_SND_DEBUG
  3352. [ALC260_TEST] = {
  3353. .mixers = { alc260_test_mixer,
  3354. alc260_capture_mixer },
  3355. .init_verbs = { alc260_test_init_verbs },
  3356. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  3357. .dac_nids = alc260_test_dac_nids,
  3358. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  3359. .adc_nids = alc260_test_adc_nids,
  3360. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3361. .channel_mode = alc260_modes,
  3362. .input_mux = &alc260_test_capture_source,
  3363. },
  3364. #endif
  3365. };
  3366. static int patch_alc260(struct hda_codec *codec)
  3367. {
  3368. struct alc_spec *spec;
  3369. int err, board_config;
  3370. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3371. if (spec == NULL)
  3372. return -ENOMEM;
  3373. codec->spec = spec;
  3374. board_config = snd_hda_check_board_config(codec, alc260_cfg_tbl);
  3375. if (board_config < 0 || board_config >= ALC260_MODEL_LAST) {
  3376. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260\n");
  3377. board_config = ALC260_AUTO;
  3378. }
  3379. if (board_config == ALC260_AUTO) {
  3380. /* automatic parse from the BIOS config */
  3381. err = alc260_parse_auto_config(codec);
  3382. if (err < 0) {
  3383. alc_free(codec);
  3384. return err;
  3385. } else if (! err) {
  3386. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  3387. board_config = ALC260_BASIC;
  3388. }
  3389. }
  3390. if (board_config != ALC260_AUTO)
  3391. setup_preset(spec, &alc260_presets[board_config]);
  3392. spec->stream_name_analog = "ALC260 Analog";
  3393. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  3394. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  3395. spec->stream_name_digital = "ALC260 Digital";
  3396. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  3397. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  3398. codec->patch_ops = alc_patch_ops;
  3399. if (board_config == ALC260_AUTO)
  3400. spec->init_hook = alc260_auto_init;
  3401. return 0;
  3402. }
  3403. /*
  3404. * ALC882 support
  3405. *
  3406. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  3407. * configuration. Each pin widget can choose any input DACs and a mixer.
  3408. * Each ADC is connected from a mixer of all inputs. This makes possible
  3409. * 6-channel independent captures.
  3410. *
  3411. * In addition, an independent DAC for the multi-playback (not used in this
  3412. * driver yet).
  3413. */
  3414. #define ALC882_DIGOUT_NID 0x06
  3415. #define ALC882_DIGIN_NID 0x0a
  3416. static struct hda_channel_mode alc882_ch_modes[1] = {
  3417. { 8, NULL }
  3418. };
  3419. static hda_nid_t alc882_dac_nids[4] = {
  3420. /* front, rear, clfe, rear_surr */
  3421. 0x02, 0x03, 0x04, 0x05
  3422. };
  3423. /* identical with ALC880 */
  3424. #define alc882_adc_nids alc880_adc_nids
  3425. #define alc882_adc_nids_alt alc880_adc_nids_alt
  3426. /* input MUX */
  3427. /* FIXME: should be a matrix-type input source selection */
  3428. static struct hda_input_mux alc882_capture_source = {
  3429. .num_items = 4,
  3430. .items = {
  3431. { "Mic", 0x0 },
  3432. { "Front Mic", 0x1 },
  3433. { "Line", 0x2 },
  3434. { "CD", 0x4 },
  3435. },
  3436. };
  3437. #define alc882_mux_enum_info alc_mux_enum_info
  3438. #define alc882_mux_enum_get alc_mux_enum_get
  3439. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  3440. {
  3441. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  3442. struct alc_spec *spec = codec->spec;
  3443. const struct hda_input_mux *imux = spec->input_mux;
  3444. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  3445. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  3446. hda_nid_t nid = capture_mixers[adc_idx];
  3447. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  3448. unsigned int i, idx;
  3449. idx = ucontrol->value.enumerated.item[0];
  3450. if (idx >= imux->num_items)
  3451. idx = imux->num_items - 1;
  3452. if (*cur_val == idx && ! codec->in_resume)
  3453. return 0;
  3454. for (i = 0; i < imux->num_items; i++) {
  3455. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  3456. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3457. v | (imux->items[i].index << 8));
  3458. }
  3459. *cur_val = idx;
  3460. return 1;
  3461. }
  3462. /*
  3463. * 6ch mode
  3464. */
  3465. static struct hda_verb alc882_sixstack_ch6_init[] = {
  3466. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3467. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3468. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3469. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3470. { } /* end */
  3471. };
  3472. /*
  3473. * 8ch mode
  3474. */
  3475. static struct hda_verb alc882_sixstack_ch8_init[] = {
  3476. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3477. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3478. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3479. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3480. { } /* end */
  3481. };
  3482. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  3483. { 6, alc882_sixstack_ch6_init },
  3484. { 8, alc882_sixstack_ch8_init },
  3485. };
  3486. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  3487. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  3488. */
  3489. static struct snd_kcontrol_new alc882_base_mixer[] = {
  3490. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3491. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  3492. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  3493. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  3494. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  3495. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3496. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  3497. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  3498. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  3499. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  3500. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  3501. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3502. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3503. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3504. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3505. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3506. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3507. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  3508. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  3509. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3510. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  3511. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  3512. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  3513. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  3514. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  3515. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  3516. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  3517. {
  3518. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3519. /* .name = "Capture Source", */
  3520. .name = "Input Source",
  3521. .count = 3,
  3522. .info = alc882_mux_enum_info,
  3523. .get = alc882_mux_enum_get,
  3524. .put = alc882_mux_enum_put,
  3525. },
  3526. { } /* end */
  3527. };
  3528. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  3529. {
  3530. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3531. .name = "Channel Mode",
  3532. .info = alc_ch_mode_info,
  3533. .get = alc_ch_mode_get,
  3534. .put = alc_ch_mode_put,
  3535. },
  3536. { } /* end */
  3537. };
  3538. static struct hda_verb alc882_init_verbs[] = {
  3539. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  3540. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3541. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3542. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3543. /* Rear mixer */
  3544. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3545. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3546. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3547. /* CLFE mixer */
  3548. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3549. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3550. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3551. /* Side mixer */
  3552. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3553. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3554. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3555. /* Front Pin: output 0 (0x0c) */
  3556. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3557. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3558. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  3559. /* Rear Pin: output 1 (0x0d) */
  3560. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3561. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3562. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  3563. /* CLFE Pin: output 2 (0x0e) */
  3564. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3565. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3566. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  3567. /* Side Pin: output 3 (0x0f) */
  3568. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3569. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3570. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  3571. /* Mic (rear) pin: input vref at 80% */
  3572. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3573. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3574. /* Front Mic pin: input vref at 80% */
  3575. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3576. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3577. /* Line In pin: input */
  3578. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3579. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  3580. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  3581. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3582. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3583. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3584. /* CD pin widget for input */
  3585. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3586. /* FIXME: use matrix-type input source selection */
  3587. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3588. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3589. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3590. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3591. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3592. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3593. /* Input mixer2 */
  3594. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3595. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3596. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3597. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3598. /* Input mixer3 */
  3599. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3600. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3601. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3602. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3603. /* ADC1: mute amp left and right */
  3604. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3605. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3606. /* ADC2: mute amp left and right */
  3607. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3608. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3609. /* ADC3: mute amp left and right */
  3610. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3611. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3612. { }
  3613. };
  3614. /*
  3615. * generic initialization of ADC, input mixers and output mixers
  3616. */
  3617. static struct hda_verb alc882_auto_init_verbs[] = {
  3618. /*
  3619. * Unmute ADC0-2 and set the default input to mic-in
  3620. */
  3621. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3622. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3623. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3624. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3625. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3626. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3627. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3628. * mixer widget
  3629. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3630. * mic (mic 2)
  3631. */
  3632. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3633. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3634. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3635. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3636. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3637. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3638. /*
  3639. * Set up output mixers (0x0c - 0x0f)
  3640. */
  3641. /* set vol=0 to output mixers */
  3642. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3643. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3644. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3645. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3646. /* set up input amps for analog loopback */
  3647. /* Amp Indices: DAC = 0, mixer = 1 */
  3648. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3649. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3650. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3651. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3652. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3653. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3654. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3655. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3656. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3657. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3658. /* FIXME: use matrix-type input source selection */
  3659. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3660. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3661. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3662. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3663. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3664. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3665. /* Input mixer2 */
  3666. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3667. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3668. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3669. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3670. /* Input mixer3 */
  3671. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3672. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3673. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3674. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3675. { }
  3676. };
  3677. /* capture mixer elements */
  3678. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  3679. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  3680. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  3681. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  3682. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  3683. {
  3684. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3685. /* The multiple "Capture Source" controls confuse alsamixer
  3686. * So call somewhat different..
  3687. * FIXME: the controls appear in the "playback" view!
  3688. */
  3689. /* .name = "Capture Source", */
  3690. .name = "Input Source",
  3691. .count = 2,
  3692. .info = alc882_mux_enum_info,
  3693. .get = alc882_mux_enum_get,
  3694. .put = alc882_mux_enum_put,
  3695. },
  3696. { } /* end */
  3697. };
  3698. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  3699. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  3700. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  3701. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  3702. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  3703. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  3704. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  3705. {
  3706. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3707. /* The multiple "Capture Source" controls confuse alsamixer
  3708. * So call somewhat different..
  3709. * FIXME: the controls appear in the "playback" view!
  3710. */
  3711. /* .name = "Capture Source", */
  3712. .name = "Input Source",
  3713. .count = 3,
  3714. .info = alc882_mux_enum_info,
  3715. .get = alc882_mux_enum_get,
  3716. .put = alc882_mux_enum_put,
  3717. },
  3718. { } /* end */
  3719. };
  3720. /* pcm configuration: identiacal with ALC880 */
  3721. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  3722. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  3723. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  3724. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  3725. /*
  3726. * configuration and preset
  3727. */
  3728. static struct hda_board_config alc882_cfg_tbl[] = {
  3729. { .modelname = "3stack-dig", .config = ALC882_3ST_DIG },
  3730. { .modelname = "6stack-dig", .config = ALC882_6ST_DIG },
  3731. { .pci_subvendor = 0x1462, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* MSI */
  3732. { .pci_subvendor = 0x105b, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* Foxconn */
  3733. { .pci_subvendor = 0x1019, .pci_subdevice = 0x6668, .config = ALC882_6ST_DIG }, /* ECS */
  3734. { .modelname = "auto", .config = ALC882_AUTO },
  3735. {}
  3736. };
  3737. static struct alc_config_preset alc882_presets[] = {
  3738. [ALC882_3ST_DIG] = {
  3739. .mixers = { alc882_base_mixer },
  3740. .init_verbs = { alc882_init_verbs },
  3741. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  3742. .dac_nids = alc882_dac_nids,
  3743. .dig_out_nid = ALC882_DIGOUT_NID,
  3744. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  3745. .adc_nids = alc882_adc_nids,
  3746. .dig_in_nid = ALC882_DIGIN_NID,
  3747. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  3748. .channel_mode = alc882_ch_modes,
  3749. .input_mux = &alc882_capture_source,
  3750. },
  3751. [ALC882_6ST_DIG] = {
  3752. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  3753. .init_verbs = { alc882_init_verbs },
  3754. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  3755. .dac_nids = alc882_dac_nids,
  3756. .dig_out_nid = ALC882_DIGOUT_NID,
  3757. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  3758. .adc_nids = alc882_adc_nids,
  3759. .dig_in_nid = ALC882_DIGIN_NID,
  3760. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  3761. .channel_mode = alc882_sixstack_modes,
  3762. .input_mux = &alc882_capture_source,
  3763. },
  3764. };
  3765. /*
  3766. * BIOS auto configuration
  3767. */
  3768. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  3769. hda_nid_t nid, int pin_type,
  3770. int dac_idx)
  3771. {
  3772. /* set as output */
  3773. struct alc_spec *spec = codec->spec;
  3774. int idx;
  3775. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  3776. idx = 4;
  3777. else
  3778. idx = spec->multiout.dac_nids[dac_idx] - 2;
  3779. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3780. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3781. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  3782. }
  3783. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  3784. {
  3785. struct alc_spec *spec = codec->spec;
  3786. int i;
  3787. for (i = 0; i <= HDA_SIDE; i++) {
  3788. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3789. if (nid)
  3790. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  3791. }
  3792. }
  3793. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  3794. {
  3795. struct alc_spec *spec = codec->spec;
  3796. hda_nid_t pin;
  3797. pin = spec->autocfg.hp_pin;
  3798. if (pin) /* connect to front */
  3799. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  3800. }
  3801. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  3802. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  3803. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  3804. {
  3805. struct alc_spec *spec = codec->spec;
  3806. int i;
  3807. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3808. hda_nid_t nid = spec->autocfg.input_pins[i];
  3809. if (alc882_is_input_pin(nid)) {
  3810. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3811. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3812. if (nid != ALC882_PIN_CD_NID)
  3813. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3814. AMP_OUT_MUTE);
  3815. }
  3816. }
  3817. }
  3818. /* almost identical with ALC880 parser... */
  3819. static int alc882_parse_auto_config(struct hda_codec *codec)
  3820. {
  3821. struct alc_spec *spec = codec->spec;
  3822. int err = alc880_parse_auto_config(codec);
  3823. if (err < 0)
  3824. return err;
  3825. else if (err > 0)
  3826. /* hack - override the init verbs */
  3827. spec->init_verbs[0] = alc882_auto_init_verbs;
  3828. return err;
  3829. }
  3830. /* additional initialization for auto-configuration model */
  3831. static void alc882_auto_init(struct hda_codec *codec)
  3832. {
  3833. alc882_auto_init_multi_out(codec);
  3834. alc882_auto_init_hp_out(codec);
  3835. alc882_auto_init_analog_input(codec);
  3836. }
  3837. /*
  3838. * ALC882 Headphone poll in 3.5.1a or 3.5.2
  3839. */
  3840. static int patch_alc882(struct hda_codec *codec)
  3841. {
  3842. struct alc_spec *spec;
  3843. int err, board_config;
  3844. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3845. if (spec == NULL)
  3846. return -ENOMEM;
  3847. codec->spec = spec;
  3848. board_config = snd_hda_check_board_config(codec, alc882_cfg_tbl);
  3849. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  3850. printk(KERN_INFO "hda_codec: Unknown model for ALC882, trying auto-probe from BIOS...\n");
  3851. board_config = ALC882_AUTO;
  3852. }
  3853. if (board_config == ALC882_AUTO) {
  3854. /* automatic parse from the BIOS config */
  3855. err = alc882_parse_auto_config(codec);
  3856. if (err < 0) {
  3857. alc_free(codec);
  3858. return err;
  3859. } else if (! err) {
  3860. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  3861. board_config = ALC882_3ST_DIG;
  3862. }
  3863. }
  3864. if (board_config != ALC882_AUTO)
  3865. setup_preset(spec, &alc882_presets[board_config]);
  3866. spec->stream_name_analog = "ALC882 Analog";
  3867. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  3868. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  3869. spec->stream_name_digital = "ALC882 Digital";
  3870. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  3871. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  3872. if (! spec->adc_nids && spec->input_mux) {
  3873. /* check whether NID 0x07 is valid */
  3874. unsigned int wcap = get_wcaps(codec, 0x07);
  3875. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3876. if (wcap != AC_WID_AUD_IN) {
  3877. spec->adc_nids = alc882_adc_nids_alt;
  3878. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  3879. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  3880. spec->num_mixers++;
  3881. } else {
  3882. spec->adc_nids = alc882_adc_nids;
  3883. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  3884. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  3885. spec->num_mixers++;
  3886. }
  3887. }
  3888. codec->patch_ops = alc_patch_ops;
  3889. if (board_config == ALC882_AUTO)
  3890. spec->init_hook = alc882_auto_init;
  3891. return 0;
  3892. }
  3893. /*
  3894. * ALC262 support
  3895. */
  3896. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  3897. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  3898. #define alc262_dac_nids alc260_dac_nids
  3899. #define alc262_adc_nids alc882_adc_nids
  3900. #define alc262_adc_nids_alt alc882_adc_nids_alt
  3901. #define alc262_modes alc260_modes
  3902. #define alc262_capture_source alc882_capture_source
  3903. static struct snd_kcontrol_new alc262_base_mixer[] = {
  3904. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3905. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  3906. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3907. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3908. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3909. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3910. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3911. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3912. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  3913. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  3914. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3915. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  3916. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  3917. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3918. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3919. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  3920. { } /* end */
  3921. };
  3922. #define alc262_capture_mixer alc882_capture_mixer
  3923. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  3924. /*
  3925. * generic initialization of ADC, input mixers and output mixers
  3926. */
  3927. static struct hda_verb alc262_init_verbs[] = {
  3928. /*
  3929. * Unmute ADC0-2 and set the default input to mic-in
  3930. */
  3931. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  3932. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3933. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  3934. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3935. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  3936. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3937. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3938. * mixer widget
  3939. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3940. * mic (mic 2)
  3941. */
  3942. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3943. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3944. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3945. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3946. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3947. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3948. /*
  3949. * Set up output mixers (0x0c - 0x0e)
  3950. */
  3951. /* set vol=0 to output mixers */
  3952. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3953. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3954. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3955. /* set up input amps for analog loopback */
  3956. /* Amp Indices: DAC = 0, mixer = 1 */
  3957. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3958. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3959. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3960. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3961. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3962. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3963. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3964. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3965. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3966. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3967. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3968. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3969. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3970. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3971. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3972. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3973. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3974. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  3975. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  3976. /* FIXME: use matrix-type input source selection */
  3977. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  3978. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  3979. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3980. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3981. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3982. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3983. /* Input mixer2 */
  3984. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3985. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3986. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3987. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3988. /* Input mixer3 */
  3989. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3990. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  3991. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  3992. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  3993. { }
  3994. };
  3995. /*
  3996. * fujitsu model
  3997. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  3998. */
  3999. #define ALC_HP_EVENT 0x37
  4000. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  4001. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  4002. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4003. {}
  4004. };
  4005. static struct hda_input_mux alc262_fujitsu_capture_source = {
  4006. .num_items = 2,
  4007. .items = {
  4008. { "Mic", 0x0 },
  4009. { "CD", 0x4 },
  4010. },
  4011. };
  4012. /* mute/unmute internal speaker according to the hp jack and mute state */
  4013. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  4014. {
  4015. struct alc_spec *spec = codec->spec;
  4016. unsigned int mute;
  4017. if (force || ! spec->sense_updated) {
  4018. unsigned int present;
  4019. /* need to execute and sync at first */
  4020. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  4021. present = snd_hda_codec_read(codec, 0x14, 0,
  4022. AC_VERB_GET_PIN_SENSE, 0);
  4023. spec->jack_present = (present & 0x80000000) != 0;
  4024. spec->sense_updated = 1;
  4025. }
  4026. if (spec->jack_present) {
  4027. /* mute internal speaker */
  4028. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  4029. 0x80, 0x80);
  4030. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  4031. 0x80, 0x80);
  4032. } else {
  4033. /* unmute internal speaker if necessary */
  4034. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  4035. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  4036. 0x80, mute & 0x80);
  4037. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  4038. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  4039. 0x80, mute & 0x80);
  4040. }
  4041. }
  4042. /* unsolicited event for HP jack sensing */
  4043. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  4044. unsigned int res)
  4045. {
  4046. if ((res >> 26) != ALC_HP_EVENT)
  4047. return;
  4048. alc262_fujitsu_automute(codec, 1);
  4049. }
  4050. /* bind volumes of both NID 0x0c and 0x0d */
  4051. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  4052. struct snd_ctl_elem_value *ucontrol)
  4053. {
  4054. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4055. long *valp = ucontrol->value.integer.value;
  4056. int change;
  4057. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  4058. 0x7f, valp[0] & 0x7f);
  4059. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  4060. 0x7f, valp[1] & 0x7f);
  4061. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  4062. 0x7f, valp[0] & 0x7f);
  4063. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  4064. 0x7f, valp[1] & 0x7f);
  4065. return change;
  4066. }
  4067. /* bind hp and internal speaker mute (with plug check) */
  4068. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  4069. struct snd_ctl_elem_value *ucontrol)
  4070. {
  4071. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4072. long *valp = ucontrol->value.integer.value;
  4073. int change;
  4074. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  4075. 0x80, valp[0] ? 0 : 0x80);
  4076. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  4077. 0x80, valp[1] ? 0 : 0x80);
  4078. if (change || codec->in_resume)
  4079. alc262_fujitsu_automute(codec, codec->in_resume);
  4080. return change;
  4081. }
  4082. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  4083. {
  4084. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4085. .name = "Master Playback Volume",
  4086. .info = snd_hda_mixer_amp_volume_info,
  4087. .get = snd_hda_mixer_amp_volume_get,
  4088. .put = alc262_fujitsu_master_vol_put,
  4089. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  4090. },
  4091. {
  4092. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4093. .name = "Master Playback Switch",
  4094. .info = snd_hda_mixer_amp_switch_info,
  4095. .get = snd_hda_mixer_amp_switch_get,
  4096. .put = alc262_fujitsu_master_sw_put,
  4097. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  4098. },
  4099. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4100. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4101. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4102. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4103. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4104. { } /* end */
  4105. };
  4106. /* add playback controls from the parsed DAC table */
  4107. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  4108. {
  4109. hda_nid_t nid;
  4110. int err;
  4111. spec->multiout.num_dacs = 1; /* only use one dac */
  4112. spec->multiout.dac_nids = spec->private_dac_nids;
  4113. spec->multiout.dac_nids[0] = 2;
  4114. nid = cfg->line_out_pins[0];
  4115. if (nid) {
  4116. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  4117. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  4118. return err;
  4119. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  4120. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4121. return err;
  4122. }
  4123. nid = cfg->speaker_pins[0];
  4124. if (nid) {
  4125. if (nid == 0x16) {
  4126. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  4127. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  4128. return err;
  4129. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  4130. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  4131. return err;
  4132. } else {
  4133. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  4134. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4135. return err;
  4136. }
  4137. }
  4138. nid = cfg->hp_pin;
  4139. if (nid) {
  4140. /* spec->multiout.hp_nid = 2; */
  4141. if (nid == 0x16) {
  4142. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  4143. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  4144. return err;
  4145. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  4146. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  4147. return err;
  4148. } else {
  4149. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  4150. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4151. return err;
  4152. }
  4153. }
  4154. return 0;
  4155. }
  4156. /* identical with ALC880 */
  4157. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  4158. /*
  4159. * generic initialization of ADC, input mixers and output mixers
  4160. */
  4161. static struct hda_verb alc262_volume_init_verbs[] = {
  4162. /*
  4163. * Unmute ADC0-2 and set the default input to mic-in
  4164. */
  4165. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4166. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4167. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4168. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4169. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4170. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4171. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4172. * mixer widget
  4173. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4174. * mic (mic 2)
  4175. */
  4176. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4179. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4180. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4181. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4182. /*
  4183. * Set up output mixers (0x0c - 0x0f)
  4184. */
  4185. /* set vol=0 to output mixers */
  4186. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4187. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4188. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4189. /* set up input amps for analog loopback */
  4190. /* Amp Indices: DAC = 0, mixer = 1 */
  4191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4192. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4194. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4196. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4197. /* FIXME: use matrix-type input source selection */
  4198. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4199. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4200. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4201. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4202. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4203. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4204. /* Input mixer2 */
  4205. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4206. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4207. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4208. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4209. /* Input mixer3 */
  4210. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4211. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4212. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4213. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4214. { }
  4215. };
  4216. /* pcm configuration: identiacal with ALC880 */
  4217. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  4218. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  4219. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  4220. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  4221. /*
  4222. * BIOS auto configuration
  4223. */
  4224. static int alc262_parse_auto_config(struct hda_codec *codec)
  4225. {
  4226. struct alc_spec *spec = codec->spec;
  4227. int err;
  4228. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  4229. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4230. alc262_ignore)) < 0)
  4231. return err;
  4232. if (! spec->autocfg.line_outs)
  4233. return 0; /* can't find valid BIOS pin config */
  4234. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  4235. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  4236. return err;
  4237. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  4238. if (spec->autocfg.dig_out_pin)
  4239. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  4240. if (spec->autocfg.dig_in_pin)
  4241. spec->dig_in_nid = ALC262_DIGIN_NID;
  4242. if (spec->kctl_alloc)
  4243. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4244. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  4245. spec->input_mux = &spec->private_imux;
  4246. return 1;
  4247. }
  4248. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  4249. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  4250. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  4251. /* init callback for auto-configuration model -- overriding the default init */
  4252. static void alc262_auto_init(struct hda_codec *codec)
  4253. {
  4254. alc262_auto_init_multi_out(codec);
  4255. alc262_auto_init_hp_out(codec);
  4256. alc262_auto_init_analog_input(codec);
  4257. }
  4258. /*
  4259. * configuration and preset
  4260. */
  4261. static struct hda_board_config alc262_cfg_tbl[] = {
  4262. { .modelname = "basic", .config = ALC262_BASIC },
  4263. { .modelname = "fujitsu", .config = ALC262_FUJITSU },
  4264. { .pci_subvendor = 0x10cf, .pci_subdevice = 0x1397, .config = ALC262_FUJITSU },
  4265. { .modelname = "auto", .config = ALC262_AUTO },
  4266. {}
  4267. };
  4268. static struct alc_config_preset alc262_presets[] = {
  4269. [ALC262_BASIC] = {
  4270. .mixers = { alc262_base_mixer },
  4271. .init_verbs = { alc262_init_verbs },
  4272. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  4273. .dac_nids = alc262_dac_nids,
  4274. .hp_nid = 0x03,
  4275. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  4276. .channel_mode = alc262_modes,
  4277. .input_mux = &alc262_capture_source,
  4278. },
  4279. [ALC262_FUJITSU] = {
  4280. .mixers = { alc262_fujitsu_mixer },
  4281. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  4282. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  4283. .dac_nids = alc262_dac_nids,
  4284. .hp_nid = 0x03,
  4285. .dig_out_nid = ALC262_DIGOUT_NID,
  4286. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  4287. .channel_mode = alc262_modes,
  4288. .input_mux = &alc262_fujitsu_capture_source,
  4289. .unsol_event = alc262_fujitsu_unsol_event,
  4290. },
  4291. };
  4292. static int patch_alc262(struct hda_codec *codec)
  4293. {
  4294. struct alc_spec *spec;
  4295. int board_config;
  4296. int err;
  4297. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  4298. if (spec == NULL)
  4299. return -ENOMEM;
  4300. codec->spec = spec;
  4301. #if 0
  4302. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  4303. {
  4304. int tmp;
  4305. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  4306. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  4307. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  4308. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  4309. }
  4310. #endif
  4311. board_config = snd_hda_check_board_config(codec, alc262_cfg_tbl);
  4312. if (board_config < 0 || board_config >= ALC262_MODEL_LAST) {
  4313. printk(KERN_INFO "hda_codec: Unknown model for ALC262, trying auto-probe from BIOS...\n");
  4314. board_config = ALC262_AUTO;
  4315. }
  4316. if (board_config == ALC262_AUTO) {
  4317. /* automatic parse from the BIOS config */
  4318. err = alc262_parse_auto_config(codec);
  4319. if (err < 0) {
  4320. alc_free(codec);
  4321. return err;
  4322. } else if (! err) {
  4323. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  4324. board_config = ALC262_BASIC;
  4325. }
  4326. }
  4327. if (board_config != ALC262_AUTO)
  4328. setup_preset(spec, &alc262_presets[board_config]);
  4329. spec->stream_name_analog = "ALC262 Analog";
  4330. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  4331. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  4332. spec->stream_name_digital = "ALC262 Digital";
  4333. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  4334. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  4335. if (! spec->adc_nids && spec->input_mux) {
  4336. /* check whether NID 0x07 is valid */
  4337. unsigned int wcap = get_wcaps(codec, 0x07);
  4338. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4339. if (wcap != AC_WID_AUD_IN) {
  4340. spec->adc_nids = alc262_adc_nids_alt;
  4341. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  4342. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  4343. spec->num_mixers++;
  4344. } else {
  4345. spec->adc_nids = alc262_adc_nids;
  4346. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  4347. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  4348. spec->num_mixers++;
  4349. }
  4350. }
  4351. codec->patch_ops = alc_patch_ops;
  4352. if (board_config == ALC262_AUTO)
  4353. spec->init_hook = alc262_auto_init;
  4354. return 0;
  4355. }
  4356. /*
  4357. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  4358. */
  4359. /*
  4360. * set the path ways for 2 channel output
  4361. * need to set the codec line out and mic 1 pin widgets to inputs
  4362. */
  4363. static struct hda_verb alc861_threestack_ch2_init[] = {
  4364. /* set pin widget 1Ah (line in) for input */
  4365. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4366. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  4367. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4368. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  4369. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, //mic
  4370. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, //line in
  4371. { } /* end */
  4372. };
  4373. /*
  4374. * 6ch mode
  4375. * need to set the codec line out and mic 1 pin widgets to outputs
  4376. */
  4377. static struct hda_verb alc861_threestack_ch6_init[] = {
  4378. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  4379. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4380. /* set pin widget 18h (mic1) for output (CLFE)*/
  4381. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4382. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4383. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4384. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  4385. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, //mic
  4386. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, //line in
  4387. { } /* end */
  4388. };
  4389. static struct hda_channel_mode alc861_threestack_modes[2] = {
  4390. { 2, alc861_threestack_ch2_init },
  4391. { 6, alc861_threestack_ch6_init },
  4392. };
  4393. /* patch-ALC861 */
  4394. static struct snd_kcontrol_new alc861_base_mixer[] = {
  4395. /* output mixer control */
  4396. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  4397. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  4398. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  4399. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  4400. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  4401. /*Input mixer control */
  4402. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  4403. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  4404. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  4405. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  4406. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  4407. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  4408. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  4409. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  4410. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  4411. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  4412. /* Capture mixer control */
  4413. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4414. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4415. {
  4416. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4417. .name = "Capture Source",
  4418. .count = 1,
  4419. .info = alc_mux_enum_info,
  4420. .get = alc_mux_enum_get,
  4421. .put = alc_mux_enum_put,
  4422. },
  4423. { } /* end */
  4424. };
  4425. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  4426. /* output mixer control */
  4427. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  4428. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  4429. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  4430. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  4431. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  4432. /* Input mixer control */
  4433. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  4434. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  4435. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  4436. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  4437. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  4438. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  4439. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  4440. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  4441. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  4442. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  4443. /* Capture mixer control */
  4444. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4445. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4446. {
  4447. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4448. .name = "Capture Source",
  4449. .count = 1,
  4450. .info = alc_mux_enum_info,
  4451. .get = alc_mux_enum_get,
  4452. .put = alc_mux_enum_put,
  4453. },
  4454. {
  4455. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4456. .name = "Channel Mode",
  4457. .info = alc_ch_mode_info,
  4458. .get = alc_ch_mode_get,
  4459. .put = alc_ch_mode_put,
  4460. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  4461. },
  4462. { } /* end */
  4463. };
  4464. /*
  4465. * generic initialization of ADC, input mixers and output mixers
  4466. */
  4467. static struct hda_verb alc861_base_init_verbs[] = {
  4468. /*
  4469. * Unmute ADC0 and set the default input to mic-in
  4470. */
  4471. /* port-A for surround (rear panel) */
  4472. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4473. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4474. /* port-B for mic-in (rear panel) with vref */
  4475. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4476. /* port-C for line-in (rear panel) */
  4477. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4478. /* port-D for Front */
  4479. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4480. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4481. /* port-E for HP out (front panel) */
  4482. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  4483. /* route front PCM to HP */
  4484. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4485. /* port-F for mic-in (front panel) with vref */
  4486. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4487. /* port-G for CLFE (rear panel) */
  4488. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4489. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4490. /* port-H for side (rear panel) */
  4491. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4492. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4493. /* CD-in */
  4494. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4495. /* route front mic to ADC1*/
  4496. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4497. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4498. /* Unmute DAC0~3 & spdif out*/
  4499. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4500. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4501. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4502. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4503. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4504. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  4505. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4506. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4507. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4508. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4509. /* Unmute Stereo Mixer 15 */
  4510. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4511. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4512. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4513. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  4514. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4515. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4516. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4517. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4518. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4519. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4520. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4521. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4522. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  4523. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4524. { }
  4525. };
  4526. static struct hda_verb alc861_threestack_init_verbs[] = {
  4527. /*
  4528. * Unmute ADC0 and set the default input to mic-in
  4529. */
  4530. /* port-A for surround (rear panel) */
  4531. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4532. /* port-B for mic-in (rear panel) with vref */
  4533. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4534. /* port-C for line-in (rear panel) */
  4535. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4536. /* port-D for Front */
  4537. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  4538. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  4539. /* port-E for HP out (front panel) */
  4540. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  4541. /* route front PCM to HP */
  4542. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4543. /* port-F for mic-in (front panel) with vref */
  4544. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  4545. /* port-G for CLFE (rear panel) */
  4546. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4547. /* port-H for side (rear panel) */
  4548. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4549. /* CD-in */
  4550. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  4551. /* route front mic to ADC1*/
  4552. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4553. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4554. /* Unmute DAC0~3 & spdif out*/
  4555. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4556. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4557. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4558. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4559. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4560. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  4561. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4562. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4563. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4564. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4565. /* Unmute Stereo Mixer 15 */
  4566. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4567. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4568. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4569. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  4570. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4571. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4572. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4573. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4574. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4575. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4576. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4577. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4578. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  4579. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4580. { }
  4581. };
  4582. /*
  4583. * generic initialization of ADC, input mixers and output mixers
  4584. */
  4585. static struct hda_verb alc861_auto_init_verbs[] = {
  4586. /*
  4587. * Unmute ADC0 and set the default input to mic-in
  4588. */
  4589. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4590. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4591. /* Unmute DAC0~3 & spdif out*/
  4592. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4593. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4594. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4595. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4596. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4597. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  4598. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4599. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4600. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4601. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4602. /* Unmute Stereo Mixer 15 */
  4603. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4604. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4605. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4606. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  4607. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4608. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4609. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4610. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4611. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4612. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4613. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4614. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4615. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4616. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4617. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4618. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4619. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4620. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4621. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4622. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4623. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  4624. { }
  4625. };
  4626. /* pcm configuration: identiacal with ALC880 */
  4627. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  4628. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  4629. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  4630. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  4631. #define ALC861_DIGOUT_NID 0x07
  4632. static struct hda_channel_mode alc861_8ch_modes[1] = {
  4633. { 8, NULL }
  4634. };
  4635. static hda_nid_t alc861_dac_nids[4] = {
  4636. /* front, surround, clfe, side */
  4637. 0x03, 0x06, 0x05, 0x04
  4638. };
  4639. static hda_nid_t alc861_adc_nids[1] = {
  4640. /* ADC0-2 */
  4641. 0x08,
  4642. };
  4643. static struct hda_input_mux alc861_capture_source = {
  4644. .num_items = 5,
  4645. .items = {
  4646. { "Mic", 0x0 },
  4647. { "Front Mic", 0x3 },
  4648. { "Line", 0x1 },
  4649. { "CD", 0x4 },
  4650. { "Mixer", 0x5 },
  4651. },
  4652. };
  4653. /* fill in the dac_nids table from the parsed pin configuration */
  4654. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  4655. {
  4656. int i;
  4657. hda_nid_t nid;
  4658. spec->multiout.dac_nids = spec->private_dac_nids;
  4659. for (i = 0; i < cfg->line_outs; i++) {
  4660. nid = cfg->line_out_pins[i];
  4661. if (nid) {
  4662. if (i >= ARRAY_SIZE(alc861_dac_nids))
  4663. continue;
  4664. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  4665. }
  4666. }
  4667. spec->multiout.num_dacs = cfg->line_outs;
  4668. return 0;
  4669. }
  4670. /* add playback controls from the parsed DAC table */
  4671. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  4672. const struct auto_pin_cfg *cfg)
  4673. {
  4674. char name[32];
  4675. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  4676. hda_nid_t nid;
  4677. int i, idx, err;
  4678. for (i = 0; i < cfg->line_outs; i++) {
  4679. nid = spec->multiout.dac_nids[i];
  4680. if (! nid)
  4681. continue;
  4682. if (nid == 0x05) {
  4683. /* Center/LFE */
  4684. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  4685. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  4686. return err;
  4687. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  4688. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  4689. return err;
  4690. } else {
  4691. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  4692. if (nid == alc861_dac_nids[idx])
  4693. break;
  4694. sprintf(name, "%s Playback Switch", chname[idx]);
  4695. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  4696. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4697. return err;
  4698. }
  4699. }
  4700. return 0;
  4701. }
  4702. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  4703. {
  4704. int err;
  4705. hda_nid_t nid;
  4706. if (! pin)
  4707. return 0;
  4708. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  4709. nid = 0x03;
  4710. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  4711. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  4712. return err;
  4713. spec->multiout.hp_nid = nid;
  4714. }
  4715. return 0;
  4716. }
  4717. /* create playback/capture controls for input pins */
  4718. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  4719. {
  4720. struct hda_input_mux *imux = &spec->private_imux;
  4721. int i, err, idx, idx1;
  4722. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4723. switch(cfg->input_pins[i]) {
  4724. case 0x0c:
  4725. idx1 = 1;
  4726. idx = 2; // Line In
  4727. break;
  4728. case 0x0f:
  4729. idx1 = 2;
  4730. idx = 2; // Line In
  4731. break;
  4732. case 0x0d:
  4733. idx1 = 0;
  4734. idx = 1; // Mic In
  4735. break;
  4736. case 0x10:
  4737. idx1 = 3;
  4738. idx = 1; // Mic In
  4739. break;
  4740. case 0x11:
  4741. idx1 = 4;
  4742. idx = 0; // CD
  4743. break;
  4744. default:
  4745. continue;
  4746. }
  4747. err = new_analog_input(spec, cfg->input_pins[i],
  4748. auto_pin_cfg_labels[i], idx, 0x15);
  4749. if (err < 0)
  4750. return err;
  4751. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  4752. imux->items[imux->num_items].index = idx1;
  4753. imux->num_items++;
  4754. }
  4755. return 0;
  4756. }
  4757. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  4758. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4759. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4760. {
  4761. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4762. /* The multiple "Capture Source" controls confuse alsamixer
  4763. * So call somewhat different..
  4764. *FIXME: the controls appear in the "playback" view!
  4765. */
  4766. /* .name = "Capture Source", */
  4767. .name = "Input Source",
  4768. .count = 1,
  4769. .info = alc_mux_enum_info,
  4770. .get = alc_mux_enum_get,
  4771. .put = alc_mux_enum_put,
  4772. },
  4773. { } /* end */
  4774. };
  4775. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  4776. int pin_type, int dac_idx)
  4777. {
  4778. /* set as output */
  4779. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4780. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4781. }
  4782. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  4783. {
  4784. struct alc_spec *spec = codec->spec;
  4785. int i;
  4786. for (i = 0; i < spec->autocfg.line_outs; i++) {
  4787. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4788. if (nid)
  4789. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  4790. }
  4791. }
  4792. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  4793. {
  4794. struct alc_spec *spec = codec->spec;
  4795. hda_nid_t pin;
  4796. pin = spec->autocfg.hp_pin;
  4797. if (pin) /* connect to front */
  4798. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  4799. }
  4800. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  4801. {
  4802. struct alc_spec *spec = codec->spec;
  4803. int i;
  4804. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4805. hda_nid_t nid = spec->autocfg.input_pins[i];
  4806. if ((nid>=0x0c) && (nid <=0x11)) {
  4807. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4808. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4809. }
  4810. }
  4811. }
  4812. /* parse the BIOS configuration and set up the alc_spec */
  4813. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  4814. static int alc861_parse_auto_config(struct hda_codec *codec)
  4815. {
  4816. struct alc_spec *spec = codec->spec;
  4817. int err;
  4818. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  4819. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4820. alc861_ignore)) < 0)
  4821. return err;
  4822. if (! spec->autocfg.line_outs)
  4823. return 0; /* can't find valid BIOS pin config */
  4824. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  4825. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  4826. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pin)) < 0 ||
  4827. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  4828. return err;
  4829. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  4830. if (spec->autocfg.dig_out_pin)
  4831. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  4832. if (spec->kctl_alloc)
  4833. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4834. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  4835. spec->input_mux = &spec->private_imux;
  4836. spec->adc_nids = alc861_adc_nids;
  4837. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  4838. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  4839. spec->num_mixers++;
  4840. return 1;
  4841. }
  4842. /* additional initialization for auto-configuration model */
  4843. static void alc861_auto_init(struct hda_codec *codec)
  4844. {
  4845. alc861_auto_init_multi_out(codec);
  4846. alc861_auto_init_hp_out(codec);
  4847. alc861_auto_init_analog_input(codec);
  4848. }
  4849. /*
  4850. * configuration and preset
  4851. */
  4852. static struct hda_board_config alc861_cfg_tbl[] = {
  4853. { .modelname = "3stack", .config = ALC861_3ST },
  4854. { .pci_subvendor = 0x8086, .pci_subdevice = 0xd600, .config = ALC861_3ST },
  4855. { .modelname = "3stack-dig", .config = ALC861_3ST_DIG },
  4856. { .modelname = "6stack-dig", .config = ALC861_6ST_DIG },
  4857. { .modelname = "auto", .config = ALC861_AUTO },
  4858. {}
  4859. };
  4860. static struct alc_config_preset alc861_presets[] = {
  4861. [ALC861_3ST] = {
  4862. .mixers = { alc861_3ST_mixer },
  4863. .init_verbs = { alc861_threestack_init_verbs },
  4864. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  4865. .dac_nids = alc861_dac_nids,
  4866. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  4867. .channel_mode = alc861_threestack_modes,
  4868. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  4869. .adc_nids = alc861_adc_nids,
  4870. .input_mux = &alc861_capture_source,
  4871. },
  4872. [ALC861_3ST_DIG] = {
  4873. .mixers = { alc861_base_mixer },
  4874. .init_verbs = { alc861_threestack_init_verbs },
  4875. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  4876. .dac_nids = alc861_dac_nids,
  4877. .dig_out_nid = ALC861_DIGOUT_NID,
  4878. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  4879. .channel_mode = alc861_threestack_modes,
  4880. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  4881. .adc_nids = alc861_adc_nids,
  4882. .input_mux = &alc861_capture_source,
  4883. },
  4884. [ALC861_6ST_DIG] = {
  4885. .mixers = { alc861_base_mixer },
  4886. .init_verbs = { alc861_base_init_verbs },
  4887. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  4888. .dac_nids = alc861_dac_nids,
  4889. .dig_out_nid = ALC861_DIGOUT_NID,
  4890. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  4891. .channel_mode = alc861_8ch_modes,
  4892. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  4893. .adc_nids = alc861_adc_nids,
  4894. .input_mux = &alc861_capture_source,
  4895. },
  4896. };
  4897. static int patch_alc861(struct hda_codec *codec)
  4898. {
  4899. struct alc_spec *spec;
  4900. int board_config;
  4901. int err;
  4902. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  4903. if (spec == NULL)
  4904. return -ENOMEM;
  4905. codec->spec = spec;
  4906. board_config = snd_hda_check_board_config(codec, alc861_cfg_tbl);
  4907. if (board_config < 0 || board_config >= ALC861_MODEL_LAST) {
  4908. printk(KERN_INFO "hda_codec: Unknown model for ALC861, trying auto-probe from BIOS...\n");
  4909. board_config = ALC861_AUTO;
  4910. }
  4911. if (board_config == ALC861_AUTO) {
  4912. /* automatic parse from the BIOS config */
  4913. err = alc861_parse_auto_config(codec);
  4914. if (err < 0) {
  4915. alc_free(codec);
  4916. return err;
  4917. } else if (! err) {
  4918. printk(KERN_INFO "hda_codec: Cannot set up configuration from BIOS. Using base mode...\n");
  4919. board_config = ALC861_3ST_DIG;
  4920. }
  4921. }
  4922. if (board_config != ALC861_AUTO)
  4923. setup_preset(spec, &alc861_presets[board_config]);
  4924. spec->stream_name_analog = "ALC861 Analog";
  4925. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  4926. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  4927. spec->stream_name_digital = "ALC861 Digital";
  4928. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  4929. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  4930. codec->patch_ops = alc_patch_ops;
  4931. if (board_config == ALC861_AUTO)
  4932. spec->init_hook = alc861_auto_init;
  4933. return 0;
  4934. }
  4935. /*
  4936. * patch entries
  4937. */
  4938. struct hda_codec_preset snd_hda_preset_realtek[] = {
  4939. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  4940. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  4941. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  4942. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  4943. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc882 },
  4944. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  4945. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  4946. {} /* terminator */
  4947. };