patch_realtek.c 263 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780
  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. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_UNIWILL_DIG,
  53. ALC880_UNIWILL,
  54. ALC880_UNIWILL_P53,
  55. ALC880_CLEVO,
  56. ALC880_TCL_S700,
  57. ALC880_LG,
  58. ALC880_LG_LW,
  59. #ifdef CONFIG_SND_DEBUG
  60. ALC880_TEST,
  61. #endif
  62. ALC880_AUTO,
  63. ALC880_MODEL_LAST /* last tag */
  64. };
  65. /* ALC260 models */
  66. enum {
  67. ALC260_BASIC,
  68. ALC260_HP,
  69. ALC260_HP_3013,
  70. ALC260_FUJITSU_S702X,
  71. ALC260_ACER,
  72. #ifdef CONFIG_SND_DEBUG
  73. ALC260_TEST,
  74. #endif
  75. ALC260_AUTO,
  76. ALC260_MODEL_LAST /* last tag */
  77. };
  78. /* ALC262 models */
  79. enum {
  80. ALC262_BASIC,
  81. ALC262_HIPPO,
  82. ALC262_HIPPO_1,
  83. ALC262_FUJITSU,
  84. ALC262_HP_BPC,
  85. ALC262_BENQ_ED8,
  86. ALC262_AUTO,
  87. ALC262_MODEL_LAST /* last tag */
  88. };
  89. /* ALC861 models */
  90. enum {
  91. ALC861_3ST,
  92. ALC660_3ST,
  93. ALC861_3ST_DIG,
  94. ALC861_6ST_DIG,
  95. ALC861_UNIWILL_M31,
  96. ALC861_TOSHIBA,
  97. ALC861_ASUS,
  98. ALC861_ASUS_LAPTOP,
  99. ALC861_AUTO,
  100. ALC861_MODEL_LAST,
  101. };
  102. /* ALC882 models */
  103. enum {
  104. ALC882_3ST_DIG,
  105. ALC882_6ST_DIG,
  106. ALC882_ARIMA,
  107. ALC882_AUTO,
  108. ALC885_MACPRO,
  109. ALC882_MODEL_LAST,
  110. };
  111. /* ALC883 models */
  112. enum {
  113. ALC883_3ST_2ch_DIG,
  114. ALC883_3ST_6ch_DIG,
  115. ALC883_3ST_6ch,
  116. ALC883_6ST_DIG,
  117. ALC883_TARGA_DIG,
  118. ALC883_TARGA_2ch_DIG,
  119. ALC888_DEMO_BOARD,
  120. ALC883_ACER,
  121. ALC883_MEDION,
  122. ALC883_LAPTOP_EAPD,
  123. ALC883_AUTO,
  124. ALC883_MODEL_LAST,
  125. };
  126. /* for GPIO Poll */
  127. #define GPIO_MASK 0x03
  128. struct alc_spec {
  129. /* codec parameterization */
  130. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  131. unsigned int num_mixers;
  132. const struct hda_verb *init_verbs[5]; /* initialization verbs
  133. * don't forget NULL
  134. * termination!
  135. */
  136. unsigned int num_init_verbs;
  137. char *stream_name_analog; /* analog PCM stream */
  138. struct hda_pcm_stream *stream_analog_playback;
  139. struct hda_pcm_stream *stream_analog_capture;
  140. char *stream_name_digital; /* digital PCM stream */
  141. struct hda_pcm_stream *stream_digital_playback;
  142. struct hda_pcm_stream *stream_digital_capture;
  143. /* playback */
  144. struct hda_multi_out multiout; /* playback set-up
  145. * max_channels, dacs must be set
  146. * dig_out_nid and hp_nid are optional
  147. */
  148. /* capture */
  149. unsigned int num_adc_nids;
  150. hda_nid_t *adc_nids;
  151. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  152. /* capture source */
  153. unsigned int num_mux_defs;
  154. const struct hda_input_mux *input_mux;
  155. unsigned int cur_mux[3];
  156. /* channel model */
  157. const struct hda_channel_mode *channel_mode;
  158. int num_channel_mode;
  159. int need_dac_fix;
  160. /* PCM information */
  161. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  162. /* dynamic controls, init_verbs and input_mux */
  163. struct auto_pin_cfg autocfg;
  164. unsigned int num_kctl_alloc, num_kctl_used;
  165. struct snd_kcontrol_new *kctl_alloc;
  166. struct hda_input_mux private_imux;
  167. hda_nid_t private_dac_nids[5];
  168. /* hooks */
  169. void (*init_hook)(struct hda_codec *codec);
  170. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  171. /* for pin sensing */
  172. unsigned int sense_updated: 1;
  173. unsigned int jack_present: 1;
  174. };
  175. /*
  176. * configuration template - to be copied to the spec instance
  177. */
  178. struct alc_config_preset {
  179. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  180. * with spec
  181. */
  182. const struct hda_verb *init_verbs[5];
  183. unsigned int num_dacs;
  184. hda_nid_t *dac_nids;
  185. hda_nid_t dig_out_nid; /* optional */
  186. hda_nid_t hp_nid; /* optional */
  187. unsigned int num_adc_nids;
  188. hda_nid_t *adc_nids;
  189. hda_nid_t dig_in_nid;
  190. unsigned int num_channel_mode;
  191. const struct hda_channel_mode *channel_mode;
  192. int need_dac_fix;
  193. unsigned int num_mux_defs;
  194. const struct hda_input_mux *input_mux;
  195. void (*unsol_event)(struct hda_codec *, unsigned int);
  196. void (*init_hook)(struct hda_codec *);
  197. };
  198. /*
  199. * input MUX handling
  200. */
  201. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  202. struct snd_ctl_elem_info *uinfo)
  203. {
  204. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  205. struct alc_spec *spec = codec->spec;
  206. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  207. if (mux_idx >= spec->num_mux_defs)
  208. mux_idx = 0;
  209. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  210. }
  211. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  212. struct snd_ctl_elem_value *ucontrol)
  213. {
  214. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  215. struct alc_spec *spec = codec->spec;
  216. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  217. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  218. return 0;
  219. }
  220. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  221. struct snd_ctl_elem_value *ucontrol)
  222. {
  223. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  224. struct alc_spec *spec = codec->spec;
  225. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  226. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  227. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  228. spec->adc_nids[adc_idx],
  229. &spec->cur_mux[adc_idx]);
  230. }
  231. /*
  232. * channel mode setting
  233. */
  234. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  235. struct snd_ctl_elem_info *uinfo)
  236. {
  237. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  238. struct alc_spec *spec = codec->spec;
  239. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  240. spec->num_channel_mode);
  241. }
  242. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  243. struct snd_ctl_elem_value *ucontrol)
  244. {
  245. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  246. struct alc_spec *spec = codec->spec;
  247. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  248. spec->num_channel_mode,
  249. spec->multiout.max_channels);
  250. }
  251. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  252. struct snd_ctl_elem_value *ucontrol)
  253. {
  254. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  255. struct alc_spec *spec = codec->spec;
  256. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  257. spec->num_channel_mode,
  258. &spec->multiout.max_channels);
  259. if (err >= 0 && spec->need_dac_fix)
  260. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  261. return err;
  262. }
  263. /*
  264. * Control the mode of pin widget settings via the mixer. "pc" is used
  265. * instead of "%" to avoid consequences of accidently treating the % as
  266. * being part of a format specifier. Maximum allowed length of a value is
  267. * 63 characters plus NULL terminator.
  268. *
  269. * Note: some retasking pin complexes seem to ignore requests for input
  270. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  271. * are requested. Therefore order this list so that this behaviour will not
  272. * cause problems when mixer clients move through the enum sequentially.
  273. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  274. * March 2006.
  275. */
  276. static char *alc_pin_mode_names[] = {
  277. "Mic 50pc bias", "Mic 80pc bias",
  278. "Line in", "Line out", "Headphone out",
  279. };
  280. static unsigned char alc_pin_mode_values[] = {
  281. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  282. };
  283. /* The control can present all 5 options, or it can limit the options based
  284. * in the pin being assumed to be exclusively an input or an output pin. In
  285. * addition, "input" pins may or may not process the mic bias option
  286. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  287. * accept requests for bias as of chip versions up to March 2006) and/or
  288. * wiring in the computer.
  289. */
  290. #define ALC_PIN_DIR_IN 0x00
  291. #define ALC_PIN_DIR_OUT 0x01
  292. #define ALC_PIN_DIR_INOUT 0x02
  293. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  294. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  295. /* Info about the pin modes supported by the different pin direction modes.
  296. * For each direction the minimum and maximum values are given.
  297. */
  298. static signed char alc_pin_mode_dir_info[5][2] = {
  299. { 0, 2 }, /* ALC_PIN_DIR_IN */
  300. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  301. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  302. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  303. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  304. };
  305. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  306. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  307. #define alc_pin_mode_n_items(_dir) \
  308. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  309. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  310. struct snd_ctl_elem_info *uinfo)
  311. {
  312. unsigned int item_num = uinfo->value.enumerated.item;
  313. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  314. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  315. uinfo->count = 1;
  316. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  317. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  318. item_num = alc_pin_mode_min(dir);
  319. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  320. return 0;
  321. }
  322. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  323. struct snd_ctl_elem_value *ucontrol)
  324. {
  325. unsigned int i;
  326. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  327. hda_nid_t nid = kcontrol->private_value & 0xffff;
  328. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  329. long *valp = ucontrol->value.integer.value;
  330. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  331. AC_VERB_GET_PIN_WIDGET_CONTROL,
  332. 0x00);
  333. /* Find enumerated value for current pinctl setting */
  334. i = alc_pin_mode_min(dir);
  335. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  336. i++;
  337. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  338. return 0;
  339. }
  340. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  341. struct snd_ctl_elem_value *ucontrol)
  342. {
  343. signed int change;
  344. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  345. hda_nid_t nid = kcontrol->private_value & 0xffff;
  346. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  347. long val = *ucontrol->value.integer.value;
  348. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  349. AC_VERB_GET_PIN_WIDGET_CONTROL,
  350. 0x00);
  351. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  352. val = alc_pin_mode_min(dir);
  353. change = pinctl != alc_pin_mode_values[val];
  354. if (change) {
  355. /* Set pin mode to that requested */
  356. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  357. alc_pin_mode_values[val]);
  358. /* Also enable the retasking pin's input/output as required
  359. * for the requested pin mode. Enum values of 2 or less are
  360. * input modes.
  361. *
  362. * Dynamically switching the input/output buffers probably
  363. * reduces noise slightly (particularly on input) so we'll
  364. * do it. However, having both input and output buffers
  365. * enabled simultaneously doesn't seem to be problematic if
  366. * this turns out to be necessary in the future.
  367. */
  368. if (val <= 2) {
  369. snd_hda_codec_write(codec, nid, 0,
  370. AC_VERB_SET_AMP_GAIN_MUTE,
  371. AMP_OUT_MUTE);
  372. snd_hda_codec_write(codec, nid, 0,
  373. AC_VERB_SET_AMP_GAIN_MUTE,
  374. AMP_IN_UNMUTE(0));
  375. } else {
  376. snd_hda_codec_write(codec, nid, 0,
  377. AC_VERB_SET_AMP_GAIN_MUTE,
  378. AMP_IN_MUTE(0));
  379. snd_hda_codec_write(codec, nid, 0,
  380. AC_VERB_SET_AMP_GAIN_MUTE,
  381. AMP_OUT_UNMUTE);
  382. }
  383. }
  384. return change;
  385. }
  386. #define ALC_PIN_MODE(xname, nid, dir) \
  387. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  388. .info = alc_pin_mode_info, \
  389. .get = alc_pin_mode_get, \
  390. .put = alc_pin_mode_put, \
  391. .private_value = nid | (dir<<16) }
  392. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  393. * together using a mask with more than one bit set. This control is
  394. * currently used only by the ALC260 test model. At this stage they are not
  395. * needed for any "production" models.
  396. */
  397. #ifdef CONFIG_SND_DEBUG
  398. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  399. struct snd_ctl_elem_info *uinfo)
  400. {
  401. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  402. uinfo->count = 1;
  403. uinfo->value.integer.min = 0;
  404. uinfo->value.integer.max = 1;
  405. return 0;
  406. }
  407. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  408. struct snd_ctl_elem_value *ucontrol)
  409. {
  410. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  411. hda_nid_t nid = kcontrol->private_value & 0xffff;
  412. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  413. long *valp = ucontrol->value.integer.value;
  414. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  415. AC_VERB_GET_GPIO_DATA, 0x00);
  416. *valp = (val & mask) != 0;
  417. return 0;
  418. }
  419. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  420. struct snd_ctl_elem_value *ucontrol)
  421. {
  422. signed int change;
  423. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  424. hda_nid_t nid = kcontrol->private_value & 0xffff;
  425. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  426. long val = *ucontrol->value.integer.value;
  427. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  428. AC_VERB_GET_GPIO_DATA,
  429. 0x00);
  430. /* Set/unset the masked GPIO bit(s) as needed */
  431. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  432. if (val == 0)
  433. gpio_data &= ~mask;
  434. else
  435. gpio_data |= mask;
  436. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  437. return change;
  438. }
  439. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  440. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  441. .info = alc_gpio_data_info, \
  442. .get = alc_gpio_data_get, \
  443. .put = alc_gpio_data_put, \
  444. .private_value = nid | (mask<<16) }
  445. #endif /* CONFIG_SND_DEBUG */
  446. /* A switch control to allow the enabling of the digital IO pins on the
  447. * ALC260. This is incredibly simplistic; the intention of this control is
  448. * to provide something in the test model allowing digital outputs to be
  449. * identified if present. If models are found which can utilise these
  450. * outputs a more complete mixer control can be devised for those models if
  451. * necessary.
  452. */
  453. #ifdef CONFIG_SND_DEBUG
  454. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  455. struct snd_ctl_elem_info *uinfo)
  456. {
  457. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  458. uinfo->count = 1;
  459. uinfo->value.integer.min = 0;
  460. uinfo->value.integer.max = 1;
  461. return 0;
  462. }
  463. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  464. struct snd_ctl_elem_value *ucontrol)
  465. {
  466. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  467. hda_nid_t nid = kcontrol->private_value & 0xffff;
  468. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  469. long *valp = ucontrol->value.integer.value;
  470. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  471. AC_VERB_GET_DIGI_CONVERT, 0x00);
  472. *valp = (val & mask) != 0;
  473. return 0;
  474. }
  475. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  476. struct snd_ctl_elem_value *ucontrol)
  477. {
  478. signed int change;
  479. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  480. hda_nid_t nid = kcontrol->private_value & 0xffff;
  481. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  482. long val = *ucontrol->value.integer.value;
  483. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  484. AC_VERB_GET_DIGI_CONVERT,
  485. 0x00);
  486. /* Set/unset the masked control bit(s) as needed */
  487. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  488. if (val==0)
  489. ctrl_data &= ~mask;
  490. else
  491. ctrl_data |= mask;
  492. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  493. ctrl_data);
  494. return change;
  495. }
  496. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  497. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  498. .info = alc_spdif_ctrl_info, \
  499. .get = alc_spdif_ctrl_get, \
  500. .put = alc_spdif_ctrl_put, \
  501. .private_value = nid | (mask<<16) }
  502. #endif /* CONFIG_SND_DEBUG */
  503. /*
  504. * set up from the preset table
  505. */
  506. static void setup_preset(struct alc_spec *spec,
  507. const struct alc_config_preset *preset)
  508. {
  509. int i;
  510. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  511. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  512. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  513. i++)
  514. spec->init_verbs[spec->num_init_verbs++] =
  515. preset->init_verbs[i];
  516. spec->channel_mode = preset->channel_mode;
  517. spec->num_channel_mode = preset->num_channel_mode;
  518. spec->need_dac_fix = preset->need_dac_fix;
  519. spec->multiout.max_channels = spec->channel_mode[0].channels;
  520. spec->multiout.num_dacs = preset->num_dacs;
  521. spec->multiout.dac_nids = preset->dac_nids;
  522. spec->multiout.dig_out_nid = preset->dig_out_nid;
  523. spec->multiout.hp_nid = preset->hp_nid;
  524. spec->num_mux_defs = preset->num_mux_defs;
  525. if (! spec->num_mux_defs)
  526. spec->num_mux_defs = 1;
  527. spec->input_mux = preset->input_mux;
  528. spec->num_adc_nids = preset->num_adc_nids;
  529. spec->adc_nids = preset->adc_nids;
  530. spec->dig_in_nid = preset->dig_in_nid;
  531. spec->unsol_event = preset->unsol_event;
  532. spec->init_hook = preset->init_hook;
  533. }
  534. /*
  535. * ALC880 3-stack model
  536. *
  537. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  538. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  539. * F-Mic = 0x1b, HP = 0x19
  540. */
  541. static hda_nid_t alc880_dac_nids[4] = {
  542. /* front, rear, clfe, rear_surr */
  543. 0x02, 0x05, 0x04, 0x03
  544. };
  545. static hda_nid_t alc880_adc_nids[3] = {
  546. /* ADC0-2 */
  547. 0x07, 0x08, 0x09,
  548. };
  549. /* The datasheet says the node 0x07 is connected from inputs,
  550. * but it shows zero connection in the real implementation on some devices.
  551. * Note: this is a 915GAV bug, fixed on 915GLV
  552. */
  553. static hda_nid_t alc880_adc_nids_alt[2] = {
  554. /* ADC1-2 */
  555. 0x08, 0x09,
  556. };
  557. #define ALC880_DIGOUT_NID 0x06
  558. #define ALC880_DIGIN_NID 0x0a
  559. static struct hda_input_mux alc880_capture_source = {
  560. .num_items = 4,
  561. .items = {
  562. { "Mic", 0x0 },
  563. { "Front Mic", 0x3 },
  564. { "Line", 0x2 },
  565. { "CD", 0x4 },
  566. },
  567. };
  568. /* channel source setting (2/6 channel selection for 3-stack) */
  569. /* 2ch mode */
  570. static struct hda_verb alc880_threestack_ch2_init[] = {
  571. /* set line-in to input, mute it */
  572. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  573. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  574. /* set mic-in to input vref 80%, mute it */
  575. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  576. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  577. { } /* end */
  578. };
  579. /* 6ch mode */
  580. static struct hda_verb alc880_threestack_ch6_init[] = {
  581. /* set line-in to output, unmute it */
  582. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  583. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  584. /* set mic-in to output, unmute it */
  585. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  586. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  587. { } /* end */
  588. };
  589. static struct hda_channel_mode alc880_threestack_modes[2] = {
  590. { 2, alc880_threestack_ch2_init },
  591. { 6, alc880_threestack_ch6_init },
  592. };
  593. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  594. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  595. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  596. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  597. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  598. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  599. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  600. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  601. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  602. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  603. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  604. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  605. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  606. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  607. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  608. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  609. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  610. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  611. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  612. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  613. {
  614. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  615. .name = "Channel Mode",
  616. .info = alc_ch_mode_info,
  617. .get = alc_ch_mode_get,
  618. .put = alc_ch_mode_put,
  619. },
  620. { } /* end */
  621. };
  622. /* capture mixer elements */
  623. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  624. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  625. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  626. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  627. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  628. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  629. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  630. {
  631. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  632. /* The multiple "Capture Source" controls confuse alsamixer
  633. * So call somewhat different..
  634. * FIXME: the controls appear in the "playback" view!
  635. */
  636. /* .name = "Capture Source", */
  637. .name = "Input Source",
  638. .count = 3,
  639. .info = alc_mux_enum_info,
  640. .get = alc_mux_enum_get,
  641. .put = alc_mux_enum_put,
  642. },
  643. { } /* end */
  644. };
  645. /* capture mixer elements (in case NID 0x07 not available) */
  646. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  647. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  648. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  649. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  650. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  651. {
  652. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  653. /* The multiple "Capture Source" controls confuse alsamixer
  654. * So call somewhat different..
  655. * FIXME: the controls appear in the "playback" view!
  656. */
  657. /* .name = "Capture Source", */
  658. .name = "Input Source",
  659. .count = 2,
  660. .info = alc_mux_enum_info,
  661. .get = alc_mux_enum_get,
  662. .put = alc_mux_enum_put,
  663. },
  664. { } /* end */
  665. };
  666. /*
  667. * ALC880 5-stack model
  668. *
  669. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  670. * Side = 0x02 (0xd)
  671. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  672. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  673. */
  674. /* additional mixers to alc880_three_stack_mixer */
  675. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  676. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  677. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  678. { } /* end */
  679. };
  680. /* channel source setting (6/8 channel selection for 5-stack) */
  681. /* 6ch mode */
  682. static struct hda_verb alc880_fivestack_ch6_init[] = {
  683. /* set line-in to input, mute it */
  684. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  685. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  686. { } /* end */
  687. };
  688. /* 8ch mode */
  689. static struct hda_verb alc880_fivestack_ch8_init[] = {
  690. /* set line-in to output, unmute it */
  691. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  692. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  693. { } /* end */
  694. };
  695. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  696. { 6, alc880_fivestack_ch6_init },
  697. { 8, alc880_fivestack_ch8_init },
  698. };
  699. /*
  700. * ALC880 6-stack model
  701. *
  702. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  703. * Side = 0x05 (0x0f)
  704. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  705. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  706. */
  707. static hda_nid_t alc880_6st_dac_nids[4] = {
  708. /* front, rear, clfe, rear_surr */
  709. 0x02, 0x03, 0x04, 0x05
  710. };
  711. static struct hda_input_mux alc880_6stack_capture_source = {
  712. .num_items = 4,
  713. .items = {
  714. { "Mic", 0x0 },
  715. { "Front Mic", 0x1 },
  716. { "Line", 0x2 },
  717. { "CD", 0x4 },
  718. },
  719. };
  720. /* fixed 8-channels */
  721. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  722. { 8, NULL },
  723. };
  724. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  725. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  726. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  727. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  728. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  729. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  730. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  731. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  732. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  733. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  734. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  735. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  736. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  737. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  738. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  739. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  740. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  741. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  742. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  743. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  744. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  745. {
  746. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  747. .name = "Channel Mode",
  748. .info = alc_ch_mode_info,
  749. .get = alc_ch_mode_get,
  750. .put = alc_ch_mode_put,
  751. },
  752. { } /* end */
  753. };
  754. /*
  755. * ALC880 W810 model
  756. *
  757. * W810 has rear IO for:
  758. * Front (DAC 02)
  759. * Surround (DAC 03)
  760. * Center/LFE (DAC 04)
  761. * Digital out (06)
  762. *
  763. * The system also has a pair of internal speakers, and a headphone jack.
  764. * These are both connected to Line2 on the codec, hence to DAC 02.
  765. *
  766. * There is a variable resistor to control the speaker or headphone
  767. * volume. This is a hardware-only device without a software API.
  768. *
  769. * Plugging headphones in will disable the internal speakers. This is
  770. * implemented in hardware, not via the driver using jack sense. In
  771. * a similar fashion, plugging into the rear socket marked "front" will
  772. * disable both the speakers and headphones.
  773. *
  774. * For input, there's a microphone jack, and an "audio in" jack.
  775. * These may not do anything useful with this driver yet, because I
  776. * haven't setup any initialization verbs for these yet...
  777. */
  778. static hda_nid_t alc880_w810_dac_nids[3] = {
  779. /* front, rear/surround, clfe */
  780. 0x02, 0x03, 0x04
  781. };
  782. /* fixed 6 channels */
  783. static struct hda_channel_mode alc880_w810_modes[1] = {
  784. { 6, NULL }
  785. };
  786. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  787. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  788. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  789. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  790. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  791. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  792. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  793. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  794. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  795. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  796. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  797. { } /* end */
  798. };
  799. /*
  800. * Z710V model
  801. *
  802. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  803. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  804. * Line = 0x1a
  805. */
  806. static hda_nid_t alc880_z71v_dac_nids[1] = {
  807. 0x02
  808. };
  809. #define ALC880_Z71V_HP_DAC 0x03
  810. /* fixed 2 channels */
  811. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  812. { 2, NULL }
  813. };
  814. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  815. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  816. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  817. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  818. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  819. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  820. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  821. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  822. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  823. { } /* end */
  824. };
  825. /* FIXME! */
  826. /*
  827. * ALC880 F1734 model
  828. *
  829. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  830. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  831. */
  832. static hda_nid_t alc880_f1734_dac_nids[1] = {
  833. 0x03
  834. };
  835. #define ALC880_F1734_HP_DAC 0x02
  836. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  837. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  838. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  839. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  840. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  841. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  842. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  843. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  844. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  845. { } /* end */
  846. };
  847. /* FIXME! */
  848. /*
  849. * ALC880 ASUS model
  850. *
  851. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  852. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  853. * Mic = 0x18, Line = 0x1a
  854. */
  855. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  856. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  857. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  858. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  859. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  860. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  861. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  862. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  863. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  864. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  865. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  866. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  867. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  868. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  869. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  870. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  871. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  872. {
  873. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  874. .name = "Channel Mode",
  875. .info = alc_ch_mode_info,
  876. .get = alc_ch_mode_get,
  877. .put = alc_ch_mode_put,
  878. },
  879. { } /* end */
  880. };
  881. /* FIXME! */
  882. /*
  883. * ALC880 ASUS W1V model
  884. *
  885. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  886. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  887. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  888. */
  889. /* additional mixers to alc880_asus_mixer */
  890. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  891. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  892. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  893. { } /* end */
  894. };
  895. /* additional mixers to alc880_asus_mixer */
  896. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  897. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  898. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  899. { } /* end */
  900. };
  901. /* TCL S700 */
  902. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  903. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  904. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  905. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  906. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  907. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  908. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  909. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  910. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  911. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  912. {
  913. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  914. /* The multiple "Capture Source" controls confuse alsamixer
  915. * So call somewhat different..
  916. * FIXME: the controls appear in the "playback" view!
  917. */
  918. /* .name = "Capture Source", */
  919. .name = "Input Source",
  920. .count = 1,
  921. .info = alc_mux_enum_info,
  922. .get = alc_mux_enum_get,
  923. .put = alc_mux_enum_put,
  924. },
  925. { } /* end */
  926. };
  927. /* Uniwill */
  928. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  929. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  930. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  931. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  932. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  933. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  934. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  935. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  936. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  937. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  938. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  939. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  940. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  941. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  942. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  943. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  944. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  945. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  946. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  947. {
  948. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  949. .name = "Channel Mode",
  950. .info = alc_ch_mode_info,
  951. .get = alc_ch_mode_get,
  952. .put = alc_ch_mode_put,
  953. },
  954. { } /* end */
  955. };
  956. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  957. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  958. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  959. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  960. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  961. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  962. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  963. { } /* end */
  964. };
  965. /*
  966. * build control elements
  967. */
  968. static int alc_build_controls(struct hda_codec *codec)
  969. {
  970. struct alc_spec *spec = codec->spec;
  971. int err;
  972. int i;
  973. for (i = 0; i < spec->num_mixers; i++) {
  974. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  975. if (err < 0)
  976. return err;
  977. }
  978. if (spec->multiout.dig_out_nid) {
  979. err = snd_hda_create_spdif_out_ctls(codec,
  980. spec->multiout.dig_out_nid);
  981. if (err < 0)
  982. return err;
  983. }
  984. if (spec->dig_in_nid) {
  985. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  986. if (err < 0)
  987. return err;
  988. }
  989. return 0;
  990. }
  991. /*
  992. * initialize the codec volumes, etc
  993. */
  994. /*
  995. * generic initialization of ADC, input mixers and output mixers
  996. */
  997. static struct hda_verb alc880_volume_init_verbs[] = {
  998. /*
  999. * Unmute ADC0-2 and set the default input to mic-in
  1000. */
  1001. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1002. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1003. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1004. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1005. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1006. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1007. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1008. * mixer widget
  1009. * Note: PASD motherboards uses the Line In 2 as the input for front
  1010. * panel mic (mic 2)
  1011. */
  1012. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1013. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1014. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1015. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1016. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1017. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1018. /*
  1019. * Set up output mixers (0x0c - 0x0f)
  1020. */
  1021. /* set vol=0 to output mixers */
  1022. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1023. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1024. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1025. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1026. /* set up input amps for analog loopback */
  1027. /* Amp Indices: DAC = 0, mixer = 1 */
  1028. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1029. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1030. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1031. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1032. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1033. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1034. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1035. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1036. { }
  1037. };
  1038. /*
  1039. * 3-stack pin configuration:
  1040. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1041. */
  1042. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1043. /*
  1044. * preset connection lists of input pins
  1045. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1046. */
  1047. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1048. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1049. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1050. /*
  1051. * Set pin mode and muting
  1052. */
  1053. /* set front pin widgets 0x14 for output */
  1054. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1055. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1056. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1057. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1058. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1059. /* Mic2 (as headphone out) for HP output */
  1060. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1061. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1062. /* Line In pin widget for input */
  1063. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1064. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1065. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1066. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1067. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1068. /* CD pin widget for input */
  1069. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1070. { }
  1071. };
  1072. /*
  1073. * 5-stack pin configuration:
  1074. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1075. * line-in/side = 0x1a, f-mic = 0x1b
  1076. */
  1077. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1078. /*
  1079. * preset connection lists of input pins
  1080. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1081. */
  1082. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1083. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1084. /*
  1085. * Set pin mode and muting
  1086. */
  1087. /* set pin widgets 0x14-0x17 for output */
  1088. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1089. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1090. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1091. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1092. /* unmute pins for output (no gain on this amp) */
  1093. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1094. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1095. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1096. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1097. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1098. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1099. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1100. /* Mic2 (as headphone out) for HP output */
  1101. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1102. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1103. /* Line In pin widget for input */
  1104. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1105. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1106. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1107. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1108. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1109. /* CD pin widget for input */
  1110. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1111. { }
  1112. };
  1113. /*
  1114. * W810 pin configuration:
  1115. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1116. */
  1117. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1118. /* hphone/speaker input selector: front DAC */
  1119. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1120. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1121. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1122. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1123. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1124. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1125. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1126. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1127. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1128. { }
  1129. };
  1130. /*
  1131. * Z71V pin configuration:
  1132. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1133. */
  1134. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1135. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1136. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1137. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1138. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1139. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1140. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1141. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1142. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1143. { }
  1144. };
  1145. /*
  1146. * 6-stack pin configuration:
  1147. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1148. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1149. */
  1150. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1151. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1152. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1153. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1154. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1155. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1156. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1157. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1158. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1159. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1160. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1161. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1162. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1163. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1164. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1165. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1166. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1167. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1168. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1169. { }
  1170. };
  1171. /*
  1172. * Uniwill pin configuration:
  1173. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1174. * line = 0x1a
  1175. */
  1176. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1177. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1178. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1179. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1180. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1181. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1182. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1183. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1184. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1185. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1186. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1187. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1188. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1189. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1190. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1191. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1192. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1193. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1194. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1195. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1196. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1197. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1198. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1199. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1200. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1201. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1202. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1203. { }
  1204. };
  1205. /*
  1206. * Uniwill P53
  1207. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1208. */
  1209. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1210. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1211. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1212. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1213. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1214. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1215. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1216. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1217. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1218. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1219. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1220. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1221. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1222. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1223. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1224. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1225. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1226. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1227. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1228. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1229. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1230. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1231. { }
  1232. };
  1233. /* toggle speaker-output according to the hp-jack state */
  1234. static void alc880_uniwill_automute(struct hda_codec *codec)
  1235. {
  1236. unsigned int present;
  1237. present = snd_hda_codec_read(codec, 0x14, 0,
  1238. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1239. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1240. 0x80, present ? 0x80 : 0);
  1241. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1242. 0x80, present ? 0x80 : 0);
  1243. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1244. 0x80, present ? 0x80 : 0);
  1245. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1246. 0x80, present ? 0x80 : 0);
  1247. present = snd_hda_codec_read(codec, 0x18, 0,
  1248. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1249. snd_hda_codec_write(codec, 0x0b, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1250. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  1251. }
  1252. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1253. unsigned int res)
  1254. {
  1255. /* Looks like the unsol event is incompatible with the standard
  1256. * definition. 4bit tag is placed at 28 bit!
  1257. */
  1258. if ((res >> 28) == ALC880_HP_EVENT ||
  1259. (res >> 28) == ALC880_MIC_EVENT)
  1260. alc880_uniwill_automute(codec);
  1261. }
  1262. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1263. {
  1264. unsigned int present;
  1265. present = snd_hda_codec_read(codec, 0x14, 0,
  1266. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1267. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1268. 0x80, present ? 0x80 : 0);
  1269. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1270. 0x80, present ? 0x80 : 0);
  1271. }
  1272. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1273. {
  1274. unsigned int present;
  1275. present = snd_hda_codec_read(codec, 0x21, 0,
  1276. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1277. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1278. 0x7f, present);
  1279. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1280. 0x7f, present);
  1281. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1282. 0x7f, present);
  1283. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1284. 0x7f, present);
  1285. }
  1286. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1287. unsigned int res)
  1288. {
  1289. /* Looks like the unsol event is incompatible with the standard
  1290. * definition. 4bit tag is placed at 28 bit!
  1291. */
  1292. if ((res >> 28) == ALC880_HP_EVENT)
  1293. alc880_uniwill_p53_hp_automute(codec);
  1294. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1295. alc880_uniwill_p53_dcvol_automute(codec);
  1296. }
  1297. /* FIXME! */
  1298. /*
  1299. * F1734 pin configuration:
  1300. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1301. */
  1302. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1303. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1304. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1305. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1306. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1307. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1308. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1309. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1310. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1311. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1312. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1313. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1314. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1315. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1316. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1318. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1319. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1320. { }
  1321. };
  1322. /* FIXME! */
  1323. /*
  1324. * ASUS pin configuration:
  1325. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1326. */
  1327. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1328. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1329. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1330. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1331. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1332. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1333. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1334. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1335. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1336. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1337. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1338. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1339. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1340. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1341. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1342. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1343. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1344. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1345. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1346. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1347. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1348. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1349. { }
  1350. };
  1351. /* Enable GPIO mask and set output */
  1352. static struct hda_verb alc880_gpio1_init_verbs[] = {
  1353. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  1354. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  1355. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  1356. { }
  1357. };
  1358. /* Enable GPIO mask and set output */
  1359. static struct hda_verb alc880_gpio2_init_verbs[] = {
  1360. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  1361. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  1362. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  1363. { }
  1364. };
  1365. /* Clevo m520g init */
  1366. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1367. /* headphone output */
  1368. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1369. /* line-out */
  1370. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1371. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1372. /* Line-in */
  1373. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1374. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1375. /* CD */
  1376. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1377. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1378. /* Mic1 (rear panel) */
  1379. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1380. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1381. /* Mic2 (front panel) */
  1382. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1383. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1384. /* headphone */
  1385. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1386. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1387. /* change to EAPD mode */
  1388. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1389. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1390. { }
  1391. };
  1392. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1393. /* change to EAPD mode */
  1394. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1395. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1396. /* Headphone output */
  1397. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1398. /* Front output*/
  1399. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1400. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1401. /* Line In pin widget for input */
  1402. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1403. /* CD pin widget for input */
  1404. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1405. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1406. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1407. /* change to EAPD mode */
  1408. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1409. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1410. { }
  1411. };
  1412. /*
  1413. * LG m1 express dual
  1414. *
  1415. * Pin assignment:
  1416. * Rear Line-In/Out (blue): 0x14
  1417. * Build-in Mic-In: 0x15
  1418. * Speaker-out: 0x17
  1419. * HP-Out (green): 0x1b
  1420. * Mic-In/Out (red): 0x19
  1421. * SPDIF-Out: 0x1e
  1422. */
  1423. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1424. static hda_nid_t alc880_lg_dac_nids[3] = {
  1425. 0x05, 0x02, 0x03
  1426. };
  1427. /* seems analog CD is not working */
  1428. static struct hda_input_mux alc880_lg_capture_source = {
  1429. .num_items = 3,
  1430. .items = {
  1431. { "Mic", 0x1 },
  1432. { "Line", 0x5 },
  1433. { "Internal Mic", 0x6 },
  1434. },
  1435. };
  1436. /* 2,4,6 channel modes */
  1437. static struct hda_verb alc880_lg_ch2_init[] = {
  1438. /* set line-in and mic-in to input */
  1439. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1440. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1441. { }
  1442. };
  1443. static struct hda_verb alc880_lg_ch4_init[] = {
  1444. /* set line-in to out and mic-in to input */
  1445. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1446. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1447. { }
  1448. };
  1449. static struct hda_verb alc880_lg_ch6_init[] = {
  1450. /* set line-in and mic-in to output */
  1451. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1452. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1453. { }
  1454. };
  1455. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1456. { 2, alc880_lg_ch2_init },
  1457. { 4, alc880_lg_ch4_init },
  1458. { 6, alc880_lg_ch6_init },
  1459. };
  1460. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1461. /* FIXME: it's not really "master" but front channels */
  1462. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1463. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1464. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1465. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1466. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1467. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1468. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1469. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1470. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1471. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1472. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1473. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1474. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1475. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1476. {
  1477. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1478. .name = "Channel Mode",
  1479. .info = alc_ch_mode_info,
  1480. .get = alc_ch_mode_get,
  1481. .put = alc_ch_mode_put,
  1482. },
  1483. { } /* end */
  1484. };
  1485. static struct hda_verb alc880_lg_init_verbs[] = {
  1486. /* set capture source to mic-in */
  1487. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1488. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1489. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1490. /* mute all amp mixer inputs */
  1491. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1492. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1493. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1494. /* line-in to input */
  1495. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1496. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1497. /* built-in mic */
  1498. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1499. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1500. /* speaker-out */
  1501. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1502. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1503. /* mic-in to input */
  1504. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1505. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1506. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1507. /* HP-out */
  1508. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1509. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1510. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1511. /* jack sense */
  1512. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1513. { }
  1514. };
  1515. /* toggle speaker-output according to the hp-jack state */
  1516. static void alc880_lg_automute(struct hda_codec *codec)
  1517. {
  1518. unsigned int present;
  1519. present = snd_hda_codec_read(codec, 0x1b, 0,
  1520. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1521. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1522. 0x80, present ? 0x80 : 0);
  1523. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1524. 0x80, present ? 0x80 : 0);
  1525. }
  1526. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1527. {
  1528. /* Looks like the unsol event is incompatible with the standard
  1529. * definition. 4bit tag is placed at 28 bit!
  1530. */
  1531. if ((res >> 28) == 0x01)
  1532. alc880_lg_automute(codec);
  1533. }
  1534. /*
  1535. * LG LW20
  1536. *
  1537. * Pin assignment:
  1538. * Speaker-out: 0x14
  1539. * Mic-In: 0x18
  1540. * Built-in Mic-In: 0x19 (?)
  1541. * HP-Out: 0x1b
  1542. * SPDIF-Out: 0x1e
  1543. */
  1544. /* seems analog CD is not working */
  1545. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1546. .num_items = 2,
  1547. .items = {
  1548. { "Mic", 0x0 },
  1549. { "Internal Mic", 0x1 },
  1550. },
  1551. };
  1552. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1553. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1554. HDA_BIND_MUTE("Master Playback Switch", 0x0c, 2, HDA_INPUT),
  1555. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1556. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1557. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1558. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1559. { } /* end */
  1560. };
  1561. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1562. /* set capture source to mic-in */
  1563. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1564. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1565. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1566. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1567. /* speaker-out */
  1568. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1569. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1570. /* HP-out */
  1571. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1572. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1573. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1574. /* mic-in to input */
  1575. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1576. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1577. /* built-in mic */
  1578. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1579. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1580. /* jack sense */
  1581. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1582. { }
  1583. };
  1584. /* toggle speaker-output according to the hp-jack state */
  1585. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1586. {
  1587. unsigned int present;
  1588. present = snd_hda_codec_read(codec, 0x1b, 0,
  1589. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1590. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1591. 0x80, present ? 0x80 : 0);
  1592. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1593. 0x80, present ? 0x80 : 0);
  1594. }
  1595. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1596. {
  1597. /* Looks like the unsol event is incompatible with the standard
  1598. * definition. 4bit tag is placed at 28 bit!
  1599. */
  1600. if ((res >> 28) == 0x01)
  1601. alc880_lg_lw_automute(codec);
  1602. }
  1603. /*
  1604. * Common callbacks
  1605. */
  1606. static int alc_init(struct hda_codec *codec)
  1607. {
  1608. struct alc_spec *spec = codec->spec;
  1609. unsigned int i;
  1610. for (i = 0; i < spec->num_init_verbs; i++)
  1611. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1612. if (spec->init_hook)
  1613. spec->init_hook(codec);
  1614. return 0;
  1615. }
  1616. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1617. {
  1618. struct alc_spec *spec = codec->spec;
  1619. if (spec->unsol_event)
  1620. spec->unsol_event(codec, res);
  1621. }
  1622. #ifdef CONFIG_PM
  1623. /*
  1624. * resume
  1625. */
  1626. static int alc_resume(struct hda_codec *codec)
  1627. {
  1628. struct alc_spec *spec = codec->spec;
  1629. int i;
  1630. alc_init(codec);
  1631. for (i = 0; i < spec->num_mixers; i++)
  1632. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1633. if (spec->multiout.dig_out_nid)
  1634. snd_hda_resume_spdif_out(codec);
  1635. if (spec->dig_in_nid)
  1636. snd_hda_resume_spdif_in(codec);
  1637. return 0;
  1638. }
  1639. #endif
  1640. /*
  1641. * Analog playback callbacks
  1642. */
  1643. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1644. struct hda_codec *codec,
  1645. struct snd_pcm_substream *substream)
  1646. {
  1647. struct alc_spec *spec = codec->spec;
  1648. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1649. }
  1650. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1651. struct hda_codec *codec,
  1652. unsigned int stream_tag,
  1653. unsigned int format,
  1654. struct snd_pcm_substream *substream)
  1655. {
  1656. struct alc_spec *spec = codec->spec;
  1657. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1658. stream_tag, format, substream);
  1659. }
  1660. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1661. struct hda_codec *codec,
  1662. struct snd_pcm_substream *substream)
  1663. {
  1664. struct alc_spec *spec = codec->spec;
  1665. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1666. }
  1667. /*
  1668. * Digital out
  1669. */
  1670. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1671. struct hda_codec *codec,
  1672. struct snd_pcm_substream *substream)
  1673. {
  1674. struct alc_spec *spec = codec->spec;
  1675. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1676. }
  1677. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1678. struct hda_codec *codec,
  1679. struct snd_pcm_substream *substream)
  1680. {
  1681. struct alc_spec *spec = codec->spec;
  1682. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1683. }
  1684. /*
  1685. * Analog capture
  1686. */
  1687. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1688. struct hda_codec *codec,
  1689. unsigned int stream_tag,
  1690. unsigned int format,
  1691. struct snd_pcm_substream *substream)
  1692. {
  1693. struct alc_spec *spec = codec->spec;
  1694. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1695. stream_tag, 0, format);
  1696. return 0;
  1697. }
  1698. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1699. struct hda_codec *codec,
  1700. struct snd_pcm_substream *substream)
  1701. {
  1702. struct alc_spec *spec = codec->spec;
  1703. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1704. 0, 0, 0);
  1705. return 0;
  1706. }
  1707. /*
  1708. */
  1709. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1710. .substreams = 1,
  1711. .channels_min = 2,
  1712. .channels_max = 8,
  1713. /* NID is set in alc_build_pcms */
  1714. .ops = {
  1715. .open = alc880_playback_pcm_open,
  1716. .prepare = alc880_playback_pcm_prepare,
  1717. .cleanup = alc880_playback_pcm_cleanup
  1718. },
  1719. };
  1720. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1721. .substreams = 2,
  1722. .channels_min = 2,
  1723. .channels_max = 2,
  1724. /* NID is set in alc_build_pcms */
  1725. .ops = {
  1726. .prepare = alc880_capture_pcm_prepare,
  1727. .cleanup = alc880_capture_pcm_cleanup
  1728. },
  1729. };
  1730. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1731. .substreams = 1,
  1732. .channels_min = 2,
  1733. .channels_max = 2,
  1734. /* NID is set in alc_build_pcms */
  1735. .ops = {
  1736. .open = alc880_dig_playback_pcm_open,
  1737. .close = alc880_dig_playback_pcm_close
  1738. },
  1739. };
  1740. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1741. .substreams = 1,
  1742. .channels_min = 2,
  1743. .channels_max = 2,
  1744. /* NID is set in alc_build_pcms */
  1745. };
  1746. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1747. static struct hda_pcm_stream alc_pcm_null_playback = {
  1748. .substreams = 0,
  1749. .channels_min = 0,
  1750. .channels_max = 0,
  1751. };
  1752. static int alc_build_pcms(struct hda_codec *codec)
  1753. {
  1754. struct alc_spec *spec = codec->spec;
  1755. struct hda_pcm *info = spec->pcm_rec;
  1756. int i;
  1757. codec->num_pcms = 1;
  1758. codec->pcm_info = info;
  1759. info->name = spec->stream_name_analog;
  1760. if (spec->stream_analog_playback) {
  1761. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1762. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1763. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1764. }
  1765. if (spec->stream_analog_capture) {
  1766. snd_assert(spec->adc_nids, return -EINVAL);
  1767. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1768. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1769. }
  1770. if (spec->channel_mode) {
  1771. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1772. for (i = 0; i < spec->num_channel_mode; i++) {
  1773. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1774. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1775. }
  1776. }
  1777. }
  1778. /* SPDIF for stream index #1 */
  1779. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1780. codec->num_pcms = 2;
  1781. info = spec->pcm_rec + 1;
  1782. info->name = spec->stream_name_digital;
  1783. if (spec->multiout.dig_out_nid &&
  1784. spec->stream_digital_playback) {
  1785. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1786. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1787. }
  1788. if (spec->dig_in_nid &&
  1789. spec->stream_digital_capture) {
  1790. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1791. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1792. }
  1793. }
  1794. /* If the use of more than one ADC is requested for the current
  1795. * model, configure a second analog capture-only PCM.
  1796. */
  1797. /* Additional Analaog capture for index #2 */
  1798. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1799. spec->adc_nids) {
  1800. codec->num_pcms = 3;
  1801. info = spec->pcm_rec + 2;
  1802. info->name = spec->stream_name_analog;
  1803. /* No playback stream for second PCM */
  1804. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1805. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1806. if (spec->stream_analog_capture) {
  1807. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1808. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1809. }
  1810. }
  1811. return 0;
  1812. }
  1813. static void alc_free(struct hda_codec *codec)
  1814. {
  1815. struct alc_spec *spec = codec->spec;
  1816. unsigned int i;
  1817. if (! spec)
  1818. return;
  1819. if (spec->kctl_alloc) {
  1820. for (i = 0; i < spec->num_kctl_used; i++)
  1821. kfree(spec->kctl_alloc[i].name);
  1822. kfree(spec->kctl_alloc);
  1823. }
  1824. kfree(spec);
  1825. }
  1826. /*
  1827. */
  1828. static struct hda_codec_ops alc_patch_ops = {
  1829. .build_controls = alc_build_controls,
  1830. .build_pcms = alc_build_pcms,
  1831. .init = alc_init,
  1832. .free = alc_free,
  1833. .unsol_event = alc_unsol_event,
  1834. #ifdef CONFIG_PM
  1835. .resume = alc_resume,
  1836. #endif
  1837. };
  1838. /*
  1839. * Test configuration for debugging
  1840. *
  1841. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  1842. * enum controls.
  1843. */
  1844. #ifdef CONFIG_SND_DEBUG
  1845. static hda_nid_t alc880_test_dac_nids[4] = {
  1846. 0x02, 0x03, 0x04, 0x05
  1847. };
  1848. static struct hda_input_mux alc880_test_capture_source = {
  1849. .num_items = 7,
  1850. .items = {
  1851. { "In-1", 0x0 },
  1852. { "In-2", 0x1 },
  1853. { "In-3", 0x2 },
  1854. { "In-4", 0x3 },
  1855. { "CD", 0x4 },
  1856. { "Front", 0x5 },
  1857. { "Surround", 0x6 },
  1858. },
  1859. };
  1860. static struct hda_channel_mode alc880_test_modes[4] = {
  1861. { 2, NULL },
  1862. { 4, NULL },
  1863. { 6, NULL },
  1864. { 8, NULL },
  1865. };
  1866. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  1867. struct snd_ctl_elem_info *uinfo)
  1868. {
  1869. static char *texts[] = {
  1870. "N/A", "Line Out", "HP Out",
  1871. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  1872. };
  1873. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1874. uinfo->count = 1;
  1875. uinfo->value.enumerated.items = 8;
  1876. if (uinfo->value.enumerated.item >= 8)
  1877. uinfo->value.enumerated.item = 7;
  1878. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1879. return 0;
  1880. }
  1881. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  1882. struct snd_ctl_elem_value *ucontrol)
  1883. {
  1884. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1885. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1886. unsigned int pin_ctl, item = 0;
  1887. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  1888. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1889. if (pin_ctl & AC_PINCTL_OUT_EN) {
  1890. if (pin_ctl & AC_PINCTL_HP_EN)
  1891. item = 2;
  1892. else
  1893. item = 1;
  1894. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  1895. switch (pin_ctl & AC_PINCTL_VREFEN) {
  1896. case AC_PINCTL_VREF_HIZ: item = 3; break;
  1897. case AC_PINCTL_VREF_50: item = 4; break;
  1898. case AC_PINCTL_VREF_GRD: item = 5; break;
  1899. case AC_PINCTL_VREF_80: item = 6; break;
  1900. case AC_PINCTL_VREF_100: item = 7; break;
  1901. }
  1902. }
  1903. ucontrol->value.enumerated.item[0] = item;
  1904. return 0;
  1905. }
  1906. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  1907. struct snd_ctl_elem_value *ucontrol)
  1908. {
  1909. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1910. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1911. static unsigned int ctls[] = {
  1912. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  1913. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  1914. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  1915. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  1916. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  1917. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  1918. };
  1919. unsigned int old_ctl, new_ctl;
  1920. old_ctl = snd_hda_codec_read(codec, nid, 0,
  1921. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  1922. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  1923. if (old_ctl != new_ctl) {
  1924. snd_hda_codec_write(codec, nid, 0,
  1925. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  1926. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  1927. (ucontrol->value.enumerated.item[0] >= 3 ?
  1928. 0xb080 : 0xb000));
  1929. return 1;
  1930. }
  1931. return 0;
  1932. }
  1933. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  1934. struct snd_ctl_elem_info *uinfo)
  1935. {
  1936. static char *texts[] = {
  1937. "Front", "Surround", "CLFE", "Side"
  1938. };
  1939. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  1940. uinfo->count = 1;
  1941. uinfo->value.enumerated.items = 4;
  1942. if (uinfo->value.enumerated.item >= 4)
  1943. uinfo->value.enumerated.item = 3;
  1944. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  1945. return 0;
  1946. }
  1947. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  1948. struct snd_ctl_elem_value *ucontrol)
  1949. {
  1950. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1951. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1952. unsigned int sel;
  1953. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  1954. ucontrol->value.enumerated.item[0] = sel & 3;
  1955. return 0;
  1956. }
  1957. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  1958. struct snd_ctl_elem_value *ucontrol)
  1959. {
  1960. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  1961. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  1962. unsigned int sel;
  1963. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  1964. if (ucontrol->value.enumerated.item[0] != sel) {
  1965. sel = ucontrol->value.enumerated.item[0] & 3;
  1966. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  1967. return 1;
  1968. }
  1969. return 0;
  1970. }
  1971. #define PIN_CTL_TEST(xname,nid) { \
  1972. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1973. .name = xname, \
  1974. .info = alc_test_pin_ctl_info, \
  1975. .get = alc_test_pin_ctl_get, \
  1976. .put = alc_test_pin_ctl_put, \
  1977. .private_value = nid \
  1978. }
  1979. #define PIN_SRC_TEST(xname,nid) { \
  1980. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  1981. .name = xname, \
  1982. .info = alc_test_pin_src_info, \
  1983. .get = alc_test_pin_src_get, \
  1984. .put = alc_test_pin_src_put, \
  1985. .private_value = nid \
  1986. }
  1987. static struct snd_kcontrol_new alc880_test_mixer[] = {
  1988. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1989. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1990. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  1991. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1992. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1993. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1994. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  1995. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1996. PIN_CTL_TEST("Front Pin Mode", 0x14),
  1997. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  1998. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  1999. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2000. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2001. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2002. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2003. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2004. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2005. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2006. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2007. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2008. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2009. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2010. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2011. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2012. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2013. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2014. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2015. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2016. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2017. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2018. {
  2019. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2020. .name = "Channel Mode",
  2021. .info = alc_ch_mode_info,
  2022. .get = alc_ch_mode_get,
  2023. .put = alc_ch_mode_put,
  2024. },
  2025. { } /* end */
  2026. };
  2027. static struct hda_verb alc880_test_init_verbs[] = {
  2028. /* Unmute inputs of 0x0c - 0x0f */
  2029. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2030. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2031. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2032. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2033. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2034. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2035. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2036. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2037. /* Vol output for 0x0c-0x0f */
  2038. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2039. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2040. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2041. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2042. /* Set output pins 0x14-0x17 */
  2043. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2044. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2045. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2046. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2047. /* Unmute output pins 0x14-0x17 */
  2048. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2049. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2050. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2051. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2052. /* Set input pins 0x18-0x1c */
  2053. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2054. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2055. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2056. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2057. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2058. /* Mute input pins 0x18-0x1b */
  2059. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2060. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2061. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2062. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2063. /* ADC set up */
  2064. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2065. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2066. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2067. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2068. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2069. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2070. /* Analog input/passthru */
  2071. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2072. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2073. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2074. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2075. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2076. { }
  2077. };
  2078. #endif
  2079. /*
  2080. */
  2081. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2082. [ALC880_3ST] = "3stack",
  2083. [ALC880_TCL_S700] = "tcl",
  2084. [ALC880_3ST_DIG] = "3stack-digout",
  2085. [ALC880_CLEVO] = "clevo",
  2086. [ALC880_5ST] = "5stack",
  2087. [ALC880_5ST_DIG] = "5stack-digout",
  2088. [ALC880_W810] = "w810",
  2089. [ALC880_Z71V] = "z71v",
  2090. [ALC880_6ST] = "6stack",
  2091. [ALC880_6ST_DIG] = "6stack-digout",
  2092. [ALC880_ASUS] = "asus",
  2093. [ALC880_ASUS_W1V] = "asus-w1v",
  2094. [ALC880_ASUS_DIG] = "asus-dig",
  2095. [ALC880_ASUS_DIG2] = "asus-dig2",
  2096. [ALC880_UNIWILL_DIG] = "uniwill",
  2097. [ALC880_F1734] = "F1734",
  2098. [ALC880_LG] = "lg",
  2099. [ALC880_LG_LW] = "lg-lw",
  2100. #ifdef CONFIG_SND_DEBUG
  2101. [ALC880_TEST] = "test",
  2102. #endif
  2103. [ALC880_AUTO] = "auto",
  2104. };
  2105. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2106. /* Broken BIOS configuration */
  2107. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2108. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2109. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2110. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2111. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2112. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2113. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2114. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2115. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2116. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2117. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2118. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2119. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2120. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2121. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2122. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2123. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2124. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2125. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2126. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2127. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2128. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2129. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2130. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2131. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2132. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2133. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2134. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2135. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2136. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2137. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2138. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2139. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2140. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2141. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2142. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2143. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2144. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2145. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2146. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2147. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2148. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2149. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2150. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2151. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2152. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2153. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2154. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2155. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2156. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2157. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2158. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2159. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2160. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2161. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2162. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2163. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2164. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2165. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2166. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2167. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2168. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2169. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2170. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2171. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2172. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2173. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2174. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2175. {}
  2176. };
  2177. /*
  2178. * ALC880 codec presets
  2179. */
  2180. static struct alc_config_preset alc880_presets[] = {
  2181. [ALC880_3ST] = {
  2182. .mixers = { alc880_three_stack_mixer },
  2183. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2184. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2185. .dac_nids = alc880_dac_nids,
  2186. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2187. .channel_mode = alc880_threestack_modes,
  2188. .need_dac_fix = 1,
  2189. .input_mux = &alc880_capture_source,
  2190. },
  2191. [ALC880_3ST_DIG] = {
  2192. .mixers = { alc880_three_stack_mixer },
  2193. .init_verbs = { alc880_volume_init_verbs, alc880_pin_3stack_init_verbs },
  2194. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2195. .dac_nids = alc880_dac_nids,
  2196. .dig_out_nid = ALC880_DIGOUT_NID,
  2197. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2198. .channel_mode = alc880_threestack_modes,
  2199. .need_dac_fix = 1,
  2200. .input_mux = &alc880_capture_source,
  2201. },
  2202. [ALC880_TCL_S700] = {
  2203. .mixers = { alc880_tcl_s700_mixer },
  2204. .init_verbs = { alc880_volume_init_verbs,
  2205. alc880_pin_tcl_S700_init_verbs,
  2206. alc880_gpio2_init_verbs },
  2207. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2208. .dac_nids = alc880_dac_nids,
  2209. .hp_nid = 0x03,
  2210. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2211. .channel_mode = alc880_2_jack_modes,
  2212. .input_mux = &alc880_capture_source,
  2213. },
  2214. [ALC880_5ST] = {
  2215. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer},
  2216. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2217. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2218. .dac_nids = alc880_dac_nids,
  2219. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2220. .channel_mode = alc880_fivestack_modes,
  2221. .input_mux = &alc880_capture_source,
  2222. },
  2223. [ALC880_5ST_DIG] = {
  2224. .mixers = { alc880_three_stack_mixer, alc880_five_stack_mixer },
  2225. .init_verbs = { alc880_volume_init_verbs, alc880_pin_5stack_init_verbs },
  2226. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2227. .dac_nids = alc880_dac_nids,
  2228. .dig_out_nid = ALC880_DIGOUT_NID,
  2229. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2230. .channel_mode = alc880_fivestack_modes,
  2231. .input_mux = &alc880_capture_source,
  2232. },
  2233. [ALC880_6ST] = {
  2234. .mixers = { alc880_six_stack_mixer },
  2235. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2236. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2237. .dac_nids = alc880_6st_dac_nids,
  2238. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2239. .channel_mode = alc880_sixstack_modes,
  2240. .input_mux = &alc880_6stack_capture_source,
  2241. },
  2242. [ALC880_6ST_DIG] = {
  2243. .mixers = { alc880_six_stack_mixer },
  2244. .init_verbs = { alc880_volume_init_verbs, alc880_pin_6stack_init_verbs },
  2245. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2246. .dac_nids = alc880_6st_dac_nids,
  2247. .dig_out_nid = ALC880_DIGOUT_NID,
  2248. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2249. .channel_mode = alc880_sixstack_modes,
  2250. .input_mux = &alc880_6stack_capture_source,
  2251. },
  2252. [ALC880_W810] = {
  2253. .mixers = { alc880_w810_base_mixer },
  2254. .init_verbs = { alc880_volume_init_verbs, alc880_pin_w810_init_verbs,
  2255. alc880_gpio2_init_verbs },
  2256. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2257. .dac_nids = alc880_w810_dac_nids,
  2258. .dig_out_nid = ALC880_DIGOUT_NID,
  2259. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2260. .channel_mode = alc880_w810_modes,
  2261. .input_mux = &alc880_capture_source,
  2262. },
  2263. [ALC880_Z71V] = {
  2264. .mixers = { alc880_z71v_mixer },
  2265. .init_verbs = { alc880_volume_init_verbs, alc880_pin_z71v_init_verbs },
  2266. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2267. .dac_nids = alc880_z71v_dac_nids,
  2268. .dig_out_nid = ALC880_DIGOUT_NID,
  2269. .hp_nid = 0x03,
  2270. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2271. .channel_mode = alc880_2_jack_modes,
  2272. .input_mux = &alc880_capture_source,
  2273. },
  2274. [ALC880_F1734] = {
  2275. .mixers = { alc880_f1734_mixer },
  2276. .init_verbs = { alc880_volume_init_verbs, alc880_pin_f1734_init_verbs },
  2277. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2278. .dac_nids = alc880_f1734_dac_nids,
  2279. .hp_nid = 0x02,
  2280. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2281. .channel_mode = alc880_2_jack_modes,
  2282. .input_mux = &alc880_capture_source,
  2283. },
  2284. [ALC880_ASUS] = {
  2285. .mixers = { alc880_asus_mixer },
  2286. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2287. alc880_gpio1_init_verbs },
  2288. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2289. .dac_nids = alc880_asus_dac_nids,
  2290. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2291. .channel_mode = alc880_asus_modes,
  2292. .need_dac_fix = 1,
  2293. .input_mux = &alc880_capture_source,
  2294. },
  2295. [ALC880_ASUS_DIG] = {
  2296. .mixers = { alc880_asus_mixer },
  2297. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2298. alc880_gpio1_init_verbs },
  2299. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2300. .dac_nids = alc880_asus_dac_nids,
  2301. .dig_out_nid = ALC880_DIGOUT_NID,
  2302. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2303. .channel_mode = alc880_asus_modes,
  2304. .need_dac_fix = 1,
  2305. .input_mux = &alc880_capture_source,
  2306. },
  2307. [ALC880_ASUS_DIG2] = {
  2308. .mixers = { alc880_asus_mixer },
  2309. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2310. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2311. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2312. .dac_nids = alc880_asus_dac_nids,
  2313. .dig_out_nid = ALC880_DIGOUT_NID,
  2314. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2315. .channel_mode = alc880_asus_modes,
  2316. .need_dac_fix = 1,
  2317. .input_mux = &alc880_capture_source,
  2318. },
  2319. [ALC880_ASUS_W1V] = {
  2320. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2321. .init_verbs = { alc880_volume_init_verbs, alc880_pin_asus_init_verbs,
  2322. alc880_gpio1_init_verbs },
  2323. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2324. .dac_nids = alc880_asus_dac_nids,
  2325. .dig_out_nid = ALC880_DIGOUT_NID,
  2326. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2327. .channel_mode = alc880_asus_modes,
  2328. .need_dac_fix = 1,
  2329. .input_mux = &alc880_capture_source,
  2330. },
  2331. [ALC880_UNIWILL_DIG] = {
  2332. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2333. .init_verbs = { alc880_volume_init_verbs,
  2334. alc880_pin_asus_init_verbs },
  2335. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2336. .dac_nids = alc880_asus_dac_nids,
  2337. .dig_out_nid = ALC880_DIGOUT_NID,
  2338. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2339. .channel_mode = alc880_asus_modes,
  2340. .need_dac_fix = 1,
  2341. .input_mux = &alc880_capture_source,
  2342. },
  2343. [ALC880_UNIWILL] = {
  2344. .mixers = { alc880_uniwill_mixer },
  2345. .init_verbs = { alc880_volume_init_verbs,
  2346. alc880_uniwill_init_verbs },
  2347. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2348. .dac_nids = alc880_asus_dac_nids,
  2349. .dig_out_nid = ALC880_DIGOUT_NID,
  2350. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2351. .channel_mode = alc880_threestack_modes,
  2352. .need_dac_fix = 1,
  2353. .input_mux = &alc880_capture_source,
  2354. .unsol_event = alc880_uniwill_unsol_event,
  2355. .init_hook = alc880_uniwill_automute,
  2356. },
  2357. [ALC880_UNIWILL_P53] = {
  2358. .mixers = { alc880_uniwill_p53_mixer },
  2359. .init_verbs = { alc880_volume_init_verbs,
  2360. alc880_uniwill_p53_init_verbs },
  2361. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2362. .dac_nids = alc880_asus_dac_nids,
  2363. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2364. .channel_mode = alc880_w810_modes,
  2365. .input_mux = &alc880_capture_source,
  2366. .unsol_event = alc880_uniwill_p53_unsol_event,
  2367. .init_hook = alc880_uniwill_p53_hp_automute,
  2368. },
  2369. [ALC880_CLEVO] = {
  2370. .mixers = { alc880_three_stack_mixer },
  2371. .init_verbs = { alc880_volume_init_verbs,
  2372. alc880_pin_clevo_init_verbs },
  2373. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2374. .dac_nids = alc880_dac_nids,
  2375. .hp_nid = 0x03,
  2376. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2377. .channel_mode = alc880_threestack_modes,
  2378. .need_dac_fix = 1,
  2379. .input_mux = &alc880_capture_source,
  2380. },
  2381. [ALC880_LG] = {
  2382. .mixers = { alc880_lg_mixer },
  2383. .init_verbs = { alc880_volume_init_verbs,
  2384. alc880_lg_init_verbs },
  2385. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2386. .dac_nids = alc880_lg_dac_nids,
  2387. .dig_out_nid = ALC880_DIGOUT_NID,
  2388. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2389. .channel_mode = alc880_lg_ch_modes,
  2390. .need_dac_fix = 1,
  2391. .input_mux = &alc880_lg_capture_source,
  2392. .unsol_event = alc880_lg_unsol_event,
  2393. .init_hook = alc880_lg_automute,
  2394. },
  2395. [ALC880_LG_LW] = {
  2396. .mixers = { alc880_lg_lw_mixer },
  2397. .init_verbs = { alc880_volume_init_verbs,
  2398. alc880_lg_lw_init_verbs },
  2399. .num_dacs = 1,
  2400. .dac_nids = alc880_dac_nids,
  2401. .dig_out_nid = ALC880_DIGOUT_NID,
  2402. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2403. .channel_mode = alc880_2_jack_modes,
  2404. .input_mux = &alc880_lg_lw_capture_source,
  2405. .unsol_event = alc880_lg_lw_unsol_event,
  2406. .init_hook = alc880_lg_lw_automute,
  2407. },
  2408. #ifdef CONFIG_SND_DEBUG
  2409. [ALC880_TEST] = {
  2410. .mixers = { alc880_test_mixer },
  2411. .init_verbs = { alc880_test_init_verbs },
  2412. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2413. .dac_nids = alc880_test_dac_nids,
  2414. .dig_out_nid = ALC880_DIGOUT_NID,
  2415. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2416. .channel_mode = alc880_test_modes,
  2417. .input_mux = &alc880_test_capture_source,
  2418. },
  2419. #endif
  2420. };
  2421. /*
  2422. * Automatic parse of I/O pins from the BIOS configuration
  2423. */
  2424. #define NUM_CONTROL_ALLOC 32
  2425. #define NUM_VERB_ALLOC 32
  2426. enum {
  2427. ALC_CTL_WIDGET_VOL,
  2428. ALC_CTL_WIDGET_MUTE,
  2429. ALC_CTL_BIND_MUTE,
  2430. };
  2431. static struct snd_kcontrol_new alc880_control_templates[] = {
  2432. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2433. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2434. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2435. };
  2436. /* add dynamic controls */
  2437. static int add_control(struct alc_spec *spec, int type, const char *name, unsigned long val)
  2438. {
  2439. struct snd_kcontrol_new *knew;
  2440. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2441. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2442. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL); /* array + terminator */
  2443. if (! knew)
  2444. return -ENOMEM;
  2445. if (spec->kctl_alloc) {
  2446. memcpy(knew, spec->kctl_alloc, sizeof(*knew) * spec->num_kctl_alloc);
  2447. kfree(spec->kctl_alloc);
  2448. }
  2449. spec->kctl_alloc = knew;
  2450. spec->num_kctl_alloc = num;
  2451. }
  2452. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2453. *knew = alc880_control_templates[type];
  2454. knew->name = kstrdup(name, GFP_KERNEL);
  2455. if (! knew->name)
  2456. return -ENOMEM;
  2457. knew->private_value = val;
  2458. spec->num_kctl_used++;
  2459. return 0;
  2460. }
  2461. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2462. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2463. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2464. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2465. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2466. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2467. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2468. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2469. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2470. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2471. #define ALC880_PIN_CD_NID 0x1c
  2472. /* fill in the dac_nids table from the parsed pin configuration */
  2473. static int alc880_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  2474. {
  2475. hda_nid_t nid;
  2476. int assigned[4];
  2477. int i, j;
  2478. memset(assigned, 0, sizeof(assigned));
  2479. spec->multiout.dac_nids = spec->private_dac_nids;
  2480. /* check the pins hardwired to audio widget */
  2481. for (i = 0; i < cfg->line_outs; i++) {
  2482. nid = cfg->line_out_pins[i];
  2483. if (alc880_is_fixed_pin(nid)) {
  2484. int idx = alc880_fixed_pin_idx(nid);
  2485. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2486. assigned[idx] = 1;
  2487. }
  2488. }
  2489. /* left pins can be connect to any audio widget */
  2490. for (i = 0; i < cfg->line_outs; i++) {
  2491. nid = cfg->line_out_pins[i];
  2492. if (alc880_is_fixed_pin(nid))
  2493. continue;
  2494. /* search for an empty channel */
  2495. for (j = 0; j < cfg->line_outs; j++) {
  2496. if (! assigned[j]) {
  2497. spec->multiout.dac_nids[i] = alc880_idx_to_dac(j);
  2498. assigned[j] = 1;
  2499. break;
  2500. }
  2501. }
  2502. }
  2503. spec->multiout.num_dacs = cfg->line_outs;
  2504. return 0;
  2505. }
  2506. /* add playback controls from the parsed DAC table */
  2507. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2508. const struct auto_pin_cfg *cfg)
  2509. {
  2510. char name[32];
  2511. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  2512. hda_nid_t nid;
  2513. int i, err;
  2514. for (i = 0; i < cfg->line_outs; i++) {
  2515. if (! spec->multiout.dac_nids[i])
  2516. continue;
  2517. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2518. if (i == 2) {
  2519. /* Center/LFE */
  2520. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Center Playback Volume",
  2521. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  2522. return err;
  2523. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "LFE Playback Volume",
  2524. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  2525. return err;
  2526. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  2527. HDA_COMPOSE_AMP_VAL(nid, 1, 2, HDA_INPUT))) < 0)
  2528. return err;
  2529. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  2530. HDA_COMPOSE_AMP_VAL(nid, 2, 2, HDA_INPUT))) < 0)
  2531. return err;
  2532. } else {
  2533. sprintf(name, "%s Playback Volume", chname[i]);
  2534. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2535. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2536. return err;
  2537. sprintf(name, "%s Playback Switch", chname[i]);
  2538. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2539. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2540. return err;
  2541. }
  2542. }
  2543. return 0;
  2544. }
  2545. /* add playback controls for speaker and HP outputs */
  2546. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2547. const char *pfx)
  2548. {
  2549. hda_nid_t nid;
  2550. int err;
  2551. char name[32];
  2552. if (! pin)
  2553. return 0;
  2554. if (alc880_is_fixed_pin(pin)) {
  2555. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2556. /* specify the DAC as the extra output */
  2557. if (! spec->multiout.hp_nid)
  2558. spec->multiout.hp_nid = nid;
  2559. else
  2560. spec->multiout.extra_out_nid[0] = nid;
  2561. /* control HP volume/switch on the output mixer amp */
  2562. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2563. sprintf(name, "%s Playback Volume", pfx);
  2564. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2565. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  2566. return err;
  2567. sprintf(name, "%s Playback Switch", pfx);
  2568. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2569. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT))) < 0)
  2570. return err;
  2571. } else if (alc880_is_multi_pin(pin)) {
  2572. /* set manual connection */
  2573. /* we have only a switch on HP-out PIN */
  2574. sprintf(name, "%s Playback Switch", pfx);
  2575. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2576. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT))) < 0)
  2577. return err;
  2578. }
  2579. return 0;
  2580. }
  2581. /* create input playback/capture controls for the given pin */
  2582. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin, const char *ctlname,
  2583. int idx, hda_nid_t mix_nid)
  2584. {
  2585. char name[32];
  2586. int err;
  2587. sprintf(name, "%s Playback Volume", ctlname);
  2588. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2589. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2590. return err;
  2591. sprintf(name, "%s Playback Switch", ctlname);
  2592. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2593. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT))) < 0)
  2594. return err;
  2595. return 0;
  2596. }
  2597. /* create playback/capture controls for input pins */
  2598. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2599. const struct auto_pin_cfg *cfg)
  2600. {
  2601. struct hda_input_mux *imux = &spec->private_imux;
  2602. int i, err, idx;
  2603. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2604. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2605. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2606. err = new_analog_input(spec, cfg->input_pins[i],
  2607. auto_pin_cfg_labels[i],
  2608. idx, 0x0b);
  2609. if (err < 0)
  2610. return err;
  2611. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  2612. imux->items[imux->num_items].index = alc880_input_pin_idx(cfg->input_pins[i]);
  2613. imux->num_items++;
  2614. }
  2615. }
  2616. return 0;
  2617. }
  2618. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2619. hda_nid_t nid, int pin_type,
  2620. int dac_idx)
  2621. {
  2622. /* set as output */
  2623. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  2624. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  2625. /* need the manual connection? */
  2626. if (alc880_is_multi_pin(nid)) {
  2627. struct alc_spec *spec = codec->spec;
  2628. int idx = alc880_multi_pin_idx(nid);
  2629. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2630. AC_VERB_SET_CONNECT_SEL,
  2631. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2632. }
  2633. }
  2634. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2635. {
  2636. struct alc_spec *spec = codec->spec;
  2637. int i;
  2638. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2639. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2640. alc880_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  2641. }
  2642. }
  2643. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2644. {
  2645. struct alc_spec *spec = codec->spec;
  2646. hda_nid_t pin;
  2647. pin = spec->autocfg.speaker_pins[0];
  2648. if (pin) /* connect to front */
  2649. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2650. pin = spec->autocfg.hp_pins[0];
  2651. if (pin) /* connect to front */
  2652. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2653. }
  2654. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2655. {
  2656. struct alc_spec *spec = codec->spec;
  2657. int i;
  2658. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2659. hda_nid_t nid = spec->autocfg.input_pins[i];
  2660. if (alc880_is_input_pin(nid)) {
  2661. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2662. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  2663. if (nid != ALC880_PIN_CD_NID)
  2664. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2665. AMP_OUT_MUTE);
  2666. }
  2667. }
  2668. }
  2669. /* parse the BIOS configuration and set up the alc_spec */
  2670. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  2671. static int alc880_parse_auto_config(struct hda_codec *codec)
  2672. {
  2673. struct alc_spec *spec = codec->spec;
  2674. int err;
  2675. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2676. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2677. alc880_ignore)) < 0)
  2678. return err;
  2679. if (! spec->autocfg.line_outs)
  2680. return 0; /* can't find valid BIOS pin config */
  2681. if ((err = alc880_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  2682. (err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  2683. (err = alc880_auto_create_extra_out(spec,
  2684. spec->autocfg.speaker_pins[0],
  2685. "Speaker")) < 0 ||
  2686. (err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2687. "Headphone")) < 0 ||
  2688. (err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  2689. return err;
  2690. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2691. if (spec->autocfg.dig_out_pin)
  2692. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2693. if (spec->autocfg.dig_in_pin)
  2694. spec->dig_in_nid = ALC880_DIGIN_NID;
  2695. if (spec->kctl_alloc)
  2696. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2697. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2698. spec->num_mux_defs = 1;
  2699. spec->input_mux = &spec->private_imux;
  2700. return 1;
  2701. }
  2702. /* additional initialization for auto-configuration model */
  2703. static void alc880_auto_init(struct hda_codec *codec)
  2704. {
  2705. alc880_auto_init_multi_out(codec);
  2706. alc880_auto_init_extra_out(codec);
  2707. alc880_auto_init_analog_input(codec);
  2708. }
  2709. /*
  2710. * OK, here we have finally the patch for ALC880
  2711. */
  2712. static int patch_alc880(struct hda_codec *codec)
  2713. {
  2714. struct alc_spec *spec;
  2715. int board_config;
  2716. int err;
  2717. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2718. if (spec == NULL)
  2719. return -ENOMEM;
  2720. codec->spec = spec;
  2721. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2722. alc880_models,
  2723. alc880_cfg_tbl);
  2724. if (board_config < 0) {
  2725. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2726. "trying auto-probe from BIOS...\n");
  2727. board_config = ALC880_AUTO;
  2728. }
  2729. if (board_config == ALC880_AUTO) {
  2730. /* automatic parse from the BIOS config */
  2731. err = alc880_parse_auto_config(codec);
  2732. if (err < 0) {
  2733. alc_free(codec);
  2734. return err;
  2735. } else if (! err) {
  2736. printk(KERN_INFO
  2737. "hda_codec: Cannot set up configuration "
  2738. "from BIOS. Using 3-stack mode...\n");
  2739. board_config = ALC880_3ST;
  2740. }
  2741. }
  2742. if (board_config != ALC880_AUTO)
  2743. setup_preset(spec, &alc880_presets[board_config]);
  2744. spec->stream_name_analog = "ALC880 Analog";
  2745. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  2746. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  2747. spec->stream_name_digital = "ALC880 Digital";
  2748. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  2749. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  2750. if (! spec->adc_nids && spec->input_mux) {
  2751. /* check whether NID 0x07 is valid */
  2752. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  2753. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  2754. if (wcap != AC_WID_AUD_IN) {
  2755. spec->adc_nids = alc880_adc_nids_alt;
  2756. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  2757. spec->mixers[spec->num_mixers] = alc880_capture_alt_mixer;
  2758. spec->num_mixers++;
  2759. } else {
  2760. spec->adc_nids = alc880_adc_nids;
  2761. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  2762. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  2763. spec->num_mixers++;
  2764. }
  2765. }
  2766. codec->patch_ops = alc_patch_ops;
  2767. if (board_config == ALC880_AUTO)
  2768. spec->init_hook = alc880_auto_init;
  2769. return 0;
  2770. }
  2771. /*
  2772. * ALC260 support
  2773. */
  2774. static hda_nid_t alc260_dac_nids[1] = {
  2775. /* front */
  2776. 0x02,
  2777. };
  2778. static hda_nid_t alc260_adc_nids[1] = {
  2779. /* ADC0 */
  2780. 0x04,
  2781. };
  2782. static hda_nid_t alc260_adc_nids_alt[1] = {
  2783. /* ADC1 */
  2784. 0x05,
  2785. };
  2786. static hda_nid_t alc260_hp_adc_nids[2] = {
  2787. /* ADC1, 0 */
  2788. 0x05, 0x04
  2789. };
  2790. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  2791. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  2792. */
  2793. static hda_nid_t alc260_dual_adc_nids[2] = {
  2794. /* ADC0, ADC1 */
  2795. 0x04, 0x05
  2796. };
  2797. #define ALC260_DIGOUT_NID 0x03
  2798. #define ALC260_DIGIN_NID 0x06
  2799. static struct hda_input_mux alc260_capture_source = {
  2800. .num_items = 4,
  2801. .items = {
  2802. { "Mic", 0x0 },
  2803. { "Front Mic", 0x1 },
  2804. { "Line", 0x2 },
  2805. { "CD", 0x4 },
  2806. },
  2807. };
  2808. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  2809. * headphone jack and the internal CD lines since these are the only pins at
  2810. * which audio can appear. For flexibility, also allow the option of
  2811. * recording the mixer output on the second ADC (ADC0 doesn't have a
  2812. * connection to the mixer output).
  2813. */
  2814. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  2815. {
  2816. .num_items = 3,
  2817. .items = {
  2818. { "Mic/Line", 0x0 },
  2819. { "CD", 0x4 },
  2820. { "Headphone", 0x2 },
  2821. },
  2822. },
  2823. {
  2824. .num_items = 4,
  2825. .items = {
  2826. { "Mic/Line", 0x0 },
  2827. { "CD", 0x4 },
  2828. { "Headphone", 0x2 },
  2829. { "Mixer", 0x5 },
  2830. },
  2831. },
  2832. };
  2833. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  2834. * the Fujitsu S702x, but jacks are marked differently.
  2835. */
  2836. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  2837. {
  2838. .num_items = 4,
  2839. .items = {
  2840. { "Mic", 0x0 },
  2841. { "Line", 0x2 },
  2842. { "CD", 0x4 },
  2843. { "Headphone", 0x5 },
  2844. },
  2845. },
  2846. {
  2847. .num_items = 5,
  2848. .items = {
  2849. { "Mic", 0x0 },
  2850. { "Line", 0x2 },
  2851. { "CD", 0x4 },
  2852. { "Headphone", 0x6 },
  2853. { "Mixer", 0x5 },
  2854. },
  2855. },
  2856. };
  2857. /*
  2858. * This is just place-holder, so there's something for alc_build_pcms to look
  2859. * at when it calculates the maximum number of channels. ALC260 has no mixer
  2860. * element which allows changing the channel mode, so the verb list is
  2861. * never used.
  2862. */
  2863. static struct hda_channel_mode alc260_modes[1] = {
  2864. { 2, NULL },
  2865. };
  2866. /* Mixer combinations
  2867. *
  2868. * basic: base_output + input + pc_beep + capture
  2869. * HP: base_output + input + capture_alt
  2870. * HP_3013: hp_3013 + input + capture
  2871. * fujitsu: fujitsu + capture
  2872. * acer: acer + capture
  2873. */
  2874. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  2875. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2876. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  2877. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2878. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  2879. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2880. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  2881. { } /* end */
  2882. };
  2883. static struct snd_kcontrol_new alc260_input_mixer[] = {
  2884. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2885. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2886. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2887. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2888. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2889. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2890. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  2891. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  2892. { } /* end */
  2893. };
  2894. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  2895. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  2896. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  2897. { } /* end */
  2898. };
  2899. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  2900. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2901. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  2902. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  2903. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  2904. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2905. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  2906. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  2907. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  2908. { } /* end */
  2909. };
  2910. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  2911. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  2912. */
  2913. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  2914. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2915. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  2916. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2917. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2918. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2919. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  2920. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  2921. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2922. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2923. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2924. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  2925. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  2926. { } /* end */
  2927. };
  2928. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  2929. * versions of the ALC260 don't act on requests to enable mic bias from NID
  2930. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  2931. * datasheet doesn't mention this restriction. At this stage it's not clear
  2932. * whether this behaviour is intentional or is a hardware bug in chip
  2933. * revisions available in early 2006. Therefore for now allow the
  2934. * "Headphone Jack Mode" control to span all choices, but if it turns out
  2935. * that the lack of mic bias for this NID is intentional we could change the
  2936. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2937. *
  2938. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  2939. * don't appear to make the mic bias available from the "line" jack, even
  2940. * though the NID used for this jack (0x14) can supply it. The theory is
  2941. * that perhaps Acer have included blocking capacitors between the ALC260
  2942. * and the output jack. If this turns out to be the case for all such
  2943. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  2944. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  2945. *
  2946. * The C20x Tablet series have a mono internal speaker which is controlled
  2947. * via the chip's Mono sum widget and pin complex, so include the necessary
  2948. * controls for such models. On models without a "mono speaker" the control
  2949. * won't do anything.
  2950. */
  2951. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  2952. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  2953. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  2954. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  2955. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  2956. HDA_OUTPUT),
  2957. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  2958. HDA_INPUT),
  2959. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  2960. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  2961. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  2962. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  2963. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  2964. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  2965. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  2966. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  2967. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  2968. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  2969. { } /* end */
  2970. };
  2971. /* capture mixer elements */
  2972. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  2973. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  2974. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  2975. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  2976. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  2977. {
  2978. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2979. /* The multiple "Capture Source" controls confuse alsamixer
  2980. * So call somewhat different..
  2981. * FIXME: the controls appear in the "playback" view!
  2982. */
  2983. /* .name = "Capture Source", */
  2984. .name = "Input Source",
  2985. .count = 2,
  2986. .info = alc_mux_enum_info,
  2987. .get = alc_mux_enum_get,
  2988. .put = alc_mux_enum_put,
  2989. },
  2990. { } /* end */
  2991. };
  2992. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  2993. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  2994. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  2995. {
  2996. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2997. /* The multiple "Capture Source" controls confuse alsamixer
  2998. * So call somewhat different..
  2999. * FIXME: the controls appear in the "playback" view!
  3000. */
  3001. /* .name = "Capture Source", */
  3002. .name = "Input Source",
  3003. .count = 1,
  3004. .info = alc_mux_enum_info,
  3005. .get = alc_mux_enum_get,
  3006. .put = alc_mux_enum_put,
  3007. },
  3008. { } /* end */
  3009. };
  3010. /*
  3011. * initialization verbs
  3012. */
  3013. static struct hda_verb alc260_init_verbs[] = {
  3014. /* Line In pin widget for input */
  3015. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3016. /* CD pin widget for input */
  3017. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3018. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3019. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3020. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3021. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3022. /* LINE-2 is used for line-out in rear */
  3023. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3024. /* select line-out */
  3025. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3026. /* LINE-OUT pin */
  3027. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3028. /* enable HP */
  3029. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3030. /* enable Mono */
  3031. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3032. /* mute capture amp left and right */
  3033. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3034. /* set connection select to line in (default select for this ADC) */
  3035. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3036. /* mute capture amp left and right */
  3037. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3038. /* set connection select to line in (default select for this ADC) */
  3039. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3040. /* set vol=0 Line-Out mixer amp left and right */
  3041. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3042. /* unmute pin widget amp left and right (no gain on this amp) */
  3043. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3044. /* set vol=0 HP mixer amp left and right */
  3045. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3046. /* unmute pin widget amp left and right (no gain on this amp) */
  3047. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3048. /* set vol=0 Mono mixer amp left and right */
  3049. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3050. /* unmute pin widget amp left and right (no gain on this amp) */
  3051. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3052. /* unmute LINE-2 out pin */
  3053. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3054. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3055. /* mute CD */
  3056. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3057. /* mute Line In */
  3058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3059. /* mute Mic */
  3060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3061. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3062. /* mute Front out path */
  3063. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3064. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3065. /* mute Headphone out path */
  3066. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3067. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3068. /* mute Mono out path */
  3069. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3070. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3071. { }
  3072. };
  3073. #if 0 /* should be identical with alc260_init_verbs? */
  3074. static struct hda_verb alc260_hp_init_verbs[] = {
  3075. /* Headphone and output */
  3076. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3077. /* mono output */
  3078. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3079. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3080. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3081. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3082. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3083. /* Line In pin widget for input */
  3084. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3085. /* Line-2 pin widget for output */
  3086. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3087. /* CD pin widget for input */
  3088. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3089. /* unmute amp left and right */
  3090. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3091. /* set connection select to line in (default select for this ADC) */
  3092. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3093. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3094. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3095. /* mute pin widget amp left and right (no gain on this amp) */
  3096. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3097. /* unmute HP mixer amp left and right (volume = 0) */
  3098. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3099. /* mute pin widget amp left and right (no gain on this amp) */
  3100. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3101. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3102. /* unmute CD */
  3103. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3104. /* unmute Line In */
  3105. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3106. /* unmute Mic */
  3107. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3108. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3109. /* Unmute Front out path */
  3110. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3111. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3112. /* Unmute Headphone out path */
  3113. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3114. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3115. /* Unmute Mono out path */
  3116. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3117. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3118. { }
  3119. };
  3120. #endif
  3121. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3122. /* Line out and output */
  3123. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3124. /* mono output */
  3125. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3126. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3127. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3128. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3129. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3130. /* Line In pin widget for input */
  3131. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3132. /* Headphone pin widget for output */
  3133. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3134. /* CD pin widget for input */
  3135. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3136. /* unmute amp left and right */
  3137. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3138. /* set connection select to line in (default select for this ADC) */
  3139. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3140. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3141. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3142. /* mute pin widget amp left and right (no gain on this amp) */
  3143. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3144. /* unmute HP mixer amp left and right (volume = 0) */
  3145. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3146. /* mute pin widget amp left and right (no gain on this amp) */
  3147. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3148. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 & Line In 2 = 0x03 */
  3149. /* unmute CD */
  3150. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3151. /* unmute Line In */
  3152. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3153. /* unmute Mic */
  3154. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3155. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3156. /* Unmute Front out path */
  3157. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3158. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3159. /* Unmute Headphone out path */
  3160. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3161. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3162. /* Unmute Mono out path */
  3163. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3164. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3165. { }
  3166. };
  3167. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3168. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3169. * audio = 0x16, internal speaker = 0x10.
  3170. */
  3171. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3172. /* Disable all GPIOs */
  3173. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3174. /* Internal speaker is connected to headphone pin */
  3175. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3176. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3177. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3178. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3179. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3180. /* Ensure all other unused pins are disabled and muted. */
  3181. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3182. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3183. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3184. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3185. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3186. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3187. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3188. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3189. /* Disable digital (SPDIF) pins */
  3190. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3191. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3192. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3193. * when acting as an output.
  3194. */
  3195. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3196. /* Start with output sum widgets muted and their output gains at min */
  3197. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3198. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3199. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3200. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3201. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3202. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3203. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3204. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3205. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3206. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3207. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3208. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3209. * If the pin mode is changed by the user the pin mode control will
  3210. * take care of enabling the pin's input/output buffers as needed.
  3211. * Therefore there's no need to enable the input buffer at this
  3212. * stage.
  3213. */
  3214. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3215. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3216. * mixer ctrl)
  3217. */
  3218. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3219. /* Mute capture amp left and right */
  3220. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3221. /* Set ADC connection select to match default mixer setting - line
  3222. * in (on mic1 pin)
  3223. */
  3224. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3225. /* Do the same for the second ADC: mute capture input amp and
  3226. * set ADC connection to line in (on mic1 pin)
  3227. */
  3228. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3229. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3230. /* Mute all inputs to mixer widget (even unconnected ones) */
  3231. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3232. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3233. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3234. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3235. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3236. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3237. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3238. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3239. { }
  3240. };
  3241. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3242. * similar laptops (adapted from Fujitsu init verbs).
  3243. */
  3244. static struct hda_verb alc260_acer_init_verbs[] = {
  3245. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3246. * the headphone jack. Turn this on and rely on the standard mute
  3247. * methods whenever the user wants to turn these outputs off.
  3248. */
  3249. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3250. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3251. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3252. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3253. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3254. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3255. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3256. /* Line In jack is connected to Line1 pin */
  3257. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3258. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3259. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3260. /* Ensure all other unused pins are disabled and muted. */
  3261. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3262. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3263. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3264. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3265. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3266. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3267. /* Disable digital (SPDIF) pins */
  3268. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3269. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3270. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3271. * bus when acting as outputs.
  3272. */
  3273. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3274. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3275. /* Start with output sum widgets muted and their output gains at min */
  3276. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3277. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3278. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3279. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3280. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3281. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3282. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3283. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3284. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3285. /* Unmute Line-out pin widget amp left and right (no equiv mixer ctrl) */
  3286. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3287. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3288. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3289. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3290. * inputs. If the pin mode is changed by the user the pin mode control
  3291. * will take care of enabling the pin's input/output buffers as needed.
  3292. * Therefore there's no need to enable the input buffer at this
  3293. * stage.
  3294. */
  3295. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3296. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3297. /* Mute capture amp left and right */
  3298. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3299. /* Set ADC connection select to match default mixer setting - mic
  3300. * (on mic1 pin)
  3301. */
  3302. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3303. /* Do similar with the second ADC: mute capture input amp and
  3304. * set ADC connection to mic to match ALSA's default state.
  3305. */
  3306. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3307. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3308. /* Mute all inputs to mixer widget (even unconnected ones) */
  3309. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3310. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3311. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3312. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3313. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3314. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3315. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3316. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3317. { }
  3318. };
  3319. /* Test configuration for debugging, modelled after the ALC880 test
  3320. * configuration.
  3321. */
  3322. #ifdef CONFIG_SND_DEBUG
  3323. static hda_nid_t alc260_test_dac_nids[1] = {
  3324. 0x02,
  3325. };
  3326. static hda_nid_t alc260_test_adc_nids[2] = {
  3327. 0x04, 0x05,
  3328. };
  3329. /* For testing the ALC260, each input MUX needs its own definition since
  3330. * the signal assignments are different. This assumes that the first ADC
  3331. * is NID 0x04.
  3332. */
  3333. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3334. {
  3335. .num_items = 7,
  3336. .items = {
  3337. { "MIC1 pin", 0x0 },
  3338. { "MIC2 pin", 0x1 },
  3339. { "LINE1 pin", 0x2 },
  3340. { "LINE2 pin", 0x3 },
  3341. { "CD pin", 0x4 },
  3342. { "LINE-OUT pin", 0x5 },
  3343. { "HP-OUT pin", 0x6 },
  3344. },
  3345. },
  3346. {
  3347. .num_items = 8,
  3348. .items = {
  3349. { "MIC1 pin", 0x0 },
  3350. { "MIC2 pin", 0x1 },
  3351. { "LINE1 pin", 0x2 },
  3352. { "LINE2 pin", 0x3 },
  3353. { "CD pin", 0x4 },
  3354. { "Mixer", 0x5 },
  3355. { "LINE-OUT pin", 0x6 },
  3356. { "HP-OUT pin", 0x7 },
  3357. },
  3358. },
  3359. };
  3360. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3361. /* Output driver widgets */
  3362. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3363. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3364. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3365. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3366. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3367. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3368. /* Modes for retasking pin widgets
  3369. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3370. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3371. * mention this restriction. At this stage it's not clear whether
  3372. * this behaviour is intentional or is a hardware bug in chip
  3373. * revisions available at least up until early 2006. Therefore for
  3374. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3375. * choices, but if it turns out that the lack of mic bias for these
  3376. * NIDs is intentional we could change their modes from
  3377. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3378. */
  3379. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3380. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3381. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3382. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3383. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3384. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3385. /* Loopback mixer controls */
  3386. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3387. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3388. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3389. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3390. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3391. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3392. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3393. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3394. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3395. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3396. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3397. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3398. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3399. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3400. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3401. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3402. /* Controls for GPIO pins, assuming they are configured as outputs */
  3403. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3404. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3405. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3406. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3407. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3408. * is ambigious as to which NID is which; testing on laptops which
  3409. * make this output available should provide clarification.
  3410. */
  3411. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3412. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3413. { } /* end */
  3414. };
  3415. static struct hda_verb alc260_test_init_verbs[] = {
  3416. /* Enable all GPIOs as outputs with an initial value of 0 */
  3417. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3418. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3419. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3420. /* Enable retasking pins as output, initially without power amp */
  3421. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3422. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3423. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3424. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3425. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3426. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3427. /* Disable digital (SPDIF) pins initially, but users can enable
  3428. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3429. * payload also sets the generation to 0, output to be in "consumer"
  3430. * PCM format, copyright asserted, no pre-emphasis and no validity
  3431. * control.
  3432. */
  3433. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3434. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3435. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3436. * OUT1 sum bus when acting as an output.
  3437. */
  3438. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3439. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3440. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3441. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3442. /* Start with output sum widgets muted and their output gains at min */
  3443. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3444. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3445. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3446. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3447. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3448. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3449. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3450. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3451. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3452. /* Unmute retasking pin widget output buffers since the default
  3453. * state appears to be output. As the pin mode is changed by the
  3454. * user the pin mode control will take care of enabling the pin's
  3455. * input/output buffers as needed.
  3456. */
  3457. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3458. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3459. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3460. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3461. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3462. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3463. /* Also unmute the mono-out pin widget */
  3464. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3465. /* Mute capture amp left and right */
  3466. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3467. /* Set ADC connection select to match default mixer setting (mic1
  3468. * pin)
  3469. */
  3470. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3471. /* Do the same for the second ADC: mute capture input amp and
  3472. * set ADC connection to mic1 pin
  3473. */
  3474. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3475. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3476. /* Mute all inputs to mixer widget (even unconnected ones) */
  3477. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3478. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3479. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3480. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3481. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3482. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3483. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3484. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3485. { }
  3486. };
  3487. #endif
  3488. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3489. .substreams = 1,
  3490. .channels_min = 2,
  3491. .channels_max = 2,
  3492. };
  3493. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3494. .substreams = 1,
  3495. .channels_min = 2,
  3496. .channels_max = 2,
  3497. };
  3498. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3499. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3500. /*
  3501. * for BIOS auto-configuration
  3502. */
  3503. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3504. const char *pfx)
  3505. {
  3506. hda_nid_t nid_vol;
  3507. unsigned long vol_val, sw_val;
  3508. char name[32];
  3509. int err;
  3510. if (nid >= 0x0f && nid < 0x11) {
  3511. nid_vol = nid - 0x7;
  3512. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3513. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3514. } else if (nid == 0x11) {
  3515. nid_vol = nid - 0x7;
  3516. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3517. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3518. } else if (nid >= 0x12 && nid <= 0x15) {
  3519. nid_vol = 0x08;
  3520. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3521. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3522. } else
  3523. return 0; /* N/A */
  3524. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3525. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val)) < 0)
  3526. return err;
  3527. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3528. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val)) < 0)
  3529. return err;
  3530. return 1;
  3531. }
  3532. /* add playback controls from the parsed DAC table */
  3533. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3534. const struct auto_pin_cfg *cfg)
  3535. {
  3536. hda_nid_t nid;
  3537. int err;
  3538. spec->multiout.num_dacs = 1;
  3539. spec->multiout.dac_nids = spec->private_dac_nids;
  3540. spec->multiout.dac_nids[0] = 0x02;
  3541. nid = cfg->line_out_pins[0];
  3542. if (nid) {
  3543. err = alc260_add_playback_controls(spec, nid, "Front");
  3544. if (err < 0)
  3545. return err;
  3546. }
  3547. nid = cfg->speaker_pins[0];
  3548. if (nid) {
  3549. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3550. if (err < 0)
  3551. return err;
  3552. }
  3553. nid = cfg->hp_pins[0];
  3554. if (nid) {
  3555. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3556. if (err < 0)
  3557. return err;
  3558. }
  3559. return 0;
  3560. }
  3561. /* create playback/capture controls for input pins */
  3562. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3563. const struct auto_pin_cfg *cfg)
  3564. {
  3565. struct hda_input_mux *imux = &spec->private_imux;
  3566. int i, err, idx;
  3567. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3568. if (cfg->input_pins[i] >= 0x12) {
  3569. idx = cfg->input_pins[i] - 0x12;
  3570. err = new_analog_input(spec, cfg->input_pins[i],
  3571. auto_pin_cfg_labels[i], idx, 0x07);
  3572. if (err < 0)
  3573. return err;
  3574. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3575. imux->items[imux->num_items].index = idx;
  3576. imux->num_items++;
  3577. }
  3578. if ((cfg->input_pins[i] >= 0x0f) && (cfg->input_pins[i] <= 0x10)){
  3579. idx = cfg->input_pins[i] - 0x09;
  3580. err = new_analog_input(spec, cfg->input_pins[i],
  3581. auto_pin_cfg_labels[i], idx, 0x07);
  3582. if (err < 0)
  3583. return err;
  3584. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  3585. imux->items[imux->num_items].index = idx;
  3586. imux->num_items++;
  3587. }
  3588. }
  3589. return 0;
  3590. }
  3591. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3592. hda_nid_t nid, int pin_type,
  3593. int sel_idx)
  3594. {
  3595. /* set as output */
  3596. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  3597. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  3598. /* need the manual connection? */
  3599. if (nid >= 0x12) {
  3600. int idx = nid - 0x12;
  3601. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3602. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3603. }
  3604. }
  3605. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3606. {
  3607. struct alc_spec *spec = codec->spec;
  3608. hda_nid_t nid;
  3609. nid = spec->autocfg.line_out_pins[0];
  3610. if (nid)
  3611. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3612. nid = spec->autocfg.speaker_pins[0];
  3613. if (nid)
  3614. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3615. nid = spec->autocfg.hp_pins[0];
  3616. if (nid)
  3617. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3618. }
  3619. #define ALC260_PIN_CD_NID 0x16
  3620. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3621. {
  3622. struct alc_spec *spec = codec->spec;
  3623. int i;
  3624. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3625. hda_nid_t nid = spec->autocfg.input_pins[i];
  3626. if (nid >= 0x12) {
  3627. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3628. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  3629. if (nid != ALC260_PIN_CD_NID)
  3630. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3631. AMP_OUT_MUTE);
  3632. }
  3633. }
  3634. }
  3635. /*
  3636. * generic initialization of ADC, input mixers and output mixers
  3637. */
  3638. static struct hda_verb alc260_volume_init_verbs[] = {
  3639. /*
  3640. * Unmute ADC0-1 and set the default input to mic-in
  3641. */
  3642. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3643. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3644. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3645. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3646. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  3647. * mixer widget
  3648. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  3649. * mic (mic 2)
  3650. */
  3651. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  3652. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3653. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3657. /*
  3658. * Set up output mixers (0x08 - 0x0a)
  3659. */
  3660. /* set vol=0 to output mixers */
  3661. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3662. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3663. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3664. /* set up input amps for analog loopback */
  3665. /* Amp Indices: DAC = 0, mixer = 1 */
  3666. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3667. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3668. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3669. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3670. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3671. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  3672. { }
  3673. };
  3674. static int alc260_parse_auto_config(struct hda_codec *codec)
  3675. {
  3676. struct alc_spec *spec = codec->spec;
  3677. unsigned int wcap;
  3678. int err;
  3679. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  3680. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3681. alc260_ignore)) < 0)
  3682. return err;
  3683. if ((err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0)
  3684. return err;
  3685. if (! spec->kctl_alloc)
  3686. return 0; /* can't find valid BIOS pin config */
  3687. if ((err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  3688. return err;
  3689. spec->multiout.max_channels = 2;
  3690. if (spec->autocfg.dig_out_pin)
  3691. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  3692. if (spec->kctl_alloc)
  3693. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3694. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  3695. spec->num_mux_defs = 1;
  3696. spec->input_mux = &spec->private_imux;
  3697. /* check whether NID 0x04 is valid */
  3698. wcap = get_wcaps(codec, 0x04);
  3699. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  3700. if (wcap != AC_WID_AUD_IN) {
  3701. spec->adc_nids = alc260_adc_nids_alt;
  3702. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  3703. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  3704. } else {
  3705. spec->adc_nids = alc260_adc_nids;
  3706. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  3707. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  3708. }
  3709. spec->num_mixers++;
  3710. return 1;
  3711. }
  3712. /* additional initialization for auto-configuration model */
  3713. static void alc260_auto_init(struct hda_codec *codec)
  3714. {
  3715. alc260_auto_init_multi_out(codec);
  3716. alc260_auto_init_analog_input(codec);
  3717. }
  3718. /*
  3719. * ALC260 configurations
  3720. */
  3721. static const char *alc260_models[ALC260_MODEL_LAST] = {
  3722. [ALC260_BASIC] = "basic",
  3723. [ALC260_HP] = "hp",
  3724. [ALC260_HP_3013] = "hp-3013",
  3725. [ALC260_FUJITSU_S702X] = "fujitsu",
  3726. [ALC260_ACER] = "acer",
  3727. #ifdef CONFIG_SND_DEBUG
  3728. [ALC260_TEST] = "test",
  3729. #endif
  3730. [ALC260_AUTO] = "auto",
  3731. };
  3732. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  3733. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  3734. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  3735. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  3736. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  3737. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  3738. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  3739. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  3740. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  3741. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  3742. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  3743. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  3744. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  3745. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  3746. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  3747. {}
  3748. };
  3749. static struct alc_config_preset alc260_presets[] = {
  3750. [ALC260_BASIC] = {
  3751. .mixers = { alc260_base_output_mixer,
  3752. alc260_input_mixer,
  3753. alc260_pc_beep_mixer,
  3754. alc260_capture_mixer },
  3755. .init_verbs = { alc260_init_verbs },
  3756. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3757. .dac_nids = alc260_dac_nids,
  3758. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  3759. .adc_nids = alc260_adc_nids,
  3760. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3761. .channel_mode = alc260_modes,
  3762. .input_mux = &alc260_capture_source,
  3763. },
  3764. [ALC260_HP] = {
  3765. .mixers = { alc260_base_output_mixer,
  3766. alc260_input_mixer,
  3767. alc260_capture_alt_mixer },
  3768. .init_verbs = { alc260_init_verbs },
  3769. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3770. .dac_nids = alc260_dac_nids,
  3771. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3772. .adc_nids = alc260_hp_adc_nids,
  3773. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3774. .channel_mode = alc260_modes,
  3775. .input_mux = &alc260_capture_source,
  3776. },
  3777. [ALC260_HP_3013] = {
  3778. .mixers = { alc260_hp_3013_mixer,
  3779. alc260_input_mixer,
  3780. alc260_capture_alt_mixer },
  3781. .init_verbs = { alc260_hp_3013_init_verbs },
  3782. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3783. .dac_nids = alc260_dac_nids,
  3784. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  3785. .adc_nids = alc260_hp_adc_nids,
  3786. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3787. .channel_mode = alc260_modes,
  3788. .input_mux = &alc260_capture_source,
  3789. },
  3790. [ALC260_FUJITSU_S702X] = {
  3791. .mixers = { alc260_fujitsu_mixer,
  3792. alc260_capture_mixer },
  3793. .init_verbs = { alc260_fujitsu_init_verbs },
  3794. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3795. .dac_nids = alc260_dac_nids,
  3796. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3797. .adc_nids = alc260_dual_adc_nids,
  3798. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3799. .channel_mode = alc260_modes,
  3800. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  3801. .input_mux = alc260_fujitsu_capture_sources,
  3802. },
  3803. [ALC260_ACER] = {
  3804. .mixers = { alc260_acer_mixer,
  3805. alc260_capture_mixer },
  3806. .init_verbs = { alc260_acer_init_verbs },
  3807. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  3808. .dac_nids = alc260_dac_nids,
  3809. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  3810. .adc_nids = alc260_dual_adc_nids,
  3811. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3812. .channel_mode = alc260_modes,
  3813. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  3814. .input_mux = alc260_acer_capture_sources,
  3815. },
  3816. #ifdef CONFIG_SND_DEBUG
  3817. [ALC260_TEST] = {
  3818. .mixers = { alc260_test_mixer,
  3819. alc260_capture_mixer },
  3820. .init_verbs = { alc260_test_init_verbs },
  3821. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  3822. .dac_nids = alc260_test_dac_nids,
  3823. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  3824. .adc_nids = alc260_test_adc_nids,
  3825. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  3826. .channel_mode = alc260_modes,
  3827. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  3828. .input_mux = alc260_test_capture_sources,
  3829. },
  3830. #endif
  3831. };
  3832. static int patch_alc260(struct hda_codec *codec)
  3833. {
  3834. struct alc_spec *spec;
  3835. int err, board_config;
  3836. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3837. if (spec == NULL)
  3838. return -ENOMEM;
  3839. codec->spec = spec;
  3840. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  3841. alc260_models,
  3842. alc260_cfg_tbl);
  3843. if (board_config < 0) {
  3844. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  3845. "trying auto-probe from BIOS...\n");
  3846. board_config = ALC260_AUTO;
  3847. }
  3848. if (board_config == ALC260_AUTO) {
  3849. /* automatic parse from the BIOS config */
  3850. err = alc260_parse_auto_config(codec);
  3851. if (err < 0) {
  3852. alc_free(codec);
  3853. return err;
  3854. } else if (! err) {
  3855. printk(KERN_INFO
  3856. "hda_codec: Cannot set up configuration "
  3857. "from BIOS. Using base mode...\n");
  3858. board_config = ALC260_BASIC;
  3859. }
  3860. }
  3861. if (board_config != ALC260_AUTO)
  3862. setup_preset(spec, &alc260_presets[board_config]);
  3863. spec->stream_name_analog = "ALC260 Analog";
  3864. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  3865. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  3866. spec->stream_name_digital = "ALC260 Digital";
  3867. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  3868. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  3869. codec->patch_ops = alc_patch_ops;
  3870. if (board_config == ALC260_AUTO)
  3871. spec->init_hook = alc260_auto_init;
  3872. return 0;
  3873. }
  3874. /*
  3875. * ALC882 support
  3876. *
  3877. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  3878. * configuration. Each pin widget can choose any input DACs and a mixer.
  3879. * Each ADC is connected from a mixer of all inputs. This makes possible
  3880. * 6-channel independent captures.
  3881. *
  3882. * In addition, an independent DAC for the multi-playback (not used in this
  3883. * driver yet).
  3884. */
  3885. #define ALC882_DIGOUT_NID 0x06
  3886. #define ALC882_DIGIN_NID 0x0a
  3887. static struct hda_channel_mode alc882_ch_modes[1] = {
  3888. { 8, NULL }
  3889. };
  3890. static hda_nid_t alc882_dac_nids[4] = {
  3891. /* front, rear, clfe, rear_surr */
  3892. 0x02, 0x03, 0x04, 0x05
  3893. };
  3894. /* identical with ALC880 */
  3895. #define alc882_adc_nids alc880_adc_nids
  3896. #define alc882_adc_nids_alt alc880_adc_nids_alt
  3897. /* input MUX */
  3898. /* FIXME: should be a matrix-type input source selection */
  3899. static struct hda_input_mux alc882_capture_source = {
  3900. .num_items = 4,
  3901. .items = {
  3902. { "Mic", 0x0 },
  3903. { "Front Mic", 0x1 },
  3904. { "Line", 0x2 },
  3905. { "CD", 0x4 },
  3906. },
  3907. };
  3908. #define alc882_mux_enum_info alc_mux_enum_info
  3909. #define alc882_mux_enum_get alc_mux_enum_get
  3910. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
  3911. {
  3912. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  3913. struct alc_spec *spec = codec->spec;
  3914. const struct hda_input_mux *imux = spec->input_mux;
  3915. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  3916. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  3917. hda_nid_t nid = capture_mixers[adc_idx];
  3918. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  3919. unsigned int i, idx;
  3920. idx = ucontrol->value.enumerated.item[0];
  3921. if (idx >= imux->num_items)
  3922. idx = imux->num_items - 1;
  3923. if (*cur_val == idx && ! codec->in_resume)
  3924. return 0;
  3925. for (i = 0; i < imux->num_items; i++) {
  3926. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  3927. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3928. v | (imux->items[i].index << 8));
  3929. }
  3930. *cur_val = idx;
  3931. return 1;
  3932. }
  3933. /*
  3934. * 6ch mode
  3935. */
  3936. static struct hda_verb alc882_sixstack_ch6_init[] = {
  3937. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  3938. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3939. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3940. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3941. { } /* end */
  3942. };
  3943. /*
  3944. * 8ch mode
  3945. */
  3946. static struct hda_verb alc882_sixstack_ch8_init[] = {
  3947. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3948. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3949. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3950. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  3951. { } /* end */
  3952. };
  3953. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  3954. { 6, alc882_sixstack_ch6_init },
  3955. { 8, alc882_sixstack_ch8_init },
  3956. };
  3957. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  3958. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  3959. */
  3960. static struct snd_kcontrol_new alc882_base_mixer[] = {
  3961. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  3962. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  3963. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  3964. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  3965. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  3966. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  3967. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  3968. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  3969. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  3970. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  3971. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  3972. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  3973. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  3974. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  3975. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  3976. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  3977. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  3978. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  3979. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  3980. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  3981. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  3982. { } /* end */
  3983. };
  3984. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  3985. {
  3986. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3987. .name = "Channel Mode",
  3988. .info = alc_ch_mode_info,
  3989. .get = alc_ch_mode_get,
  3990. .put = alc_ch_mode_put,
  3991. },
  3992. { } /* end */
  3993. };
  3994. static struct hda_verb alc882_init_verbs[] = {
  3995. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  3996. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3997. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3998. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3999. /* Rear mixer */
  4000. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4001. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4002. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4003. /* CLFE mixer */
  4004. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4005. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4006. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4007. /* Side mixer */
  4008. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4009. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4010. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4011. /* Front Pin: output 0 (0x0c) */
  4012. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4013. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4014. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4015. /* Rear Pin: output 1 (0x0d) */
  4016. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4017. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4018. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4019. /* CLFE Pin: output 2 (0x0e) */
  4020. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4021. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4022. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4023. /* Side Pin: output 3 (0x0f) */
  4024. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4025. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4026. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4027. /* Mic (rear) pin: input vref at 80% */
  4028. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4029. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4030. /* Front Mic pin: input vref at 80% */
  4031. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4032. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4033. /* Line In pin: input */
  4034. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4035. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4036. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4037. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4038. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4039. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4040. /* CD pin widget for input */
  4041. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4042. /* FIXME: use matrix-type input source selection */
  4043. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4044. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4045. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4046. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4047. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4048. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4049. /* Input mixer2 */
  4050. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4051. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4052. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4053. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4054. /* Input mixer3 */
  4055. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4056. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4057. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4058. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4059. /* ADC1: mute amp left and right */
  4060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4061. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4062. /* ADC2: mute amp left and right */
  4063. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4064. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4065. /* ADC3: mute amp left and right */
  4066. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4067. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4068. { }
  4069. };
  4070. static struct hda_verb alc882_eapd_verbs[] = {
  4071. /* change to EAPD mode */
  4072. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4073. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4074. { }
  4075. };
  4076. /* Mac Pro test */
  4077. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4078. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4079. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4080. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4081. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4082. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4083. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4084. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4085. { } /* end */
  4086. };
  4087. static struct hda_verb alc882_macpro_init_verbs[] = {
  4088. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4089. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4090. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4091. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4092. /* Front Pin: output 0 (0x0c) */
  4093. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4094. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4095. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4096. /* Front Mic pin: input vref at 80% */
  4097. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4098. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4099. /* Speaker: output */
  4100. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4101. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4102. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4103. /* Headphone output (output 0 - 0x0c) */
  4104. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4105. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4106. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4107. /* FIXME: use matrix-type input source selection */
  4108. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4109. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4110. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4111. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4112. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4113. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4114. /* Input mixer2 */
  4115. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4116. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4117. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4118. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4119. /* Input mixer3 */
  4120. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4121. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4122. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4123. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4124. /* ADC1: mute amp left and right */
  4125. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4126. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4127. /* ADC2: mute amp left and right */
  4128. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4129. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4130. /* ADC3: mute amp left and right */
  4131. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4132. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4133. { }
  4134. };
  4135. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4136. {
  4137. unsigned int gpiostate, gpiomask, gpiodir;
  4138. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4139. AC_VERB_GET_GPIO_DATA, 0);
  4140. if (!muted)
  4141. gpiostate |= (1 << pin);
  4142. else
  4143. gpiostate &= ~(1 << pin);
  4144. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4145. AC_VERB_GET_GPIO_MASK, 0);
  4146. gpiomask |= (1 << pin);
  4147. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4148. AC_VERB_GET_GPIO_DIRECTION, 0);
  4149. gpiodir |= (1 << pin);
  4150. snd_hda_codec_write(codec, codec->afg, 0,
  4151. AC_VERB_SET_GPIO_MASK, gpiomask);
  4152. snd_hda_codec_write(codec, codec->afg, 0,
  4153. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4154. msleep(1);
  4155. snd_hda_codec_write(codec, codec->afg, 0,
  4156. AC_VERB_SET_GPIO_DATA, gpiostate);
  4157. }
  4158. /*
  4159. * generic initialization of ADC, input mixers and output mixers
  4160. */
  4161. static struct hda_verb alc882_auto_init_verbs[] = {
  4162. /*
  4163. * Unmute ADC0-2 and set the default input to mic-in
  4164. */
  4165. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4166. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4167. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4168. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4169. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4170. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4171. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4172. * mixer widget
  4173. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4174. * mic (mic 2)
  4175. */
  4176. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4179. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4180. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4181. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4182. /*
  4183. * Set up output mixers (0x0c - 0x0f)
  4184. */
  4185. /* set vol=0 to output mixers */
  4186. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4187. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4188. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4189. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4190. /* set up input amps for analog loopback */
  4191. /* Amp Indices: DAC = 0, mixer = 1 */
  4192. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4193. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4194. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4195. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4196. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4197. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4198. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4199. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4200. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4201. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4202. /* FIXME: use matrix-type input source selection */
  4203. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4204. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4205. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4206. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4207. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4208. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4209. /* Input mixer2 */
  4210. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4211. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4212. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4213. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4214. /* Input mixer3 */
  4215. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4216. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4217. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4218. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4219. { }
  4220. };
  4221. /* capture mixer elements */
  4222. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4223. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4224. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4225. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4226. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4227. {
  4228. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4229. /* The multiple "Capture Source" controls confuse alsamixer
  4230. * So call somewhat different..
  4231. * FIXME: the controls appear in the "playback" view!
  4232. */
  4233. /* .name = "Capture Source", */
  4234. .name = "Input Source",
  4235. .count = 2,
  4236. .info = alc882_mux_enum_info,
  4237. .get = alc882_mux_enum_get,
  4238. .put = alc882_mux_enum_put,
  4239. },
  4240. { } /* end */
  4241. };
  4242. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4243. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4244. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4245. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4246. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4247. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4248. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4249. {
  4250. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4251. /* The multiple "Capture Source" controls confuse alsamixer
  4252. * So call somewhat different..
  4253. * FIXME: the controls appear in the "playback" view!
  4254. */
  4255. /* .name = "Capture Source", */
  4256. .name = "Input Source",
  4257. .count = 3,
  4258. .info = alc882_mux_enum_info,
  4259. .get = alc882_mux_enum_get,
  4260. .put = alc882_mux_enum_put,
  4261. },
  4262. { } /* end */
  4263. };
  4264. /* pcm configuration: identiacal with ALC880 */
  4265. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4266. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4267. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4268. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4269. /*
  4270. * configuration and preset
  4271. */
  4272. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4273. [ALC882_3ST_DIG] = "3stack-dig",
  4274. [ALC882_6ST_DIG] = "6stack-dig",
  4275. [ALC882_ARIMA] = "arima",
  4276. [ALC885_MACPRO] = "macpro",
  4277. [ALC882_AUTO] = "auto",
  4278. };
  4279. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4280. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4281. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4282. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4283. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4284. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4285. {}
  4286. };
  4287. static struct alc_config_preset alc882_presets[] = {
  4288. [ALC882_3ST_DIG] = {
  4289. .mixers = { alc882_base_mixer },
  4290. .init_verbs = { alc882_init_verbs },
  4291. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4292. .dac_nids = alc882_dac_nids,
  4293. .dig_out_nid = ALC882_DIGOUT_NID,
  4294. .dig_in_nid = ALC882_DIGIN_NID,
  4295. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4296. .channel_mode = alc882_ch_modes,
  4297. .need_dac_fix = 1,
  4298. .input_mux = &alc882_capture_source,
  4299. },
  4300. [ALC882_6ST_DIG] = {
  4301. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4302. .init_verbs = { alc882_init_verbs },
  4303. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4304. .dac_nids = alc882_dac_nids,
  4305. .dig_out_nid = ALC882_DIGOUT_NID,
  4306. .dig_in_nid = ALC882_DIGIN_NID,
  4307. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4308. .channel_mode = alc882_sixstack_modes,
  4309. .input_mux = &alc882_capture_source,
  4310. },
  4311. [ALC882_ARIMA] = {
  4312. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4313. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4314. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4315. .dac_nids = alc882_dac_nids,
  4316. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4317. .channel_mode = alc882_sixstack_modes,
  4318. .input_mux = &alc882_capture_source,
  4319. },
  4320. [ALC885_MACPRO] = {
  4321. .mixers = { alc882_macpro_mixer },
  4322. .init_verbs = { alc882_macpro_init_verbs },
  4323. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4324. .dac_nids = alc882_dac_nids,
  4325. .dig_out_nid = ALC882_DIGOUT_NID,
  4326. .dig_in_nid = ALC882_DIGIN_NID,
  4327. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4328. .channel_mode = alc882_ch_modes,
  4329. .input_mux = &alc882_capture_source,
  4330. },
  4331. };
  4332. /*
  4333. * BIOS auto configuration
  4334. */
  4335. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4336. hda_nid_t nid, int pin_type,
  4337. int dac_idx)
  4338. {
  4339. /* set as output */
  4340. struct alc_spec *spec = codec->spec;
  4341. int idx;
  4342. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4343. idx = 4;
  4344. else
  4345. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4346. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  4347. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  4348. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4349. }
  4350. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4351. {
  4352. struct alc_spec *spec = codec->spec;
  4353. int i;
  4354. for (i = 0; i <= HDA_SIDE; i++) {
  4355. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4356. if (nid)
  4357. alc882_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  4358. }
  4359. }
  4360. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4361. {
  4362. struct alc_spec *spec = codec->spec;
  4363. hda_nid_t pin;
  4364. pin = spec->autocfg.hp_pins[0];
  4365. if (pin) /* connect to front */
  4366. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0); /* use dac 0 */
  4367. }
  4368. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4369. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4370. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4371. {
  4372. struct alc_spec *spec = codec->spec;
  4373. int i;
  4374. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4375. hda_nid_t nid = spec->autocfg.input_pins[i];
  4376. if (alc882_is_input_pin(nid)) {
  4377. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4378. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  4379. if (nid != ALC882_PIN_CD_NID)
  4380. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4381. AMP_OUT_MUTE);
  4382. }
  4383. }
  4384. }
  4385. /* almost identical with ALC880 parser... */
  4386. static int alc882_parse_auto_config(struct hda_codec *codec)
  4387. {
  4388. struct alc_spec *spec = codec->spec;
  4389. int err = alc880_parse_auto_config(codec);
  4390. if (err < 0)
  4391. return err;
  4392. else if (err > 0)
  4393. /* hack - override the init verbs */
  4394. spec->init_verbs[0] = alc882_auto_init_verbs;
  4395. return err;
  4396. }
  4397. /* additional initialization for auto-configuration model */
  4398. static void alc882_auto_init(struct hda_codec *codec)
  4399. {
  4400. alc882_auto_init_multi_out(codec);
  4401. alc882_auto_init_hp_out(codec);
  4402. alc882_auto_init_analog_input(codec);
  4403. }
  4404. static int patch_alc882(struct hda_codec *codec)
  4405. {
  4406. struct alc_spec *spec;
  4407. int err, board_config;
  4408. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4409. if (spec == NULL)
  4410. return -ENOMEM;
  4411. codec->spec = spec;
  4412. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  4413. alc882_models,
  4414. alc882_cfg_tbl);
  4415. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  4416. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  4417. "trying auto-probe from BIOS...\n");
  4418. board_config = ALC882_AUTO;
  4419. }
  4420. if (board_config == ALC882_AUTO) {
  4421. /* automatic parse from the BIOS config */
  4422. err = alc882_parse_auto_config(codec);
  4423. if (err < 0) {
  4424. alc_free(codec);
  4425. return err;
  4426. } else if (! err) {
  4427. printk(KERN_INFO
  4428. "hda_codec: Cannot set up configuration "
  4429. "from BIOS. Using base mode...\n");
  4430. board_config = ALC882_3ST_DIG;
  4431. }
  4432. }
  4433. if (board_config != ALC882_AUTO)
  4434. setup_preset(spec, &alc882_presets[board_config]);
  4435. if (board_config == ALC885_MACPRO) {
  4436. alc882_gpio_mute(codec, 0, 0);
  4437. alc882_gpio_mute(codec, 1, 0);
  4438. }
  4439. spec->stream_name_analog = "ALC882 Analog";
  4440. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  4441. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  4442. spec->stream_name_digital = "ALC882 Digital";
  4443. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  4444. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  4445. if (! spec->adc_nids && spec->input_mux) {
  4446. /* check whether NID 0x07 is valid */
  4447. unsigned int wcap = get_wcaps(codec, 0x07);
  4448. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4449. if (wcap != AC_WID_AUD_IN) {
  4450. spec->adc_nids = alc882_adc_nids_alt;
  4451. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  4452. spec->mixers[spec->num_mixers] = alc882_capture_alt_mixer;
  4453. spec->num_mixers++;
  4454. } else {
  4455. spec->adc_nids = alc882_adc_nids;
  4456. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  4457. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  4458. spec->num_mixers++;
  4459. }
  4460. }
  4461. codec->patch_ops = alc_patch_ops;
  4462. if (board_config == ALC882_AUTO)
  4463. spec->init_hook = alc882_auto_init;
  4464. return 0;
  4465. }
  4466. /*
  4467. * ALC883 support
  4468. *
  4469. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  4470. * configuration. Each pin widget can choose any input DACs and a mixer.
  4471. * Each ADC is connected from a mixer of all inputs. This makes possible
  4472. * 6-channel independent captures.
  4473. *
  4474. * In addition, an independent DAC for the multi-playback (not used in this
  4475. * driver yet).
  4476. */
  4477. #define ALC883_DIGOUT_NID 0x06
  4478. #define ALC883_DIGIN_NID 0x0a
  4479. static hda_nid_t alc883_dac_nids[4] = {
  4480. /* front, rear, clfe, rear_surr */
  4481. 0x02, 0x04, 0x03, 0x05
  4482. };
  4483. static hda_nid_t alc883_adc_nids[2] = {
  4484. /* ADC1-2 */
  4485. 0x08, 0x09,
  4486. };
  4487. /* input MUX */
  4488. /* FIXME: should be a matrix-type input source selection */
  4489. static struct hda_input_mux alc883_capture_source = {
  4490. .num_items = 4,
  4491. .items = {
  4492. { "Mic", 0x0 },
  4493. { "Front Mic", 0x1 },
  4494. { "Line", 0x2 },
  4495. { "CD", 0x4 },
  4496. },
  4497. };
  4498. #define alc883_mux_enum_info alc_mux_enum_info
  4499. #define alc883_mux_enum_get alc_mux_enum_get
  4500. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  4501. struct snd_ctl_elem_value *ucontrol)
  4502. {
  4503. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4504. struct alc_spec *spec = codec->spec;
  4505. const struct hda_input_mux *imux = spec->input_mux;
  4506. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4507. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4508. hda_nid_t nid = capture_mixers[adc_idx];
  4509. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4510. unsigned int i, idx;
  4511. idx = ucontrol->value.enumerated.item[0];
  4512. if (idx >= imux->num_items)
  4513. idx = imux->num_items - 1;
  4514. if (*cur_val == idx && ! codec->in_resume)
  4515. return 0;
  4516. for (i = 0; i < imux->num_items; i++) {
  4517. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4518. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4519. v | (imux->items[i].index << 8));
  4520. }
  4521. *cur_val = idx;
  4522. return 1;
  4523. }
  4524. /*
  4525. * 2ch mode
  4526. */
  4527. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  4528. { 2, NULL }
  4529. };
  4530. /*
  4531. * 2ch mode
  4532. */
  4533. static struct hda_verb alc883_3ST_ch2_init[] = {
  4534. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4535. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4536. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4537. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4538. { } /* end */
  4539. };
  4540. /*
  4541. * 6ch mode
  4542. */
  4543. static struct hda_verb alc883_3ST_ch6_init[] = {
  4544. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4545. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4546. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4547. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4548. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4549. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4550. { } /* end */
  4551. };
  4552. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  4553. { 2, alc883_3ST_ch2_init },
  4554. { 6, alc883_3ST_ch6_init },
  4555. };
  4556. /*
  4557. * 6ch mode
  4558. */
  4559. static struct hda_verb alc883_sixstack_ch6_init[] = {
  4560. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4561. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4562. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4563. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4564. { } /* end */
  4565. };
  4566. /*
  4567. * 8ch mode
  4568. */
  4569. static struct hda_verb alc883_sixstack_ch8_init[] = {
  4570. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4571. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4572. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4573. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4574. { } /* end */
  4575. };
  4576. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  4577. { 6, alc883_sixstack_ch6_init },
  4578. { 8, alc883_sixstack_ch8_init },
  4579. };
  4580. static struct hda_verb alc883_medion_eapd_verbs[] = {
  4581. /* eanable EAPD on medion laptop */
  4582. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4583. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  4584. { }
  4585. };
  4586. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4587. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4588. */
  4589. static struct snd_kcontrol_new alc883_base_mixer[] = {
  4590. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4591. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4592. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4593. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4594. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4595. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4596. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4597. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4598. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4599. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4600. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4601. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4602. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4603. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4604. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4605. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4606. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4607. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4608. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4609. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4610. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4611. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4612. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4613. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4614. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4615. {
  4616. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4617. /* .name = "Capture Source", */
  4618. .name = "Input Source",
  4619. .count = 2,
  4620. .info = alc883_mux_enum_info,
  4621. .get = alc883_mux_enum_get,
  4622. .put = alc883_mux_enum_put,
  4623. },
  4624. { } /* end */
  4625. };
  4626. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  4627. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4628. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4629. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4630. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4631. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4632. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4633. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4634. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4635. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4636. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4637. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4638. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4639. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4640. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4641. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4642. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4643. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4644. {
  4645. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4646. /* .name = "Capture Source", */
  4647. .name = "Input Source",
  4648. .count = 2,
  4649. .info = alc883_mux_enum_info,
  4650. .get = alc883_mux_enum_get,
  4651. .put = alc883_mux_enum_put,
  4652. },
  4653. { } /* end */
  4654. };
  4655. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  4656. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4657. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4658. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4659. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4660. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4661. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4662. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4663. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4664. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4665. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4666. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4667. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4668. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4669. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4670. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4671. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4672. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4673. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4674. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4675. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4676. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4677. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4678. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4679. {
  4680. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4681. /* .name = "Capture Source", */
  4682. .name = "Input Source",
  4683. .count = 2,
  4684. .info = alc883_mux_enum_info,
  4685. .get = alc883_mux_enum_get,
  4686. .put = alc883_mux_enum_put,
  4687. },
  4688. { } /* end */
  4689. };
  4690. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  4691. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4692. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4693. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4694. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4695. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4696. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4697. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  4698. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  4699. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4700. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4701. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4702. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4703. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4704. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4705. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4706. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4707. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4708. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4709. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4710. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4711. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4712. {
  4713. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4714. /* .name = "Capture Source", */
  4715. .name = "Input Source",
  4716. .count = 1,
  4717. .info = alc883_mux_enum_info,
  4718. .get = alc883_mux_enum_get,
  4719. .put = alc883_mux_enum_put,
  4720. },
  4721. { } /* end */
  4722. };
  4723. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  4724. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4725. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4726. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4727. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4728. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4729. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4730. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4731. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4732. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4733. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4734. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4735. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4736. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4737. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4738. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4739. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4740. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4741. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4742. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4743. {
  4744. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4745. /* .name = "Capture Source", */
  4746. .name = "Input Source",
  4747. .count = 2,
  4748. .info = alc883_mux_enum_info,
  4749. .get = alc883_mux_enum_get,
  4750. .put = alc883_mux_enum_put,
  4751. },
  4752. { } /* end */
  4753. };
  4754. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  4755. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4756. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4757. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4758. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4759. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4760. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4761. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4762. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4763. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4764. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4765. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4766. {
  4767. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4768. /* .name = "Capture Source", */
  4769. .name = "Input Source",
  4770. .count = 2,
  4771. .info = alc883_mux_enum_info,
  4772. .get = alc883_mux_enum_get,
  4773. .put = alc883_mux_enum_put,
  4774. },
  4775. { } /* end */
  4776. };
  4777. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  4778. {
  4779. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4780. .name = "Channel Mode",
  4781. .info = alc_ch_mode_info,
  4782. .get = alc_ch_mode_get,
  4783. .put = alc_ch_mode_put,
  4784. },
  4785. { } /* end */
  4786. };
  4787. static struct hda_verb alc883_init_verbs[] = {
  4788. /* ADC1: mute amp left and right */
  4789. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4790. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4791. /* ADC2: mute amp left and right */
  4792. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4793. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4794. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4795. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4796. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4797. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4798. /* Rear mixer */
  4799. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4800. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4801. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4802. /* CLFE mixer */
  4803. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4804. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4805. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4806. /* Side mixer */
  4807. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4808. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4809. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4810. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4811. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4812. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4813. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4814. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4815. /* Front Pin: output 0 (0x0c) */
  4816. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4817. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4818. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4819. /* Rear Pin: output 1 (0x0d) */
  4820. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4821. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4822. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4823. /* CLFE Pin: output 2 (0x0e) */
  4824. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4825. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4826. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4827. /* Side Pin: output 3 (0x0f) */
  4828. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4829. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4830. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4831. /* Mic (rear) pin: input vref at 80% */
  4832. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4833. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4834. /* Front Mic pin: input vref at 80% */
  4835. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4836. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4837. /* Line In pin: input */
  4838. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4839. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4840. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4841. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4842. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4843. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4844. /* CD pin widget for input */
  4845. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4846. /* FIXME: use matrix-type input source selection */
  4847. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4848. /* Input mixer2 */
  4849. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4850. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4851. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4852. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4853. /* Input mixer3 */
  4854. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4855. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4856. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4857. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4858. { }
  4859. };
  4860. static struct hda_verb alc883_tagra_verbs[] = {
  4861. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4862. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4863. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4864. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4865. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4866. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4867. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4868. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4869. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4870. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4871. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4872. { } /* end */
  4873. };
  4874. /* toggle speaker-output according to the hp-jack state */
  4875. static void alc883_tagra_automute(struct hda_codec *codec)
  4876. {
  4877. unsigned int present;
  4878. present = snd_hda_codec_read(codec, 0x14, 0,
  4879. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4880. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4881. 0x80, present ? 0x80 : 0);
  4882. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4883. 0x80, present ? 0x80 : 0);
  4884. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4885. }
  4886. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  4887. {
  4888. if ((res >> 26) == ALC880_HP_EVENT)
  4889. alc883_tagra_automute(codec);
  4890. }
  4891. /*
  4892. * generic initialization of ADC, input mixers and output mixers
  4893. */
  4894. static struct hda_verb alc883_auto_init_verbs[] = {
  4895. /*
  4896. * Unmute ADC0-2 and set the default input to mic-in
  4897. */
  4898. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4899. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4900. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4901. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4902. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4903. * mixer widget
  4904. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  4905. * mic (mic 2)
  4906. */
  4907. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4908. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4909. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4910. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4911. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4912. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4913. /*
  4914. * Set up output mixers (0x0c - 0x0f)
  4915. */
  4916. /* set vol=0 to output mixers */
  4917. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4918. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4919. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4920. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4921. /* set up input amps for analog loopback */
  4922. /* Amp Indices: DAC = 0, mixer = 1 */
  4923. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4924. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4925. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4926. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4927. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4928. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4929. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4930. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4931. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4932. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4933. /* FIXME: use matrix-type input source selection */
  4934. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4935. /* Input mixer1 */
  4936. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4937. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4938. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4939. //{0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4940. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4941. /* Input mixer2 */
  4942. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4943. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4944. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4945. //{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4946. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4947. { }
  4948. };
  4949. /* capture mixer elements */
  4950. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  4951. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4952. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4953. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4954. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4955. {
  4956. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4957. /* The multiple "Capture Source" controls confuse alsamixer
  4958. * So call somewhat different..
  4959. * FIXME: the controls appear in the "playback" view!
  4960. */
  4961. /* .name = "Capture Source", */
  4962. .name = "Input Source",
  4963. .count = 2,
  4964. .info = alc882_mux_enum_info,
  4965. .get = alc882_mux_enum_get,
  4966. .put = alc882_mux_enum_put,
  4967. },
  4968. { } /* end */
  4969. };
  4970. /* pcm configuration: identiacal with ALC880 */
  4971. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  4972. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  4973. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  4974. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  4975. /*
  4976. * configuration and preset
  4977. */
  4978. static const char *alc883_models[ALC883_MODEL_LAST] = {
  4979. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  4980. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  4981. [ALC883_3ST_6ch] = "3stack-6ch",
  4982. [ALC883_6ST_DIG] = "6stack-dig",
  4983. [ALC883_TARGA_DIG] = "targa-dig",
  4984. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  4985. [ALC888_DEMO_BOARD] = "6stack-dig-demo",
  4986. [ALC883_ACER] = "acer",
  4987. [ALC883_MEDION] = "medion",
  4988. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  4989. [ALC883_AUTO] = "auto",
  4990. };
  4991. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  4992. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  4993. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  4994. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  4995. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  4996. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  4997. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  4998. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  4999. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5000. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5001. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5002. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5003. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5004. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5005. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5006. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5007. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5008. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5009. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5010. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5011. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5012. {}
  5013. };
  5014. static struct alc_config_preset alc883_presets[] = {
  5015. [ALC883_3ST_2ch_DIG] = {
  5016. .mixers = { alc883_3ST_2ch_mixer },
  5017. .init_verbs = { alc883_init_verbs },
  5018. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5019. .dac_nids = alc883_dac_nids,
  5020. .dig_out_nid = ALC883_DIGOUT_NID,
  5021. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5022. .adc_nids = alc883_adc_nids,
  5023. .dig_in_nid = ALC883_DIGIN_NID,
  5024. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5025. .channel_mode = alc883_3ST_2ch_modes,
  5026. .input_mux = &alc883_capture_source,
  5027. },
  5028. [ALC883_3ST_6ch_DIG] = {
  5029. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5030. .init_verbs = { alc883_init_verbs },
  5031. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5032. .dac_nids = alc883_dac_nids,
  5033. .dig_out_nid = ALC883_DIGOUT_NID,
  5034. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5035. .adc_nids = alc883_adc_nids,
  5036. .dig_in_nid = ALC883_DIGIN_NID,
  5037. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5038. .channel_mode = alc883_3ST_6ch_modes,
  5039. .need_dac_fix = 1,
  5040. .input_mux = &alc883_capture_source,
  5041. },
  5042. [ALC883_3ST_6ch] = {
  5043. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5044. .init_verbs = { alc883_init_verbs },
  5045. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5046. .dac_nids = alc883_dac_nids,
  5047. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5048. .adc_nids = alc883_adc_nids,
  5049. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5050. .channel_mode = alc883_3ST_6ch_modes,
  5051. .need_dac_fix = 1,
  5052. .input_mux = &alc883_capture_source,
  5053. },
  5054. [ALC883_6ST_DIG] = {
  5055. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5056. .init_verbs = { alc883_init_verbs },
  5057. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5058. .dac_nids = alc883_dac_nids,
  5059. .dig_out_nid = ALC883_DIGOUT_NID,
  5060. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5061. .adc_nids = alc883_adc_nids,
  5062. .dig_in_nid = ALC883_DIGIN_NID,
  5063. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5064. .channel_mode = alc883_sixstack_modes,
  5065. .input_mux = &alc883_capture_source,
  5066. },
  5067. [ALC883_TARGA_DIG] = {
  5068. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  5069. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5070. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5071. .dac_nids = alc883_dac_nids,
  5072. .dig_out_nid = ALC883_DIGOUT_NID,
  5073. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5074. .adc_nids = alc883_adc_nids,
  5075. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5076. .channel_mode = alc883_3ST_6ch_modes,
  5077. .need_dac_fix = 1,
  5078. .input_mux = &alc883_capture_source,
  5079. .unsol_event = alc883_tagra_unsol_event,
  5080. .init_hook = alc883_tagra_automute,
  5081. },
  5082. [ALC883_TARGA_2ch_DIG] = {
  5083. .mixers = { alc883_tagra_2ch_mixer},
  5084. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  5085. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5086. .dac_nids = alc883_dac_nids,
  5087. .dig_out_nid = ALC883_DIGOUT_NID,
  5088. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5089. .adc_nids = alc883_adc_nids,
  5090. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5091. .channel_mode = alc883_3ST_2ch_modes,
  5092. .input_mux = &alc883_capture_source,
  5093. .unsol_event = alc883_tagra_unsol_event,
  5094. .init_hook = alc883_tagra_automute,
  5095. },
  5096. [ALC888_DEMO_BOARD] = {
  5097. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5098. .init_verbs = { alc883_init_verbs },
  5099. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5100. .dac_nids = alc883_dac_nids,
  5101. .dig_out_nid = ALC883_DIGOUT_NID,
  5102. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5103. .adc_nids = alc883_adc_nids,
  5104. .dig_in_nid = ALC883_DIGIN_NID,
  5105. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5106. .channel_mode = alc883_sixstack_modes,
  5107. .input_mux = &alc883_capture_source,
  5108. },
  5109. [ALC883_ACER] = {
  5110. .mixers = { alc883_base_mixer,
  5111. alc883_chmode_mixer },
  5112. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  5113. * and the headphone jack. Turn this on and rely on the
  5114. * standard mute methods whenever the user wants to turn
  5115. * these outputs off.
  5116. */
  5117. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  5118. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5119. .dac_nids = alc883_dac_nids,
  5120. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5121. .adc_nids = alc883_adc_nids,
  5122. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5123. .channel_mode = alc883_3ST_2ch_modes,
  5124. .input_mux = &alc883_capture_source,
  5125. },
  5126. [ALC883_MEDION] = {
  5127. .mixers = { alc883_fivestack_mixer,
  5128. alc883_chmode_mixer },
  5129. .init_verbs = { alc883_init_verbs,
  5130. alc883_medion_eapd_verbs },
  5131. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5132. .dac_nids = alc883_dac_nids,
  5133. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5134. .adc_nids = alc883_adc_nids,
  5135. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  5136. .channel_mode = alc883_sixstack_modes,
  5137. .input_mux = &alc883_capture_source,
  5138. },
  5139. [ALC883_LAPTOP_EAPD] = {
  5140. .mixers = { alc883_base_mixer,
  5141. alc883_chmode_mixer },
  5142. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  5143. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5144. .dac_nids = alc883_dac_nids,
  5145. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5146. .adc_nids = alc883_adc_nids,
  5147. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5148. .channel_mode = alc883_3ST_2ch_modes,
  5149. .input_mux = &alc883_capture_source,
  5150. },
  5151. };
  5152. /*
  5153. * BIOS auto configuration
  5154. */
  5155. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  5156. hda_nid_t nid, int pin_type,
  5157. int dac_idx)
  5158. {
  5159. /* set as output */
  5160. struct alc_spec *spec = codec->spec;
  5161. int idx;
  5162. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5163. idx = 4;
  5164. else
  5165. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5166. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5167. pin_type);
  5168. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5169. AMP_OUT_UNMUTE);
  5170. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5171. }
  5172. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  5173. {
  5174. struct alc_spec *spec = codec->spec;
  5175. int i;
  5176. for (i = 0; i <= HDA_SIDE; i++) {
  5177. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5178. if (nid)
  5179. alc883_auto_set_output_and_unmute(codec, nid, PIN_OUT, i);
  5180. }
  5181. }
  5182. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  5183. {
  5184. struct alc_spec *spec = codec->spec;
  5185. hda_nid_t pin;
  5186. pin = spec->autocfg.hp_pins[0];
  5187. if (pin) /* connect to front */
  5188. /* use dac 0 */
  5189. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5190. }
  5191. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  5192. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  5193. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  5194. {
  5195. struct alc_spec *spec = codec->spec;
  5196. int i;
  5197. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5198. hda_nid_t nid = spec->autocfg.input_pins[i];
  5199. if (alc883_is_input_pin(nid)) {
  5200. snd_hda_codec_write(codec, nid, 0,
  5201. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5202. (i <= AUTO_PIN_FRONT_MIC ?
  5203. PIN_VREF80 : PIN_IN));
  5204. if (nid != ALC883_PIN_CD_NID)
  5205. snd_hda_codec_write(codec, nid, 0,
  5206. AC_VERB_SET_AMP_GAIN_MUTE,
  5207. AMP_OUT_MUTE);
  5208. }
  5209. }
  5210. }
  5211. /* almost identical with ALC880 parser... */
  5212. static int alc883_parse_auto_config(struct hda_codec *codec)
  5213. {
  5214. struct alc_spec *spec = codec->spec;
  5215. int err = alc880_parse_auto_config(codec);
  5216. if (err < 0)
  5217. return err;
  5218. else if (err > 0)
  5219. /* hack - override the init verbs */
  5220. spec->init_verbs[0] = alc883_auto_init_verbs;
  5221. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  5222. spec->num_mixers++;
  5223. return err;
  5224. }
  5225. /* additional initialization for auto-configuration model */
  5226. static void alc883_auto_init(struct hda_codec *codec)
  5227. {
  5228. alc883_auto_init_multi_out(codec);
  5229. alc883_auto_init_hp_out(codec);
  5230. alc883_auto_init_analog_input(codec);
  5231. }
  5232. static int patch_alc883(struct hda_codec *codec)
  5233. {
  5234. struct alc_spec *spec;
  5235. int err, board_config;
  5236. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5237. if (spec == NULL)
  5238. return -ENOMEM;
  5239. codec->spec = spec;
  5240. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  5241. alc883_models,
  5242. alc883_cfg_tbl);
  5243. if (board_config < 0) {
  5244. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  5245. "trying auto-probe from BIOS...\n");
  5246. board_config = ALC883_AUTO;
  5247. }
  5248. if (board_config == ALC883_AUTO) {
  5249. /* automatic parse from the BIOS config */
  5250. err = alc883_parse_auto_config(codec);
  5251. if (err < 0) {
  5252. alc_free(codec);
  5253. return err;
  5254. } else if (! err) {
  5255. printk(KERN_INFO
  5256. "hda_codec: Cannot set up configuration "
  5257. "from BIOS. Using base mode...\n");
  5258. board_config = ALC883_3ST_2ch_DIG;
  5259. }
  5260. }
  5261. if (board_config != ALC883_AUTO)
  5262. setup_preset(spec, &alc883_presets[board_config]);
  5263. spec->stream_name_analog = "ALC883 Analog";
  5264. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  5265. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  5266. spec->stream_name_digital = "ALC883 Digital";
  5267. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  5268. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  5269. if (! spec->adc_nids && spec->input_mux) {
  5270. spec->adc_nids = alc883_adc_nids;
  5271. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  5272. }
  5273. codec->patch_ops = alc_patch_ops;
  5274. if (board_config == ALC883_AUTO)
  5275. spec->init_hook = alc883_auto_init;
  5276. return 0;
  5277. }
  5278. /*
  5279. * ALC262 support
  5280. */
  5281. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  5282. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  5283. #define alc262_dac_nids alc260_dac_nids
  5284. #define alc262_adc_nids alc882_adc_nids
  5285. #define alc262_adc_nids_alt alc882_adc_nids_alt
  5286. #define alc262_modes alc260_modes
  5287. #define alc262_capture_source alc882_capture_source
  5288. static struct snd_kcontrol_new alc262_base_mixer[] = {
  5289. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5290. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5291. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5292. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5293. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5294. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5295. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5296. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5297. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5298. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5299. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5300. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5301. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  5302. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5303. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5304. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5305. { } /* end */
  5306. };
  5307. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  5308. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5309. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5310. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5311. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5312. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5313. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5314. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5315. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5316. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5317. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5318. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5319. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  5320. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  5321. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5322. { } /* end */
  5323. };
  5324. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  5325. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5326. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5327. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5328. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5329. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5330. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5331. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5332. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  5333. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  5334. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5335. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5336. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5337. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5338. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5339. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5340. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  5341. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  5342. { } /* end */
  5343. };
  5344. #define alc262_capture_mixer alc882_capture_mixer
  5345. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  5346. /*
  5347. * generic initialization of ADC, input mixers and output mixers
  5348. */
  5349. static struct hda_verb alc262_init_verbs[] = {
  5350. /*
  5351. * Unmute ADC0-2 and set the default input to mic-in
  5352. */
  5353. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5354. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5355. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5356. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5357. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5358. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5359. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5360. * mixer widget
  5361. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5362. * mic (mic 2)
  5363. */
  5364. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5365. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5366. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5367. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5368. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5369. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5370. /*
  5371. * Set up output mixers (0x0c - 0x0e)
  5372. */
  5373. /* set vol=0 to output mixers */
  5374. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5375. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5376. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5377. /* set up input amps for analog loopback */
  5378. /* Amp Indices: DAC = 0, mixer = 1 */
  5379. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5380. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5381. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5382. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5383. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5384. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5385. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5386. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5387. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  5388. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5389. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5390. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5391. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5392. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5393. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5394. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5395. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5396. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5397. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5398. /* FIXME: use matrix-type input source selection */
  5399. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5400. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5401. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5402. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5403. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5404. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5405. /* Input mixer2 */
  5406. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5407. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5408. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5409. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5410. /* Input mixer3 */
  5411. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5412. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5413. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5414. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5415. { }
  5416. };
  5417. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  5418. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5419. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5420. {}
  5421. };
  5422. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  5423. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5424. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5425. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  5426. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  5427. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5428. {}
  5429. };
  5430. /* mute/unmute internal speaker according to the hp jack and mute state */
  5431. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  5432. {
  5433. struct alc_spec *spec = codec->spec;
  5434. unsigned int mute;
  5435. if (force || ! spec->sense_updated) {
  5436. unsigned int present;
  5437. /* need to execute and sync at first */
  5438. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  5439. present = snd_hda_codec_read(codec, 0x15, 0,
  5440. AC_VERB_GET_PIN_SENSE, 0);
  5441. spec->jack_present = (present & 0x80000000) != 0;
  5442. spec->sense_updated = 1;
  5443. }
  5444. if (spec->jack_present) {
  5445. /* mute internal speaker */
  5446. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5447. 0x80, 0x80);
  5448. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5449. 0x80, 0x80);
  5450. } else {
  5451. /* unmute internal speaker if necessary */
  5452. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  5453. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5454. 0x80, mute & 0x80);
  5455. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  5456. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5457. 0x80, mute & 0x80);
  5458. }
  5459. }
  5460. /* unsolicited event for HP jack sensing */
  5461. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  5462. unsigned int res)
  5463. {
  5464. if ((res >> 26) != ALC880_HP_EVENT)
  5465. return;
  5466. alc262_hippo_automute(codec, 1);
  5467. }
  5468. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  5469. {
  5470. struct alc_spec *spec = codec->spec;
  5471. unsigned int mute;
  5472. if (force || ! spec->sense_updated) {
  5473. unsigned int present;
  5474. /* need to execute and sync at first */
  5475. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  5476. present = snd_hda_codec_read(codec, 0x1b, 0,
  5477. AC_VERB_GET_PIN_SENSE, 0);
  5478. spec->jack_present = (present & 0x80000000) != 0;
  5479. spec->sense_updated = 1;
  5480. }
  5481. if (spec->jack_present) {
  5482. /* mute internal speaker */
  5483. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5484. 0x80, 0x80);
  5485. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5486. 0x80, 0x80);
  5487. } else {
  5488. /* unmute internal speaker if necessary */
  5489. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  5490. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5491. 0x80, mute & 0x80);
  5492. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  5493. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5494. 0x80, mute & 0x80);
  5495. }
  5496. }
  5497. /* unsolicited event for HP jack sensing */
  5498. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  5499. unsigned int res)
  5500. {
  5501. if ((res >> 26) != ALC880_HP_EVENT)
  5502. return;
  5503. alc262_hippo1_automute(codec, 1);
  5504. }
  5505. /*
  5506. * fujitsu model
  5507. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  5508. */
  5509. #define ALC_HP_EVENT 0x37
  5510. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  5511. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  5512. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5513. {}
  5514. };
  5515. static struct hda_input_mux alc262_fujitsu_capture_source = {
  5516. .num_items = 2,
  5517. .items = {
  5518. { "Mic", 0x0 },
  5519. { "CD", 0x4 },
  5520. },
  5521. };
  5522. static struct hda_input_mux alc262_HP_capture_source = {
  5523. .num_items = 5,
  5524. .items = {
  5525. { "Mic", 0x0 },
  5526. { "Front Mic", 0x3 },
  5527. { "Line", 0x2 },
  5528. { "CD", 0x4 },
  5529. { "AUX IN", 0x6 },
  5530. },
  5531. };
  5532. /* mute/unmute internal speaker according to the hp jack and mute state */
  5533. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  5534. {
  5535. struct alc_spec *spec = codec->spec;
  5536. unsigned int mute;
  5537. if (force || ! spec->sense_updated) {
  5538. unsigned int present;
  5539. /* need to execute and sync at first */
  5540. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  5541. present = snd_hda_codec_read(codec, 0x14, 0,
  5542. AC_VERB_GET_PIN_SENSE, 0);
  5543. spec->jack_present = (present & 0x80000000) != 0;
  5544. spec->sense_updated = 1;
  5545. }
  5546. if (spec->jack_present) {
  5547. /* mute internal speaker */
  5548. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5549. 0x80, 0x80);
  5550. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5551. 0x80, 0x80);
  5552. } else {
  5553. /* unmute internal speaker if necessary */
  5554. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  5555. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5556. 0x80, mute & 0x80);
  5557. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  5558. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5559. 0x80, mute & 0x80);
  5560. }
  5561. }
  5562. /* unsolicited event for HP jack sensing */
  5563. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  5564. unsigned int res)
  5565. {
  5566. if ((res >> 26) != ALC_HP_EVENT)
  5567. return;
  5568. alc262_fujitsu_automute(codec, 1);
  5569. }
  5570. /* bind volumes of both NID 0x0c and 0x0d */
  5571. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  5572. struct snd_ctl_elem_value *ucontrol)
  5573. {
  5574. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5575. long *valp = ucontrol->value.integer.value;
  5576. int change;
  5577. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  5578. 0x7f, valp[0] & 0x7f);
  5579. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  5580. 0x7f, valp[1] & 0x7f);
  5581. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  5582. 0x7f, valp[0] & 0x7f);
  5583. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  5584. 0x7f, valp[1] & 0x7f);
  5585. return change;
  5586. }
  5587. /* bind hp and internal speaker mute (with plug check) */
  5588. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  5589. struct snd_ctl_elem_value *ucontrol)
  5590. {
  5591. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5592. long *valp = ucontrol->value.integer.value;
  5593. int change;
  5594. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5595. 0x80, valp[0] ? 0 : 0x80);
  5596. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5597. 0x80, valp[1] ? 0 : 0x80);
  5598. if (change || codec->in_resume)
  5599. alc262_fujitsu_automute(codec, codec->in_resume);
  5600. return change;
  5601. }
  5602. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  5603. {
  5604. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5605. .name = "Master Playback Volume",
  5606. .info = snd_hda_mixer_amp_volume_info,
  5607. .get = snd_hda_mixer_amp_volume_get,
  5608. .put = alc262_fujitsu_master_vol_put,
  5609. .tlv = { .c = snd_hda_mixer_amp_tlv },
  5610. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  5611. },
  5612. {
  5613. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5614. .name = "Master Playback Switch",
  5615. .info = snd_hda_mixer_amp_switch_info,
  5616. .get = snd_hda_mixer_amp_switch_get,
  5617. .put = alc262_fujitsu_master_sw_put,
  5618. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  5619. },
  5620. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5621. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5622. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5623. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5624. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5625. { } /* end */
  5626. };
  5627. /* additional init verbs for Benq laptops */
  5628. static struct hda_verb alc262_EAPD_verbs[] = {
  5629. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5630. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5631. {}
  5632. };
  5633. /* add playback controls from the parsed DAC table */
  5634. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  5635. {
  5636. hda_nid_t nid;
  5637. int err;
  5638. spec->multiout.num_dacs = 1; /* only use one dac */
  5639. spec->multiout.dac_nids = spec->private_dac_nids;
  5640. spec->multiout.dac_nids[0] = 2;
  5641. nid = cfg->line_out_pins[0];
  5642. if (nid) {
  5643. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Front Playback Volume",
  5644. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT))) < 0)
  5645. return err;
  5646. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Front Playback Switch",
  5647. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5648. return err;
  5649. }
  5650. nid = cfg->speaker_pins[0];
  5651. if (nid) {
  5652. if (nid == 0x16) {
  5653. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Speaker Playback Volume",
  5654. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5655. return err;
  5656. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5657. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5658. return err;
  5659. } else {
  5660. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Speaker Playback Switch",
  5661. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5662. return err;
  5663. }
  5664. }
  5665. nid = cfg->hp_pins[0];
  5666. if (nid) {
  5667. /* spec->multiout.hp_nid = 2; */
  5668. if (nid == 0x16) {
  5669. if ((err = add_control(spec, ALC_CTL_WIDGET_VOL, "Headphone Playback Volume",
  5670. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0, HDA_OUTPUT))) < 0)
  5671. return err;
  5672. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5673. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  5674. return err;
  5675. } else {
  5676. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  5677. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  5678. return err;
  5679. }
  5680. }
  5681. return 0;
  5682. }
  5683. /* identical with ALC880 */
  5684. #define alc262_auto_create_analog_input_ctls alc880_auto_create_analog_input_ctls
  5685. /*
  5686. * generic initialization of ADC, input mixers and output mixers
  5687. */
  5688. static struct hda_verb alc262_volume_init_verbs[] = {
  5689. /*
  5690. * Unmute ADC0-2 and set the default input to mic-in
  5691. */
  5692. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5693. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5694. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5695. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5696. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5697. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5698. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5699. * mixer widget
  5700. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5701. * mic (mic 2)
  5702. */
  5703. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5704. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5705. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5706. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5707. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5708. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5709. /*
  5710. * Set up output mixers (0x0c - 0x0f)
  5711. */
  5712. /* set vol=0 to output mixers */
  5713. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5714. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5715. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5716. /* set up input amps for analog loopback */
  5717. /* Amp Indices: DAC = 0, mixer = 1 */
  5718. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5719. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5720. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5721. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5722. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5723. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5724. /* FIXME: use matrix-type input source selection */
  5725. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5726. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5727. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5728. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5729. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5730. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5731. /* Input mixer2 */
  5732. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5733. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5734. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5735. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5736. /* Input mixer3 */
  5737. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5738. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5739. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5740. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5741. { }
  5742. };
  5743. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  5744. /*
  5745. * Unmute ADC0-2 and set the default input to mic-in
  5746. */
  5747. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5748. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5749. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5750. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5751. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5752. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5753. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5754. * mixer widget
  5755. * Note: PASD motherboards uses the Line In 2 as the input for front panel
  5756. * mic (mic 2)
  5757. */
  5758. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5759. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5760. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5761. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5762. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5763. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5764. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  5765. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  5766. /*
  5767. * Set up output mixers (0x0c - 0x0e)
  5768. */
  5769. /* set vol=0 to output mixers */
  5770. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5771. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5772. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5773. /* set up input amps for analog loopback */
  5774. /* Amp Indices: DAC = 0, mixer = 1 */
  5775. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5776. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5777. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5778. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5779. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5780. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5781. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  5782. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5783. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5784. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5785. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5786. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5787. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5788. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5789. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5790. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  5791. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5792. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  5793. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5794. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5795. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5796. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  5797. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5798. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  5799. /* FIXME: use matrix-type input source selection */
  5800. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5801. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5802. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5803. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5804. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5805. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5806. /* Input mixer2 */
  5807. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5808. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5809. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5810. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5811. /* Input mixer3 */
  5812. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5813. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  5814. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  5815. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  5816. { }
  5817. };
  5818. /* pcm configuration: identiacal with ALC880 */
  5819. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  5820. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  5821. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  5822. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  5823. /*
  5824. * BIOS auto configuration
  5825. */
  5826. static int alc262_parse_auto_config(struct hda_codec *codec)
  5827. {
  5828. struct alc_spec *spec = codec->spec;
  5829. int err;
  5830. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  5831. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  5832. alc262_ignore)) < 0)
  5833. return err;
  5834. if (! spec->autocfg.line_outs)
  5835. return 0; /* can't find valid BIOS pin config */
  5836. if ((err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  5837. (err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  5838. return err;
  5839. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  5840. if (spec->autocfg.dig_out_pin)
  5841. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  5842. if (spec->autocfg.dig_in_pin)
  5843. spec->dig_in_nid = ALC262_DIGIN_NID;
  5844. if (spec->kctl_alloc)
  5845. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  5846. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  5847. spec->num_mux_defs = 1;
  5848. spec->input_mux = &spec->private_imux;
  5849. return 1;
  5850. }
  5851. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  5852. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  5853. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  5854. /* init callback for auto-configuration model -- overriding the default init */
  5855. static void alc262_auto_init(struct hda_codec *codec)
  5856. {
  5857. alc262_auto_init_multi_out(codec);
  5858. alc262_auto_init_hp_out(codec);
  5859. alc262_auto_init_analog_input(codec);
  5860. }
  5861. /*
  5862. * configuration and preset
  5863. */
  5864. static const char *alc262_models[ALC262_MODEL_LAST] = {
  5865. [ALC262_BASIC] = "basic",
  5866. [ALC262_HIPPO] = "hippo",
  5867. [ALC262_HIPPO_1] = "hippo_1",
  5868. [ALC262_FUJITSU] = "fujitsu",
  5869. [ALC262_HP_BPC] = "hp-bpc",
  5870. [ALC262_BENQ_ED8] = "benq",
  5871. [ALC262_AUTO] = "auto",
  5872. };
  5873. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  5874. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  5875. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  5876. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  5877. SND_PCI_QUIRK(0x103c, 0x2801, "HP q954", ALC262_HP_BPC),
  5878. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  5879. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  5880. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  5881. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  5882. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  5883. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  5884. {}
  5885. };
  5886. static struct alc_config_preset alc262_presets[] = {
  5887. [ALC262_BASIC] = {
  5888. .mixers = { alc262_base_mixer },
  5889. .init_verbs = { alc262_init_verbs },
  5890. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5891. .dac_nids = alc262_dac_nids,
  5892. .hp_nid = 0x03,
  5893. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5894. .channel_mode = alc262_modes,
  5895. .input_mux = &alc262_capture_source,
  5896. },
  5897. [ALC262_HIPPO] = {
  5898. .mixers = { alc262_base_mixer },
  5899. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  5900. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5901. .dac_nids = alc262_dac_nids,
  5902. .hp_nid = 0x03,
  5903. .dig_out_nid = ALC262_DIGOUT_NID,
  5904. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5905. .channel_mode = alc262_modes,
  5906. .input_mux = &alc262_capture_source,
  5907. .unsol_event = alc262_hippo_unsol_event,
  5908. },
  5909. [ALC262_HIPPO_1] = {
  5910. .mixers = { alc262_hippo1_mixer },
  5911. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  5912. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5913. .dac_nids = alc262_dac_nids,
  5914. .hp_nid = 0x02,
  5915. .dig_out_nid = ALC262_DIGOUT_NID,
  5916. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5917. .channel_mode = alc262_modes,
  5918. .input_mux = &alc262_capture_source,
  5919. .unsol_event = alc262_hippo1_unsol_event,
  5920. },
  5921. [ALC262_FUJITSU] = {
  5922. .mixers = { alc262_fujitsu_mixer },
  5923. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  5924. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5925. .dac_nids = alc262_dac_nids,
  5926. .hp_nid = 0x03,
  5927. .dig_out_nid = ALC262_DIGOUT_NID,
  5928. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5929. .channel_mode = alc262_modes,
  5930. .input_mux = &alc262_fujitsu_capture_source,
  5931. .unsol_event = alc262_fujitsu_unsol_event,
  5932. },
  5933. [ALC262_HP_BPC] = {
  5934. .mixers = { alc262_HP_BPC_mixer },
  5935. .init_verbs = { alc262_HP_BPC_init_verbs },
  5936. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5937. .dac_nids = alc262_dac_nids,
  5938. .hp_nid = 0x03,
  5939. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5940. .channel_mode = alc262_modes,
  5941. .input_mux = &alc262_HP_capture_source,
  5942. },
  5943. [ALC262_BENQ_ED8] = {
  5944. .mixers = { alc262_base_mixer },
  5945. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  5946. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  5947. .dac_nids = alc262_dac_nids,
  5948. .hp_nid = 0x03,
  5949. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  5950. .channel_mode = alc262_modes,
  5951. .input_mux = &alc262_capture_source,
  5952. },
  5953. };
  5954. static int patch_alc262(struct hda_codec *codec)
  5955. {
  5956. struct alc_spec *spec;
  5957. int board_config;
  5958. int err;
  5959. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5960. if (spec == NULL)
  5961. return -ENOMEM;
  5962. codec->spec = spec;
  5963. #if 0
  5964. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is under-run */
  5965. {
  5966. int tmp;
  5967. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  5968. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  5969. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  5970. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  5971. }
  5972. #endif
  5973. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  5974. alc262_models,
  5975. alc262_cfg_tbl);
  5976. if (board_config < 0) {
  5977. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  5978. "trying auto-probe from BIOS...\n");
  5979. board_config = ALC262_AUTO;
  5980. }
  5981. if (board_config == ALC262_AUTO) {
  5982. /* automatic parse from the BIOS config */
  5983. err = alc262_parse_auto_config(codec);
  5984. if (err < 0) {
  5985. alc_free(codec);
  5986. return err;
  5987. } else if (! err) {
  5988. printk(KERN_INFO
  5989. "hda_codec: Cannot set up configuration "
  5990. "from BIOS. Using base mode...\n");
  5991. board_config = ALC262_BASIC;
  5992. }
  5993. }
  5994. if (board_config != ALC262_AUTO)
  5995. setup_preset(spec, &alc262_presets[board_config]);
  5996. spec->stream_name_analog = "ALC262 Analog";
  5997. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  5998. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  5999. spec->stream_name_digital = "ALC262 Digital";
  6000. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  6001. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  6002. if (! spec->adc_nids && spec->input_mux) {
  6003. /* check whether NID 0x07 is valid */
  6004. unsigned int wcap = get_wcaps(codec, 0x07);
  6005. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  6006. if (wcap != AC_WID_AUD_IN) {
  6007. spec->adc_nids = alc262_adc_nids_alt;
  6008. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  6009. spec->mixers[spec->num_mixers] = alc262_capture_alt_mixer;
  6010. spec->num_mixers++;
  6011. } else {
  6012. spec->adc_nids = alc262_adc_nids;
  6013. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  6014. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  6015. spec->num_mixers++;
  6016. }
  6017. }
  6018. codec->patch_ops = alc_patch_ops;
  6019. if (board_config == ALC262_AUTO)
  6020. spec->init_hook = alc262_auto_init;
  6021. return 0;
  6022. }
  6023. /*
  6024. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  6025. */
  6026. /*
  6027. * set the path ways for 2 channel output
  6028. * need to set the codec line out and mic 1 pin widgets to inputs
  6029. */
  6030. static struct hda_verb alc861_threestack_ch2_init[] = {
  6031. /* set pin widget 1Ah (line in) for input */
  6032. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6033. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  6034. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6035. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6036. #if 0
  6037. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6038. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6039. #endif
  6040. { } /* end */
  6041. };
  6042. /*
  6043. * 6ch mode
  6044. * need to set the codec line out and mic 1 pin widgets to outputs
  6045. */
  6046. static struct hda_verb alc861_threestack_ch6_init[] = {
  6047. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6048. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6049. /* set pin widget 18h (mic1) for output (CLFE)*/
  6050. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6051. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6052. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6053. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6054. #if 0
  6055. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6056. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6057. #endif
  6058. { } /* end */
  6059. };
  6060. static struct hda_channel_mode alc861_threestack_modes[2] = {
  6061. { 2, alc861_threestack_ch2_init },
  6062. { 6, alc861_threestack_ch6_init },
  6063. };
  6064. /* Set mic1 as input and unmute the mixer */
  6065. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  6066. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6067. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6068. { } /* end */
  6069. };
  6070. /* Set mic1 as output and mute mixer */
  6071. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  6072. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6073. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6074. { } /* end */
  6075. };
  6076. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  6077. { 2, alc861_uniwill_m31_ch2_init },
  6078. { 4, alc861_uniwill_m31_ch4_init },
  6079. };
  6080. /* Set mic1 and line-in as input and unmute the mixer */
  6081. static struct hda_verb alc861_asus_ch2_init[] = {
  6082. /* set pin widget 1Ah (line in) for input */
  6083. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6084. /* set pin widget 18h (mic1/2) for input, for mic also enable the vref */
  6085. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6086. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  6087. #if 0
  6088. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  6089. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  6090. #endif
  6091. { } /* end */
  6092. };
  6093. /* Set mic1 nad line-in as output and mute mixer */
  6094. static struct hda_verb alc861_asus_ch6_init[] = {
  6095. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  6096. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6097. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6098. /* set pin widget 18h (mic1) for output (CLFE)*/
  6099. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6100. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  6101. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6102. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6103. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  6104. #if 0
  6105. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  6106. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  6107. #endif
  6108. { } /* end */
  6109. };
  6110. static struct hda_channel_mode alc861_asus_modes[2] = {
  6111. { 2, alc861_asus_ch2_init },
  6112. { 6, alc861_asus_ch6_init },
  6113. };
  6114. /* patch-ALC861 */
  6115. static struct snd_kcontrol_new alc861_base_mixer[] = {
  6116. /* output mixer control */
  6117. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6118. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6119. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6120. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6121. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6122. /*Input mixer control */
  6123. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6124. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6125. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6126. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6127. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6128. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6129. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6130. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6131. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6132. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6133. /* Capture mixer control */
  6134. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6135. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6136. {
  6137. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6138. .name = "Capture Source",
  6139. .count = 1,
  6140. .info = alc_mux_enum_info,
  6141. .get = alc_mux_enum_get,
  6142. .put = alc_mux_enum_put,
  6143. },
  6144. { } /* end */
  6145. };
  6146. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  6147. /* output mixer control */
  6148. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6149. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6150. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6151. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6152. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6153. /* Input mixer control */
  6154. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6155. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6156. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6157. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6158. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6159. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6160. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6161. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6162. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6163. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6164. /* Capture mixer control */
  6165. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6166. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6167. {
  6168. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6169. .name = "Capture Source",
  6170. .count = 1,
  6171. .info = alc_mux_enum_info,
  6172. .get = alc_mux_enum_get,
  6173. .put = alc_mux_enum_put,
  6174. },
  6175. {
  6176. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6177. .name = "Channel Mode",
  6178. .info = alc_ch_mode_info,
  6179. .get = alc_ch_mode_get,
  6180. .put = alc_ch_mode_put,
  6181. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  6182. },
  6183. { } /* end */
  6184. };
  6185. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  6186. /* output mixer control */
  6187. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6188. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6189. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6190. /*Capture mixer control */
  6191. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6192. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6193. {
  6194. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6195. .name = "Capture Source",
  6196. .count = 1,
  6197. .info = alc_mux_enum_info,
  6198. .get = alc_mux_enum_get,
  6199. .put = alc_mux_enum_put,
  6200. },
  6201. { } /* end */
  6202. };
  6203. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  6204. /* output mixer control */
  6205. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6206. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6207. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6208. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6209. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  6210. /* Input mixer control */
  6211. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6212. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  6213. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6214. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6215. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6216. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6217. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6218. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6219. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6220. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  6221. /* Capture mixer control */
  6222. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6223. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6224. {
  6225. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6226. .name = "Capture Source",
  6227. .count = 1,
  6228. .info = alc_mux_enum_info,
  6229. .get = alc_mux_enum_get,
  6230. .put = alc_mux_enum_put,
  6231. },
  6232. {
  6233. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6234. .name = "Channel Mode",
  6235. .info = alc_ch_mode_info,
  6236. .get = alc_ch_mode_get,
  6237. .put = alc_ch_mode_put,
  6238. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6239. },
  6240. { } /* end */
  6241. };
  6242. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  6243. /* output mixer control */
  6244. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  6245. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  6246. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  6247. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  6248. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  6249. /* Input mixer control */
  6250. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  6251. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6252. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6253. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6254. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  6255. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  6256. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  6257. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  6258. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  6259. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT), /* was HDA_INPUT (why?) */
  6260. /* Capture mixer control */
  6261. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6262. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6263. {
  6264. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6265. .name = "Capture Source",
  6266. .count = 1,
  6267. .info = alc_mux_enum_info,
  6268. .get = alc_mux_enum_get,
  6269. .put = alc_mux_enum_put,
  6270. },
  6271. {
  6272. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6273. .name = "Channel Mode",
  6274. .info = alc_ch_mode_info,
  6275. .get = alc_ch_mode_get,
  6276. .put = alc_ch_mode_put,
  6277. .private_value = ARRAY_SIZE(alc861_asus_modes),
  6278. },
  6279. { }
  6280. };
  6281. /* additional mixer */
  6282. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  6283. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  6284. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  6285. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  6286. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  6287. { }
  6288. };
  6289. /*
  6290. * generic initialization of ADC, input mixers and output mixers
  6291. */
  6292. static struct hda_verb alc861_base_init_verbs[] = {
  6293. /*
  6294. * Unmute ADC0 and set the default input to mic-in
  6295. */
  6296. /* port-A for surround (rear panel) */
  6297. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6298. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6299. /* port-B for mic-in (rear panel) with vref */
  6300. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6301. /* port-C for line-in (rear panel) */
  6302. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6303. /* port-D for Front */
  6304. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6305. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6306. /* port-E for HP out (front panel) */
  6307. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6308. /* route front PCM to HP */
  6309. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6310. /* port-F for mic-in (front panel) with vref */
  6311. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6312. /* port-G for CLFE (rear panel) */
  6313. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6314. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6315. /* port-H for side (rear panel) */
  6316. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6317. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6318. /* CD-in */
  6319. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6320. /* route front mic to ADC1*/
  6321. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6322. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6323. /* Unmute DAC0~3 & spdif out*/
  6324. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6325. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6326. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6327. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6328. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6329. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6330. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6331. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6332. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6333. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6334. /* Unmute Stereo Mixer 15 */
  6335. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6336. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6337. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6338. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6339. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6340. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6341. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6342. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6343. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6344. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6345. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6346. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6347. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6348. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6349. { }
  6350. };
  6351. static struct hda_verb alc861_threestack_init_verbs[] = {
  6352. /*
  6353. * Unmute ADC0 and set the default input to mic-in
  6354. */
  6355. /* port-A for surround (rear panel) */
  6356. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6357. /* port-B for mic-in (rear panel) with vref */
  6358. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6359. /* port-C for line-in (rear panel) */
  6360. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6361. /* port-D for Front */
  6362. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6363. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6364. /* port-E for HP out (front panel) */
  6365. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  6366. /* route front PCM to HP */
  6367. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6368. /* port-F for mic-in (front panel) with vref */
  6369. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6370. /* port-G for CLFE (rear panel) */
  6371. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6372. /* port-H for side (rear panel) */
  6373. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6374. /* CD-in */
  6375. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6376. /* route front mic to ADC1*/
  6377. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6378. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6379. /* Unmute DAC0~3 & spdif out*/
  6380. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6381. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6382. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6383. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6384. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6385. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6386. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6387. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6388. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6389. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6390. /* Unmute Stereo Mixer 15 */
  6391. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6392. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6393. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6394. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6395. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6396. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6397. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6398. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6399. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6400. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6401. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6402. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6403. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6404. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6405. { }
  6406. };
  6407. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  6408. /*
  6409. * Unmute ADC0 and set the default input to mic-in
  6410. */
  6411. /* port-A for surround (rear panel) */
  6412. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6413. /* port-B for mic-in (rear panel) with vref */
  6414. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6415. /* port-C for line-in (rear panel) */
  6416. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6417. /* port-D for Front */
  6418. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6419. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6420. /* port-E for HP out (front panel) */
  6421. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, // this has to be set to VREF80
  6422. /* route front PCM to HP */
  6423. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6424. /* port-F for mic-in (front panel) with vref */
  6425. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6426. /* port-G for CLFE (rear panel) */
  6427. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6428. /* port-H for side (rear panel) */
  6429. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  6430. /* CD-in */
  6431. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6432. /* route front mic to ADC1*/
  6433. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6434. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6435. /* Unmute DAC0~3 & spdif out*/
  6436. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6437. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6438. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6439. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6440. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6441. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6442. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6443. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6444. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6445. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6446. /* Unmute Stereo Mixer 15 */
  6447. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6448. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6449. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6450. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, //Output 0~12 step
  6451. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6452. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6453. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6454. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6455. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6456. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6457. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6458. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6459. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, // hp used DAC 3 (Front)
  6460. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6461. { }
  6462. };
  6463. static struct hda_verb alc861_asus_init_verbs[] = {
  6464. /*
  6465. * Unmute ADC0 and set the default input to mic-in
  6466. */
  6467. /* port-A for surround (rear panel) | according to codec#0 this is the HP jack*/
  6468. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  6469. /* route front PCM to HP */
  6470. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  6471. /* port-B for mic-in (rear panel) with vref */
  6472. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6473. /* port-C for line-in (rear panel) */
  6474. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6475. /* port-D for Front */
  6476. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6477. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6478. /* port-E for HP out (front panel) */
  6479. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 }, /* this has to be set to VREF80 */
  6480. /* route front PCM to HP */
  6481. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  6482. /* port-F for mic-in (front panel) with vref */
  6483. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  6484. /* port-G for CLFE (rear panel) */
  6485. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6486. /* port-H for side (rear panel) */
  6487. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  6488. /* CD-in */
  6489. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  6490. /* route front mic to ADC1*/
  6491. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6492. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6493. /* Unmute DAC0~3 & spdif out*/
  6494. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6495. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6496. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6497. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6498. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6499. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6500. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6501. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6502. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6503. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6504. /* Unmute Stereo Mixer 15 */
  6505. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6506. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6507. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6508. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c }, /* Output 0~12 step */
  6509. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6510. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6511. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6512. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6513. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6514. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6515. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6516. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6517. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, /* hp used DAC 3 (Front) */
  6518. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6519. { }
  6520. };
  6521. /* additional init verbs for ASUS laptops */
  6522. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  6523. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  6524. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  6525. { }
  6526. };
  6527. /*
  6528. * generic initialization of ADC, input mixers and output mixers
  6529. */
  6530. static struct hda_verb alc861_auto_init_verbs[] = {
  6531. /*
  6532. * Unmute ADC0 and set the default input to mic-in
  6533. */
  6534. // {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6535. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6536. /* Unmute DAC0~3 & spdif out*/
  6537. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6538. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6539. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6540. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6541. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6542. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  6543. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6544. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6545. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6546. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6547. /* Unmute Stereo Mixer 15 */
  6548. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6549. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6550. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6551. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  6552. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6553. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6554. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6555. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6556. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6557. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6558. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6559. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6560. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6561. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6562. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6563. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6564. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6565. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6566. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6567. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6568. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, // set Mic 1
  6569. { }
  6570. };
  6571. static struct hda_verb alc861_toshiba_init_verbs[] = {
  6572. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6573. { }
  6574. };
  6575. /* toggle speaker-output according to the hp-jack state */
  6576. static void alc861_toshiba_automute(struct hda_codec *codec)
  6577. {
  6578. unsigned int present;
  6579. present = snd_hda_codec_read(codec, 0x0f, 0,
  6580. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6581. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  6582. 0x80, present ? 0x80 : 0);
  6583. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  6584. 0x80, present ? 0x80 : 0);
  6585. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  6586. 0x80, present ? 0 : 0x80);
  6587. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  6588. 0x80, present ? 0 : 0x80);
  6589. }
  6590. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  6591. unsigned int res)
  6592. {
  6593. /* Looks like the unsol event is incompatible with the standard
  6594. * definition. 6bit tag is placed at 26 bit!
  6595. */
  6596. if ((res >> 26) == ALC880_HP_EVENT)
  6597. alc861_toshiba_automute(codec);
  6598. }
  6599. /* pcm configuration: identiacal with ALC880 */
  6600. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  6601. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  6602. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  6603. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  6604. #define ALC861_DIGOUT_NID 0x07
  6605. static struct hda_channel_mode alc861_8ch_modes[1] = {
  6606. { 8, NULL }
  6607. };
  6608. static hda_nid_t alc861_dac_nids[4] = {
  6609. /* front, surround, clfe, side */
  6610. 0x03, 0x06, 0x05, 0x04
  6611. };
  6612. static hda_nid_t alc660_dac_nids[3] = {
  6613. /* front, clfe, surround */
  6614. 0x03, 0x05, 0x06
  6615. };
  6616. static hda_nid_t alc861_adc_nids[1] = {
  6617. /* ADC0-2 */
  6618. 0x08,
  6619. };
  6620. static struct hda_input_mux alc861_capture_source = {
  6621. .num_items = 5,
  6622. .items = {
  6623. { "Mic", 0x0 },
  6624. { "Front Mic", 0x3 },
  6625. { "Line", 0x1 },
  6626. { "CD", 0x4 },
  6627. { "Mixer", 0x5 },
  6628. },
  6629. };
  6630. /* fill in the dac_nids table from the parsed pin configuration */
  6631. static int alc861_auto_fill_dac_nids(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  6632. {
  6633. int i;
  6634. hda_nid_t nid;
  6635. spec->multiout.dac_nids = spec->private_dac_nids;
  6636. for (i = 0; i < cfg->line_outs; i++) {
  6637. nid = cfg->line_out_pins[i];
  6638. if (nid) {
  6639. if (i >= ARRAY_SIZE(alc861_dac_nids))
  6640. continue;
  6641. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  6642. }
  6643. }
  6644. spec->multiout.num_dacs = cfg->line_outs;
  6645. return 0;
  6646. }
  6647. /* add playback controls from the parsed DAC table */
  6648. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  6649. const struct auto_pin_cfg *cfg)
  6650. {
  6651. char name[32];
  6652. static const char *chname[4] = { "Front", "Surround", NULL /*CLFE*/, "Side" };
  6653. hda_nid_t nid;
  6654. int i, idx, err;
  6655. for (i = 0; i < cfg->line_outs; i++) {
  6656. nid = spec->multiout.dac_nids[i];
  6657. if (! nid)
  6658. continue;
  6659. if (nid == 0x05) {
  6660. /* Center/LFE */
  6661. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "Center Playback Switch",
  6662. HDA_COMPOSE_AMP_VAL(nid, 1, 0, HDA_OUTPUT))) < 0)
  6663. return err;
  6664. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, "LFE Playback Switch",
  6665. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT))) < 0)
  6666. return err;
  6667. } else {
  6668. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1; idx++)
  6669. if (nid == alc861_dac_nids[idx])
  6670. break;
  6671. sprintf(name, "%s Playback Switch", chname[idx]);
  6672. if ((err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  6673. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  6674. return err;
  6675. }
  6676. }
  6677. return 0;
  6678. }
  6679. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  6680. {
  6681. int err;
  6682. hda_nid_t nid;
  6683. if (! pin)
  6684. return 0;
  6685. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  6686. nid = 0x03;
  6687. if ((err = add_control(spec, ALC_CTL_WIDGET_MUTE, "Headphone Playback Switch",
  6688. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT))) < 0)
  6689. return err;
  6690. spec->multiout.hp_nid = nid;
  6691. }
  6692. return 0;
  6693. }
  6694. /* create playback/capture controls for input pins */
  6695. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec, const struct auto_pin_cfg *cfg)
  6696. {
  6697. struct hda_input_mux *imux = &spec->private_imux;
  6698. int i, err, idx, idx1;
  6699. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6700. switch(cfg->input_pins[i]) {
  6701. case 0x0c:
  6702. idx1 = 1;
  6703. idx = 2; // Line In
  6704. break;
  6705. case 0x0f:
  6706. idx1 = 2;
  6707. idx = 2; // Line In
  6708. break;
  6709. case 0x0d:
  6710. idx1 = 0;
  6711. idx = 1; // Mic In
  6712. break;
  6713. case 0x10:
  6714. idx1 = 3;
  6715. idx = 1; // Mic In
  6716. break;
  6717. case 0x11:
  6718. idx1 = 4;
  6719. idx = 0; // CD
  6720. break;
  6721. default:
  6722. continue;
  6723. }
  6724. err = new_analog_input(spec, cfg->input_pins[i],
  6725. auto_pin_cfg_labels[i], idx, 0x15);
  6726. if (err < 0)
  6727. return err;
  6728. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  6729. imux->items[imux->num_items].index = idx1;
  6730. imux->num_items++;
  6731. }
  6732. return 0;
  6733. }
  6734. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  6735. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6736. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6737. {
  6738. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6739. /* The multiple "Capture Source" controls confuse alsamixer
  6740. * So call somewhat different..
  6741. *FIXME: the controls appear in the "playback" view!
  6742. */
  6743. /* .name = "Capture Source", */
  6744. .name = "Input Source",
  6745. .count = 1,
  6746. .info = alc_mux_enum_info,
  6747. .get = alc_mux_enum_get,
  6748. .put = alc_mux_enum_put,
  6749. },
  6750. { } /* end */
  6751. };
  6752. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec, hda_nid_t nid,
  6753. int pin_type, int dac_idx)
  6754. {
  6755. /* set as output */
  6756. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  6757. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  6758. }
  6759. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  6760. {
  6761. struct alc_spec *spec = codec->spec;
  6762. int i;
  6763. for (i = 0; i < spec->autocfg.line_outs; i++) {
  6764. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6765. if (nid)
  6766. alc861_auto_set_output_and_unmute(codec, nid, PIN_OUT, spec->multiout.dac_nids[i]);
  6767. }
  6768. }
  6769. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  6770. {
  6771. struct alc_spec *spec = codec->spec;
  6772. hda_nid_t pin;
  6773. pin = spec->autocfg.hp_pins[0];
  6774. if (pin) /* connect to front */
  6775. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP, spec->multiout.dac_nids[0]);
  6776. }
  6777. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  6778. {
  6779. struct alc_spec *spec = codec->spec;
  6780. int i;
  6781. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6782. hda_nid_t nid = spec->autocfg.input_pins[i];
  6783. if ((nid>=0x0c) && (nid <=0x11)) {
  6784. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6785. i <= AUTO_PIN_FRONT_MIC ? PIN_VREF80 : PIN_IN);
  6786. }
  6787. }
  6788. }
  6789. /* parse the BIOS configuration and set up the alc_spec */
  6790. /* return 1 if successful, 0 if the proper config is not found, or a negative error code */
  6791. static int alc861_parse_auto_config(struct hda_codec *codec)
  6792. {
  6793. struct alc_spec *spec = codec->spec;
  6794. int err;
  6795. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  6796. if ((err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  6797. alc861_ignore)) < 0)
  6798. return err;
  6799. if (! spec->autocfg.line_outs)
  6800. return 0; /* can't find valid BIOS pin config */
  6801. if ((err = alc861_auto_fill_dac_nids(spec, &spec->autocfg)) < 0 ||
  6802. (err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg)) < 0 ||
  6803. (err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0])) < 0 ||
  6804. (err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg)) < 0)
  6805. return err;
  6806. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  6807. if (spec->autocfg.dig_out_pin)
  6808. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  6809. if (spec->kctl_alloc)
  6810. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  6811. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  6812. spec->num_mux_defs = 1;
  6813. spec->input_mux = &spec->private_imux;
  6814. spec->adc_nids = alc861_adc_nids;
  6815. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  6816. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  6817. spec->num_mixers++;
  6818. return 1;
  6819. }
  6820. /* additional initialization for auto-configuration model */
  6821. static void alc861_auto_init(struct hda_codec *codec)
  6822. {
  6823. alc861_auto_init_multi_out(codec);
  6824. alc861_auto_init_hp_out(codec);
  6825. alc861_auto_init_analog_input(codec);
  6826. }
  6827. /*
  6828. * configuration and preset
  6829. */
  6830. static const char *alc861_models[ALC861_MODEL_LAST] = {
  6831. [ALC861_3ST] = "3stack",
  6832. [ALC660_3ST] = "3stack-660",
  6833. [ALC861_3ST_DIG] = "3stack-dig",
  6834. [ALC861_6ST_DIG] = "6stack-dig",
  6835. [ALC861_UNIWILL_M31] = "uniwill-m31",
  6836. [ALC861_TOSHIBA] = "toshiba",
  6837. [ALC861_ASUS] = "asus",
  6838. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  6839. [ALC861_AUTO] = "auto",
  6840. };
  6841. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  6842. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  6843. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  6844. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  6845. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660_3ST),
  6846. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  6847. SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA),
  6848. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  6849. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  6850. {}
  6851. };
  6852. static struct alc_config_preset alc861_presets[] = {
  6853. [ALC861_3ST] = {
  6854. .mixers = { alc861_3ST_mixer },
  6855. .init_verbs = { alc861_threestack_init_verbs },
  6856. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6857. .dac_nids = alc861_dac_nids,
  6858. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6859. .channel_mode = alc861_threestack_modes,
  6860. .need_dac_fix = 1,
  6861. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6862. .adc_nids = alc861_adc_nids,
  6863. .input_mux = &alc861_capture_source,
  6864. },
  6865. [ALC861_3ST_DIG] = {
  6866. .mixers = { alc861_base_mixer },
  6867. .init_verbs = { alc861_threestack_init_verbs },
  6868. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6869. .dac_nids = alc861_dac_nids,
  6870. .dig_out_nid = ALC861_DIGOUT_NID,
  6871. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6872. .channel_mode = alc861_threestack_modes,
  6873. .need_dac_fix = 1,
  6874. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6875. .adc_nids = alc861_adc_nids,
  6876. .input_mux = &alc861_capture_source,
  6877. },
  6878. [ALC861_6ST_DIG] = {
  6879. .mixers = { alc861_base_mixer },
  6880. .init_verbs = { alc861_base_init_verbs },
  6881. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6882. .dac_nids = alc861_dac_nids,
  6883. .dig_out_nid = ALC861_DIGOUT_NID,
  6884. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  6885. .channel_mode = alc861_8ch_modes,
  6886. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6887. .adc_nids = alc861_adc_nids,
  6888. .input_mux = &alc861_capture_source,
  6889. },
  6890. [ALC660_3ST] = {
  6891. .mixers = { alc861_3ST_mixer },
  6892. .init_verbs = { alc861_threestack_init_verbs },
  6893. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  6894. .dac_nids = alc660_dac_nids,
  6895. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  6896. .channel_mode = alc861_threestack_modes,
  6897. .need_dac_fix = 1,
  6898. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6899. .adc_nids = alc861_adc_nids,
  6900. .input_mux = &alc861_capture_source,
  6901. },
  6902. [ALC861_UNIWILL_M31] = {
  6903. .mixers = { alc861_uniwill_m31_mixer },
  6904. .init_verbs = { alc861_uniwill_m31_init_verbs },
  6905. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6906. .dac_nids = alc861_dac_nids,
  6907. .dig_out_nid = ALC861_DIGOUT_NID,
  6908. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  6909. .channel_mode = alc861_uniwill_m31_modes,
  6910. .need_dac_fix = 1,
  6911. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6912. .adc_nids = alc861_adc_nids,
  6913. .input_mux = &alc861_capture_source,
  6914. },
  6915. [ALC861_TOSHIBA] = {
  6916. .mixers = { alc861_toshiba_mixer },
  6917. .init_verbs = { alc861_base_init_verbs, alc861_toshiba_init_verbs },
  6918. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6919. .dac_nids = alc861_dac_nids,
  6920. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6921. .channel_mode = alc883_3ST_2ch_modes,
  6922. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6923. .adc_nids = alc861_adc_nids,
  6924. .input_mux = &alc861_capture_source,
  6925. .unsol_event = alc861_toshiba_unsol_event,
  6926. .init_hook = alc861_toshiba_automute,
  6927. },
  6928. [ALC861_ASUS] = {
  6929. .mixers = { alc861_asus_mixer },
  6930. .init_verbs = { alc861_asus_init_verbs },
  6931. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6932. .dac_nids = alc861_dac_nids,
  6933. .dig_out_nid = ALC861_DIGOUT_NID,
  6934. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  6935. .channel_mode = alc861_asus_modes,
  6936. .need_dac_fix = 1,
  6937. .hp_nid = 0x06,
  6938. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6939. .adc_nids = alc861_adc_nids,
  6940. .input_mux = &alc861_capture_source,
  6941. },
  6942. [ALC861_ASUS_LAPTOP] = {
  6943. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  6944. .init_verbs = { alc861_asus_init_verbs,
  6945. alc861_asus_laptop_init_verbs },
  6946. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  6947. .dac_nids = alc861_dac_nids,
  6948. .dig_out_nid = ALC861_DIGOUT_NID,
  6949. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6950. .channel_mode = alc883_3ST_2ch_modes,
  6951. .need_dac_fix = 1,
  6952. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  6953. .adc_nids = alc861_adc_nids,
  6954. .input_mux = &alc861_capture_source,
  6955. },
  6956. };
  6957. static int patch_alc861(struct hda_codec *codec)
  6958. {
  6959. struct alc_spec *spec;
  6960. int board_config;
  6961. int err;
  6962. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6963. if (spec == NULL)
  6964. return -ENOMEM;
  6965. codec->spec = spec;
  6966. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  6967. alc861_models,
  6968. alc861_cfg_tbl);
  6969. if (board_config < 0) {
  6970. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  6971. "trying auto-probe from BIOS...\n");
  6972. board_config = ALC861_AUTO;
  6973. }
  6974. if (board_config == ALC861_AUTO) {
  6975. /* automatic parse from the BIOS config */
  6976. err = alc861_parse_auto_config(codec);
  6977. if (err < 0) {
  6978. alc_free(codec);
  6979. return err;
  6980. } else if (! err) {
  6981. printk(KERN_INFO
  6982. "hda_codec: Cannot set up configuration "
  6983. "from BIOS. Using base mode...\n");
  6984. board_config = ALC861_3ST_DIG;
  6985. }
  6986. }
  6987. if (board_config != ALC861_AUTO)
  6988. setup_preset(spec, &alc861_presets[board_config]);
  6989. spec->stream_name_analog = "ALC861 Analog";
  6990. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  6991. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  6992. spec->stream_name_digital = "ALC861 Digital";
  6993. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  6994. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  6995. codec->patch_ops = alc_patch_ops;
  6996. if (board_config == ALC861_AUTO)
  6997. spec->init_hook = alc861_auto_init;
  6998. return 0;
  6999. }
  7000. /*
  7001. * patch entries
  7002. */
  7003. struct hda_codec_preset snd_hda_preset_realtek[] = {
  7004. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  7005. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  7006. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  7007. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  7008. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  7009. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  7010. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  7011. { .id = 0x10ec0861, .rev = 0x100300, .name = "ALC861",
  7012. .patch = patch_alc861 },
  7013. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  7014. .patch = patch_alc861 },
  7015. { .id = 0x10ec0660, .name = "ALC660", .patch = patch_alc861 },
  7016. {} /* terminator */
  7017. };