patch_realtek.c 381 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480
  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_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_BENQ_T31,
  93. ALC262_AUTO,
  94. ALC262_MODEL_LAST /* last tag */
  95. };
  96. /* ALC268 models */
  97. enum {
  98. ALC268_3ST,
  99. ALC268_AUTO,
  100. ALC268_MODEL_LAST /* last tag */
  101. };
  102. /* ALC861 models */
  103. enum {
  104. ALC861_3ST,
  105. ALC660_3ST,
  106. ALC861_3ST_DIG,
  107. ALC861_6ST_DIG,
  108. ALC861_UNIWILL_M31,
  109. ALC861_TOSHIBA,
  110. ALC861_ASUS,
  111. ALC861_ASUS_LAPTOP,
  112. ALC861_AUTO,
  113. ALC861_MODEL_LAST,
  114. };
  115. /* ALC861-VD models */
  116. enum {
  117. ALC660VD_3ST,
  118. ALC660VD_3ST_DIG,
  119. ALC861VD_3ST,
  120. ALC861VD_3ST_DIG,
  121. ALC861VD_6ST_DIG,
  122. ALC861VD_LENOVO,
  123. ALC861VD_DALLAS,
  124. ALC861VD_AUTO,
  125. ALC861VD_MODEL_LAST,
  126. };
  127. /* ALC662 models */
  128. enum {
  129. ALC662_3ST_2ch_DIG,
  130. ALC662_3ST_6ch_DIG,
  131. ALC662_3ST_6ch,
  132. ALC662_5ST_DIG,
  133. ALC662_LENOVO_101E,
  134. ALC662_AUTO,
  135. ALC662_MODEL_LAST,
  136. };
  137. /* ALC882 models */
  138. enum {
  139. ALC882_3ST_DIG,
  140. ALC882_6ST_DIG,
  141. ALC882_ARIMA,
  142. ALC882_W2JC,
  143. ALC882_TARGA,
  144. ALC882_ASUS_A7J,
  145. ALC885_MACPRO,
  146. ALC882_AUTO,
  147. ALC882_MODEL_LAST,
  148. };
  149. /* ALC883 models */
  150. enum {
  151. ALC883_3ST_2ch_DIG,
  152. ALC883_3ST_6ch_DIG,
  153. ALC883_3ST_6ch,
  154. ALC883_6ST_DIG,
  155. ALC883_TARGA_DIG,
  156. ALC883_TARGA_2ch_DIG,
  157. ALC883_ACER,
  158. ALC883_MEDION,
  159. ALC883_MEDION_MD2,
  160. ALC883_LAPTOP_EAPD,
  161. ALC883_LENOVO_101E_2ch,
  162. ALC883_LENOVO_NB0763,
  163. ALC888_LENOVO_MS7195_DIG,
  164. ALC888_HP_NETTLE,
  165. ALC888_HP_LUCKNOW,
  166. ALC883_AUTO,
  167. ALC883_MODEL_LAST,
  168. };
  169. /* for GPIO Poll */
  170. #define GPIO_MASK 0x03
  171. struct alc_spec {
  172. /* codec parameterization */
  173. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  174. unsigned int num_mixers;
  175. const struct hda_verb *init_verbs[5]; /* initialization verbs
  176. * don't forget NULL
  177. * termination!
  178. */
  179. unsigned int num_init_verbs;
  180. char *stream_name_analog; /* analog PCM stream */
  181. struct hda_pcm_stream *stream_analog_playback;
  182. struct hda_pcm_stream *stream_analog_capture;
  183. char *stream_name_digital; /* digital PCM stream */
  184. struct hda_pcm_stream *stream_digital_playback;
  185. struct hda_pcm_stream *stream_digital_capture;
  186. /* playback */
  187. struct hda_multi_out multiout; /* playback set-up
  188. * max_channels, dacs must be set
  189. * dig_out_nid and hp_nid are optional
  190. */
  191. /* capture */
  192. unsigned int num_adc_nids;
  193. hda_nid_t *adc_nids;
  194. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  195. /* capture source */
  196. unsigned int num_mux_defs;
  197. const struct hda_input_mux *input_mux;
  198. unsigned int cur_mux[3];
  199. /* channel model */
  200. const struct hda_channel_mode *channel_mode;
  201. int num_channel_mode;
  202. int need_dac_fix;
  203. /* PCM information */
  204. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  205. /* dynamic controls, init_verbs and input_mux */
  206. struct auto_pin_cfg autocfg;
  207. unsigned int num_kctl_alloc, num_kctl_used;
  208. struct snd_kcontrol_new *kctl_alloc;
  209. struct hda_input_mux private_imux;
  210. hda_nid_t private_dac_nids[5];
  211. /* hooks */
  212. void (*init_hook)(struct hda_codec *codec);
  213. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  214. /* for pin sensing */
  215. unsigned int sense_updated: 1;
  216. unsigned int jack_present: 1;
  217. };
  218. /*
  219. * configuration template - to be copied to the spec instance
  220. */
  221. struct alc_config_preset {
  222. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  223. * with spec
  224. */
  225. const struct hda_verb *init_verbs[5];
  226. unsigned int num_dacs;
  227. hda_nid_t *dac_nids;
  228. hda_nid_t dig_out_nid; /* optional */
  229. hda_nid_t hp_nid; /* optional */
  230. unsigned int num_adc_nids;
  231. hda_nid_t *adc_nids;
  232. hda_nid_t dig_in_nid;
  233. unsigned int num_channel_mode;
  234. const struct hda_channel_mode *channel_mode;
  235. int need_dac_fix;
  236. unsigned int num_mux_defs;
  237. const struct hda_input_mux *input_mux;
  238. void (*unsol_event)(struct hda_codec *, unsigned int);
  239. void (*init_hook)(struct hda_codec *);
  240. };
  241. /*
  242. * input MUX handling
  243. */
  244. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  245. struct snd_ctl_elem_info *uinfo)
  246. {
  247. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  248. struct alc_spec *spec = codec->spec;
  249. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  250. if (mux_idx >= spec->num_mux_defs)
  251. mux_idx = 0;
  252. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  253. }
  254. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  255. struct snd_ctl_elem_value *ucontrol)
  256. {
  257. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  258. struct alc_spec *spec = codec->spec;
  259. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  260. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  261. return 0;
  262. }
  263. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  264. struct snd_ctl_elem_value *ucontrol)
  265. {
  266. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  267. struct alc_spec *spec = codec->spec;
  268. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  269. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  270. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  271. spec->adc_nids[adc_idx],
  272. &spec->cur_mux[adc_idx]);
  273. }
  274. /*
  275. * channel mode setting
  276. */
  277. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  278. struct snd_ctl_elem_info *uinfo)
  279. {
  280. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  281. struct alc_spec *spec = codec->spec;
  282. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  283. spec->num_channel_mode);
  284. }
  285. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  286. struct snd_ctl_elem_value *ucontrol)
  287. {
  288. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  289. struct alc_spec *spec = codec->spec;
  290. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  291. spec->num_channel_mode,
  292. spec->multiout.max_channels);
  293. }
  294. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  295. struct snd_ctl_elem_value *ucontrol)
  296. {
  297. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  298. struct alc_spec *spec = codec->spec;
  299. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  300. spec->num_channel_mode,
  301. &spec->multiout.max_channels);
  302. if (err >= 0 && spec->need_dac_fix)
  303. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  304. return err;
  305. }
  306. /*
  307. * Control the mode of pin widget settings via the mixer. "pc" is used
  308. * instead of "%" to avoid consequences of accidently treating the % as
  309. * being part of a format specifier. Maximum allowed length of a value is
  310. * 63 characters plus NULL terminator.
  311. *
  312. * Note: some retasking pin complexes seem to ignore requests for input
  313. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  314. * are requested. Therefore order this list so that this behaviour will not
  315. * cause problems when mixer clients move through the enum sequentially.
  316. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  317. * March 2006.
  318. */
  319. static char *alc_pin_mode_names[] = {
  320. "Mic 50pc bias", "Mic 80pc bias",
  321. "Line in", "Line out", "Headphone out",
  322. };
  323. static unsigned char alc_pin_mode_values[] = {
  324. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  325. };
  326. /* The control can present all 5 options, or it can limit the options based
  327. * in the pin being assumed to be exclusively an input or an output pin. In
  328. * addition, "input" pins may or may not process the mic bias option
  329. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  330. * accept requests for bias as of chip versions up to March 2006) and/or
  331. * wiring in the computer.
  332. */
  333. #define ALC_PIN_DIR_IN 0x00
  334. #define ALC_PIN_DIR_OUT 0x01
  335. #define ALC_PIN_DIR_INOUT 0x02
  336. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  337. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  338. /* Info about the pin modes supported by the different pin direction modes.
  339. * For each direction the minimum and maximum values are given.
  340. */
  341. static signed char alc_pin_mode_dir_info[5][2] = {
  342. { 0, 2 }, /* ALC_PIN_DIR_IN */
  343. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  344. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  345. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  346. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  347. };
  348. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  349. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  350. #define alc_pin_mode_n_items(_dir) \
  351. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  352. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  353. struct snd_ctl_elem_info *uinfo)
  354. {
  355. unsigned int item_num = uinfo->value.enumerated.item;
  356. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  357. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  358. uinfo->count = 1;
  359. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  360. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  361. item_num = alc_pin_mode_min(dir);
  362. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  363. return 0;
  364. }
  365. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  366. struct snd_ctl_elem_value *ucontrol)
  367. {
  368. unsigned int i;
  369. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  370. hda_nid_t nid = kcontrol->private_value & 0xffff;
  371. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  372. long *valp = ucontrol->value.integer.value;
  373. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  374. AC_VERB_GET_PIN_WIDGET_CONTROL,
  375. 0x00);
  376. /* Find enumerated value for current pinctl setting */
  377. i = alc_pin_mode_min(dir);
  378. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  379. i++;
  380. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  381. return 0;
  382. }
  383. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  384. struct snd_ctl_elem_value *ucontrol)
  385. {
  386. signed int change;
  387. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  388. hda_nid_t nid = kcontrol->private_value & 0xffff;
  389. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  390. long val = *ucontrol->value.integer.value;
  391. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  392. AC_VERB_GET_PIN_WIDGET_CONTROL,
  393. 0x00);
  394. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  395. val = alc_pin_mode_min(dir);
  396. change = pinctl != alc_pin_mode_values[val];
  397. if (change) {
  398. /* Set pin mode to that requested */
  399. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  400. alc_pin_mode_values[val]);
  401. /* Also enable the retasking pin's input/output as required
  402. * for the requested pin mode. Enum values of 2 or less are
  403. * input modes.
  404. *
  405. * Dynamically switching the input/output buffers probably
  406. * reduces noise slightly (particularly on input) so we'll
  407. * do it. However, having both input and output buffers
  408. * enabled simultaneously doesn't seem to be problematic if
  409. * this turns out to be necessary in the future.
  410. */
  411. if (val <= 2) {
  412. snd_hda_codec_write(codec, nid, 0,
  413. AC_VERB_SET_AMP_GAIN_MUTE,
  414. AMP_OUT_MUTE);
  415. snd_hda_codec_write(codec, nid, 0,
  416. AC_VERB_SET_AMP_GAIN_MUTE,
  417. AMP_IN_UNMUTE(0));
  418. } else {
  419. snd_hda_codec_write(codec, nid, 0,
  420. AC_VERB_SET_AMP_GAIN_MUTE,
  421. AMP_IN_MUTE(0));
  422. snd_hda_codec_write(codec, nid, 0,
  423. AC_VERB_SET_AMP_GAIN_MUTE,
  424. AMP_OUT_UNMUTE);
  425. }
  426. }
  427. return change;
  428. }
  429. #define ALC_PIN_MODE(xname, nid, dir) \
  430. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  431. .info = alc_pin_mode_info, \
  432. .get = alc_pin_mode_get, \
  433. .put = alc_pin_mode_put, \
  434. .private_value = nid | (dir<<16) }
  435. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  436. * together using a mask with more than one bit set. This control is
  437. * currently used only by the ALC260 test model. At this stage they are not
  438. * needed for any "production" models.
  439. */
  440. #ifdef CONFIG_SND_DEBUG
  441. static int alc_gpio_data_info(struct snd_kcontrol *kcontrol,
  442. struct snd_ctl_elem_info *uinfo)
  443. {
  444. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  445. uinfo->count = 1;
  446. uinfo->value.integer.min = 0;
  447. uinfo->value.integer.max = 1;
  448. return 0;
  449. }
  450. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  451. struct snd_ctl_elem_value *ucontrol)
  452. {
  453. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  454. hda_nid_t nid = kcontrol->private_value & 0xffff;
  455. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  456. long *valp = ucontrol->value.integer.value;
  457. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  458. AC_VERB_GET_GPIO_DATA, 0x00);
  459. *valp = (val & mask) != 0;
  460. return 0;
  461. }
  462. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  463. struct snd_ctl_elem_value *ucontrol)
  464. {
  465. signed int change;
  466. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  467. hda_nid_t nid = kcontrol->private_value & 0xffff;
  468. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  469. long val = *ucontrol->value.integer.value;
  470. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  471. AC_VERB_GET_GPIO_DATA,
  472. 0x00);
  473. /* Set/unset the masked GPIO bit(s) as needed */
  474. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  475. if (val == 0)
  476. gpio_data &= ~mask;
  477. else
  478. gpio_data |= mask;
  479. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  480. return change;
  481. }
  482. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  483. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  484. .info = alc_gpio_data_info, \
  485. .get = alc_gpio_data_get, \
  486. .put = alc_gpio_data_put, \
  487. .private_value = nid | (mask<<16) }
  488. #endif /* CONFIG_SND_DEBUG */
  489. /* A switch control to allow the enabling of the digital IO pins on the
  490. * ALC260. This is incredibly simplistic; the intention of this control is
  491. * to provide something in the test model allowing digital outputs to be
  492. * identified if present. If models are found which can utilise these
  493. * outputs a more complete mixer control can be devised for those models if
  494. * necessary.
  495. */
  496. #ifdef CONFIG_SND_DEBUG
  497. static int alc_spdif_ctrl_info(struct snd_kcontrol *kcontrol,
  498. struct snd_ctl_elem_info *uinfo)
  499. {
  500. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  501. uinfo->count = 1;
  502. uinfo->value.integer.min = 0;
  503. uinfo->value.integer.max = 1;
  504. return 0;
  505. }
  506. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  507. struct snd_ctl_elem_value *ucontrol)
  508. {
  509. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  510. hda_nid_t nid = kcontrol->private_value & 0xffff;
  511. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  512. long *valp = ucontrol->value.integer.value;
  513. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  514. AC_VERB_GET_DIGI_CONVERT, 0x00);
  515. *valp = (val & mask) != 0;
  516. return 0;
  517. }
  518. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  519. struct snd_ctl_elem_value *ucontrol)
  520. {
  521. signed int change;
  522. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  523. hda_nid_t nid = kcontrol->private_value & 0xffff;
  524. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  525. long val = *ucontrol->value.integer.value;
  526. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  527. AC_VERB_GET_DIGI_CONVERT,
  528. 0x00);
  529. /* Set/unset the masked control bit(s) as needed */
  530. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  531. if (val==0)
  532. ctrl_data &= ~mask;
  533. else
  534. ctrl_data |= mask;
  535. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  536. ctrl_data);
  537. return change;
  538. }
  539. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  540. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  541. .info = alc_spdif_ctrl_info, \
  542. .get = alc_spdif_ctrl_get, \
  543. .put = alc_spdif_ctrl_put, \
  544. .private_value = nid | (mask<<16) }
  545. #endif /* CONFIG_SND_DEBUG */
  546. /*
  547. * set up from the preset table
  548. */
  549. static void setup_preset(struct alc_spec *spec,
  550. const struct alc_config_preset *preset)
  551. {
  552. int i;
  553. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  554. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  555. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  556. i++)
  557. spec->init_verbs[spec->num_init_verbs++] =
  558. preset->init_verbs[i];
  559. spec->channel_mode = preset->channel_mode;
  560. spec->num_channel_mode = preset->num_channel_mode;
  561. spec->need_dac_fix = preset->need_dac_fix;
  562. spec->multiout.max_channels = spec->channel_mode[0].channels;
  563. spec->multiout.num_dacs = preset->num_dacs;
  564. spec->multiout.dac_nids = preset->dac_nids;
  565. spec->multiout.dig_out_nid = preset->dig_out_nid;
  566. spec->multiout.hp_nid = preset->hp_nid;
  567. spec->num_mux_defs = preset->num_mux_defs;
  568. if (!spec->num_mux_defs)
  569. spec->num_mux_defs = 1;
  570. spec->input_mux = preset->input_mux;
  571. spec->num_adc_nids = preset->num_adc_nids;
  572. spec->adc_nids = preset->adc_nids;
  573. spec->dig_in_nid = preset->dig_in_nid;
  574. spec->unsol_event = preset->unsol_event;
  575. spec->init_hook = preset->init_hook;
  576. }
  577. /* Enable GPIO mask and set output */
  578. static struct hda_verb alc_gpio1_init_verbs[] = {
  579. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  580. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  581. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  582. { }
  583. };
  584. static struct hda_verb alc_gpio2_init_verbs[] = {
  585. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  586. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  587. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  588. { }
  589. };
  590. static struct hda_verb alc_gpio3_init_verbs[] = {
  591. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  592. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  593. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  594. { }
  595. };
  596. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  597. * 31 ~ 16 : Manufacture ID
  598. * 15 ~ 8 : SKU ID
  599. * 7 ~ 0 : Assembly ID
  600. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  601. */
  602. static void alc_subsystem_id(struct hda_codec *codec,
  603. unsigned int porta, unsigned int porte,
  604. unsigned int portd)
  605. {
  606. unsigned int ass, tmp;
  607. ass = codec->subsystem_id;
  608. if (!(ass & 1))
  609. return;
  610. /* Override */
  611. tmp = (ass & 0x38) >> 3; /* external Amp control */
  612. switch (tmp) {
  613. case 1:
  614. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  615. break;
  616. case 3:
  617. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  618. break;
  619. case 7:
  620. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  621. break;
  622. case 5:
  623. switch (codec->vendor_id) {
  624. case 0x10ec0862:
  625. case 0x10ec0660:
  626. case 0x10ec0662:
  627. case 0x10ec0267:
  628. case 0x10ec0268:
  629. snd_hda_codec_write(codec, 0x14, 0,
  630. AC_VERB_SET_EAPD_BTLENABLE, 2);
  631. snd_hda_codec_write(codec, 0x15, 0,
  632. AC_VERB_SET_EAPD_BTLENABLE, 2);
  633. return;
  634. }
  635. case 6:
  636. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  637. hda_nid_t port = 0;
  638. tmp = (ass & 0x1800) >> 11;
  639. switch (tmp) {
  640. case 0: port = porta; break;
  641. case 1: port = porte; break;
  642. case 2: port = portd; break;
  643. }
  644. if (port)
  645. snd_hda_codec_write(codec, port, 0,
  646. AC_VERB_SET_EAPD_BTLENABLE,
  647. 2);
  648. }
  649. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  650. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  651. (tmp == 5 ? 0x3040 : 0x3050));
  652. break;
  653. }
  654. }
  655. /*
  656. * ALC880 3-stack model
  657. *
  658. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  659. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  660. * F-Mic = 0x1b, HP = 0x19
  661. */
  662. static hda_nid_t alc880_dac_nids[4] = {
  663. /* front, rear, clfe, rear_surr */
  664. 0x02, 0x05, 0x04, 0x03
  665. };
  666. static hda_nid_t alc880_adc_nids[3] = {
  667. /* ADC0-2 */
  668. 0x07, 0x08, 0x09,
  669. };
  670. /* The datasheet says the node 0x07 is connected from inputs,
  671. * but it shows zero connection in the real implementation on some devices.
  672. * Note: this is a 915GAV bug, fixed on 915GLV
  673. */
  674. static hda_nid_t alc880_adc_nids_alt[2] = {
  675. /* ADC1-2 */
  676. 0x08, 0x09,
  677. };
  678. #define ALC880_DIGOUT_NID 0x06
  679. #define ALC880_DIGIN_NID 0x0a
  680. static struct hda_input_mux alc880_capture_source = {
  681. .num_items = 4,
  682. .items = {
  683. { "Mic", 0x0 },
  684. { "Front Mic", 0x3 },
  685. { "Line", 0x2 },
  686. { "CD", 0x4 },
  687. },
  688. };
  689. /* channel source setting (2/6 channel selection for 3-stack) */
  690. /* 2ch mode */
  691. static struct hda_verb alc880_threestack_ch2_init[] = {
  692. /* set line-in to input, mute it */
  693. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  694. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  695. /* set mic-in to input vref 80%, mute it */
  696. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  697. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  698. { } /* end */
  699. };
  700. /* 6ch mode */
  701. static struct hda_verb alc880_threestack_ch6_init[] = {
  702. /* set line-in to output, unmute it */
  703. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  704. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  705. /* set mic-in to output, unmute it */
  706. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  707. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  708. { } /* end */
  709. };
  710. static struct hda_channel_mode alc880_threestack_modes[2] = {
  711. { 2, alc880_threestack_ch2_init },
  712. { 6, alc880_threestack_ch6_init },
  713. };
  714. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  715. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  716. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  717. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  718. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  719. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  720. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  721. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  722. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  723. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  724. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  725. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  726. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  727. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  728. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  729. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  730. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  731. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  732. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  733. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  734. {
  735. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  736. .name = "Channel Mode",
  737. .info = alc_ch_mode_info,
  738. .get = alc_ch_mode_get,
  739. .put = alc_ch_mode_put,
  740. },
  741. { } /* end */
  742. };
  743. /* capture mixer elements */
  744. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  745. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  746. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  747. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  748. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  749. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  750. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  751. {
  752. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  753. /* The multiple "Capture Source" controls confuse alsamixer
  754. * So call somewhat different..
  755. * FIXME: the controls appear in the "playback" view!
  756. */
  757. /* .name = "Capture Source", */
  758. .name = "Input Source",
  759. .count = 3,
  760. .info = alc_mux_enum_info,
  761. .get = alc_mux_enum_get,
  762. .put = alc_mux_enum_put,
  763. },
  764. { } /* end */
  765. };
  766. /* capture mixer elements (in case NID 0x07 not available) */
  767. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  768. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  769. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  770. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  771. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  772. {
  773. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  774. /* The multiple "Capture Source" controls confuse alsamixer
  775. * So call somewhat different..
  776. * FIXME: the controls appear in the "playback" view!
  777. */
  778. /* .name = "Capture Source", */
  779. .name = "Input Source",
  780. .count = 2,
  781. .info = alc_mux_enum_info,
  782. .get = alc_mux_enum_get,
  783. .put = alc_mux_enum_put,
  784. },
  785. { } /* end */
  786. };
  787. /*
  788. * ALC880 5-stack model
  789. *
  790. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  791. * Side = 0x02 (0xd)
  792. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  793. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  794. */
  795. /* additional mixers to alc880_three_stack_mixer */
  796. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  797. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  798. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  799. { } /* end */
  800. };
  801. /* channel source setting (6/8 channel selection for 5-stack) */
  802. /* 6ch mode */
  803. static struct hda_verb alc880_fivestack_ch6_init[] = {
  804. /* set line-in to input, mute it */
  805. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  806. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  807. { } /* end */
  808. };
  809. /* 8ch mode */
  810. static struct hda_verb alc880_fivestack_ch8_init[] = {
  811. /* set line-in to output, unmute it */
  812. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  813. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  814. { } /* end */
  815. };
  816. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  817. { 6, alc880_fivestack_ch6_init },
  818. { 8, alc880_fivestack_ch8_init },
  819. };
  820. /*
  821. * ALC880 6-stack model
  822. *
  823. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  824. * Side = 0x05 (0x0f)
  825. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  826. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  827. */
  828. static hda_nid_t alc880_6st_dac_nids[4] = {
  829. /* front, rear, clfe, rear_surr */
  830. 0x02, 0x03, 0x04, 0x05
  831. };
  832. static struct hda_input_mux alc880_6stack_capture_source = {
  833. .num_items = 4,
  834. .items = {
  835. { "Mic", 0x0 },
  836. { "Front Mic", 0x1 },
  837. { "Line", 0x2 },
  838. { "CD", 0x4 },
  839. },
  840. };
  841. /* fixed 8-channels */
  842. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  843. { 8, NULL },
  844. };
  845. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  846. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  847. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  848. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  849. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  850. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  851. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  852. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  853. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  854. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  855. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  856. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  857. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  858. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  859. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  860. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  861. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  862. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  863. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  864. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  865. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  866. {
  867. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  868. .name = "Channel Mode",
  869. .info = alc_ch_mode_info,
  870. .get = alc_ch_mode_get,
  871. .put = alc_ch_mode_put,
  872. },
  873. { } /* end */
  874. };
  875. /*
  876. * ALC880 W810 model
  877. *
  878. * W810 has rear IO for:
  879. * Front (DAC 02)
  880. * Surround (DAC 03)
  881. * Center/LFE (DAC 04)
  882. * Digital out (06)
  883. *
  884. * The system also has a pair of internal speakers, and a headphone jack.
  885. * These are both connected to Line2 on the codec, hence to DAC 02.
  886. *
  887. * There is a variable resistor to control the speaker or headphone
  888. * volume. This is a hardware-only device without a software API.
  889. *
  890. * Plugging headphones in will disable the internal speakers. This is
  891. * implemented in hardware, not via the driver using jack sense. In
  892. * a similar fashion, plugging into the rear socket marked "front" will
  893. * disable both the speakers and headphones.
  894. *
  895. * For input, there's a microphone jack, and an "audio in" jack.
  896. * These may not do anything useful with this driver yet, because I
  897. * haven't setup any initialization verbs for these yet...
  898. */
  899. static hda_nid_t alc880_w810_dac_nids[3] = {
  900. /* front, rear/surround, clfe */
  901. 0x02, 0x03, 0x04
  902. };
  903. /* fixed 6 channels */
  904. static struct hda_channel_mode alc880_w810_modes[1] = {
  905. { 6, NULL }
  906. };
  907. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  908. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  909. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  910. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  911. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  912. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  913. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  914. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  915. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  916. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  917. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  918. { } /* end */
  919. };
  920. /*
  921. * Z710V model
  922. *
  923. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  924. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  925. * Line = 0x1a
  926. */
  927. static hda_nid_t alc880_z71v_dac_nids[1] = {
  928. 0x02
  929. };
  930. #define ALC880_Z71V_HP_DAC 0x03
  931. /* fixed 2 channels */
  932. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  933. { 2, NULL }
  934. };
  935. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  936. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  937. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  938. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  939. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  940. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  941. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  942. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  943. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  944. { } /* end */
  945. };
  946. /* FIXME! */
  947. /*
  948. * ALC880 F1734 model
  949. *
  950. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  951. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  952. */
  953. static hda_nid_t alc880_f1734_dac_nids[1] = {
  954. 0x03
  955. };
  956. #define ALC880_F1734_HP_DAC 0x02
  957. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  958. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  959. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  960. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  961. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  962. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  963. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  964. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  965. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  966. { } /* end */
  967. };
  968. /* FIXME! */
  969. /*
  970. * ALC880 ASUS model
  971. *
  972. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  973. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  974. * Mic = 0x18, Line = 0x1a
  975. */
  976. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  977. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  978. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  979. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  980. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  981. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  982. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  983. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  984. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  985. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  986. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  987. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  988. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  989. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  990. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  991. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  992. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  993. {
  994. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  995. .name = "Channel Mode",
  996. .info = alc_ch_mode_info,
  997. .get = alc_ch_mode_get,
  998. .put = alc_ch_mode_put,
  999. },
  1000. { } /* end */
  1001. };
  1002. /* FIXME! */
  1003. /*
  1004. * ALC880 ASUS W1V model
  1005. *
  1006. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1007. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1008. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1009. */
  1010. /* additional mixers to alc880_asus_mixer */
  1011. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1012. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1013. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1014. { } /* end */
  1015. };
  1016. /* additional mixers to alc880_asus_mixer */
  1017. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1018. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1019. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1020. { } /* end */
  1021. };
  1022. /* TCL S700 */
  1023. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1024. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1025. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1026. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1027. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1028. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1029. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1030. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1031. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1032. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1033. {
  1034. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1035. /* The multiple "Capture Source" controls confuse alsamixer
  1036. * So call somewhat different..
  1037. * FIXME: the controls appear in the "playback" view!
  1038. */
  1039. /* .name = "Capture Source", */
  1040. .name = "Input Source",
  1041. .count = 1,
  1042. .info = alc_mux_enum_info,
  1043. .get = alc_mux_enum_get,
  1044. .put = alc_mux_enum_put,
  1045. },
  1046. { } /* end */
  1047. };
  1048. /* Uniwill */
  1049. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1050. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1051. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1052. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1053. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1054. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1055. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1056. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1057. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1058. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1059. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1060. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1061. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1062. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1063. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1064. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1065. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1066. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1067. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1068. {
  1069. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1070. .name = "Channel Mode",
  1071. .info = alc_ch_mode_info,
  1072. .get = alc_ch_mode_get,
  1073. .put = alc_ch_mode_put,
  1074. },
  1075. { } /* end */
  1076. };
  1077. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1078. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1079. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1080. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1081. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1082. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1083. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1084. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1085. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1086. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1087. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1088. { } /* end */
  1089. };
  1090. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1091. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1092. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1093. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1094. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1095. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1096. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1097. { } /* end */
  1098. };
  1099. /*
  1100. * build control elements
  1101. */
  1102. static int alc_build_controls(struct hda_codec *codec)
  1103. {
  1104. struct alc_spec *spec = codec->spec;
  1105. int err;
  1106. int i;
  1107. for (i = 0; i < spec->num_mixers; i++) {
  1108. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1109. if (err < 0)
  1110. return err;
  1111. }
  1112. if (spec->multiout.dig_out_nid) {
  1113. err = snd_hda_create_spdif_out_ctls(codec,
  1114. spec->multiout.dig_out_nid);
  1115. if (err < 0)
  1116. return err;
  1117. }
  1118. if (spec->dig_in_nid) {
  1119. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1120. if (err < 0)
  1121. return err;
  1122. }
  1123. return 0;
  1124. }
  1125. /*
  1126. * initialize the codec volumes, etc
  1127. */
  1128. /*
  1129. * generic initialization of ADC, input mixers and output mixers
  1130. */
  1131. static struct hda_verb alc880_volume_init_verbs[] = {
  1132. /*
  1133. * Unmute ADC0-2 and set the default input to mic-in
  1134. */
  1135. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1136. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1137. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1138. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1139. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1140. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1141. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1142. * mixer widget
  1143. * Note: PASD motherboards uses the Line In 2 as the input for front
  1144. * panel mic (mic 2)
  1145. */
  1146. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1147. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1148. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1149. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1150. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1151. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1152. /*
  1153. * Set up output mixers (0x0c - 0x0f)
  1154. */
  1155. /* set vol=0 to output mixers */
  1156. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1157. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1158. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1159. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1160. /* set up input amps for analog loopback */
  1161. /* Amp Indices: DAC = 0, mixer = 1 */
  1162. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1163. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1164. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1165. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1166. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1167. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1168. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1169. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1170. { }
  1171. };
  1172. /*
  1173. * 3-stack pin configuration:
  1174. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1175. */
  1176. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1177. /*
  1178. * preset connection lists of input pins
  1179. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1180. */
  1181. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1182. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1183. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1184. /*
  1185. * Set pin mode and muting
  1186. */
  1187. /* set front pin widgets 0x14 for output */
  1188. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1189. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1190. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1191. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1192. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1193. /* Mic2 (as headphone out) for HP output */
  1194. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1195. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1196. /* Line In pin widget for input */
  1197. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1198. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1199. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1200. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1201. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1202. /* CD pin widget for input */
  1203. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1204. { }
  1205. };
  1206. /*
  1207. * 5-stack pin configuration:
  1208. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1209. * line-in/side = 0x1a, f-mic = 0x1b
  1210. */
  1211. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1212. /*
  1213. * preset connection lists of input pins
  1214. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1215. */
  1216. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1217. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1218. /*
  1219. * Set pin mode and muting
  1220. */
  1221. /* set pin widgets 0x14-0x17 for output */
  1222. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1223. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1224. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1225. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1226. /* unmute pins for output (no gain on this amp) */
  1227. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1228. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1229. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1230. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1231. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1232. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1233. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1234. /* Mic2 (as headphone out) for HP output */
  1235. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1236. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1237. /* Line In pin widget for input */
  1238. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1239. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1240. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1241. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1242. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1243. /* CD pin widget for input */
  1244. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1245. { }
  1246. };
  1247. /*
  1248. * W810 pin configuration:
  1249. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1250. */
  1251. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1252. /* hphone/speaker input selector: front DAC */
  1253. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1254. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1255. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1257. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1258. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1259. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1260. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1261. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1262. { }
  1263. };
  1264. /*
  1265. * Z71V pin configuration:
  1266. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1267. */
  1268. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1269. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1270. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1271. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1272. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1273. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1274. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1275. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1276. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1277. { }
  1278. };
  1279. /*
  1280. * 6-stack pin configuration:
  1281. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1282. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1283. */
  1284. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1285. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1286. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1287. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1288. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1289. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1290. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1291. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1292. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1293. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1294. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1295. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1296. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1297. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1298. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1299. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1300. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1301. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1302. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1303. { }
  1304. };
  1305. /*
  1306. * Uniwill pin configuration:
  1307. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1308. * line = 0x1a
  1309. */
  1310. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1311. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1312. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1313. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1314. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1315. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1316. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1317. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1318. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1319. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1320. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1321. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1322. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1323. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1324. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1325. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1326. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1327. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1328. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1329. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1330. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1331. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1332. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1333. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1334. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1335. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1336. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1337. { }
  1338. };
  1339. /*
  1340. * Uniwill P53
  1341. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1342. */
  1343. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1344. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1345. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1346. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1347. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1348. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1349. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1350. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1351. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1352. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1353. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1354. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1355. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1356. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1357. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1358. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1359. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1360. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1361. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1362. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1363. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1364. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1365. { }
  1366. };
  1367. static struct hda_verb alc880_beep_init_verbs[] = {
  1368. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1369. { }
  1370. };
  1371. /* toggle speaker-output according to the hp-jack state */
  1372. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1373. {
  1374. unsigned int present;
  1375. unsigned char bits;
  1376. present = snd_hda_codec_read(codec, 0x14, 0,
  1377. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1378. bits = present ? 0x80 : 0;
  1379. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1380. 0x80, bits);
  1381. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1382. 0x80, bits);
  1383. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1384. 0x80, bits);
  1385. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1386. 0x80, bits);
  1387. }
  1388. /* auto-toggle front mic */
  1389. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1390. {
  1391. unsigned int present;
  1392. unsigned char bits;
  1393. present = snd_hda_codec_read(codec, 0x18, 0,
  1394. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1395. bits = present ? 0x80 : 0;
  1396. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1397. 0x80, bits);
  1398. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1399. 0x80, bits);
  1400. }
  1401. static void alc880_uniwill_automute(struct hda_codec *codec)
  1402. {
  1403. alc880_uniwill_hp_automute(codec);
  1404. alc880_uniwill_mic_automute(codec);
  1405. }
  1406. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1407. unsigned int res)
  1408. {
  1409. /* Looks like the unsol event is incompatible with the standard
  1410. * definition. 4bit tag is placed at 28 bit!
  1411. */
  1412. switch (res >> 28) {
  1413. case ALC880_HP_EVENT:
  1414. alc880_uniwill_hp_automute(codec);
  1415. break;
  1416. case ALC880_MIC_EVENT:
  1417. alc880_uniwill_mic_automute(codec);
  1418. break;
  1419. }
  1420. }
  1421. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1422. {
  1423. unsigned int present;
  1424. unsigned char bits;
  1425. present = snd_hda_codec_read(codec, 0x14, 0,
  1426. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1427. bits = present ? 0x80 : 0;
  1428. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1429. 0x80, bits);
  1430. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1431. 0x80, bits);
  1432. }
  1433. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1434. {
  1435. unsigned int present;
  1436. present = snd_hda_codec_read(codec, 0x21, 0,
  1437. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1438. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1439. 0x7f, present);
  1440. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1441. 0x7f, present);
  1442. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1443. 0x7f, present);
  1444. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1445. 0x7f, present);
  1446. }
  1447. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1448. unsigned int res)
  1449. {
  1450. /* Looks like the unsol event is incompatible with the standard
  1451. * definition. 4bit tag is placed at 28 bit!
  1452. */
  1453. if ((res >> 28) == ALC880_HP_EVENT)
  1454. alc880_uniwill_p53_hp_automute(codec);
  1455. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1456. alc880_uniwill_p53_dcvol_automute(codec);
  1457. }
  1458. /* FIXME! */
  1459. /*
  1460. * F1734 pin configuration:
  1461. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1462. */
  1463. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1464. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1465. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1466. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1467. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1468. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1469. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1470. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1471. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1472. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1473. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1474. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1475. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1476. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1477. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1478. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1479. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1480. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1481. { }
  1482. };
  1483. /* FIXME! */
  1484. /*
  1485. * ASUS pin configuration:
  1486. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1487. */
  1488. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1489. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1490. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1491. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1492. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1493. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1494. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1495. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1496. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1497. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1498. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1499. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1500. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1501. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1502. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1503. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1504. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1505. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1506. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1507. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1508. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1509. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1510. { }
  1511. };
  1512. /* Enable GPIO mask and set output */
  1513. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1514. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1515. /* Clevo m520g init */
  1516. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1517. /* headphone output */
  1518. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1519. /* line-out */
  1520. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1521. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1522. /* Line-in */
  1523. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1524. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1525. /* CD */
  1526. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1527. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1528. /* Mic1 (rear panel) */
  1529. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1530. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1531. /* Mic2 (front panel) */
  1532. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1533. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1534. /* headphone */
  1535. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1536. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1537. /* change to EAPD mode */
  1538. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1539. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1540. { }
  1541. };
  1542. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1543. /* change to EAPD mode */
  1544. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1545. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1546. /* Headphone output */
  1547. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1548. /* Front output*/
  1549. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1550. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1551. /* Line In pin widget for input */
  1552. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1553. /* CD pin widget for input */
  1554. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1555. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1556. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1557. /* change to EAPD mode */
  1558. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1559. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1560. { }
  1561. };
  1562. /*
  1563. * LG m1 express dual
  1564. *
  1565. * Pin assignment:
  1566. * Rear Line-In/Out (blue): 0x14
  1567. * Build-in Mic-In: 0x15
  1568. * Speaker-out: 0x17
  1569. * HP-Out (green): 0x1b
  1570. * Mic-In/Out (red): 0x19
  1571. * SPDIF-Out: 0x1e
  1572. */
  1573. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1574. static hda_nid_t alc880_lg_dac_nids[3] = {
  1575. 0x05, 0x02, 0x03
  1576. };
  1577. /* seems analog CD is not working */
  1578. static struct hda_input_mux alc880_lg_capture_source = {
  1579. .num_items = 3,
  1580. .items = {
  1581. { "Mic", 0x1 },
  1582. { "Line", 0x5 },
  1583. { "Internal Mic", 0x6 },
  1584. },
  1585. };
  1586. /* 2,4,6 channel modes */
  1587. static struct hda_verb alc880_lg_ch2_init[] = {
  1588. /* set line-in and mic-in to input */
  1589. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1590. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1591. { }
  1592. };
  1593. static struct hda_verb alc880_lg_ch4_init[] = {
  1594. /* set line-in to out and mic-in to input */
  1595. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1596. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1597. { }
  1598. };
  1599. static struct hda_verb alc880_lg_ch6_init[] = {
  1600. /* set line-in and mic-in to output */
  1601. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1602. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1603. { }
  1604. };
  1605. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1606. { 2, alc880_lg_ch2_init },
  1607. { 4, alc880_lg_ch4_init },
  1608. { 6, alc880_lg_ch6_init },
  1609. };
  1610. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1611. /* FIXME: it's not really "master" but front channels */
  1612. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1613. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1614. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1615. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1616. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1617. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1618. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1619. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1620. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1621. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1622. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1623. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1624. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1625. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1626. {
  1627. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1628. .name = "Channel Mode",
  1629. .info = alc_ch_mode_info,
  1630. .get = alc_ch_mode_get,
  1631. .put = alc_ch_mode_put,
  1632. },
  1633. { } /* end */
  1634. };
  1635. static struct hda_verb alc880_lg_init_verbs[] = {
  1636. /* set capture source to mic-in */
  1637. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1638. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1639. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1640. /* mute all amp mixer inputs */
  1641. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1642. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1643. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1644. /* line-in to input */
  1645. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1646. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1647. /* built-in mic */
  1648. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1649. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1650. /* speaker-out */
  1651. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1652. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1653. /* mic-in to input */
  1654. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1655. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1656. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1657. /* HP-out */
  1658. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1659. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1660. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1661. /* jack sense */
  1662. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1663. { }
  1664. };
  1665. /* toggle speaker-output according to the hp-jack state */
  1666. static void alc880_lg_automute(struct hda_codec *codec)
  1667. {
  1668. unsigned int present;
  1669. unsigned char bits;
  1670. present = snd_hda_codec_read(codec, 0x1b, 0,
  1671. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1672. bits = present ? 0x80 : 0;
  1673. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1674. 0x80, bits);
  1675. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1676. 0x80, bits);
  1677. }
  1678. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1679. {
  1680. /* Looks like the unsol event is incompatible with the standard
  1681. * definition. 4bit tag is placed at 28 bit!
  1682. */
  1683. if ((res >> 28) == 0x01)
  1684. alc880_lg_automute(codec);
  1685. }
  1686. /*
  1687. * LG LW20
  1688. *
  1689. * Pin assignment:
  1690. * Speaker-out: 0x14
  1691. * Mic-In: 0x18
  1692. * Built-in Mic-In: 0x19 (?)
  1693. * HP-Out: 0x1b
  1694. * SPDIF-Out: 0x1e
  1695. */
  1696. /* seems analog CD is not working */
  1697. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1698. .num_items = 2,
  1699. .items = {
  1700. { "Mic", 0x0 },
  1701. { "Internal Mic", 0x1 },
  1702. },
  1703. };
  1704. #define alc880_lg_lw_modes alc880_threestack_modes
  1705. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1706. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1707. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1708. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1709. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1710. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1711. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1712. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1713. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1714. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1715. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1716. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1717. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1718. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1719. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1720. {
  1721. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1722. .name = "Channel Mode",
  1723. .info = alc_ch_mode_info,
  1724. .get = alc_ch_mode_get,
  1725. .put = alc_ch_mode_put,
  1726. },
  1727. { } /* end */
  1728. };
  1729. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1730. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1731. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1732. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1733. /* set capture source to mic-in */
  1734. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1735. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1736. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1737. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1738. /* speaker-out */
  1739. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1740. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1741. /* HP-out */
  1742. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1743. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1744. /* mic-in to input */
  1745. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1746. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1747. /* built-in mic */
  1748. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1749. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1750. /* jack sense */
  1751. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1752. { }
  1753. };
  1754. /* toggle speaker-output according to the hp-jack state */
  1755. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1756. {
  1757. unsigned int present;
  1758. unsigned char bits;
  1759. present = snd_hda_codec_read(codec, 0x1b, 0,
  1760. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1761. bits = present ? 0x80 : 0;
  1762. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1763. 0x80, bits);
  1764. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1765. 0x80, bits);
  1766. }
  1767. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1768. {
  1769. /* Looks like the unsol event is incompatible with the standard
  1770. * definition. 4bit tag is placed at 28 bit!
  1771. */
  1772. if ((res >> 28) == 0x01)
  1773. alc880_lg_lw_automute(codec);
  1774. }
  1775. /*
  1776. * Common callbacks
  1777. */
  1778. static int alc_init(struct hda_codec *codec)
  1779. {
  1780. struct alc_spec *spec = codec->spec;
  1781. unsigned int i;
  1782. for (i = 0; i < spec->num_init_verbs; i++)
  1783. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1784. if (spec->init_hook)
  1785. spec->init_hook(codec);
  1786. return 0;
  1787. }
  1788. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1789. {
  1790. struct alc_spec *spec = codec->spec;
  1791. if (spec->unsol_event)
  1792. spec->unsol_event(codec, res);
  1793. }
  1794. #ifdef CONFIG_PM
  1795. /*
  1796. * resume
  1797. */
  1798. static int alc_resume(struct hda_codec *codec)
  1799. {
  1800. struct alc_spec *spec = codec->spec;
  1801. int i;
  1802. alc_init(codec);
  1803. for (i = 0; i < spec->num_mixers; i++)
  1804. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1805. if (spec->multiout.dig_out_nid)
  1806. snd_hda_resume_spdif_out(codec);
  1807. if (spec->dig_in_nid)
  1808. snd_hda_resume_spdif_in(codec);
  1809. return 0;
  1810. }
  1811. #endif
  1812. /*
  1813. * Analog playback callbacks
  1814. */
  1815. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1816. struct hda_codec *codec,
  1817. struct snd_pcm_substream *substream)
  1818. {
  1819. struct alc_spec *spec = codec->spec;
  1820. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1821. }
  1822. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1823. struct hda_codec *codec,
  1824. unsigned int stream_tag,
  1825. unsigned int format,
  1826. struct snd_pcm_substream *substream)
  1827. {
  1828. struct alc_spec *spec = codec->spec;
  1829. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1830. stream_tag, format, substream);
  1831. }
  1832. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1833. struct hda_codec *codec,
  1834. struct snd_pcm_substream *substream)
  1835. {
  1836. struct alc_spec *spec = codec->spec;
  1837. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1838. }
  1839. /*
  1840. * Digital out
  1841. */
  1842. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1843. struct hda_codec *codec,
  1844. struct snd_pcm_substream *substream)
  1845. {
  1846. struct alc_spec *spec = codec->spec;
  1847. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1848. }
  1849. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1850. struct hda_codec *codec,
  1851. unsigned int stream_tag,
  1852. unsigned int format,
  1853. struct snd_pcm_substream *substream)
  1854. {
  1855. struct alc_spec *spec = codec->spec;
  1856. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1857. stream_tag, format, substream);
  1858. }
  1859. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1860. struct hda_codec *codec,
  1861. struct snd_pcm_substream *substream)
  1862. {
  1863. struct alc_spec *spec = codec->spec;
  1864. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1865. }
  1866. /*
  1867. * Analog capture
  1868. */
  1869. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1870. struct hda_codec *codec,
  1871. unsigned int stream_tag,
  1872. unsigned int format,
  1873. struct snd_pcm_substream *substream)
  1874. {
  1875. struct alc_spec *spec = codec->spec;
  1876. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1877. stream_tag, 0, format);
  1878. return 0;
  1879. }
  1880. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1881. struct hda_codec *codec,
  1882. struct snd_pcm_substream *substream)
  1883. {
  1884. struct alc_spec *spec = codec->spec;
  1885. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1886. 0, 0, 0);
  1887. return 0;
  1888. }
  1889. /*
  1890. */
  1891. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1892. .substreams = 1,
  1893. .channels_min = 2,
  1894. .channels_max = 8,
  1895. /* NID is set in alc_build_pcms */
  1896. .ops = {
  1897. .open = alc880_playback_pcm_open,
  1898. .prepare = alc880_playback_pcm_prepare,
  1899. .cleanup = alc880_playback_pcm_cleanup
  1900. },
  1901. };
  1902. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1903. .substreams = 2,
  1904. .channels_min = 2,
  1905. .channels_max = 2,
  1906. /* NID is set in alc_build_pcms */
  1907. .ops = {
  1908. .prepare = alc880_capture_pcm_prepare,
  1909. .cleanup = alc880_capture_pcm_cleanup
  1910. },
  1911. };
  1912. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1913. .substreams = 1,
  1914. .channels_min = 2,
  1915. .channels_max = 2,
  1916. /* NID is set in alc_build_pcms */
  1917. .ops = {
  1918. .open = alc880_dig_playback_pcm_open,
  1919. .close = alc880_dig_playback_pcm_close,
  1920. .prepare = alc880_dig_playback_pcm_prepare
  1921. },
  1922. };
  1923. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1924. .substreams = 1,
  1925. .channels_min = 2,
  1926. .channels_max = 2,
  1927. /* NID is set in alc_build_pcms */
  1928. };
  1929. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1930. static struct hda_pcm_stream alc_pcm_null_playback = {
  1931. .substreams = 0,
  1932. .channels_min = 0,
  1933. .channels_max = 0,
  1934. };
  1935. static int alc_build_pcms(struct hda_codec *codec)
  1936. {
  1937. struct alc_spec *spec = codec->spec;
  1938. struct hda_pcm *info = spec->pcm_rec;
  1939. int i;
  1940. codec->num_pcms = 1;
  1941. codec->pcm_info = info;
  1942. info->name = spec->stream_name_analog;
  1943. if (spec->stream_analog_playback) {
  1944. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1945. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1946. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1947. }
  1948. if (spec->stream_analog_capture) {
  1949. snd_assert(spec->adc_nids, return -EINVAL);
  1950. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1951. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1952. }
  1953. if (spec->channel_mode) {
  1954. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1955. for (i = 0; i < spec->num_channel_mode; i++) {
  1956. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1957. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1958. }
  1959. }
  1960. }
  1961. /* SPDIF for stream index #1 */
  1962. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1963. codec->num_pcms = 2;
  1964. info = spec->pcm_rec + 1;
  1965. info->name = spec->stream_name_digital;
  1966. if (spec->multiout.dig_out_nid &&
  1967. spec->stream_digital_playback) {
  1968. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1969. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1970. }
  1971. if (spec->dig_in_nid &&
  1972. spec->stream_digital_capture) {
  1973. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1974. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1975. }
  1976. }
  1977. /* If the use of more than one ADC is requested for the current
  1978. * model, configure a second analog capture-only PCM.
  1979. */
  1980. /* Additional Analaog capture for index #2 */
  1981. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1982. spec->adc_nids) {
  1983. codec->num_pcms = 3;
  1984. info = spec->pcm_rec + 2;
  1985. info->name = spec->stream_name_analog;
  1986. /* No playback stream for second PCM */
  1987. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  1988. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  1989. if (spec->stream_analog_capture) {
  1990. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1991. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  1992. }
  1993. }
  1994. return 0;
  1995. }
  1996. static void alc_free(struct hda_codec *codec)
  1997. {
  1998. struct alc_spec *spec = codec->spec;
  1999. unsigned int i;
  2000. if (!spec)
  2001. return;
  2002. if (spec->kctl_alloc) {
  2003. for (i = 0; i < spec->num_kctl_used; i++)
  2004. kfree(spec->kctl_alloc[i].name);
  2005. kfree(spec->kctl_alloc);
  2006. }
  2007. kfree(spec);
  2008. }
  2009. /*
  2010. */
  2011. static struct hda_codec_ops alc_patch_ops = {
  2012. .build_controls = alc_build_controls,
  2013. .build_pcms = alc_build_pcms,
  2014. .init = alc_init,
  2015. .free = alc_free,
  2016. .unsol_event = alc_unsol_event,
  2017. #ifdef CONFIG_PM
  2018. .resume = alc_resume,
  2019. #endif
  2020. };
  2021. /*
  2022. * Test configuration for debugging
  2023. *
  2024. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2025. * enum controls.
  2026. */
  2027. #ifdef CONFIG_SND_DEBUG
  2028. static hda_nid_t alc880_test_dac_nids[4] = {
  2029. 0x02, 0x03, 0x04, 0x05
  2030. };
  2031. static struct hda_input_mux alc880_test_capture_source = {
  2032. .num_items = 7,
  2033. .items = {
  2034. { "In-1", 0x0 },
  2035. { "In-2", 0x1 },
  2036. { "In-3", 0x2 },
  2037. { "In-4", 0x3 },
  2038. { "CD", 0x4 },
  2039. { "Front", 0x5 },
  2040. { "Surround", 0x6 },
  2041. },
  2042. };
  2043. static struct hda_channel_mode alc880_test_modes[4] = {
  2044. { 2, NULL },
  2045. { 4, NULL },
  2046. { 6, NULL },
  2047. { 8, NULL },
  2048. };
  2049. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2050. struct snd_ctl_elem_info *uinfo)
  2051. {
  2052. static char *texts[] = {
  2053. "N/A", "Line Out", "HP Out",
  2054. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2055. };
  2056. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2057. uinfo->count = 1;
  2058. uinfo->value.enumerated.items = 8;
  2059. if (uinfo->value.enumerated.item >= 8)
  2060. uinfo->value.enumerated.item = 7;
  2061. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2062. return 0;
  2063. }
  2064. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2065. struct snd_ctl_elem_value *ucontrol)
  2066. {
  2067. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2068. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2069. unsigned int pin_ctl, item = 0;
  2070. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2071. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2072. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2073. if (pin_ctl & AC_PINCTL_HP_EN)
  2074. item = 2;
  2075. else
  2076. item = 1;
  2077. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2078. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2079. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2080. case AC_PINCTL_VREF_50: item = 4; break;
  2081. case AC_PINCTL_VREF_GRD: item = 5; break;
  2082. case AC_PINCTL_VREF_80: item = 6; break;
  2083. case AC_PINCTL_VREF_100: item = 7; break;
  2084. }
  2085. }
  2086. ucontrol->value.enumerated.item[0] = item;
  2087. return 0;
  2088. }
  2089. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2090. struct snd_ctl_elem_value *ucontrol)
  2091. {
  2092. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2093. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2094. static unsigned int ctls[] = {
  2095. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2096. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2097. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2098. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2099. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2100. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2101. };
  2102. unsigned int old_ctl, new_ctl;
  2103. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2104. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2105. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2106. if (old_ctl != new_ctl) {
  2107. snd_hda_codec_write(codec, nid, 0,
  2108. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2109. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2110. (ucontrol->value.enumerated.item[0] >= 3 ?
  2111. 0xb080 : 0xb000));
  2112. return 1;
  2113. }
  2114. return 0;
  2115. }
  2116. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2117. struct snd_ctl_elem_info *uinfo)
  2118. {
  2119. static char *texts[] = {
  2120. "Front", "Surround", "CLFE", "Side"
  2121. };
  2122. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2123. uinfo->count = 1;
  2124. uinfo->value.enumerated.items = 4;
  2125. if (uinfo->value.enumerated.item >= 4)
  2126. uinfo->value.enumerated.item = 3;
  2127. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2128. return 0;
  2129. }
  2130. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2131. struct snd_ctl_elem_value *ucontrol)
  2132. {
  2133. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2134. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2135. unsigned int sel;
  2136. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2137. ucontrol->value.enumerated.item[0] = sel & 3;
  2138. return 0;
  2139. }
  2140. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2141. struct snd_ctl_elem_value *ucontrol)
  2142. {
  2143. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2144. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2145. unsigned int sel;
  2146. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2147. if (ucontrol->value.enumerated.item[0] != sel) {
  2148. sel = ucontrol->value.enumerated.item[0] & 3;
  2149. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2150. return 1;
  2151. }
  2152. return 0;
  2153. }
  2154. #define PIN_CTL_TEST(xname,nid) { \
  2155. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2156. .name = xname, \
  2157. .info = alc_test_pin_ctl_info, \
  2158. .get = alc_test_pin_ctl_get, \
  2159. .put = alc_test_pin_ctl_put, \
  2160. .private_value = nid \
  2161. }
  2162. #define PIN_SRC_TEST(xname,nid) { \
  2163. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2164. .name = xname, \
  2165. .info = alc_test_pin_src_info, \
  2166. .get = alc_test_pin_src_get, \
  2167. .put = alc_test_pin_src_put, \
  2168. .private_value = nid \
  2169. }
  2170. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2171. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2172. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2173. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2174. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2175. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2176. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2177. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2178. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2179. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2180. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2181. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2182. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2183. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2184. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2185. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2186. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2187. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2188. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2189. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2190. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2191. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2192. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2193. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2194. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2195. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2196. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2197. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2198. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2199. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2200. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2201. {
  2202. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2203. .name = "Channel Mode",
  2204. .info = alc_ch_mode_info,
  2205. .get = alc_ch_mode_get,
  2206. .put = alc_ch_mode_put,
  2207. },
  2208. { } /* end */
  2209. };
  2210. static struct hda_verb alc880_test_init_verbs[] = {
  2211. /* Unmute inputs of 0x0c - 0x0f */
  2212. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2213. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2214. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2215. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2216. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2217. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2218. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2219. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2220. /* Vol output for 0x0c-0x0f */
  2221. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2222. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2223. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2224. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2225. /* Set output pins 0x14-0x17 */
  2226. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2227. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2228. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2229. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2230. /* Unmute output pins 0x14-0x17 */
  2231. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2232. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2233. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2234. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2235. /* Set input pins 0x18-0x1c */
  2236. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2237. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2238. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2239. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2240. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2241. /* Mute input pins 0x18-0x1b */
  2242. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2243. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2244. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2245. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2246. /* ADC set up */
  2247. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2248. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2249. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2250. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2251. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2252. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2253. /* Analog input/passthru */
  2254. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2255. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2256. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2257. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2258. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2259. { }
  2260. };
  2261. #endif
  2262. /*
  2263. */
  2264. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2265. [ALC880_3ST] = "3stack",
  2266. [ALC880_TCL_S700] = "tcl",
  2267. [ALC880_3ST_DIG] = "3stack-digout",
  2268. [ALC880_CLEVO] = "clevo",
  2269. [ALC880_5ST] = "5stack",
  2270. [ALC880_5ST_DIG] = "5stack-digout",
  2271. [ALC880_W810] = "w810",
  2272. [ALC880_Z71V] = "z71v",
  2273. [ALC880_6ST] = "6stack",
  2274. [ALC880_6ST_DIG] = "6stack-digout",
  2275. [ALC880_ASUS] = "asus",
  2276. [ALC880_ASUS_W1V] = "asus-w1v",
  2277. [ALC880_ASUS_DIG] = "asus-dig",
  2278. [ALC880_ASUS_DIG2] = "asus-dig2",
  2279. [ALC880_UNIWILL_DIG] = "uniwill",
  2280. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2281. [ALC880_FUJITSU] = "fujitsu",
  2282. [ALC880_F1734] = "F1734",
  2283. [ALC880_LG] = "lg",
  2284. [ALC880_LG_LW] = "lg-lw",
  2285. #ifdef CONFIG_SND_DEBUG
  2286. [ALC880_TEST] = "test",
  2287. #endif
  2288. [ALC880_AUTO] = "auto",
  2289. };
  2290. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2291. /* Broken BIOS configuration */
  2292. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2293. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2294. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2295. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2296. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2297. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2298. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2299. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2300. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2301. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2302. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2303. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2304. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2305. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2306. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2307. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2308. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2309. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2310. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2311. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2312. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2313. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2314. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2315. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2316. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2317. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2318. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2319. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2320. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2321. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2322. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2323. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2324. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2325. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2326. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2327. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2328. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2329. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2330. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2331. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2332. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2333. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2334. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2335. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2336. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2337. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2338. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2339. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2340. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2341. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2342. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2343. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2344. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2345. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2346. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2347. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2348. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2349. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2350. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2351. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2352. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2353. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2354. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2355. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2356. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2357. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2358. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2359. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2360. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2361. {}
  2362. };
  2363. /*
  2364. * ALC880 codec presets
  2365. */
  2366. static struct alc_config_preset alc880_presets[] = {
  2367. [ALC880_3ST] = {
  2368. .mixers = { alc880_three_stack_mixer },
  2369. .init_verbs = { alc880_volume_init_verbs,
  2370. alc880_pin_3stack_init_verbs },
  2371. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2372. .dac_nids = alc880_dac_nids,
  2373. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2374. .channel_mode = alc880_threestack_modes,
  2375. .need_dac_fix = 1,
  2376. .input_mux = &alc880_capture_source,
  2377. },
  2378. [ALC880_3ST_DIG] = {
  2379. .mixers = { alc880_three_stack_mixer },
  2380. .init_verbs = { alc880_volume_init_verbs,
  2381. alc880_pin_3stack_init_verbs },
  2382. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2383. .dac_nids = alc880_dac_nids,
  2384. .dig_out_nid = ALC880_DIGOUT_NID,
  2385. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2386. .channel_mode = alc880_threestack_modes,
  2387. .need_dac_fix = 1,
  2388. .input_mux = &alc880_capture_source,
  2389. },
  2390. [ALC880_TCL_S700] = {
  2391. .mixers = { alc880_tcl_s700_mixer },
  2392. .init_verbs = { alc880_volume_init_verbs,
  2393. alc880_pin_tcl_S700_init_verbs,
  2394. alc880_gpio2_init_verbs },
  2395. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2396. .dac_nids = alc880_dac_nids,
  2397. .hp_nid = 0x03,
  2398. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2399. .channel_mode = alc880_2_jack_modes,
  2400. .input_mux = &alc880_capture_source,
  2401. },
  2402. [ALC880_5ST] = {
  2403. .mixers = { alc880_three_stack_mixer,
  2404. alc880_five_stack_mixer},
  2405. .init_verbs = { alc880_volume_init_verbs,
  2406. alc880_pin_5stack_init_verbs },
  2407. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2408. .dac_nids = alc880_dac_nids,
  2409. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2410. .channel_mode = alc880_fivestack_modes,
  2411. .input_mux = &alc880_capture_source,
  2412. },
  2413. [ALC880_5ST_DIG] = {
  2414. .mixers = { alc880_three_stack_mixer,
  2415. alc880_five_stack_mixer },
  2416. .init_verbs = { alc880_volume_init_verbs,
  2417. alc880_pin_5stack_init_verbs },
  2418. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2419. .dac_nids = alc880_dac_nids,
  2420. .dig_out_nid = ALC880_DIGOUT_NID,
  2421. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2422. .channel_mode = alc880_fivestack_modes,
  2423. .input_mux = &alc880_capture_source,
  2424. },
  2425. [ALC880_6ST] = {
  2426. .mixers = { alc880_six_stack_mixer },
  2427. .init_verbs = { alc880_volume_init_verbs,
  2428. alc880_pin_6stack_init_verbs },
  2429. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2430. .dac_nids = alc880_6st_dac_nids,
  2431. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2432. .channel_mode = alc880_sixstack_modes,
  2433. .input_mux = &alc880_6stack_capture_source,
  2434. },
  2435. [ALC880_6ST_DIG] = {
  2436. .mixers = { alc880_six_stack_mixer },
  2437. .init_verbs = { alc880_volume_init_verbs,
  2438. alc880_pin_6stack_init_verbs },
  2439. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2440. .dac_nids = alc880_6st_dac_nids,
  2441. .dig_out_nid = ALC880_DIGOUT_NID,
  2442. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2443. .channel_mode = alc880_sixstack_modes,
  2444. .input_mux = &alc880_6stack_capture_source,
  2445. },
  2446. [ALC880_W810] = {
  2447. .mixers = { alc880_w810_base_mixer },
  2448. .init_verbs = { alc880_volume_init_verbs,
  2449. alc880_pin_w810_init_verbs,
  2450. alc880_gpio2_init_verbs },
  2451. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2452. .dac_nids = alc880_w810_dac_nids,
  2453. .dig_out_nid = ALC880_DIGOUT_NID,
  2454. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2455. .channel_mode = alc880_w810_modes,
  2456. .input_mux = &alc880_capture_source,
  2457. },
  2458. [ALC880_Z71V] = {
  2459. .mixers = { alc880_z71v_mixer },
  2460. .init_verbs = { alc880_volume_init_verbs,
  2461. alc880_pin_z71v_init_verbs },
  2462. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2463. .dac_nids = alc880_z71v_dac_nids,
  2464. .dig_out_nid = ALC880_DIGOUT_NID,
  2465. .hp_nid = 0x03,
  2466. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2467. .channel_mode = alc880_2_jack_modes,
  2468. .input_mux = &alc880_capture_source,
  2469. },
  2470. [ALC880_F1734] = {
  2471. .mixers = { alc880_f1734_mixer },
  2472. .init_verbs = { alc880_volume_init_verbs,
  2473. alc880_pin_f1734_init_verbs },
  2474. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2475. .dac_nids = alc880_f1734_dac_nids,
  2476. .hp_nid = 0x02,
  2477. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2478. .channel_mode = alc880_2_jack_modes,
  2479. .input_mux = &alc880_capture_source,
  2480. },
  2481. [ALC880_ASUS] = {
  2482. .mixers = { alc880_asus_mixer },
  2483. .init_verbs = { alc880_volume_init_verbs,
  2484. alc880_pin_asus_init_verbs,
  2485. alc880_gpio1_init_verbs },
  2486. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2487. .dac_nids = alc880_asus_dac_nids,
  2488. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2489. .channel_mode = alc880_asus_modes,
  2490. .need_dac_fix = 1,
  2491. .input_mux = &alc880_capture_source,
  2492. },
  2493. [ALC880_ASUS_DIG] = {
  2494. .mixers = { alc880_asus_mixer },
  2495. .init_verbs = { alc880_volume_init_verbs,
  2496. alc880_pin_asus_init_verbs,
  2497. alc880_gpio1_init_verbs },
  2498. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2499. .dac_nids = alc880_asus_dac_nids,
  2500. .dig_out_nid = ALC880_DIGOUT_NID,
  2501. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2502. .channel_mode = alc880_asus_modes,
  2503. .need_dac_fix = 1,
  2504. .input_mux = &alc880_capture_source,
  2505. },
  2506. [ALC880_ASUS_DIG2] = {
  2507. .mixers = { alc880_asus_mixer },
  2508. .init_verbs = { alc880_volume_init_verbs,
  2509. alc880_pin_asus_init_verbs,
  2510. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2511. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2512. .dac_nids = alc880_asus_dac_nids,
  2513. .dig_out_nid = ALC880_DIGOUT_NID,
  2514. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2515. .channel_mode = alc880_asus_modes,
  2516. .need_dac_fix = 1,
  2517. .input_mux = &alc880_capture_source,
  2518. },
  2519. [ALC880_ASUS_W1V] = {
  2520. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2521. .init_verbs = { alc880_volume_init_verbs,
  2522. alc880_pin_asus_init_verbs,
  2523. alc880_gpio1_init_verbs },
  2524. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2525. .dac_nids = alc880_asus_dac_nids,
  2526. .dig_out_nid = ALC880_DIGOUT_NID,
  2527. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2528. .channel_mode = alc880_asus_modes,
  2529. .need_dac_fix = 1,
  2530. .input_mux = &alc880_capture_source,
  2531. },
  2532. [ALC880_UNIWILL_DIG] = {
  2533. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2534. .init_verbs = { alc880_volume_init_verbs,
  2535. alc880_pin_asus_init_verbs },
  2536. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2537. .dac_nids = alc880_asus_dac_nids,
  2538. .dig_out_nid = ALC880_DIGOUT_NID,
  2539. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2540. .channel_mode = alc880_asus_modes,
  2541. .need_dac_fix = 1,
  2542. .input_mux = &alc880_capture_source,
  2543. },
  2544. [ALC880_UNIWILL] = {
  2545. .mixers = { alc880_uniwill_mixer },
  2546. .init_verbs = { alc880_volume_init_verbs,
  2547. alc880_uniwill_init_verbs },
  2548. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2549. .dac_nids = alc880_asus_dac_nids,
  2550. .dig_out_nid = ALC880_DIGOUT_NID,
  2551. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2552. .channel_mode = alc880_threestack_modes,
  2553. .need_dac_fix = 1,
  2554. .input_mux = &alc880_capture_source,
  2555. .unsol_event = alc880_uniwill_unsol_event,
  2556. .init_hook = alc880_uniwill_automute,
  2557. },
  2558. [ALC880_UNIWILL_P53] = {
  2559. .mixers = { alc880_uniwill_p53_mixer },
  2560. .init_verbs = { alc880_volume_init_verbs,
  2561. alc880_uniwill_p53_init_verbs },
  2562. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2563. .dac_nids = alc880_asus_dac_nids,
  2564. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2565. .channel_mode = alc880_threestack_modes,
  2566. .input_mux = &alc880_capture_source,
  2567. .unsol_event = alc880_uniwill_p53_unsol_event,
  2568. .init_hook = alc880_uniwill_p53_hp_automute,
  2569. },
  2570. [ALC880_FUJITSU] = {
  2571. .mixers = { alc880_fujitsu_mixer,
  2572. alc880_pcbeep_mixer, },
  2573. .init_verbs = { alc880_volume_init_verbs,
  2574. alc880_uniwill_p53_init_verbs,
  2575. alc880_beep_init_verbs },
  2576. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2577. .dac_nids = alc880_dac_nids,
  2578. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2579. .channel_mode = alc880_2_jack_modes,
  2580. .input_mux = &alc880_capture_source,
  2581. .unsol_event = alc880_uniwill_p53_unsol_event,
  2582. .init_hook = alc880_uniwill_p53_hp_automute,
  2583. },
  2584. [ALC880_CLEVO] = {
  2585. .mixers = { alc880_three_stack_mixer },
  2586. .init_verbs = { alc880_volume_init_verbs,
  2587. alc880_pin_clevo_init_verbs },
  2588. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2589. .dac_nids = alc880_dac_nids,
  2590. .hp_nid = 0x03,
  2591. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2592. .channel_mode = alc880_threestack_modes,
  2593. .need_dac_fix = 1,
  2594. .input_mux = &alc880_capture_source,
  2595. },
  2596. [ALC880_LG] = {
  2597. .mixers = { alc880_lg_mixer },
  2598. .init_verbs = { alc880_volume_init_verbs,
  2599. alc880_lg_init_verbs },
  2600. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2601. .dac_nids = alc880_lg_dac_nids,
  2602. .dig_out_nid = ALC880_DIGOUT_NID,
  2603. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2604. .channel_mode = alc880_lg_ch_modes,
  2605. .need_dac_fix = 1,
  2606. .input_mux = &alc880_lg_capture_source,
  2607. .unsol_event = alc880_lg_unsol_event,
  2608. .init_hook = alc880_lg_automute,
  2609. },
  2610. [ALC880_LG_LW] = {
  2611. .mixers = { alc880_lg_lw_mixer },
  2612. .init_verbs = { alc880_volume_init_verbs,
  2613. alc880_lg_lw_init_verbs },
  2614. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2615. .dac_nids = alc880_dac_nids,
  2616. .dig_out_nid = ALC880_DIGOUT_NID,
  2617. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2618. .channel_mode = alc880_lg_lw_modes,
  2619. .input_mux = &alc880_lg_lw_capture_source,
  2620. .unsol_event = alc880_lg_lw_unsol_event,
  2621. .init_hook = alc880_lg_lw_automute,
  2622. },
  2623. #ifdef CONFIG_SND_DEBUG
  2624. [ALC880_TEST] = {
  2625. .mixers = { alc880_test_mixer },
  2626. .init_verbs = { alc880_test_init_verbs },
  2627. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2628. .dac_nids = alc880_test_dac_nids,
  2629. .dig_out_nid = ALC880_DIGOUT_NID,
  2630. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2631. .channel_mode = alc880_test_modes,
  2632. .input_mux = &alc880_test_capture_source,
  2633. },
  2634. #endif
  2635. };
  2636. /*
  2637. * Automatic parse of I/O pins from the BIOS configuration
  2638. */
  2639. #define NUM_CONTROL_ALLOC 32
  2640. #define NUM_VERB_ALLOC 32
  2641. enum {
  2642. ALC_CTL_WIDGET_VOL,
  2643. ALC_CTL_WIDGET_MUTE,
  2644. ALC_CTL_BIND_MUTE,
  2645. };
  2646. static struct snd_kcontrol_new alc880_control_templates[] = {
  2647. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2648. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2649. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2650. };
  2651. /* add dynamic controls */
  2652. static int add_control(struct alc_spec *spec, int type, const char *name,
  2653. unsigned long val)
  2654. {
  2655. struct snd_kcontrol_new *knew;
  2656. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2657. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2658. /* array + terminator */
  2659. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2660. if (!knew)
  2661. return -ENOMEM;
  2662. if (spec->kctl_alloc) {
  2663. memcpy(knew, spec->kctl_alloc,
  2664. sizeof(*knew) * spec->num_kctl_alloc);
  2665. kfree(spec->kctl_alloc);
  2666. }
  2667. spec->kctl_alloc = knew;
  2668. spec->num_kctl_alloc = num;
  2669. }
  2670. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2671. *knew = alc880_control_templates[type];
  2672. knew->name = kstrdup(name, GFP_KERNEL);
  2673. if (!knew->name)
  2674. return -ENOMEM;
  2675. knew->private_value = val;
  2676. spec->num_kctl_used++;
  2677. return 0;
  2678. }
  2679. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2680. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2681. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2682. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2683. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2684. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2685. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2686. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2687. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2688. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2689. #define ALC880_PIN_CD_NID 0x1c
  2690. /* fill in the dac_nids table from the parsed pin configuration */
  2691. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2692. const struct auto_pin_cfg *cfg)
  2693. {
  2694. hda_nid_t nid;
  2695. int assigned[4];
  2696. int i, j;
  2697. memset(assigned, 0, sizeof(assigned));
  2698. spec->multiout.dac_nids = spec->private_dac_nids;
  2699. /* check the pins hardwired to audio widget */
  2700. for (i = 0; i < cfg->line_outs; i++) {
  2701. nid = cfg->line_out_pins[i];
  2702. if (alc880_is_fixed_pin(nid)) {
  2703. int idx = alc880_fixed_pin_idx(nid);
  2704. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2705. assigned[idx] = 1;
  2706. }
  2707. }
  2708. /* left pins can be connect to any audio widget */
  2709. for (i = 0; i < cfg->line_outs; i++) {
  2710. nid = cfg->line_out_pins[i];
  2711. if (alc880_is_fixed_pin(nid))
  2712. continue;
  2713. /* search for an empty channel */
  2714. for (j = 0; j < cfg->line_outs; j++) {
  2715. if (!assigned[j]) {
  2716. spec->multiout.dac_nids[i] =
  2717. alc880_idx_to_dac(j);
  2718. assigned[j] = 1;
  2719. break;
  2720. }
  2721. }
  2722. }
  2723. spec->multiout.num_dacs = cfg->line_outs;
  2724. return 0;
  2725. }
  2726. /* add playback controls from the parsed DAC table */
  2727. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2728. const struct auto_pin_cfg *cfg)
  2729. {
  2730. char name[32];
  2731. static const char *chname[4] = {
  2732. "Front", "Surround", NULL /*CLFE*/, "Side"
  2733. };
  2734. hda_nid_t nid;
  2735. int i, err;
  2736. for (i = 0; i < cfg->line_outs; i++) {
  2737. if (!spec->multiout.dac_nids[i])
  2738. continue;
  2739. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2740. if (i == 2) {
  2741. /* Center/LFE */
  2742. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2743. "Center Playback Volume",
  2744. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2745. HDA_OUTPUT));
  2746. if (err < 0)
  2747. return err;
  2748. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2749. "LFE Playback Volume",
  2750. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2751. HDA_OUTPUT));
  2752. if (err < 0)
  2753. return err;
  2754. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2755. "Center Playback Switch",
  2756. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2757. HDA_INPUT));
  2758. if (err < 0)
  2759. return err;
  2760. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2761. "LFE Playback Switch",
  2762. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2763. HDA_INPUT));
  2764. if (err < 0)
  2765. return err;
  2766. } else {
  2767. sprintf(name, "%s Playback Volume", chname[i]);
  2768. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2769. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2770. HDA_OUTPUT));
  2771. if (err < 0)
  2772. return err;
  2773. sprintf(name, "%s Playback Switch", chname[i]);
  2774. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2775. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2776. HDA_INPUT));
  2777. if (err < 0)
  2778. return err;
  2779. }
  2780. }
  2781. return 0;
  2782. }
  2783. /* add playback controls for speaker and HP outputs */
  2784. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2785. const char *pfx)
  2786. {
  2787. hda_nid_t nid;
  2788. int err;
  2789. char name[32];
  2790. if (!pin)
  2791. return 0;
  2792. if (alc880_is_fixed_pin(pin)) {
  2793. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2794. /* specify the DAC as the extra output */
  2795. if (!spec->multiout.hp_nid)
  2796. spec->multiout.hp_nid = nid;
  2797. else
  2798. spec->multiout.extra_out_nid[0] = nid;
  2799. /* control HP volume/switch on the output mixer amp */
  2800. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2801. sprintf(name, "%s Playback Volume", pfx);
  2802. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2803. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2804. if (err < 0)
  2805. return err;
  2806. sprintf(name, "%s Playback Switch", pfx);
  2807. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2808. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2809. if (err < 0)
  2810. return err;
  2811. } else if (alc880_is_multi_pin(pin)) {
  2812. /* set manual connection */
  2813. /* we have only a switch on HP-out PIN */
  2814. sprintf(name, "%s Playback Switch", pfx);
  2815. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2816. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2817. if (err < 0)
  2818. return err;
  2819. }
  2820. return 0;
  2821. }
  2822. /* create input playback/capture controls for the given pin */
  2823. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2824. const char *ctlname,
  2825. int idx, hda_nid_t mix_nid)
  2826. {
  2827. char name[32];
  2828. int err;
  2829. sprintf(name, "%s Playback Volume", ctlname);
  2830. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2831. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2832. if (err < 0)
  2833. return err;
  2834. sprintf(name, "%s Playback Switch", ctlname);
  2835. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2836. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2837. if (err < 0)
  2838. return err;
  2839. return 0;
  2840. }
  2841. /* create playback/capture controls for input pins */
  2842. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2843. const struct auto_pin_cfg *cfg)
  2844. {
  2845. struct hda_input_mux *imux = &spec->private_imux;
  2846. int i, err, idx;
  2847. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2848. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2849. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2850. err = new_analog_input(spec, cfg->input_pins[i],
  2851. auto_pin_cfg_labels[i],
  2852. idx, 0x0b);
  2853. if (err < 0)
  2854. return err;
  2855. imux->items[imux->num_items].label =
  2856. auto_pin_cfg_labels[i];
  2857. imux->items[imux->num_items].index =
  2858. alc880_input_pin_idx(cfg->input_pins[i]);
  2859. imux->num_items++;
  2860. }
  2861. }
  2862. return 0;
  2863. }
  2864. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2865. hda_nid_t nid, int pin_type,
  2866. int dac_idx)
  2867. {
  2868. /* set as output */
  2869. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2870. pin_type);
  2871. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2872. AMP_OUT_UNMUTE);
  2873. /* need the manual connection? */
  2874. if (alc880_is_multi_pin(nid)) {
  2875. struct alc_spec *spec = codec->spec;
  2876. int idx = alc880_multi_pin_idx(nid);
  2877. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2878. AC_VERB_SET_CONNECT_SEL,
  2879. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2880. }
  2881. }
  2882. static int get_pin_type(int line_out_type)
  2883. {
  2884. if (line_out_type == AUTO_PIN_HP_OUT)
  2885. return PIN_HP;
  2886. else
  2887. return PIN_OUT;
  2888. }
  2889. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2890. {
  2891. struct alc_spec *spec = codec->spec;
  2892. int i;
  2893. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2894. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2895. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2896. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2897. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2898. }
  2899. }
  2900. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2901. {
  2902. struct alc_spec *spec = codec->spec;
  2903. hda_nid_t pin;
  2904. pin = spec->autocfg.speaker_pins[0];
  2905. if (pin) /* connect to front */
  2906. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2907. pin = spec->autocfg.hp_pins[0];
  2908. if (pin) /* connect to front */
  2909. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2910. }
  2911. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2912. {
  2913. struct alc_spec *spec = codec->spec;
  2914. int i;
  2915. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2916. hda_nid_t nid = spec->autocfg.input_pins[i];
  2917. if (alc880_is_input_pin(nid)) {
  2918. snd_hda_codec_write(codec, nid, 0,
  2919. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2920. i <= AUTO_PIN_FRONT_MIC ?
  2921. PIN_VREF80 : PIN_IN);
  2922. if (nid != ALC880_PIN_CD_NID)
  2923. snd_hda_codec_write(codec, nid, 0,
  2924. AC_VERB_SET_AMP_GAIN_MUTE,
  2925. AMP_OUT_MUTE);
  2926. }
  2927. }
  2928. }
  2929. /* parse the BIOS configuration and set up the alc_spec */
  2930. /* return 1 if successful, 0 if the proper config is not found,
  2931. * or a negative error code
  2932. */
  2933. static int alc880_parse_auto_config(struct hda_codec *codec)
  2934. {
  2935. struct alc_spec *spec = codec->spec;
  2936. int err;
  2937. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2938. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2939. alc880_ignore);
  2940. if (err < 0)
  2941. return err;
  2942. if (!spec->autocfg.line_outs)
  2943. return 0; /* can't find valid BIOS pin config */
  2944. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2945. if (err < 0)
  2946. return err;
  2947. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2948. if (err < 0)
  2949. return err;
  2950. err = alc880_auto_create_extra_out(spec,
  2951. spec->autocfg.speaker_pins[0],
  2952. "Speaker");
  2953. if (err < 0)
  2954. return err;
  2955. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2956. "Headphone");
  2957. if (err < 0)
  2958. return err;
  2959. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2960. if (err < 0)
  2961. return err;
  2962. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2963. if (spec->autocfg.dig_out_pin)
  2964. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2965. if (spec->autocfg.dig_in_pin)
  2966. spec->dig_in_nid = ALC880_DIGIN_NID;
  2967. if (spec->kctl_alloc)
  2968. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2969. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2970. spec->num_mux_defs = 1;
  2971. spec->input_mux = &spec->private_imux;
  2972. return 1;
  2973. }
  2974. /* additional initialization for auto-configuration model */
  2975. static void alc880_auto_init(struct hda_codec *codec)
  2976. {
  2977. alc880_auto_init_multi_out(codec);
  2978. alc880_auto_init_extra_out(codec);
  2979. alc880_auto_init_analog_input(codec);
  2980. }
  2981. /*
  2982. * OK, here we have finally the patch for ALC880
  2983. */
  2984. static int patch_alc880(struct hda_codec *codec)
  2985. {
  2986. struct alc_spec *spec;
  2987. int board_config;
  2988. int err;
  2989. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  2990. if (spec == NULL)
  2991. return -ENOMEM;
  2992. codec->spec = spec;
  2993. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  2994. alc880_models,
  2995. alc880_cfg_tbl);
  2996. if (board_config < 0) {
  2997. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  2998. "trying auto-probe from BIOS...\n");
  2999. board_config = ALC880_AUTO;
  3000. }
  3001. if (board_config == ALC880_AUTO) {
  3002. /* automatic parse from the BIOS config */
  3003. err = alc880_parse_auto_config(codec);
  3004. if (err < 0) {
  3005. alc_free(codec);
  3006. return err;
  3007. } else if (!err) {
  3008. printk(KERN_INFO
  3009. "hda_codec: Cannot set up configuration "
  3010. "from BIOS. Using 3-stack mode...\n");
  3011. board_config = ALC880_3ST;
  3012. }
  3013. }
  3014. if (board_config != ALC880_AUTO)
  3015. setup_preset(spec, &alc880_presets[board_config]);
  3016. spec->stream_name_analog = "ALC880 Analog";
  3017. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3018. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3019. spec->stream_name_digital = "ALC880 Digital";
  3020. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3021. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3022. if (!spec->adc_nids && spec->input_mux) {
  3023. /* check whether NID 0x07 is valid */
  3024. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3025. /* get type */
  3026. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3027. if (wcap != AC_WID_AUD_IN) {
  3028. spec->adc_nids = alc880_adc_nids_alt;
  3029. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3030. spec->mixers[spec->num_mixers] =
  3031. alc880_capture_alt_mixer;
  3032. spec->num_mixers++;
  3033. } else {
  3034. spec->adc_nids = alc880_adc_nids;
  3035. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3036. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3037. spec->num_mixers++;
  3038. }
  3039. }
  3040. codec->patch_ops = alc_patch_ops;
  3041. if (board_config == ALC880_AUTO)
  3042. spec->init_hook = alc880_auto_init;
  3043. return 0;
  3044. }
  3045. /*
  3046. * ALC260 support
  3047. */
  3048. static hda_nid_t alc260_dac_nids[1] = {
  3049. /* front */
  3050. 0x02,
  3051. };
  3052. static hda_nid_t alc260_adc_nids[1] = {
  3053. /* ADC0 */
  3054. 0x04,
  3055. };
  3056. static hda_nid_t alc260_adc_nids_alt[1] = {
  3057. /* ADC1 */
  3058. 0x05,
  3059. };
  3060. static hda_nid_t alc260_hp_adc_nids[2] = {
  3061. /* ADC1, 0 */
  3062. 0x05, 0x04
  3063. };
  3064. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3065. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3066. */
  3067. static hda_nid_t alc260_dual_adc_nids[2] = {
  3068. /* ADC0, ADC1 */
  3069. 0x04, 0x05
  3070. };
  3071. #define ALC260_DIGOUT_NID 0x03
  3072. #define ALC260_DIGIN_NID 0x06
  3073. static struct hda_input_mux alc260_capture_source = {
  3074. .num_items = 4,
  3075. .items = {
  3076. { "Mic", 0x0 },
  3077. { "Front Mic", 0x1 },
  3078. { "Line", 0x2 },
  3079. { "CD", 0x4 },
  3080. },
  3081. };
  3082. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3083. * headphone jack and the internal CD lines since these are the only pins at
  3084. * which audio can appear. For flexibility, also allow the option of
  3085. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3086. * connection to the mixer output).
  3087. */
  3088. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3089. {
  3090. .num_items = 3,
  3091. .items = {
  3092. { "Mic/Line", 0x0 },
  3093. { "CD", 0x4 },
  3094. { "Headphone", 0x2 },
  3095. },
  3096. },
  3097. {
  3098. .num_items = 4,
  3099. .items = {
  3100. { "Mic/Line", 0x0 },
  3101. { "CD", 0x4 },
  3102. { "Headphone", 0x2 },
  3103. { "Mixer", 0x5 },
  3104. },
  3105. },
  3106. };
  3107. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3108. * the Fujitsu S702x, but jacks are marked differently.
  3109. */
  3110. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3111. {
  3112. .num_items = 4,
  3113. .items = {
  3114. { "Mic", 0x0 },
  3115. { "Line", 0x2 },
  3116. { "CD", 0x4 },
  3117. { "Headphone", 0x5 },
  3118. },
  3119. },
  3120. {
  3121. .num_items = 5,
  3122. .items = {
  3123. { "Mic", 0x0 },
  3124. { "Line", 0x2 },
  3125. { "CD", 0x4 },
  3126. { "Headphone", 0x6 },
  3127. { "Mixer", 0x5 },
  3128. },
  3129. },
  3130. };
  3131. /*
  3132. * This is just place-holder, so there's something for alc_build_pcms to look
  3133. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3134. * element which allows changing the channel mode, so the verb list is
  3135. * never used.
  3136. */
  3137. static struct hda_channel_mode alc260_modes[1] = {
  3138. { 2, NULL },
  3139. };
  3140. /* Mixer combinations
  3141. *
  3142. * basic: base_output + input + pc_beep + capture
  3143. * HP: base_output + input + capture_alt
  3144. * HP_3013: hp_3013 + input + capture
  3145. * fujitsu: fujitsu + capture
  3146. * acer: acer + capture
  3147. */
  3148. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3149. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3150. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3151. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3152. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3153. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3154. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3155. { } /* end */
  3156. };
  3157. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3158. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3159. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3160. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3161. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3162. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3163. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3164. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3165. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3166. { } /* end */
  3167. };
  3168. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3169. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3170. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3171. { } /* end */
  3172. };
  3173. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3174. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3175. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3176. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3177. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3178. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3179. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3180. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3181. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3182. { } /* end */
  3183. };
  3184. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3185. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3186. */
  3187. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3188. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3189. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3190. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3191. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3192. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3193. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3194. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3195. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3196. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3197. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3198. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3199. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3200. { } /* end */
  3201. };
  3202. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3203. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3204. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3205. * datasheet doesn't mention this restriction. At this stage it's not clear
  3206. * whether this behaviour is intentional or is a hardware bug in chip
  3207. * revisions available in early 2006. Therefore for now allow the
  3208. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3209. * that the lack of mic bias for this NID is intentional we could change the
  3210. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3211. *
  3212. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3213. * don't appear to make the mic bias available from the "line" jack, even
  3214. * though the NID used for this jack (0x14) can supply it. The theory is
  3215. * that perhaps Acer have included blocking capacitors between the ALC260
  3216. * and the output jack. If this turns out to be the case for all such
  3217. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3218. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3219. *
  3220. * The C20x Tablet series have a mono internal speaker which is controlled
  3221. * via the chip's Mono sum widget and pin complex, so include the necessary
  3222. * controls for such models. On models without a "mono speaker" the control
  3223. * won't do anything.
  3224. */
  3225. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3226. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3227. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3228. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3229. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3230. HDA_OUTPUT),
  3231. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3232. HDA_INPUT),
  3233. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3234. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3235. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3236. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3237. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3238. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3239. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3240. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3241. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3242. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3243. { } /* end */
  3244. };
  3245. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3246. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3247. */
  3248. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3249. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3250. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3251. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3252. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3253. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3254. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3255. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3256. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3257. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3258. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3259. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3260. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3261. { } /* end */
  3262. };
  3263. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3264. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3265. */
  3266. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3267. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3268. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3269. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3270. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3271. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3272. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3273. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3274. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3275. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3276. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3277. { } /* end */
  3278. };
  3279. /* capture mixer elements */
  3280. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3281. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3282. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3283. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3284. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3285. {
  3286. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3287. /* The multiple "Capture Source" controls confuse alsamixer
  3288. * So call somewhat different..
  3289. * FIXME: the controls appear in the "playback" view!
  3290. */
  3291. /* .name = "Capture Source", */
  3292. .name = "Input Source",
  3293. .count = 2,
  3294. .info = alc_mux_enum_info,
  3295. .get = alc_mux_enum_get,
  3296. .put = alc_mux_enum_put,
  3297. },
  3298. { } /* end */
  3299. };
  3300. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3301. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3302. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3303. {
  3304. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3305. /* The multiple "Capture Source" controls confuse alsamixer
  3306. * So call somewhat different..
  3307. * FIXME: the controls appear in the "playback" view!
  3308. */
  3309. /* .name = "Capture Source", */
  3310. .name = "Input Source",
  3311. .count = 1,
  3312. .info = alc_mux_enum_info,
  3313. .get = alc_mux_enum_get,
  3314. .put = alc_mux_enum_put,
  3315. },
  3316. { } /* end */
  3317. };
  3318. /*
  3319. * initialization verbs
  3320. */
  3321. static struct hda_verb alc260_init_verbs[] = {
  3322. /* Line In pin widget for input */
  3323. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3324. /* CD pin widget for input */
  3325. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3326. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3327. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3328. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3329. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3330. /* LINE-2 is used for line-out in rear */
  3331. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3332. /* select line-out */
  3333. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3334. /* LINE-OUT pin */
  3335. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3336. /* enable HP */
  3337. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3338. /* enable Mono */
  3339. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3340. /* mute capture amp left and right */
  3341. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3342. /* set connection select to line in (default select for this ADC) */
  3343. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3344. /* mute capture amp left and right */
  3345. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3346. /* set connection select to line in (default select for this ADC) */
  3347. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3348. /* set vol=0 Line-Out mixer amp left and right */
  3349. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3350. /* unmute pin widget amp left and right (no gain on this amp) */
  3351. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3352. /* set vol=0 HP mixer amp left and right */
  3353. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3354. /* unmute pin widget amp left and right (no gain on this amp) */
  3355. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3356. /* set vol=0 Mono mixer amp left and right */
  3357. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3358. /* unmute pin widget amp left and right (no gain on this amp) */
  3359. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3360. /* unmute LINE-2 out pin */
  3361. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3362. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3363. * Line In 2 = 0x03
  3364. */
  3365. /* mute CD */
  3366. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3367. /* mute Line In */
  3368. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3369. /* mute Mic */
  3370. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3371. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3372. /* mute Front out path */
  3373. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3374. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3375. /* mute Headphone out path */
  3376. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3377. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3378. /* mute Mono out path */
  3379. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3380. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3381. { }
  3382. };
  3383. #if 0 /* should be identical with alc260_init_verbs? */
  3384. static struct hda_verb alc260_hp_init_verbs[] = {
  3385. /* Headphone and output */
  3386. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3387. /* mono output */
  3388. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3389. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3390. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3391. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3392. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3393. /* Line In pin widget for input */
  3394. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3395. /* Line-2 pin widget for output */
  3396. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3397. /* CD pin widget for input */
  3398. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3399. /* unmute amp left and right */
  3400. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3401. /* set connection select to line in (default select for this ADC) */
  3402. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3403. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3404. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3405. /* mute pin widget amp left and right (no gain on this amp) */
  3406. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3407. /* unmute HP mixer amp left and right (volume = 0) */
  3408. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3409. /* mute pin widget amp left and right (no gain on this amp) */
  3410. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3411. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3412. * Line In 2 = 0x03
  3413. */
  3414. /* unmute CD */
  3415. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3416. /* unmute Line In */
  3417. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3418. /* unmute Mic */
  3419. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3420. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3421. /* Unmute Front out path */
  3422. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3423. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3424. /* Unmute Headphone out path */
  3425. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3426. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3427. /* Unmute Mono out path */
  3428. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3429. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3430. { }
  3431. };
  3432. #endif
  3433. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3434. /* Line out and output */
  3435. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3436. /* mono output */
  3437. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3438. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3439. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3440. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3441. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3442. /* Line In pin widget for input */
  3443. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3444. /* Headphone pin widget for output */
  3445. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3446. /* CD pin widget for input */
  3447. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3448. /* unmute amp left and right */
  3449. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3450. /* set connection select to line in (default select for this ADC) */
  3451. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3452. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3453. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3454. /* mute pin widget amp left and right (no gain on this amp) */
  3455. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3456. /* unmute HP mixer amp left and right (volume = 0) */
  3457. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3458. /* mute pin widget amp left and right (no gain on this amp) */
  3459. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3460. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3461. * Line In 2 = 0x03
  3462. */
  3463. /* unmute CD */
  3464. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3465. /* unmute Line In */
  3466. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3467. /* unmute Mic */
  3468. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3469. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3470. /* Unmute Front out path */
  3471. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3472. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3473. /* Unmute Headphone out path */
  3474. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3475. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3476. /* Unmute Mono out path */
  3477. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3478. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3479. { }
  3480. };
  3481. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3482. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3483. * audio = 0x16, internal speaker = 0x10.
  3484. */
  3485. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3486. /* Disable all GPIOs */
  3487. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3488. /* Internal speaker is connected to headphone pin */
  3489. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3490. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3491. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3492. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3493. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3494. /* Ensure all other unused pins are disabled and muted. */
  3495. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3496. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3497. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3498. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3499. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3500. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3501. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3502. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3503. /* Disable digital (SPDIF) pins */
  3504. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3505. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3506. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3507. * when acting as an output.
  3508. */
  3509. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3510. /* Start with output sum widgets muted and their output gains at min */
  3511. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3512. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3513. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3514. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3515. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3516. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3517. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3518. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3519. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3520. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3521. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3522. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3523. * If the pin mode is changed by the user the pin mode control will
  3524. * take care of enabling the pin's input/output buffers as needed.
  3525. * Therefore there's no need to enable the input buffer at this
  3526. * stage.
  3527. */
  3528. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3529. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3530. * mixer ctrl)
  3531. */
  3532. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3533. /* Mute capture amp left and right */
  3534. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3535. /* Set ADC connection select to match default mixer setting - line
  3536. * in (on mic1 pin)
  3537. */
  3538. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3539. /* Do the same for the second ADC: mute capture input amp and
  3540. * set ADC connection to line in (on mic1 pin)
  3541. */
  3542. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3543. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3544. /* Mute all inputs to mixer widget (even unconnected ones) */
  3545. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3546. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3547. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3548. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3549. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3550. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3551. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3552. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3553. { }
  3554. };
  3555. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3556. * similar laptops (adapted from Fujitsu init verbs).
  3557. */
  3558. static struct hda_verb alc260_acer_init_verbs[] = {
  3559. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3560. * the headphone jack. Turn this on and rely on the standard mute
  3561. * methods whenever the user wants to turn these outputs off.
  3562. */
  3563. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3564. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3565. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3566. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3567. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3568. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3569. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3570. /* Line In jack is connected to Line1 pin */
  3571. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3572. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3573. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3574. /* Ensure all other unused pins are disabled and muted. */
  3575. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3576. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3577. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3578. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3579. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3580. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3581. /* Disable digital (SPDIF) pins */
  3582. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3583. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3584. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3585. * bus when acting as outputs.
  3586. */
  3587. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3588. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3589. /* Start with output sum widgets muted and their output gains at min */
  3590. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3591. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3592. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3593. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3594. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3595. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3596. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3597. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3598. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3599. /* Unmute Line-out pin widget amp left and right
  3600. * (no equiv mixer ctrl)
  3601. */
  3602. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3603. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3604. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3605. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3606. * inputs. If the pin mode is changed by the user the pin mode control
  3607. * will take care of enabling the pin's input/output buffers as needed.
  3608. * Therefore there's no need to enable the input buffer at this
  3609. * stage.
  3610. */
  3611. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3612. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3613. /* Mute capture amp left and right */
  3614. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3615. /* Set ADC connection select to match default mixer setting - mic
  3616. * (on mic1 pin)
  3617. */
  3618. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3619. /* Do similar with the second ADC: mute capture input amp and
  3620. * set ADC connection to mic to match ALSA's default state.
  3621. */
  3622. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3623. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3624. /* Mute all inputs to mixer widget (even unconnected ones) */
  3625. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3626. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3627. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3628. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3629. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3630. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3631. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3632. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3633. { }
  3634. };
  3635. static struct hda_verb alc260_will_verbs[] = {
  3636. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3637. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3638. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3639. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3640. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3641. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3642. {}
  3643. };
  3644. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3645. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3646. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3647. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3648. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3649. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3650. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3651. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3652. {}
  3653. };
  3654. /* toggle speaker-output according to the hp-jack state */
  3655. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3656. {
  3657. unsigned int present;
  3658. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3659. present = snd_hda_codec_read(codec, 0x0f, 0,
  3660. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3661. if (present) {
  3662. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3663. snd_hda_codec_write(codec, 0x0f, 0,
  3664. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3665. } else {
  3666. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3667. snd_hda_codec_write(codec, 0x0f, 0,
  3668. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3669. }
  3670. }
  3671. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3672. unsigned int res)
  3673. {
  3674. if ((res >> 26) == ALC880_HP_EVENT)
  3675. alc260_replacer_672v_automute(codec);
  3676. }
  3677. /* Test configuration for debugging, modelled after the ALC880 test
  3678. * configuration.
  3679. */
  3680. #ifdef CONFIG_SND_DEBUG
  3681. static hda_nid_t alc260_test_dac_nids[1] = {
  3682. 0x02,
  3683. };
  3684. static hda_nid_t alc260_test_adc_nids[2] = {
  3685. 0x04, 0x05,
  3686. };
  3687. /* For testing the ALC260, each input MUX needs its own definition since
  3688. * the signal assignments are different. This assumes that the first ADC
  3689. * is NID 0x04.
  3690. */
  3691. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3692. {
  3693. .num_items = 7,
  3694. .items = {
  3695. { "MIC1 pin", 0x0 },
  3696. { "MIC2 pin", 0x1 },
  3697. { "LINE1 pin", 0x2 },
  3698. { "LINE2 pin", 0x3 },
  3699. { "CD pin", 0x4 },
  3700. { "LINE-OUT pin", 0x5 },
  3701. { "HP-OUT pin", 0x6 },
  3702. },
  3703. },
  3704. {
  3705. .num_items = 8,
  3706. .items = {
  3707. { "MIC1 pin", 0x0 },
  3708. { "MIC2 pin", 0x1 },
  3709. { "LINE1 pin", 0x2 },
  3710. { "LINE2 pin", 0x3 },
  3711. { "CD pin", 0x4 },
  3712. { "Mixer", 0x5 },
  3713. { "LINE-OUT pin", 0x6 },
  3714. { "HP-OUT pin", 0x7 },
  3715. },
  3716. },
  3717. };
  3718. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3719. /* Output driver widgets */
  3720. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3721. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3722. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3723. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3724. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3725. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3726. /* Modes for retasking pin widgets
  3727. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3728. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3729. * mention this restriction. At this stage it's not clear whether
  3730. * this behaviour is intentional or is a hardware bug in chip
  3731. * revisions available at least up until early 2006. Therefore for
  3732. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3733. * choices, but if it turns out that the lack of mic bias for these
  3734. * NIDs is intentional we could change their modes from
  3735. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3736. */
  3737. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3738. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3739. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3740. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3741. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3742. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3743. /* Loopback mixer controls */
  3744. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3745. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3746. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3747. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3748. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3749. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3750. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3751. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3752. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3753. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3754. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3755. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3756. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3757. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3758. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3759. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3760. /* Controls for GPIO pins, assuming they are configured as outputs */
  3761. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3762. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3763. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3764. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3765. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3766. * is ambigious as to which NID is which; testing on laptops which
  3767. * make this output available should provide clarification.
  3768. */
  3769. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3770. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3771. { } /* end */
  3772. };
  3773. static struct hda_verb alc260_test_init_verbs[] = {
  3774. /* Enable all GPIOs as outputs with an initial value of 0 */
  3775. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3776. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3777. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3778. /* Enable retasking pins as output, initially without power amp */
  3779. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3780. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3781. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3782. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3783. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3784. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3785. /* Disable digital (SPDIF) pins initially, but users can enable
  3786. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3787. * payload also sets the generation to 0, output to be in "consumer"
  3788. * PCM format, copyright asserted, no pre-emphasis and no validity
  3789. * control.
  3790. */
  3791. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3792. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3793. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3794. * OUT1 sum bus when acting as an output.
  3795. */
  3796. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3797. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3798. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3799. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3800. /* Start with output sum widgets muted and their output gains at min */
  3801. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3802. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3803. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3804. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3805. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3806. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3807. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3808. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3809. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3810. /* Unmute retasking pin widget output buffers since the default
  3811. * state appears to be output. As the pin mode is changed by the
  3812. * user the pin mode control will take care of enabling the pin's
  3813. * input/output buffers as needed.
  3814. */
  3815. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3816. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3817. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3818. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3819. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3820. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3821. /* Also unmute the mono-out pin widget */
  3822. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3823. /* Mute capture amp left and right */
  3824. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3825. /* Set ADC connection select to match default mixer setting (mic1
  3826. * pin)
  3827. */
  3828. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3829. /* Do the same for the second ADC: mute capture input amp and
  3830. * set ADC connection to mic1 pin
  3831. */
  3832. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3833. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3834. /* Mute all inputs to mixer widget (even unconnected ones) */
  3835. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3836. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3837. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3838. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3839. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3840. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3841. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3842. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3843. { }
  3844. };
  3845. #endif
  3846. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3847. .substreams = 1,
  3848. .channels_min = 2,
  3849. .channels_max = 2,
  3850. };
  3851. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3852. .substreams = 1,
  3853. .channels_min = 2,
  3854. .channels_max = 2,
  3855. };
  3856. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3857. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3858. /*
  3859. * for BIOS auto-configuration
  3860. */
  3861. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3862. const char *pfx)
  3863. {
  3864. hda_nid_t nid_vol;
  3865. unsigned long vol_val, sw_val;
  3866. char name[32];
  3867. int err;
  3868. if (nid >= 0x0f && nid < 0x11) {
  3869. nid_vol = nid - 0x7;
  3870. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3871. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3872. } else if (nid == 0x11) {
  3873. nid_vol = nid - 0x7;
  3874. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3875. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3876. } else if (nid >= 0x12 && nid <= 0x15) {
  3877. nid_vol = 0x08;
  3878. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3879. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3880. } else
  3881. return 0; /* N/A */
  3882. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3883. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3884. if (err < 0)
  3885. return err;
  3886. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3887. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3888. if (err < 0)
  3889. return err;
  3890. return 1;
  3891. }
  3892. /* add playback controls from the parsed DAC table */
  3893. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3894. const struct auto_pin_cfg *cfg)
  3895. {
  3896. hda_nid_t nid;
  3897. int err;
  3898. spec->multiout.num_dacs = 1;
  3899. spec->multiout.dac_nids = spec->private_dac_nids;
  3900. spec->multiout.dac_nids[0] = 0x02;
  3901. nid = cfg->line_out_pins[0];
  3902. if (nid) {
  3903. err = alc260_add_playback_controls(spec, nid, "Front");
  3904. if (err < 0)
  3905. return err;
  3906. }
  3907. nid = cfg->speaker_pins[0];
  3908. if (nid) {
  3909. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3910. if (err < 0)
  3911. return err;
  3912. }
  3913. nid = cfg->hp_pins[0];
  3914. if (nid) {
  3915. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3916. if (err < 0)
  3917. return err;
  3918. }
  3919. return 0;
  3920. }
  3921. /* create playback/capture controls for input pins */
  3922. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3923. const struct auto_pin_cfg *cfg)
  3924. {
  3925. struct hda_input_mux *imux = &spec->private_imux;
  3926. int i, err, idx;
  3927. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3928. if (cfg->input_pins[i] >= 0x12) {
  3929. idx = cfg->input_pins[i] - 0x12;
  3930. err = new_analog_input(spec, cfg->input_pins[i],
  3931. auto_pin_cfg_labels[i], idx,
  3932. 0x07);
  3933. if (err < 0)
  3934. return err;
  3935. imux->items[imux->num_items].label =
  3936. auto_pin_cfg_labels[i];
  3937. imux->items[imux->num_items].index = idx;
  3938. imux->num_items++;
  3939. }
  3940. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3941. idx = cfg->input_pins[i] - 0x09;
  3942. err = new_analog_input(spec, cfg->input_pins[i],
  3943. auto_pin_cfg_labels[i], idx,
  3944. 0x07);
  3945. if (err < 0)
  3946. return err;
  3947. imux->items[imux->num_items].label =
  3948. auto_pin_cfg_labels[i];
  3949. imux->items[imux->num_items].index = idx;
  3950. imux->num_items++;
  3951. }
  3952. }
  3953. return 0;
  3954. }
  3955. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3956. hda_nid_t nid, int pin_type,
  3957. int sel_idx)
  3958. {
  3959. /* set as output */
  3960. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3961. pin_type);
  3962. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3963. AMP_OUT_UNMUTE);
  3964. /* need the manual connection? */
  3965. if (nid >= 0x12) {
  3966. int idx = nid - 0x12;
  3967. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3968. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3969. }
  3970. }
  3971. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3972. {
  3973. struct alc_spec *spec = codec->spec;
  3974. hda_nid_t nid;
  3975. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  3976. nid = spec->autocfg.line_out_pins[0];
  3977. if (nid) {
  3978. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3979. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  3980. }
  3981. nid = spec->autocfg.speaker_pins[0];
  3982. if (nid)
  3983. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3984. nid = spec->autocfg.hp_pins[0];
  3985. if (nid)
  3986. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  3987. }
  3988. #define ALC260_PIN_CD_NID 0x16
  3989. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  3990. {
  3991. struct alc_spec *spec = codec->spec;
  3992. int i;
  3993. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3994. hda_nid_t nid = spec->autocfg.input_pins[i];
  3995. if (nid >= 0x12) {
  3996. snd_hda_codec_write(codec, nid, 0,
  3997. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3998. i <= AUTO_PIN_FRONT_MIC ?
  3999. PIN_VREF80 : PIN_IN);
  4000. if (nid != ALC260_PIN_CD_NID)
  4001. snd_hda_codec_write(codec, nid, 0,
  4002. AC_VERB_SET_AMP_GAIN_MUTE,
  4003. AMP_OUT_MUTE);
  4004. }
  4005. }
  4006. }
  4007. /*
  4008. * generic initialization of ADC, input mixers and output mixers
  4009. */
  4010. static struct hda_verb alc260_volume_init_verbs[] = {
  4011. /*
  4012. * Unmute ADC0-1 and set the default input to mic-in
  4013. */
  4014. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4015. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4016. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4017. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4018. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4019. * mixer widget
  4020. * Note: PASD motherboards uses the Line In 2 as the input for
  4021. * front panel mic (mic 2)
  4022. */
  4023. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4024. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4025. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4026. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4027. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4028. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4029. /*
  4030. * Set up output mixers (0x08 - 0x0a)
  4031. */
  4032. /* set vol=0 to output mixers */
  4033. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4034. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4035. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4036. /* set up input amps for analog loopback */
  4037. /* Amp Indices: DAC = 0, mixer = 1 */
  4038. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4039. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4040. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4041. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4042. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4043. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4044. { }
  4045. };
  4046. static int alc260_parse_auto_config(struct hda_codec *codec)
  4047. {
  4048. struct alc_spec *spec = codec->spec;
  4049. unsigned int wcap;
  4050. int err;
  4051. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4052. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4053. alc260_ignore);
  4054. if (err < 0)
  4055. return err;
  4056. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4057. if (err < 0)
  4058. return err;
  4059. if (!spec->kctl_alloc)
  4060. return 0; /* can't find valid BIOS pin config */
  4061. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4062. if (err < 0)
  4063. return err;
  4064. spec->multiout.max_channels = 2;
  4065. if (spec->autocfg.dig_out_pin)
  4066. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4067. if (spec->kctl_alloc)
  4068. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4069. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4070. spec->num_mux_defs = 1;
  4071. spec->input_mux = &spec->private_imux;
  4072. /* check whether NID 0x04 is valid */
  4073. wcap = get_wcaps(codec, 0x04);
  4074. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4075. if (wcap != AC_WID_AUD_IN) {
  4076. spec->adc_nids = alc260_adc_nids_alt;
  4077. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4078. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4079. } else {
  4080. spec->adc_nids = alc260_adc_nids;
  4081. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4082. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4083. }
  4084. spec->num_mixers++;
  4085. return 1;
  4086. }
  4087. /* additional initialization for auto-configuration model */
  4088. static void alc260_auto_init(struct hda_codec *codec)
  4089. {
  4090. alc260_auto_init_multi_out(codec);
  4091. alc260_auto_init_analog_input(codec);
  4092. }
  4093. /*
  4094. * ALC260 configurations
  4095. */
  4096. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4097. [ALC260_BASIC] = "basic",
  4098. [ALC260_HP] = "hp",
  4099. [ALC260_HP_3013] = "hp-3013",
  4100. [ALC260_FUJITSU_S702X] = "fujitsu",
  4101. [ALC260_ACER] = "acer",
  4102. [ALC260_WILL] = "will",
  4103. [ALC260_REPLACER_672V] = "replacer",
  4104. #ifdef CONFIG_SND_DEBUG
  4105. [ALC260_TEST] = "test",
  4106. #endif
  4107. [ALC260_AUTO] = "auto",
  4108. };
  4109. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4110. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4111. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4112. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4113. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4114. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4115. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4116. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4117. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4118. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4119. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4120. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4121. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4122. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4123. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4124. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4125. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4126. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4127. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4128. {}
  4129. };
  4130. static struct alc_config_preset alc260_presets[] = {
  4131. [ALC260_BASIC] = {
  4132. .mixers = { alc260_base_output_mixer,
  4133. alc260_input_mixer,
  4134. alc260_pc_beep_mixer,
  4135. alc260_capture_mixer },
  4136. .init_verbs = { alc260_init_verbs },
  4137. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4138. .dac_nids = alc260_dac_nids,
  4139. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4140. .adc_nids = alc260_adc_nids,
  4141. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4142. .channel_mode = alc260_modes,
  4143. .input_mux = &alc260_capture_source,
  4144. },
  4145. [ALC260_HP] = {
  4146. .mixers = { alc260_base_output_mixer,
  4147. alc260_input_mixer,
  4148. alc260_capture_alt_mixer },
  4149. .init_verbs = { alc260_init_verbs },
  4150. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4151. .dac_nids = alc260_dac_nids,
  4152. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4153. .adc_nids = alc260_hp_adc_nids,
  4154. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4155. .channel_mode = alc260_modes,
  4156. .input_mux = &alc260_capture_source,
  4157. },
  4158. [ALC260_HP_3013] = {
  4159. .mixers = { alc260_hp_3013_mixer,
  4160. alc260_input_mixer,
  4161. alc260_capture_alt_mixer },
  4162. .init_verbs = { alc260_hp_3013_init_verbs },
  4163. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4164. .dac_nids = alc260_dac_nids,
  4165. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4166. .adc_nids = alc260_hp_adc_nids,
  4167. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4168. .channel_mode = alc260_modes,
  4169. .input_mux = &alc260_capture_source,
  4170. },
  4171. [ALC260_FUJITSU_S702X] = {
  4172. .mixers = { alc260_fujitsu_mixer,
  4173. alc260_capture_mixer },
  4174. .init_verbs = { alc260_fujitsu_init_verbs },
  4175. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4176. .dac_nids = alc260_dac_nids,
  4177. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4178. .adc_nids = alc260_dual_adc_nids,
  4179. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4180. .channel_mode = alc260_modes,
  4181. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4182. .input_mux = alc260_fujitsu_capture_sources,
  4183. },
  4184. [ALC260_ACER] = {
  4185. .mixers = { alc260_acer_mixer,
  4186. alc260_capture_mixer },
  4187. .init_verbs = { alc260_acer_init_verbs },
  4188. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4189. .dac_nids = alc260_dac_nids,
  4190. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4191. .adc_nids = alc260_dual_adc_nids,
  4192. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4193. .channel_mode = alc260_modes,
  4194. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4195. .input_mux = alc260_acer_capture_sources,
  4196. },
  4197. [ALC260_WILL] = {
  4198. .mixers = { alc260_will_mixer,
  4199. alc260_capture_mixer },
  4200. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4201. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4202. .dac_nids = alc260_dac_nids,
  4203. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4204. .adc_nids = alc260_adc_nids,
  4205. .dig_out_nid = ALC260_DIGOUT_NID,
  4206. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4207. .channel_mode = alc260_modes,
  4208. .input_mux = &alc260_capture_source,
  4209. },
  4210. [ALC260_REPLACER_672V] = {
  4211. .mixers = { alc260_replacer_672v_mixer,
  4212. alc260_capture_mixer },
  4213. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4214. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4215. .dac_nids = alc260_dac_nids,
  4216. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4217. .adc_nids = alc260_adc_nids,
  4218. .dig_out_nid = ALC260_DIGOUT_NID,
  4219. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4220. .channel_mode = alc260_modes,
  4221. .input_mux = &alc260_capture_source,
  4222. .unsol_event = alc260_replacer_672v_unsol_event,
  4223. .init_hook = alc260_replacer_672v_automute,
  4224. },
  4225. #ifdef CONFIG_SND_DEBUG
  4226. [ALC260_TEST] = {
  4227. .mixers = { alc260_test_mixer,
  4228. alc260_capture_mixer },
  4229. .init_verbs = { alc260_test_init_verbs },
  4230. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4231. .dac_nids = alc260_test_dac_nids,
  4232. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4233. .adc_nids = alc260_test_adc_nids,
  4234. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4235. .channel_mode = alc260_modes,
  4236. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4237. .input_mux = alc260_test_capture_sources,
  4238. },
  4239. #endif
  4240. };
  4241. static int patch_alc260(struct hda_codec *codec)
  4242. {
  4243. struct alc_spec *spec;
  4244. int err, board_config;
  4245. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4246. if (spec == NULL)
  4247. return -ENOMEM;
  4248. codec->spec = spec;
  4249. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4250. alc260_models,
  4251. alc260_cfg_tbl);
  4252. if (board_config < 0) {
  4253. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4254. "trying auto-probe from BIOS...\n");
  4255. board_config = ALC260_AUTO;
  4256. }
  4257. if (board_config == ALC260_AUTO) {
  4258. /* automatic parse from the BIOS config */
  4259. err = alc260_parse_auto_config(codec);
  4260. if (err < 0) {
  4261. alc_free(codec);
  4262. return err;
  4263. } else if (!err) {
  4264. printk(KERN_INFO
  4265. "hda_codec: Cannot set up configuration "
  4266. "from BIOS. Using base mode...\n");
  4267. board_config = ALC260_BASIC;
  4268. }
  4269. }
  4270. if (board_config != ALC260_AUTO)
  4271. setup_preset(spec, &alc260_presets[board_config]);
  4272. spec->stream_name_analog = "ALC260 Analog";
  4273. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4274. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4275. spec->stream_name_digital = "ALC260 Digital";
  4276. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4277. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4278. codec->patch_ops = alc_patch_ops;
  4279. if (board_config == ALC260_AUTO)
  4280. spec->init_hook = alc260_auto_init;
  4281. return 0;
  4282. }
  4283. /*
  4284. * ALC882 support
  4285. *
  4286. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4287. * configuration. Each pin widget can choose any input DACs and a mixer.
  4288. * Each ADC is connected from a mixer of all inputs. This makes possible
  4289. * 6-channel independent captures.
  4290. *
  4291. * In addition, an independent DAC for the multi-playback (not used in this
  4292. * driver yet).
  4293. */
  4294. #define ALC882_DIGOUT_NID 0x06
  4295. #define ALC882_DIGIN_NID 0x0a
  4296. static struct hda_channel_mode alc882_ch_modes[1] = {
  4297. { 8, NULL }
  4298. };
  4299. static hda_nid_t alc882_dac_nids[4] = {
  4300. /* front, rear, clfe, rear_surr */
  4301. 0x02, 0x03, 0x04, 0x05
  4302. };
  4303. /* identical with ALC880 */
  4304. #define alc882_adc_nids alc880_adc_nids
  4305. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4306. /* input MUX */
  4307. /* FIXME: should be a matrix-type input source selection */
  4308. static struct hda_input_mux alc882_capture_source = {
  4309. .num_items = 4,
  4310. .items = {
  4311. { "Mic", 0x0 },
  4312. { "Front Mic", 0x1 },
  4313. { "Line", 0x2 },
  4314. { "CD", 0x4 },
  4315. },
  4316. };
  4317. #define alc882_mux_enum_info alc_mux_enum_info
  4318. #define alc882_mux_enum_get alc_mux_enum_get
  4319. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4320. struct snd_ctl_elem_value *ucontrol)
  4321. {
  4322. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4323. struct alc_spec *spec = codec->spec;
  4324. const struct hda_input_mux *imux = spec->input_mux;
  4325. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4326. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4327. hda_nid_t nid = capture_mixers[adc_idx];
  4328. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4329. unsigned int i, idx;
  4330. idx = ucontrol->value.enumerated.item[0];
  4331. if (idx >= imux->num_items)
  4332. idx = imux->num_items - 1;
  4333. if (*cur_val == idx && !codec->in_resume)
  4334. return 0;
  4335. for (i = 0; i < imux->num_items; i++) {
  4336. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4337. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4338. v | (imux->items[i].index << 8));
  4339. }
  4340. *cur_val = idx;
  4341. return 1;
  4342. }
  4343. /*
  4344. * 2ch mode
  4345. */
  4346. static struct hda_verb alc882_3ST_ch2_init[] = {
  4347. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4348. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4349. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4350. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4351. { } /* end */
  4352. };
  4353. /*
  4354. * 6ch mode
  4355. */
  4356. static struct hda_verb alc882_3ST_ch6_init[] = {
  4357. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4358. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4359. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4360. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4361. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4362. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4363. { } /* end */
  4364. };
  4365. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4366. { 2, alc882_3ST_ch2_init },
  4367. { 6, alc882_3ST_ch6_init },
  4368. };
  4369. /*
  4370. * 6ch mode
  4371. */
  4372. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4373. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4374. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4375. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4376. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4377. { } /* end */
  4378. };
  4379. /*
  4380. * 8ch mode
  4381. */
  4382. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4383. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4384. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4385. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4386. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4387. { } /* end */
  4388. };
  4389. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4390. { 6, alc882_sixstack_ch6_init },
  4391. { 8, alc882_sixstack_ch8_init },
  4392. };
  4393. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4394. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4395. */
  4396. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4397. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4398. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4399. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4400. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4401. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4402. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4403. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4404. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4405. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4406. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4407. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4408. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4409. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4410. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4411. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4412. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4413. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4414. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4415. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4416. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4417. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4418. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4419. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4420. { } /* end */
  4421. };
  4422. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4423. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4424. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4425. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4426. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4427. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4428. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4429. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4430. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4431. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4432. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4433. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4434. { } /* end */
  4435. };
  4436. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4437. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4438. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4439. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4440. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4441. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4442. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4443. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4444. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4445. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4446. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4447. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4448. { } /* end */
  4449. };
  4450. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4451. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4452. */
  4453. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4454. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4455. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4456. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4457. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4458. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4459. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4460. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4461. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4462. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4463. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4464. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4465. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4466. { } /* end */
  4467. };
  4468. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4469. {
  4470. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4471. .name = "Channel Mode",
  4472. .info = alc_ch_mode_info,
  4473. .get = alc_ch_mode_get,
  4474. .put = alc_ch_mode_put,
  4475. },
  4476. { } /* end */
  4477. };
  4478. static struct hda_verb alc882_init_verbs[] = {
  4479. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4480. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4481. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4482. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4483. /* Rear mixer */
  4484. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4485. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4486. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4487. /* CLFE mixer */
  4488. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4489. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4490. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4491. /* Side mixer */
  4492. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4493. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4494. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4495. /* Front Pin: output 0 (0x0c) */
  4496. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4497. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4498. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4499. /* Rear Pin: output 1 (0x0d) */
  4500. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4501. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4502. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4503. /* CLFE Pin: output 2 (0x0e) */
  4504. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4505. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4506. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4507. /* Side Pin: output 3 (0x0f) */
  4508. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4509. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4510. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4511. /* Mic (rear) pin: input vref at 80% */
  4512. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4513. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4514. /* Front Mic pin: input vref at 80% */
  4515. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4516. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4517. /* Line In pin: input */
  4518. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4519. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4520. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4521. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4522. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4523. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4524. /* CD pin widget for input */
  4525. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4526. /* FIXME: use matrix-type input source selection */
  4527. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4528. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4529. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4530. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4531. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4532. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4533. /* Input mixer2 */
  4534. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4535. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4536. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4537. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4538. /* Input mixer3 */
  4539. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4540. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4541. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4542. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4543. /* ADC1: mute amp left and right */
  4544. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4545. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4546. /* ADC2: mute amp left and right */
  4547. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4548. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4549. /* ADC3: mute amp left and right */
  4550. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4551. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4552. { }
  4553. };
  4554. static struct hda_verb alc882_eapd_verbs[] = {
  4555. /* change to EAPD mode */
  4556. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4557. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4558. { }
  4559. };
  4560. /* Mac Pro test */
  4561. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4562. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4563. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4564. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4565. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4566. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4567. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4568. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4569. { } /* end */
  4570. };
  4571. static struct hda_verb alc882_macpro_init_verbs[] = {
  4572. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4573. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4574. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4575. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4576. /* Front Pin: output 0 (0x0c) */
  4577. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4578. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4579. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4580. /* Front Mic pin: input vref at 80% */
  4581. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4582. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4583. /* Speaker: output */
  4584. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4585. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4586. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4587. /* Headphone output (output 0 - 0x0c) */
  4588. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4589. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4590. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4591. /* FIXME: use matrix-type input source selection */
  4592. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4593. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4594. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4595. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4596. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4597. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4598. /* Input mixer2 */
  4599. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4600. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4601. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4602. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4603. /* Input mixer3 */
  4604. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4605. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4606. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4607. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4608. /* ADC1: mute amp left and right */
  4609. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4610. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4611. /* ADC2: mute amp left and right */
  4612. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4613. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4614. /* ADC3: mute amp left and right */
  4615. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4616. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4617. { }
  4618. };
  4619. static struct hda_verb alc882_targa_verbs[] = {
  4620. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4621. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4622. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4623. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4624. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4625. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4626. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4627. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4628. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4629. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4630. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4631. { } /* end */
  4632. };
  4633. /* toggle speaker-output according to the hp-jack state */
  4634. static void alc882_targa_automute(struct hda_codec *codec)
  4635. {
  4636. unsigned int present;
  4637. present = snd_hda_codec_read(codec, 0x14, 0,
  4638. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4639. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4640. 0x80, present ? 0x80 : 0);
  4641. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4642. 0x80, present ? 0x80 : 0);
  4643. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4644. }
  4645. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4646. {
  4647. /* Looks like the unsol event is incompatible with the standard
  4648. * definition. 4bit tag is placed at 26 bit!
  4649. */
  4650. if (((res >> 26) == ALC880_HP_EVENT)) {
  4651. alc882_targa_automute(codec);
  4652. }
  4653. }
  4654. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4655. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4656. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4657. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4658. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4659. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4660. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4661. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4662. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4663. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4664. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4665. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4666. { } /* end */
  4667. };
  4668. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4669. {
  4670. unsigned int gpiostate, gpiomask, gpiodir;
  4671. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4672. AC_VERB_GET_GPIO_DATA, 0);
  4673. if (!muted)
  4674. gpiostate |= (1 << pin);
  4675. else
  4676. gpiostate &= ~(1 << pin);
  4677. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4678. AC_VERB_GET_GPIO_MASK, 0);
  4679. gpiomask |= (1 << pin);
  4680. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4681. AC_VERB_GET_GPIO_DIRECTION, 0);
  4682. gpiodir |= (1 << pin);
  4683. snd_hda_codec_write(codec, codec->afg, 0,
  4684. AC_VERB_SET_GPIO_MASK, gpiomask);
  4685. snd_hda_codec_write(codec, codec->afg, 0,
  4686. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4687. msleep(1);
  4688. snd_hda_codec_write(codec, codec->afg, 0,
  4689. AC_VERB_SET_GPIO_DATA, gpiostate);
  4690. }
  4691. /*
  4692. * generic initialization of ADC, input mixers and output mixers
  4693. */
  4694. static struct hda_verb alc882_auto_init_verbs[] = {
  4695. /*
  4696. * Unmute ADC0-2 and set the default input to mic-in
  4697. */
  4698. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4699. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4700. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4701. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4702. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4703. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4704. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4705. * mixer widget
  4706. * Note: PASD motherboards uses the Line In 2 as the input for
  4707. * front panel mic (mic 2)
  4708. */
  4709. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4710. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4711. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4712. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4713. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4714. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4715. /*
  4716. * Set up output mixers (0x0c - 0x0f)
  4717. */
  4718. /* set vol=0 to output mixers */
  4719. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4720. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4721. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4722. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4723. /* set up input amps for analog loopback */
  4724. /* Amp Indices: DAC = 0, mixer = 1 */
  4725. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4726. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4727. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4728. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4729. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4730. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4731. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4732. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4733. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4734. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4735. /* FIXME: use matrix-type input source selection */
  4736. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4737. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4738. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4739. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4740. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4741. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4742. /* Input mixer2 */
  4743. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4744. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4745. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4746. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4747. /* Input mixer3 */
  4748. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4749. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4750. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4751. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4752. { }
  4753. };
  4754. /* capture mixer elements */
  4755. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4756. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4757. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4758. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4759. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4760. {
  4761. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4762. /* The multiple "Capture Source" controls confuse alsamixer
  4763. * So call somewhat different..
  4764. * FIXME: the controls appear in the "playback" view!
  4765. */
  4766. /* .name = "Capture Source", */
  4767. .name = "Input Source",
  4768. .count = 2,
  4769. .info = alc882_mux_enum_info,
  4770. .get = alc882_mux_enum_get,
  4771. .put = alc882_mux_enum_put,
  4772. },
  4773. { } /* end */
  4774. };
  4775. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4776. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4777. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4778. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4779. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4780. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4781. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4782. {
  4783. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4784. /* The multiple "Capture Source" controls confuse alsamixer
  4785. * So call somewhat different..
  4786. * FIXME: the controls appear in the "playback" view!
  4787. */
  4788. /* .name = "Capture Source", */
  4789. .name = "Input Source",
  4790. .count = 3,
  4791. .info = alc882_mux_enum_info,
  4792. .get = alc882_mux_enum_get,
  4793. .put = alc882_mux_enum_put,
  4794. },
  4795. { } /* end */
  4796. };
  4797. /* pcm configuration: identiacal with ALC880 */
  4798. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4799. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4800. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4801. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4802. /*
  4803. * configuration and preset
  4804. */
  4805. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4806. [ALC882_3ST_DIG] = "3stack-dig",
  4807. [ALC882_6ST_DIG] = "6stack-dig",
  4808. [ALC882_ARIMA] = "arima",
  4809. [ALC882_W2JC] = "w2jc",
  4810. [ALC885_MACPRO] = "macpro",
  4811. [ALC882_AUTO] = "auto",
  4812. };
  4813. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4814. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4815. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4816. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4817. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4818. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4819. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4820. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4821. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4822. {}
  4823. };
  4824. static struct alc_config_preset alc882_presets[] = {
  4825. [ALC882_3ST_DIG] = {
  4826. .mixers = { alc882_base_mixer },
  4827. .init_verbs = { alc882_init_verbs },
  4828. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4829. .dac_nids = alc882_dac_nids,
  4830. .dig_out_nid = ALC882_DIGOUT_NID,
  4831. .dig_in_nid = ALC882_DIGIN_NID,
  4832. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4833. .channel_mode = alc882_ch_modes,
  4834. .need_dac_fix = 1,
  4835. .input_mux = &alc882_capture_source,
  4836. },
  4837. [ALC882_6ST_DIG] = {
  4838. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4839. .init_verbs = { alc882_init_verbs },
  4840. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4841. .dac_nids = alc882_dac_nids,
  4842. .dig_out_nid = ALC882_DIGOUT_NID,
  4843. .dig_in_nid = ALC882_DIGIN_NID,
  4844. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4845. .channel_mode = alc882_sixstack_modes,
  4846. .input_mux = &alc882_capture_source,
  4847. },
  4848. [ALC882_ARIMA] = {
  4849. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4850. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4851. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4852. .dac_nids = alc882_dac_nids,
  4853. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4854. .channel_mode = alc882_sixstack_modes,
  4855. .input_mux = &alc882_capture_source,
  4856. },
  4857. [ALC882_W2JC] = {
  4858. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4859. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4860. alc880_gpio1_init_verbs },
  4861. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4862. .dac_nids = alc882_dac_nids,
  4863. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4864. .channel_mode = alc880_threestack_modes,
  4865. .need_dac_fix = 1,
  4866. .input_mux = &alc882_capture_source,
  4867. .dig_out_nid = ALC882_DIGOUT_NID,
  4868. },
  4869. [ALC885_MACPRO] = {
  4870. .mixers = { alc882_macpro_mixer },
  4871. .init_verbs = { alc882_macpro_init_verbs },
  4872. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4873. .dac_nids = alc882_dac_nids,
  4874. .dig_out_nid = ALC882_DIGOUT_NID,
  4875. .dig_in_nid = ALC882_DIGIN_NID,
  4876. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4877. .channel_mode = alc882_ch_modes,
  4878. .input_mux = &alc882_capture_source,
  4879. },
  4880. [ALC882_TARGA] = {
  4881. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4882. alc882_capture_mixer },
  4883. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4884. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4885. .dac_nids = alc882_dac_nids,
  4886. .dig_out_nid = ALC882_DIGOUT_NID,
  4887. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4888. .adc_nids = alc882_adc_nids,
  4889. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4890. .channel_mode = alc882_3ST_6ch_modes,
  4891. .need_dac_fix = 1,
  4892. .input_mux = &alc882_capture_source,
  4893. .unsol_event = alc882_targa_unsol_event,
  4894. .init_hook = alc882_targa_automute,
  4895. },
  4896. [ALC882_ASUS_A7J] = {
  4897. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4898. alc882_capture_mixer },
  4899. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4900. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4901. .dac_nids = alc882_dac_nids,
  4902. .dig_out_nid = ALC882_DIGOUT_NID,
  4903. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4904. .adc_nids = alc882_adc_nids,
  4905. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4906. .channel_mode = alc882_3ST_6ch_modes,
  4907. .need_dac_fix = 1,
  4908. .input_mux = &alc882_capture_source,
  4909. },
  4910. };
  4911. /*
  4912. * BIOS auto configuration
  4913. */
  4914. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4915. hda_nid_t nid, int pin_type,
  4916. int dac_idx)
  4917. {
  4918. /* set as output */
  4919. struct alc_spec *spec = codec->spec;
  4920. int idx;
  4921. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4922. idx = 4;
  4923. else
  4924. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4925. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4926. pin_type);
  4927. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4928. AMP_OUT_UNMUTE);
  4929. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4930. }
  4931. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4932. {
  4933. struct alc_spec *spec = codec->spec;
  4934. int i;
  4935. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4936. for (i = 0; i <= HDA_SIDE; i++) {
  4937. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4938. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4939. if (nid)
  4940. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  4941. i);
  4942. }
  4943. }
  4944. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4945. {
  4946. struct alc_spec *spec = codec->spec;
  4947. hda_nid_t pin;
  4948. pin = spec->autocfg.hp_pins[0];
  4949. if (pin) /* connect to front */
  4950. /* use dac 0 */
  4951. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4952. }
  4953. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  4954. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  4955. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  4956. {
  4957. struct alc_spec *spec = codec->spec;
  4958. int i;
  4959. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4960. hda_nid_t nid = spec->autocfg.input_pins[i];
  4961. if (alc882_is_input_pin(nid)) {
  4962. snd_hda_codec_write(codec, nid, 0,
  4963. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4964. i <= AUTO_PIN_FRONT_MIC ?
  4965. PIN_VREF80 : PIN_IN);
  4966. if (nid != ALC882_PIN_CD_NID)
  4967. snd_hda_codec_write(codec, nid, 0,
  4968. AC_VERB_SET_AMP_GAIN_MUTE,
  4969. AMP_OUT_MUTE);
  4970. }
  4971. }
  4972. }
  4973. /* almost identical with ALC880 parser... */
  4974. static int alc882_parse_auto_config(struct hda_codec *codec)
  4975. {
  4976. struct alc_spec *spec = codec->spec;
  4977. int err = alc880_parse_auto_config(codec);
  4978. if (err < 0)
  4979. return err;
  4980. else if (err > 0)
  4981. /* hack - override the init verbs */
  4982. spec->init_verbs[0] = alc882_auto_init_verbs;
  4983. return err;
  4984. }
  4985. /* additional initialization for auto-configuration model */
  4986. static void alc882_auto_init(struct hda_codec *codec)
  4987. {
  4988. alc882_auto_init_multi_out(codec);
  4989. alc882_auto_init_hp_out(codec);
  4990. alc882_auto_init_analog_input(codec);
  4991. }
  4992. static int patch_alc882(struct hda_codec *codec)
  4993. {
  4994. struct alc_spec *spec;
  4995. int err, board_config;
  4996. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4997. if (spec == NULL)
  4998. return -ENOMEM;
  4999. codec->spec = spec;
  5000. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5001. alc882_models,
  5002. alc882_cfg_tbl);
  5003. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5004. /* Pick up systems that don't supply PCI SSID */
  5005. switch (codec->subsystem_id) {
  5006. case 0x106b0c00: /* Mac Pro */
  5007. board_config = ALC885_MACPRO;
  5008. break;
  5009. default:
  5010. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5011. "trying auto-probe from BIOS...\n");
  5012. board_config = ALC882_AUTO;
  5013. }
  5014. }
  5015. if (board_config == ALC882_AUTO) {
  5016. /* automatic parse from the BIOS config */
  5017. err = alc882_parse_auto_config(codec);
  5018. if (err < 0) {
  5019. alc_free(codec);
  5020. return err;
  5021. } else if (!err) {
  5022. printk(KERN_INFO
  5023. "hda_codec: Cannot set up configuration "
  5024. "from BIOS. Using base mode...\n");
  5025. board_config = ALC882_3ST_DIG;
  5026. }
  5027. }
  5028. if (board_config != ALC882_AUTO)
  5029. setup_preset(spec, &alc882_presets[board_config]);
  5030. if (board_config == ALC885_MACPRO) {
  5031. alc882_gpio_mute(codec, 0, 0);
  5032. alc882_gpio_mute(codec, 1, 0);
  5033. }
  5034. spec->stream_name_analog = "ALC882 Analog";
  5035. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5036. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5037. spec->stream_name_digital = "ALC882 Digital";
  5038. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5039. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5040. if (!spec->adc_nids && spec->input_mux) {
  5041. /* check whether NID 0x07 is valid */
  5042. unsigned int wcap = get_wcaps(codec, 0x07);
  5043. /* get type */
  5044. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5045. if (wcap != AC_WID_AUD_IN) {
  5046. spec->adc_nids = alc882_adc_nids_alt;
  5047. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5048. spec->mixers[spec->num_mixers] =
  5049. alc882_capture_alt_mixer;
  5050. spec->num_mixers++;
  5051. } else {
  5052. spec->adc_nids = alc882_adc_nids;
  5053. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5054. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5055. spec->num_mixers++;
  5056. }
  5057. }
  5058. codec->patch_ops = alc_patch_ops;
  5059. if (board_config == ALC882_AUTO)
  5060. spec->init_hook = alc882_auto_init;
  5061. return 0;
  5062. }
  5063. /*
  5064. * ALC883 support
  5065. *
  5066. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5067. * configuration. Each pin widget can choose any input DACs and a mixer.
  5068. * Each ADC is connected from a mixer of all inputs. This makes possible
  5069. * 6-channel independent captures.
  5070. *
  5071. * In addition, an independent DAC for the multi-playback (not used in this
  5072. * driver yet).
  5073. */
  5074. #define ALC883_DIGOUT_NID 0x06
  5075. #define ALC883_DIGIN_NID 0x0a
  5076. static hda_nid_t alc883_dac_nids[4] = {
  5077. /* front, rear, clfe, rear_surr */
  5078. 0x02, 0x04, 0x03, 0x05
  5079. };
  5080. static hda_nid_t alc883_adc_nids[2] = {
  5081. /* ADC1-2 */
  5082. 0x08, 0x09,
  5083. };
  5084. /* input MUX */
  5085. /* FIXME: should be a matrix-type input source selection */
  5086. static struct hda_input_mux alc883_capture_source = {
  5087. .num_items = 4,
  5088. .items = {
  5089. { "Mic", 0x0 },
  5090. { "Front Mic", 0x1 },
  5091. { "Line", 0x2 },
  5092. { "CD", 0x4 },
  5093. },
  5094. };
  5095. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5096. .num_items = 2,
  5097. .items = {
  5098. { "Mic", 0x1 },
  5099. { "Line", 0x2 },
  5100. },
  5101. };
  5102. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5103. .num_items = 4,
  5104. .items = {
  5105. { "Mic", 0x0 },
  5106. { "iMic", 0x1 },
  5107. { "Line", 0x2 },
  5108. { "CD", 0x4 },
  5109. },
  5110. };
  5111. #define alc883_mux_enum_info alc_mux_enum_info
  5112. #define alc883_mux_enum_get alc_mux_enum_get
  5113. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5114. struct snd_ctl_elem_value *ucontrol)
  5115. {
  5116. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5117. struct alc_spec *spec = codec->spec;
  5118. const struct hda_input_mux *imux = spec->input_mux;
  5119. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5120. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5121. hda_nid_t nid = capture_mixers[adc_idx];
  5122. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5123. unsigned int i, idx;
  5124. idx = ucontrol->value.enumerated.item[0];
  5125. if (idx >= imux->num_items)
  5126. idx = imux->num_items - 1;
  5127. if (*cur_val == idx && !codec->in_resume)
  5128. return 0;
  5129. for (i = 0; i < imux->num_items; i++) {
  5130. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5131. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5132. v | (imux->items[i].index << 8));
  5133. }
  5134. *cur_val = idx;
  5135. return 1;
  5136. }
  5137. /*
  5138. * 2ch mode
  5139. */
  5140. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5141. { 2, NULL }
  5142. };
  5143. /*
  5144. * 2ch mode
  5145. */
  5146. static struct hda_verb alc883_3ST_ch2_init[] = {
  5147. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5148. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5149. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5150. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5151. { } /* end */
  5152. };
  5153. /*
  5154. * 6ch mode
  5155. */
  5156. static struct hda_verb alc883_3ST_ch6_init[] = {
  5157. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5158. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5159. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5160. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5161. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5162. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5163. { } /* end */
  5164. };
  5165. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5166. { 2, alc883_3ST_ch2_init },
  5167. { 6, alc883_3ST_ch6_init },
  5168. };
  5169. /*
  5170. * 6ch mode
  5171. */
  5172. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5173. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5174. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5175. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5176. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5177. { } /* end */
  5178. };
  5179. /*
  5180. * 8ch mode
  5181. */
  5182. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5183. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5184. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5185. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5186. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5187. { } /* end */
  5188. };
  5189. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5190. { 6, alc883_sixstack_ch6_init },
  5191. { 8, alc883_sixstack_ch8_init },
  5192. };
  5193. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5194. /* eanable EAPD on medion laptop */
  5195. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5196. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5197. { }
  5198. };
  5199. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5200. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5201. */
  5202. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5203. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5204. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5205. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5206. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5207. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5208. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5209. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5210. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5211. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5212. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5213. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5214. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5215. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5216. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5217. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5218. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5219. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5220. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5221. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5222. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5223. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5224. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5225. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5226. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5227. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5228. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5229. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5230. {
  5231. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5232. /* .name = "Capture Source", */
  5233. .name = "Input Source",
  5234. .count = 2,
  5235. .info = alc883_mux_enum_info,
  5236. .get = alc883_mux_enum_get,
  5237. .put = alc883_mux_enum_put,
  5238. },
  5239. { } /* end */
  5240. };
  5241. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5242. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5243. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5244. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5245. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5246. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5247. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5248. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5249. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5250. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5251. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5252. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5253. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5254. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5255. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5256. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5257. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5258. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5259. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5260. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5261. {
  5262. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5263. /* .name = "Capture Source", */
  5264. .name = "Input Source",
  5265. .count = 2,
  5266. .info = alc883_mux_enum_info,
  5267. .get = alc883_mux_enum_get,
  5268. .put = alc883_mux_enum_put,
  5269. },
  5270. { } /* end */
  5271. };
  5272. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5273. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5274. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5275. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5276. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5277. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5278. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5279. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5280. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5281. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5282. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5283. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5284. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5285. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5286. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5287. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5288. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5289. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5290. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5291. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5292. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5293. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5294. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5295. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5296. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5297. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5298. {
  5299. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5300. /* .name = "Capture Source", */
  5301. .name = "Input Source",
  5302. .count = 2,
  5303. .info = alc883_mux_enum_info,
  5304. .get = alc883_mux_enum_get,
  5305. .put = alc883_mux_enum_put,
  5306. },
  5307. { } /* end */
  5308. };
  5309. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5310. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5311. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5312. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5313. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5314. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5315. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5316. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5317. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5318. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5319. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5320. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5321. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5322. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5323. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5324. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5325. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5326. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5327. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5328. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5329. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5330. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5331. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5332. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5333. {
  5334. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5335. /* .name = "Capture Source", */
  5336. .name = "Input Source",
  5337. .count = 1,
  5338. .info = alc883_mux_enum_info,
  5339. .get = alc883_mux_enum_get,
  5340. .put = alc883_mux_enum_put,
  5341. },
  5342. { } /* end */
  5343. };
  5344. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5345. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5346. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5347. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5348. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5349. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5350. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5351. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5352. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5353. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5354. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5355. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5356. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5357. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5358. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5359. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5360. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5361. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5362. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5363. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5364. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5365. {
  5366. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5367. /* .name = "Capture Source", */
  5368. .name = "Input Source",
  5369. .count = 2,
  5370. .info = alc883_mux_enum_info,
  5371. .get = alc883_mux_enum_get,
  5372. .put = alc883_mux_enum_put,
  5373. },
  5374. { } /* end */
  5375. };
  5376. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5377. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5378. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5379. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5380. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5381. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5382. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5383. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5384. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5385. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5386. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5387. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5388. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5389. {
  5390. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5391. /* .name = "Capture Source", */
  5392. .name = "Input Source",
  5393. .count = 2,
  5394. .info = alc883_mux_enum_info,
  5395. .get = alc883_mux_enum_get,
  5396. .put = alc883_mux_enum_put,
  5397. },
  5398. { } /* end */
  5399. };
  5400. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5401. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5402. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5403. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5404. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5405. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5406. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5407. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5408. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5409. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5410. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5411. {
  5412. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5413. /* .name = "Capture Source", */
  5414. .name = "Input Source",
  5415. .count = 1,
  5416. .info = alc883_mux_enum_info,
  5417. .get = alc883_mux_enum_get,
  5418. .put = alc883_mux_enum_put,
  5419. },
  5420. { } /* end */
  5421. };
  5422. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5423. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5424. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5425. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5426. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5427. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5428. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5429. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5430. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5431. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5432. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5433. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5434. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5435. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5436. {
  5437. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5438. /* .name = "Capture Source", */
  5439. .name = "Input Source",
  5440. .count = 2,
  5441. .info = alc883_mux_enum_info,
  5442. .get = alc883_mux_enum_get,
  5443. .put = alc883_mux_enum_put,
  5444. },
  5445. { } /* end */
  5446. };
  5447. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5448. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5449. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5450. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5451. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5452. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5453. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5454. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5455. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5456. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5457. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5458. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5459. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5460. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5461. {
  5462. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5463. /* .name = "Capture Source", */
  5464. .name = "Input Source",
  5465. .count = 2,
  5466. .info = alc883_mux_enum_info,
  5467. .get = alc883_mux_enum_get,
  5468. .put = alc883_mux_enum_put,
  5469. },
  5470. { } /* end */
  5471. };
  5472. static struct snd_kcontrol_new alc888_hp_nettle_mixer[] = {
  5473. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5474. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5475. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5476. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5477. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5478. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5479. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5480. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5481. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5482. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5483. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5484. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5485. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5486. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5487. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5488. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5489. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5490. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5491. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5492. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5493. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5494. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5495. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5496. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5497. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5498. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5499. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5500. {
  5501. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5502. /* .name = "Capture Source", */
  5503. .name = "Input Source",
  5504. .count = 2,
  5505. .info = alc883_mux_enum_info,
  5506. .get = alc883_mux_enum_get,
  5507. .put = alc883_mux_enum_put,
  5508. },
  5509. { } /* end */
  5510. };
  5511. static struct snd_kcontrol_new alc888_hp_lucknow_mixer[] = {
  5512. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5513. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5514. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5515. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5516. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5517. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5518. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5519. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5520. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5521. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5522. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5523. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5524. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5525. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5526. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5527. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5528. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5529. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5530. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5531. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5532. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5533. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5534. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5535. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5536. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5537. {
  5538. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5539. /* .name = "Capture Source", */
  5540. .name = "Input Source",
  5541. .count = 2,
  5542. .info = alc883_mux_enum_info,
  5543. .get = alc883_mux_enum_get,
  5544. .put = alc883_mux_enum_put,
  5545. },
  5546. { } /* end */
  5547. };
  5548. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5549. {
  5550. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5551. .name = "Channel Mode",
  5552. .info = alc_ch_mode_info,
  5553. .get = alc_ch_mode_get,
  5554. .put = alc_ch_mode_put,
  5555. },
  5556. { } /* end */
  5557. };
  5558. static struct hda_verb alc883_init_verbs[] = {
  5559. /* ADC1: mute amp left and right */
  5560. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5561. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5562. /* ADC2: mute amp left and right */
  5563. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5564. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5565. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5566. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5567. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5568. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5569. /* Rear mixer */
  5570. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5571. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5572. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5573. /* CLFE mixer */
  5574. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5575. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5576. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5577. /* Side mixer */
  5578. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5579. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5580. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5581. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5582. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5583. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5584. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5585. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5586. /* Front Pin: output 0 (0x0c) */
  5587. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5588. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5589. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5590. /* Rear Pin: output 1 (0x0d) */
  5591. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5592. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5593. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5594. /* CLFE Pin: output 2 (0x0e) */
  5595. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5596. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5597. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5598. /* Side Pin: output 3 (0x0f) */
  5599. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5600. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5601. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5602. /* Mic (rear) pin: input vref at 80% */
  5603. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5604. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5605. /* Front Mic pin: input vref at 80% */
  5606. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5607. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5608. /* Line In pin: input */
  5609. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5610. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5611. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5612. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5613. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5614. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5615. /* CD pin widget for input */
  5616. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5617. /* FIXME: use matrix-type input source selection */
  5618. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5619. /* Input mixer2 */
  5620. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5621. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5622. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5623. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5624. /* Input mixer3 */
  5625. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5626. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5627. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5628. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5629. { }
  5630. };
  5631. static struct hda_verb alc883_tagra_verbs[] = {
  5632. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5633. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5634. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5635. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5636. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5637. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5638. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5639. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5640. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5641. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5642. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5643. { } /* end */
  5644. };
  5645. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5646. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5647. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5648. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5649. { } /* end */
  5650. };
  5651. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5652. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5653. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5654. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5655. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5656. { } /* end */
  5657. };
  5658. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5659. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5660. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5661. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5662. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5663. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5664. { } /* end */
  5665. };
  5666. static struct hda_verb alc888_hp_nettle_verbs[] = {
  5667. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5668. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  5669. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  5670. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  5671. { }
  5672. };
  5673. static struct hda_verb alc888_hp_lucknow_verbs[] = {
  5674. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5675. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  5676. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  5677. { }
  5678. };
  5679. static struct hda_verb alc888_hp_lucknow_2ch_init[] = {
  5680. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5681. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5682. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5683. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5684. { }
  5685. };
  5686. static struct hda_verb alc888_hp_lucknow_6ch_init[] = {
  5687. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5688. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5689. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5690. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5691. { }
  5692. };
  5693. static struct hda_channel_mode alc888_hp_lucknow_modes[2] = {
  5694. { 2, alc888_hp_lucknow_2ch_init },
  5695. { 6, alc888_hp_lucknow_6ch_init },
  5696. };
  5697. /* toggle front-jack and RCA according to the hp-jack state */
  5698. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5699. {
  5700. unsigned int present;
  5701. present = snd_hda_codec_read(codec, 0x1b, 0,
  5702. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5703. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5704. 0x80, present ? 0x80 : 0);
  5705. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5706. 0x80, present ? 0x80 : 0);
  5707. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5708. 0x80, present ? 0x80 : 0);
  5709. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5710. 0x80, present ? 0x80 : 0);
  5711. }
  5712. /* toggle RCA according to the front-jack state */
  5713. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5714. {
  5715. unsigned int present;
  5716. present = snd_hda_codec_read(codec, 0x14, 0,
  5717. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5718. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5719. 0x80, present ? 0x80 : 0);
  5720. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5721. 0x80, present ? 0x80 : 0);
  5722. }
  5723. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5724. unsigned int res)
  5725. {
  5726. if ((res >> 26) == ALC880_HP_EVENT)
  5727. alc888_lenovo_ms7195_front_automute(codec);
  5728. if ((res >> 26) == ALC880_FRONT_EVENT)
  5729. alc888_lenovo_ms7195_rca_automute(codec);
  5730. }
  5731. static struct hda_verb alc883_medion_md2_verbs[] = {
  5732. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5733. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5734. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5735. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5736. { } /* end */
  5737. };
  5738. /* toggle speaker-output according to the hp-jack state */
  5739. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5740. {
  5741. unsigned int present;
  5742. present = snd_hda_codec_read(codec, 0x14, 0,
  5743. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5744. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5745. 0x80, present ? 0x80 : 0);
  5746. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5747. 0x80, present ? 0x80 : 0);
  5748. }
  5749. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5750. unsigned int res)
  5751. {
  5752. if ((res >> 26) == ALC880_HP_EVENT)
  5753. alc883_medion_md2_automute(codec);
  5754. }
  5755. /* toggle speaker-output according to the hp-jack state */
  5756. static void alc883_tagra_automute(struct hda_codec *codec)
  5757. {
  5758. unsigned int present;
  5759. unsigned char bits;
  5760. present = snd_hda_codec_read(codec, 0x14, 0,
  5761. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5762. bits = present ? 0x80 : 0;
  5763. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5764. 0x80, bits);
  5765. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5766. 0x80, bits);
  5767. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5768. present ? 1 : 3);
  5769. }
  5770. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5771. {
  5772. if ((res >> 26) == ALC880_HP_EVENT)
  5773. alc883_tagra_automute(codec);
  5774. }
  5775. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5776. {
  5777. unsigned int present;
  5778. unsigned char bits;
  5779. present = snd_hda_codec_read(codec, 0x14, 0,
  5780. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5781. bits = present ? 0x80 : 0;
  5782. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5783. 0x80, bits);
  5784. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5785. 0x80, bits);
  5786. }
  5787. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5788. {
  5789. unsigned int present;
  5790. unsigned char bits;
  5791. present = snd_hda_codec_read(codec, 0x1b, 0,
  5792. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5793. bits = present ? 0x80 : 0;
  5794. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5795. 0x80, bits);
  5796. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5797. 0x80, bits);
  5798. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5799. 0x80, bits);
  5800. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5801. 0x80, bits);
  5802. }
  5803. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5804. unsigned int res)
  5805. {
  5806. if ((res >> 26) == ALC880_HP_EVENT)
  5807. alc883_lenovo_101e_all_automute(codec);
  5808. if ((res >> 26) == ALC880_FRONT_EVENT)
  5809. alc883_lenovo_101e_ispeaker_automute(codec);
  5810. }
  5811. /*
  5812. * generic initialization of ADC, input mixers and output mixers
  5813. */
  5814. static struct hda_verb alc883_auto_init_verbs[] = {
  5815. /*
  5816. * Unmute ADC0-2 and set the default input to mic-in
  5817. */
  5818. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5819. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5820. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5821. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5822. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5823. * mixer widget
  5824. * Note: PASD motherboards uses the Line In 2 as the input for
  5825. * front panel mic (mic 2)
  5826. */
  5827. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5828. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5829. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5830. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5831. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5832. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5833. /*
  5834. * Set up output mixers (0x0c - 0x0f)
  5835. */
  5836. /* set vol=0 to output mixers */
  5837. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5838. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5839. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5840. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5841. /* set up input amps for analog loopback */
  5842. /* Amp Indices: DAC = 0, mixer = 1 */
  5843. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5844. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5845. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5846. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5847. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5848. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5849. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5850. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5851. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5852. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5853. /* FIXME: use matrix-type input source selection */
  5854. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5855. /* Input mixer1 */
  5856. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5857. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5858. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5859. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5860. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5861. /* Input mixer2 */
  5862. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5863. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5864. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5865. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5866. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5867. { }
  5868. };
  5869. /* capture mixer elements */
  5870. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5871. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5872. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5873. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5874. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5875. {
  5876. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5877. /* The multiple "Capture Source" controls confuse alsamixer
  5878. * So call somewhat different..
  5879. * FIXME: the controls appear in the "playback" view!
  5880. */
  5881. /* .name = "Capture Source", */
  5882. .name = "Input Source",
  5883. .count = 2,
  5884. .info = alc882_mux_enum_info,
  5885. .get = alc882_mux_enum_get,
  5886. .put = alc882_mux_enum_put,
  5887. },
  5888. { } /* end */
  5889. };
  5890. /* pcm configuration: identiacal with ALC880 */
  5891. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5892. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5893. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5894. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5895. /*
  5896. * configuration and preset
  5897. */
  5898. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5899. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5900. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5901. [ALC883_3ST_6ch] = "3stack-6ch",
  5902. [ALC883_6ST_DIG] = "6stack-dig",
  5903. [ALC883_TARGA_DIG] = "targa-dig",
  5904. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5905. [ALC883_ACER] = "acer",
  5906. [ALC883_MEDION] = "medion",
  5907. [ALC883_MEDION_MD2] = "medion-md2",
  5908. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5909. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5910. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  5911. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  5912. [ALC888_HP_NETTLE] = "hp-nettle",
  5913. [ALC888_HP_LUCKNOW] = "hp-lucknow",
  5914. [ALC883_AUTO] = "auto",
  5915. };
  5916. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5917. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5918. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  5919. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5920. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5921. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5922. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5923. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5924. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5925. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  5926. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5927. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  5928. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5929. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  5930. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5931. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5932. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5933. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5934. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5935. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5936. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5937. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5938. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5939. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5940. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  5941. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5942. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5943. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5944. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  5945. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5946. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5947. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_HP_NETTLE),
  5948. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_HP_LUCKNOW),
  5949. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  5950. {}
  5951. };
  5952. static struct alc_config_preset alc883_presets[] = {
  5953. [ALC883_3ST_2ch_DIG] = {
  5954. .mixers = { alc883_3ST_2ch_mixer },
  5955. .init_verbs = { alc883_init_verbs },
  5956. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5957. .dac_nids = alc883_dac_nids,
  5958. .dig_out_nid = ALC883_DIGOUT_NID,
  5959. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5960. .adc_nids = alc883_adc_nids,
  5961. .dig_in_nid = ALC883_DIGIN_NID,
  5962. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  5963. .channel_mode = alc883_3ST_2ch_modes,
  5964. .input_mux = &alc883_capture_source,
  5965. },
  5966. [ALC883_3ST_6ch_DIG] = {
  5967. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5968. .init_verbs = { alc883_init_verbs },
  5969. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5970. .dac_nids = alc883_dac_nids,
  5971. .dig_out_nid = ALC883_DIGOUT_NID,
  5972. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5973. .adc_nids = alc883_adc_nids,
  5974. .dig_in_nid = ALC883_DIGIN_NID,
  5975. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5976. .channel_mode = alc883_3ST_6ch_modes,
  5977. .need_dac_fix = 1,
  5978. .input_mux = &alc883_capture_source,
  5979. },
  5980. [ALC883_3ST_6ch] = {
  5981. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  5982. .init_verbs = { alc883_init_verbs },
  5983. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5984. .dac_nids = alc883_dac_nids,
  5985. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5986. .adc_nids = alc883_adc_nids,
  5987. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  5988. .channel_mode = alc883_3ST_6ch_modes,
  5989. .need_dac_fix = 1,
  5990. .input_mux = &alc883_capture_source,
  5991. },
  5992. [ALC883_6ST_DIG] = {
  5993. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  5994. .init_verbs = { alc883_init_verbs },
  5995. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  5996. .dac_nids = alc883_dac_nids,
  5997. .dig_out_nid = ALC883_DIGOUT_NID,
  5998. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  5999. .adc_nids = alc883_adc_nids,
  6000. .dig_in_nid = ALC883_DIGIN_NID,
  6001. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6002. .channel_mode = alc883_sixstack_modes,
  6003. .input_mux = &alc883_capture_source,
  6004. },
  6005. [ALC883_TARGA_DIG] = {
  6006. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6007. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6008. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6009. .dac_nids = alc883_dac_nids,
  6010. .dig_out_nid = ALC883_DIGOUT_NID,
  6011. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6012. .adc_nids = alc883_adc_nids,
  6013. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6014. .channel_mode = alc883_3ST_6ch_modes,
  6015. .need_dac_fix = 1,
  6016. .input_mux = &alc883_capture_source,
  6017. .unsol_event = alc883_tagra_unsol_event,
  6018. .init_hook = alc883_tagra_automute,
  6019. },
  6020. [ALC883_TARGA_2ch_DIG] = {
  6021. .mixers = { alc883_tagra_2ch_mixer},
  6022. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6023. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6024. .dac_nids = alc883_dac_nids,
  6025. .dig_out_nid = ALC883_DIGOUT_NID,
  6026. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6027. .adc_nids = alc883_adc_nids,
  6028. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6029. .channel_mode = alc883_3ST_2ch_modes,
  6030. .input_mux = &alc883_capture_source,
  6031. .unsol_event = alc883_tagra_unsol_event,
  6032. .init_hook = alc883_tagra_automute,
  6033. },
  6034. [ALC883_ACER] = {
  6035. .mixers = { alc883_base_mixer,
  6036. alc883_chmode_mixer },
  6037. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6038. * and the headphone jack. Turn this on and rely on the
  6039. * standard mute methods whenever the user wants to turn
  6040. * these outputs off.
  6041. */
  6042. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6043. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6044. .dac_nids = alc883_dac_nids,
  6045. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6046. .adc_nids = alc883_adc_nids,
  6047. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6048. .channel_mode = alc883_3ST_2ch_modes,
  6049. .input_mux = &alc883_capture_source,
  6050. },
  6051. [ALC883_MEDION] = {
  6052. .mixers = { alc883_fivestack_mixer,
  6053. alc883_chmode_mixer },
  6054. .init_verbs = { alc883_init_verbs,
  6055. alc883_medion_eapd_verbs },
  6056. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6057. .dac_nids = alc883_dac_nids,
  6058. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6059. .adc_nids = alc883_adc_nids,
  6060. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6061. .channel_mode = alc883_sixstack_modes,
  6062. .input_mux = &alc883_capture_source,
  6063. },
  6064. [ALC883_MEDION_MD2] = {
  6065. .mixers = { alc883_medion_md2_mixer},
  6066. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6067. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6068. .dac_nids = alc883_dac_nids,
  6069. .dig_out_nid = ALC883_DIGOUT_NID,
  6070. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6071. .adc_nids = alc883_adc_nids,
  6072. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6073. .channel_mode = alc883_3ST_2ch_modes,
  6074. .input_mux = &alc883_capture_source,
  6075. .unsol_event = alc883_medion_md2_unsol_event,
  6076. .init_hook = alc883_medion_md2_automute,
  6077. },
  6078. [ALC883_LAPTOP_EAPD] = {
  6079. .mixers = { alc883_base_mixer,
  6080. alc883_chmode_mixer },
  6081. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6082. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6083. .dac_nids = alc883_dac_nids,
  6084. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6085. .adc_nids = alc883_adc_nids,
  6086. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6087. .channel_mode = alc883_3ST_2ch_modes,
  6088. .input_mux = &alc883_capture_source,
  6089. },
  6090. [ALC883_LENOVO_101E_2ch] = {
  6091. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6092. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6093. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6094. .dac_nids = alc883_dac_nids,
  6095. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6096. .adc_nids = alc883_adc_nids,
  6097. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6098. .channel_mode = alc883_3ST_2ch_modes,
  6099. .input_mux = &alc883_lenovo_101e_capture_source,
  6100. .unsol_event = alc883_lenovo_101e_unsol_event,
  6101. .init_hook = alc883_lenovo_101e_all_automute,
  6102. },
  6103. [ALC883_LENOVO_NB0763] = {
  6104. .mixers = { alc883_lenovo_nb0763_mixer },
  6105. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6106. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6107. .dac_nids = alc883_dac_nids,
  6108. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6109. .adc_nids = alc883_adc_nids,
  6110. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6111. .channel_mode = alc883_3ST_2ch_modes,
  6112. .need_dac_fix = 1,
  6113. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6114. .unsol_event = alc883_medion_md2_unsol_event,
  6115. .init_hook = alc883_medion_md2_automute,
  6116. },
  6117. [ALC888_LENOVO_MS7195_DIG] = {
  6118. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6119. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6120. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6121. .dac_nids = alc883_dac_nids,
  6122. .dig_out_nid = ALC883_DIGOUT_NID,
  6123. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6124. .adc_nids = alc883_adc_nids,
  6125. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6126. .channel_mode = alc883_3ST_6ch_modes,
  6127. .need_dac_fix = 1,
  6128. .input_mux = &alc883_capture_source,
  6129. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6130. .init_hook = alc888_lenovo_ms7195_front_automute,
  6131. },
  6132. [ALC888_HP_NETTLE] = {
  6133. .mixers = { alc888_hp_nettle_mixer, alc883_chmode_mixer },
  6134. .init_verbs = { alc883_init_verbs, alc888_hp_nettle_verbs },
  6135. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6136. .dac_nids = alc883_dac_nids,
  6137. .dig_out_nid = ALC883_DIGOUT_NID,
  6138. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6139. .adc_nids = alc883_adc_nids,
  6140. .dig_in_nid = ALC883_DIGIN_NID,
  6141. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6142. .channel_mode = alc883_sixstack_modes,
  6143. .input_mux = &alc883_capture_source,
  6144. },
  6145. [ALC888_HP_LUCKNOW] = {
  6146. .mixers = { alc888_hp_lucknow_mixer, alc883_chmode_mixer },
  6147. .init_verbs = { alc883_init_verbs, alc888_hp_lucknow_verbs },
  6148. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6149. .dac_nids = alc883_dac_nids,
  6150. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6151. .adc_nids = alc883_adc_nids,
  6152. .num_channel_mode = ARRAY_SIZE(alc888_hp_lucknow_modes),
  6153. .channel_mode = alc888_hp_lucknow_modes,
  6154. .need_dac_fix = 1,
  6155. .input_mux = &alc883_capture_source,
  6156. },
  6157. };
  6158. /*
  6159. * BIOS auto configuration
  6160. */
  6161. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6162. hda_nid_t nid, int pin_type,
  6163. int dac_idx)
  6164. {
  6165. /* set as output */
  6166. struct alc_spec *spec = codec->spec;
  6167. int idx;
  6168. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6169. idx = 4;
  6170. else
  6171. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6172. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6173. pin_type);
  6174. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6175. AMP_OUT_UNMUTE);
  6176. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6177. }
  6178. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6179. {
  6180. struct alc_spec *spec = codec->spec;
  6181. int i;
  6182. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6183. for (i = 0; i <= HDA_SIDE; i++) {
  6184. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6185. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6186. if (nid)
  6187. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6188. i);
  6189. }
  6190. }
  6191. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6192. {
  6193. struct alc_spec *spec = codec->spec;
  6194. hda_nid_t pin;
  6195. pin = spec->autocfg.hp_pins[0];
  6196. if (pin) /* connect to front */
  6197. /* use dac 0 */
  6198. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6199. }
  6200. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6201. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6202. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6203. {
  6204. struct alc_spec *spec = codec->spec;
  6205. int i;
  6206. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6207. hda_nid_t nid = spec->autocfg.input_pins[i];
  6208. if (alc883_is_input_pin(nid)) {
  6209. snd_hda_codec_write(codec, nid, 0,
  6210. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6211. (i <= AUTO_PIN_FRONT_MIC ?
  6212. PIN_VREF80 : PIN_IN));
  6213. if (nid != ALC883_PIN_CD_NID)
  6214. snd_hda_codec_write(codec, nid, 0,
  6215. AC_VERB_SET_AMP_GAIN_MUTE,
  6216. AMP_OUT_MUTE);
  6217. }
  6218. }
  6219. }
  6220. /* almost identical with ALC880 parser... */
  6221. static int alc883_parse_auto_config(struct hda_codec *codec)
  6222. {
  6223. struct alc_spec *spec = codec->spec;
  6224. int err = alc880_parse_auto_config(codec);
  6225. if (err < 0)
  6226. return err;
  6227. else if (err > 0)
  6228. /* hack - override the init verbs */
  6229. spec->init_verbs[0] = alc883_auto_init_verbs;
  6230. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6231. spec->num_mixers++;
  6232. return err;
  6233. }
  6234. /* additional initialization for auto-configuration model */
  6235. static void alc883_auto_init(struct hda_codec *codec)
  6236. {
  6237. alc883_auto_init_multi_out(codec);
  6238. alc883_auto_init_hp_out(codec);
  6239. alc883_auto_init_analog_input(codec);
  6240. }
  6241. static int patch_alc883(struct hda_codec *codec)
  6242. {
  6243. struct alc_spec *spec;
  6244. int err, board_config;
  6245. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6246. if (spec == NULL)
  6247. return -ENOMEM;
  6248. codec->spec = spec;
  6249. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6250. alc883_models,
  6251. alc883_cfg_tbl);
  6252. if (board_config < 0) {
  6253. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6254. "trying auto-probe from BIOS...\n");
  6255. board_config = ALC883_AUTO;
  6256. }
  6257. if (board_config == ALC883_AUTO) {
  6258. /* automatic parse from the BIOS config */
  6259. err = alc883_parse_auto_config(codec);
  6260. if (err < 0) {
  6261. alc_free(codec);
  6262. return err;
  6263. } else if (!err) {
  6264. printk(KERN_INFO
  6265. "hda_codec: Cannot set up configuration "
  6266. "from BIOS. Using base mode...\n");
  6267. board_config = ALC883_3ST_2ch_DIG;
  6268. }
  6269. }
  6270. if (board_config != ALC883_AUTO)
  6271. setup_preset(spec, &alc883_presets[board_config]);
  6272. spec->stream_name_analog = "ALC883 Analog";
  6273. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6274. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6275. spec->stream_name_digital = "ALC883 Digital";
  6276. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6277. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6278. if (!spec->adc_nids && spec->input_mux) {
  6279. spec->adc_nids = alc883_adc_nids;
  6280. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6281. }
  6282. codec->patch_ops = alc_patch_ops;
  6283. if (board_config == ALC883_AUTO)
  6284. spec->init_hook = alc883_auto_init;
  6285. return 0;
  6286. }
  6287. /*
  6288. * ALC262 support
  6289. */
  6290. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6291. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6292. #define alc262_dac_nids alc260_dac_nids
  6293. #define alc262_adc_nids alc882_adc_nids
  6294. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6295. #define alc262_modes alc260_modes
  6296. #define alc262_capture_source alc882_capture_source
  6297. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6298. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6299. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6300. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6301. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6302. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6303. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6304. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6305. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6306. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6307. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6308. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6309. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6310. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6311. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6312. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6313. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6314. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6315. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6316. { } /* end */
  6317. };
  6318. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6319. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6320. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6321. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6322. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6323. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6324. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6325. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6326. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6327. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6328. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6329. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6330. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6331. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6332. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6333. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6334. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6335. { } /* end */
  6336. };
  6337. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6338. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6339. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6340. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6341. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6342. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6343. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6344. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6345. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6346. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6347. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6348. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6349. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6350. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6351. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6352. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6353. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6354. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6355. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6356. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6357. { } /* end */
  6358. };
  6359. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6360. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6361. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6362. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6363. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6364. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6365. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6366. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6367. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6368. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6369. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6370. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6371. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6372. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6373. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6374. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6375. { } /* end */
  6376. };
  6377. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6378. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6379. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6380. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6381. { } /* end */
  6382. };
  6383. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6384. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6385. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6386. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6387. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6388. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6389. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6390. { } /* end */
  6391. };
  6392. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6393. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6394. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6395. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6396. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6397. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6398. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6399. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6400. { } /* end */
  6401. };
  6402. #define alc262_capture_mixer alc882_capture_mixer
  6403. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6404. /*
  6405. * generic initialization of ADC, input mixers and output mixers
  6406. */
  6407. static struct hda_verb alc262_init_verbs[] = {
  6408. /*
  6409. * Unmute ADC0-2 and set the default input to mic-in
  6410. */
  6411. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6412. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6413. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6414. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6415. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6416. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6417. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6418. * mixer widget
  6419. * Note: PASD motherboards uses the Line In 2 as the input for
  6420. * front panel mic (mic 2)
  6421. */
  6422. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6423. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6424. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6425. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6426. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6427. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6428. /*
  6429. * Set up output mixers (0x0c - 0x0e)
  6430. */
  6431. /* set vol=0 to output mixers */
  6432. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6433. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6434. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6435. /* set up input amps for analog loopback */
  6436. /* Amp Indices: DAC = 0, mixer = 1 */
  6437. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6438. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6439. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6440. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6441. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6442. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6443. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6444. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6445. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6446. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6447. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6448. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6449. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6450. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6451. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6452. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6453. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6454. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6455. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6456. /* FIXME: use matrix-type input source selection */
  6457. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6458. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6459. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6460. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6461. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6462. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6463. /* Input mixer2 */
  6464. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6465. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6466. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6467. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6468. /* Input mixer3 */
  6469. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6470. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6471. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6472. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6473. { }
  6474. };
  6475. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6476. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6477. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6478. {}
  6479. };
  6480. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6481. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6482. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6483. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6484. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6485. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6486. {}
  6487. };
  6488. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6489. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6490. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6491. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6492. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6493. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6494. };
  6495. /* mute/unmute internal speaker according to the hp jack and mute state */
  6496. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  6497. {
  6498. struct alc_spec *spec = codec->spec;
  6499. unsigned int mute;
  6500. if (force || !spec->sense_updated) {
  6501. unsigned int present;
  6502. /* need to execute and sync at first */
  6503. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6504. present = snd_hda_codec_read(codec, 0x15, 0,
  6505. AC_VERB_GET_PIN_SENSE, 0);
  6506. spec->jack_present = (present & 0x80000000) != 0;
  6507. spec->sense_updated = 1;
  6508. }
  6509. if (spec->jack_present) {
  6510. /* mute internal speaker */
  6511. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6512. 0x80, 0x80);
  6513. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6514. 0x80, 0x80);
  6515. } else {
  6516. /* unmute internal speaker if necessary */
  6517. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6518. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6519. 0x80, mute & 0x80);
  6520. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6521. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6522. 0x80, mute & 0x80);
  6523. }
  6524. }
  6525. /* unsolicited event for HP jack sensing */
  6526. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6527. unsigned int res)
  6528. {
  6529. if ((res >> 26) != ALC880_HP_EVENT)
  6530. return;
  6531. alc262_hippo_automute(codec, 1);
  6532. }
  6533. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  6534. {
  6535. struct alc_spec *spec = codec->spec;
  6536. unsigned int mute;
  6537. if (force || !spec->sense_updated) {
  6538. unsigned int present;
  6539. /* need to execute and sync at first */
  6540. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6541. present = snd_hda_codec_read(codec, 0x1b, 0,
  6542. AC_VERB_GET_PIN_SENSE, 0);
  6543. spec->jack_present = (present & 0x80000000) != 0;
  6544. spec->sense_updated = 1;
  6545. }
  6546. if (spec->jack_present) {
  6547. /* mute internal speaker */
  6548. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6549. 0x80, 0x80);
  6550. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6551. 0x80, 0x80);
  6552. } else {
  6553. /* unmute internal speaker if necessary */
  6554. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6555. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6556. 0x80, mute & 0x80);
  6557. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6558. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6559. 0x80, mute & 0x80);
  6560. }
  6561. }
  6562. /* unsolicited event for HP jack sensing */
  6563. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6564. unsigned int res)
  6565. {
  6566. if ((res >> 26) != ALC880_HP_EVENT)
  6567. return;
  6568. alc262_hippo1_automute(codec, 1);
  6569. }
  6570. /*
  6571. * fujitsu model
  6572. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6573. */
  6574. #define ALC_HP_EVENT 0x37
  6575. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6576. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6577. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6578. {}
  6579. };
  6580. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6581. .num_items = 2,
  6582. .items = {
  6583. { "Mic", 0x0 },
  6584. { "CD", 0x4 },
  6585. },
  6586. };
  6587. static struct hda_input_mux alc262_HP_capture_source = {
  6588. .num_items = 5,
  6589. .items = {
  6590. { "Mic", 0x0 },
  6591. { "Front Mic", 0x3 },
  6592. { "Line", 0x2 },
  6593. { "CD", 0x4 },
  6594. { "AUX IN", 0x6 },
  6595. },
  6596. };
  6597. /* mute/unmute internal speaker according to the hp jack and mute state */
  6598. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6599. {
  6600. struct alc_spec *spec = codec->spec;
  6601. unsigned int mute;
  6602. if (force || !spec->sense_updated) {
  6603. unsigned int present;
  6604. /* need to execute and sync at first */
  6605. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6606. present = snd_hda_codec_read(codec, 0x14, 0,
  6607. AC_VERB_GET_PIN_SENSE, 0);
  6608. spec->jack_present = (present & 0x80000000) != 0;
  6609. spec->sense_updated = 1;
  6610. }
  6611. if (spec->jack_present) {
  6612. /* mute internal speaker */
  6613. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6614. 0x80, 0x80);
  6615. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6616. 0x80, 0x80);
  6617. } else {
  6618. /* unmute internal speaker if necessary */
  6619. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6620. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6621. 0x80, mute & 0x80);
  6622. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6623. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6624. 0x80, mute & 0x80);
  6625. }
  6626. }
  6627. /* unsolicited event for HP jack sensing */
  6628. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6629. unsigned int res)
  6630. {
  6631. if ((res >> 26) != ALC_HP_EVENT)
  6632. return;
  6633. alc262_fujitsu_automute(codec, 1);
  6634. }
  6635. /* bind volumes of both NID 0x0c and 0x0d */
  6636. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6637. struct snd_ctl_elem_value *ucontrol)
  6638. {
  6639. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6640. long *valp = ucontrol->value.integer.value;
  6641. int change;
  6642. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6643. 0x7f, valp[0] & 0x7f);
  6644. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6645. 0x7f, valp[1] & 0x7f);
  6646. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6647. 0x7f, valp[0] & 0x7f);
  6648. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6649. 0x7f, valp[1] & 0x7f);
  6650. return change;
  6651. }
  6652. /* bind hp and internal speaker mute (with plug check) */
  6653. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6654. struct snd_ctl_elem_value *ucontrol)
  6655. {
  6656. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6657. long *valp = ucontrol->value.integer.value;
  6658. int change;
  6659. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6660. 0x80, valp[0] ? 0 : 0x80);
  6661. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6662. 0x80, valp[1] ? 0 : 0x80);
  6663. if (change || codec->in_resume)
  6664. alc262_fujitsu_automute(codec, codec->in_resume);
  6665. return change;
  6666. }
  6667. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6668. {
  6669. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6670. .name = "Master Playback Volume",
  6671. .info = snd_hda_mixer_amp_volume_info,
  6672. .get = snd_hda_mixer_amp_volume_get,
  6673. .put = alc262_fujitsu_master_vol_put,
  6674. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6675. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6676. },
  6677. {
  6678. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6679. .name = "Master Playback Switch",
  6680. .info = snd_hda_mixer_amp_switch_info,
  6681. .get = snd_hda_mixer_amp_switch_get,
  6682. .put = alc262_fujitsu_master_sw_put,
  6683. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6684. },
  6685. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6686. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6687. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6688. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6689. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6690. { } /* end */
  6691. };
  6692. /* additional init verbs for Benq laptops */
  6693. static struct hda_verb alc262_EAPD_verbs[] = {
  6694. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6695. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6696. {}
  6697. };
  6698. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  6699. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6700. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6701. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6702. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6703. {}
  6704. };
  6705. /* add playback controls from the parsed DAC table */
  6706. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6707. const struct auto_pin_cfg *cfg)
  6708. {
  6709. hda_nid_t nid;
  6710. int err;
  6711. spec->multiout.num_dacs = 1; /* only use one dac */
  6712. spec->multiout.dac_nids = spec->private_dac_nids;
  6713. spec->multiout.dac_nids[0] = 2;
  6714. nid = cfg->line_out_pins[0];
  6715. if (nid) {
  6716. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6717. "Front Playback Volume",
  6718. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6719. if (err < 0)
  6720. return err;
  6721. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6722. "Front Playback Switch",
  6723. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6724. if (err < 0)
  6725. return err;
  6726. }
  6727. nid = cfg->speaker_pins[0];
  6728. if (nid) {
  6729. if (nid == 0x16) {
  6730. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6731. "Speaker Playback Volume",
  6732. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6733. HDA_OUTPUT));
  6734. if (err < 0)
  6735. return err;
  6736. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6737. "Speaker Playback Switch",
  6738. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6739. HDA_OUTPUT));
  6740. if (err < 0)
  6741. return err;
  6742. } else {
  6743. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6744. "Speaker Playback Switch",
  6745. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6746. HDA_OUTPUT));
  6747. if (err < 0)
  6748. return err;
  6749. }
  6750. }
  6751. nid = cfg->hp_pins[0];
  6752. if (nid) {
  6753. /* spec->multiout.hp_nid = 2; */
  6754. if (nid == 0x16) {
  6755. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6756. "Headphone Playback Volume",
  6757. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6758. HDA_OUTPUT));
  6759. if (err < 0)
  6760. return err;
  6761. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6762. "Headphone Playback Switch",
  6763. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6764. HDA_OUTPUT));
  6765. if (err < 0)
  6766. return err;
  6767. } else {
  6768. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6769. "Headphone Playback Switch",
  6770. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6771. HDA_OUTPUT));
  6772. if (err < 0)
  6773. return err;
  6774. }
  6775. }
  6776. return 0;
  6777. }
  6778. /* identical with ALC880 */
  6779. #define alc262_auto_create_analog_input_ctls \
  6780. alc880_auto_create_analog_input_ctls
  6781. /*
  6782. * generic initialization of ADC, input mixers and output mixers
  6783. */
  6784. static struct hda_verb alc262_volume_init_verbs[] = {
  6785. /*
  6786. * Unmute ADC0-2 and set the default input to mic-in
  6787. */
  6788. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6789. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6790. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6791. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6792. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6793. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6794. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6795. * mixer widget
  6796. * Note: PASD motherboards uses the Line In 2 as the input for
  6797. * front panel mic (mic 2)
  6798. */
  6799. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6800. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6801. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6802. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6803. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6804. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6805. /*
  6806. * Set up output mixers (0x0c - 0x0f)
  6807. */
  6808. /* set vol=0 to output mixers */
  6809. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6810. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6811. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6812. /* set up input amps for analog loopback */
  6813. /* Amp Indices: DAC = 0, mixer = 1 */
  6814. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6815. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6816. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6817. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6818. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6819. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6820. /* FIXME: use matrix-type input source selection */
  6821. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6822. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6823. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6824. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6825. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6826. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6827. /* Input mixer2 */
  6828. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6829. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6830. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6831. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6832. /* Input mixer3 */
  6833. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6834. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6835. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6836. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6837. { }
  6838. };
  6839. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6840. /*
  6841. * Unmute ADC0-2 and set the default input to mic-in
  6842. */
  6843. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6844. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6845. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6846. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6847. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6848. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6849. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6850. * mixer widget
  6851. * Note: PASD motherboards uses the Line In 2 as the input for
  6852. * front panel mic (mic 2)
  6853. */
  6854. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6855. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6856. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6857. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6858. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6859. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6860. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6861. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6862. /*
  6863. * Set up output mixers (0x0c - 0x0e)
  6864. */
  6865. /* set vol=0 to output mixers */
  6866. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6867. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6868. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6869. /* set up input amps for analog loopback */
  6870. /* Amp Indices: DAC = 0, mixer = 1 */
  6871. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6872. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6873. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6874. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6875. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6876. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6877. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6878. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6879. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6880. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6881. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6882. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6883. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6884. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6885. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6886. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6887. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6888. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6889. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6890. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6891. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6892. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6893. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6894. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6895. /* FIXME: use matrix-type input source selection */
  6896. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6897. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6898. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6899. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6900. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6901. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6902. /* Input mixer2 */
  6903. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6904. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6905. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6906. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6907. /* Input mixer3 */
  6908. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6909. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6910. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6911. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6912. { }
  6913. };
  6914. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6915. /*
  6916. * Unmute ADC0-2 and set the default input to mic-in
  6917. */
  6918. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6919. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6920. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6921. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6922. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6923. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6924. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6925. * mixer widget
  6926. * Note: PASD motherboards uses the Line In 2 as the input for front
  6927. * panel mic (mic 2)
  6928. */
  6929. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6930. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6931. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6932. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6933. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6934. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6935. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6936. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6937. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6938. /*
  6939. * Set up output mixers (0x0c - 0x0e)
  6940. */
  6941. /* set vol=0 to output mixers */
  6942. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6943. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6944. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6945. /* set up input amps for analog loopback */
  6946. /* Amp Indices: DAC = 0, mixer = 1 */
  6947. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6948. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6949. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6950. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6951. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6952. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6953. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  6954. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  6955. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  6956. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  6957. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  6958. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  6959. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  6960. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6961. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6962. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6963. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6964. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  6965. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6966. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6967. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6968. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6969. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6970. /* FIXME: use matrix-type input source selection */
  6971. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6972. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6973. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  6974. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  6975. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  6976. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  6977. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  6978. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6979. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  6980. /* Input mixer2 */
  6981. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6982. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6983. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6984. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6985. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6986. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6987. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6988. /* Input mixer3 */
  6989. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6990. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  6991. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6992. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6993. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6994. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  6995. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  6996. { }
  6997. };
  6998. /* pcm configuration: identiacal with ALC880 */
  6999. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7000. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7001. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7002. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7003. /*
  7004. * BIOS auto configuration
  7005. */
  7006. static int alc262_parse_auto_config(struct hda_codec *codec)
  7007. {
  7008. struct alc_spec *spec = codec->spec;
  7009. int err;
  7010. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7011. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7012. alc262_ignore);
  7013. if (err < 0)
  7014. return err;
  7015. if (!spec->autocfg.line_outs)
  7016. return 0; /* can't find valid BIOS pin config */
  7017. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7018. if (err < 0)
  7019. return err;
  7020. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7021. if (err < 0)
  7022. return err;
  7023. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7024. if (spec->autocfg.dig_out_pin)
  7025. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7026. if (spec->autocfg.dig_in_pin)
  7027. spec->dig_in_nid = ALC262_DIGIN_NID;
  7028. if (spec->kctl_alloc)
  7029. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7030. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7031. spec->num_mux_defs = 1;
  7032. spec->input_mux = &spec->private_imux;
  7033. return 1;
  7034. }
  7035. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7036. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7037. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7038. /* init callback for auto-configuration model -- overriding the default init */
  7039. static void alc262_auto_init(struct hda_codec *codec)
  7040. {
  7041. alc262_auto_init_multi_out(codec);
  7042. alc262_auto_init_hp_out(codec);
  7043. alc262_auto_init_analog_input(codec);
  7044. }
  7045. /*
  7046. * configuration and preset
  7047. */
  7048. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7049. [ALC262_BASIC] = "basic",
  7050. [ALC262_HIPPO] = "hippo",
  7051. [ALC262_HIPPO_1] = "hippo_1",
  7052. [ALC262_FUJITSU] = "fujitsu",
  7053. [ALC262_HP_BPC] = "hp-bpc",
  7054. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7055. [ALC262_BENQ_ED8] = "benq",
  7056. [ALC262_BENQ_T31] = "benq-t31",
  7057. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7058. [ALC262_AUTO] = "auto",
  7059. };
  7060. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7061. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7062. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7063. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7064. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7065. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7066. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7067. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7068. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7069. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7070. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7071. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7072. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7073. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7074. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7075. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7076. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7077. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7078. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7079. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7080. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7081. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7082. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7083. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7084. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7085. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7086. {}
  7087. };
  7088. static struct alc_config_preset alc262_presets[] = {
  7089. [ALC262_BASIC] = {
  7090. .mixers = { alc262_base_mixer },
  7091. .init_verbs = { alc262_init_verbs },
  7092. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7093. .dac_nids = alc262_dac_nids,
  7094. .hp_nid = 0x03,
  7095. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7096. .channel_mode = alc262_modes,
  7097. .input_mux = &alc262_capture_source,
  7098. },
  7099. [ALC262_HIPPO] = {
  7100. .mixers = { alc262_base_mixer },
  7101. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7102. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7103. .dac_nids = alc262_dac_nids,
  7104. .hp_nid = 0x03,
  7105. .dig_out_nid = ALC262_DIGOUT_NID,
  7106. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7107. .channel_mode = alc262_modes,
  7108. .input_mux = &alc262_capture_source,
  7109. .unsol_event = alc262_hippo_unsol_event,
  7110. },
  7111. [ALC262_HIPPO_1] = {
  7112. .mixers = { alc262_hippo1_mixer },
  7113. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7114. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7115. .dac_nids = alc262_dac_nids,
  7116. .hp_nid = 0x02,
  7117. .dig_out_nid = ALC262_DIGOUT_NID,
  7118. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7119. .channel_mode = alc262_modes,
  7120. .input_mux = &alc262_capture_source,
  7121. .unsol_event = alc262_hippo1_unsol_event,
  7122. },
  7123. [ALC262_FUJITSU] = {
  7124. .mixers = { alc262_fujitsu_mixer },
  7125. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7126. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7127. .dac_nids = alc262_dac_nids,
  7128. .hp_nid = 0x03,
  7129. .dig_out_nid = ALC262_DIGOUT_NID,
  7130. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7131. .channel_mode = alc262_modes,
  7132. .input_mux = &alc262_fujitsu_capture_source,
  7133. .unsol_event = alc262_fujitsu_unsol_event,
  7134. },
  7135. [ALC262_HP_BPC] = {
  7136. .mixers = { alc262_HP_BPC_mixer },
  7137. .init_verbs = { alc262_HP_BPC_init_verbs },
  7138. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7139. .dac_nids = alc262_dac_nids,
  7140. .hp_nid = 0x03,
  7141. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7142. .channel_mode = alc262_modes,
  7143. .input_mux = &alc262_HP_capture_source,
  7144. },
  7145. [ALC262_HP_BPC_D7000_WF] = {
  7146. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7147. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7148. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7149. .dac_nids = alc262_dac_nids,
  7150. .hp_nid = 0x03,
  7151. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7152. .channel_mode = alc262_modes,
  7153. .input_mux = &alc262_HP_capture_source,
  7154. },
  7155. [ALC262_HP_BPC_D7000_WL] = {
  7156. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7157. alc262_HP_BPC_WildWest_option_mixer },
  7158. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7159. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7160. .dac_nids = alc262_dac_nids,
  7161. .hp_nid = 0x03,
  7162. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7163. .channel_mode = alc262_modes,
  7164. .input_mux = &alc262_HP_capture_source,
  7165. },
  7166. [ALC262_BENQ_ED8] = {
  7167. .mixers = { alc262_base_mixer },
  7168. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7169. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7170. .dac_nids = alc262_dac_nids,
  7171. .hp_nid = 0x03,
  7172. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7173. .channel_mode = alc262_modes,
  7174. .input_mux = &alc262_capture_source,
  7175. },
  7176. [ALC262_SONY_ASSAMD] = {
  7177. .mixers = { alc262_sony_mixer },
  7178. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7179. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7180. .dac_nids = alc262_dac_nids,
  7181. .hp_nid = 0x02,
  7182. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7183. .channel_mode = alc262_modes,
  7184. .input_mux = &alc262_capture_source,
  7185. .unsol_event = alc262_hippo_unsol_event,
  7186. },
  7187. [ALC262_BENQ_T31] = {
  7188. .mixers = { alc262_benq_t31_mixer },
  7189. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7190. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7191. .dac_nids = alc262_dac_nids,
  7192. .hp_nid = 0x03,
  7193. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7194. .channel_mode = alc262_modes,
  7195. .input_mux = &alc262_capture_source,
  7196. .unsol_event = alc262_hippo_unsol_event,
  7197. },
  7198. };
  7199. static int patch_alc262(struct hda_codec *codec)
  7200. {
  7201. struct alc_spec *spec;
  7202. int board_config;
  7203. int err;
  7204. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7205. if (spec == NULL)
  7206. return -ENOMEM;
  7207. codec->spec = spec;
  7208. #if 0
  7209. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7210. * under-run
  7211. */
  7212. {
  7213. int tmp;
  7214. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7215. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7216. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7217. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7218. }
  7219. #endif
  7220. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7221. alc262_models,
  7222. alc262_cfg_tbl);
  7223. if (board_config < 0) {
  7224. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7225. "trying auto-probe from BIOS...\n");
  7226. board_config = ALC262_AUTO;
  7227. }
  7228. if (board_config == ALC262_AUTO) {
  7229. /* automatic parse from the BIOS config */
  7230. err = alc262_parse_auto_config(codec);
  7231. if (err < 0) {
  7232. alc_free(codec);
  7233. return err;
  7234. } else if (!err) {
  7235. printk(KERN_INFO
  7236. "hda_codec: Cannot set up configuration "
  7237. "from BIOS. Using base mode...\n");
  7238. board_config = ALC262_BASIC;
  7239. }
  7240. }
  7241. if (board_config != ALC262_AUTO)
  7242. setup_preset(spec, &alc262_presets[board_config]);
  7243. spec->stream_name_analog = "ALC262 Analog";
  7244. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7245. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7246. spec->stream_name_digital = "ALC262 Digital";
  7247. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7248. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7249. if (!spec->adc_nids && spec->input_mux) {
  7250. /* check whether NID 0x07 is valid */
  7251. unsigned int wcap = get_wcaps(codec, 0x07);
  7252. /* get type */
  7253. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7254. if (wcap != AC_WID_AUD_IN) {
  7255. spec->adc_nids = alc262_adc_nids_alt;
  7256. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7257. spec->mixers[spec->num_mixers] =
  7258. alc262_capture_alt_mixer;
  7259. spec->num_mixers++;
  7260. } else {
  7261. spec->adc_nids = alc262_adc_nids;
  7262. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7263. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7264. spec->num_mixers++;
  7265. }
  7266. }
  7267. codec->patch_ops = alc_patch_ops;
  7268. if (board_config == ALC262_AUTO)
  7269. spec->init_hook = alc262_auto_init;
  7270. return 0;
  7271. }
  7272. /*
  7273. * ALC268 channel source setting (2 channel)
  7274. */
  7275. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7276. #define alc268_modes alc260_modes
  7277. static hda_nid_t alc268_dac_nids[2] = {
  7278. /* front, hp */
  7279. 0x02, 0x03
  7280. };
  7281. static hda_nid_t alc268_adc_nids[2] = {
  7282. /* ADC0-1 */
  7283. 0x08, 0x07
  7284. };
  7285. static hda_nid_t alc268_adc_nids_alt[1] = {
  7286. /* ADC0 */
  7287. 0x08
  7288. };
  7289. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7290. /* output mixer control */
  7291. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7292. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7293. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7294. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7295. { }
  7296. };
  7297. /*
  7298. * generic initialization of ADC, input mixers and output mixers
  7299. */
  7300. static struct hda_verb alc268_base_init_verbs[] = {
  7301. /* Unmute DAC0-1 and set vol = 0 */
  7302. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7303. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7304. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7305. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7306. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7307. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7308. /*
  7309. * Set up output mixers (0x0c - 0x0e)
  7310. */
  7311. /* set vol=0 to output mixers */
  7312. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7313. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7314. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7315. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7316. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7317. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7318. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7319. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7320. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7321. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7322. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7323. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7324. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7325. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7326. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7327. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7328. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7329. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7330. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7331. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7332. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7333. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7334. /* FIXME: use matrix-type input source selection */
  7335. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7336. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7337. /* Input mixer2 */
  7338. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7339. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7340. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7341. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7342. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7343. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7344. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7345. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7346. { }
  7347. };
  7348. /*
  7349. * generic initialization of ADC, input mixers and output mixers
  7350. */
  7351. static struct hda_verb alc268_volume_init_verbs[] = {
  7352. /* set output DAC */
  7353. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7354. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7355. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7356. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7357. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7358. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7359. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7360. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7361. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7362. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7363. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7364. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7365. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7366. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7367. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7368. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7369. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7370. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7371. /* set PCBEEP vol = 0 */
  7372. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7373. { }
  7374. };
  7375. #define alc268_mux_enum_info alc_mux_enum_info
  7376. #define alc268_mux_enum_get alc_mux_enum_get
  7377. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7378. struct snd_ctl_elem_value *ucontrol)
  7379. {
  7380. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7381. struct alc_spec *spec = codec->spec;
  7382. const struct hda_input_mux *imux = spec->input_mux;
  7383. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7384. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7385. hda_nid_t nid = capture_mixers[adc_idx];
  7386. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7387. unsigned int i, idx;
  7388. idx = ucontrol->value.enumerated.item[0];
  7389. if (idx >= imux->num_items)
  7390. idx = imux->num_items - 1;
  7391. if (*cur_val == idx && !codec->in_resume)
  7392. return 0;
  7393. for (i = 0; i < imux->num_items; i++) {
  7394. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7395. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7396. v | (imux->items[i].index << 8));
  7397. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
  7398. idx );
  7399. }
  7400. *cur_val = idx;
  7401. return 1;
  7402. }
  7403. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7404. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7405. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7406. {
  7407. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7408. /* The multiple "Capture Source" controls confuse alsamixer
  7409. * So call somewhat different..
  7410. * FIXME: the controls appear in the "playback" view!
  7411. */
  7412. /* .name = "Capture Source", */
  7413. .name = "Input Source",
  7414. .count = 1,
  7415. .info = alc268_mux_enum_info,
  7416. .get = alc268_mux_enum_get,
  7417. .put = alc268_mux_enum_put,
  7418. },
  7419. { } /* end */
  7420. };
  7421. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7422. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7423. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7424. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7425. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7426. {
  7427. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7428. /* The multiple "Capture Source" controls confuse alsamixer
  7429. * So call somewhat different..
  7430. * FIXME: the controls appear in the "playback" view!
  7431. */
  7432. /* .name = "Capture Source", */
  7433. .name = "Input Source",
  7434. .count = 2,
  7435. .info = alc268_mux_enum_info,
  7436. .get = alc268_mux_enum_get,
  7437. .put = alc268_mux_enum_put,
  7438. },
  7439. { } /* end */
  7440. };
  7441. static struct hda_input_mux alc268_capture_source = {
  7442. .num_items = 4,
  7443. .items = {
  7444. { "Mic", 0x0 },
  7445. { "Front Mic", 0x1 },
  7446. { "Line", 0x2 },
  7447. { "CD", 0x3 },
  7448. },
  7449. };
  7450. /* create input playback/capture controls for the given pin */
  7451. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7452. const char *ctlname, int idx)
  7453. {
  7454. char name[32];
  7455. int err;
  7456. sprintf(name, "%s Playback Volume", ctlname);
  7457. if (nid == 0x14) {
  7458. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7459. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7460. HDA_OUTPUT));
  7461. if (err < 0)
  7462. return err;
  7463. } else if (nid == 0x15) {
  7464. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7465. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7466. HDA_OUTPUT));
  7467. if (err < 0)
  7468. return err;
  7469. } else
  7470. return -1;
  7471. sprintf(name, "%s Playback Switch", ctlname);
  7472. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7473. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7474. if (err < 0)
  7475. return err;
  7476. return 0;
  7477. }
  7478. /* add playback controls from the parsed DAC table */
  7479. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7480. const struct auto_pin_cfg *cfg)
  7481. {
  7482. hda_nid_t nid;
  7483. int err;
  7484. spec->multiout.num_dacs = 2; /* only use one dac */
  7485. spec->multiout.dac_nids = spec->private_dac_nids;
  7486. spec->multiout.dac_nids[0] = 2;
  7487. spec->multiout.dac_nids[1] = 3;
  7488. nid = cfg->line_out_pins[0];
  7489. if (nid)
  7490. alc268_new_analog_output(spec, nid, "Front", 0);
  7491. nid = cfg->speaker_pins[0];
  7492. if (nid == 0x1d) {
  7493. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7494. "Speaker Playback Volume",
  7495. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7496. if (err < 0)
  7497. return err;
  7498. }
  7499. nid = cfg->hp_pins[0];
  7500. if (nid)
  7501. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7502. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7503. if (nid == 0x16) {
  7504. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7505. "Mono Playback Switch",
  7506. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7507. if (err < 0)
  7508. return err;
  7509. }
  7510. return 0;
  7511. }
  7512. /* create playback/capture controls for input pins */
  7513. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7514. const struct auto_pin_cfg *cfg)
  7515. {
  7516. struct hda_input_mux *imux = &spec->private_imux;
  7517. int i, idx1;
  7518. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7519. switch(cfg->input_pins[i]) {
  7520. case 0x18:
  7521. idx1 = 0; /* Mic 1 */
  7522. break;
  7523. case 0x19:
  7524. idx1 = 1; /* Mic 2 */
  7525. break;
  7526. case 0x1a:
  7527. idx1 = 2; /* Line In */
  7528. break;
  7529. case 0x1c:
  7530. idx1 = 3; /* CD */
  7531. break;
  7532. default:
  7533. continue;
  7534. }
  7535. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7536. imux->items[imux->num_items].index = idx1;
  7537. imux->num_items++;
  7538. }
  7539. return 0;
  7540. }
  7541. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7542. {
  7543. struct alc_spec *spec = codec->spec;
  7544. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7545. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7546. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7547. unsigned int dac_vol1, dac_vol2;
  7548. if (speaker_nid) {
  7549. snd_hda_codec_write(codec, speaker_nid, 0,
  7550. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7551. snd_hda_codec_write(codec, 0x0f, 0,
  7552. AC_VERB_SET_AMP_GAIN_MUTE,
  7553. AMP_IN_UNMUTE(1));
  7554. snd_hda_codec_write(codec, 0x10, 0,
  7555. AC_VERB_SET_AMP_GAIN_MUTE,
  7556. AMP_IN_UNMUTE(1));
  7557. } else {
  7558. snd_hda_codec_write(codec, 0x0f, 0,
  7559. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7560. snd_hda_codec_write(codec, 0x10, 0,
  7561. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7562. }
  7563. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7564. if (line_nid == 0x14)
  7565. dac_vol2 = AMP_OUT_ZERO;
  7566. else if (line_nid == 0x15)
  7567. dac_vol1 = AMP_OUT_ZERO;
  7568. if (hp_nid == 0x14)
  7569. dac_vol2 = AMP_OUT_ZERO;
  7570. else if (hp_nid == 0x15)
  7571. dac_vol1 = AMP_OUT_ZERO;
  7572. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7573. spec->autocfg.line_out_pins[1] != 0x16 ||
  7574. spec->autocfg.line_out_pins[2] != 0x16)
  7575. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7576. snd_hda_codec_write(codec, 0x02, 0,
  7577. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7578. snd_hda_codec_write(codec, 0x03, 0,
  7579. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7580. }
  7581. /* pcm configuration: identiacal with ALC880 */
  7582. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7583. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7584. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7585. /*
  7586. * BIOS auto configuration
  7587. */
  7588. static int alc268_parse_auto_config(struct hda_codec *codec)
  7589. {
  7590. struct alc_spec *spec = codec->spec;
  7591. int err;
  7592. static hda_nid_t alc268_ignore[] = { 0 };
  7593. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7594. alc268_ignore);
  7595. if (err < 0)
  7596. return err;
  7597. if (!spec->autocfg.line_outs)
  7598. return 0; /* can't find valid BIOS pin config */
  7599. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7600. if (err < 0)
  7601. return err;
  7602. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7603. if (err < 0)
  7604. return err;
  7605. spec->multiout.max_channels = 2;
  7606. /* digital only support output */
  7607. if (spec->autocfg.dig_out_pin)
  7608. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7609. if (spec->kctl_alloc)
  7610. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7611. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7612. spec->num_mux_defs = 1;
  7613. spec->input_mux = &spec->private_imux;
  7614. return 1;
  7615. }
  7616. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7617. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7618. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7619. /* init callback for auto-configuration model -- overriding the default init */
  7620. static void alc268_auto_init(struct hda_codec *codec)
  7621. {
  7622. alc268_auto_init_multi_out(codec);
  7623. alc268_auto_init_hp_out(codec);
  7624. alc268_auto_init_mono_speaker_out(codec);
  7625. alc268_auto_init_analog_input(codec);
  7626. }
  7627. /*
  7628. * configuration and preset
  7629. */
  7630. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7631. [ALC268_3ST] = "3stack",
  7632. [ALC268_AUTO] = "auto",
  7633. };
  7634. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7635. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7636. {}
  7637. };
  7638. static struct alc_config_preset alc268_presets[] = {
  7639. [ALC268_3ST] = {
  7640. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7641. .init_verbs = { alc268_base_init_verbs },
  7642. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7643. .dac_nids = alc268_dac_nids,
  7644. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7645. .adc_nids = alc268_adc_nids_alt,
  7646. .hp_nid = 0x03,
  7647. .dig_out_nid = ALC268_DIGOUT_NID,
  7648. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7649. .channel_mode = alc268_modes,
  7650. .input_mux = &alc268_capture_source,
  7651. },
  7652. };
  7653. static int patch_alc268(struct hda_codec *codec)
  7654. {
  7655. struct alc_spec *spec;
  7656. int board_config;
  7657. int err;
  7658. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7659. if (spec == NULL)
  7660. return -ENOMEM;
  7661. codec->spec = spec;
  7662. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7663. alc268_models,
  7664. alc268_cfg_tbl);
  7665. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7666. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7667. "trying auto-probe from BIOS...\n");
  7668. board_config = ALC268_AUTO;
  7669. }
  7670. if (board_config == ALC268_AUTO) {
  7671. /* automatic parse from the BIOS config */
  7672. err = alc268_parse_auto_config(codec);
  7673. if (err < 0) {
  7674. alc_free(codec);
  7675. return err;
  7676. } else if (!err) {
  7677. printk(KERN_INFO
  7678. "hda_codec: Cannot set up configuration "
  7679. "from BIOS. Using base mode...\n");
  7680. board_config = ALC268_3ST;
  7681. }
  7682. }
  7683. if (board_config != ALC268_AUTO)
  7684. setup_preset(spec, &alc268_presets[board_config]);
  7685. spec->stream_name_analog = "ALC268 Analog";
  7686. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7687. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7688. spec->stream_name_digital = "ALC268 Digital";
  7689. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7690. if (board_config == ALC268_AUTO) {
  7691. if (!spec->adc_nids && spec->input_mux) {
  7692. /* check whether NID 0x07 is valid */
  7693. unsigned int wcap = get_wcaps(codec, 0x07);
  7694. /* get type */
  7695. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7696. if (wcap != AC_WID_AUD_IN) {
  7697. spec->adc_nids = alc268_adc_nids_alt;
  7698. spec->num_adc_nids =
  7699. ARRAY_SIZE(alc268_adc_nids_alt);
  7700. spec->mixers[spec->num_mixers] =
  7701. alc268_capture_alt_mixer;
  7702. spec->num_mixers++;
  7703. } else {
  7704. spec->adc_nids = alc268_adc_nids;
  7705. spec->num_adc_nids =
  7706. ARRAY_SIZE(alc268_adc_nids);
  7707. spec->mixers[spec->num_mixers] =
  7708. alc268_capture_mixer;
  7709. spec->num_mixers++;
  7710. }
  7711. }
  7712. }
  7713. codec->patch_ops = alc_patch_ops;
  7714. if (board_config == ALC268_AUTO)
  7715. spec->init_hook = alc268_auto_init;
  7716. return 0;
  7717. }
  7718. /*
  7719. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7720. */
  7721. /*
  7722. * set the path ways for 2 channel output
  7723. * need to set the codec line out and mic 1 pin widgets to inputs
  7724. */
  7725. static struct hda_verb alc861_threestack_ch2_init[] = {
  7726. /* set pin widget 1Ah (line in) for input */
  7727. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7728. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7729. * the vref
  7730. */
  7731. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7732. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7733. #if 0
  7734. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7735. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7736. #endif
  7737. { } /* end */
  7738. };
  7739. /*
  7740. * 6ch mode
  7741. * need to set the codec line out and mic 1 pin widgets to outputs
  7742. */
  7743. static struct hda_verb alc861_threestack_ch6_init[] = {
  7744. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7745. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7746. /* set pin widget 18h (mic1) for output (CLFE)*/
  7747. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7748. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7749. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7750. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7751. #if 0
  7752. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7753. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7754. #endif
  7755. { } /* end */
  7756. };
  7757. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7758. { 2, alc861_threestack_ch2_init },
  7759. { 6, alc861_threestack_ch6_init },
  7760. };
  7761. /* Set mic1 as input and unmute the mixer */
  7762. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7763. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7764. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7765. { } /* end */
  7766. };
  7767. /* Set mic1 as output and mute mixer */
  7768. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7769. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7770. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7771. { } /* end */
  7772. };
  7773. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7774. { 2, alc861_uniwill_m31_ch2_init },
  7775. { 4, alc861_uniwill_m31_ch4_init },
  7776. };
  7777. /* Set mic1 and line-in as input and unmute the mixer */
  7778. static struct hda_verb alc861_asus_ch2_init[] = {
  7779. /* set pin widget 1Ah (line in) for input */
  7780. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7781. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7782. * the vref
  7783. */
  7784. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7785. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7786. #if 0
  7787. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7788. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7789. #endif
  7790. { } /* end */
  7791. };
  7792. /* Set mic1 nad line-in as output and mute mixer */
  7793. static struct hda_verb alc861_asus_ch6_init[] = {
  7794. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7795. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7796. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7797. /* set pin widget 18h (mic1) for output (CLFE)*/
  7798. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7799. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7800. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7801. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7802. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7803. #if 0
  7804. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7805. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7806. #endif
  7807. { } /* end */
  7808. };
  7809. static struct hda_channel_mode alc861_asus_modes[2] = {
  7810. { 2, alc861_asus_ch2_init },
  7811. { 6, alc861_asus_ch6_init },
  7812. };
  7813. /* patch-ALC861 */
  7814. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7815. /* output mixer control */
  7816. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7817. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7818. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7819. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7820. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7821. /*Input mixer control */
  7822. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7823. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7824. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7825. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7826. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7827. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7828. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7829. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7830. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7831. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7832. /* Capture mixer control */
  7833. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7834. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7835. {
  7836. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7837. .name = "Capture Source",
  7838. .count = 1,
  7839. .info = alc_mux_enum_info,
  7840. .get = alc_mux_enum_get,
  7841. .put = alc_mux_enum_put,
  7842. },
  7843. { } /* end */
  7844. };
  7845. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7846. /* output mixer control */
  7847. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7848. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7849. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7850. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7851. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7852. /* Input mixer control */
  7853. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7854. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7855. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7856. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7857. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7858. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7859. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7860. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7861. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7862. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7863. /* Capture mixer control */
  7864. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7865. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7866. {
  7867. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7868. .name = "Capture Source",
  7869. .count = 1,
  7870. .info = alc_mux_enum_info,
  7871. .get = alc_mux_enum_get,
  7872. .put = alc_mux_enum_put,
  7873. },
  7874. {
  7875. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7876. .name = "Channel Mode",
  7877. .info = alc_ch_mode_info,
  7878. .get = alc_ch_mode_get,
  7879. .put = alc_ch_mode_put,
  7880. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7881. },
  7882. { } /* end */
  7883. };
  7884. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  7885. /* output mixer control */
  7886. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7887. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7888. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7889. /*Capture mixer control */
  7890. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7891. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7892. {
  7893. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7894. .name = "Capture Source",
  7895. .count = 1,
  7896. .info = alc_mux_enum_info,
  7897. .get = alc_mux_enum_get,
  7898. .put = alc_mux_enum_put,
  7899. },
  7900. { } /* end */
  7901. };
  7902. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  7903. /* output mixer control */
  7904. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7905. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7906. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7907. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7908. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7909. /* Input mixer control */
  7910. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7911. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7912. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7913. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7914. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7915. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7916. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7917. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7918. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7919. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7920. /* Capture mixer control */
  7921. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7922. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7923. {
  7924. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7925. .name = "Capture Source",
  7926. .count = 1,
  7927. .info = alc_mux_enum_info,
  7928. .get = alc_mux_enum_get,
  7929. .put = alc_mux_enum_put,
  7930. },
  7931. {
  7932. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7933. .name = "Channel Mode",
  7934. .info = alc_ch_mode_info,
  7935. .get = alc_ch_mode_get,
  7936. .put = alc_ch_mode_put,
  7937. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7938. },
  7939. { } /* end */
  7940. };
  7941. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  7942. /* output mixer control */
  7943. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7944. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7945. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7946. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7947. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7948. /* Input mixer control */
  7949. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7950. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7951. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7952. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7953. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7954. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7955. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7956. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7957. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7958. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  7959. /* Capture mixer control */
  7960. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7961. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7962. {
  7963. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7964. .name = "Capture Source",
  7965. .count = 1,
  7966. .info = alc_mux_enum_info,
  7967. .get = alc_mux_enum_get,
  7968. .put = alc_mux_enum_put,
  7969. },
  7970. {
  7971. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7972. .name = "Channel Mode",
  7973. .info = alc_ch_mode_info,
  7974. .get = alc_ch_mode_get,
  7975. .put = alc_ch_mode_put,
  7976. .private_value = ARRAY_SIZE(alc861_asus_modes),
  7977. },
  7978. { }
  7979. };
  7980. /* additional mixer */
  7981. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  7982. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7983. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7984. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  7985. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  7986. { }
  7987. };
  7988. /*
  7989. * generic initialization of ADC, input mixers and output mixers
  7990. */
  7991. static struct hda_verb alc861_base_init_verbs[] = {
  7992. /*
  7993. * Unmute ADC0 and set the default input to mic-in
  7994. */
  7995. /* port-A for surround (rear panel) */
  7996. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7997. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7998. /* port-B for mic-in (rear panel) with vref */
  7999. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8000. /* port-C for line-in (rear panel) */
  8001. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8002. /* port-D for Front */
  8003. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8004. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8005. /* port-E for HP out (front panel) */
  8006. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8007. /* route front PCM to HP */
  8008. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8009. /* port-F for mic-in (front panel) with vref */
  8010. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8011. /* port-G for CLFE (rear panel) */
  8012. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8013. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8014. /* port-H for side (rear panel) */
  8015. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8016. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8017. /* CD-in */
  8018. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8019. /* route front mic to ADC1*/
  8020. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8021. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8022. /* Unmute DAC0~3 & spdif out*/
  8023. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8024. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8025. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8026. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8027. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8028. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8029. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8030. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8031. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8032. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8033. /* Unmute Stereo Mixer 15 */
  8034. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8035. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8036. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8037. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8038. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8039. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8040. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8041. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8042. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8043. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8044. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8045. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8046. /* hp used DAC 3 (Front) */
  8047. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8048. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8049. { }
  8050. };
  8051. static struct hda_verb alc861_threestack_init_verbs[] = {
  8052. /*
  8053. * Unmute ADC0 and set the default input to mic-in
  8054. */
  8055. /* port-A for surround (rear panel) */
  8056. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8057. /* port-B for mic-in (rear panel) with vref */
  8058. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8059. /* port-C for line-in (rear panel) */
  8060. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8061. /* port-D for Front */
  8062. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8063. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8064. /* port-E for HP out (front panel) */
  8065. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8066. /* route front PCM to HP */
  8067. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8068. /* port-F for mic-in (front panel) with vref */
  8069. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8070. /* port-G for CLFE (rear panel) */
  8071. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8072. /* port-H for side (rear panel) */
  8073. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8074. /* CD-in */
  8075. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8076. /* route front mic to ADC1*/
  8077. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8078. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8079. /* Unmute DAC0~3 & spdif out*/
  8080. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8081. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8082. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8083. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8084. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8085. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8086. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8087. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8088. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8089. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8090. /* Unmute Stereo Mixer 15 */
  8091. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8092. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8093. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8094. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8095. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8096. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8097. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8098. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8099. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8100. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8101. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8102. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8103. /* hp used DAC 3 (Front) */
  8104. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8105. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8106. { }
  8107. };
  8108. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8109. /*
  8110. * Unmute ADC0 and set the default input to mic-in
  8111. */
  8112. /* port-A for surround (rear panel) */
  8113. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8114. /* port-B for mic-in (rear panel) with vref */
  8115. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8116. /* port-C for line-in (rear panel) */
  8117. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8118. /* port-D for Front */
  8119. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8120. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8121. /* port-E for HP out (front panel) */
  8122. /* this has to be set to VREF80 */
  8123. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8124. /* route front PCM to HP */
  8125. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8126. /* port-F for mic-in (front panel) with vref */
  8127. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8128. /* port-G for CLFE (rear panel) */
  8129. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8130. /* port-H for side (rear panel) */
  8131. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8132. /* CD-in */
  8133. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8134. /* route front mic to ADC1*/
  8135. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8136. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8137. /* Unmute DAC0~3 & spdif out*/
  8138. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8139. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8140. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8141. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8142. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8143. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8144. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8145. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8146. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8147. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8148. /* Unmute Stereo Mixer 15 */
  8149. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8150. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8151. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8152. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8153. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8154. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8155. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8156. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8157. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8158. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8159. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8160. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8161. /* hp used DAC 3 (Front) */
  8162. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8163. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8164. { }
  8165. };
  8166. static struct hda_verb alc861_asus_init_verbs[] = {
  8167. /*
  8168. * Unmute ADC0 and set the default input to mic-in
  8169. */
  8170. /* port-A for surround (rear panel)
  8171. * according to codec#0 this is the HP jack
  8172. */
  8173. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8174. /* route front PCM to HP */
  8175. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8176. /* port-B for mic-in (rear panel) with vref */
  8177. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8178. /* port-C for line-in (rear panel) */
  8179. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8180. /* port-D for Front */
  8181. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8182. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8183. /* port-E for HP out (front panel) */
  8184. /* this has to be set to VREF80 */
  8185. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8186. /* route front PCM to HP */
  8187. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8188. /* port-F for mic-in (front panel) with vref */
  8189. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8190. /* port-G for CLFE (rear panel) */
  8191. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8192. /* port-H for side (rear panel) */
  8193. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8194. /* CD-in */
  8195. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8196. /* route front mic to ADC1*/
  8197. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8198. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8199. /* Unmute DAC0~3 & spdif out*/
  8200. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8201. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8202. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8203. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8204. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8205. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8206. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8207. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8208. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8209. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8210. /* Unmute Stereo Mixer 15 */
  8211. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8212. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8213. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8214. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8215. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8216. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8217. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8218. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8219. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8220. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8221. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8222. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8223. /* hp used DAC 3 (Front) */
  8224. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8225. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8226. { }
  8227. };
  8228. /* additional init verbs for ASUS laptops */
  8229. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8230. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8231. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8232. { }
  8233. };
  8234. /*
  8235. * generic initialization of ADC, input mixers and output mixers
  8236. */
  8237. static struct hda_verb alc861_auto_init_verbs[] = {
  8238. /*
  8239. * Unmute ADC0 and set the default input to mic-in
  8240. */
  8241. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8242. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8243. /* Unmute DAC0~3 & spdif out*/
  8244. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8245. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8246. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8247. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8248. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8249. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8250. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8251. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8252. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8253. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8254. /* Unmute Stereo Mixer 15 */
  8255. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8256. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8257. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8258. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8259. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8260. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8261. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8262. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8263. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8264. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8265. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8266. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8267. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8268. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8269. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8270. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8271. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8272. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8273. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8274. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8275. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8276. { }
  8277. };
  8278. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8279. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8280. { }
  8281. };
  8282. /* toggle speaker-output according to the hp-jack state */
  8283. static void alc861_toshiba_automute(struct hda_codec *codec)
  8284. {
  8285. unsigned int present;
  8286. present = snd_hda_codec_read(codec, 0x0f, 0,
  8287. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8288. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  8289. 0x80, present ? 0x80 : 0);
  8290. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  8291. 0x80, present ? 0x80 : 0);
  8292. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  8293. 0x80, present ? 0 : 0x80);
  8294. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  8295. 0x80, present ? 0 : 0x80);
  8296. }
  8297. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8298. unsigned int res)
  8299. {
  8300. if ((res >> 26) == ALC880_HP_EVENT)
  8301. alc861_toshiba_automute(codec);
  8302. }
  8303. /* pcm configuration: identiacal with ALC880 */
  8304. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8305. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8306. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8307. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8308. #define ALC861_DIGOUT_NID 0x07
  8309. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8310. { 8, NULL }
  8311. };
  8312. static hda_nid_t alc861_dac_nids[4] = {
  8313. /* front, surround, clfe, side */
  8314. 0x03, 0x06, 0x05, 0x04
  8315. };
  8316. static hda_nid_t alc660_dac_nids[3] = {
  8317. /* front, clfe, surround */
  8318. 0x03, 0x05, 0x06
  8319. };
  8320. static hda_nid_t alc861_adc_nids[1] = {
  8321. /* ADC0-2 */
  8322. 0x08,
  8323. };
  8324. static struct hda_input_mux alc861_capture_source = {
  8325. .num_items = 5,
  8326. .items = {
  8327. { "Mic", 0x0 },
  8328. { "Front Mic", 0x3 },
  8329. { "Line", 0x1 },
  8330. { "CD", 0x4 },
  8331. { "Mixer", 0x5 },
  8332. },
  8333. };
  8334. /* fill in the dac_nids table from the parsed pin configuration */
  8335. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8336. const struct auto_pin_cfg *cfg)
  8337. {
  8338. int i;
  8339. hda_nid_t nid;
  8340. spec->multiout.dac_nids = spec->private_dac_nids;
  8341. for (i = 0; i < cfg->line_outs; i++) {
  8342. nid = cfg->line_out_pins[i];
  8343. if (nid) {
  8344. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8345. continue;
  8346. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8347. }
  8348. }
  8349. spec->multiout.num_dacs = cfg->line_outs;
  8350. return 0;
  8351. }
  8352. /* add playback controls from the parsed DAC table */
  8353. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8354. const struct auto_pin_cfg *cfg)
  8355. {
  8356. char name[32];
  8357. static const char *chname[4] = {
  8358. "Front", "Surround", NULL /*CLFE*/, "Side"
  8359. };
  8360. hda_nid_t nid;
  8361. int i, idx, err;
  8362. for (i = 0; i < cfg->line_outs; i++) {
  8363. nid = spec->multiout.dac_nids[i];
  8364. if (!nid)
  8365. continue;
  8366. if (nid == 0x05) {
  8367. /* Center/LFE */
  8368. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8369. "Center Playback Switch",
  8370. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8371. HDA_OUTPUT));
  8372. if (err < 0)
  8373. return err;
  8374. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8375. "LFE Playback Switch",
  8376. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8377. HDA_OUTPUT));
  8378. if (err < 0)
  8379. return err;
  8380. } else {
  8381. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8382. idx++)
  8383. if (nid == alc861_dac_nids[idx])
  8384. break;
  8385. sprintf(name, "%s Playback Switch", chname[idx]);
  8386. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8387. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8388. HDA_OUTPUT));
  8389. if (err < 0)
  8390. return err;
  8391. }
  8392. }
  8393. return 0;
  8394. }
  8395. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8396. {
  8397. int err;
  8398. hda_nid_t nid;
  8399. if (!pin)
  8400. return 0;
  8401. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8402. nid = 0x03;
  8403. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8404. "Headphone Playback Switch",
  8405. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8406. if (err < 0)
  8407. return err;
  8408. spec->multiout.hp_nid = nid;
  8409. }
  8410. return 0;
  8411. }
  8412. /* create playback/capture controls for input pins */
  8413. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8414. const struct auto_pin_cfg *cfg)
  8415. {
  8416. struct hda_input_mux *imux = &spec->private_imux;
  8417. int i, err, idx, idx1;
  8418. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8419. switch (cfg->input_pins[i]) {
  8420. case 0x0c:
  8421. idx1 = 1;
  8422. idx = 2; /* Line In */
  8423. break;
  8424. case 0x0f:
  8425. idx1 = 2;
  8426. idx = 2; /* Line In */
  8427. break;
  8428. case 0x0d:
  8429. idx1 = 0;
  8430. idx = 1; /* Mic In */
  8431. break;
  8432. case 0x10:
  8433. idx1 = 3;
  8434. idx = 1; /* Mic In */
  8435. break;
  8436. case 0x11:
  8437. idx1 = 4;
  8438. idx = 0; /* CD */
  8439. break;
  8440. default:
  8441. continue;
  8442. }
  8443. err = new_analog_input(spec, cfg->input_pins[i],
  8444. auto_pin_cfg_labels[i], idx, 0x15);
  8445. if (err < 0)
  8446. return err;
  8447. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8448. imux->items[imux->num_items].index = idx1;
  8449. imux->num_items++;
  8450. }
  8451. return 0;
  8452. }
  8453. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8454. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8455. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8456. {
  8457. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8458. /* The multiple "Capture Source" controls confuse alsamixer
  8459. * So call somewhat different..
  8460. *FIXME: the controls appear in the "playback" view!
  8461. */
  8462. /* .name = "Capture Source", */
  8463. .name = "Input Source",
  8464. .count = 1,
  8465. .info = alc_mux_enum_info,
  8466. .get = alc_mux_enum_get,
  8467. .put = alc_mux_enum_put,
  8468. },
  8469. { } /* end */
  8470. };
  8471. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8472. hda_nid_t nid,
  8473. int pin_type, int dac_idx)
  8474. {
  8475. /* set as output */
  8476. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8477. pin_type);
  8478. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8479. AMP_OUT_UNMUTE);
  8480. }
  8481. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8482. {
  8483. struct alc_spec *spec = codec->spec;
  8484. int i;
  8485. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8486. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8487. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8488. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8489. if (nid)
  8490. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8491. spec->multiout.dac_nids[i]);
  8492. }
  8493. }
  8494. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8495. {
  8496. struct alc_spec *spec = codec->spec;
  8497. hda_nid_t pin;
  8498. pin = spec->autocfg.hp_pins[0];
  8499. if (pin) /* connect to front */
  8500. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8501. spec->multiout.dac_nids[0]);
  8502. }
  8503. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8504. {
  8505. struct alc_spec *spec = codec->spec;
  8506. int i;
  8507. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8508. hda_nid_t nid = spec->autocfg.input_pins[i];
  8509. if (nid >= 0x0c && nid <= 0x11) {
  8510. snd_hda_codec_write(codec, nid, 0,
  8511. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8512. i <= AUTO_PIN_FRONT_MIC ?
  8513. PIN_VREF80 : PIN_IN);
  8514. }
  8515. }
  8516. }
  8517. /* parse the BIOS configuration and set up the alc_spec */
  8518. /* return 1 if successful, 0 if the proper config is not found,
  8519. * or a negative error code
  8520. */
  8521. static int alc861_parse_auto_config(struct hda_codec *codec)
  8522. {
  8523. struct alc_spec *spec = codec->spec;
  8524. int err;
  8525. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8526. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8527. alc861_ignore);
  8528. if (err < 0)
  8529. return err;
  8530. if (!spec->autocfg.line_outs)
  8531. return 0; /* can't find valid BIOS pin config */
  8532. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8533. if (err < 0)
  8534. return err;
  8535. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8536. if (err < 0)
  8537. return err;
  8538. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8539. if (err < 0)
  8540. return err;
  8541. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8542. if (err < 0)
  8543. return err;
  8544. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8545. if (spec->autocfg.dig_out_pin)
  8546. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8547. if (spec->kctl_alloc)
  8548. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8549. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8550. spec->num_mux_defs = 1;
  8551. spec->input_mux = &spec->private_imux;
  8552. spec->adc_nids = alc861_adc_nids;
  8553. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8554. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8555. spec->num_mixers++;
  8556. return 1;
  8557. }
  8558. /* additional initialization for auto-configuration model */
  8559. static void alc861_auto_init(struct hda_codec *codec)
  8560. {
  8561. alc861_auto_init_multi_out(codec);
  8562. alc861_auto_init_hp_out(codec);
  8563. alc861_auto_init_analog_input(codec);
  8564. }
  8565. /*
  8566. * configuration and preset
  8567. */
  8568. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8569. [ALC861_3ST] = "3stack",
  8570. [ALC660_3ST] = "3stack-660",
  8571. [ALC861_3ST_DIG] = "3stack-dig",
  8572. [ALC861_6ST_DIG] = "6stack-dig",
  8573. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8574. [ALC861_TOSHIBA] = "toshiba",
  8575. [ALC861_ASUS] = "asus",
  8576. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8577. [ALC861_AUTO] = "auto",
  8578. };
  8579. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8580. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8581. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8582. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8583. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8584. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  8585. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8586. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  8587. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8588. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  8589. * Any other models that need this preset?
  8590. */
  8591. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  8592. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8593. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8594. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8595. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8596. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8597. {}
  8598. };
  8599. static struct alc_config_preset alc861_presets[] = {
  8600. [ALC861_3ST] = {
  8601. .mixers = { alc861_3ST_mixer },
  8602. .init_verbs = { alc861_threestack_init_verbs },
  8603. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8604. .dac_nids = alc861_dac_nids,
  8605. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8606. .channel_mode = alc861_threestack_modes,
  8607. .need_dac_fix = 1,
  8608. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8609. .adc_nids = alc861_adc_nids,
  8610. .input_mux = &alc861_capture_source,
  8611. },
  8612. [ALC861_3ST_DIG] = {
  8613. .mixers = { alc861_base_mixer },
  8614. .init_verbs = { alc861_threestack_init_verbs },
  8615. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8616. .dac_nids = alc861_dac_nids,
  8617. .dig_out_nid = ALC861_DIGOUT_NID,
  8618. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8619. .channel_mode = alc861_threestack_modes,
  8620. .need_dac_fix = 1,
  8621. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8622. .adc_nids = alc861_adc_nids,
  8623. .input_mux = &alc861_capture_source,
  8624. },
  8625. [ALC861_6ST_DIG] = {
  8626. .mixers = { alc861_base_mixer },
  8627. .init_verbs = { alc861_base_init_verbs },
  8628. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8629. .dac_nids = alc861_dac_nids,
  8630. .dig_out_nid = ALC861_DIGOUT_NID,
  8631. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8632. .channel_mode = alc861_8ch_modes,
  8633. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8634. .adc_nids = alc861_adc_nids,
  8635. .input_mux = &alc861_capture_source,
  8636. },
  8637. [ALC660_3ST] = {
  8638. .mixers = { alc861_3ST_mixer },
  8639. .init_verbs = { alc861_threestack_init_verbs },
  8640. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8641. .dac_nids = alc660_dac_nids,
  8642. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8643. .channel_mode = alc861_threestack_modes,
  8644. .need_dac_fix = 1,
  8645. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8646. .adc_nids = alc861_adc_nids,
  8647. .input_mux = &alc861_capture_source,
  8648. },
  8649. [ALC861_UNIWILL_M31] = {
  8650. .mixers = { alc861_uniwill_m31_mixer },
  8651. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8652. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8653. .dac_nids = alc861_dac_nids,
  8654. .dig_out_nid = ALC861_DIGOUT_NID,
  8655. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8656. .channel_mode = alc861_uniwill_m31_modes,
  8657. .need_dac_fix = 1,
  8658. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8659. .adc_nids = alc861_adc_nids,
  8660. .input_mux = &alc861_capture_source,
  8661. },
  8662. [ALC861_TOSHIBA] = {
  8663. .mixers = { alc861_toshiba_mixer },
  8664. .init_verbs = { alc861_base_init_verbs,
  8665. alc861_toshiba_init_verbs },
  8666. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8667. .dac_nids = alc861_dac_nids,
  8668. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8669. .channel_mode = alc883_3ST_2ch_modes,
  8670. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8671. .adc_nids = alc861_adc_nids,
  8672. .input_mux = &alc861_capture_source,
  8673. .unsol_event = alc861_toshiba_unsol_event,
  8674. .init_hook = alc861_toshiba_automute,
  8675. },
  8676. [ALC861_ASUS] = {
  8677. .mixers = { alc861_asus_mixer },
  8678. .init_verbs = { alc861_asus_init_verbs },
  8679. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8680. .dac_nids = alc861_dac_nids,
  8681. .dig_out_nid = ALC861_DIGOUT_NID,
  8682. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8683. .channel_mode = alc861_asus_modes,
  8684. .need_dac_fix = 1,
  8685. .hp_nid = 0x06,
  8686. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8687. .adc_nids = alc861_adc_nids,
  8688. .input_mux = &alc861_capture_source,
  8689. },
  8690. [ALC861_ASUS_LAPTOP] = {
  8691. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8692. .init_verbs = { alc861_asus_init_verbs,
  8693. alc861_asus_laptop_init_verbs },
  8694. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8695. .dac_nids = alc861_dac_nids,
  8696. .dig_out_nid = ALC861_DIGOUT_NID,
  8697. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8698. .channel_mode = alc883_3ST_2ch_modes,
  8699. .need_dac_fix = 1,
  8700. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8701. .adc_nids = alc861_adc_nids,
  8702. .input_mux = &alc861_capture_source,
  8703. },
  8704. };
  8705. static int patch_alc861(struct hda_codec *codec)
  8706. {
  8707. struct alc_spec *spec;
  8708. int board_config;
  8709. int err;
  8710. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8711. if (spec == NULL)
  8712. return -ENOMEM;
  8713. codec->spec = spec;
  8714. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8715. alc861_models,
  8716. alc861_cfg_tbl);
  8717. if (board_config < 0) {
  8718. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8719. "trying auto-probe from BIOS...\n");
  8720. board_config = ALC861_AUTO;
  8721. }
  8722. if (board_config == ALC861_AUTO) {
  8723. /* automatic parse from the BIOS config */
  8724. err = alc861_parse_auto_config(codec);
  8725. if (err < 0) {
  8726. alc_free(codec);
  8727. return err;
  8728. } else if (!err) {
  8729. printk(KERN_INFO
  8730. "hda_codec: Cannot set up configuration "
  8731. "from BIOS. Using base mode...\n");
  8732. board_config = ALC861_3ST_DIG;
  8733. }
  8734. }
  8735. if (board_config != ALC861_AUTO)
  8736. setup_preset(spec, &alc861_presets[board_config]);
  8737. spec->stream_name_analog = "ALC861 Analog";
  8738. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8739. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8740. spec->stream_name_digital = "ALC861 Digital";
  8741. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8742. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8743. codec->patch_ops = alc_patch_ops;
  8744. if (board_config == ALC861_AUTO)
  8745. spec->init_hook = alc861_auto_init;
  8746. return 0;
  8747. }
  8748. /*
  8749. * ALC861-VD support
  8750. *
  8751. * Based on ALC882
  8752. *
  8753. * In addition, an independent DAC
  8754. */
  8755. #define ALC861VD_DIGOUT_NID 0x06
  8756. static hda_nid_t alc861vd_dac_nids[4] = {
  8757. /* front, surr, clfe, side surr */
  8758. 0x02, 0x03, 0x04, 0x05
  8759. };
  8760. /* dac_nids for ALC660vd are in a different order - according to
  8761. * Realtek's driver.
  8762. * This should probably tesult in a different mixer for 6stack models
  8763. * of ALC660vd codecs, but for now there is only 3stack mixer
  8764. * - and it is the same as in 861vd.
  8765. * adc_nids in ALC660vd are (is) the same as in 861vd
  8766. */
  8767. static hda_nid_t alc660vd_dac_nids[3] = {
  8768. /* front, rear, clfe, rear_surr */
  8769. 0x02, 0x04, 0x03
  8770. };
  8771. static hda_nid_t alc861vd_adc_nids[1] = {
  8772. /* ADC0 */
  8773. 0x09,
  8774. };
  8775. /* input MUX */
  8776. /* FIXME: should be a matrix-type input source selection */
  8777. static struct hda_input_mux alc861vd_capture_source = {
  8778. .num_items = 4,
  8779. .items = {
  8780. { "Mic", 0x0 },
  8781. { "Front Mic", 0x1 },
  8782. { "Line", 0x2 },
  8783. { "CD", 0x4 },
  8784. },
  8785. };
  8786. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8787. .num_items = 3,
  8788. .items = {
  8789. { "Front Mic", 0x0 },
  8790. { "ATAPI Mic", 0x1 },
  8791. { "Line In", 0x5 },
  8792. },
  8793. };
  8794. #define alc861vd_mux_enum_info alc_mux_enum_info
  8795. #define alc861vd_mux_enum_get alc_mux_enum_get
  8796. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8797. struct snd_ctl_elem_value *ucontrol)
  8798. {
  8799. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8800. struct alc_spec *spec = codec->spec;
  8801. const struct hda_input_mux *imux = spec->input_mux;
  8802. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8803. static hda_nid_t capture_mixers[1] = { 0x22 };
  8804. hda_nid_t nid = capture_mixers[adc_idx];
  8805. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8806. unsigned int i, idx;
  8807. idx = ucontrol->value.enumerated.item[0];
  8808. if (idx >= imux->num_items)
  8809. idx = imux->num_items - 1;
  8810. if (*cur_val == idx && !codec->in_resume)
  8811. return 0;
  8812. for (i = 0; i < imux->num_items; i++) {
  8813. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8814. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8815. v | (imux->items[i].index << 8));
  8816. }
  8817. *cur_val = idx;
  8818. return 1;
  8819. }
  8820. /*
  8821. * 2ch mode
  8822. */
  8823. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8824. { 2, NULL }
  8825. };
  8826. /*
  8827. * 6ch mode
  8828. */
  8829. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8830. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8831. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8832. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8833. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8834. { } /* end */
  8835. };
  8836. /*
  8837. * 8ch mode
  8838. */
  8839. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8840. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8841. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8842. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8843. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8844. { } /* end */
  8845. };
  8846. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8847. { 6, alc861vd_6stack_ch6_init },
  8848. { 8, alc861vd_6stack_ch8_init },
  8849. };
  8850. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8851. {
  8852. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8853. .name = "Channel Mode",
  8854. .info = alc_ch_mode_info,
  8855. .get = alc_ch_mode_get,
  8856. .put = alc_ch_mode_put,
  8857. },
  8858. { } /* end */
  8859. };
  8860. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8861. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8862. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8863. {
  8864. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8865. /* The multiple "Capture Source" controls confuse alsamixer
  8866. * So call somewhat different..
  8867. *FIXME: the controls appear in the "playback" view!
  8868. */
  8869. /* .name = "Capture Source", */
  8870. .name = "Input Source",
  8871. .count = 1,
  8872. .info = alc861vd_mux_enum_info,
  8873. .get = alc861vd_mux_enum_get,
  8874. .put = alc861vd_mux_enum_put,
  8875. },
  8876. { } /* end */
  8877. };
  8878. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8879. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8880. */
  8881. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  8882. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8883. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8884. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8885. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  8886. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  8887. HDA_OUTPUT),
  8888. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  8889. HDA_OUTPUT),
  8890. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  8891. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  8892. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  8893. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  8894. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8895. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8896. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8897. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8898. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8899. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8900. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8901. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8902. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8903. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8904. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8905. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8906. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8907. { } /* end */
  8908. };
  8909. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  8910. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8911. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8912. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8913. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8914. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8915. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8916. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8917. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8918. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8919. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8920. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8921. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8922. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8923. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8924. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8925. { } /* end */
  8926. };
  8927. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  8928. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8929. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  8930. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8931. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8932. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8933. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8934. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8935. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8936. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8937. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8938. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8939. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8940. { } /* end */
  8941. };
  8942. /* Pin assignment: Front=0x14, HP = 0x15,
  8943. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  8944. */
  8945. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  8946. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8947. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8948. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8949. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  8950. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8951. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8952. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8953. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8954. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8955. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8956. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8957. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8958. {
  8959. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8960. /* .name = "Capture Source", */
  8961. .name = "Input Source",
  8962. .count = 1,
  8963. .info = alc882_mux_enum_info,
  8964. .get = alc882_mux_enum_get,
  8965. .put = alc882_mux_enum_put,
  8966. },
  8967. { } /* end */
  8968. };
  8969. /*
  8970. * generic initialization of ADC, input mixers and output mixers
  8971. */
  8972. static struct hda_verb alc861vd_volume_init_verbs[] = {
  8973. /*
  8974. * Unmute ADC0 and set the default input to mic-in
  8975. */
  8976. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  8977. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8978. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  8979. * the analog-loopback mixer widget
  8980. */
  8981. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  8982. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8983. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8984. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8985. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8986. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8987. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  8988. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8989. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8990. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8991. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  8992. /*
  8993. * Set up output mixers (0x02 - 0x05)
  8994. */
  8995. /* set vol=0 to output mixers */
  8996. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8997. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8998. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8999. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9000. /* set up input amps for analog loopback */
  9001. /* Amp Indices: DAC = 0, mixer = 1 */
  9002. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9003. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9004. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9005. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9006. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9007. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9008. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9009. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9010. { }
  9011. };
  9012. /*
  9013. * 3-stack pin configuration:
  9014. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9015. */
  9016. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9017. /*
  9018. * Set pin mode and muting
  9019. */
  9020. /* set front pin widgets 0x14 for output */
  9021. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9022. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9023. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9024. /* Mic (rear) pin: input vref at 80% */
  9025. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9026. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9027. /* Front Mic pin: input vref at 80% */
  9028. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9029. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9030. /* Line In pin: input */
  9031. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9032. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9033. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9034. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9035. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9036. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9037. /* CD pin widget for input */
  9038. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9039. { }
  9040. };
  9041. /*
  9042. * 6-stack pin configuration:
  9043. */
  9044. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9045. /*
  9046. * Set pin mode and muting
  9047. */
  9048. /* set front pin widgets 0x14 for output */
  9049. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9050. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9051. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9052. /* Rear Pin: output 1 (0x0d) */
  9053. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9054. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9055. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9056. /* CLFE Pin: output 2 (0x0e) */
  9057. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9058. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9059. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9060. /* Side Pin: output 3 (0x0f) */
  9061. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9062. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9063. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9064. /* Mic (rear) pin: input vref at 80% */
  9065. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9066. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9067. /* Front Mic pin: input vref at 80% */
  9068. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9069. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9070. /* Line In pin: input */
  9071. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9072. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9073. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9074. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9075. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9076. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9077. /* CD pin widget for input */
  9078. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9079. { }
  9080. };
  9081. static struct hda_verb alc861vd_eapd_verbs[] = {
  9082. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9083. { }
  9084. };
  9085. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9086. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9087. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9088. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9089. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9090. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9091. {}
  9092. };
  9093. /* toggle speaker-output according to the hp-jack state */
  9094. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9095. {
  9096. unsigned int present;
  9097. unsigned char bits;
  9098. present = snd_hda_codec_read(codec, 0x1b, 0,
  9099. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9100. bits = present ? 0x80 : 0;
  9101. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9102. 0x80, bits);
  9103. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9104. 0x80, bits);
  9105. }
  9106. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9107. {
  9108. unsigned int present;
  9109. unsigned char bits;
  9110. present = snd_hda_codec_read(codec, 0x18, 0,
  9111. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9112. bits = present ? 0x80 : 0;
  9113. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  9114. 0x80, bits);
  9115. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  9116. 0x80, bits);
  9117. }
  9118. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9119. {
  9120. alc861vd_lenovo_hp_automute(codec);
  9121. alc861vd_lenovo_mic_automute(codec);
  9122. }
  9123. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9124. unsigned int res)
  9125. {
  9126. switch (res >> 26) {
  9127. case ALC880_HP_EVENT:
  9128. alc861vd_lenovo_hp_automute(codec);
  9129. break;
  9130. case ALC880_MIC_EVENT:
  9131. alc861vd_lenovo_mic_automute(codec);
  9132. break;
  9133. }
  9134. }
  9135. static struct hda_verb alc861vd_dallas_verbs[] = {
  9136. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9137. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9138. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9139. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9140. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9141. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9142. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9143. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9144. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9145. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9146. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9147. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9148. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9149. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9150. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9151. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9152. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9153. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9154. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9155. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9156. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9157. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9158. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9159. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9160. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9161. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9162. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9163. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9164. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9165. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9166. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9167. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9168. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9169. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9170. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9171. { } /* end */
  9172. };
  9173. /* toggle speaker-output according to the hp-jack state */
  9174. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9175. {
  9176. unsigned int present;
  9177. present = snd_hda_codec_read(codec, 0x15, 0,
  9178. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9179. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9180. 0x80, present ? 0x80 : 0);
  9181. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9182. 0x80, present ? 0x80 : 0);
  9183. }
  9184. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9185. {
  9186. if ((res >> 26) == ALC880_HP_EVENT)
  9187. alc861vd_dallas_automute(codec);
  9188. }
  9189. /* pcm configuration: identiacal with ALC880 */
  9190. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9191. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9192. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9193. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9194. /*
  9195. * configuration and preset
  9196. */
  9197. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9198. [ALC660VD_3ST] = "3stack-660",
  9199. [ALC660VD_3ST_DIG]= "3stack-660-digout",
  9200. [ALC861VD_3ST] = "3stack",
  9201. [ALC861VD_3ST_DIG] = "3stack-digout",
  9202. [ALC861VD_6ST_DIG] = "6stack-digout",
  9203. [ALC861VD_LENOVO] = "lenovo",
  9204. [ALC861VD_DALLAS] = "dallas",
  9205. [ALC861VD_AUTO] = "auto",
  9206. };
  9207. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9208. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9209. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9210. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9211. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9212. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9213. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9214. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9215. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9216. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9217. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9218. {}
  9219. };
  9220. static struct alc_config_preset alc861vd_presets[] = {
  9221. [ALC660VD_3ST] = {
  9222. .mixers = { alc861vd_3st_mixer },
  9223. .init_verbs = { alc861vd_volume_init_verbs,
  9224. alc861vd_3stack_init_verbs },
  9225. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9226. .dac_nids = alc660vd_dac_nids,
  9227. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9228. .adc_nids = alc861vd_adc_nids,
  9229. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9230. .channel_mode = alc861vd_3stack_2ch_modes,
  9231. .input_mux = &alc861vd_capture_source,
  9232. },
  9233. [ALC660VD_3ST_DIG] = {
  9234. .mixers = { alc861vd_3st_mixer },
  9235. .init_verbs = { alc861vd_volume_init_verbs,
  9236. alc861vd_3stack_init_verbs },
  9237. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9238. .dac_nids = alc660vd_dac_nids,
  9239. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9240. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9241. .adc_nids = alc861vd_adc_nids,
  9242. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9243. .channel_mode = alc861vd_3stack_2ch_modes,
  9244. .input_mux = &alc861vd_capture_source,
  9245. },
  9246. [ALC861VD_3ST] = {
  9247. .mixers = { alc861vd_3st_mixer },
  9248. .init_verbs = { alc861vd_volume_init_verbs,
  9249. alc861vd_3stack_init_verbs },
  9250. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9251. .dac_nids = alc861vd_dac_nids,
  9252. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9253. .channel_mode = alc861vd_3stack_2ch_modes,
  9254. .input_mux = &alc861vd_capture_source,
  9255. },
  9256. [ALC861VD_3ST_DIG] = {
  9257. .mixers = { alc861vd_3st_mixer },
  9258. .init_verbs = { alc861vd_volume_init_verbs,
  9259. alc861vd_3stack_init_verbs },
  9260. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9261. .dac_nids = alc861vd_dac_nids,
  9262. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9263. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9264. .channel_mode = alc861vd_3stack_2ch_modes,
  9265. .input_mux = &alc861vd_capture_source,
  9266. },
  9267. [ALC861VD_6ST_DIG] = {
  9268. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9269. .init_verbs = { alc861vd_volume_init_verbs,
  9270. alc861vd_6stack_init_verbs },
  9271. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9272. .dac_nids = alc861vd_dac_nids,
  9273. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9274. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9275. .channel_mode = alc861vd_6stack_modes,
  9276. .input_mux = &alc861vd_capture_source,
  9277. },
  9278. [ALC861VD_LENOVO] = {
  9279. .mixers = { alc861vd_lenovo_mixer },
  9280. .init_verbs = { alc861vd_volume_init_verbs,
  9281. alc861vd_3stack_init_verbs,
  9282. alc861vd_eapd_verbs,
  9283. alc861vd_lenovo_unsol_verbs },
  9284. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9285. .dac_nids = alc660vd_dac_nids,
  9286. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9287. .adc_nids = alc861vd_adc_nids,
  9288. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9289. .channel_mode = alc861vd_3stack_2ch_modes,
  9290. .input_mux = &alc861vd_capture_source,
  9291. .unsol_event = alc861vd_lenovo_unsol_event,
  9292. .init_hook = alc861vd_lenovo_automute,
  9293. },
  9294. [ALC861VD_DALLAS] = {
  9295. .mixers = { alc861vd_dallas_mixer },
  9296. .init_verbs = { alc861vd_dallas_verbs },
  9297. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9298. .dac_nids = alc861vd_dac_nids,
  9299. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9300. .adc_nids = alc861vd_adc_nids,
  9301. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9302. .channel_mode = alc861vd_3stack_2ch_modes,
  9303. .input_mux = &alc861vd_dallas_capture_source,
  9304. .unsol_event = alc861vd_dallas_unsol_event,
  9305. .init_hook = alc861vd_dallas_automute,
  9306. },
  9307. };
  9308. /*
  9309. * BIOS auto configuration
  9310. */
  9311. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9312. hda_nid_t nid, int pin_type, int dac_idx)
  9313. {
  9314. /* set as output */
  9315. snd_hda_codec_write(codec, nid, 0,
  9316. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9317. snd_hda_codec_write(codec, nid, 0,
  9318. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9319. }
  9320. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9321. {
  9322. struct alc_spec *spec = codec->spec;
  9323. int i;
  9324. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9325. for (i = 0; i <= HDA_SIDE; i++) {
  9326. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9327. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9328. if (nid)
  9329. alc861vd_auto_set_output_and_unmute(codec, nid,
  9330. pin_type, i);
  9331. }
  9332. }
  9333. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9334. {
  9335. struct alc_spec *spec = codec->spec;
  9336. hda_nid_t pin;
  9337. pin = spec->autocfg.hp_pins[0];
  9338. if (pin) /* connect to front and use dac 0 */
  9339. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9340. }
  9341. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9342. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9343. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9344. {
  9345. struct alc_spec *spec = codec->spec;
  9346. int i;
  9347. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9348. hda_nid_t nid = spec->autocfg.input_pins[i];
  9349. if (alc861vd_is_input_pin(nid)) {
  9350. snd_hda_codec_write(codec, nid, 0,
  9351. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9352. i <= AUTO_PIN_FRONT_MIC ?
  9353. PIN_VREF80 : PIN_IN);
  9354. if (nid != ALC861VD_PIN_CD_NID)
  9355. snd_hda_codec_write(codec, nid, 0,
  9356. AC_VERB_SET_AMP_GAIN_MUTE,
  9357. AMP_OUT_MUTE);
  9358. }
  9359. }
  9360. }
  9361. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9362. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9363. /* add playback controls from the parsed DAC table */
  9364. /* Based on ALC880 version. But ALC861VD has separate,
  9365. * different NIDs for mute/unmute switch and volume control */
  9366. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9367. const struct auto_pin_cfg *cfg)
  9368. {
  9369. char name[32];
  9370. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9371. hda_nid_t nid_v, nid_s;
  9372. int i, err;
  9373. for (i = 0; i < cfg->line_outs; i++) {
  9374. if (!spec->multiout.dac_nids[i])
  9375. continue;
  9376. nid_v = alc861vd_idx_to_mixer_vol(
  9377. alc880_dac_to_idx(
  9378. spec->multiout.dac_nids[i]));
  9379. nid_s = alc861vd_idx_to_mixer_switch(
  9380. alc880_dac_to_idx(
  9381. spec->multiout.dac_nids[i]));
  9382. if (i == 2) {
  9383. /* Center/LFE */
  9384. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9385. "Center Playback Volume",
  9386. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9387. HDA_OUTPUT));
  9388. if (err < 0)
  9389. return err;
  9390. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9391. "LFE Playback Volume",
  9392. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9393. HDA_OUTPUT));
  9394. if (err < 0)
  9395. return err;
  9396. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9397. "Center Playback Switch",
  9398. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9399. HDA_INPUT));
  9400. if (err < 0)
  9401. return err;
  9402. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9403. "LFE Playback Switch",
  9404. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9405. HDA_INPUT));
  9406. if (err < 0)
  9407. return err;
  9408. } else {
  9409. sprintf(name, "%s Playback Volume", chname[i]);
  9410. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9411. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9412. HDA_OUTPUT));
  9413. if (err < 0)
  9414. return err;
  9415. sprintf(name, "%s Playback Switch", chname[i]);
  9416. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9417. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9418. HDA_INPUT));
  9419. if (err < 0)
  9420. return err;
  9421. }
  9422. }
  9423. return 0;
  9424. }
  9425. /* add playback controls for speaker and HP outputs */
  9426. /* Based on ALC880 version. But ALC861VD has separate,
  9427. * different NIDs for mute/unmute switch and volume control */
  9428. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9429. hda_nid_t pin, const char *pfx)
  9430. {
  9431. hda_nid_t nid_v, nid_s;
  9432. int err;
  9433. char name[32];
  9434. if (!pin)
  9435. return 0;
  9436. if (alc880_is_fixed_pin(pin)) {
  9437. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9438. /* specify the DAC as the extra output */
  9439. if (!spec->multiout.hp_nid)
  9440. spec->multiout.hp_nid = nid_v;
  9441. else
  9442. spec->multiout.extra_out_nid[0] = nid_v;
  9443. /* control HP volume/switch on the output mixer amp */
  9444. nid_v = alc861vd_idx_to_mixer_vol(
  9445. alc880_fixed_pin_idx(pin));
  9446. nid_s = alc861vd_idx_to_mixer_switch(
  9447. alc880_fixed_pin_idx(pin));
  9448. sprintf(name, "%s Playback Volume", pfx);
  9449. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9450. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9451. if (err < 0)
  9452. return err;
  9453. sprintf(name, "%s Playback Switch", pfx);
  9454. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9455. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9456. if (err < 0)
  9457. return err;
  9458. } else if (alc880_is_multi_pin(pin)) {
  9459. /* set manual connection */
  9460. /* we have only a switch on HP-out PIN */
  9461. sprintf(name, "%s Playback Switch", pfx);
  9462. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9463. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9464. if (err < 0)
  9465. return err;
  9466. }
  9467. return 0;
  9468. }
  9469. /* parse the BIOS configuration and set up the alc_spec
  9470. * return 1 if successful, 0 if the proper config is not found,
  9471. * or a negative error code
  9472. * Based on ALC880 version - had to change it to override
  9473. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9474. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9475. {
  9476. struct alc_spec *spec = codec->spec;
  9477. int err;
  9478. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9479. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9480. alc861vd_ignore);
  9481. if (err < 0)
  9482. return err;
  9483. if (!spec->autocfg.line_outs)
  9484. return 0; /* can't find valid BIOS pin config */
  9485. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9486. if (err < 0)
  9487. return err;
  9488. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9489. if (err < 0)
  9490. return err;
  9491. err = alc861vd_auto_create_extra_out(spec,
  9492. spec->autocfg.speaker_pins[0],
  9493. "Speaker");
  9494. if (err < 0)
  9495. return err;
  9496. err = alc861vd_auto_create_extra_out(spec,
  9497. spec->autocfg.hp_pins[0],
  9498. "Headphone");
  9499. if (err < 0)
  9500. return err;
  9501. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9502. if (err < 0)
  9503. return err;
  9504. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9505. if (spec->autocfg.dig_out_pin)
  9506. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9507. if (spec->kctl_alloc)
  9508. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9509. spec->init_verbs[spec->num_init_verbs++]
  9510. = alc861vd_volume_init_verbs;
  9511. spec->num_mux_defs = 1;
  9512. spec->input_mux = &spec->private_imux;
  9513. return 1;
  9514. }
  9515. /* additional initialization for auto-configuration model */
  9516. static void alc861vd_auto_init(struct hda_codec *codec)
  9517. {
  9518. alc861vd_auto_init_multi_out(codec);
  9519. alc861vd_auto_init_hp_out(codec);
  9520. alc861vd_auto_init_analog_input(codec);
  9521. }
  9522. static int patch_alc861vd(struct hda_codec *codec)
  9523. {
  9524. struct alc_spec *spec;
  9525. int err, board_config;
  9526. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9527. if (spec == NULL)
  9528. return -ENOMEM;
  9529. codec->spec = spec;
  9530. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9531. alc861vd_models,
  9532. alc861vd_cfg_tbl);
  9533. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9534. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9535. "ALC861VD, trying auto-probe from BIOS...\n");
  9536. board_config = ALC861VD_AUTO;
  9537. }
  9538. if (board_config == ALC861VD_AUTO) {
  9539. /* automatic parse from the BIOS config */
  9540. err = alc861vd_parse_auto_config(codec);
  9541. if (err < 0) {
  9542. alc_free(codec);
  9543. return err;
  9544. } else if (!err) {
  9545. printk(KERN_INFO
  9546. "hda_codec: Cannot set up configuration "
  9547. "from BIOS. Using base mode...\n");
  9548. board_config = ALC861VD_3ST;
  9549. }
  9550. }
  9551. if (board_config != ALC861VD_AUTO)
  9552. setup_preset(spec, &alc861vd_presets[board_config]);
  9553. spec->stream_name_analog = "ALC861VD Analog";
  9554. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9555. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9556. spec->stream_name_digital = "ALC861VD Digital";
  9557. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9558. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9559. spec->adc_nids = alc861vd_adc_nids;
  9560. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9561. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9562. spec->num_mixers++;
  9563. codec->patch_ops = alc_patch_ops;
  9564. if (board_config == ALC861VD_AUTO)
  9565. spec->init_hook = alc861vd_auto_init;
  9566. return 0;
  9567. }
  9568. /*
  9569. * ALC662 support
  9570. *
  9571. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9572. * configuration. Each pin widget can choose any input DACs and a mixer.
  9573. * Each ADC is connected from a mixer of all inputs. This makes possible
  9574. * 6-channel independent captures.
  9575. *
  9576. * In addition, an independent DAC for the multi-playback (not used in this
  9577. * driver yet).
  9578. */
  9579. #define ALC662_DIGOUT_NID 0x06
  9580. #define ALC662_DIGIN_NID 0x0a
  9581. static hda_nid_t alc662_dac_nids[4] = {
  9582. /* front, rear, clfe, rear_surr */
  9583. 0x02, 0x03, 0x04
  9584. };
  9585. static hda_nid_t alc662_adc_nids[1] = {
  9586. /* ADC1-2 */
  9587. 0x09,
  9588. };
  9589. /* input MUX */
  9590. /* FIXME: should be a matrix-type input source selection */
  9591. static struct hda_input_mux alc662_capture_source = {
  9592. .num_items = 4,
  9593. .items = {
  9594. { "Mic", 0x0 },
  9595. { "Front Mic", 0x1 },
  9596. { "Line", 0x2 },
  9597. { "CD", 0x4 },
  9598. },
  9599. };
  9600. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9601. .num_items = 2,
  9602. .items = {
  9603. { "Mic", 0x1 },
  9604. { "Line", 0x2 },
  9605. },
  9606. };
  9607. #define alc662_mux_enum_info alc_mux_enum_info
  9608. #define alc662_mux_enum_get alc_mux_enum_get
  9609. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9610. struct snd_ctl_elem_value *ucontrol)
  9611. {
  9612. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9613. struct alc_spec *spec = codec->spec;
  9614. const struct hda_input_mux *imux = spec->input_mux;
  9615. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9616. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9617. hda_nid_t nid = capture_mixers[adc_idx];
  9618. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9619. unsigned int i, idx;
  9620. idx = ucontrol->value.enumerated.item[0];
  9621. if (idx >= imux->num_items)
  9622. idx = imux->num_items - 1;
  9623. if (*cur_val == idx && !codec->in_resume)
  9624. return 0;
  9625. for (i = 0; i < imux->num_items; i++) {
  9626. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  9627. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9628. v | (imux->items[i].index << 8));
  9629. }
  9630. *cur_val = idx;
  9631. return 1;
  9632. }
  9633. /*
  9634. * 2ch mode
  9635. */
  9636. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9637. { 2, NULL }
  9638. };
  9639. /*
  9640. * 2ch mode
  9641. */
  9642. static struct hda_verb alc662_3ST_ch2_init[] = {
  9643. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9644. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9645. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9646. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9647. { } /* end */
  9648. };
  9649. /*
  9650. * 6ch mode
  9651. */
  9652. static struct hda_verb alc662_3ST_ch6_init[] = {
  9653. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9654. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9655. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9656. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9657. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9658. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9659. { } /* end */
  9660. };
  9661. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9662. { 2, alc662_3ST_ch2_init },
  9663. { 6, alc662_3ST_ch6_init },
  9664. };
  9665. /*
  9666. * 2ch mode
  9667. */
  9668. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9669. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9670. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9671. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9672. { } /* end */
  9673. };
  9674. /*
  9675. * 6ch mode
  9676. */
  9677. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9678. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9679. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9680. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9681. { } /* end */
  9682. };
  9683. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9684. { 2, alc662_sixstack_ch6_init },
  9685. { 6, alc662_sixstack_ch8_init },
  9686. };
  9687. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9688. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9689. */
  9690. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9691. /* output mixer control */
  9692. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9693. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9694. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9695. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9696. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9697. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9698. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9699. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9700. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9701. /*Input mixer control */
  9702. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9703. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9704. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9705. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9706. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9707. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9708. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9709. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9710. /* Capture mixer control */
  9711. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9712. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9713. {
  9714. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9715. .name = "Capture Source",
  9716. .count = 1,
  9717. .info = alc_mux_enum_info,
  9718. .get = alc_mux_enum_get,
  9719. .put = alc_mux_enum_put,
  9720. },
  9721. { } /* end */
  9722. };
  9723. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9724. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9725. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9726. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9727. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9728. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9729. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9730. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9731. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9732. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9733. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9734. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9735. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9736. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9737. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9738. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9739. {
  9740. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9741. /* .name = "Capture Source", */
  9742. .name = "Input Source",
  9743. .count = 1,
  9744. .info = alc662_mux_enum_info,
  9745. .get = alc662_mux_enum_get,
  9746. .put = alc662_mux_enum_put,
  9747. },
  9748. { } /* end */
  9749. };
  9750. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9751. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9752. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9753. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9754. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9755. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9756. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9757. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9758. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9759. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9760. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9761. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9762. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9763. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9764. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9765. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9766. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9767. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9768. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9769. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9770. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9771. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9772. {
  9773. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9774. /* .name = "Capture Source", */
  9775. .name = "Input Source",
  9776. .count = 1,
  9777. .info = alc662_mux_enum_info,
  9778. .get = alc662_mux_enum_get,
  9779. .put = alc662_mux_enum_put,
  9780. },
  9781. { } /* end */
  9782. };
  9783. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9784. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9785. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9786. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9787. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9788. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9789. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9790. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9791. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9792. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9793. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9794. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9795. {
  9796. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9797. /* .name = "Capture Source", */
  9798. .name = "Input Source",
  9799. .count = 1,
  9800. .info = alc662_mux_enum_info,
  9801. .get = alc662_mux_enum_get,
  9802. .put = alc662_mux_enum_put,
  9803. },
  9804. { } /* end */
  9805. };
  9806. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9807. {
  9808. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9809. .name = "Channel Mode",
  9810. .info = alc_ch_mode_info,
  9811. .get = alc_ch_mode_get,
  9812. .put = alc_ch_mode_put,
  9813. },
  9814. { } /* end */
  9815. };
  9816. static struct hda_verb alc662_init_verbs[] = {
  9817. /* ADC: mute amp left and right */
  9818. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9819. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9820. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9821. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9822. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9823. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9824. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9825. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9826. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9827. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9828. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9829. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9830. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9831. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9832. /* Front Pin: output 0 (0x0c) */
  9833. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9834. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9835. /* Rear Pin: output 1 (0x0d) */
  9836. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9837. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9838. /* CLFE Pin: output 2 (0x0e) */
  9839. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9840. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9841. /* Mic (rear) pin: input vref at 80% */
  9842. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9843. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9844. /* Front Mic pin: input vref at 80% */
  9845. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9846. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9847. /* Line In pin: input */
  9848. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9849. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9850. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9851. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9852. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9853. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9854. /* CD pin widget for input */
  9855. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9856. /* FIXME: use matrix-type input source selection */
  9857. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9858. /* Input mixer */
  9859. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9860. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9861. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9862. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9863. { }
  9864. };
  9865. static struct hda_verb alc662_sue_init_verbs[] = {
  9866. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9867. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9868. {}
  9869. };
  9870. /*
  9871. * generic initialization of ADC, input mixers and output mixers
  9872. */
  9873. static struct hda_verb alc662_auto_init_verbs[] = {
  9874. /*
  9875. * Unmute ADC and set the default input to mic-in
  9876. */
  9877. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9878. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9879. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  9880. * mixer widget
  9881. * Note: PASD motherboards uses the Line In 2 as the input for front
  9882. * panel mic (mic 2)
  9883. */
  9884. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9885. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9886. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9887. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9888. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9889. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9890. /*
  9891. * Set up output mixers (0x0c - 0x0f)
  9892. */
  9893. /* set vol=0 to output mixers */
  9894. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9895. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9896. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9897. /* set up input amps for analog loopback */
  9898. /* Amp Indices: DAC = 0, mixer = 1 */
  9899. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9900. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9901. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9902. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9903. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9904. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9905. /* FIXME: use matrix-type input source selection */
  9906. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9907. /* Input mixer */
  9908. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9909. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9910. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9911. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  9912. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9913. { }
  9914. };
  9915. /* capture mixer elements */
  9916. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  9917. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9918. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9919. {
  9920. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9921. /* The multiple "Capture Source" controls confuse alsamixer
  9922. * So call somewhat different..
  9923. * FIXME: the controls appear in the "playback" view!
  9924. */
  9925. /* .name = "Capture Source", */
  9926. .name = "Input Source",
  9927. .count = 1,
  9928. .info = alc882_mux_enum_info,
  9929. .get = alc882_mux_enum_get,
  9930. .put = alc882_mux_enum_put,
  9931. },
  9932. { } /* end */
  9933. };
  9934. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  9935. {
  9936. unsigned int present;
  9937. unsigned char bits;
  9938. present = snd_hda_codec_read(codec, 0x14, 0,
  9939. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9940. bits = present ? 0x80 : 0;
  9941. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9942. 0x80, bits);
  9943. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9944. 0x80, bits);
  9945. }
  9946. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  9947. {
  9948. unsigned int present;
  9949. unsigned char bits;
  9950. present = snd_hda_codec_read(codec, 0x1b, 0,
  9951. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9952. bits = present ? 0x80 : 0;
  9953. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9954. 0x80, bits);
  9955. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9956. 0x80, bits);
  9957. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9958. 0x80, bits);
  9959. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9960. 0x80, bits);
  9961. }
  9962. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  9963. unsigned int res)
  9964. {
  9965. if ((res >> 26) == ALC880_HP_EVENT)
  9966. alc662_lenovo_101e_all_automute(codec);
  9967. if ((res >> 26) == ALC880_FRONT_EVENT)
  9968. alc662_lenovo_101e_ispeaker_automute(codec);
  9969. }
  9970. /* pcm configuration: identiacal with ALC880 */
  9971. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  9972. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  9973. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  9974. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  9975. /*
  9976. * configuration and preset
  9977. */
  9978. static const char *alc662_models[ALC662_MODEL_LAST] = {
  9979. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  9980. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  9981. [ALC662_3ST_6ch] = "3stack-6ch",
  9982. [ALC662_5ST_DIG] = "6stack-dig",
  9983. [ALC662_LENOVO_101E] = "lenovo-101e",
  9984. [ALC662_AUTO] = "auto",
  9985. };
  9986. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  9987. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  9988. {}
  9989. };
  9990. static struct alc_config_preset alc662_presets[] = {
  9991. [ALC662_3ST_2ch_DIG] = {
  9992. .mixers = { alc662_3ST_2ch_mixer },
  9993. .init_verbs = { alc662_init_verbs },
  9994. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  9995. .dac_nids = alc662_dac_nids,
  9996. .dig_out_nid = ALC662_DIGOUT_NID,
  9997. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  9998. .adc_nids = alc662_adc_nids,
  9999. .dig_in_nid = ALC662_DIGIN_NID,
  10000. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10001. .channel_mode = alc662_3ST_2ch_modes,
  10002. .input_mux = &alc662_capture_source,
  10003. },
  10004. [ALC662_3ST_6ch_DIG] = {
  10005. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10006. .init_verbs = { alc662_init_verbs },
  10007. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10008. .dac_nids = alc662_dac_nids,
  10009. .dig_out_nid = ALC662_DIGOUT_NID,
  10010. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10011. .adc_nids = alc662_adc_nids,
  10012. .dig_in_nid = ALC662_DIGIN_NID,
  10013. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10014. .channel_mode = alc662_3ST_6ch_modes,
  10015. .need_dac_fix = 1,
  10016. .input_mux = &alc662_capture_source,
  10017. },
  10018. [ALC662_3ST_6ch] = {
  10019. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10020. .init_verbs = { alc662_init_verbs },
  10021. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10022. .dac_nids = alc662_dac_nids,
  10023. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10024. .adc_nids = alc662_adc_nids,
  10025. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10026. .channel_mode = alc662_3ST_6ch_modes,
  10027. .need_dac_fix = 1,
  10028. .input_mux = &alc662_capture_source,
  10029. },
  10030. [ALC662_5ST_DIG] = {
  10031. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10032. .init_verbs = { alc662_init_verbs },
  10033. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10034. .dac_nids = alc662_dac_nids,
  10035. .dig_out_nid = ALC662_DIGOUT_NID,
  10036. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10037. .adc_nids = alc662_adc_nids,
  10038. .dig_in_nid = ALC662_DIGIN_NID,
  10039. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10040. .channel_mode = alc662_5stack_modes,
  10041. .input_mux = &alc662_capture_source,
  10042. },
  10043. [ALC662_LENOVO_101E] = {
  10044. .mixers = { alc662_lenovo_101e_mixer },
  10045. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10046. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10047. .dac_nids = alc662_dac_nids,
  10048. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10049. .adc_nids = alc662_adc_nids,
  10050. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10051. .channel_mode = alc662_3ST_2ch_modes,
  10052. .input_mux = &alc662_lenovo_101e_capture_source,
  10053. .unsol_event = alc662_lenovo_101e_unsol_event,
  10054. .init_hook = alc662_lenovo_101e_all_automute,
  10055. },
  10056. };
  10057. /*
  10058. * BIOS auto configuration
  10059. */
  10060. /* add playback controls from the parsed DAC table */
  10061. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10062. const struct auto_pin_cfg *cfg)
  10063. {
  10064. char name[32];
  10065. static const char *chname[4] = {
  10066. "Front", "Surround", NULL /*CLFE*/, "Side"
  10067. };
  10068. hda_nid_t nid;
  10069. int i, err;
  10070. for (i = 0; i < cfg->line_outs; i++) {
  10071. if (!spec->multiout.dac_nids[i])
  10072. continue;
  10073. nid = alc880_idx_to_mixer(i);
  10074. if (i == 2) {
  10075. /* Center/LFE */
  10076. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10077. "Center Playback Volume",
  10078. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10079. HDA_OUTPUT));
  10080. if (err < 0)
  10081. return err;
  10082. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10083. "LFE Playback Volume",
  10084. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10085. HDA_OUTPUT));
  10086. if (err < 0)
  10087. return err;
  10088. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10089. "Center Playback Switch",
  10090. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10091. HDA_INPUT));
  10092. if (err < 0)
  10093. return err;
  10094. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10095. "LFE Playback Switch",
  10096. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10097. HDA_INPUT));
  10098. if (err < 0)
  10099. return err;
  10100. } else {
  10101. sprintf(name, "%s Playback Volume", chname[i]);
  10102. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10103. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10104. HDA_OUTPUT));
  10105. if (err < 0)
  10106. return err;
  10107. sprintf(name, "%s Playback Switch", chname[i]);
  10108. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10109. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10110. HDA_INPUT));
  10111. if (err < 0)
  10112. return err;
  10113. }
  10114. }
  10115. return 0;
  10116. }
  10117. /* add playback controls for speaker and HP outputs */
  10118. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10119. const char *pfx)
  10120. {
  10121. hda_nid_t nid;
  10122. int err;
  10123. char name[32];
  10124. if (!pin)
  10125. return 0;
  10126. if (alc880_is_fixed_pin(pin)) {
  10127. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10128. /* printk("DAC nid=%x\n",nid); */
  10129. /* specify the DAC as the extra output */
  10130. if (!spec->multiout.hp_nid)
  10131. spec->multiout.hp_nid = nid;
  10132. else
  10133. spec->multiout.extra_out_nid[0] = nid;
  10134. /* control HP volume/switch on the output mixer amp */
  10135. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10136. sprintf(name, "%s Playback Volume", pfx);
  10137. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10138. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10139. if (err < 0)
  10140. return err;
  10141. sprintf(name, "%s Playback Switch", pfx);
  10142. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10143. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10144. if (err < 0)
  10145. return err;
  10146. } else if (alc880_is_multi_pin(pin)) {
  10147. /* set manual connection */
  10148. /* we have only a switch on HP-out PIN */
  10149. sprintf(name, "%s Playback Switch", pfx);
  10150. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10151. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10152. if (err < 0)
  10153. return err;
  10154. }
  10155. return 0;
  10156. }
  10157. /* create playback/capture controls for input pins */
  10158. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10159. const struct auto_pin_cfg *cfg)
  10160. {
  10161. struct hda_input_mux *imux = &spec->private_imux;
  10162. int i, err, idx;
  10163. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10164. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10165. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10166. err = new_analog_input(spec, cfg->input_pins[i],
  10167. auto_pin_cfg_labels[i],
  10168. idx, 0x0b);
  10169. if (err < 0)
  10170. return err;
  10171. imux->items[imux->num_items].label =
  10172. auto_pin_cfg_labels[i];
  10173. imux->items[imux->num_items].index =
  10174. alc880_input_pin_idx(cfg->input_pins[i]);
  10175. imux->num_items++;
  10176. }
  10177. }
  10178. return 0;
  10179. }
  10180. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10181. hda_nid_t nid, int pin_type,
  10182. int dac_idx)
  10183. {
  10184. /* set as output */
  10185. snd_hda_codec_write(codec, nid, 0,
  10186. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10187. snd_hda_codec_write(codec, nid, 0,
  10188. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10189. /* need the manual connection? */
  10190. if (alc880_is_multi_pin(nid)) {
  10191. struct alc_spec *spec = codec->spec;
  10192. int idx = alc880_multi_pin_idx(nid);
  10193. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10194. AC_VERB_SET_CONNECT_SEL,
  10195. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10196. }
  10197. }
  10198. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10199. {
  10200. struct alc_spec *spec = codec->spec;
  10201. int i;
  10202. for (i = 0; i <= HDA_SIDE; i++) {
  10203. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10204. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10205. if (nid)
  10206. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10207. i);
  10208. }
  10209. }
  10210. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10211. {
  10212. struct alc_spec *spec = codec->spec;
  10213. hda_nid_t pin;
  10214. pin = spec->autocfg.hp_pins[0];
  10215. if (pin) /* connect to front */
  10216. /* use dac 0 */
  10217. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10218. }
  10219. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10220. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10221. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10222. {
  10223. struct alc_spec *spec = codec->spec;
  10224. int i;
  10225. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10226. hda_nid_t nid = spec->autocfg.input_pins[i];
  10227. if (alc662_is_input_pin(nid)) {
  10228. snd_hda_codec_write(codec, nid, 0,
  10229. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10230. (i <= AUTO_PIN_FRONT_MIC ?
  10231. PIN_VREF80 : PIN_IN));
  10232. if (nid != ALC662_PIN_CD_NID)
  10233. snd_hda_codec_write(codec, nid, 0,
  10234. AC_VERB_SET_AMP_GAIN_MUTE,
  10235. AMP_OUT_MUTE);
  10236. }
  10237. }
  10238. }
  10239. static int alc662_parse_auto_config(struct hda_codec *codec)
  10240. {
  10241. struct alc_spec *spec = codec->spec;
  10242. int err;
  10243. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10244. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10245. alc662_ignore);
  10246. if (err < 0)
  10247. return err;
  10248. if (!spec->autocfg.line_outs)
  10249. return 0; /* can't find valid BIOS pin config */
  10250. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10251. if (err < 0)
  10252. return err;
  10253. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10254. if (err < 0)
  10255. return err;
  10256. err = alc662_auto_create_extra_out(spec,
  10257. spec->autocfg.speaker_pins[0],
  10258. "Speaker");
  10259. if (err < 0)
  10260. return err;
  10261. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10262. "Headphone");
  10263. if (err < 0)
  10264. return err;
  10265. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10266. if (err < 0)
  10267. return err;
  10268. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10269. if (spec->autocfg.dig_out_pin)
  10270. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10271. if (spec->kctl_alloc)
  10272. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10273. spec->num_mux_defs = 1;
  10274. spec->input_mux = &spec->private_imux;
  10275. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10276. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10277. spec->num_mixers++;
  10278. return 1;
  10279. }
  10280. /* additional initialization for auto-configuration model */
  10281. static void alc662_auto_init(struct hda_codec *codec)
  10282. {
  10283. alc662_auto_init_multi_out(codec);
  10284. alc662_auto_init_hp_out(codec);
  10285. alc662_auto_init_analog_input(codec);
  10286. }
  10287. static int patch_alc662(struct hda_codec *codec)
  10288. {
  10289. struct alc_spec *spec;
  10290. int err, board_config;
  10291. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10292. if (!spec)
  10293. return -ENOMEM;
  10294. codec->spec = spec;
  10295. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10296. alc662_models,
  10297. alc662_cfg_tbl);
  10298. if (board_config < 0) {
  10299. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10300. "trying auto-probe from BIOS...\n");
  10301. board_config = ALC662_AUTO;
  10302. }
  10303. if (board_config == ALC662_AUTO) {
  10304. /* automatic parse from the BIOS config */
  10305. err = alc662_parse_auto_config(codec);
  10306. if (err < 0) {
  10307. alc_free(codec);
  10308. return err;
  10309. } else if (!err) {
  10310. printk(KERN_INFO
  10311. "hda_codec: Cannot set up configuration "
  10312. "from BIOS. Using base mode...\n");
  10313. board_config = ALC662_3ST_2ch_DIG;
  10314. }
  10315. }
  10316. if (board_config != ALC662_AUTO)
  10317. setup_preset(spec, &alc662_presets[board_config]);
  10318. spec->stream_name_analog = "ALC662 Analog";
  10319. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10320. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10321. spec->stream_name_digital = "ALC662 Digital";
  10322. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10323. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10324. if (!spec->adc_nids && spec->input_mux) {
  10325. spec->adc_nids = alc662_adc_nids;
  10326. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10327. }
  10328. codec->patch_ops = alc_patch_ops;
  10329. if (board_config == ALC662_AUTO)
  10330. spec->init_hook = alc662_auto_init;
  10331. return 0;
  10332. }
  10333. /*
  10334. * patch entries
  10335. */
  10336. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10337. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10338. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10339. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10340. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10341. .patch = patch_alc861 },
  10342. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10343. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10344. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10345. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10346. .patch = patch_alc883 },
  10347. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10348. .patch = patch_alc662 },
  10349. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10350. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10351. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10352. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10353. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10354. {} /* terminator */
  10355. };