patch_realtek.c 265 KB

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