patch_realtek.c 195 KB

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