patch_realtek.c 382 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537
  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. * Fix-up pin default configurations
  657. */
  658. struct alc_pincfg {
  659. hda_nid_t nid;
  660. u32 val;
  661. };
  662. static void alc_fix_pincfg(struct hda_codec *codec,
  663. const struct snd_pci_quirk *quirk,
  664. const struct alc_pincfg **pinfix)
  665. {
  666. const struct alc_pincfg *cfg;
  667. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  668. if (!quirk)
  669. return;
  670. cfg = pinfix[quirk->value];
  671. for (; cfg->nid; cfg++) {
  672. int i;
  673. u32 val = cfg->val;
  674. for (i = 0; i < 4; i++) {
  675. snd_hda_codec_write(codec, cfg->nid, 0,
  676. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  677. val & 0xff);
  678. val >>= 8;
  679. }
  680. }
  681. }
  682. /*
  683. * ALC880 3-stack model
  684. *
  685. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  686. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  687. * F-Mic = 0x1b, HP = 0x19
  688. */
  689. static hda_nid_t alc880_dac_nids[4] = {
  690. /* front, rear, clfe, rear_surr */
  691. 0x02, 0x05, 0x04, 0x03
  692. };
  693. static hda_nid_t alc880_adc_nids[3] = {
  694. /* ADC0-2 */
  695. 0x07, 0x08, 0x09,
  696. };
  697. /* The datasheet says the node 0x07 is connected from inputs,
  698. * but it shows zero connection in the real implementation on some devices.
  699. * Note: this is a 915GAV bug, fixed on 915GLV
  700. */
  701. static hda_nid_t alc880_adc_nids_alt[2] = {
  702. /* ADC1-2 */
  703. 0x08, 0x09,
  704. };
  705. #define ALC880_DIGOUT_NID 0x06
  706. #define ALC880_DIGIN_NID 0x0a
  707. static struct hda_input_mux alc880_capture_source = {
  708. .num_items = 4,
  709. .items = {
  710. { "Mic", 0x0 },
  711. { "Front Mic", 0x3 },
  712. { "Line", 0x2 },
  713. { "CD", 0x4 },
  714. },
  715. };
  716. /* channel source setting (2/6 channel selection for 3-stack) */
  717. /* 2ch mode */
  718. static struct hda_verb alc880_threestack_ch2_init[] = {
  719. /* set line-in to input, mute it */
  720. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  721. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  722. /* set mic-in to input vref 80%, mute it */
  723. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  724. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  725. { } /* end */
  726. };
  727. /* 6ch mode */
  728. static struct hda_verb alc880_threestack_ch6_init[] = {
  729. /* set line-in to output, unmute it */
  730. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  731. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  732. /* set mic-in to output, unmute it */
  733. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  734. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  735. { } /* end */
  736. };
  737. static struct hda_channel_mode alc880_threestack_modes[2] = {
  738. { 2, alc880_threestack_ch2_init },
  739. { 6, alc880_threestack_ch6_init },
  740. };
  741. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  742. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  743. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  744. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  745. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  746. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  747. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  748. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  749. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  750. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  751. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  752. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  753. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  754. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  755. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  756. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  757. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  758. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  759. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  760. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  761. {
  762. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  763. .name = "Channel Mode",
  764. .info = alc_ch_mode_info,
  765. .get = alc_ch_mode_get,
  766. .put = alc_ch_mode_put,
  767. },
  768. { } /* end */
  769. };
  770. /* capture mixer elements */
  771. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  772. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  773. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  774. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  775. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  776. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  777. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  778. {
  779. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  780. /* The multiple "Capture Source" controls confuse alsamixer
  781. * So call somewhat different..
  782. * FIXME: the controls appear in the "playback" view!
  783. */
  784. /* .name = "Capture Source", */
  785. .name = "Input Source",
  786. .count = 3,
  787. .info = alc_mux_enum_info,
  788. .get = alc_mux_enum_get,
  789. .put = alc_mux_enum_put,
  790. },
  791. { } /* end */
  792. };
  793. /* capture mixer elements (in case NID 0x07 not available) */
  794. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  795. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  796. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  797. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  798. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  799. {
  800. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  801. /* The multiple "Capture Source" controls confuse alsamixer
  802. * So call somewhat different..
  803. * FIXME: the controls appear in the "playback" view!
  804. */
  805. /* .name = "Capture Source", */
  806. .name = "Input Source",
  807. .count = 2,
  808. .info = alc_mux_enum_info,
  809. .get = alc_mux_enum_get,
  810. .put = alc_mux_enum_put,
  811. },
  812. { } /* end */
  813. };
  814. /*
  815. * ALC880 5-stack model
  816. *
  817. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  818. * Side = 0x02 (0xd)
  819. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  820. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  821. */
  822. /* additional mixers to alc880_three_stack_mixer */
  823. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  824. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  825. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  826. { } /* end */
  827. };
  828. /* channel source setting (6/8 channel selection for 5-stack) */
  829. /* 6ch mode */
  830. static struct hda_verb alc880_fivestack_ch6_init[] = {
  831. /* set line-in to input, mute it */
  832. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  833. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  834. { } /* end */
  835. };
  836. /* 8ch mode */
  837. static struct hda_verb alc880_fivestack_ch8_init[] = {
  838. /* set line-in to output, unmute it */
  839. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  840. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  841. { } /* end */
  842. };
  843. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  844. { 6, alc880_fivestack_ch6_init },
  845. { 8, alc880_fivestack_ch8_init },
  846. };
  847. /*
  848. * ALC880 6-stack model
  849. *
  850. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  851. * Side = 0x05 (0x0f)
  852. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  853. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  854. */
  855. static hda_nid_t alc880_6st_dac_nids[4] = {
  856. /* front, rear, clfe, rear_surr */
  857. 0x02, 0x03, 0x04, 0x05
  858. };
  859. static struct hda_input_mux alc880_6stack_capture_source = {
  860. .num_items = 4,
  861. .items = {
  862. { "Mic", 0x0 },
  863. { "Front Mic", 0x1 },
  864. { "Line", 0x2 },
  865. { "CD", 0x4 },
  866. },
  867. };
  868. /* fixed 8-channels */
  869. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  870. { 8, NULL },
  871. };
  872. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  873. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  874. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  875. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  876. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  877. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  878. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  879. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  880. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  881. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  882. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  883. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  884. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  885. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  886. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  887. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  888. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  889. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  890. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  891. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  892. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  893. {
  894. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  895. .name = "Channel Mode",
  896. .info = alc_ch_mode_info,
  897. .get = alc_ch_mode_get,
  898. .put = alc_ch_mode_put,
  899. },
  900. { } /* end */
  901. };
  902. /*
  903. * ALC880 W810 model
  904. *
  905. * W810 has rear IO for:
  906. * Front (DAC 02)
  907. * Surround (DAC 03)
  908. * Center/LFE (DAC 04)
  909. * Digital out (06)
  910. *
  911. * The system also has a pair of internal speakers, and a headphone jack.
  912. * These are both connected to Line2 on the codec, hence to DAC 02.
  913. *
  914. * There is a variable resistor to control the speaker or headphone
  915. * volume. This is a hardware-only device without a software API.
  916. *
  917. * Plugging headphones in will disable the internal speakers. This is
  918. * implemented in hardware, not via the driver using jack sense. In
  919. * a similar fashion, plugging into the rear socket marked "front" will
  920. * disable both the speakers and headphones.
  921. *
  922. * For input, there's a microphone jack, and an "audio in" jack.
  923. * These may not do anything useful with this driver yet, because I
  924. * haven't setup any initialization verbs for these yet...
  925. */
  926. static hda_nid_t alc880_w810_dac_nids[3] = {
  927. /* front, rear/surround, clfe */
  928. 0x02, 0x03, 0x04
  929. };
  930. /* fixed 6 channels */
  931. static struct hda_channel_mode alc880_w810_modes[1] = {
  932. { 6, NULL }
  933. };
  934. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  935. static struct snd_kcontrol_new alc880_w810_base_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("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  939. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  940. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  941. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  942. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  943. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  944. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  945. { } /* end */
  946. };
  947. /*
  948. * Z710V model
  949. *
  950. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  951. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  952. * Line = 0x1a
  953. */
  954. static hda_nid_t alc880_z71v_dac_nids[1] = {
  955. 0x02
  956. };
  957. #define ALC880_Z71V_HP_DAC 0x03
  958. /* fixed 2 channels */
  959. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  960. { 2, NULL }
  961. };
  962. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  963. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  964. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  965. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  966. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  967. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  968. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  969. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  970. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  971. { } /* end */
  972. };
  973. /* FIXME! */
  974. /*
  975. * ALC880 F1734 model
  976. *
  977. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  978. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  979. */
  980. static hda_nid_t alc880_f1734_dac_nids[1] = {
  981. 0x03
  982. };
  983. #define ALC880_F1734_HP_DAC 0x02
  984. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  985. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  986. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  987. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  988. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  989. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  990. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, 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. { } /* end */
  994. };
  995. /* FIXME! */
  996. /*
  997. * ALC880 ASUS model
  998. *
  999. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1000. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1001. * Mic = 0x18, Line = 0x1a
  1002. */
  1003. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1004. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1005. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1006. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1007. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1008. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1009. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1010. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1011. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1012. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1013. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1014. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1015. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1016. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1017. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1018. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1019. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1020. {
  1021. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1022. .name = "Channel Mode",
  1023. .info = alc_ch_mode_info,
  1024. .get = alc_ch_mode_get,
  1025. .put = alc_ch_mode_put,
  1026. },
  1027. { } /* end */
  1028. };
  1029. /* FIXME! */
  1030. /*
  1031. * ALC880 ASUS W1V model
  1032. *
  1033. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1034. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1035. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1036. */
  1037. /* additional mixers to alc880_asus_mixer */
  1038. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1039. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1040. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1041. { } /* end */
  1042. };
  1043. /* additional mixers to alc880_asus_mixer */
  1044. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1045. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1046. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1047. { } /* end */
  1048. };
  1049. /* TCL S700 */
  1050. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1051. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1052. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1053. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1054. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1055. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1056. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1057. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1058. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1059. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1060. {
  1061. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1062. /* The multiple "Capture Source" controls confuse alsamixer
  1063. * So call somewhat different..
  1064. * FIXME: the controls appear in the "playback" view!
  1065. */
  1066. /* .name = "Capture Source", */
  1067. .name = "Input Source",
  1068. .count = 1,
  1069. .info = alc_mux_enum_info,
  1070. .get = alc_mux_enum_get,
  1071. .put = alc_mux_enum_put,
  1072. },
  1073. { } /* end */
  1074. };
  1075. /* Uniwill */
  1076. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1077. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1078. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1079. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1080. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1081. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1082. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1083. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1084. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1085. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1086. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1087. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1088. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1089. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1090. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1091. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1092. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1093. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1094. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1095. {
  1096. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1097. .name = "Channel Mode",
  1098. .info = alc_ch_mode_info,
  1099. .get = alc_ch_mode_get,
  1100. .put = alc_ch_mode_put,
  1101. },
  1102. { } /* end */
  1103. };
  1104. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1105. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1106. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1107. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1108. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1109. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1110. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1111. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1112. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1113. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1114. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1115. { } /* end */
  1116. };
  1117. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1118. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1119. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1120. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1121. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1122. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1123. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1124. { } /* end */
  1125. };
  1126. /*
  1127. * build control elements
  1128. */
  1129. static int alc_build_controls(struct hda_codec *codec)
  1130. {
  1131. struct alc_spec *spec = codec->spec;
  1132. int err;
  1133. int i;
  1134. for (i = 0; i < spec->num_mixers; i++) {
  1135. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1136. if (err < 0)
  1137. return err;
  1138. }
  1139. if (spec->multiout.dig_out_nid) {
  1140. err = snd_hda_create_spdif_out_ctls(codec,
  1141. spec->multiout.dig_out_nid);
  1142. if (err < 0)
  1143. return err;
  1144. }
  1145. if (spec->dig_in_nid) {
  1146. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1147. if (err < 0)
  1148. return err;
  1149. }
  1150. return 0;
  1151. }
  1152. /*
  1153. * initialize the codec volumes, etc
  1154. */
  1155. /*
  1156. * generic initialization of ADC, input mixers and output mixers
  1157. */
  1158. static struct hda_verb alc880_volume_init_verbs[] = {
  1159. /*
  1160. * Unmute ADC0-2 and set the default input to mic-in
  1161. */
  1162. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1163. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1164. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1165. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1166. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1167. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1168. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1169. * mixer widget
  1170. * Note: PASD motherboards uses the Line In 2 as the input for front
  1171. * panel mic (mic 2)
  1172. */
  1173. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1174. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1175. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1179. /*
  1180. * Set up output mixers (0x0c - 0x0f)
  1181. */
  1182. /* set vol=0 to output mixers */
  1183. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1184. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1185. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1186. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1187. /* set up input amps for analog loopback */
  1188. /* Amp Indices: DAC = 0, mixer = 1 */
  1189. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1191. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1193. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1195. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1197. { }
  1198. };
  1199. /*
  1200. * 3-stack pin configuration:
  1201. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1202. */
  1203. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1204. /*
  1205. * preset connection lists of input pins
  1206. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1207. */
  1208. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1209. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1210. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1211. /*
  1212. * Set pin mode and muting
  1213. */
  1214. /* set front pin widgets 0x14 for output */
  1215. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1216. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1217. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1218. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1219. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1220. /* Mic2 (as headphone out) for HP output */
  1221. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1222. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1223. /* Line In pin widget for input */
  1224. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1225. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1226. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1227. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1228. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1229. /* CD pin widget for input */
  1230. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1231. { }
  1232. };
  1233. /*
  1234. * 5-stack pin configuration:
  1235. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1236. * line-in/side = 0x1a, f-mic = 0x1b
  1237. */
  1238. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1239. /*
  1240. * preset connection lists of input pins
  1241. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1242. */
  1243. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1244. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1245. /*
  1246. * Set pin mode and muting
  1247. */
  1248. /* set pin widgets 0x14-0x17 for output */
  1249. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1250. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1251. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1253. /* unmute pins for output (no gain on this amp) */
  1254. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1255. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1258. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1259. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1260. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1261. /* Mic2 (as headphone out) for HP output */
  1262. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1263. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1264. /* Line In pin widget for input */
  1265. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1266. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1267. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1268. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1269. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1270. /* CD pin widget for input */
  1271. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1272. { }
  1273. };
  1274. /*
  1275. * W810 pin configuration:
  1276. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1277. */
  1278. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1279. /* hphone/speaker input selector: front DAC */
  1280. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1281. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1282. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1283. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1284. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1285. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1286. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1287. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1288. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1289. { }
  1290. };
  1291. /*
  1292. * Z71V pin configuration:
  1293. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1294. */
  1295. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1296. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1297. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1298. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1299. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1300. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1301. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1302. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1303. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1304. { }
  1305. };
  1306. /*
  1307. * 6-stack pin configuration:
  1308. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1309. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1310. */
  1311. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1312. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1313. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1314. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1315. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1316. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1318. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1319. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1320. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1321. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1322. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1323. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1324. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1325. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1326. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1327. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1328. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1329. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1330. { }
  1331. };
  1332. /*
  1333. * Uniwill pin configuration:
  1334. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1335. * line = 0x1a
  1336. */
  1337. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1338. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1339. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1340. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1341. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1342. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1343. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1344. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1345. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1346. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1347. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1349. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1351. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1353. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1354. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1355. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1356. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1357. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1358. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1359. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1360. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1361. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1362. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1363. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1364. { }
  1365. };
  1366. /*
  1367. * Uniwill P53
  1368. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1369. */
  1370. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1371. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1372. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1373. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1374. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1375. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1376. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1377. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1378. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1379. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1380. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1381. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1382. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1383. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1384. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1385. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1386. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1387. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1388. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1389. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1390. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1391. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1392. { }
  1393. };
  1394. static struct hda_verb alc880_beep_init_verbs[] = {
  1395. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1396. { }
  1397. };
  1398. /* toggle speaker-output according to the hp-jack state */
  1399. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1400. {
  1401. unsigned int present;
  1402. unsigned char bits;
  1403. present = snd_hda_codec_read(codec, 0x14, 0,
  1404. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1405. bits = present ? 0x80 : 0;
  1406. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1407. 0x80, bits);
  1408. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1409. 0x80, bits);
  1410. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1411. 0x80, bits);
  1412. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1413. 0x80, bits);
  1414. }
  1415. /* auto-toggle front mic */
  1416. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1417. {
  1418. unsigned int present;
  1419. unsigned char bits;
  1420. present = snd_hda_codec_read(codec, 0x18, 0,
  1421. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1422. bits = present ? 0x80 : 0;
  1423. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1424. 0x80, bits);
  1425. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1426. 0x80, bits);
  1427. }
  1428. static void alc880_uniwill_automute(struct hda_codec *codec)
  1429. {
  1430. alc880_uniwill_hp_automute(codec);
  1431. alc880_uniwill_mic_automute(codec);
  1432. }
  1433. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1434. unsigned int res)
  1435. {
  1436. /* Looks like the unsol event is incompatible with the standard
  1437. * definition. 4bit tag is placed at 28 bit!
  1438. */
  1439. switch (res >> 28) {
  1440. case ALC880_HP_EVENT:
  1441. alc880_uniwill_hp_automute(codec);
  1442. break;
  1443. case ALC880_MIC_EVENT:
  1444. alc880_uniwill_mic_automute(codec);
  1445. break;
  1446. }
  1447. }
  1448. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1449. {
  1450. unsigned int present;
  1451. unsigned char bits;
  1452. present = snd_hda_codec_read(codec, 0x14, 0,
  1453. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1454. bits = present ? 0x80 : 0;
  1455. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1456. 0x80, bits);
  1457. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1458. 0x80, bits);
  1459. }
  1460. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1461. {
  1462. unsigned int present;
  1463. present = snd_hda_codec_read(codec, 0x21, 0,
  1464. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1465. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1466. 0x7f, present);
  1467. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1468. 0x7f, present);
  1469. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1470. 0x7f, present);
  1471. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1472. 0x7f, present);
  1473. }
  1474. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1475. unsigned int res)
  1476. {
  1477. /* Looks like the unsol event is incompatible with the standard
  1478. * definition. 4bit tag is placed at 28 bit!
  1479. */
  1480. if ((res >> 28) == ALC880_HP_EVENT)
  1481. alc880_uniwill_p53_hp_automute(codec);
  1482. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1483. alc880_uniwill_p53_dcvol_automute(codec);
  1484. }
  1485. /* FIXME! */
  1486. /*
  1487. * F1734 pin configuration:
  1488. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1489. */
  1490. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1491. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1492. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1493. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1494. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1495. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1496. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1497. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1498. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1499. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1500. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1501. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1502. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1503. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1504. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1505. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1506. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1507. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1508. { }
  1509. };
  1510. /* FIXME! */
  1511. /*
  1512. * ASUS pin configuration:
  1513. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1514. */
  1515. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1516. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1517. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1518. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1519. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1520. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1521. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1522. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1523. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1524. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1525. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1526. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1527. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1528. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1529. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1530. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1531. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1532. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1533. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1534. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1535. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1536. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1537. { }
  1538. };
  1539. /* Enable GPIO mask and set output */
  1540. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1541. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1542. /* Clevo m520g init */
  1543. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1544. /* headphone output */
  1545. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1546. /* line-out */
  1547. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1548. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1549. /* Line-in */
  1550. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1551. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1552. /* CD */
  1553. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1554. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1555. /* Mic1 (rear panel) */
  1556. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1557. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1558. /* Mic2 (front panel) */
  1559. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1560. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1561. /* headphone */
  1562. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1563. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1564. /* change to EAPD mode */
  1565. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1566. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1567. { }
  1568. };
  1569. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1570. /* change to EAPD mode */
  1571. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1572. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1573. /* Headphone output */
  1574. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1575. /* Front output*/
  1576. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1577. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1578. /* Line In pin widget for input */
  1579. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1580. /* CD pin widget for input */
  1581. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1582. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1583. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1584. /* change to EAPD mode */
  1585. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1586. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1587. { }
  1588. };
  1589. /*
  1590. * LG m1 express dual
  1591. *
  1592. * Pin assignment:
  1593. * Rear Line-In/Out (blue): 0x14
  1594. * Build-in Mic-In: 0x15
  1595. * Speaker-out: 0x17
  1596. * HP-Out (green): 0x1b
  1597. * Mic-In/Out (red): 0x19
  1598. * SPDIF-Out: 0x1e
  1599. */
  1600. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1601. static hda_nid_t alc880_lg_dac_nids[3] = {
  1602. 0x05, 0x02, 0x03
  1603. };
  1604. /* seems analog CD is not working */
  1605. static struct hda_input_mux alc880_lg_capture_source = {
  1606. .num_items = 3,
  1607. .items = {
  1608. { "Mic", 0x1 },
  1609. { "Line", 0x5 },
  1610. { "Internal Mic", 0x6 },
  1611. },
  1612. };
  1613. /* 2,4,6 channel modes */
  1614. static struct hda_verb alc880_lg_ch2_init[] = {
  1615. /* set line-in and mic-in to input */
  1616. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1617. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1618. { }
  1619. };
  1620. static struct hda_verb alc880_lg_ch4_init[] = {
  1621. /* set line-in to out and mic-in to input */
  1622. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1623. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1624. { }
  1625. };
  1626. static struct hda_verb alc880_lg_ch6_init[] = {
  1627. /* set line-in and mic-in to output */
  1628. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1629. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1630. { }
  1631. };
  1632. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1633. { 2, alc880_lg_ch2_init },
  1634. { 4, alc880_lg_ch4_init },
  1635. { 6, alc880_lg_ch6_init },
  1636. };
  1637. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1638. /* FIXME: it's not really "master" but front channels */
  1639. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1640. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1641. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1642. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1643. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1644. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1645. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1646. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1647. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1648. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1649. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1650. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1651. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1652. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1653. {
  1654. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1655. .name = "Channel Mode",
  1656. .info = alc_ch_mode_info,
  1657. .get = alc_ch_mode_get,
  1658. .put = alc_ch_mode_put,
  1659. },
  1660. { } /* end */
  1661. };
  1662. static struct hda_verb alc880_lg_init_verbs[] = {
  1663. /* set capture source to mic-in */
  1664. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1665. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1666. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1667. /* mute all amp mixer inputs */
  1668. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1669. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1670. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1671. /* line-in to input */
  1672. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1673. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1674. /* built-in mic */
  1675. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1676. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1677. /* speaker-out */
  1678. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1679. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1680. /* mic-in to input */
  1681. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1682. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1683. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1684. /* HP-out */
  1685. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1686. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1687. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1688. /* jack sense */
  1689. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1690. { }
  1691. };
  1692. /* toggle speaker-output according to the hp-jack state */
  1693. static void alc880_lg_automute(struct hda_codec *codec)
  1694. {
  1695. unsigned int present;
  1696. unsigned char bits;
  1697. present = snd_hda_codec_read(codec, 0x1b, 0,
  1698. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1699. bits = present ? 0x80 : 0;
  1700. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1701. 0x80, bits);
  1702. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1703. 0x80, bits);
  1704. }
  1705. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1706. {
  1707. /* Looks like the unsol event is incompatible with the standard
  1708. * definition. 4bit tag is placed at 28 bit!
  1709. */
  1710. if ((res >> 28) == 0x01)
  1711. alc880_lg_automute(codec);
  1712. }
  1713. /*
  1714. * LG LW20
  1715. *
  1716. * Pin assignment:
  1717. * Speaker-out: 0x14
  1718. * Mic-In: 0x18
  1719. * Built-in Mic-In: 0x19 (?)
  1720. * HP-Out: 0x1b
  1721. * SPDIF-Out: 0x1e
  1722. */
  1723. /* seems analog CD is not working */
  1724. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1725. .num_items = 2,
  1726. .items = {
  1727. { "Mic", 0x0 },
  1728. { "Internal Mic", 0x1 },
  1729. },
  1730. };
  1731. #define alc880_lg_lw_modes alc880_threestack_modes
  1732. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1733. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1734. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1735. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1736. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1737. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1738. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1739. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1740. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1741. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1742. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1743. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1744. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1745. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1746. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1747. {
  1748. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1749. .name = "Channel Mode",
  1750. .info = alc_ch_mode_info,
  1751. .get = alc_ch_mode_get,
  1752. .put = alc_ch_mode_put,
  1753. },
  1754. { } /* end */
  1755. };
  1756. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1757. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1758. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1759. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1760. /* set capture source to mic-in */
  1761. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1762. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1763. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1764. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1765. /* speaker-out */
  1766. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1767. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1768. /* HP-out */
  1769. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1770. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1771. /* mic-in to input */
  1772. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1773. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1774. /* built-in mic */
  1775. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1776. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1777. /* jack sense */
  1778. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1779. { }
  1780. };
  1781. /* toggle speaker-output according to the hp-jack state */
  1782. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1783. {
  1784. unsigned int present;
  1785. unsigned char bits;
  1786. present = snd_hda_codec_read(codec, 0x1b, 0,
  1787. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1788. bits = present ? 0x80 : 0;
  1789. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1790. 0x80, bits);
  1791. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1792. 0x80, bits);
  1793. }
  1794. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1795. {
  1796. /* Looks like the unsol event is incompatible with the standard
  1797. * definition. 4bit tag is placed at 28 bit!
  1798. */
  1799. if ((res >> 28) == 0x01)
  1800. alc880_lg_lw_automute(codec);
  1801. }
  1802. /*
  1803. * Common callbacks
  1804. */
  1805. static int alc_init(struct hda_codec *codec)
  1806. {
  1807. struct alc_spec *spec = codec->spec;
  1808. unsigned int i;
  1809. for (i = 0; i < spec->num_init_verbs; i++)
  1810. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1811. if (spec->init_hook)
  1812. spec->init_hook(codec);
  1813. return 0;
  1814. }
  1815. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1816. {
  1817. struct alc_spec *spec = codec->spec;
  1818. if (spec->unsol_event)
  1819. spec->unsol_event(codec, res);
  1820. }
  1821. #ifdef CONFIG_PM
  1822. /*
  1823. * resume
  1824. */
  1825. static int alc_resume(struct hda_codec *codec)
  1826. {
  1827. struct alc_spec *spec = codec->spec;
  1828. int i;
  1829. alc_init(codec);
  1830. for (i = 0; i < spec->num_mixers; i++)
  1831. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1832. if (spec->multiout.dig_out_nid)
  1833. snd_hda_resume_spdif_out(codec);
  1834. if (spec->dig_in_nid)
  1835. snd_hda_resume_spdif_in(codec);
  1836. return 0;
  1837. }
  1838. #endif
  1839. /*
  1840. * Analog playback callbacks
  1841. */
  1842. static int alc880_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_analog_open(codec, &spec->multiout, substream);
  1848. }
  1849. static int alc880_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_analog_prepare(codec, &spec->multiout,
  1857. stream_tag, format, substream);
  1858. }
  1859. static int alc880_playback_pcm_cleanup(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_analog_cleanup(codec, &spec->multiout);
  1865. }
  1866. /*
  1867. * Digital out
  1868. */
  1869. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1870. struct hda_codec *codec,
  1871. struct snd_pcm_substream *substream)
  1872. {
  1873. struct alc_spec *spec = codec->spec;
  1874. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1875. }
  1876. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1877. struct hda_codec *codec,
  1878. unsigned int stream_tag,
  1879. unsigned int format,
  1880. struct snd_pcm_substream *substream)
  1881. {
  1882. struct alc_spec *spec = codec->spec;
  1883. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1884. stream_tag, format, substream);
  1885. }
  1886. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1887. struct hda_codec *codec,
  1888. struct snd_pcm_substream *substream)
  1889. {
  1890. struct alc_spec *spec = codec->spec;
  1891. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1892. }
  1893. /*
  1894. * Analog capture
  1895. */
  1896. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1897. struct hda_codec *codec,
  1898. unsigned int stream_tag,
  1899. unsigned int format,
  1900. struct snd_pcm_substream *substream)
  1901. {
  1902. struct alc_spec *spec = codec->spec;
  1903. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1904. stream_tag, 0, format);
  1905. return 0;
  1906. }
  1907. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1908. struct hda_codec *codec,
  1909. struct snd_pcm_substream *substream)
  1910. {
  1911. struct alc_spec *spec = codec->spec;
  1912. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1913. 0, 0, 0);
  1914. return 0;
  1915. }
  1916. /*
  1917. */
  1918. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1919. .substreams = 1,
  1920. .channels_min = 2,
  1921. .channels_max = 8,
  1922. /* NID is set in alc_build_pcms */
  1923. .ops = {
  1924. .open = alc880_playback_pcm_open,
  1925. .prepare = alc880_playback_pcm_prepare,
  1926. .cleanup = alc880_playback_pcm_cleanup
  1927. },
  1928. };
  1929. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1930. .substreams = 2,
  1931. .channels_min = 2,
  1932. .channels_max = 2,
  1933. /* NID is set in alc_build_pcms */
  1934. .ops = {
  1935. .prepare = alc880_capture_pcm_prepare,
  1936. .cleanup = alc880_capture_pcm_cleanup
  1937. },
  1938. };
  1939. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1940. .substreams = 1,
  1941. .channels_min = 2,
  1942. .channels_max = 2,
  1943. /* NID is set in alc_build_pcms */
  1944. .ops = {
  1945. .open = alc880_dig_playback_pcm_open,
  1946. .close = alc880_dig_playback_pcm_close,
  1947. .prepare = alc880_dig_playback_pcm_prepare
  1948. },
  1949. };
  1950. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1951. .substreams = 1,
  1952. .channels_min = 2,
  1953. .channels_max = 2,
  1954. /* NID is set in alc_build_pcms */
  1955. };
  1956. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1957. static struct hda_pcm_stream alc_pcm_null_playback = {
  1958. .substreams = 0,
  1959. .channels_min = 0,
  1960. .channels_max = 0,
  1961. };
  1962. static int alc_build_pcms(struct hda_codec *codec)
  1963. {
  1964. struct alc_spec *spec = codec->spec;
  1965. struct hda_pcm *info = spec->pcm_rec;
  1966. int i;
  1967. codec->num_pcms = 1;
  1968. codec->pcm_info = info;
  1969. info->name = spec->stream_name_analog;
  1970. if (spec->stream_analog_playback) {
  1971. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1972. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1973. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1974. }
  1975. if (spec->stream_analog_capture) {
  1976. snd_assert(spec->adc_nids, return -EINVAL);
  1977. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1978. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1979. }
  1980. if (spec->channel_mode) {
  1981. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1982. for (i = 0; i < spec->num_channel_mode; i++) {
  1983. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1984. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1985. }
  1986. }
  1987. }
  1988. /* SPDIF for stream index #1 */
  1989. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1990. codec->num_pcms = 2;
  1991. info = spec->pcm_rec + 1;
  1992. info->name = spec->stream_name_digital;
  1993. if (spec->multiout.dig_out_nid &&
  1994. spec->stream_digital_playback) {
  1995. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1996. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1997. }
  1998. if (spec->dig_in_nid &&
  1999. spec->stream_digital_capture) {
  2000. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  2001. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  2002. }
  2003. }
  2004. /* If the use of more than one ADC is requested for the current
  2005. * model, configure a second analog capture-only PCM.
  2006. */
  2007. /* Additional Analaog capture for index #2 */
  2008. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  2009. spec->adc_nids) {
  2010. codec->num_pcms = 3;
  2011. info = spec->pcm_rec + 2;
  2012. info->name = spec->stream_name_analog;
  2013. /* No playback stream for second PCM */
  2014. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2015. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2016. if (spec->stream_analog_capture) {
  2017. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2018. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2019. }
  2020. }
  2021. return 0;
  2022. }
  2023. static void alc_free(struct hda_codec *codec)
  2024. {
  2025. struct alc_spec *spec = codec->spec;
  2026. unsigned int i;
  2027. if (!spec)
  2028. return;
  2029. if (spec->kctl_alloc) {
  2030. for (i = 0; i < spec->num_kctl_used; i++)
  2031. kfree(spec->kctl_alloc[i].name);
  2032. kfree(spec->kctl_alloc);
  2033. }
  2034. kfree(spec);
  2035. }
  2036. /*
  2037. */
  2038. static struct hda_codec_ops alc_patch_ops = {
  2039. .build_controls = alc_build_controls,
  2040. .build_pcms = alc_build_pcms,
  2041. .init = alc_init,
  2042. .free = alc_free,
  2043. .unsol_event = alc_unsol_event,
  2044. #ifdef CONFIG_PM
  2045. .resume = alc_resume,
  2046. #endif
  2047. };
  2048. /*
  2049. * Test configuration for debugging
  2050. *
  2051. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2052. * enum controls.
  2053. */
  2054. #ifdef CONFIG_SND_DEBUG
  2055. static hda_nid_t alc880_test_dac_nids[4] = {
  2056. 0x02, 0x03, 0x04, 0x05
  2057. };
  2058. static struct hda_input_mux alc880_test_capture_source = {
  2059. .num_items = 7,
  2060. .items = {
  2061. { "In-1", 0x0 },
  2062. { "In-2", 0x1 },
  2063. { "In-3", 0x2 },
  2064. { "In-4", 0x3 },
  2065. { "CD", 0x4 },
  2066. { "Front", 0x5 },
  2067. { "Surround", 0x6 },
  2068. },
  2069. };
  2070. static struct hda_channel_mode alc880_test_modes[4] = {
  2071. { 2, NULL },
  2072. { 4, NULL },
  2073. { 6, NULL },
  2074. { 8, NULL },
  2075. };
  2076. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2077. struct snd_ctl_elem_info *uinfo)
  2078. {
  2079. static char *texts[] = {
  2080. "N/A", "Line Out", "HP Out",
  2081. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2082. };
  2083. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2084. uinfo->count = 1;
  2085. uinfo->value.enumerated.items = 8;
  2086. if (uinfo->value.enumerated.item >= 8)
  2087. uinfo->value.enumerated.item = 7;
  2088. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2089. return 0;
  2090. }
  2091. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2092. struct snd_ctl_elem_value *ucontrol)
  2093. {
  2094. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2095. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2096. unsigned int pin_ctl, item = 0;
  2097. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2098. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2099. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2100. if (pin_ctl & AC_PINCTL_HP_EN)
  2101. item = 2;
  2102. else
  2103. item = 1;
  2104. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2105. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2106. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2107. case AC_PINCTL_VREF_50: item = 4; break;
  2108. case AC_PINCTL_VREF_GRD: item = 5; break;
  2109. case AC_PINCTL_VREF_80: item = 6; break;
  2110. case AC_PINCTL_VREF_100: item = 7; break;
  2111. }
  2112. }
  2113. ucontrol->value.enumerated.item[0] = item;
  2114. return 0;
  2115. }
  2116. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2117. struct snd_ctl_elem_value *ucontrol)
  2118. {
  2119. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2120. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2121. static unsigned int ctls[] = {
  2122. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2123. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2124. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2125. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2126. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2127. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2128. };
  2129. unsigned int old_ctl, new_ctl;
  2130. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2131. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2132. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2133. if (old_ctl != new_ctl) {
  2134. snd_hda_codec_write(codec, nid, 0,
  2135. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2136. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2137. (ucontrol->value.enumerated.item[0] >= 3 ?
  2138. 0xb080 : 0xb000));
  2139. return 1;
  2140. }
  2141. return 0;
  2142. }
  2143. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2144. struct snd_ctl_elem_info *uinfo)
  2145. {
  2146. static char *texts[] = {
  2147. "Front", "Surround", "CLFE", "Side"
  2148. };
  2149. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2150. uinfo->count = 1;
  2151. uinfo->value.enumerated.items = 4;
  2152. if (uinfo->value.enumerated.item >= 4)
  2153. uinfo->value.enumerated.item = 3;
  2154. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2155. return 0;
  2156. }
  2157. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2158. struct snd_ctl_elem_value *ucontrol)
  2159. {
  2160. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2161. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2162. unsigned int sel;
  2163. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2164. ucontrol->value.enumerated.item[0] = sel & 3;
  2165. return 0;
  2166. }
  2167. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2168. struct snd_ctl_elem_value *ucontrol)
  2169. {
  2170. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2171. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2172. unsigned int sel;
  2173. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2174. if (ucontrol->value.enumerated.item[0] != sel) {
  2175. sel = ucontrol->value.enumerated.item[0] & 3;
  2176. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2177. return 1;
  2178. }
  2179. return 0;
  2180. }
  2181. #define PIN_CTL_TEST(xname,nid) { \
  2182. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2183. .name = xname, \
  2184. .info = alc_test_pin_ctl_info, \
  2185. .get = alc_test_pin_ctl_get, \
  2186. .put = alc_test_pin_ctl_put, \
  2187. .private_value = nid \
  2188. }
  2189. #define PIN_SRC_TEST(xname,nid) { \
  2190. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2191. .name = xname, \
  2192. .info = alc_test_pin_src_info, \
  2193. .get = alc_test_pin_src_get, \
  2194. .put = alc_test_pin_src_put, \
  2195. .private_value = nid \
  2196. }
  2197. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2198. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2199. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2200. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2201. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2202. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2203. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2204. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2205. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2206. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2207. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2208. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2209. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2210. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2211. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2212. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2213. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2214. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2215. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2216. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2217. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2218. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2219. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2220. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2221. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2222. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2223. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2224. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2225. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2226. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2227. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2228. {
  2229. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2230. .name = "Channel Mode",
  2231. .info = alc_ch_mode_info,
  2232. .get = alc_ch_mode_get,
  2233. .put = alc_ch_mode_put,
  2234. },
  2235. { } /* end */
  2236. };
  2237. static struct hda_verb alc880_test_init_verbs[] = {
  2238. /* Unmute inputs of 0x0c - 0x0f */
  2239. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2240. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2241. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2242. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2243. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2244. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2245. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2246. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2247. /* Vol output for 0x0c-0x0f */
  2248. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2249. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2250. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2251. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2252. /* Set output pins 0x14-0x17 */
  2253. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2254. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2255. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2256. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2257. /* Unmute output pins 0x14-0x17 */
  2258. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2259. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2260. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2261. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2262. /* Set input pins 0x18-0x1c */
  2263. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2264. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2265. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2266. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2267. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2268. /* Mute input pins 0x18-0x1b */
  2269. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2270. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2271. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2272. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2273. /* ADC set up */
  2274. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2275. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2276. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2277. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2278. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2279. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2280. /* Analog input/passthru */
  2281. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2282. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2283. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2284. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2285. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2286. { }
  2287. };
  2288. #endif
  2289. /*
  2290. */
  2291. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2292. [ALC880_3ST] = "3stack",
  2293. [ALC880_TCL_S700] = "tcl",
  2294. [ALC880_3ST_DIG] = "3stack-digout",
  2295. [ALC880_CLEVO] = "clevo",
  2296. [ALC880_5ST] = "5stack",
  2297. [ALC880_5ST_DIG] = "5stack-digout",
  2298. [ALC880_W810] = "w810",
  2299. [ALC880_Z71V] = "z71v",
  2300. [ALC880_6ST] = "6stack",
  2301. [ALC880_6ST_DIG] = "6stack-digout",
  2302. [ALC880_ASUS] = "asus",
  2303. [ALC880_ASUS_W1V] = "asus-w1v",
  2304. [ALC880_ASUS_DIG] = "asus-dig",
  2305. [ALC880_ASUS_DIG2] = "asus-dig2",
  2306. [ALC880_UNIWILL_DIG] = "uniwill",
  2307. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2308. [ALC880_FUJITSU] = "fujitsu",
  2309. [ALC880_F1734] = "F1734",
  2310. [ALC880_LG] = "lg",
  2311. [ALC880_LG_LW] = "lg-lw",
  2312. #ifdef CONFIG_SND_DEBUG
  2313. [ALC880_TEST] = "test",
  2314. #endif
  2315. [ALC880_AUTO] = "auto",
  2316. };
  2317. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2318. /* Broken BIOS configuration */
  2319. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2320. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2321. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2322. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2323. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2324. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2325. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2326. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2327. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2328. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2329. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2330. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2331. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2332. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2333. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2334. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2335. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2336. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2337. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2338. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2339. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2340. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2341. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2342. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2343. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2344. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2345. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2346. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2347. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2348. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2349. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2350. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2351. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2352. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2353. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2354. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2355. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2356. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2357. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2358. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2359. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2360. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2361. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2362. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2363. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2364. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2365. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2366. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2367. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2368. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2369. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2370. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2371. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2372. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2373. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2374. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2375. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2376. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2377. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2378. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2379. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2380. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2381. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2382. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2383. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2384. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2385. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2386. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2387. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2388. {}
  2389. };
  2390. /*
  2391. * ALC880 codec presets
  2392. */
  2393. static struct alc_config_preset alc880_presets[] = {
  2394. [ALC880_3ST] = {
  2395. .mixers = { alc880_three_stack_mixer },
  2396. .init_verbs = { alc880_volume_init_verbs,
  2397. alc880_pin_3stack_init_verbs },
  2398. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2399. .dac_nids = alc880_dac_nids,
  2400. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2401. .channel_mode = alc880_threestack_modes,
  2402. .need_dac_fix = 1,
  2403. .input_mux = &alc880_capture_source,
  2404. },
  2405. [ALC880_3ST_DIG] = {
  2406. .mixers = { alc880_three_stack_mixer },
  2407. .init_verbs = { alc880_volume_init_verbs,
  2408. alc880_pin_3stack_init_verbs },
  2409. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2410. .dac_nids = alc880_dac_nids,
  2411. .dig_out_nid = ALC880_DIGOUT_NID,
  2412. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2413. .channel_mode = alc880_threestack_modes,
  2414. .need_dac_fix = 1,
  2415. .input_mux = &alc880_capture_source,
  2416. },
  2417. [ALC880_TCL_S700] = {
  2418. .mixers = { alc880_tcl_s700_mixer },
  2419. .init_verbs = { alc880_volume_init_verbs,
  2420. alc880_pin_tcl_S700_init_verbs,
  2421. alc880_gpio2_init_verbs },
  2422. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2423. .dac_nids = alc880_dac_nids,
  2424. .hp_nid = 0x03,
  2425. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2426. .channel_mode = alc880_2_jack_modes,
  2427. .input_mux = &alc880_capture_source,
  2428. },
  2429. [ALC880_5ST] = {
  2430. .mixers = { alc880_three_stack_mixer,
  2431. alc880_five_stack_mixer},
  2432. .init_verbs = { alc880_volume_init_verbs,
  2433. alc880_pin_5stack_init_verbs },
  2434. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2435. .dac_nids = alc880_dac_nids,
  2436. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2437. .channel_mode = alc880_fivestack_modes,
  2438. .input_mux = &alc880_capture_source,
  2439. },
  2440. [ALC880_5ST_DIG] = {
  2441. .mixers = { alc880_three_stack_mixer,
  2442. alc880_five_stack_mixer },
  2443. .init_verbs = { alc880_volume_init_verbs,
  2444. alc880_pin_5stack_init_verbs },
  2445. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2446. .dac_nids = alc880_dac_nids,
  2447. .dig_out_nid = ALC880_DIGOUT_NID,
  2448. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2449. .channel_mode = alc880_fivestack_modes,
  2450. .input_mux = &alc880_capture_source,
  2451. },
  2452. [ALC880_6ST] = {
  2453. .mixers = { alc880_six_stack_mixer },
  2454. .init_verbs = { alc880_volume_init_verbs,
  2455. alc880_pin_6stack_init_verbs },
  2456. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2457. .dac_nids = alc880_6st_dac_nids,
  2458. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2459. .channel_mode = alc880_sixstack_modes,
  2460. .input_mux = &alc880_6stack_capture_source,
  2461. },
  2462. [ALC880_6ST_DIG] = {
  2463. .mixers = { alc880_six_stack_mixer },
  2464. .init_verbs = { alc880_volume_init_verbs,
  2465. alc880_pin_6stack_init_verbs },
  2466. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2467. .dac_nids = alc880_6st_dac_nids,
  2468. .dig_out_nid = ALC880_DIGOUT_NID,
  2469. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2470. .channel_mode = alc880_sixstack_modes,
  2471. .input_mux = &alc880_6stack_capture_source,
  2472. },
  2473. [ALC880_W810] = {
  2474. .mixers = { alc880_w810_base_mixer },
  2475. .init_verbs = { alc880_volume_init_verbs,
  2476. alc880_pin_w810_init_verbs,
  2477. alc880_gpio2_init_verbs },
  2478. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2479. .dac_nids = alc880_w810_dac_nids,
  2480. .dig_out_nid = ALC880_DIGOUT_NID,
  2481. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2482. .channel_mode = alc880_w810_modes,
  2483. .input_mux = &alc880_capture_source,
  2484. },
  2485. [ALC880_Z71V] = {
  2486. .mixers = { alc880_z71v_mixer },
  2487. .init_verbs = { alc880_volume_init_verbs,
  2488. alc880_pin_z71v_init_verbs },
  2489. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2490. .dac_nids = alc880_z71v_dac_nids,
  2491. .dig_out_nid = ALC880_DIGOUT_NID,
  2492. .hp_nid = 0x03,
  2493. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2494. .channel_mode = alc880_2_jack_modes,
  2495. .input_mux = &alc880_capture_source,
  2496. },
  2497. [ALC880_F1734] = {
  2498. .mixers = { alc880_f1734_mixer },
  2499. .init_verbs = { alc880_volume_init_verbs,
  2500. alc880_pin_f1734_init_verbs },
  2501. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2502. .dac_nids = alc880_f1734_dac_nids,
  2503. .hp_nid = 0x02,
  2504. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2505. .channel_mode = alc880_2_jack_modes,
  2506. .input_mux = &alc880_capture_source,
  2507. },
  2508. [ALC880_ASUS] = {
  2509. .mixers = { alc880_asus_mixer },
  2510. .init_verbs = { alc880_volume_init_verbs,
  2511. alc880_pin_asus_init_verbs,
  2512. alc880_gpio1_init_verbs },
  2513. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2514. .dac_nids = alc880_asus_dac_nids,
  2515. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2516. .channel_mode = alc880_asus_modes,
  2517. .need_dac_fix = 1,
  2518. .input_mux = &alc880_capture_source,
  2519. },
  2520. [ALC880_ASUS_DIG] = {
  2521. .mixers = { alc880_asus_mixer },
  2522. .init_verbs = { alc880_volume_init_verbs,
  2523. alc880_pin_asus_init_verbs,
  2524. alc880_gpio1_init_verbs },
  2525. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2526. .dac_nids = alc880_asus_dac_nids,
  2527. .dig_out_nid = ALC880_DIGOUT_NID,
  2528. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2529. .channel_mode = alc880_asus_modes,
  2530. .need_dac_fix = 1,
  2531. .input_mux = &alc880_capture_source,
  2532. },
  2533. [ALC880_ASUS_DIG2] = {
  2534. .mixers = { alc880_asus_mixer },
  2535. .init_verbs = { alc880_volume_init_verbs,
  2536. alc880_pin_asus_init_verbs,
  2537. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2538. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2539. .dac_nids = alc880_asus_dac_nids,
  2540. .dig_out_nid = ALC880_DIGOUT_NID,
  2541. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2542. .channel_mode = alc880_asus_modes,
  2543. .need_dac_fix = 1,
  2544. .input_mux = &alc880_capture_source,
  2545. },
  2546. [ALC880_ASUS_W1V] = {
  2547. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2548. .init_verbs = { alc880_volume_init_verbs,
  2549. alc880_pin_asus_init_verbs,
  2550. alc880_gpio1_init_verbs },
  2551. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2552. .dac_nids = alc880_asus_dac_nids,
  2553. .dig_out_nid = ALC880_DIGOUT_NID,
  2554. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2555. .channel_mode = alc880_asus_modes,
  2556. .need_dac_fix = 1,
  2557. .input_mux = &alc880_capture_source,
  2558. },
  2559. [ALC880_UNIWILL_DIG] = {
  2560. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2561. .init_verbs = { alc880_volume_init_verbs,
  2562. alc880_pin_asus_init_verbs },
  2563. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2564. .dac_nids = alc880_asus_dac_nids,
  2565. .dig_out_nid = ALC880_DIGOUT_NID,
  2566. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2567. .channel_mode = alc880_asus_modes,
  2568. .need_dac_fix = 1,
  2569. .input_mux = &alc880_capture_source,
  2570. },
  2571. [ALC880_UNIWILL] = {
  2572. .mixers = { alc880_uniwill_mixer },
  2573. .init_verbs = { alc880_volume_init_verbs,
  2574. alc880_uniwill_init_verbs },
  2575. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2576. .dac_nids = alc880_asus_dac_nids,
  2577. .dig_out_nid = ALC880_DIGOUT_NID,
  2578. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2579. .channel_mode = alc880_threestack_modes,
  2580. .need_dac_fix = 1,
  2581. .input_mux = &alc880_capture_source,
  2582. .unsol_event = alc880_uniwill_unsol_event,
  2583. .init_hook = alc880_uniwill_automute,
  2584. },
  2585. [ALC880_UNIWILL_P53] = {
  2586. .mixers = { alc880_uniwill_p53_mixer },
  2587. .init_verbs = { alc880_volume_init_verbs,
  2588. alc880_uniwill_p53_init_verbs },
  2589. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2590. .dac_nids = alc880_asus_dac_nids,
  2591. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2592. .channel_mode = alc880_threestack_modes,
  2593. .input_mux = &alc880_capture_source,
  2594. .unsol_event = alc880_uniwill_p53_unsol_event,
  2595. .init_hook = alc880_uniwill_p53_hp_automute,
  2596. },
  2597. [ALC880_FUJITSU] = {
  2598. .mixers = { alc880_fujitsu_mixer,
  2599. alc880_pcbeep_mixer, },
  2600. .init_verbs = { alc880_volume_init_verbs,
  2601. alc880_uniwill_p53_init_verbs,
  2602. alc880_beep_init_verbs },
  2603. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2604. .dac_nids = alc880_dac_nids,
  2605. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2606. .channel_mode = alc880_2_jack_modes,
  2607. .input_mux = &alc880_capture_source,
  2608. .unsol_event = alc880_uniwill_p53_unsol_event,
  2609. .init_hook = alc880_uniwill_p53_hp_automute,
  2610. },
  2611. [ALC880_CLEVO] = {
  2612. .mixers = { alc880_three_stack_mixer },
  2613. .init_verbs = { alc880_volume_init_verbs,
  2614. alc880_pin_clevo_init_verbs },
  2615. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2616. .dac_nids = alc880_dac_nids,
  2617. .hp_nid = 0x03,
  2618. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2619. .channel_mode = alc880_threestack_modes,
  2620. .need_dac_fix = 1,
  2621. .input_mux = &alc880_capture_source,
  2622. },
  2623. [ALC880_LG] = {
  2624. .mixers = { alc880_lg_mixer },
  2625. .init_verbs = { alc880_volume_init_verbs,
  2626. alc880_lg_init_verbs },
  2627. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2628. .dac_nids = alc880_lg_dac_nids,
  2629. .dig_out_nid = ALC880_DIGOUT_NID,
  2630. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2631. .channel_mode = alc880_lg_ch_modes,
  2632. .need_dac_fix = 1,
  2633. .input_mux = &alc880_lg_capture_source,
  2634. .unsol_event = alc880_lg_unsol_event,
  2635. .init_hook = alc880_lg_automute,
  2636. },
  2637. [ALC880_LG_LW] = {
  2638. .mixers = { alc880_lg_lw_mixer },
  2639. .init_verbs = { alc880_volume_init_verbs,
  2640. alc880_lg_lw_init_verbs },
  2641. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2642. .dac_nids = alc880_dac_nids,
  2643. .dig_out_nid = ALC880_DIGOUT_NID,
  2644. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2645. .channel_mode = alc880_lg_lw_modes,
  2646. .input_mux = &alc880_lg_lw_capture_source,
  2647. .unsol_event = alc880_lg_lw_unsol_event,
  2648. .init_hook = alc880_lg_lw_automute,
  2649. },
  2650. #ifdef CONFIG_SND_DEBUG
  2651. [ALC880_TEST] = {
  2652. .mixers = { alc880_test_mixer },
  2653. .init_verbs = { alc880_test_init_verbs },
  2654. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2655. .dac_nids = alc880_test_dac_nids,
  2656. .dig_out_nid = ALC880_DIGOUT_NID,
  2657. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2658. .channel_mode = alc880_test_modes,
  2659. .input_mux = &alc880_test_capture_source,
  2660. },
  2661. #endif
  2662. };
  2663. /*
  2664. * Automatic parse of I/O pins from the BIOS configuration
  2665. */
  2666. #define NUM_CONTROL_ALLOC 32
  2667. #define NUM_VERB_ALLOC 32
  2668. enum {
  2669. ALC_CTL_WIDGET_VOL,
  2670. ALC_CTL_WIDGET_MUTE,
  2671. ALC_CTL_BIND_MUTE,
  2672. };
  2673. static struct snd_kcontrol_new alc880_control_templates[] = {
  2674. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2675. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2676. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2677. };
  2678. /* add dynamic controls */
  2679. static int add_control(struct alc_spec *spec, int type, const char *name,
  2680. unsigned long val)
  2681. {
  2682. struct snd_kcontrol_new *knew;
  2683. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2684. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2685. /* array + terminator */
  2686. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2687. if (!knew)
  2688. return -ENOMEM;
  2689. if (spec->kctl_alloc) {
  2690. memcpy(knew, spec->kctl_alloc,
  2691. sizeof(*knew) * spec->num_kctl_alloc);
  2692. kfree(spec->kctl_alloc);
  2693. }
  2694. spec->kctl_alloc = knew;
  2695. spec->num_kctl_alloc = num;
  2696. }
  2697. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2698. *knew = alc880_control_templates[type];
  2699. knew->name = kstrdup(name, GFP_KERNEL);
  2700. if (!knew->name)
  2701. return -ENOMEM;
  2702. knew->private_value = val;
  2703. spec->num_kctl_used++;
  2704. return 0;
  2705. }
  2706. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2707. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2708. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2709. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2710. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2711. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2712. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2713. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2714. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2715. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2716. #define ALC880_PIN_CD_NID 0x1c
  2717. /* fill in the dac_nids table from the parsed pin configuration */
  2718. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2719. const struct auto_pin_cfg *cfg)
  2720. {
  2721. hda_nid_t nid;
  2722. int assigned[4];
  2723. int i, j;
  2724. memset(assigned, 0, sizeof(assigned));
  2725. spec->multiout.dac_nids = spec->private_dac_nids;
  2726. /* check the pins hardwired to audio widget */
  2727. for (i = 0; i < cfg->line_outs; i++) {
  2728. nid = cfg->line_out_pins[i];
  2729. if (alc880_is_fixed_pin(nid)) {
  2730. int idx = alc880_fixed_pin_idx(nid);
  2731. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2732. assigned[idx] = 1;
  2733. }
  2734. }
  2735. /* left pins can be connect to any audio widget */
  2736. for (i = 0; i < cfg->line_outs; i++) {
  2737. nid = cfg->line_out_pins[i];
  2738. if (alc880_is_fixed_pin(nid))
  2739. continue;
  2740. /* search for an empty channel */
  2741. for (j = 0; j < cfg->line_outs; j++) {
  2742. if (!assigned[j]) {
  2743. spec->multiout.dac_nids[i] =
  2744. alc880_idx_to_dac(j);
  2745. assigned[j] = 1;
  2746. break;
  2747. }
  2748. }
  2749. }
  2750. spec->multiout.num_dacs = cfg->line_outs;
  2751. return 0;
  2752. }
  2753. /* add playback controls from the parsed DAC table */
  2754. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2755. const struct auto_pin_cfg *cfg)
  2756. {
  2757. char name[32];
  2758. static const char *chname[4] = {
  2759. "Front", "Surround", NULL /*CLFE*/, "Side"
  2760. };
  2761. hda_nid_t nid;
  2762. int i, err;
  2763. for (i = 0; i < cfg->line_outs; i++) {
  2764. if (!spec->multiout.dac_nids[i])
  2765. continue;
  2766. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2767. if (i == 2) {
  2768. /* Center/LFE */
  2769. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2770. "Center Playback Volume",
  2771. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2772. HDA_OUTPUT));
  2773. if (err < 0)
  2774. return err;
  2775. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2776. "LFE Playback Volume",
  2777. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2778. HDA_OUTPUT));
  2779. if (err < 0)
  2780. return err;
  2781. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2782. "Center Playback Switch",
  2783. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2784. HDA_INPUT));
  2785. if (err < 0)
  2786. return err;
  2787. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2788. "LFE Playback Switch",
  2789. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2790. HDA_INPUT));
  2791. if (err < 0)
  2792. return err;
  2793. } else {
  2794. sprintf(name, "%s Playback Volume", chname[i]);
  2795. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2796. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2797. HDA_OUTPUT));
  2798. if (err < 0)
  2799. return err;
  2800. sprintf(name, "%s Playback Switch", chname[i]);
  2801. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2802. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2803. HDA_INPUT));
  2804. if (err < 0)
  2805. return err;
  2806. }
  2807. }
  2808. return 0;
  2809. }
  2810. /* add playback controls for speaker and HP outputs */
  2811. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2812. const char *pfx)
  2813. {
  2814. hda_nid_t nid;
  2815. int err;
  2816. char name[32];
  2817. if (!pin)
  2818. return 0;
  2819. if (alc880_is_fixed_pin(pin)) {
  2820. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2821. /* specify the DAC as the extra output */
  2822. if (!spec->multiout.hp_nid)
  2823. spec->multiout.hp_nid = nid;
  2824. else
  2825. spec->multiout.extra_out_nid[0] = nid;
  2826. /* control HP volume/switch on the output mixer amp */
  2827. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2828. sprintf(name, "%s Playback Volume", pfx);
  2829. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2830. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2831. if (err < 0)
  2832. return err;
  2833. sprintf(name, "%s Playback Switch", pfx);
  2834. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2835. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2836. if (err < 0)
  2837. return err;
  2838. } else if (alc880_is_multi_pin(pin)) {
  2839. /* set manual connection */
  2840. /* we have only a switch on HP-out PIN */
  2841. sprintf(name, "%s Playback Switch", pfx);
  2842. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2843. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2844. if (err < 0)
  2845. return err;
  2846. }
  2847. return 0;
  2848. }
  2849. /* create input playback/capture controls for the given pin */
  2850. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2851. const char *ctlname,
  2852. int idx, hda_nid_t mix_nid)
  2853. {
  2854. char name[32];
  2855. int err;
  2856. sprintf(name, "%s Playback Volume", ctlname);
  2857. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2858. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2859. if (err < 0)
  2860. return err;
  2861. sprintf(name, "%s Playback Switch", ctlname);
  2862. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2863. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2864. if (err < 0)
  2865. return err;
  2866. return 0;
  2867. }
  2868. /* create playback/capture controls for input pins */
  2869. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2870. const struct auto_pin_cfg *cfg)
  2871. {
  2872. struct hda_input_mux *imux = &spec->private_imux;
  2873. int i, err, idx;
  2874. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2875. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2876. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2877. err = new_analog_input(spec, cfg->input_pins[i],
  2878. auto_pin_cfg_labels[i],
  2879. idx, 0x0b);
  2880. if (err < 0)
  2881. return err;
  2882. imux->items[imux->num_items].label =
  2883. auto_pin_cfg_labels[i];
  2884. imux->items[imux->num_items].index =
  2885. alc880_input_pin_idx(cfg->input_pins[i]);
  2886. imux->num_items++;
  2887. }
  2888. }
  2889. return 0;
  2890. }
  2891. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2892. hda_nid_t nid, int pin_type,
  2893. int dac_idx)
  2894. {
  2895. /* set as output */
  2896. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2897. pin_type);
  2898. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2899. AMP_OUT_UNMUTE);
  2900. /* need the manual connection? */
  2901. if (alc880_is_multi_pin(nid)) {
  2902. struct alc_spec *spec = codec->spec;
  2903. int idx = alc880_multi_pin_idx(nid);
  2904. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2905. AC_VERB_SET_CONNECT_SEL,
  2906. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2907. }
  2908. }
  2909. static int get_pin_type(int line_out_type)
  2910. {
  2911. if (line_out_type == AUTO_PIN_HP_OUT)
  2912. return PIN_HP;
  2913. else
  2914. return PIN_OUT;
  2915. }
  2916. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2917. {
  2918. struct alc_spec *spec = codec->spec;
  2919. int i;
  2920. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2921. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2922. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2923. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2924. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2925. }
  2926. }
  2927. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2928. {
  2929. struct alc_spec *spec = codec->spec;
  2930. hda_nid_t pin;
  2931. pin = spec->autocfg.speaker_pins[0];
  2932. if (pin) /* connect to front */
  2933. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2934. pin = spec->autocfg.hp_pins[0];
  2935. if (pin) /* connect to front */
  2936. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2937. }
  2938. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2939. {
  2940. struct alc_spec *spec = codec->spec;
  2941. int i;
  2942. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2943. hda_nid_t nid = spec->autocfg.input_pins[i];
  2944. if (alc880_is_input_pin(nid)) {
  2945. snd_hda_codec_write(codec, nid, 0,
  2946. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2947. i <= AUTO_PIN_FRONT_MIC ?
  2948. PIN_VREF80 : PIN_IN);
  2949. if (nid != ALC880_PIN_CD_NID)
  2950. snd_hda_codec_write(codec, nid, 0,
  2951. AC_VERB_SET_AMP_GAIN_MUTE,
  2952. AMP_OUT_MUTE);
  2953. }
  2954. }
  2955. }
  2956. /* parse the BIOS configuration and set up the alc_spec */
  2957. /* return 1 if successful, 0 if the proper config is not found,
  2958. * or a negative error code
  2959. */
  2960. static int alc880_parse_auto_config(struct hda_codec *codec)
  2961. {
  2962. struct alc_spec *spec = codec->spec;
  2963. int err;
  2964. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2965. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2966. alc880_ignore);
  2967. if (err < 0)
  2968. return err;
  2969. if (!spec->autocfg.line_outs)
  2970. return 0; /* can't find valid BIOS pin config */
  2971. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2972. if (err < 0)
  2973. return err;
  2974. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2975. if (err < 0)
  2976. return err;
  2977. err = alc880_auto_create_extra_out(spec,
  2978. spec->autocfg.speaker_pins[0],
  2979. "Speaker");
  2980. if (err < 0)
  2981. return err;
  2982. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2983. "Headphone");
  2984. if (err < 0)
  2985. return err;
  2986. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2987. if (err < 0)
  2988. return err;
  2989. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2990. if (spec->autocfg.dig_out_pin)
  2991. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2992. if (spec->autocfg.dig_in_pin)
  2993. spec->dig_in_nid = ALC880_DIGIN_NID;
  2994. if (spec->kctl_alloc)
  2995. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2996. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2997. spec->num_mux_defs = 1;
  2998. spec->input_mux = &spec->private_imux;
  2999. return 1;
  3000. }
  3001. /* additional initialization for auto-configuration model */
  3002. static void alc880_auto_init(struct hda_codec *codec)
  3003. {
  3004. alc880_auto_init_multi_out(codec);
  3005. alc880_auto_init_extra_out(codec);
  3006. alc880_auto_init_analog_input(codec);
  3007. }
  3008. /*
  3009. * OK, here we have finally the patch for ALC880
  3010. */
  3011. static int patch_alc880(struct hda_codec *codec)
  3012. {
  3013. struct alc_spec *spec;
  3014. int board_config;
  3015. int err;
  3016. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3017. if (spec == NULL)
  3018. return -ENOMEM;
  3019. codec->spec = spec;
  3020. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3021. alc880_models,
  3022. alc880_cfg_tbl);
  3023. if (board_config < 0) {
  3024. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3025. "trying auto-probe from BIOS...\n");
  3026. board_config = ALC880_AUTO;
  3027. }
  3028. if (board_config == ALC880_AUTO) {
  3029. /* automatic parse from the BIOS config */
  3030. err = alc880_parse_auto_config(codec);
  3031. if (err < 0) {
  3032. alc_free(codec);
  3033. return err;
  3034. } else if (!err) {
  3035. printk(KERN_INFO
  3036. "hda_codec: Cannot set up configuration "
  3037. "from BIOS. Using 3-stack mode...\n");
  3038. board_config = ALC880_3ST;
  3039. }
  3040. }
  3041. if (board_config != ALC880_AUTO)
  3042. setup_preset(spec, &alc880_presets[board_config]);
  3043. spec->stream_name_analog = "ALC880 Analog";
  3044. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3045. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3046. spec->stream_name_digital = "ALC880 Digital";
  3047. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3048. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3049. if (!spec->adc_nids && spec->input_mux) {
  3050. /* check whether NID 0x07 is valid */
  3051. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3052. /* get type */
  3053. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3054. if (wcap != AC_WID_AUD_IN) {
  3055. spec->adc_nids = alc880_adc_nids_alt;
  3056. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3057. spec->mixers[spec->num_mixers] =
  3058. alc880_capture_alt_mixer;
  3059. spec->num_mixers++;
  3060. } else {
  3061. spec->adc_nids = alc880_adc_nids;
  3062. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3063. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3064. spec->num_mixers++;
  3065. }
  3066. }
  3067. codec->patch_ops = alc_patch_ops;
  3068. if (board_config == ALC880_AUTO)
  3069. spec->init_hook = alc880_auto_init;
  3070. return 0;
  3071. }
  3072. /*
  3073. * ALC260 support
  3074. */
  3075. static hda_nid_t alc260_dac_nids[1] = {
  3076. /* front */
  3077. 0x02,
  3078. };
  3079. static hda_nid_t alc260_adc_nids[1] = {
  3080. /* ADC0 */
  3081. 0x04,
  3082. };
  3083. static hda_nid_t alc260_adc_nids_alt[1] = {
  3084. /* ADC1 */
  3085. 0x05,
  3086. };
  3087. static hda_nid_t alc260_hp_adc_nids[2] = {
  3088. /* ADC1, 0 */
  3089. 0x05, 0x04
  3090. };
  3091. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3092. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3093. */
  3094. static hda_nid_t alc260_dual_adc_nids[2] = {
  3095. /* ADC0, ADC1 */
  3096. 0x04, 0x05
  3097. };
  3098. #define ALC260_DIGOUT_NID 0x03
  3099. #define ALC260_DIGIN_NID 0x06
  3100. static struct hda_input_mux alc260_capture_source = {
  3101. .num_items = 4,
  3102. .items = {
  3103. { "Mic", 0x0 },
  3104. { "Front Mic", 0x1 },
  3105. { "Line", 0x2 },
  3106. { "CD", 0x4 },
  3107. },
  3108. };
  3109. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3110. * headphone jack and the internal CD lines since these are the only pins at
  3111. * which audio can appear. For flexibility, also allow the option of
  3112. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3113. * connection to the mixer output).
  3114. */
  3115. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3116. {
  3117. .num_items = 3,
  3118. .items = {
  3119. { "Mic/Line", 0x0 },
  3120. { "CD", 0x4 },
  3121. { "Headphone", 0x2 },
  3122. },
  3123. },
  3124. {
  3125. .num_items = 4,
  3126. .items = {
  3127. { "Mic/Line", 0x0 },
  3128. { "CD", 0x4 },
  3129. { "Headphone", 0x2 },
  3130. { "Mixer", 0x5 },
  3131. },
  3132. },
  3133. };
  3134. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3135. * the Fujitsu S702x, but jacks are marked differently.
  3136. */
  3137. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3138. {
  3139. .num_items = 4,
  3140. .items = {
  3141. { "Mic", 0x0 },
  3142. { "Line", 0x2 },
  3143. { "CD", 0x4 },
  3144. { "Headphone", 0x5 },
  3145. },
  3146. },
  3147. {
  3148. .num_items = 5,
  3149. .items = {
  3150. { "Mic", 0x0 },
  3151. { "Line", 0x2 },
  3152. { "CD", 0x4 },
  3153. { "Headphone", 0x6 },
  3154. { "Mixer", 0x5 },
  3155. },
  3156. },
  3157. };
  3158. /*
  3159. * This is just place-holder, so there's something for alc_build_pcms to look
  3160. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3161. * element which allows changing the channel mode, so the verb list is
  3162. * never used.
  3163. */
  3164. static struct hda_channel_mode alc260_modes[1] = {
  3165. { 2, NULL },
  3166. };
  3167. /* Mixer combinations
  3168. *
  3169. * basic: base_output + input + pc_beep + capture
  3170. * HP: base_output + input + capture_alt
  3171. * HP_3013: hp_3013 + input + capture
  3172. * fujitsu: fujitsu + capture
  3173. * acer: acer + capture
  3174. */
  3175. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3176. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3177. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3178. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3179. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3180. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3181. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3182. { } /* end */
  3183. };
  3184. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3185. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3186. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3187. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3188. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3189. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3190. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3191. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3192. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3193. { } /* end */
  3194. };
  3195. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3196. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3197. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3198. { } /* end */
  3199. };
  3200. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3201. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3202. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3203. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3204. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3205. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3206. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3207. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3208. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3209. { } /* end */
  3210. };
  3211. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3212. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3213. */
  3214. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3215. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3216. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3217. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3218. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3219. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3220. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3221. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3222. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3223. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3224. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3225. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3226. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3227. { } /* end */
  3228. };
  3229. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3230. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3231. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3232. * datasheet doesn't mention this restriction. At this stage it's not clear
  3233. * whether this behaviour is intentional or is a hardware bug in chip
  3234. * revisions available in early 2006. Therefore for now allow the
  3235. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3236. * that the lack of mic bias for this NID is intentional we could change the
  3237. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3238. *
  3239. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3240. * don't appear to make the mic bias available from the "line" jack, even
  3241. * though the NID used for this jack (0x14) can supply it. The theory is
  3242. * that perhaps Acer have included blocking capacitors between the ALC260
  3243. * and the output jack. If this turns out to be the case for all such
  3244. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3245. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3246. *
  3247. * The C20x Tablet series have a mono internal speaker which is controlled
  3248. * via the chip's Mono sum widget and pin complex, so include the necessary
  3249. * controls for such models. On models without a "mono speaker" the control
  3250. * won't do anything.
  3251. */
  3252. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3253. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3254. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3255. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3256. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3257. HDA_OUTPUT),
  3258. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3259. HDA_INPUT),
  3260. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3261. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3262. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3263. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3264. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3265. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3266. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3267. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3268. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3269. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3270. { } /* end */
  3271. };
  3272. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3273. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3274. */
  3275. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3276. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3277. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3278. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3279. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3280. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3281. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3282. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3283. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3284. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3285. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3286. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3287. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3288. { } /* end */
  3289. };
  3290. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3291. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3292. */
  3293. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3294. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3295. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3296. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3297. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3298. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3299. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3300. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3301. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3302. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3303. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3304. { } /* end */
  3305. };
  3306. /* capture mixer elements */
  3307. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3308. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3309. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3310. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3311. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3312. {
  3313. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3314. /* The multiple "Capture Source" controls confuse alsamixer
  3315. * So call somewhat different..
  3316. * FIXME: the controls appear in the "playback" view!
  3317. */
  3318. /* .name = "Capture Source", */
  3319. .name = "Input Source",
  3320. .count = 2,
  3321. .info = alc_mux_enum_info,
  3322. .get = alc_mux_enum_get,
  3323. .put = alc_mux_enum_put,
  3324. },
  3325. { } /* end */
  3326. };
  3327. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3328. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3329. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3330. {
  3331. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3332. /* The multiple "Capture Source" controls confuse alsamixer
  3333. * So call somewhat different..
  3334. * FIXME: the controls appear in the "playback" view!
  3335. */
  3336. /* .name = "Capture Source", */
  3337. .name = "Input Source",
  3338. .count = 1,
  3339. .info = alc_mux_enum_info,
  3340. .get = alc_mux_enum_get,
  3341. .put = alc_mux_enum_put,
  3342. },
  3343. { } /* end */
  3344. };
  3345. /*
  3346. * initialization verbs
  3347. */
  3348. static struct hda_verb alc260_init_verbs[] = {
  3349. /* Line In pin widget for input */
  3350. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3351. /* CD pin widget for input */
  3352. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3353. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3354. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3355. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3356. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3357. /* LINE-2 is used for line-out in rear */
  3358. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3359. /* select line-out */
  3360. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3361. /* LINE-OUT pin */
  3362. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3363. /* enable HP */
  3364. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3365. /* enable Mono */
  3366. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3367. /* mute capture amp left and right */
  3368. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3369. /* set connection select to line in (default select for this ADC) */
  3370. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3371. /* mute capture amp left and right */
  3372. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3373. /* set connection select to line in (default select for this ADC) */
  3374. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3375. /* set vol=0 Line-Out mixer amp left and right */
  3376. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3377. /* unmute pin widget amp left and right (no gain on this amp) */
  3378. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3379. /* set vol=0 HP mixer amp left and right */
  3380. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3381. /* unmute pin widget amp left and right (no gain on this amp) */
  3382. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3383. /* set vol=0 Mono mixer amp left and right */
  3384. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3385. /* unmute pin widget amp left and right (no gain on this amp) */
  3386. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3387. /* unmute LINE-2 out pin */
  3388. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3389. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3390. * Line In 2 = 0x03
  3391. */
  3392. /* mute CD */
  3393. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3394. /* mute Line In */
  3395. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3396. /* mute Mic */
  3397. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3398. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3399. /* mute Front out path */
  3400. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3401. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3402. /* mute Headphone out path */
  3403. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3404. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3405. /* mute Mono out path */
  3406. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3407. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3408. { }
  3409. };
  3410. #if 0 /* should be identical with alc260_init_verbs? */
  3411. static struct hda_verb alc260_hp_init_verbs[] = {
  3412. /* Headphone and output */
  3413. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3414. /* mono output */
  3415. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3416. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3417. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3418. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3419. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3420. /* Line In pin widget for input */
  3421. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3422. /* Line-2 pin widget for output */
  3423. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3424. /* CD pin widget for input */
  3425. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3426. /* unmute amp left and right */
  3427. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3428. /* set connection select to line in (default select for this ADC) */
  3429. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3430. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3431. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3432. /* mute pin widget amp left and right (no gain on this amp) */
  3433. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3434. /* unmute HP mixer amp left and right (volume = 0) */
  3435. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3436. /* mute pin widget amp left and right (no gain on this amp) */
  3437. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3438. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3439. * Line In 2 = 0x03
  3440. */
  3441. /* unmute CD */
  3442. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3443. /* unmute Line In */
  3444. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3445. /* unmute Mic */
  3446. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3447. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3448. /* Unmute Front out path */
  3449. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3450. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3451. /* Unmute Headphone out path */
  3452. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3453. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3454. /* Unmute Mono out path */
  3455. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3456. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3457. { }
  3458. };
  3459. #endif
  3460. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3461. /* Line out and output */
  3462. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3463. /* mono output */
  3464. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3465. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3466. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3467. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3468. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3469. /* Line In pin widget for input */
  3470. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3471. /* Headphone pin widget for output */
  3472. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3473. /* CD pin widget for input */
  3474. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3475. /* unmute amp left and right */
  3476. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3477. /* set connection select to line in (default select for this ADC) */
  3478. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3479. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3480. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3481. /* mute pin widget amp left and right (no gain on this amp) */
  3482. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3483. /* unmute HP mixer amp left and right (volume = 0) */
  3484. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3485. /* mute pin widget amp left and right (no gain on this amp) */
  3486. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3487. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3488. * Line In 2 = 0x03
  3489. */
  3490. /* unmute CD */
  3491. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3492. /* unmute Line In */
  3493. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3494. /* unmute Mic */
  3495. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3496. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3497. /* Unmute Front out path */
  3498. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3499. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3500. /* Unmute Headphone out path */
  3501. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3502. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3503. /* Unmute Mono out path */
  3504. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3505. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3506. { }
  3507. };
  3508. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3509. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3510. * audio = 0x16, internal speaker = 0x10.
  3511. */
  3512. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3513. /* Disable all GPIOs */
  3514. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3515. /* Internal speaker is connected to headphone pin */
  3516. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3517. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3518. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3519. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3520. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3521. /* Ensure all other unused pins are disabled and muted. */
  3522. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3523. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3524. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3525. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3526. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3527. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3528. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3529. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3530. /* Disable digital (SPDIF) pins */
  3531. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3532. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3533. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3534. * when acting as an output.
  3535. */
  3536. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3537. /* Start with output sum widgets muted and their output gains at min */
  3538. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3539. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3540. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3541. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3542. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3543. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3544. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3545. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3546. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3547. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3548. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3549. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3550. * If the pin mode is changed by the user the pin mode control will
  3551. * take care of enabling the pin's input/output buffers as needed.
  3552. * Therefore there's no need to enable the input buffer at this
  3553. * stage.
  3554. */
  3555. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3556. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3557. * mixer ctrl)
  3558. */
  3559. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3560. /* Mute capture amp left and right */
  3561. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3562. /* Set ADC connection select to match default mixer setting - line
  3563. * in (on mic1 pin)
  3564. */
  3565. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3566. /* Do the same for the second ADC: mute capture input amp and
  3567. * set ADC connection to line in (on mic1 pin)
  3568. */
  3569. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3570. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3571. /* Mute all inputs to mixer widget (even unconnected ones) */
  3572. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3573. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3575. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3576. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3578. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3579. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3580. { }
  3581. };
  3582. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3583. * similar laptops (adapted from Fujitsu init verbs).
  3584. */
  3585. static struct hda_verb alc260_acer_init_verbs[] = {
  3586. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3587. * the headphone jack. Turn this on and rely on the standard mute
  3588. * methods whenever the user wants to turn these outputs off.
  3589. */
  3590. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3591. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3592. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3593. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3594. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3595. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3596. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3597. /* Line In jack is connected to Line1 pin */
  3598. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3599. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3600. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3601. /* Ensure all other unused pins are disabled and muted. */
  3602. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3603. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3604. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3605. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3606. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3607. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3608. /* Disable digital (SPDIF) pins */
  3609. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3610. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3611. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3612. * bus when acting as outputs.
  3613. */
  3614. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3615. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3616. /* Start with output sum widgets muted and their output gains at min */
  3617. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3618. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3619. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3620. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3621. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3622. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3623. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3624. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3625. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3626. /* Unmute Line-out pin widget amp left and right
  3627. * (no equiv mixer ctrl)
  3628. */
  3629. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3630. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3631. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3632. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3633. * inputs. If the pin mode is changed by the user the pin mode control
  3634. * will take care of enabling the pin's input/output buffers as needed.
  3635. * Therefore there's no need to enable the input buffer at this
  3636. * stage.
  3637. */
  3638. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3639. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3640. /* Mute capture amp left and right */
  3641. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3642. /* Set ADC connection select to match default mixer setting - mic
  3643. * (on mic1 pin)
  3644. */
  3645. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3646. /* Do similar with the second ADC: mute capture input amp and
  3647. * set ADC connection to mic to match ALSA's default state.
  3648. */
  3649. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3650. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3651. /* Mute all inputs to mixer widget (even unconnected ones) */
  3652. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3653. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3658. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3659. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3660. { }
  3661. };
  3662. static struct hda_verb alc260_will_verbs[] = {
  3663. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3664. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3665. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3666. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3667. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3668. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3669. {}
  3670. };
  3671. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3672. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3673. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3674. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3675. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3676. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3677. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3678. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3679. {}
  3680. };
  3681. /* toggle speaker-output according to the hp-jack state */
  3682. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3683. {
  3684. unsigned int present;
  3685. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3686. present = snd_hda_codec_read(codec, 0x0f, 0,
  3687. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3688. if (present) {
  3689. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3690. snd_hda_codec_write(codec, 0x0f, 0,
  3691. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3692. } else {
  3693. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3694. snd_hda_codec_write(codec, 0x0f, 0,
  3695. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3696. }
  3697. }
  3698. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3699. unsigned int res)
  3700. {
  3701. if ((res >> 26) == ALC880_HP_EVENT)
  3702. alc260_replacer_672v_automute(codec);
  3703. }
  3704. /* Test configuration for debugging, modelled after the ALC880 test
  3705. * configuration.
  3706. */
  3707. #ifdef CONFIG_SND_DEBUG
  3708. static hda_nid_t alc260_test_dac_nids[1] = {
  3709. 0x02,
  3710. };
  3711. static hda_nid_t alc260_test_adc_nids[2] = {
  3712. 0x04, 0x05,
  3713. };
  3714. /* For testing the ALC260, each input MUX needs its own definition since
  3715. * the signal assignments are different. This assumes that the first ADC
  3716. * is NID 0x04.
  3717. */
  3718. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3719. {
  3720. .num_items = 7,
  3721. .items = {
  3722. { "MIC1 pin", 0x0 },
  3723. { "MIC2 pin", 0x1 },
  3724. { "LINE1 pin", 0x2 },
  3725. { "LINE2 pin", 0x3 },
  3726. { "CD pin", 0x4 },
  3727. { "LINE-OUT pin", 0x5 },
  3728. { "HP-OUT pin", 0x6 },
  3729. },
  3730. },
  3731. {
  3732. .num_items = 8,
  3733. .items = {
  3734. { "MIC1 pin", 0x0 },
  3735. { "MIC2 pin", 0x1 },
  3736. { "LINE1 pin", 0x2 },
  3737. { "LINE2 pin", 0x3 },
  3738. { "CD pin", 0x4 },
  3739. { "Mixer", 0x5 },
  3740. { "LINE-OUT pin", 0x6 },
  3741. { "HP-OUT pin", 0x7 },
  3742. },
  3743. },
  3744. };
  3745. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3746. /* Output driver widgets */
  3747. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3748. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3749. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3750. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3751. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3752. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3753. /* Modes for retasking pin widgets
  3754. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3755. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3756. * mention this restriction. At this stage it's not clear whether
  3757. * this behaviour is intentional or is a hardware bug in chip
  3758. * revisions available at least up until early 2006. Therefore for
  3759. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3760. * choices, but if it turns out that the lack of mic bias for these
  3761. * NIDs is intentional we could change their modes from
  3762. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3763. */
  3764. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3765. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3766. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3767. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3768. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3769. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3770. /* Loopback mixer controls */
  3771. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3772. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3773. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3774. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3775. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3776. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3777. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3778. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3779. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3780. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3781. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3782. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3783. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3784. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3785. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3786. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3787. /* Controls for GPIO pins, assuming they are configured as outputs */
  3788. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3789. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3790. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3791. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3792. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3793. * is ambigious as to which NID is which; testing on laptops which
  3794. * make this output available should provide clarification.
  3795. */
  3796. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3797. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3798. { } /* end */
  3799. };
  3800. static struct hda_verb alc260_test_init_verbs[] = {
  3801. /* Enable all GPIOs as outputs with an initial value of 0 */
  3802. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3803. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3804. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3805. /* Enable retasking pins as output, initially without power amp */
  3806. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3807. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3808. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3809. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3810. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3811. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3812. /* Disable digital (SPDIF) pins initially, but users can enable
  3813. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3814. * payload also sets the generation to 0, output to be in "consumer"
  3815. * PCM format, copyright asserted, no pre-emphasis and no validity
  3816. * control.
  3817. */
  3818. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3819. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3820. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3821. * OUT1 sum bus when acting as an output.
  3822. */
  3823. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3824. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3825. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3826. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3827. /* Start with output sum widgets muted and their output gains at min */
  3828. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3829. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3830. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3831. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3832. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3833. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3834. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3835. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3836. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3837. /* Unmute retasking pin widget output buffers since the default
  3838. * state appears to be output. As the pin mode is changed by the
  3839. * user the pin mode control will take care of enabling the pin's
  3840. * input/output buffers as needed.
  3841. */
  3842. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3843. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3844. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3845. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3846. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3847. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3848. /* Also unmute the mono-out pin widget */
  3849. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3850. /* Mute capture amp left and right */
  3851. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3852. /* Set ADC connection select to match default mixer setting (mic1
  3853. * pin)
  3854. */
  3855. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3856. /* Do the same for the second ADC: mute capture input amp and
  3857. * set ADC connection to mic1 pin
  3858. */
  3859. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3860. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3861. /* Mute all inputs to mixer widget (even unconnected ones) */
  3862. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3863. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3864. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3865. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3866. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3867. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3870. { }
  3871. };
  3872. #endif
  3873. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3874. .substreams = 1,
  3875. .channels_min = 2,
  3876. .channels_max = 2,
  3877. };
  3878. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3879. .substreams = 1,
  3880. .channels_min = 2,
  3881. .channels_max = 2,
  3882. };
  3883. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3884. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3885. /*
  3886. * for BIOS auto-configuration
  3887. */
  3888. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3889. const char *pfx)
  3890. {
  3891. hda_nid_t nid_vol;
  3892. unsigned long vol_val, sw_val;
  3893. char name[32];
  3894. int err;
  3895. if (nid >= 0x0f && nid < 0x11) {
  3896. nid_vol = nid - 0x7;
  3897. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3898. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3899. } else if (nid == 0x11) {
  3900. nid_vol = nid - 0x7;
  3901. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3902. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3903. } else if (nid >= 0x12 && nid <= 0x15) {
  3904. nid_vol = 0x08;
  3905. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3906. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3907. } else
  3908. return 0; /* N/A */
  3909. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3910. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3911. if (err < 0)
  3912. return err;
  3913. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3914. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3915. if (err < 0)
  3916. return err;
  3917. return 1;
  3918. }
  3919. /* add playback controls from the parsed DAC table */
  3920. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3921. const struct auto_pin_cfg *cfg)
  3922. {
  3923. hda_nid_t nid;
  3924. int err;
  3925. spec->multiout.num_dacs = 1;
  3926. spec->multiout.dac_nids = spec->private_dac_nids;
  3927. spec->multiout.dac_nids[0] = 0x02;
  3928. nid = cfg->line_out_pins[0];
  3929. if (nid) {
  3930. err = alc260_add_playback_controls(spec, nid, "Front");
  3931. if (err < 0)
  3932. return err;
  3933. }
  3934. nid = cfg->speaker_pins[0];
  3935. if (nid) {
  3936. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3937. if (err < 0)
  3938. return err;
  3939. }
  3940. nid = cfg->hp_pins[0];
  3941. if (nid) {
  3942. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3943. if (err < 0)
  3944. return err;
  3945. }
  3946. return 0;
  3947. }
  3948. /* create playback/capture controls for input pins */
  3949. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3950. const struct auto_pin_cfg *cfg)
  3951. {
  3952. struct hda_input_mux *imux = &spec->private_imux;
  3953. int i, err, idx;
  3954. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3955. if (cfg->input_pins[i] >= 0x12) {
  3956. idx = cfg->input_pins[i] - 0x12;
  3957. err = new_analog_input(spec, cfg->input_pins[i],
  3958. auto_pin_cfg_labels[i], idx,
  3959. 0x07);
  3960. if (err < 0)
  3961. return err;
  3962. imux->items[imux->num_items].label =
  3963. auto_pin_cfg_labels[i];
  3964. imux->items[imux->num_items].index = idx;
  3965. imux->num_items++;
  3966. }
  3967. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3968. idx = cfg->input_pins[i] - 0x09;
  3969. err = new_analog_input(spec, cfg->input_pins[i],
  3970. auto_pin_cfg_labels[i], idx,
  3971. 0x07);
  3972. if (err < 0)
  3973. return err;
  3974. imux->items[imux->num_items].label =
  3975. auto_pin_cfg_labels[i];
  3976. imux->items[imux->num_items].index = idx;
  3977. imux->num_items++;
  3978. }
  3979. }
  3980. return 0;
  3981. }
  3982. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3983. hda_nid_t nid, int pin_type,
  3984. int sel_idx)
  3985. {
  3986. /* set as output */
  3987. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3988. pin_type);
  3989. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3990. AMP_OUT_UNMUTE);
  3991. /* need the manual connection? */
  3992. if (nid >= 0x12) {
  3993. int idx = nid - 0x12;
  3994. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3995. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3996. }
  3997. }
  3998. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3999. {
  4000. struct alc_spec *spec = codec->spec;
  4001. hda_nid_t nid;
  4002. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4003. nid = spec->autocfg.line_out_pins[0];
  4004. if (nid) {
  4005. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4006. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4007. }
  4008. nid = spec->autocfg.speaker_pins[0];
  4009. if (nid)
  4010. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4011. nid = spec->autocfg.hp_pins[0];
  4012. if (nid)
  4013. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4014. }
  4015. #define ALC260_PIN_CD_NID 0x16
  4016. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4017. {
  4018. struct alc_spec *spec = codec->spec;
  4019. int i;
  4020. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4021. hda_nid_t nid = spec->autocfg.input_pins[i];
  4022. if (nid >= 0x12) {
  4023. snd_hda_codec_write(codec, nid, 0,
  4024. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4025. i <= AUTO_PIN_FRONT_MIC ?
  4026. PIN_VREF80 : PIN_IN);
  4027. if (nid != ALC260_PIN_CD_NID)
  4028. snd_hda_codec_write(codec, nid, 0,
  4029. AC_VERB_SET_AMP_GAIN_MUTE,
  4030. AMP_OUT_MUTE);
  4031. }
  4032. }
  4033. }
  4034. /*
  4035. * generic initialization of ADC, input mixers and output mixers
  4036. */
  4037. static struct hda_verb alc260_volume_init_verbs[] = {
  4038. /*
  4039. * Unmute ADC0-1 and set the default input to mic-in
  4040. */
  4041. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4042. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4043. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4044. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4045. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4046. * mixer widget
  4047. * Note: PASD motherboards uses the Line In 2 as the input for
  4048. * front panel mic (mic 2)
  4049. */
  4050. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4051. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4052. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4053. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4054. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4055. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4056. /*
  4057. * Set up output mixers (0x08 - 0x0a)
  4058. */
  4059. /* set vol=0 to output mixers */
  4060. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4061. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4062. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4063. /* set up input amps for analog loopback */
  4064. /* Amp Indices: DAC = 0, mixer = 1 */
  4065. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4066. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4067. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4068. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4069. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4070. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4071. { }
  4072. };
  4073. static int alc260_parse_auto_config(struct hda_codec *codec)
  4074. {
  4075. struct alc_spec *spec = codec->spec;
  4076. unsigned int wcap;
  4077. int err;
  4078. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4079. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4080. alc260_ignore);
  4081. if (err < 0)
  4082. return err;
  4083. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4084. if (err < 0)
  4085. return err;
  4086. if (!spec->kctl_alloc)
  4087. return 0; /* can't find valid BIOS pin config */
  4088. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4089. if (err < 0)
  4090. return err;
  4091. spec->multiout.max_channels = 2;
  4092. if (spec->autocfg.dig_out_pin)
  4093. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4094. if (spec->kctl_alloc)
  4095. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4096. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4097. spec->num_mux_defs = 1;
  4098. spec->input_mux = &spec->private_imux;
  4099. /* check whether NID 0x04 is valid */
  4100. wcap = get_wcaps(codec, 0x04);
  4101. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4102. if (wcap != AC_WID_AUD_IN) {
  4103. spec->adc_nids = alc260_adc_nids_alt;
  4104. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4105. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4106. } else {
  4107. spec->adc_nids = alc260_adc_nids;
  4108. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4109. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4110. }
  4111. spec->num_mixers++;
  4112. return 1;
  4113. }
  4114. /* additional initialization for auto-configuration model */
  4115. static void alc260_auto_init(struct hda_codec *codec)
  4116. {
  4117. alc260_auto_init_multi_out(codec);
  4118. alc260_auto_init_analog_input(codec);
  4119. }
  4120. /*
  4121. * ALC260 configurations
  4122. */
  4123. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4124. [ALC260_BASIC] = "basic",
  4125. [ALC260_HP] = "hp",
  4126. [ALC260_HP_3013] = "hp-3013",
  4127. [ALC260_FUJITSU_S702X] = "fujitsu",
  4128. [ALC260_ACER] = "acer",
  4129. [ALC260_WILL] = "will",
  4130. [ALC260_REPLACER_672V] = "replacer",
  4131. #ifdef CONFIG_SND_DEBUG
  4132. [ALC260_TEST] = "test",
  4133. #endif
  4134. [ALC260_AUTO] = "auto",
  4135. };
  4136. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4137. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4138. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4139. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4140. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4141. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4142. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4143. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4144. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4145. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4146. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4147. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4148. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4149. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4150. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4151. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4152. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4153. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4154. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4155. {}
  4156. };
  4157. static struct alc_config_preset alc260_presets[] = {
  4158. [ALC260_BASIC] = {
  4159. .mixers = { alc260_base_output_mixer,
  4160. alc260_input_mixer,
  4161. alc260_pc_beep_mixer,
  4162. alc260_capture_mixer },
  4163. .init_verbs = { alc260_init_verbs },
  4164. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4165. .dac_nids = alc260_dac_nids,
  4166. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4167. .adc_nids = alc260_adc_nids,
  4168. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4169. .channel_mode = alc260_modes,
  4170. .input_mux = &alc260_capture_source,
  4171. },
  4172. [ALC260_HP] = {
  4173. .mixers = { alc260_base_output_mixer,
  4174. alc260_input_mixer,
  4175. alc260_capture_alt_mixer },
  4176. .init_verbs = { alc260_init_verbs },
  4177. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4178. .dac_nids = alc260_dac_nids,
  4179. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4180. .adc_nids = alc260_hp_adc_nids,
  4181. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4182. .channel_mode = alc260_modes,
  4183. .input_mux = &alc260_capture_source,
  4184. },
  4185. [ALC260_HP_3013] = {
  4186. .mixers = { alc260_hp_3013_mixer,
  4187. alc260_input_mixer,
  4188. alc260_capture_alt_mixer },
  4189. .init_verbs = { alc260_hp_3013_init_verbs },
  4190. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4191. .dac_nids = alc260_dac_nids,
  4192. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4193. .adc_nids = alc260_hp_adc_nids,
  4194. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4195. .channel_mode = alc260_modes,
  4196. .input_mux = &alc260_capture_source,
  4197. },
  4198. [ALC260_FUJITSU_S702X] = {
  4199. .mixers = { alc260_fujitsu_mixer,
  4200. alc260_capture_mixer },
  4201. .init_verbs = { alc260_fujitsu_init_verbs },
  4202. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4203. .dac_nids = alc260_dac_nids,
  4204. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4205. .adc_nids = alc260_dual_adc_nids,
  4206. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4207. .channel_mode = alc260_modes,
  4208. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4209. .input_mux = alc260_fujitsu_capture_sources,
  4210. },
  4211. [ALC260_ACER] = {
  4212. .mixers = { alc260_acer_mixer,
  4213. alc260_capture_mixer },
  4214. .init_verbs = { alc260_acer_init_verbs },
  4215. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4216. .dac_nids = alc260_dac_nids,
  4217. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4218. .adc_nids = alc260_dual_adc_nids,
  4219. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4220. .channel_mode = alc260_modes,
  4221. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4222. .input_mux = alc260_acer_capture_sources,
  4223. },
  4224. [ALC260_WILL] = {
  4225. .mixers = { alc260_will_mixer,
  4226. alc260_capture_mixer },
  4227. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4228. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4229. .dac_nids = alc260_dac_nids,
  4230. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4231. .adc_nids = alc260_adc_nids,
  4232. .dig_out_nid = ALC260_DIGOUT_NID,
  4233. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4234. .channel_mode = alc260_modes,
  4235. .input_mux = &alc260_capture_source,
  4236. },
  4237. [ALC260_REPLACER_672V] = {
  4238. .mixers = { alc260_replacer_672v_mixer,
  4239. alc260_capture_mixer },
  4240. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4241. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4242. .dac_nids = alc260_dac_nids,
  4243. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4244. .adc_nids = alc260_adc_nids,
  4245. .dig_out_nid = ALC260_DIGOUT_NID,
  4246. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4247. .channel_mode = alc260_modes,
  4248. .input_mux = &alc260_capture_source,
  4249. .unsol_event = alc260_replacer_672v_unsol_event,
  4250. .init_hook = alc260_replacer_672v_automute,
  4251. },
  4252. #ifdef CONFIG_SND_DEBUG
  4253. [ALC260_TEST] = {
  4254. .mixers = { alc260_test_mixer,
  4255. alc260_capture_mixer },
  4256. .init_verbs = { alc260_test_init_verbs },
  4257. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4258. .dac_nids = alc260_test_dac_nids,
  4259. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4260. .adc_nids = alc260_test_adc_nids,
  4261. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4262. .channel_mode = alc260_modes,
  4263. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4264. .input_mux = alc260_test_capture_sources,
  4265. },
  4266. #endif
  4267. };
  4268. static int patch_alc260(struct hda_codec *codec)
  4269. {
  4270. struct alc_spec *spec;
  4271. int err, board_config;
  4272. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4273. if (spec == NULL)
  4274. return -ENOMEM;
  4275. codec->spec = spec;
  4276. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4277. alc260_models,
  4278. alc260_cfg_tbl);
  4279. if (board_config < 0) {
  4280. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4281. "trying auto-probe from BIOS...\n");
  4282. board_config = ALC260_AUTO;
  4283. }
  4284. if (board_config == ALC260_AUTO) {
  4285. /* automatic parse from the BIOS config */
  4286. err = alc260_parse_auto_config(codec);
  4287. if (err < 0) {
  4288. alc_free(codec);
  4289. return err;
  4290. } else if (!err) {
  4291. printk(KERN_INFO
  4292. "hda_codec: Cannot set up configuration "
  4293. "from BIOS. Using base mode...\n");
  4294. board_config = ALC260_BASIC;
  4295. }
  4296. }
  4297. if (board_config != ALC260_AUTO)
  4298. setup_preset(spec, &alc260_presets[board_config]);
  4299. spec->stream_name_analog = "ALC260 Analog";
  4300. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4301. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4302. spec->stream_name_digital = "ALC260 Digital";
  4303. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4304. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4305. codec->patch_ops = alc_patch_ops;
  4306. if (board_config == ALC260_AUTO)
  4307. spec->init_hook = alc260_auto_init;
  4308. return 0;
  4309. }
  4310. /*
  4311. * ALC882 support
  4312. *
  4313. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4314. * configuration. Each pin widget can choose any input DACs and a mixer.
  4315. * Each ADC is connected from a mixer of all inputs. This makes possible
  4316. * 6-channel independent captures.
  4317. *
  4318. * In addition, an independent DAC for the multi-playback (not used in this
  4319. * driver yet).
  4320. */
  4321. #define ALC882_DIGOUT_NID 0x06
  4322. #define ALC882_DIGIN_NID 0x0a
  4323. static struct hda_channel_mode alc882_ch_modes[1] = {
  4324. { 8, NULL }
  4325. };
  4326. static hda_nid_t alc882_dac_nids[4] = {
  4327. /* front, rear, clfe, rear_surr */
  4328. 0x02, 0x03, 0x04, 0x05
  4329. };
  4330. /* identical with ALC880 */
  4331. #define alc882_adc_nids alc880_adc_nids
  4332. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4333. /* input MUX */
  4334. /* FIXME: should be a matrix-type input source selection */
  4335. static struct hda_input_mux alc882_capture_source = {
  4336. .num_items = 4,
  4337. .items = {
  4338. { "Mic", 0x0 },
  4339. { "Front Mic", 0x1 },
  4340. { "Line", 0x2 },
  4341. { "CD", 0x4 },
  4342. },
  4343. };
  4344. #define alc882_mux_enum_info alc_mux_enum_info
  4345. #define alc882_mux_enum_get alc_mux_enum_get
  4346. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4347. struct snd_ctl_elem_value *ucontrol)
  4348. {
  4349. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4350. struct alc_spec *spec = codec->spec;
  4351. const struct hda_input_mux *imux = spec->input_mux;
  4352. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4353. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4354. hda_nid_t nid = capture_mixers[adc_idx];
  4355. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4356. unsigned int i, idx;
  4357. idx = ucontrol->value.enumerated.item[0];
  4358. if (idx >= imux->num_items)
  4359. idx = imux->num_items - 1;
  4360. if (*cur_val == idx && !codec->in_resume)
  4361. return 0;
  4362. for (i = 0; i < imux->num_items; i++) {
  4363. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4364. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4365. v | (imux->items[i].index << 8));
  4366. }
  4367. *cur_val = idx;
  4368. return 1;
  4369. }
  4370. /*
  4371. * 2ch mode
  4372. */
  4373. static struct hda_verb alc882_3ST_ch2_init[] = {
  4374. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4375. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4376. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4377. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4378. { } /* end */
  4379. };
  4380. /*
  4381. * 6ch mode
  4382. */
  4383. static struct hda_verb alc882_3ST_ch6_init[] = {
  4384. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4385. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4386. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4387. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4388. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4389. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4390. { } /* end */
  4391. };
  4392. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4393. { 2, alc882_3ST_ch2_init },
  4394. { 6, alc882_3ST_ch6_init },
  4395. };
  4396. /*
  4397. * 6ch mode
  4398. */
  4399. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4400. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4401. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4402. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4403. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4404. { } /* end */
  4405. };
  4406. /*
  4407. * 8ch mode
  4408. */
  4409. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4410. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4411. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4412. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4413. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4414. { } /* end */
  4415. };
  4416. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4417. { 6, alc882_sixstack_ch6_init },
  4418. { 8, alc882_sixstack_ch8_init },
  4419. };
  4420. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4421. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4422. */
  4423. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4424. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4425. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4426. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4427. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4428. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4429. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4430. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4431. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4432. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4433. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4434. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4435. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4436. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4437. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4438. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4439. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4440. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4441. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4442. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4443. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4444. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4445. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4446. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4447. { } /* end */
  4448. };
  4449. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4450. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4451. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4452. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4453. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4454. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4455. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4456. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4457. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4458. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4459. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4460. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4461. { } /* end */
  4462. };
  4463. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4464. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4465. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4466. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4467. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4468. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4469. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4470. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4471. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4472. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4473. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4474. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4475. { } /* end */
  4476. };
  4477. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4478. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4479. */
  4480. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4481. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4482. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4483. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4484. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4485. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4486. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4487. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4488. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4489. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4490. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4491. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4492. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4493. { } /* end */
  4494. };
  4495. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4496. {
  4497. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4498. .name = "Channel Mode",
  4499. .info = alc_ch_mode_info,
  4500. .get = alc_ch_mode_get,
  4501. .put = alc_ch_mode_put,
  4502. },
  4503. { } /* end */
  4504. };
  4505. static struct hda_verb alc882_init_verbs[] = {
  4506. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4507. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4508. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4509. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4510. /* Rear mixer */
  4511. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4512. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4513. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4514. /* CLFE mixer */
  4515. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4516. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4517. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4518. /* Side mixer */
  4519. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4520. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4521. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4522. /* Front Pin: output 0 (0x0c) */
  4523. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4524. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4525. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4526. /* Rear Pin: output 1 (0x0d) */
  4527. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4528. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4529. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4530. /* CLFE Pin: output 2 (0x0e) */
  4531. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4532. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4533. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4534. /* Side Pin: output 3 (0x0f) */
  4535. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4536. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4537. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4538. /* Mic (rear) pin: input vref at 80% */
  4539. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4540. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4541. /* Front Mic pin: input vref at 80% */
  4542. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4543. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4544. /* Line In pin: input */
  4545. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4546. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4547. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4548. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4549. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4550. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4551. /* CD pin widget for input */
  4552. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4553. /* FIXME: use matrix-type input source selection */
  4554. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4555. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4556. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4557. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4558. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4559. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4560. /* Input mixer2 */
  4561. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4562. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4563. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4564. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4565. /* Input mixer3 */
  4566. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4567. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4568. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4569. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4570. /* ADC1: mute amp left and right */
  4571. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4572. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4573. /* ADC2: mute amp left and right */
  4574. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4575. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4576. /* ADC3: mute amp left and right */
  4577. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4578. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4579. { }
  4580. };
  4581. static struct hda_verb alc882_eapd_verbs[] = {
  4582. /* change to EAPD mode */
  4583. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4584. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4585. { }
  4586. };
  4587. /* Mac Pro test */
  4588. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4589. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4590. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4591. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4592. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4593. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4594. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4595. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4596. { } /* end */
  4597. };
  4598. static struct hda_verb alc882_macpro_init_verbs[] = {
  4599. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4600. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4601. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4602. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4603. /* Front Pin: output 0 (0x0c) */
  4604. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4605. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4606. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4607. /* Front Mic pin: input vref at 80% */
  4608. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4609. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4610. /* Speaker: output */
  4611. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4612. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4613. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4614. /* Headphone output (output 0 - 0x0c) */
  4615. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4616. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4617. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4618. /* FIXME: use matrix-type input source selection */
  4619. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4620. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4621. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4622. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4623. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4624. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4625. /* Input mixer2 */
  4626. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4627. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4628. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4629. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4630. /* Input mixer3 */
  4631. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4632. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4633. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4634. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4635. /* ADC1: mute amp left and right */
  4636. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4637. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4638. /* ADC2: mute amp left and right */
  4639. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4640. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4641. /* ADC3: mute amp left and right */
  4642. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4643. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4644. { }
  4645. };
  4646. static struct hda_verb alc882_targa_verbs[] = {
  4647. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4648. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4649. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4650. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4651. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4652. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4653. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4654. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4655. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4656. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4657. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4658. { } /* end */
  4659. };
  4660. /* toggle speaker-output according to the hp-jack state */
  4661. static void alc882_targa_automute(struct hda_codec *codec)
  4662. {
  4663. unsigned int present;
  4664. present = snd_hda_codec_read(codec, 0x14, 0,
  4665. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4666. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4667. 0x80, present ? 0x80 : 0);
  4668. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4669. 0x80, present ? 0x80 : 0);
  4670. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4671. }
  4672. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4673. {
  4674. /* Looks like the unsol event is incompatible with the standard
  4675. * definition. 4bit tag is placed at 26 bit!
  4676. */
  4677. if (((res >> 26) == ALC880_HP_EVENT)) {
  4678. alc882_targa_automute(codec);
  4679. }
  4680. }
  4681. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4682. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4683. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4684. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4685. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4686. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4687. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4688. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4689. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4690. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4691. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4692. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4693. { } /* end */
  4694. };
  4695. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4696. {
  4697. unsigned int gpiostate, gpiomask, gpiodir;
  4698. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4699. AC_VERB_GET_GPIO_DATA, 0);
  4700. if (!muted)
  4701. gpiostate |= (1 << pin);
  4702. else
  4703. gpiostate &= ~(1 << pin);
  4704. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4705. AC_VERB_GET_GPIO_MASK, 0);
  4706. gpiomask |= (1 << pin);
  4707. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4708. AC_VERB_GET_GPIO_DIRECTION, 0);
  4709. gpiodir |= (1 << pin);
  4710. snd_hda_codec_write(codec, codec->afg, 0,
  4711. AC_VERB_SET_GPIO_MASK, gpiomask);
  4712. snd_hda_codec_write(codec, codec->afg, 0,
  4713. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4714. msleep(1);
  4715. snd_hda_codec_write(codec, codec->afg, 0,
  4716. AC_VERB_SET_GPIO_DATA, gpiostate);
  4717. }
  4718. /*
  4719. * generic initialization of ADC, input mixers and output mixers
  4720. */
  4721. static struct hda_verb alc882_auto_init_verbs[] = {
  4722. /*
  4723. * Unmute ADC0-2 and set the default input to mic-in
  4724. */
  4725. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4726. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4727. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4728. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4729. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4730. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4731. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4732. * mixer widget
  4733. * Note: PASD motherboards uses the Line In 2 as the input for
  4734. * front panel mic (mic 2)
  4735. */
  4736. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4737. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4738. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4739. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4740. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4741. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4742. /*
  4743. * Set up output mixers (0x0c - 0x0f)
  4744. */
  4745. /* set vol=0 to output mixers */
  4746. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4747. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4748. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4749. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4750. /* set up input amps for analog loopback */
  4751. /* Amp Indices: DAC = 0, mixer = 1 */
  4752. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4753. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4754. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4755. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4756. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4757. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4758. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4759. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4760. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4761. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4762. /* FIXME: use matrix-type input source selection */
  4763. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4764. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4765. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4766. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4767. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4768. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4769. /* Input mixer2 */
  4770. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4771. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4772. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4773. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4774. /* Input mixer3 */
  4775. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4776. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4777. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4778. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4779. { }
  4780. };
  4781. /* capture mixer elements */
  4782. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4783. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4784. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4785. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4786. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4787. {
  4788. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4789. /* The multiple "Capture Source" controls confuse alsamixer
  4790. * So call somewhat different..
  4791. * FIXME: the controls appear in the "playback" view!
  4792. */
  4793. /* .name = "Capture Source", */
  4794. .name = "Input Source",
  4795. .count = 2,
  4796. .info = alc882_mux_enum_info,
  4797. .get = alc882_mux_enum_get,
  4798. .put = alc882_mux_enum_put,
  4799. },
  4800. { } /* end */
  4801. };
  4802. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4803. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4804. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4805. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4806. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4807. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4808. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4809. {
  4810. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4811. /* The multiple "Capture Source" controls confuse alsamixer
  4812. * So call somewhat different..
  4813. * FIXME: the controls appear in the "playback" view!
  4814. */
  4815. /* .name = "Capture Source", */
  4816. .name = "Input Source",
  4817. .count = 3,
  4818. .info = alc882_mux_enum_info,
  4819. .get = alc882_mux_enum_get,
  4820. .put = alc882_mux_enum_put,
  4821. },
  4822. { } /* end */
  4823. };
  4824. /* pcm configuration: identiacal with ALC880 */
  4825. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4826. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4827. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4828. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4829. /*
  4830. * configuration and preset
  4831. */
  4832. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4833. [ALC882_3ST_DIG] = "3stack-dig",
  4834. [ALC882_6ST_DIG] = "6stack-dig",
  4835. [ALC882_ARIMA] = "arima",
  4836. [ALC882_W2JC] = "w2jc",
  4837. [ALC885_MACPRO] = "macpro",
  4838. [ALC882_AUTO] = "auto",
  4839. };
  4840. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4841. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4842. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4843. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4844. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4845. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4846. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4847. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4848. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4849. {}
  4850. };
  4851. static struct alc_config_preset alc882_presets[] = {
  4852. [ALC882_3ST_DIG] = {
  4853. .mixers = { alc882_base_mixer },
  4854. .init_verbs = { alc882_init_verbs },
  4855. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4856. .dac_nids = alc882_dac_nids,
  4857. .dig_out_nid = ALC882_DIGOUT_NID,
  4858. .dig_in_nid = ALC882_DIGIN_NID,
  4859. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4860. .channel_mode = alc882_ch_modes,
  4861. .need_dac_fix = 1,
  4862. .input_mux = &alc882_capture_source,
  4863. },
  4864. [ALC882_6ST_DIG] = {
  4865. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4866. .init_verbs = { alc882_init_verbs },
  4867. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4868. .dac_nids = alc882_dac_nids,
  4869. .dig_out_nid = ALC882_DIGOUT_NID,
  4870. .dig_in_nid = ALC882_DIGIN_NID,
  4871. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4872. .channel_mode = alc882_sixstack_modes,
  4873. .input_mux = &alc882_capture_source,
  4874. },
  4875. [ALC882_ARIMA] = {
  4876. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4877. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4878. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4879. .dac_nids = alc882_dac_nids,
  4880. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4881. .channel_mode = alc882_sixstack_modes,
  4882. .input_mux = &alc882_capture_source,
  4883. },
  4884. [ALC882_W2JC] = {
  4885. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4886. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4887. alc880_gpio1_init_verbs },
  4888. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4889. .dac_nids = alc882_dac_nids,
  4890. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4891. .channel_mode = alc880_threestack_modes,
  4892. .need_dac_fix = 1,
  4893. .input_mux = &alc882_capture_source,
  4894. .dig_out_nid = ALC882_DIGOUT_NID,
  4895. },
  4896. [ALC885_MACPRO] = {
  4897. .mixers = { alc882_macpro_mixer },
  4898. .init_verbs = { alc882_macpro_init_verbs },
  4899. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4900. .dac_nids = alc882_dac_nids,
  4901. .dig_out_nid = ALC882_DIGOUT_NID,
  4902. .dig_in_nid = ALC882_DIGIN_NID,
  4903. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4904. .channel_mode = alc882_ch_modes,
  4905. .input_mux = &alc882_capture_source,
  4906. },
  4907. [ALC882_TARGA] = {
  4908. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4909. alc882_capture_mixer },
  4910. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4911. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4912. .dac_nids = alc882_dac_nids,
  4913. .dig_out_nid = ALC882_DIGOUT_NID,
  4914. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4915. .adc_nids = alc882_adc_nids,
  4916. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4917. .channel_mode = alc882_3ST_6ch_modes,
  4918. .need_dac_fix = 1,
  4919. .input_mux = &alc882_capture_source,
  4920. .unsol_event = alc882_targa_unsol_event,
  4921. .init_hook = alc882_targa_automute,
  4922. },
  4923. [ALC882_ASUS_A7J] = {
  4924. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4925. alc882_capture_mixer },
  4926. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4927. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4928. .dac_nids = alc882_dac_nids,
  4929. .dig_out_nid = ALC882_DIGOUT_NID,
  4930. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4931. .adc_nids = alc882_adc_nids,
  4932. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4933. .channel_mode = alc882_3ST_6ch_modes,
  4934. .need_dac_fix = 1,
  4935. .input_mux = &alc882_capture_source,
  4936. },
  4937. };
  4938. /*
  4939. * Pin config fixes
  4940. */
  4941. enum {
  4942. PINFIX_ABIT_AW9D_MAX
  4943. };
  4944. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  4945. { 0x15, 0x01080104 }, /* side */
  4946. { 0x16, 0x01011012 }, /* rear */
  4947. { 0x17, 0x01016011 }, /* clfe */
  4948. { }
  4949. };
  4950. static const struct alc_pincfg *alc882_pin_fixes[] = {
  4951. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  4952. };
  4953. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  4954. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  4955. {}
  4956. };
  4957. /*
  4958. * BIOS auto configuration
  4959. */
  4960. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4961. hda_nid_t nid, int pin_type,
  4962. int dac_idx)
  4963. {
  4964. /* set as output */
  4965. struct alc_spec *spec = codec->spec;
  4966. int idx;
  4967. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4968. idx = 4;
  4969. else
  4970. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4971. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4972. pin_type);
  4973. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4974. AMP_OUT_UNMUTE);
  4975. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4976. }
  4977. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4978. {
  4979. struct alc_spec *spec = codec->spec;
  4980. int i;
  4981. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4982. for (i = 0; i <= HDA_SIDE; i++) {
  4983. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4984. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4985. if (nid)
  4986. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  4987. i);
  4988. }
  4989. }
  4990. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4991. {
  4992. struct alc_spec *spec = codec->spec;
  4993. hda_nid_t pin;
  4994. pin = spec->autocfg.hp_pins[0];
  4995. if (pin) /* connect to front */
  4996. /* use dac 0 */
  4997. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4998. }
  4999. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5000. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5001. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5002. {
  5003. struct alc_spec *spec = codec->spec;
  5004. int i;
  5005. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5006. hda_nid_t nid = spec->autocfg.input_pins[i];
  5007. if (alc882_is_input_pin(nid)) {
  5008. snd_hda_codec_write(codec, nid, 0,
  5009. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5010. i <= AUTO_PIN_FRONT_MIC ?
  5011. PIN_VREF80 : PIN_IN);
  5012. if (nid != ALC882_PIN_CD_NID)
  5013. snd_hda_codec_write(codec, nid, 0,
  5014. AC_VERB_SET_AMP_GAIN_MUTE,
  5015. AMP_OUT_MUTE);
  5016. }
  5017. }
  5018. }
  5019. /* almost identical with ALC880 parser... */
  5020. static int alc882_parse_auto_config(struct hda_codec *codec)
  5021. {
  5022. struct alc_spec *spec = codec->spec;
  5023. int err = alc880_parse_auto_config(codec);
  5024. if (err < 0)
  5025. return err;
  5026. else if (err > 0)
  5027. /* hack - override the init verbs */
  5028. spec->init_verbs[0] = alc882_auto_init_verbs;
  5029. return err;
  5030. }
  5031. /* additional initialization for auto-configuration model */
  5032. static void alc882_auto_init(struct hda_codec *codec)
  5033. {
  5034. alc882_auto_init_multi_out(codec);
  5035. alc882_auto_init_hp_out(codec);
  5036. alc882_auto_init_analog_input(codec);
  5037. }
  5038. static int patch_alc882(struct hda_codec *codec)
  5039. {
  5040. struct alc_spec *spec;
  5041. int err, board_config;
  5042. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5043. if (spec == NULL)
  5044. return -ENOMEM;
  5045. codec->spec = spec;
  5046. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5047. alc882_models,
  5048. alc882_cfg_tbl);
  5049. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5050. /* Pick up systems that don't supply PCI SSID */
  5051. switch (codec->subsystem_id) {
  5052. case 0x106b0c00: /* Mac Pro */
  5053. board_config = ALC885_MACPRO;
  5054. break;
  5055. default:
  5056. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5057. "trying auto-probe from BIOS...\n");
  5058. board_config = ALC882_AUTO;
  5059. }
  5060. }
  5061. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5062. if (board_config == ALC882_AUTO) {
  5063. /* automatic parse from the BIOS config */
  5064. err = alc882_parse_auto_config(codec);
  5065. if (err < 0) {
  5066. alc_free(codec);
  5067. return err;
  5068. } else if (!err) {
  5069. printk(KERN_INFO
  5070. "hda_codec: Cannot set up configuration "
  5071. "from BIOS. Using base mode...\n");
  5072. board_config = ALC882_3ST_DIG;
  5073. }
  5074. }
  5075. if (board_config != ALC882_AUTO)
  5076. setup_preset(spec, &alc882_presets[board_config]);
  5077. if (board_config == ALC885_MACPRO) {
  5078. alc882_gpio_mute(codec, 0, 0);
  5079. alc882_gpio_mute(codec, 1, 0);
  5080. }
  5081. spec->stream_name_analog = "ALC882 Analog";
  5082. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5083. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5084. spec->stream_name_digital = "ALC882 Digital";
  5085. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5086. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5087. if (!spec->adc_nids && spec->input_mux) {
  5088. /* check whether NID 0x07 is valid */
  5089. unsigned int wcap = get_wcaps(codec, 0x07);
  5090. /* get type */
  5091. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5092. if (wcap != AC_WID_AUD_IN) {
  5093. spec->adc_nids = alc882_adc_nids_alt;
  5094. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5095. spec->mixers[spec->num_mixers] =
  5096. alc882_capture_alt_mixer;
  5097. spec->num_mixers++;
  5098. } else {
  5099. spec->adc_nids = alc882_adc_nids;
  5100. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5101. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5102. spec->num_mixers++;
  5103. }
  5104. }
  5105. codec->patch_ops = alc_patch_ops;
  5106. if (board_config == ALC882_AUTO)
  5107. spec->init_hook = alc882_auto_init;
  5108. return 0;
  5109. }
  5110. /*
  5111. * ALC883 support
  5112. *
  5113. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5114. * configuration. Each pin widget can choose any input DACs and a mixer.
  5115. * Each ADC is connected from a mixer of all inputs. This makes possible
  5116. * 6-channel independent captures.
  5117. *
  5118. * In addition, an independent DAC for the multi-playback (not used in this
  5119. * driver yet).
  5120. */
  5121. #define ALC883_DIGOUT_NID 0x06
  5122. #define ALC883_DIGIN_NID 0x0a
  5123. static hda_nid_t alc883_dac_nids[4] = {
  5124. /* front, rear, clfe, rear_surr */
  5125. 0x02, 0x04, 0x03, 0x05
  5126. };
  5127. static hda_nid_t alc883_adc_nids[2] = {
  5128. /* ADC1-2 */
  5129. 0x08, 0x09,
  5130. };
  5131. /* input MUX */
  5132. /* FIXME: should be a matrix-type input source selection */
  5133. static struct hda_input_mux alc883_capture_source = {
  5134. .num_items = 4,
  5135. .items = {
  5136. { "Mic", 0x0 },
  5137. { "Front Mic", 0x1 },
  5138. { "Line", 0x2 },
  5139. { "CD", 0x4 },
  5140. },
  5141. };
  5142. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5143. .num_items = 2,
  5144. .items = {
  5145. { "Mic", 0x1 },
  5146. { "Line", 0x2 },
  5147. },
  5148. };
  5149. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5150. .num_items = 4,
  5151. .items = {
  5152. { "Mic", 0x0 },
  5153. { "iMic", 0x1 },
  5154. { "Line", 0x2 },
  5155. { "CD", 0x4 },
  5156. },
  5157. };
  5158. #define alc883_mux_enum_info alc_mux_enum_info
  5159. #define alc883_mux_enum_get alc_mux_enum_get
  5160. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5161. struct snd_ctl_elem_value *ucontrol)
  5162. {
  5163. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5164. struct alc_spec *spec = codec->spec;
  5165. const struct hda_input_mux *imux = spec->input_mux;
  5166. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5167. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5168. hda_nid_t nid = capture_mixers[adc_idx];
  5169. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5170. unsigned int i, idx;
  5171. idx = ucontrol->value.enumerated.item[0];
  5172. if (idx >= imux->num_items)
  5173. idx = imux->num_items - 1;
  5174. if (*cur_val == idx && !codec->in_resume)
  5175. return 0;
  5176. for (i = 0; i < imux->num_items; i++) {
  5177. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5178. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5179. v | (imux->items[i].index << 8));
  5180. }
  5181. *cur_val = idx;
  5182. return 1;
  5183. }
  5184. /*
  5185. * 2ch mode
  5186. */
  5187. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5188. { 2, NULL }
  5189. };
  5190. /*
  5191. * 2ch mode
  5192. */
  5193. static struct hda_verb alc883_3ST_ch2_init[] = {
  5194. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5195. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5196. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5197. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5198. { } /* end */
  5199. };
  5200. /*
  5201. * 6ch mode
  5202. */
  5203. static struct hda_verb alc883_3ST_ch6_init[] = {
  5204. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5205. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5206. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5207. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5208. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5209. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5210. { } /* end */
  5211. };
  5212. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5213. { 2, alc883_3ST_ch2_init },
  5214. { 6, alc883_3ST_ch6_init },
  5215. };
  5216. /*
  5217. * 6ch mode
  5218. */
  5219. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5220. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5221. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5222. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5223. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5224. { } /* end */
  5225. };
  5226. /*
  5227. * 8ch mode
  5228. */
  5229. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5230. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5231. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5232. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5233. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5234. { } /* end */
  5235. };
  5236. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5237. { 6, alc883_sixstack_ch6_init },
  5238. { 8, alc883_sixstack_ch8_init },
  5239. };
  5240. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5241. /* eanable EAPD on medion laptop */
  5242. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5243. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5244. { }
  5245. };
  5246. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5247. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5248. */
  5249. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5250. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5251. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5252. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5253. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5254. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5255. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5256. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5257. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5258. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5259. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5260. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5261. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5262. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5263. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5264. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5265. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5266. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5267. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5268. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5269. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5270. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5271. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5272. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5273. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5274. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5275. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5276. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5277. {
  5278. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5279. /* .name = "Capture Source", */
  5280. .name = "Input Source",
  5281. .count = 2,
  5282. .info = alc883_mux_enum_info,
  5283. .get = alc883_mux_enum_get,
  5284. .put = alc883_mux_enum_put,
  5285. },
  5286. { } /* end */
  5287. };
  5288. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5289. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5290. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5291. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5292. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5293. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5294. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5295. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5296. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5297. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5298. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5299. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5300. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5301. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5302. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5303. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5304. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5305. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5306. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5307. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5308. {
  5309. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5310. /* .name = "Capture Source", */
  5311. .name = "Input Source",
  5312. .count = 2,
  5313. .info = alc883_mux_enum_info,
  5314. .get = alc883_mux_enum_get,
  5315. .put = alc883_mux_enum_put,
  5316. },
  5317. { } /* end */
  5318. };
  5319. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5320. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5321. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5322. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5323. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5324. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5325. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5326. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5327. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5328. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5329. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5330. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5331. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5332. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5333. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5334. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5335. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5336. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5337. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5338. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5339. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5340. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5341. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5342. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5343. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5344. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5345. {
  5346. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5347. /* .name = "Capture Source", */
  5348. .name = "Input Source",
  5349. .count = 2,
  5350. .info = alc883_mux_enum_info,
  5351. .get = alc883_mux_enum_get,
  5352. .put = alc883_mux_enum_put,
  5353. },
  5354. { } /* end */
  5355. };
  5356. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5357. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5358. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5359. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5360. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5361. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5362. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5363. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5364. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5365. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5366. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5367. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5368. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5369. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5370. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5371. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5372. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5373. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5374. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5375. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5376. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5377. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5378. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5379. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5380. {
  5381. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5382. /* .name = "Capture Source", */
  5383. .name = "Input Source",
  5384. .count = 1,
  5385. .info = alc883_mux_enum_info,
  5386. .get = alc883_mux_enum_get,
  5387. .put = alc883_mux_enum_put,
  5388. },
  5389. { } /* end */
  5390. };
  5391. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5392. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5393. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5394. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5395. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5396. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5397. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5398. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5399. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5400. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5401. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5402. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5403. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5404. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5405. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5406. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5407. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5408. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5409. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5410. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5411. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5412. {
  5413. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5414. /* .name = "Capture Source", */
  5415. .name = "Input Source",
  5416. .count = 2,
  5417. .info = alc883_mux_enum_info,
  5418. .get = alc883_mux_enum_get,
  5419. .put = alc883_mux_enum_put,
  5420. },
  5421. { } /* end */
  5422. };
  5423. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5424. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5425. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5426. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5427. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5428. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5429. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5430. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5431. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, 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_lenovo_101e_2ch_mixer[] = {
  5448. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5449. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5450. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5451. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5452. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5453. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5454. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5455. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5456. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5457. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5458. {
  5459. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5460. /* .name = "Capture Source", */
  5461. .name = "Input Source",
  5462. .count = 1,
  5463. .info = alc883_mux_enum_info,
  5464. .get = alc883_mux_enum_get,
  5465. .put = alc883_mux_enum_put,
  5466. },
  5467. { } /* end */
  5468. };
  5469. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5470. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5471. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5472. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5473. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5474. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5475. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5476. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5477. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5478. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5479. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5480. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5481. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5482. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5483. {
  5484. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5485. /* .name = "Capture Source", */
  5486. .name = "Input Source",
  5487. .count = 2,
  5488. .info = alc883_mux_enum_info,
  5489. .get = alc883_mux_enum_get,
  5490. .put = alc883_mux_enum_put,
  5491. },
  5492. { } /* end */
  5493. };
  5494. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5495. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5496. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5497. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5498. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5499. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5500. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5501. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5502. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5503. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5504. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5505. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5506. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5507. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5508. {
  5509. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5510. /* .name = "Capture Source", */
  5511. .name = "Input Source",
  5512. .count = 2,
  5513. .info = alc883_mux_enum_info,
  5514. .get = alc883_mux_enum_get,
  5515. .put = alc883_mux_enum_put,
  5516. },
  5517. { } /* end */
  5518. };
  5519. static struct snd_kcontrol_new alc888_hp_nettle_mixer[] = {
  5520. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5521. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5522. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5523. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5524. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5525. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5526. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5527. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5528. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5529. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5530. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5531. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5532. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5533. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5534. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5535. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5536. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5537. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5538. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5539. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5540. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5541. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5542. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5543. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5544. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5545. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5546. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5547. {
  5548. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5549. /* .name = "Capture Source", */
  5550. .name = "Input Source",
  5551. .count = 2,
  5552. .info = alc883_mux_enum_info,
  5553. .get = alc883_mux_enum_get,
  5554. .put = alc883_mux_enum_put,
  5555. },
  5556. { } /* end */
  5557. };
  5558. static struct snd_kcontrol_new alc888_hp_lucknow_mixer[] = {
  5559. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5560. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5561. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5562. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5563. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5564. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5565. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5566. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5567. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5568. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5569. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5570. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5571. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5572. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5573. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5574. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5575. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5576. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5577. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5578. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5579. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5580. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5581. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5582. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5583. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5584. {
  5585. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5586. /* .name = "Capture Source", */
  5587. .name = "Input Source",
  5588. .count = 2,
  5589. .info = alc883_mux_enum_info,
  5590. .get = alc883_mux_enum_get,
  5591. .put = alc883_mux_enum_put,
  5592. },
  5593. { } /* end */
  5594. };
  5595. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5596. {
  5597. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5598. .name = "Channel Mode",
  5599. .info = alc_ch_mode_info,
  5600. .get = alc_ch_mode_get,
  5601. .put = alc_ch_mode_put,
  5602. },
  5603. { } /* end */
  5604. };
  5605. static struct hda_verb alc883_init_verbs[] = {
  5606. /* ADC1: mute amp left and right */
  5607. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5608. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5609. /* ADC2: mute amp left and right */
  5610. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5611. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5612. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5613. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5614. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5615. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5616. /* Rear mixer */
  5617. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5618. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5619. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5620. /* CLFE mixer */
  5621. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5622. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5623. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5624. /* Side mixer */
  5625. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5626. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5627. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5628. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5629. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5630. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5631. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5632. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5633. /* Front Pin: output 0 (0x0c) */
  5634. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5635. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5636. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5637. /* Rear Pin: output 1 (0x0d) */
  5638. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5639. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5640. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5641. /* CLFE Pin: output 2 (0x0e) */
  5642. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5643. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5644. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5645. /* Side Pin: output 3 (0x0f) */
  5646. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5647. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5648. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5649. /* Mic (rear) pin: input vref at 80% */
  5650. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5651. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5652. /* Front Mic pin: input vref at 80% */
  5653. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5654. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5655. /* Line In pin: input */
  5656. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5657. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5658. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5659. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5660. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5661. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5662. /* CD pin widget for input */
  5663. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5664. /* FIXME: use matrix-type input source selection */
  5665. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5666. /* Input mixer2 */
  5667. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5668. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5669. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5670. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5671. /* Input mixer3 */
  5672. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5673. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5674. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5675. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5676. { }
  5677. };
  5678. static struct hda_verb alc883_tagra_verbs[] = {
  5679. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5680. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5681. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5682. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5683. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5684. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5685. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5686. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5687. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5688. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5689. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5690. { } /* end */
  5691. };
  5692. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5693. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5694. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5695. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5696. { } /* end */
  5697. };
  5698. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5699. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5700. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5701. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5702. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5703. { } /* end */
  5704. };
  5705. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5706. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5707. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5708. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5709. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5710. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5711. { } /* end */
  5712. };
  5713. static struct hda_verb alc888_hp_nettle_verbs[] = {
  5714. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5715. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  5716. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  5717. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  5718. { }
  5719. };
  5720. static struct hda_verb alc888_hp_lucknow_verbs[] = {
  5721. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5722. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  5723. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  5724. { }
  5725. };
  5726. static struct hda_verb alc888_hp_lucknow_2ch_init[] = {
  5727. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5728. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5729. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5730. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5731. { }
  5732. };
  5733. static struct hda_verb alc888_hp_lucknow_6ch_init[] = {
  5734. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5735. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5736. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5737. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5738. { }
  5739. };
  5740. static struct hda_channel_mode alc888_hp_lucknow_modes[2] = {
  5741. { 2, alc888_hp_lucknow_2ch_init },
  5742. { 6, alc888_hp_lucknow_6ch_init },
  5743. };
  5744. /* toggle front-jack and RCA according to the hp-jack state */
  5745. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5746. {
  5747. unsigned int present;
  5748. present = snd_hda_codec_read(codec, 0x1b, 0,
  5749. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5750. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5751. 0x80, present ? 0x80 : 0);
  5752. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5753. 0x80, present ? 0x80 : 0);
  5754. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5755. 0x80, present ? 0x80 : 0);
  5756. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5757. 0x80, present ? 0x80 : 0);
  5758. }
  5759. /* toggle RCA according to the front-jack state */
  5760. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5761. {
  5762. unsigned int present;
  5763. present = snd_hda_codec_read(codec, 0x14, 0,
  5764. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5765. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5766. 0x80, present ? 0x80 : 0);
  5767. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5768. 0x80, present ? 0x80 : 0);
  5769. }
  5770. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5771. unsigned int res)
  5772. {
  5773. if ((res >> 26) == ALC880_HP_EVENT)
  5774. alc888_lenovo_ms7195_front_automute(codec);
  5775. if ((res >> 26) == ALC880_FRONT_EVENT)
  5776. alc888_lenovo_ms7195_rca_automute(codec);
  5777. }
  5778. static struct hda_verb alc883_medion_md2_verbs[] = {
  5779. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5780. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5781. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5782. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5783. { } /* end */
  5784. };
  5785. /* toggle speaker-output according to the hp-jack state */
  5786. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5787. {
  5788. unsigned int present;
  5789. present = snd_hda_codec_read(codec, 0x14, 0,
  5790. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5791. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5792. 0x80, present ? 0x80 : 0);
  5793. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5794. 0x80, present ? 0x80 : 0);
  5795. }
  5796. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5797. unsigned int res)
  5798. {
  5799. if ((res >> 26) == ALC880_HP_EVENT)
  5800. alc883_medion_md2_automute(codec);
  5801. }
  5802. /* toggle speaker-output according to the hp-jack state */
  5803. static void alc883_tagra_automute(struct hda_codec *codec)
  5804. {
  5805. unsigned int present;
  5806. unsigned char bits;
  5807. present = snd_hda_codec_read(codec, 0x14, 0,
  5808. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5809. bits = present ? 0x80 : 0;
  5810. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5811. 0x80, bits);
  5812. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5813. 0x80, bits);
  5814. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5815. present ? 1 : 3);
  5816. }
  5817. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5818. {
  5819. if ((res >> 26) == ALC880_HP_EVENT)
  5820. alc883_tagra_automute(codec);
  5821. }
  5822. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5823. {
  5824. unsigned int present;
  5825. unsigned char bits;
  5826. present = snd_hda_codec_read(codec, 0x14, 0,
  5827. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5828. bits = present ? 0x80 : 0;
  5829. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5830. 0x80, bits);
  5831. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5832. 0x80, bits);
  5833. }
  5834. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5835. {
  5836. unsigned int present;
  5837. unsigned char bits;
  5838. present = snd_hda_codec_read(codec, 0x1b, 0,
  5839. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5840. bits = present ? 0x80 : 0;
  5841. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5842. 0x80, bits);
  5843. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5844. 0x80, bits);
  5845. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5846. 0x80, bits);
  5847. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5848. 0x80, bits);
  5849. }
  5850. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5851. unsigned int res)
  5852. {
  5853. if ((res >> 26) == ALC880_HP_EVENT)
  5854. alc883_lenovo_101e_all_automute(codec);
  5855. if ((res >> 26) == ALC880_FRONT_EVENT)
  5856. alc883_lenovo_101e_ispeaker_automute(codec);
  5857. }
  5858. /*
  5859. * generic initialization of ADC, input mixers and output mixers
  5860. */
  5861. static struct hda_verb alc883_auto_init_verbs[] = {
  5862. /*
  5863. * Unmute ADC0-2 and set the default input to mic-in
  5864. */
  5865. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5866. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5867. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5868. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5869. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5870. * mixer widget
  5871. * Note: PASD motherboards uses the Line In 2 as the input for
  5872. * front panel mic (mic 2)
  5873. */
  5874. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5875. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5876. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5877. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5878. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5879. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5880. /*
  5881. * Set up output mixers (0x0c - 0x0f)
  5882. */
  5883. /* set vol=0 to output mixers */
  5884. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5885. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5886. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5887. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5888. /* set up input amps for analog loopback */
  5889. /* Amp Indices: DAC = 0, mixer = 1 */
  5890. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5891. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5892. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5893. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5894. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5895. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5896. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5897. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5898. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5899. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5900. /* FIXME: use matrix-type input source selection */
  5901. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5902. /* Input mixer1 */
  5903. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5904. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5905. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5906. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5907. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5908. /* Input mixer2 */
  5909. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5910. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5911. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5912. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5913. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5914. { }
  5915. };
  5916. /* capture mixer elements */
  5917. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5918. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5919. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5920. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5921. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5922. {
  5923. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5924. /* The multiple "Capture Source" controls confuse alsamixer
  5925. * So call somewhat different..
  5926. * FIXME: the controls appear in the "playback" view!
  5927. */
  5928. /* .name = "Capture Source", */
  5929. .name = "Input Source",
  5930. .count = 2,
  5931. .info = alc882_mux_enum_info,
  5932. .get = alc882_mux_enum_get,
  5933. .put = alc882_mux_enum_put,
  5934. },
  5935. { } /* end */
  5936. };
  5937. /* pcm configuration: identiacal with ALC880 */
  5938. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5939. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5940. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5941. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5942. /*
  5943. * configuration and preset
  5944. */
  5945. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5946. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5947. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5948. [ALC883_3ST_6ch] = "3stack-6ch",
  5949. [ALC883_6ST_DIG] = "6stack-dig",
  5950. [ALC883_TARGA_DIG] = "targa-dig",
  5951. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5952. [ALC883_ACER] = "acer",
  5953. [ALC883_MEDION] = "medion",
  5954. [ALC883_MEDION_MD2] = "medion-md2",
  5955. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5956. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5957. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  5958. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  5959. [ALC888_HP_NETTLE] = "hp-nettle",
  5960. [ALC888_HP_LUCKNOW] = "hp-lucknow",
  5961. [ALC883_AUTO] = "auto",
  5962. };
  5963. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5964. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5965. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  5966. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5967. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5968. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5969. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5970. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5971. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5972. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  5973. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5974. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  5975. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5976. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  5977. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5978. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5979. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5980. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5981. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5982. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5983. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5984. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5985. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5986. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5987. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  5988. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5989. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5990. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5991. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  5992. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5993. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5994. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_HP_NETTLE),
  5995. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_HP_LUCKNOW),
  5996. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  5997. {}
  5998. };
  5999. static struct alc_config_preset alc883_presets[] = {
  6000. [ALC883_3ST_2ch_DIG] = {
  6001. .mixers = { alc883_3ST_2ch_mixer },
  6002. .init_verbs = { alc883_init_verbs },
  6003. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6004. .dac_nids = alc883_dac_nids,
  6005. .dig_out_nid = ALC883_DIGOUT_NID,
  6006. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6007. .adc_nids = alc883_adc_nids,
  6008. .dig_in_nid = ALC883_DIGIN_NID,
  6009. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6010. .channel_mode = alc883_3ST_2ch_modes,
  6011. .input_mux = &alc883_capture_source,
  6012. },
  6013. [ALC883_3ST_6ch_DIG] = {
  6014. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6015. .init_verbs = { alc883_init_verbs },
  6016. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6017. .dac_nids = alc883_dac_nids,
  6018. .dig_out_nid = ALC883_DIGOUT_NID,
  6019. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6020. .adc_nids = alc883_adc_nids,
  6021. .dig_in_nid = ALC883_DIGIN_NID,
  6022. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6023. .channel_mode = alc883_3ST_6ch_modes,
  6024. .need_dac_fix = 1,
  6025. .input_mux = &alc883_capture_source,
  6026. },
  6027. [ALC883_3ST_6ch] = {
  6028. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6029. .init_verbs = { alc883_init_verbs },
  6030. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6031. .dac_nids = alc883_dac_nids,
  6032. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6033. .adc_nids = alc883_adc_nids,
  6034. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6035. .channel_mode = alc883_3ST_6ch_modes,
  6036. .need_dac_fix = 1,
  6037. .input_mux = &alc883_capture_source,
  6038. },
  6039. [ALC883_6ST_DIG] = {
  6040. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6041. .init_verbs = { alc883_init_verbs },
  6042. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6043. .dac_nids = alc883_dac_nids,
  6044. .dig_out_nid = ALC883_DIGOUT_NID,
  6045. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6046. .adc_nids = alc883_adc_nids,
  6047. .dig_in_nid = ALC883_DIGIN_NID,
  6048. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6049. .channel_mode = alc883_sixstack_modes,
  6050. .input_mux = &alc883_capture_source,
  6051. },
  6052. [ALC883_TARGA_DIG] = {
  6053. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6054. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6055. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6056. .dac_nids = alc883_dac_nids,
  6057. .dig_out_nid = ALC883_DIGOUT_NID,
  6058. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6059. .adc_nids = alc883_adc_nids,
  6060. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6061. .channel_mode = alc883_3ST_6ch_modes,
  6062. .need_dac_fix = 1,
  6063. .input_mux = &alc883_capture_source,
  6064. .unsol_event = alc883_tagra_unsol_event,
  6065. .init_hook = alc883_tagra_automute,
  6066. },
  6067. [ALC883_TARGA_2ch_DIG] = {
  6068. .mixers = { alc883_tagra_2ch_mixer},
  6069. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6070. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6071. .dac_nids = alc883_dac_nids,
  6072. .dig_out_nid = ALC883_DIGOUT_NID,
  6073. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6074. .adc_nids = alc883_adc_nids,
  6075. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6076. .channel_mode = alc883_3ST_2ch_modes,
  6077. .input_mux = &alc883_capture_source,
  6078. .unsol_event = alc883_tagra_unsol_event,
  6079. .init_hook = alc883_tagra_automute,
  6080. },
  6081. [ALC883_ACER] = {
  6082. .mixers = { alc883_base_mixer,
  6083. alc883_chmode_mixer },
  6084. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6085. * and the headphone jack. Turn this on and rely on the
  6086. * standard mute methods whenever the user wants to turn
  6087. * these outputs off.
  6088. */
  6089. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6090. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6091. .dac_nids = alc883_dac_nids,
  6092. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6093. .adc_nids = alc883_adc_nids,
  6094. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6095. .channel_mode = alc883_3ST_2ch_modes,
  6096. .input_mux = &alc883_capture_source,
  6097. },
  6098. [ALC883_MEDION] = {
  6099. .mixers = { alc883_fivestack_mixer,
  6100. alc883_chmode_mixer },
  6101. .init_verbs = { alc883_init_verbs,
  6102. alc883_medion_eapd_verbs },
  6103. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6104. .dac_nids = alc883_dac_nids,
  6105. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6106. .adc_nids = alc883_adc_nids,
  6107. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6108. .channel_mode = alc883_sixstack_modes,
  6109. .input_mux = &alc883_capture_source,
  6110. },
  6111. [ALC883_MEDION_MD2] = {
  6112. .mixers = { alc883_medion_md2_mixer},
  6113. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6114. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6115. .dac_nids = alc883_dac_nids,
  6116. .dig_out_nid = ALC883_DIGOUT_NID,
  6117. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6118. .adc_nids = alc883_adc_nids,
  6119. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6120. .channel_mode = alc883_3ST_2ch_modes,
  6121. .input_mux = &alc883_capture_source,
  6122. .unsol_event = alc883_medion_md2_unsol_event,
  6123. .init_hook = alc883_medion_md2_automute,
  6124. },
  6125. [ALC883_LAPTOP_EAPD] = {
  6126. .mixers = { alc883_base_mixer,
  6127. alc883_chmode_mixer },
  6128. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6129. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6130. .dac_nids = alc883_dac_nids,
  6131. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6132. .adc_nids = alc883_adc_nids,
  6133. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6134. .channel_mode = alc883_3ST_2ch_modes,
  6135. .input_mux = &alc883_capture_source,
  6136. },
  6137. [ALC883_LENOVO_101E_2ch] = {
  6138. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6139. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6140. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6141. .dac_nids = alc883_dac_nids,
  6142. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6143. .adc_nids = alc883_adc_nids,
  6144. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6145. .channel_mode = alc883_3ST_2ch_modes,
  6146. .input_mux = &alc883_lenovo_101e_capture_source,
  6147. .unsol_event = alc883_lenovo_101e_unsol_event,
  6148. .init_hook = alc883_lenovo_101e_all_automute,
  6149. },
  6150. [ALC883_LENOVO_NB0763] = {
  6151. .mixers = { alc883_lenovo_nb0763_mixer },
  6152. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6153. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6154. .dac_nids = alc883_dac_nids,
  6155. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6156. .adc_nids = alc883_adc_nids,
  6157. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6158. .channel_mode = alc883_3ST_2ch_modes,
  6159. .need_dac_fix = 1,
  6160. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6161. .unsol_event = alc883_medion_md2_unsol_event,
  6162. .init_hook = alc883_medion_md2_automute,
  6163. },
  6164. [ALC888_LENOVO_MS7195_DIG] = {
  6165. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6166. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6167. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6168. .dac_nids = alc883_dac_nids,
  6169. .dig_out_nid = ALC883_DIGOUT_NID,
  6170. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6171. .adc_nids = alc883_adc_nids,
  6172. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6173. .channel_mode = alc883_3ST_6ch_modes,
  6174. .need_dac_fix = 1,
  6175. .input_mux = &alc883_capture_source,
  6176. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6177. .init_hook = alc888_lenovo_ms7195_front_automute,
  6178. },
  6179. [ALC888_HP_NETTLE] = {
  6180. .mixers = { alc888_hp_nettle_mixer, alc883_chmode_mixer },
  6181. .init_verbs = { alc883_init_verbs, alc888_hp_nettle_verbs },
  6182. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6183. .dac_nids = alc883_dac_nids,
  6184. .dig_out_nid = ALC883_DIGOUT_NID,
  6185. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6186. .adc_nids = alc883_adc_nids,
  6187. .dig_in_nid = ALC883_DIGIN_NID,
  6188. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6189. .channel_mode = alc883_sixstack_modes,
  6190. .input_mux = &alc883_capture_source,
  6191. },
  6192. [ALC888_HP_LUCKNOW] = {
  6193. .mixers = { alc888_hp_lucknow_mixer, alc883_chmode_mixer },
  6194. .init_verbs = { alc883_init_verbs, alc888_hp_lucknow_verbs },
  6195. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6196. .dac_nids = alc883_dac_nids,
  6197. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6198. .adc_nids = alc883_adc_nids,
  6199. .num_channel_mode = ARRAY_SIZE(alc888_hp_lucknow_modes),
  6200. .channel_mode = alc888_hp_lucknow_modes,
  6201. .need_dac_fix = 1,
  6202. .input_mux = &alc883_capture_source,
  6203. },
  6204. };
  6205. /*
  6206. * BIOS auto configuration
  6207. */
  6208. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6209. hda_nid_t nid, int pin_type,
  6210. int dac_idx)
  6211. {
  6212. /* set as output */
  6213. struct alc_spec *spec = codec->spec;
  6214. int idx;
  6215. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6216. idx = 4;
  6217. else
  6218. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6219. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6220. pin_type);
  6221. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6222. AMP_OUT_UNMUTE);
  6223. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6224. }
  6225. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6226. {
  6227. struct alc_spec *spec = codec->spec;
  6228. int i;
  6229. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6230. for (i = 0; i <= HDA_SIDE; i++) {
  6231. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6232. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6233. if (nid)
  6234. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6235. i);
  6236. }
  6237. }
  6238. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6239. {
  6240. struct alc_spec *spec = codec->spec;
  6241. hda_nid_t pin;
  6242. pin = spec->autocfg.hp_pins[0];
  6243. if (pin) /* connect to front */
  6244. /* use dac 0 */
  6245. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6246. }
  6247. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6248. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6249. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6250. {
  6251. struct alc_spec *spec = codec->spec;
  6252. int i;
  6253. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6254. hda_nid_t nid = spec->autocfg.input_pins[i];
  6255. if (alc883_is_input_pin(nid)) {
  6256. snd_hda_codec_write(codec, nid, 0,
  6257. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6258. (i <= AUTO_PIN_FRONT_MIC ?
  6259. PIN_VREF80 : PIN_IN));
  6260. if (nid != ALC883_PIN_CD_NID)
  6261. snd_hda_codec_write(codec, nid, 0,
  6262. AC_VERB_SET_AMP_GAIN_MUTE,
  6263. AMP_OUT_MUTE);
  6264. }
  6265. }
  6266. }
  6267. /* almost identical with ALC880 parser... */
  6268. static int alc883_parse_auto_config(struct hda_codec *codec)
  6269. {
  6270. struct alc_spec *spec = codec->spec;
  6271. int err = alc880_parse_auto_config(codec);
  6272. if (err < 0)
  6273. return err;
  6274. else if (err > 0)
  6275. /* hack - override the init verbs */
  6276. spec->init_verbs[0] = alc883_auto_init_verbs;
  6277. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6278. spec->num_mixers++;
  6279. return err;
  6280. }
  6281. /* additional initialization for auto-configuration model */
  6282. static void alc883_auto_init(struct hda_codec *codec)
  6283. {
  6284. alc883_auto_init_multi_out(codec);
  6285. alc883_auto_init_hp_out(codec);
  6286. alc883_auto_init_analog_input(codec);
  6287. }
  6288. static int patch_alc883(struct hda_codec *codec)
  6289. {
  6290. struct alc_spec *spec;
  6291. int err, board_config;
  6292. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6293. if (spec == NULL)
  6294. return -ENOMEM;
  6295. codec->spec = spec;
  6296. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6297. alc883_models,
  6298. alc883_cfg_tbl);
  6299. if (board_config < 0) {
  6300. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6301. "trying auto-probe from BIOS...\n");
  6302. board_config = ALC883_AUTO;
  6303. }
  6304. if (board_config == ALC883_AUTO) {
  6305. /* automatic parse from the BIOS config */
  6306. err = alc883_parse_auto_config(codec);
  6307. if (err < 0) {
  6308. alc_free(codec);
  6309. return err;
  6310. } else if (!err) {
  6311. printk(KERN_INFO
  6312. "hda_codec: Cannot set up configuration "
  6313. "from BIOS. Using base mode...\n");
  6314. board_config = ALC883_3ST_2ch_DIG;
  6315. }
  6316. }
  6317. if (board_config != ALC883_AUTO)
  6318. setup_preset(spec, &alc883_presets[board_config]);
  6319. spec->stream_name_analog = "ALC883 Analog";
  6320. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6321. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6322. spec->stream_name_digital = "ALC883 Digital";
  6323. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6324. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6325. if (!spec->adc_nids && spec->input_mux) {
  6326. spec->adc_nids = alc883_adc_nids;
  6327. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6328. }
  6329. codec->patch_ops = alc_patch_ops;
  6330. if (board_config == ALC883_AUTO)
  6331. spec->init_hook = alc883_auto_init;
  6332. return 0;
  6333. }
  6334. /*
  6335. * ALC262 support
  6336. */
  6337. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6338. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6339. #define alc262_dac_nids alc260_dac_nids
  6340. #define alc262_adc_nids alc882_adc_nids
  6341. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6342. #define alc262_modes alc260_modes
  6343. #define alc262_capture_source alc882_capture_source
  6344. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6345. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6346. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6347. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6348. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, 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("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6352. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6353. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6354. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6355. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6356. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6357. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6358. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6359. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6360. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6361. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6362. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6363. { } /* end */
  6364. };
  6365. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6366. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6367. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6368. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6369. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6370. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6371. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6372. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6373. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6374. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6375. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6376. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6377. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6378. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6379. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6380. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6381. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6382. { } /* end */
  6383. };
  6384. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6385. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6386. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6387. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6388. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6389. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6390. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6391. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6392. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6393. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6394. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6395. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6396. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6397. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6398. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6399. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6400. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6401. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6402. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6403. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6404. { } /* end */
  6405. };
  6406. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6407. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6408. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6409. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6410. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6411. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6412. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6413. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6414. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6415. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6416. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6417. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6418. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6419. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6420. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6421. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6422. { } /* end */
  6423. };
  6424. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6425. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6426. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6427. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6428. { } /* end */
  6429. };
  6430. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6431. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6432. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6433. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6434. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6435. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6436. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6437. { } /* end */
  6438. };
  6439. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6440. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6441. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6442. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6443. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6444. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6445. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6446. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6447. { } /* end */
  6448. };
  6449. #define alc262_capture_mixer alc882_capture_mixer
  6450. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6451. /*
  6452. * generic initialization of ADC, input mixers and output mixers
  6453. */
  6454. static struct hda_verb alc262_init_verbs[] = {
  6455. /*
  6456. * Unmute ADC0-2 and set the default input to mic-in
  6457. */
  6458. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6459. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6460. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6461. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6462. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6463. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6464. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6465. * mixer widget
  6466. * Note: PASD motherboards uses the Line In 2 as the input for
  6467. * front panel mic (mic 2)
  6468. */
  6469. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6470. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6471. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6472. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6473. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6474. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6475. /*
  6476. * Set up output mixers (0x0c - 0x0e)
  6477. */
  6478. /* set vol=0 to output mixers */
  6479. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6480. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6481. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6482. /* set up input amps for analog loopback */
  6483. /* Amp Indices: DAC = 0, mixer = 1 */
  6484. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6485. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6486. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6487. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6488. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6489. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6490. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6491. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6492. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6493. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6494. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6495. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6496. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6497. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6498. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6499. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6500. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6501. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6502. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6503. /* FIXME: use matrix-type input source selection */
  6504. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6505. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6506. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6507. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6508. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6509. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6510. /* Input mixer2 */
  6511. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6512. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6513. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6514. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6515. /* Input mixer3 */
  6516. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6517. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6518. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6519. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6520. { }
  6521. };
  6522. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6523. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6524. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6525. {}
  6526. };
  6527. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6528. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6529. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6530. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6531. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6532. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6533. {}
  6534. };
  6535. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6536. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6537. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6538. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6539. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6540. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6541. };
  6542. /* mute/unmute internal speaker according to the hp jack and mute state */
  6543. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  6544. {
  6545. struct alc_spec *spec = codec->spec;
  6546. unsigned int mute;
  6547. if (force || !spec->sense_updated) {
  6548. unsigned int present;
  6549. /* need to execute and sync at first */
  6550. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6551. present = snd_hda_codec_read(codec, 0x15, 0,
  6552. AC_VERB_GET_PIN_SENSE, 0);
  6553. spec->jack_present = (present & 0x80000000) != 0;
  6554. spec->sense_updated = 1;
  6555. }
  6556. if (spec->jack_present) {
  6557. /* mute internal speaker */
  6558. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6559. 0x80, 0x80);
  6560. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6561. 0x80, 0x80);
  6562. } else {
  6563. /* unmute internal speaker if necessary */
  6564. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6565. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6566. 0x80, mute & 0x80);
  6567. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6568. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6569. 0x80, mute & 0x80);
  6570. }
  6571. }
  6572. /* unsolicited event for HP jack sensing */
  6573. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6574. unsigned int res)
  6575. {
  6576. if ((res >> 26) != ALC880_HP_EVENT)
  6577. return;
  6578. alc262_hippo_automute(codec, 1);
  6579. }
  6580. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  6581. {
  6582. struct alc_spec *spec = codec->spec;
  6583. unsigned int mute;
  6584. if (force || !spec->sense_updated) {
  6585. unsigned int present;
  6586. /* need to execute and sync at first */
  6587. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6588. present = snd_hda_codec_read(codec, 0x1b, 0,
  6589. AC_VERB_GET_PIN_SENSE, 0);
  6590. spec->jack_present = (present & 0x80000000) != 0;
  6591. spec->sense_updated = 1;
  6592. }
  6593. if (spec->jack_present) {
  6594. /* mute internal speaker */
  6595. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6596. 0x80, 0x80);
  6597. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6598. 0x80, 0x80);
  6599. } else {
  6600. /* unmute internal speaker if necessary */
  6601. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6602. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6603. 0x80, mute & 0x80);
  6604. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6605. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6606. 0x80, mute & 0x80);
  6607. }
  6608. }
  6609. /* unsolicited event for HP jack sensing */
  6610. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6611. unsigned int res)
  6612. {
  6613. if ((res >> 26) != ALC880_HP_EVENT)
  6614. return;
  6615. alc262_hippo1_automute(codec, 1);
  6616. }
  6617. /*
  6618. * fujitsu model
  6619. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6620. */
  6621. #define ALC_HP_EVENT 0x37
  6622. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6623. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6624. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6625. {}
  6626. };
  6627. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6628. .num_items = 2,
  6629. .items = {
  6630. { "Mic", 0x0 },
  6631. { "CD", 0x4 },
  6632. },
  6633. };
  6634. static struct hda_input_mux alc262_HP_capture_source = {
  6635. .num_items = 5,
  6636. .items = {
  6637. { "Mic", 0x0 },
  6638. { "Front Mic", 0x3 },
  6639. { "Line", 0x2 },
  6640. { "CD", 0x4 },
  6641. { "AUX IN", 0x6 },
  6642. },
  6643. };
  6644. /* mute/unmute internal speaker according to the hp jack and mute state */
  6645. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6646. {
  6647. struct alc_spec *spec = codec->spec;
  6648. unsigned int mute;
  6649. if (force || !spec->sense_updated) {
  6650. unsigned int present;
  6651. /* need to execute and sync at first */
  6652. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6653. present = snd_hda_codec_read(codec, 0x14, 0,
  6654. AC_VERB_GET_PIN_SENSE, 0);
  6655. spec->jack_present = (present & 0x80000000) != 0;
  6656. spec->sense_updated = 1;
  6657. }
  6658. if (spec->jack_present) {
  6659. /* mute internal speaker */
  6660. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6661. 0x80, 0x80);
  6662. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6663. 0x80, 0x80);
  6664. } else {
  6665. /* unmute internal speaker if necessary */
  6666. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6667. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6668. 0x80, mute & 0x80);
  6669. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6670. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6671. 0x80, mute & 0x80);
  6672. }
  6673. }
  6674. /* unsolicited event for HP jack sensing */
  6675. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6676. unsigned int res)
  6677. {
  6678. if ((res >> 26) != ALC_HP_EVENT)
  6679. return;
  6680. alc262_fujitsu_automute(codec, 1);
  6681. }
  6682. /* bind volumes of both NID 0x0c and 0x0d */
  6683. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6684. struct snd_ctl_elem_value *ucontrol)
  6685. {
  6686. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6687. long *valp = ucontrol->value.integer.value;
  6688. int change;
  6689. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6690. 0x7f, valp[0] & 0x7f);
  6691. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6692. 0x7f, valp[1] & 0x7f);
  6693. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6694. 0x7f, valp[0] & 0x7f);
  6695. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6696. 0x7f, valp[1] & 0x7f);
  6697. return change;
  6698. }
  6699. /* bind hp and internal speaker mute (with plug check) */
  6700. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6701. struct snd_ctl_elem_value *ucontrol)
  6702. {
  6703. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6704. long *valp = ucontrol->value.integer.value;
  6705. int change;
  6706. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6707. 0x80, valp[0] ? 0 : 0x80);
  6708. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6709. 0x80, valp[1] ? 0 : 0x80);
  6710. if (change || codec->in_resume)
  6711. alc262_fujitsu_automute(codec, codec->in_resume);
  6712. return change;
  6713. }
  6714. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6715. {
  6716. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6717. .name = "Master Playback Volume",
  6718. .info = snd_hda_mixer_amp_volume_info,
  6719. .get = snd_hda_mixer_amp_volume_get,
  6720. .put = alc262_fujitsu_master_vol_put,
  6721. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6722. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6723. },
  6724. {
  6725. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6726. .name = "Master Playback Switch",
  6727. .info = snd_hda_mixer_amp_switch_info,
  6728. .get = snd_hda_mixer_amp_switch_get,
  6729. .put = alc262_fujitsu_master_sw_put,
  6730. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6731. },
  6732. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6733. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6734. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6735. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6736. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6737. { } /* end */
  6738. };
  6739. /* additional init verbs for Benq laptops */
  6740. static struct hda_verb alc262_EAPD_verbs[] = {
  6741. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6742. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6743. {}
  6744. };
  6745. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  6746. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6747. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6748. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6749. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6750. {}
  6751. };
  6752. /* add playback controls from the parsed DAC table */
  6753. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6754. const struct auto_pin_cfg *cfg)
  6755. {
  6756. hda_nid_t nid;
  6757. int err;
  6758. spec->multiout.num_dacs = 1; /* only use one dac */
  6759. spec->multiout.dac_nids = spec->private_dac_nids;
  6760. spec->multiout.dac_nids[0] = 2;
  6761. nid = cfg->line_out_pins[0];
  6762. if (nid) {
  6763. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6764. "Front Playback Volume",
  6765. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6766. if (err < 0)
  6767. return err;
  6768. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6769. "Front Playback Switch",
  6770. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6771. if (err < 0)
  6772. return err;
  6773. }
  6774. nid = cfg->speaker_pins[0];
  6775. if (nid) {
  6776. if (nid == 0x16) {
  6777. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6778. "Speaker Playback Volume",
  6779. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6780. HDA_OUTPUT));
  6781. if (err < 0)
  6782. return err;
  6783. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6784. "Speaker Playback Switch",
  6785. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6786. HDA_OUTPUT));
  6787. if (err < 0)
  6788. return err;
  6789. } else {
  6790. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6791. "Speaker Playback Switch",
  6792. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6793. HDA_OUTPUT));
  6794. if (err < 0)
  6795. return err;
  6796. }
  6797. }
  6798. nid = cfg->hp_pins[0];
  6799. if (nid) {
  6800. /* spec->multiout.hp_nid = 2; */
  6801. if (nid == 0x16) {
  6802. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6803. "Headphone Playback Volume",
  6804. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6805. HDA_OUTPUT));
  6806. if (err < 0)
  6807. return err;
  6808. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6809. "Headphone Playback Switch",
  6810. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6811. HDA_OUTPUT));
  6812. if (err < 0)
  6813. return err;
  6814. } else {
  6815. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6816. "Headphone Playback Switch",
  6817. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6818. HDA_OUTPUT));
  6819. if (err < 0)
  6820. return err;
  6821. }
  6822. }
  6823. return 0;
  6824. }
  6825. /* identical with ALC880 */
  6826. #define alc262_auto_create_analog_input_ctls \
  6827. alc880_auto_create_analog_input_ctls
  6828. /*
  6829. * generic initialization of ADC, input mixers and output mixers
  6830. */
  6831. static struct hda_verb alc262_volume_init_verbs[] = {
  6832. /*
  6833. * Unmute ADC0-2 and set the default input to mic-in
  6834. */
  6835. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6836. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6837. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6838. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6839. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6840. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6841. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6842. * mixer widget
  6843. * Note: PASD motherboards uses the Line In 2 as the input for
  6844. * front panel mic (mic 2)
  6845. */
  6846. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6847. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6848. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6849. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6850. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6851. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6852. /*
  6853. * Set up output mixers (0x0c - 0x0f)
  6854. */
  6855. /* set vol=0 to output mixers */
  6856. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6857. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6858. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6859. /* set up input amps for analog loopback */
  6860. /* Amp Indices: DAC = 0, mixer = 1 */
  6861. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6862. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6863. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6864. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6865. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6866. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6867. /* FIXME: use matrix-type input source selection */
  6868. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6869. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6870. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6871. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6872. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6873. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6874. /* Input mixer2 */
  6875. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6876. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6877. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6878. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6879. /* Input mixer3 */
  6880. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6881. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6882. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6883. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6884. { }
  6885. };
  6886. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6887. /*
  6888. * Unmute ADC0-2 and set the default input to mic-in
  6889. */
  6890. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6891. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6892. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6893. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6894. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6895. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6896. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6897. * mixer widget
  6898. * Note: PASD motherboards uses the Line In 2 as the input for
  6899. * front panel mic (mic 2)
  6900. */
  6901. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6902. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6903. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6904. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6905. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6906. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6907. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6908. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6909. /*
  6910. * Set up output mixers (0x0c - 0x0e)
  6911. */
  6912. /* set vol=0 to output mixers */
  6913. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6914. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6915. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6916. /* set up input amps for analog loopback */
  6917. /* Amp Indices: DAC = 0, mixer = 1 */
  6918. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6919. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6920. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6921. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6922. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6923. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6924. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6925. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6926. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6927. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6928. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6929. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6930. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6931. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6932. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6933. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6934. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6935. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6936. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6937. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6938. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6939. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6940. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6941. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6942. /* FIXME: use matrix-type input source selection */
  6943. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6944. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6945. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6946. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6947. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6948. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6949. /* Input mixer2 */
  6950. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6951. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6952. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6953. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6954. /* Input mixer3 */
  6955. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6956. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6957. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6958. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6959. { }
  6960. };
  6961. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6962. /*
  6963. * Unmute ADC0-2 and set the default input to mic-in
  6964. */
  6965. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6966. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6967. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6968. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6969. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6970. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6971. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6972. * mixer widget
  6973. * Note: PASD motherboards uses the Line In 2 as the input for front
  6974. * panel mic (mic 2)
  6975. */
  6976. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6977. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6978. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6979. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6980. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6981. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6982. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6983. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6984. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6985. /*
  6986. * Set up output mixers (0x0c - 0x0e)
  6987. */
  6988. /* set vol=0 to output mixers */
  6989. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6990. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6991. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6992. /* set up input amps for analog loopback */
  6993. /* Amp Indices: DAC = 0, mixer = 1 */
  6994. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6995. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6996. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6997. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6998. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6999. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7000. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7001. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7002. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7003. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7004. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7005. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7006. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7007. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7008. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7009. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7010. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7011. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7012. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7013. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7014. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7015. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7016. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7017. /* FIXME: use matrix-type input source selection */
  7018. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7019. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7020. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7021. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7022. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7023. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7024. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7025. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7026. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7027. /* Input mixer2 */
  7028. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7029. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7030. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7031. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7032. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7033. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7034. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7035. /* Input mixer3 */
  7036. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7037. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7038. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7039. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7040. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7041. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7042. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7043. { }
  7044. };
  7045. /* pcm configuration: identiacal with ALC880 */
  7046. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7047. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7048. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7049. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7050. /*
  7051. * BIOS auto configuration
  7052. */
  7053. static int alc262_parse_auto_config(struct hda_codec *codec)
  7054. {
  7055. struct alc_spec *spec = codec->spec;
  7056. int err;
  7057. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7058. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7059. alc262_ignore);
  7060. if (err < 0)
  7061. return err;
  7062. if (!spec->autocfg.line_outs)
  7063. return 0; /* can't find valid BIOS pin config */
  7064. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7065. if (err < 0)
  7066. return err;
  7067. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7068. if (err < 0)
  7069. return err;
  7070. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7071. if (spec->autocfg.dig_out_pin)
  7072. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7073. if (spec->autocfg.dig_in_pin)
  7074. spec->dig_in_nid = ALC262_DIGIN_NID;
  7075. if (spec->kctl_alloc)
  7076. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7077. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7078. spec->num_mux_defs = 1;
  7079. spec->input_mux = &spec->private_imux;
  7080. return 1;
  7081. }
  7082. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7083. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7084. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7085. /* init callback for auto-configuration model -- overriding the default init */
  7086. static void alc262_auto_init(struct hda_codec *codec)
  7087. {
  7088. alc262_auto_init_multi_out(codec);
  7089. alc262_auto_init_hp_out(codec);
  7090. alc262_auto_init_analog_input(codec);
  7091. }
  7092. /*
  7093. * configuration and preset
  7094. */
  7095. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7096. [ALC262_BASIC] = "basic",
  7097. [ALC262_HIPPO] = "hippo",
  7098. [ALC262_HIPPO_1] = "hippo_1",
  7099. [ALC262_FUJITSU] = "fujitsu",
  7100. [ALC262_HP_BPC] = "hp-bpc",
  7101. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7102. [ALC262_BENQ_ED8] = "benq",
  7103. [ALC262_BENQ_T31] = "benq-t31",
  7104. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7105. [ALC262_AUTO] = "auto",
  7106. };
  7107. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7108. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7109. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7110. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7111. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7112. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7113. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7114. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7115. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7116. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7117. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7118. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7119. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7120. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7121. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7122. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7123. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7124. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7125. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7126. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7127. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7128. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7129. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7130. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7131. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7132. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7133. {}
  7134. };
  7135. static struct alc_config_preset alc262_presets[] = {
  7136. [ALC262_BASIC] = {
  7137. .mixers = { alc262_base_mixer },
  7138. .init_verbs = { alc262_init_verbs },
  7139. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7140. .dac_nids = alc262_dac_nids,
  7141. .hp_nid = 0x03,
  7142. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7143. .channel_mode = alc262_modes,
  7144. .input_mux = &alc262_capture_source,
  7145. },
  7146. [ALC262_HIPPO] = {
  7147. .mixers = { alc262_base_mixer },
  7148. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7149. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7150. .dac_nids = alc262_dac_nids,
  7151. .hp_nid = 0x03,
  7152. .dig_out_nid = ALC262_DIGOUT_NID,
  7153. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7154. .channel_mode = alc262_modes,
  7155. .input_mux = &alc262_capture_source,
  7156. .unsol_event = alc262_hippo_unsol_event,
  7157. },
  7158. [ALC262_HIPPO_1] = {
  7159. .mixers = { alc262_hippo1_mixer },
  7160. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7161. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7162. .dac_nids = alc262_dac_nids,
  7163. .hp_nid = 0x02,
  7164. .dig_out_nid = ALC262_DIGOUT_NID,
  7165. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7166. .channel_mode = alc262_modes,
  7167. .input_mux = &alc262_capture_source,
  7168. .unsol_event = alc262_hippo1_unsol_event,
  7169. },
  7170. [ALC262_FUJITSU] = {
  7171. .mixers = { alc262_fujitsu_mixer },
  7172. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7173. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7174. .dac_nids = alc262_dac_nids,
  7175. .hp_nid = 0x03,
  7176. .dig_out_nid = ALC262_DIGOUT_NID,
  7177. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7178. .channel_mode = alc262_modes,
  7179. .input_mux = &alc262_fujitsu_capture_source,
  7180. .unsol_event = alc262_fujitsu_unsol_event,
  7181. },
  7182. [ALC262_HP_BPC] = {
  7183. .mixers = { alc262_HP_BPC_mixer },
  7184. .init_verbs = { alc262_HP_BPC_init_verbs },
  7185. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7186. .dac_nids = alc262_dac_nids,
  7187. .hp_nid = 0x03,
  7188. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7189. .channel_mode = alc262_modes,
  7190. .input_mux = &alc262_HP_capture_source,
  7191. },
  7192. [ALC262_HP_BPC_D7000_WF] = {
  7193. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7194. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7195. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7196. .dac_nids = alc262_dac_nids,
  7197. .hp_nid = 0x03,
  7198. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7199. .channel_mode = alc262_modes,
  7200. .input_mux = &alc262_HP_capture_source,
  7201. },
  7202. [ALC262_HP_BPC_D7000_WL] = {
  7203. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7204. alc262_HP_BPC_WildWest_option_mixer },
  7205. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7206. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7207. .dac_nids = alc262_dac_nids,
  7208. .hp_nid = 0x03,
  7209. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7210. .channel_mode = alc262_modes,
  7211. .input_mux = &alc262_HP_capture_source,
  7212. },
  7213. [ALC262_BENQ_ED8] = {
  7214. .mixers = { alc262_base_mixer },
  7215. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7216. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7217. .dac_nids = alc262_dac_nids,
  7218. .hp_nid = 0x03,
  7219. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7220. .channel_mode = alc262_modes,
  7221. .input_mux = &alc262_capture_source,
  7222. },
  7223. [ALC262_SONY_ASSAMD] = {
  7224. .mixers = { alc262_sony_mixer },
  7225. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7226. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7227. .dac_nids = alc262_dac_nids,
  7228. .hp_nid = 0x02,
  7229. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7230. .channel_mode = alc262_modes,
  7231. .input_mux = &alc262_capture_source,
  7232. .unsol_event = alc262_hippo_unsol_event,
  7233. },
  7234. [ALC262_BENQ_T31] = {
  7235. .mixers = { alc262_benq_t31_mixer },
  7236. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7237. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7238. .dac_nids = alc262_dac_nids,
  7239. .hp_nid = 0x03,
  7240. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7241. .channel_mode = alc262_modes,
  7242. .input_mux = &alc262_capture_source,
  7243. .unsol_event = alc262_hippo_unsol_event,
  7244. },
  7245. };
  7246. static int patch_alc262(struct hda_codec *codec)
  7247. {
  7248. struct alc_spec *spec;
  7249. int board_config;
  7250. int err;
  7251. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7252. if (spec == NULL)
  7253. return -ENOMEM;
  7254. codec->spec = spec;
  7255. #if 0
  7256. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7257. * under-run
  7258. */
  7259. {
  7260. int tmp;
  7261. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7262. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7263. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7264. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7265. }
  7266. #endif
  7267. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7268. alc262_models,
  7269. alc262_cfg_tbl);
  7270. if (board_config < 0) {
  7271. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7272. "trying auto-probe from BIOS...\n");
  7273. board_config = ALC262_AUTO;
  7274. }
  7275. if (board_config == ALC262_AUTO) {
  7276. /* automatic parse from the BIOS config */
  7277. err = alc262_parse_auto_config(codec);
  7278. if (err < 0) {
  7279. alc_free(codec);
  7280. return err;
  7281. } else if (!err) {
  7282. printk(KERN_INFO
  7283. "hda_codec: Cannot set up configuration "
  7284. "from BIOS. Using base mode...\n");
  7285. board_config = ALC262_BASIC;
  7286. }
  7287. }
  7288. if (board_config != ALC262_AUTO)
  7289. setup_preset(spec, &alc262_presets[board_config]);
  7290. spec->stream_name_analog = "ALC262 Analog";
  7291. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7292. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7293. spec->stream_name_digital = "ALC262 Digital";
  7294. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7295. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7296. if (!spec->adc_nids && spec->input_mux) {
  7297. /* check whether NID 0x07 is valid */
  7298. unsigned int wcap = get_wcaps(codec, 0x07);
  7299. /* get type */
  7300. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7301. if (wcap != AC_WID_AUD_IN) {
  7302. spec->adc_nids = alc262_adc_nids_alt;
  7303. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7304. spec->mixers[spec->num_mixers] =
  7305. alc262_capture_alt_mixer;
  7306. spec->num_mixers++;
  7307. } else {
  7308. spec->adc_nids = alc262_adc_nids;
  7309. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7310. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7311. spec->num_mixers++;
  7312. }
  7313. }
  7314. codec->patch_ops = alc_patch_ops;
  7315. if (board_config == ALC262_AUTO)
  7316. spec->init_hook = alc262_auto_init;
  7317. return 0;
  7318. }
  7319. /*
  7320. * ALC268 channel source setting (2 channel)
  7321. */
  7322. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7323. #define alc268_modes alc260_modes
  7324. static hda_nid_t alc268_dac_nids[2] = {
  7325. /* front, hp */
  7326. 0x02, 0x03
  7327. };
  7328. static hda_nid_t alc268_adc_nids[2] = {
  7329. /* ADC0-1 */
  7330. 0x08, 0x07
  7331. };
  7332. static hda_nid_t alc268_adc_nids_alt[1] = {
  7333. /* ADC0 */
  7334. 0x08
  7335. };
  7336. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7337. /* output mixer control */
  7338. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7339. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7340. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7341. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7342. { }
  7343. };
  7344. /*
  7345. * generic initialization of ADC, input mixers and output mixers
  7346. */
  7347. static struct hda_verb alc268_base_init_verbs[] = {
  7348. /* Unmute DAC0-1 and set vol = 0 */
  7349. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7350. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7351. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7352. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7353. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7354. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7355. /*
  7356. * Set up output mixers (0x0c - 0x0e)
  7357. */
  7358. /* set vol=0 to output mixers */
  7359. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7360. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7361. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7362. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7363. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7364. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7365. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7366. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7367. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7368. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7369. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7370. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7371. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7372. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7373. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7374. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7375. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7376. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7377. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7378. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7379. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7380. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7381. /* FIXME: use matrix-type input source selection */
  7382. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7383. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7384. /* Input mixer2 */
  7385. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7386. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7387. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7388. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7389. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7390. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7391. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7392. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7393. { }
  7394. };
  7395. /*
  7396. * generic initialization of ADC, input mixers and output mixers
  7397. */
  7398. static struct hda_verb alc268_volume_init_verbs[] = {
  7399. /* set output DAC */
  7400. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7401. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7402. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7403. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7404. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7405. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7406. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7407. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7408. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7409. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7410. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7411. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7412. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7413. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7414. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7415. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7416. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7417. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7418. /* set PCBEEP vol = 0 */
  7419. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7420. { }
  7421. };
  7422. #define alc268_mux_enum_info alc_mux_enum_info
  7423. #define alc268_mux_enum_get alc_mux_enum_get
  7424. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7425. struct snd_ctl_elem_value *ucontrol)
  7426. {
  7427. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7428. struct alc_spec *spec = codec->spec;
  7429. const struct hda_input_mux *imux = spec->input_mux;
  7430. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7431. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7432. hda_nid_t nid = capture_mixers[adc_idx];
  7433. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7434. unsigned int i, idx;
  7435. idx = ucontrol->value.enumerated.item[0];
  7436. if (idx >= imux->num_items)
  7437. idx = imux->num_items - 1;
  7438. if (*cur_val == idx && !codec->in_resume)
  7439. return 0;
  7440. for (i = 0; i < imux->num_items; i++) {
  7441. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7442. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7443. v | (imux->items[i].index << 8));
  7444. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
  7445. idx );
  7446. }
  7447. *cur_val = idx;
  7448. return 1;
  7449. }
  7450. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7451. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7452. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7453. {
  7454. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7455. /* The multiple "Capture Source" controls confuse alsamixer
  7456. * So call somewhat different..
  7457. * FIXME: the controls appear in the "playback" view!
  7458. */
  7459. /* .name = "Capture Source", */
  7460. .name = "Input Source",
  7461. .count = 1,
  7462. .info = alc268_mux_enum_info,
  7463. .get = alc268_mux_enum_get,
  7464. .put = alc268_mux_enum_put,
  7465. },
  7466. { } /* end */
  7467. };
  7468. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7469. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7470. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7471. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7472. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7473. {
  7474. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7475. /* The multiple "Capture Source" controls confuse alsamixer
  7476. * So call somewhat different..
  7477. * FIXME: the controls appear in the "playback" view!
  7478. */
  7479. /* .name = "Capture Source", */
  7480. .name = "Input Source",
  7481. .count = 2,
  7482. .info = alc268_mux_enum_info,
  7483. .get = alc268_mux_enum_get,
  7484. .put = alc268_mux_enum_put,
  7485. },
  7486. { } /* end */
  7487. };
  7488. static struct hda_input_mux alc268_capture_source = {
  7489. .num_items = 4,
  7490. .items = {
  7491. { "Mic", 0x0 },
  7492. { "Front Mic", 0x1 },
  7493. { "Line", 0x2 },
  7494. { "CD", 0x3 },
  7495. },
  7496. };
  7497. /* create input playback/capture controls for the given pin */
  7498. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7499. const char *ctlname, int idx)
  7500. {
  7501. char name[32];
  7502. int err;
  7503. sprintf(name, "%s Playback Volume", ctlname);
  7504. if (nid == 0x14) {
  7505. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7506. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7507. HDA_OUTPUT));
  7508. if (err < 0)
  7509. return err;
  7510. } else if (nid == 0x15) {
  7511. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7512. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7513. HDA_OUTPUT));
  7514. if (err < 0)
  7515. return err;
  7516. } else
  7517. return -1;
  7518. sprintf(name, "%s Playback Switch", ctlname);
  7519. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7520. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7521. if (err < 0)
  7522. return err;
  7523. return 0;
  7524. }
  7525. /* add playback controls from the parsed DAC table */
  7526. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7527. const struct auto_pin_cfg *cfg)
  7528. {
  7529. hda_nid_t nid;
  7530. int err;
  7531. spec->multiout.num_dacs = 2; /* only use one dac */
  7532. spec->multiout.dac_nids = spec->private_dac_nids;
  7533. spec->multiout.dac_nids[0] = 2;
  7534. spec->multiout.dac_nids[1] = 3;
  7535. nid = cfg->line_out_pins[0];
  7536. if (nid)
  7537. alc268_new_analog_output(spec, nid, "Front", 0);
  7538. nid = cfg->speaker_pins[0];
  7539. if (nid == 0x1d) {
  7540. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7541. "Speaker Playback Volume",
  7542. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7543. if (err < 0)
  7544. return err;
  7545. }
  7546. nid = cfg->hp_pins[0];
  7547. if (nid)
  7548. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7549. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7550. if (nid == 0x16) {
  7551. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7552. "Mono Playback Switch",
  7553. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7554. if (err < 0)
  7555. return err;
  7556. }
  7557. return 0;
  7558. }
  7559. /* create playback/capture controls for input pins */
  7560. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7561. const struct auto_pin_cfg *cfg)
  7562. {
  7563. struct hda_input_mux *imux = &spec->private_imux;
  7564. int i, idx1;
  7565. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7566. switch(cfg->input_pins[i]) {
  7567. case 0x18:
  7568. idx1 = 0; /* Mic 1 */
  7569. break;
  7570. case 0x19:
  7571. idx1 = 1; /* Mic 2 */
  7572. break;
  7573. case 0x1a:
  7574. idx1 = 2; /* Line In */
  7575. break;
  7576. case 0x1c:
  7577. idx1 = 3; /* CD */
  7578. break;
  7579. default:
  7580. continue;
  7581. }
  7582. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7583. imux->items[imux->num_items].index = idx1;
  7584. imux->num_items++;
  7585. }
  7586. return 0;
  7587. }
  7588. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7589. {
  7590. struct alc_spec *spec = codec->spec;
  7591. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7592. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7593. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7594. unsigned int dac_vol1, dac_vol2;
  7595. if (speaker_nid) {
  7596. snd_hda_codec_write(codec, speaker_nid, 0,
  7597. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7598. snd_hda_codec_write(codec, 0x0f, 0,
  7599. AC_VERB_SET_AMP_GAIN_MUTE,
  7600. AMP_IN_UNMUTE(1));
  7601. snd_hda_codec_write(codec, 0x10, 0,
  7602. AC_VERB_SET_AMP_GAIN_MUTE,
  7603. AMP_IN_UNMUTE(1));
  7604. } else {
  7605. snd_hda_codec_write(codec, 0x0f, 0,
  7606. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7607. snd_hda_codec_write(codec, 0x10, 0,
  7608. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7609. }
  7610. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7611. if (line_nid == 0x14)
  7612. dac_vol2 = AMP_OUT_ZERO;
  7613. else if (line_nid == 0x15)
  7614. dac_vol1 = AMP_OUT_ZERO;
  7615. if (hp_nid == 0x14)
  7616. dac_vol2 = AMP_OUT_ZERO;
  7617. else if (hp_nid == 0x15)
  7618. dac_vol1 = AMP_OUT_ZERO;
  7619. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7620. spec->autocfg.line_out_pins[1] != 0x16 ||
  7621. spec->autocfg.line_out_pins[2] != 0x16)
  7622. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7623. snd_hda_codec_write(codec, 0x02, 0,
  7624. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7625. snd_hda_codec_write(codec, 0x03, 0,
  7626. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7627. }
  7628. /* pcm configuration: identiacal with ALC880 */
  7629. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7630. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7631. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7632. /*
  7633. * BIOS auto configuration
  7634. */
  7635. static int alc268_parse_auto_config(struct hda_codec *codec)
  7636. {
  7637. struct alc_spec *spec = codec->spec;
  7638. int err;
  7639. static hda_nid_t alc268_ignore[] = { 0 };
  7640. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7641. alc268_ignore);
  7642. if (err < 0)
  7643. return err;
  7644. if (!spec->autocfg.line_outs)
  7645. return 0; /* can't find valid BIOS pin config */
  7646. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7647. if (err < 0)
  7648. return err;
  7649. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7650. if (err < 0)
  7651. return err;
  7652. spec->multiout.max_channels = 2;
  7653. /* digital only support output */
  7654. if (spec->autocfg.dig_out_pin)
  7655. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7656. if (spec->kctl_alloc)
  7657. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7658. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7659. spec->num_mux_defs = 1;
  7660. spec->input_mux = &spec->private_imux;
  7661. return 1;
  7662. }
  7663. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7664. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7665. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7666. /* init callback for auto-configuration model -- overriding the default init */
  7667. static void alc268_auto_init(struct hda_codec *codec)
  7668. {
  7669. alc268_auto_init_multi_out(codec);
  7670. alc268_auto_init_hp_out(codec);
  7671. alc268_auto_init_mono_speaker_out(codec);
  7672. alc268_auto_init_analog_input(codec);
  7673. }
  7674. /*
  7675. * configuration and preset
  7676. */
  7677. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7678. [ALC268_3ST] = "3stack",
  7679. [ALC268_AUTO] = "auto",
  7680. };
  7681. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7682. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7683. {}
  7684. };
  7685. static struct alc_config_preset alc268_presets[] = {
  7686. [ALC268_3ST] = {
  7687. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7688. .init_verbs = { alc268_base_init_verbs },
  7689. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7690. .dac_nids = alc268_dac_nids,
  7691. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7692. .adc_nids = alc268_adc_nids_alt,
  7693. .hp_nid = 0x03,
  7694. .dig_out_nid = ALC268_DIGOUT_NID,
  7695. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7696. .channel_mode = alc268_modes,
  7697. .input_mux = &alc268_capture_source,
  7698. },
  7699. };
  7700. static int patch_alc268(struct hda_codec *codec)
  7701. {
  7702. struct alc_spec *spec;
  7703. int board_config;
  7704. int err;
  7705. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7706. if (spec == NULL)
  7707. return -ENOMEM;
  7708. codec->spec = spec;
  7709. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7710. alc268_models,
  7711. alc268_cfg_tbl);
  7712. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7713. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7714. "trying auto-probe from BIOS...\n");
  7715. board_config = ALC268_AUTO;
  7716. }
  7717. if (board_config == ALC268_AUTO) {
  7718. /* automatic parse from the BIOS config */
  7719. err = alc268_parse_auto_config(codec);
  7720. if (err < 0) {
  7721. alc_free(codec);
  7722. return err;
  7723. } else if (!err) {
  7724. printk(KERN_INFO
  7725. "hda_codec: Cannot set up configuration "
  7726. "from BIOS. Using base mode...\n");
  7727. board_config = ALC268_3ST;
  7728. }
  7729. }
  7730. if (board_config != ALC268_AUTO)
  7731. setup_preset(spec, &alc268_presets[board_config]);
  7732. spec->stream_name_analog = "ALC268 Analog";
  7733. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7734. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7735. spec->stream_name_digital = "ALC268 Digital";
  7736. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7737. if (board_config == ALC268_AUTO) {
  7738. if (!spec->adc_nids && spec->input_mux) {
  7739. /* check whether NID 0x07 is valid */
  7740. unsigned int wcap = get_wcaps(codec, 0x07);
  7741. /* get type */
  7742. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7743. if (wcap != AC_WID_AUD_IN) {
  7744. spec->adc_nids = alc268_adc_nids_alt;
  7745. spec->num_adc_nids =
  7746. ARRAY_SIZE(alc268_adc_nids_alt);
  7747. spec->mixers[spec->num_mixers] =
  7748. alc268_capture_alt_mixer;
  7749. spec->num_mixers++;
  7750. } else {
  7751. spec->adc_nids = alc268_adc_nids;
  7752. spec->num_adc_nids =
  7753. ARRAY_SIZE(alc268_adc_nids);
  7754. spec->mixers[spec->num_mixers] =
  7755. alc268_capture_mixer;
  7756. spec->num_mixers++;
  7757. }
  7758. }
  7759. }
  7760. codec->patch_ops = alc_patch_ops;
  7761. if (board_config == ALC268_AUTO)
  7762. spec->init_hook = alc268_auto_init;
  7763. return 0;
  7764. }
  7765. /*
  7766. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7767. */
  7768. /*
  7769. * set the path ways for 2 channel output
  7770. * need to set the codec line out and mic 1 pin widgets to inputs
  7771. */
  7772. static struct hda_verb alc861_threestack_ch2_init[] = {
  7773. /* set pin widget 1Ah (line in) for input */
  7774. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7775. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7776. * the vref
  7777. */
  7778. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7779. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7780. #if 0
  7781. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7782. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7783. #endif
  7784. { } /* end */
  7785. };
  7786. /*
  7787. * 6ch mode
  7788. * need to set the codec line out and mic 1 pin widgets to outputs
  7789. */
  7790. static struct hda_verb alc861_threestack_ch6_init[] = {
  7791. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7792. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7793. /* set pin widget 18h (mic1) for output (CLFE)*/
  7794. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7795. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7796. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7797. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7798. #if 0
  7799. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7800. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7801. #endif
  7802. { } /* end */
  7803. };
  7804. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7805. { 2, alc861_threestack_ch2_init },
  7806. { 6, alc861_threestack_ch6_init },
  7807. };
  7808. /* Set mic1 as input and unmute the mixer */
  7809. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7810. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7811. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7812. { } /* end */
  7813. };
  7814. /* Set mic1 as output and mute mixer */
  7815. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7816. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7817. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7818. { } /* end */
  7819. };
  7820. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7821. { 2, alc861_uniwill_m31_ch2_init },
  7822. { 4, alc861_uniwill_m31_ch4_init },
  7823. };
  7824. /* Set mic1 and line-in as input and unmute the mixer */
  7825. static struct hda_verb alc861_asus_ch2_init[] = {
  7826. /* set pin widget 1Ah (line in) for input */
  7827. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7828. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7829. * the vref
  7830. */
  7831. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7832. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7833. #if 0
  7834. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7835. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7836. #endif
  7837. { } /* end */
  7838. };
  7839. /* Set mic1 nad line-in as output and mute mixer */
  7840. static struct hda_verb alc861_asus_ch6_init[] = {
  7841. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7842. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7843. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7844. /* set pin widget 18h (mic1) for output (CLFE)*/
  7845. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7846. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7847. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7848. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7849. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7850. #if 0
  7851. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7852. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7853. #endif
  7854. { } /* end */
  7855. };
  7856. static struct hda_channel_mode alc861_asus_modes[2] = {
  7857. { 2, alc861_asus_ch2_init },
  7858. { 6, alc861_asus_ch6_init },
  7859. };
  7860. /* patch-ALC861 */
  7861. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7862. /* output mixer control */
  7863. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7864. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7865. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7866. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7867. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7868. /*Input mixer control */
  7869. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7870. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7871. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7872. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7873. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7874. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7875. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7876. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7877. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7878. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7879. /* Capture mixer control */
  7880. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7881. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7882. {
  7883. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7884. .name = "Capture Source",
  7885. .count = 1,
  7886. .info = alc_mux_enum_info,
  7887. .get = alc_mux_enum_get,
  7888. .put = alc_mux_enum_put,
  7889. },
  7890. { } /* end */
  7891. };
  7892. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7893. /* output mixer control */
  7894. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7895. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7896. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7897. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7898. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7899. /* Input mixer control */
  7900. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7901. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7902. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7903. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7904. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7905. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7906. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7907. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7908. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7909. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7910. /* Capture mixer control */
  7911. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7912. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7913. {
  7914. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7915. .name = "Capture Source",
  7916. .count = 1,
  7917. .info = alc_mux_enum_info,
  7918. .get = alc_mux_enum_get,
  7919. .put = alc_mux_enum_put,
  7920. },
  7921. {
  7922. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7923. .name = "Channel Mode",
  7924. .info = alc_ch_mode_info,
  7925. .get = alc_ch_mode_get,
  7926. .put = alc_ch_mode_put,
  7927. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7928. },
  7929. { } /* end */
  7930. };
  7931. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  7932. /* output mixer control */
  7933. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7934. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7935. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7936. /*Capture mixer control */
  7937. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7938. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7939. {
  7940. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7941. .name = "Capture Source",
  7942. .count = 1,
  7943. .info = alc_mux_enum_info,
  7944. .get = alc_mux_enum_get,
  7945. .put = alc_mux_enum_put,
  7946. },
  7947. { } /* end */
  7948. };
  7949. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  7950. /* output mixer control */
  7951. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7952. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7953. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7954. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7955. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7956. /* Input mixer control */
  7957. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7958. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7959. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7960. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7961. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7962. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7963. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7964. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7965. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7966. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7967. /* Capture mixer control */
  7968. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7969. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7970. {
  7971. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7972. .name = "Capture Source",
  7973. .count = 1,
  7974. .info = alc_mux_enum_info,
  7975. .get = alc_mux_enum_get,
  7976. .put = alc_mux_enum_put,
  7977. },
  7978. {
  7979. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7980. .name = "Channel Mode",
  7981. .info = alc_ch_mode_info,
  7982. .get = alc_ch_mode_get,
  7983. .put = alc_ch_mode_put,
  7984. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7985. },
  7986. { } /* end */
  7987. };
  7988. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  7989. /* output mixer control */
  7990. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7991. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7992. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7993. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7994. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7995. /* Input mixer control */
  7996. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7997. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7998. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7999. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8000. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8001. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8002. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8003. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8004. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8005. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8006. /* Capture mixer control */
  8007. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8008. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8009. {
  8010. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8011. .name = "Capture Source",
  8012. .count = 1,
  8013. .info = alc_mux_enum_info,
  8014. .get = alc_mux_enum_get,
  8015. .put = alc_mux_enum_put,
  8016. },
  8017. {
  8018. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8019. .name = "Channel Mode",
  8020. .info = alc_ch_mode_info,
  8021. .get = alc_ch_mode_get,
  8022. .put = alc_ch_mode_put,
  8023. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8024. },
  8025. { }
  8026. };
  8027. /* additional mixer */
  8028. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8029. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8030. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8031. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8032. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8033. { }
  8034. };
  8035. /*
  8036. * generic initialization of ADC, input mixers and output mixers
  8037. */
  8038. static struct hda_verb alc861_base_init_verbs[] = {
  8039. /*
  8040. * Unmute ADC0 and set the default input to mic-in
  8041. */
  8042. /* port-A for surround (rear panel) */
  8043. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8044. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8045. /* port-B for mic-in (rear panel) with vref */
  8046. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8047. /* port-C for line-in (rear panel) */
  8048. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8049. /* port-D for Front */
  8050. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8051. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8052. /* port-E for HP out (front panel) */
  8053. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8054. /* route front PCM to HP */
  8055. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8056. /* port-F for mic-in (front panel) with vref */
  8057. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8058. /* port-G for CLFE (rear panel) */
  8059. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8060. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8061. /* port-H for side (rear panel) */
  8062. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8063. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8064. /* CD-in */
  8065. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8066. /* route front mic to ADC1*/
  8067. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8068. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8069. /* Unmute DAC0~3 & spdif out*/
  8070. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8071. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8072. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8073. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8074. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8075. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8076. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8077. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8078. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8079. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8080. /* Unmute Stereo Mixer 15 */
  8081. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8082. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8083. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8084. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8085. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8086. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8087. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8088. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8089. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8090. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8091. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8092. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8093. /* hp used DAC 3 (Front) */
  8094. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8095. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8096. { }
  8097. };
  8098. static struct hda_verb alc861_threestack_init_verbs[] = {
  8099. /*
  8100. * Unmute ADC0 and set the default input to mic-in
  8101. */
  8102. /* port-A for surround (rear panel) */
  8103. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8104. /* port-B for mic-in (rear panel) with vref */
  8105. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8106. /* port-C for line-in (rear panel) */
  8107. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8108. /* port-D for Front */
  8109. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8110. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8111. /* port-E for HP out (front panel) */
  8112. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8113. /* route front PCM to HP */
  8114. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8115. /* port-F for mic-in (front panel) with vref */
  8116. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8117. /* port-G for CLFE (rear panel) */
  8118. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8119. /* port-H for side (rear panel) */
  8120. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8121. /* CD-in */
  8122. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8123. /* route front mic to ADC1*/
  8124. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8125. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8126. /* Unmute DAC0~3 & spdif out*/
  8127. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8128. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8129. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8130. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8131. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8132. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8133. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8134. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8135. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8136. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8137. /* Unmute Stereo Mixer 15 */
  8138. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8139. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8140. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8141. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8142. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8143. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8144. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8145. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8146. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8147. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8148. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8149. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8150. /* hp used DAC 3 (Front) */
  8151. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8152. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8153. { }
  8154. };
  8155. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8156. /*
  8157. * Unmute ADC0 and set the default input to mic-in
  8158. */
  8159. /* port-A for surround (rear panel) */
  8160. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8161. /* port-B for mic-in (rear panel) with vref */
  8162. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8163. /* port-C for line-in (rear panel) */
  8164. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8165. /* port-D for Front */
  8166. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8167. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8168. /* port-E for HP out (front panel) */
  8169. /* this has to be set to VREF80 */
  8170. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8171. /* route front PCM to HP */
  8172. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8173. /* port-F for mic-in (front panel) with vref */
  8174. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8175. /* port-G for CLFE (rear panel) */
  8176. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8177. /* port-H for side (rear panel) */
  8178. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8179. /* CD-in */
  8180. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8181. /* route front mic to ADC1*/
  8182. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8183. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8184. /* Unmute DAC0~3 & spdif out*/
  8185. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8186. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8187. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8188. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8189. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8190. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8191. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8192. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8193. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8194. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8195. /* Unmute Stereo Mixer 15 */
  8196. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8197. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8198. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8199. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8200. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8201. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8202. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8203. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8204. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8205. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8206. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8207. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8208. /* hp used DAC 3 (Front) */
  8209. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8210. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8211. { }
  8212. };
  8213. static struct hda_verb alc861_asus_init_verbs[] = {
  8214. /*
  8215. * Unmute ADC0 and set the default input to mic-in
  8216. */
  8217. /* port-A for surround (rear panel)
  8218. * according to codec#0 this is the HP jack
  8219. */
  8220. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8221. /* route front PCM to HP */
  8222. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8223. /* port-B for mic-in (rear panel) with vref */
  8224. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8225. /* port-C for line-in (rear panel) */
  8226. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8227. /* port-D for Front */
  8228. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8229. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8230. /* port-E for HP out (front panel) */
  8231. /* this has to be set to VREF80 */
  8232. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8233. /* route front PCM to HP */
  8234. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8235. /* port-F for mic-in (front panel) with vref */
  8236. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8237. /* port-G for CLFE (rear panel) */
  8238. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8239. /* port-H for side (rear panel) */
  8240. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8241. /* CD-in */
  8242. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8243. /* route front mic to ADC1*/
  8244. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8245. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8246. /* Unmute DAC0~3 & spdif out*/
  8247. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8248. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8249. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8250. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8251. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8252. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8253. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8254. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8255. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8256. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8257. /* Unmute Stereo Mixer 15 */
  8258. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8259. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8260. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8261. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8262. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8263. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8264. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8265. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8266. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8267. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8268. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8269. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8270. /* hp used DAC 3 (Front) */
  8271. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8272. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8273. { }
  8274. };
  8275. /* additional init verbs for ASUS laptops */
  8276. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8277. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8278. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8279. { }
  8280. };
  8281. /*
  8282. * generic initialization of ADC, input mixers and output mixers
  8283. */
  8284. static struct hda_verb alc861_auto_init_verbs[] = {
  8285. /*
  8286. * Unmute ADC0 and set the default input to mic-in
  8287. */
  8288. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8289. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8290. /* Unmute DAC0~3 & spdif out*/
  8291. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8292. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8293. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8294. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8295. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8296. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8297. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8298. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8299. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8300. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8301. /* Unmute Stereo Mixer 15 */
  8302. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8303. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8304. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8305. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8306. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8307. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8308. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8309. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8310. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8311. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8312. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8313. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8314. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8315. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8316. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8317. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8318. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8319. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8320. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8321. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8322. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8323. { }
  8324. };
  8325. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8326. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8327. { }
  8328. };
  8329. /* toggle speaker-output according to the hp-jack state */
  8330. static void alc861_toshiba_automute(struct hda_codec *codec)
  8331. {
  8332. unsigned int present;
  8333. present = snd_hda_codec_read(codec, 0x0f, 0,
  8334. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8335. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  8336. 0x80, present ? 0x80 : 0);
  8337. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  8338. 0x80, present ? 0x80 : 0);
  8339. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  8340. 0x80, present ? 0 : 0x80);
  8341. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  8342. 0x80, present ? 0 : 0x80);
  8343. }
  8344. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8345. unsigned int res)
  8346. {
  8347. if ((res >> 26) == ALC880_HP_EVENT)
  8348. alc861_toshiba_automute(codec);
  8349. }
  8350. /* pcm configuration: identiacal with ALC880 */
  8351. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8352. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8353. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8354. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8355. #define ALC861_DIGOUT_NID 0x07
  8356. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8357. { 8, NULL }
  8358. };
  8359. static hda_nid_t alc861_dac_nids[4] = {
  8360. /* front, surround, clfe, side */
  8361. 0x03, 0x06, 0x05, 0x04
  8362. };
  8363. static hda_nid_t alc660_dac_nids[3] = {
  8364. /* front, clfe, surround */
  8365. 0x03, 0x05, 0x06
  8366. };
  8367. static hda_nid_t alc861_adc_nids[1] = {
  8368. /* ADC0-2 */
  8369. 0x08,
  8370. };
  8371. static struct hda_input_mux alc861_capture_source = {
  8372. .num_items = 5,
  8373. .items = {
  8374. { "Mic", 0x0 },
  8375. { "Front Mic", 0x3 },
  8376. { "Line", 0x1 },
  8377. { "CD", 0x4 },
  8378. { "Mixer", 0x5 },
  8379. },
  8380. };
  8381. /* fill in the dac_nids table from the parsed pin configuration */
  8382. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8383. const struct auto_pin_cfg *cfg)
  8384. {
  8385. int i;
  8386. hda_nid_t nid;
  8387. spec->multiout.dac_nids = spec->private_dac_nids;
  8388. for (i = 0; i < cfg->line_outs; i++) {
  8389. nid = cfg->line_out_pins[i];
  8390. if (nid) {
  8391. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8392. continue;
  8393. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8394. }
  8395. }
  8396. spec->multiout.num_dacs = cfg->line_outs;
  8397. return 0;
  8398. }
  8399. /* add playback controls from the parsed DAC table */
  8400. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8401. const struct auto_pin_cfg *cfg)
  8402. {
  8403. char name[32];
  8404. static const char *chname[4] = {
  8405. "Front", "Surround", NULL /*CLFE*/, "Side"
  8406. };
  8407. hda_nid_t nid;
  8408. int i, idx, err;
  8409. for (i = 0; i < cfg->line_outs; i++) {
  8410. nid = spec->multiout.dac_nids[i];
  8411. if (!nid)
  8412. continue;
  8413. if (nid == 0x05) {
  8414. /* Center/LFE */
  8415. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8416. "Center Playback Switch",
  8417. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8418. HDA_OUTPUT));
  8419. if (err < 0)
  8420. return err;
  8421. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8422. "LFE Playback Switch",
  8423. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8424. HDA_OUTPUT));
  8425. if (err < 0)
  8426. return err;
  8427. } else {
  8428. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8429. idx++)
  8430. if (nid == alc861_dac_nids[idx])
  8431. break;
  8432. sprintf(name, "%s Playback Switch", chname[idx]);
  8433. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8434. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8435. HDA_OUTPUT));
  8436. if (err < 0)
  8437. return err;
  8438. }
  8439. }
  8440. return 0;
  8441. }
  8442. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8443. {
  8444. int err;
  8445. hda_nid_t nid;
  8446. if (!pin)
  8447. return 0;
  8448. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8449. nid = 0x03;
  8450. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8451. "Headphone Playback Switch",
  8452. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8453. if (err < 0)
  8454. return err;
  8455. spec->multiout.hp_nid = nid;
  8456. }
  8457. return 0;
  8458. }
  8459. /* create playback/capture controls for input pins */
  8460. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8461. const struct auto_pin_cfg *cfg)
  8462. {
  8463. struct hda_input_mux *imux = &spec->private_imux;
  8464. int i, err, idx, idx1;
  8465. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8466. switch (cfg->input_pins[i]) {
  8467. case 0x0c:
  8468. idx1 = 1;
  8469. idx = 2; /* Line In */
  8470. break;
  8471. case 0x0f:
  8472. idx1 = 2;
  8473. idx = 2; /* Line In */
  8474. break;
  8475. case 0x0d:
  8476. idx1 = 0;
  8477. idx = 1; /* Mic In */
  8478. break;
  8479. case 0x10:
  8480. idx1 = 3;
  8481. idx = 1; /* Mic In */
  8482. break;
  8483. case 0x11:
  8484. idx1 = 4;
  8485. idx = 0; /* CD */
  8486. break;
  8487. default:
  8488. continue;
  8489. }
  8490. err = new_analog_input(spec, cfg->input_pins[i],
  8491. auto_pin_cfg_labels[i], idx, 0x15);
  8492. if (err < 0)
  8493. return err;
  8494. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8495. imux->items[imux->num_items].index = idx1;
  8496. imux->num_items++;
  8497. }
  8498. return 0;
  8499. }
  8500. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8501. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8502. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8503. {
  8504. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8505. /* The multiple "Capture Source" controls confuse alsamixer
  8506. * So call somewhat different..
  8507. *FIXME: the controls appear in the "playback" view!
  8508. */
  8509. /* .name = "Capture Source", */
  8510. .name = "Input Source",
  8511. .count = 1,
  8512. .info = alc_mux_enum_info,
  8513. .get = alc_mux_enum_get,
  8514. .put = alc_mux_enum_put,
  8515. },
  8516. { } /* end */
  8517. };
  8518. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8519. hda_nid_t nid,
  8520. int pin_type, int dac_idx)
  8521. {
  8522. /* set as output */
  8523. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8524. pin_type);
  8525. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8526. AMP_OUT_UNMUTE);
  8527. }
  8528. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8529. {
  8530. struct alc_spec *spec = codec->spec;
  8531. int i;
  8532. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8533. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8534. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8535. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8536. if (nid)
  8537. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8538. spec->multiout.dac_nids[i]);
  8539. }
  8540. }
  8541. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8542. {
  8543. struct alc_spec *spec = codec->spec;
  8544. hda_nid_t pin;
  8545. pin = spec->autocfg.hp_pins[0];
  8546. if (pin) /* connect to front */
  8547. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8548. spec->multiout.dac_nids[0]);
  8549. }
  8550. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8551. {
  8552. struct alc_spec *spec = codec->spec;
  8553. int i;
  8554. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8555. hda_nid_t nid = spec->autocfg.input_pins[i];
  8556. if (nid >= 0x0c && nid <= 0x11) {
  8557. snd_hda_codec_write(codec, nid, 0,
  8558. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8559. i <= AUTO_PIN_FRONT_MIC ?
  8560. PIN_VREF80 : PIN_IN);
  8561. }
  8562. }
  8563. }
  8564. /* parse the BIOS configuration and set up the alc_spec */
  8565. /* return 1 if successful, 0 if the proper config is not found,
  8566. * or a negative error code
  8567. */
  8568. static int alc861_parse_auto_config(struct hda_codec *codec)
  8569. {
  8570. struct alc_spec *spec = codec->spec;
  8571. int err;
  8572. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8573. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8574. alc861_ignore);
  8575. if (err < 0)
  8576. return err;
  8577. if (!spec->autocfg.line_outs)
  8578. return 0; /* can't find valid BIOS pin config */
  8579. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8580. if (err < 0)
  8581. return err;
  8582. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8583. if (err < 0)
  8584. return err;
  8585. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8586. if (err < 0)
  8587. return err;
  8588. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8589. if (err < 0)
  8590. return err;
  8591. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8592. if (spec->autocfg.dig_out_pin)
  8593. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8594. if (spec->kctl_alloc)
  8595. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8596. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8597. spec->num_mux_defs = 1;
  8598. spec->input_mux = &spec->private_imux;
  8599. spec->adc_nids = alc861_adc_nids;
  8600. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8601. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8602. spec->num_mixers++;
  8603. return 1;
  8604. }
  8605. /* additional initialization for auto-configuration model */
  8606. static void alc861_auto_init(struct hda_codec *codec)
  8607. {
  8608. alc861_auto_init_multi_out(codec);
  8609. alc861_auto_init_hp_out(codec);
  8610. alc861_auto_init_analog_input(codec);
  8611. }
  8612. /*
  8613. * configuration and preset
  8614. */
  8615. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8616. [ALC861_3ST] = "3stack",
  8617. [ALC660_3ST] = "3stack-660",
  8618. [ALC861_3ST_DIG] = "3stack-dig",
  8619. [ALC861_6ST_DIG] = "6stack-dig",
  8620. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8621. [ALC861_TOSHIBA] = "toshiba",
  8622. [ALC861_ASUS] = "asus",
  8623. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8624. [ALC861_AUTO] = "auto",
  8625. };
  8626. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8627. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8628. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8629. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8630. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8631. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  8632. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8633. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  8634. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8635. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  8636. * Any other models that need this preset?
  8637. */
  8638. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  8639. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8640. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8641. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8642. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8643. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8644. {}
  8645. };
  8646. static struct alc_config_preset alc861_presets[] = {
  8647. [ALC861_3ST] = {
  8648. .mixers = { alc861_3ST_mixer },
  8649. .init_verbs = { alc861_threestack_init_verbs },
  8650. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8651. .dac_nids = alc861_dac_nids,
  8652. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8653. .channel_mode = alc861_threestack_modes,
  8654. .need_dac_fix = 1,
  8655. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8656. .adc_nids = alc861_adc_nids,
  8657. .input_mux = &alc861_capture_source,
  8658. },
  8659. [ALC861_3ST_DIG] = {
  8660. .mixers = { alc861_base_mixer },
  8661. .init_verbs = { alc861_threestack_init_verbs },
  8662. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8663. .dac_nids = alc861_dac_nids,
  8664. .dig_out_nid = ALC861_DIGOUT_NID,
  8665. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8666. .channel_mode = alc861_threestack_modes,
  8667. .need_dac_fix = 1,
  8668. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8669. .adc_nids = alc861_adc_nids,
  8670. .input_mux = &alc861_capture_source,
  8671. },
  8672. [ALC861_6ST_DIG] = {
  8673. .mixers = { alc861_base_mixer },
  8674. .init_verbs = { alc861_base_init_verbs },
  8675. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8676. .dac_nids = alc861_dac_nids,
  8677. .dig_out_nid = ALC861_DIGOUT_NID,
  8678. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8679. .channel_mode = alc861_8ch_modes,
  8680. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8681. .adc_nids = alc861_adc_nids,
  8682. .input_mux = &alc861_capture_source,
  8683. },
  8684. [ALC660_3ST] = {
  8685. .mixers = { alc861_3ST_mixer },
  8686. .init_verbs = { alc861_threestack_init_verbs },
  8687. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8688. .dac_nids = alc660_dac_nids,
  8689. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8690. .channel_mode = alc861_threestack_modes,
  8691. .need_dac_fix = 1,
  8692. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8693. .adc_nids = alc861_adc_nids,
  8694. .input_mux = &alc861_capture_source,
  8695. },
  8696. [ALC861_UNIWILL_M31] = {
  8697. .mixers = { alc861_uniwill_m31_mixer },
  8698. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8699. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8700. .dac_nids = alc861_dac_nids,
  8701. .dig_out_nid = ALC861_DIGOUT_NID,
  8702. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8703. .channel_mode = alc861_uniwill_m31_modes,
  8704. .need_dac_fix = 1,
  8705. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8706. .adc_nids = alc861_adc_nids,
  8707. .input_mux = &alc861_capture_source,
  8708. },
  8709. [ALC861_TOSHIBA] = {
  8710. .mixers = { alc861_toshiba_mixer },
  8711. .init_verbs = { alc861_base_init_verbs,
  8712. alc861_toshiba_init_verbs },
  8713. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8714. .dac_nids = alc861_dac_nids,
  8715. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8716. .channel_mode = alc883_3ST_2ch_modes,
  8717. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8718. .adc_nids = alc861_adc_nids,
  8719. .input_mux = &alc861_capture_source,
  8720. .unsol_event = alc861_toshiba_unsol_event,
  8721. .init_hook = alc861_toshiba_automute,
  8722. },
  8723. [ALC861_ASUS] = {
  8724. .mixers = { alc861_asus_mixer },
  8725. .init_verbs = { alc861_asus_init_verbs },
  8726. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8727. .dac_nids = alc861_dac_nids,
  8728. .dig_out_nid = ALC861_DIGOUT_NID,
  8729. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8730. .channel_mode = alc861_asus_modes,
  8731. .need_dac_fix = 1,
  8732. .hp_nid = 0x06,
  8733. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8734. .adc_nids = alc861_adc_nids,
  8735. .input_mux = &alc861_capture_source,
  8736. },
  8737. [ALC861_ASUS_LAPTOP] = {
  8738. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8739. .init_verbs = { alc861_asus_init_verbs,
  8740. alc861_asus_laptop_init_verbs },
  8741. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8742. .dac_nids = alc861_dac_nids,
  8743. .dig_out_nid = ALC861_DIGOUT_NID,
  8744. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8745. .channel_mode = alc883_3ST_2ch_modes,
  8746. .need_dac_fix = 1,
  8747. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8748. .adc_nids = alc861_adc_nids,
  8749. .input_mux = &alc861_capture_source,
  8750. },
  8751. };
  8752. static int patch_alc861(struct hda_codec *codec)
  8753. {
  8754. struct alc_spec *spec;
  8755. int board_config;
  8756. int err;
  8757. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8758. if (spec == NULL)
  8759. return -ENOMEM;
  8760. codec->spec = spec;
  8761. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8762. alc861_models,
  8763. alc861_cfg_tbl);
  8764. if (board_config < 0) {
  8765. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8766. "trying auto-probe from BIOS...\n");
  8767. board_config = ALC861_AUTO;
  8768. }
  8769. if (board_config == ALC861_AUTO) {
  8770. /* automatic parse from the BIOS config */
  8771. err = alc861_parse_auto_config(codec);
  8772. if (err < 0) {
  8773. alc_free(codec);
  8774. return err;
  8775. } else if (!err) {
  8776. printk(KERN_INFO
  8777. "hda_codec: Cannot set up configuration "
  8778. "from BIOS. Using base mode...\n");
  8779. board_config = ALC861_3ST_DIG;
  8780. }
  8781. }
  8782. if (board_config != ALC861_AUTO)
  8783. setup_preset(spec, &alc861_presets[board_config]);
  8784. spec->stream_name_analog = "ALC861 Analog";
  8785. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8786. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8787. spec->stream_name_digital = "ALC861 Digital";
  8788. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8789. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8790. codec->patch_ops = alc_patch_ops;
  8791. if (board_config == ALC861_AUTO)
  8792. spec->init_hook = alc861_auto_init;
  8793. return 0;
  8794. }
  8795. /*
  8796. * ALC861-VD support
  8797. *
  8798. * Based on ALC882
  8799. *
  8800. * In addition, an independent DAC
  8801. */
  8802. #define ALC861VD_DIGOUT_NID 0x06
  8803. static hda_nid_t alc861vd_dac_nids[4] = {
  8804. /* front, surr, clfe, side surr */
  8805. 0x02, 0x03, 0x04, 0x05
  8806. };
  8807. /* dac_nids for ALC660vd are in a different order - according to
  8808. * Realtek's driver.
  8809. * This should probably tesult in a different mixer for 6stack models
  8810. * of ALC660vd codecs, but for now there is only 3stack mixer
  8811. * - and it is the same as in 861vd.
  8812. * adc_nids in ALC660vd are (is) the same as in 861vd
  8813. */
  8814. static hda_nid_t alc660vd_dac_nids[3] = {
  8815. /* front, rear, clfe, rear_surr */
  8816. 0x02, 0x04, 0x03
  8817. };
  8818. static hda_nid_t alc861vd_adc_nids[1] = {
  8819. /* ADC0 */
  8820. 0x09,
  8821. };
  8822. /* input MUX */
  8823. /* FIXME: should be a matrix-type input source selection */
  8824. static struct hda_input_mux alc861vd_capture_source = {
  8825. .num_items = 4,
  8826. .items = {
  8827. { "Mic", 0x0 },
  8828. { "Front Mic", 0x1 },
  8829. { "Line", 0x2 },
  8830. { "CD", 0x4 },
  8831. },
  8832. };
  8833. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8834. .num_items = 3,
  8835. .items = {
  8836. { "Front Mic", 0x0 },
  8837. { "ATAPI Mic", 0x1 },
  8838. { "Line In", 0x5 },
  8839. },
  8840. };
  8841. #define alc861vd_mux_enum_info alc_mux_enum_info
  8842. #define alc861vd_mux_enum_get alc_mux_enum_get
  8843. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8844. struct snd_ctl_elem_value *ucontrol)
  8845. {
  8846. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8847. struct alc_spec *spec = codec->spec;
  8848. const struct hda_input_mux *imux = spec->input_mux;
  8849. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8850. static hda_nid_t capture_mixers[1] = { 0x22 };
  8851. hda_nid_t nid = capture_mixers[adc_idx];
  8852. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8853. unsigned int i, idx;
  8854. idx = ucontrol->value.enumerated.item[0];
  8855. if (idx >= imux->num_items)
  8856. idx = imux->num_items - 1;
  8857. if (*cur_val == idx && !codec->in_resume)
  8858. return 0;
  8859. for (i = 0; i < imux->num_items; i++) {
  8860. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8861. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8862. v | (imux->items[i].index << 8));
  8863. }
  8864. *cur_val = idx;
  8865. return 1;
  8866. }
  8867. /*
  8868. * 2ch mode
  8869. */
  8870. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8871. { 2, NULL }
  8872. };
  8873. /*
  8874. * 6ch mode
  8875. */
  8876. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8877. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8878. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8879. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8880. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8881. { } /* end */
  8882. };
  8883. /*
  8884. * 8ch mode
  8885. */
  8886. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8887. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8888. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8889. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8890. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8891. { } /* end */
  8892. };
  8893. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8894. { 6, alc861vd_6stack_ch6_init },
  8895. { 8, alc861vd_6stack_ch8_init },
  8896. };
  8897. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8898. {
  8899. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8900. .name = "Channel Mode",
  8901. .info = alc_ch_mode_info,
  8902. .get = alc_ch_mode_get,
  8903. .put = alc_ch_mode_put,
  8904. },
  8905. { } /* end */
  8906. };
  8907. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8908. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8909. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8910. {
  8911. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8912. /* The multiple "Capture Source" controls confuse alsamixer
  8913. * So call somewhat different..
  8914. *FIXME: the controls appear in the "playback" view!
  8915. */
  8916. /* .name = "Capture Source", */
  8917. .name = "Input Source",
  8918. .count = 1,
  8919. .info = alc861vd_mux_enum_info,
  8920. .get = alc861vd_mux_enum_get,
  8921. .put = alc861vd_mux_enum_put,
  8922. },
  8923. { } /* end */
  8924. };
  8925. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8926. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8927. */
  8928. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  8929. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8930. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8931. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8932. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  8933. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  8934. HDA_OUTPUT),
  8935. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  8936. HDA_OUTPUT),
  8937. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  8938. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  8939. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  8940. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  8941. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8942. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8943. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8944. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8945. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8946. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8947. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8948. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8949. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8950. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8951. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8952. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8953. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8954. { } /* end */
  8955. };
  8956. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  8957. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8958. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8959. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8960. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8961. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8962. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8963. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8964. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8965. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8966. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8967. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8968. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8969. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8970. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8971. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8972. { } /* end */
  8973. };
  8974. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  8975. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8976. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  8977. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8978. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8979. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8980. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8981. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8982. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8983. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8984. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8985. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8986. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8987. { } /* end */
  8988. };
  8989. /* Pin assignment: Front=0x14, HP = 0x15,
  8990. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  8991. */
  8992. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  8993. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8994. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8995. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8996. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  8997. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8998. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8999. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9000. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9001. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9002. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9003. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9004. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9005. {
  9006. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9007. /* .name = "Capture Source", */
  9008. .name = "Input Source",
  9009. .count = 1,
  9010. .info = alc882_mux_enum_info,
  9011. .get = alc882_mux_enum_get,
  9012. .put = alc882_mux_enum_put,
  9013. },
  9014. { } /* end */
  9015. };
  9016. /*
  9017. * generic initialization of ADC, input mixers and output mixers
  9018. */
  9019. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9020. /*
  9021. * Unmute ADC0 and set the default input to mic-in
  9022. */
  9023. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9024. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9025. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9026. * the analog-loopback mixer widget
  9027. */
  9028. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9029. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9030. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9031. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9032. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9033. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9034. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9035. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9036. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9037. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9038. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9039. /*
  9040. * Set up output mixers (0x02 - 0x05)
  9041. */
  9042. /* set vol=0 to output mixers */
  9043. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9044. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9045. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9046. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9047. /* set up input amps for analog loopback */
  9048. /* Amp Indices: DAC = 0, mixer = 1 */
  9049. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9050. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9051. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9052. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9053. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9054. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9055. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9056. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9057. { }
  9058. };
  9059. /*
  9060. * 3-stack pin configuration:
  9061. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9062. */
  9063. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9064. /*
  9065. * Set pin mode and muting
  9066. */
  9067. /* set front pin widgets 0x14 for output */
  9068. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9069. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9070. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9071. /* Mic (rear) pin: input vref at 80% */
  9072. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9073. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9074. /* Front Mic pin: input vref at 80% */
  9075. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9076. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9077. /* Line In pin: input */
  9078. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9079. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9080. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9081. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9082. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9083. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9084. /* CD pin widget for input */
  9085. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9086. { }
  9087. };
  9088. /*
  9089. * 6-stack pin configuration:
  9090. */
  9091. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9092. /*
  9093. * Set pin mode and muting
  9094. */
  9095. /* set front pin widgets 0x14 for output */
  9096. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9097. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9098. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9099. /* Rear Pin: output 1 (0x0d) */
  9100. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9101. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9102. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9103. /* CLFE Pin: output 2 (0x0e) */
  9104. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9105. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9106. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9107. /* Side Pin: output 3 (0x0f) */
  9108. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9109. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9110. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9111. /* Mic (rear) pin: input vref at 80% */
  9112. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9113. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9114. /* Front Mic pin: input vref at 80% */
  9115. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9116. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9117. /* Line In pin: input */
  9118. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9119. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9120. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9121. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9122. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9123. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9124. /* CD pin widget for input */
  9125. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9126. { }
  9127. };
  9128. static struct hda_verb alc861vd_eapd_verbs[] = {
  9129. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9130. { }
  9131. };
  9132. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9133. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9134. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9135. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9136. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9137. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9138. {}
  9139. };
  9140. /* toggle speaker-output according to the hp-jack state */
  9141. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9142. {
  9143. unsigned int present;
  9144. unsigned char bits;
  9145. present = snd_hda_codec_read(codec, 0x1b, 0,
  9146. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9147. bits = present ? 0x80 : 0;
  9148. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9149. 0x80, bits);
  9150. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9151. 0x80, bits);
  9152. }
  9153. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9154. {
  9155. unsigned int present;
  9156. unsigned char bits;
  9157. present = snd_hda_codec_read(codec, 0x18, 0,
  9158. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9159. bits = present ? 0x80 : 0;
  9160. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  9161. 0x80, bits);
  9162. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  9163. 0x80, bits);
  9164. }
  9165. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9166. {
  9167. alc861vd_lenovo_hp_automute(codec);
  9168. alc861vd_lenovo_mic_automute(codec);
  9169. }
  9170. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9171. unsigned int res)
  9172. {
  9173. switch (res >> 26) {
  9174. case ALC880_HP_EVENT:
  9175. alc861vd_lenovo_hp_automute(codec);
  9176. break;
  9177. case ALC880_MIC_EVENT:
  9178. alc861vd_lenovo_mic_automute(codec);
  9179. break;
  9180. }
  9181. }
  9182. static struct hda_verb alc861vd_dallas_verbs[] = {
  9183. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9184. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9185. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9186. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9187. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9188. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9189. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9190. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9191. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9192. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9193. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9194. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9195. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9196. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9197. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9198. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9199. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9200. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9201. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9202. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9203. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9204. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9205. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9206. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9207. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9208. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9209. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9210. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9211. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9212. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9213. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9214. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9215. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9216. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9217. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9218. { } /* end */
  9219. };
  9220. /* toggle speaker-output according to the hp-jack state */
  9221. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9222. {
  9223. unsigned int present;
  9224. present = snd_hda_codec_read(codec, 0x15, 0,
  9225. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9226. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9227. 0x80, present ? 0x80 : 0);
  9228. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9229. 0x80, present ? 0x80 : 0);
  9230. }
  9231. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9232. {
  9233. if ((res >> 26) == ALC880_HP_EVENT)
  9234. alc861vd_dallas_automute(codec);
  9235. }
  9236. /* pcm configuration: identiacal with ALC880 */
  9237. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9238. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9239. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9240. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9241. /*
  9242. * configuration and preset
  9243. */
  9244. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9245. [ALC660VD_3ST] = "3stack-660",
  9246. [ALC660VD_3ST_DIG]= "3stack-660-digout",
  9247. [ALC861VD_3ST] = "3stack",
  9248. [ALC861VD_3ST_DIG] = "3stack-digout",
  9249. [ALC861VD_6ST_DIG] = "6stack-digout",
  9250. [ALC861VD_LENOVO] = "lenovo",
  9251. [ALC861VD_DALLAS] = "dallas",
  9252. [ALC861VD_AUTO] = "auto",
  9253. };
  9254. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9255. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9256. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9257. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9258. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9259. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9260. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9261. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9262. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9263. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9264. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9265. {}
  9266. };
  9267. static struct alc_config_preset alc861vd_presets[] = {
  9268. [ALC660VD_3ST] = {
  9269. .mixers = { alc861vd_3st_mixer },
  9270. .init_verbs = { alc861vd_volume_init_verbs,
  9271. alc861vd_3stack_init_verbs },
  9272. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9273. .dac_nids = alc660vd_dac_nids,
  9274. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9275. .adc_nids = alc861vd_adc_nids,
  9276. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9277. .channel_mode = alc861vd_3stack_2ch_modes,
  9278. .input_mux = &alc861vd_capture_source,
  9279. },
  9280. [ALC660VD_3ST_DIG] = {
  9281. .mixers = { alc861vd_3st_mixer },
  9282. .init_verbs = { alc861vd_volume_init_verbs,
  9283. alc861vd_3stack_init_verbs },
  9284. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9285. .dac_nids = alc660vd_dac_nids,
  9286. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9287. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9288. .adc_nids = alc861vd_adc_nids,
  9289. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9290. .channel_mode = alc861vd_3stack_2ch_modes,
  9291. .input_mux = &alc861vd_capture_source,
  9292. },
  9293. [ALC861VD_3ST] = {
  9294. .mixers = { alc861vd_3st_mixer },
  9295. .init_verbs = { alc861vd_volume_init_verbs,
  9296. alc861vd_3stack_init_verbs },
  9297. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9298. .dac_nids = alc861vd_dac_nids,
  9299. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9300. .channel_mode = alc861vd_3stack_2ch_modes,
  9301. .input_mux = &alc861vd_capture_source,
  9302. },
  9303. [ALC861VD_3ST_DIG] = {
  9304. .mixers = { alc861vd_3st_mixer },
  9305. .init_verbs = { alc861vd_volume_init_verbs,
  9306. alc861vd_3stack_init_verbs },
  9307. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9308. .dac_nids = alc861vd_dac_nids,
  9309. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9310. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9311. .channel_mode = alc861vd_3stack_2ch_modes,
  9312. .input_mux = &alc861vd_capture_source,
  9313. },
  9314. [ALC861VD_6ST_DIG] = {
  9315. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9316. .init_verbs = { alc861vd_volume_init_verbs,
  9317. alc861vd_6stack_init_verbs },
  9318. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9319. .dac_nids = alc861vd_dac_nids,
  9320. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9321. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9322. .channel_mode = alc861vd_6stack_modes,
  9323. .input_mux = &alc861vd_capture_source,
  9324. },
  9325. [ALC861VD_LENOVO] = {
  9326. .mixers = { alc861vd_lenovo_mixer },
  9327. .init_verbs = { alc861vd_volume_init_verbs,
  9328. alc861vd_3stack_init_verbs,
  9329. alc861vd_eapd_verbs,
  9330. alc861vd_lenovo_unsol_verbs },
  9331. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9332. .dac_nids = alc660vd_dac_nids,
  9333. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9334. .adc_nids = alc861vd_adc_nids,
  9335. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9336. .channel_mode = alc861vd_3stack_2ch_modes,
  9337. .input_mux = &alc861vd_capture_source,
  9338. .unsol_event = alc861vd_lenovo_unsol_event,
  9339. .init_hook = alc861vd_lenovo_automute,
  9340. },
  9341. [ALC861VD_DALLAS] = {
  9342. .mixers = { alc861vd_dallas_mixer },
  9343. .init_verbs = { alc861vd_dallas_verbs },
  9344. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9345. .dac_nids = alc861vd_dac_nids,
  9346. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9347. .adc_nids = alc861vd_adc_nids,
  9348. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9349. .channel_mode = alc861vd_3stack_2ch_modes,
  9350. .input_mux = &alc861vd_dallas_capture_source,
  9351. .unsol_event = alc861vd_dallas_unsol_event,
  9352. .init_hook = alc861vd_dallas_automute,
  9353. },
  9354. };
  9355. /*
  9356. * BIOS auto configuration
  9357. */
  9358. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9359. hda_nid_t nid, int pin_type, int dac_idx)
  9360. {
  9361. /* set as output */
  9362. snd_hda_codec_write(codec, nid, 0,
  9363. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9364. snd_hda_codec_write(codec, nid, 0,
  9365. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9366. }
  9367. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9368. {
  9369. struct alc_spec *spec = codec->spec;
  9370. int i;
  9371. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9372. for (i = 0; i <= HDA_SIDE; i++) {
  9373. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9374. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9375. if (nid)
  9376. alc861vd_auto_set_output_and_unmute(codec, nid,
  9377. pin_type, i);
  9378. }
  9379. }
  9380. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9381. {
  9382. struct alc_spec *spec = codec->spec;
  9383. hda_nid_t pin;
  9384. pin = spec->autocfg.hp_pins[0];
  9385. if (pin) /* connect to front and use dac 0 */
  9386. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9387. }
  9388. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9389. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9390. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9391. {
  9392. struct alc_spec *spec = codec->spec;
  9393. int i;
  9394. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9395. hda_nid_t nid = spec->autocfg.input_pins[i];
  9396. if (alc861vd_is_input_pin(nid)) {
  9397. snd_hda_codec_write(codec, nid, 0,
  9398. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9399. i <= AUTO_PIN_FRONT_MIC ?
  9400. PIN_VREF80 : PIN_IN);
  9401. if (nid != ALC861VD_PIN_CD_NID)
  9402. snd_hda_codec_write(codec, nid, 0,
  9403. AC_VERB_SET_AMP_GAIN_MUTE,
  9404. AMP_OUT_MUTE);
  9405. }
  9406. }
  9407. }
  9408. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9409. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9410. /* add playback controls from the parsed DAC table */
  9411. /* Based on ALC880 version. But ALC861VD has separate,
  9412. * different NIDs for mute/unmute switch and volume control */
  9413. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9414. const struct auto_pin_cfg *cfg)
  9415. {
  9416. char name[32];
  9417. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9418. hda_nid_t nid_v, nid_s;
  9419. int i, err;
  9420. for (i = 0; i < cfg->line_outs; i++) {
  9421. if (!spec->multiout.dac_nids[i])
  9422. continue;
  9423. nid_v = alc861vd_idx_to_mixer_vol(
  9424. alc880_dac_to_idx(
  9425. spec->multiout.dac_nids[i]));
  9426. nid_s = alc861vd_idx_to_mixer_switch(
  9427. alc880_dac_to_idx(
  9428. spec->multiout.dac_nids[i]));
  9429. if (i == 2) {
  9430. /* Center/LFE */
  9431. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9432. "Center Playback Volume",
  9433. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9434. HDA_OUTPUT));
  9435. if (err < 0)
  9436. return err;
  9437. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9438. "LFE Playback Volume",
  9439. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9440. HDA_OUTPUT));
  9441. if (err < 0)
  9442. return err;
  9443. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9444. "Center Playback Switch",
  9445. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9446. HDA_INPUT));
  9447. if (err < 0)
  9448. return err;
  9449. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9450. "LFE Playback Switch",
  9451. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9452. HDA_INPUT));
  9453. if (err < 0)
  9454. return err;
  9455. } else {
  9456. sprintf(name, "%s Playback Volume", chname[i]);
  9457. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9458. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9459. HDA_OUTPUT));
  9460. if (err < 0)
  9461. return err;
  9462. sprintf(name, "%s Playback Switch", chname[i]);
  9463. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9464. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9465. HDA_INPUT));
  9466. if (err < 0)
  9467. return err;
  9468. }
  9469. }
  9470. return 0;
  9471. }
  9472. /* add playback controls for speaker and HP outputs */
  9473. /* Based on ALC880 version. But ALC861VD has separate,
  9474. * different NIDs for mute/unmute switch and volume control */
  9475. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9476. hda_nid_t pin, const char *pfx)
  9477. {
  9478. hda_nid_t nid_v, nid_s;
  9479. int err;
  9480. char name[32];
  9481. if (!pin)
  9482. return 0;
  9483. if (alc880_is_fixed_pin(pin)) {
  9484. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9485. /* specify the DAC as the extra output */
  9486. if (!spec->multiout.hp_nid)
  9487. spec->multiout.hp_nid = nid_v;
  9488. else
  9489. spec->multiout.extra_out_nid[0] = nid_v;
  9490. /* control HP volume/switch on the output mixer amp */
  9491. nid_v = alc861vd_idx_to_mixer_vol(
  9492. alc880_fixed_pin_idx(pin));
  9493. nid_s = alc861vd_idx_to_mixer_switch(
  9494. alc880_fixed_pin_idx(pin));
  9495. sprintf(name, "%s Playback Volume", pfx);
  9496. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9497. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9498. if (err < 0)
  9499. return err;
  9500. sprintf(name, "%s Playback Switch", pfx);
  9501. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9502. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9503. if (err < 0)
  9504. return err;
  9505. } else if (alc880_is_multi_pin(pin)) {
  9506. /* set manual connection */
  9507. /* we have only a switch on HP-out PIN */
  9508. sprintf(name, "%s Playback Switch", pfx);
  9509. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9510. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9511. if (err < 0)
  9512. return err;
  9513. }
  9514. return 0;
  9515. }
  9516. /* parse the BIOS configuration and set up the alc_spec
  9517. * return 1 if successful, 0 if the proper config is not found,
  9518. * or a negative error code
  9519. * Based on ALC880 version - had to change it to override
  9520. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9521. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9522. {
  9523. struct alc_spec *spec = codec->spec;
  9524. int err;
  9525. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9526. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9527. alc861vd_ignore);
  9528. if (err < 0)
  9529. return err;
  9530. if (!spec->autocfg.line_outs)
  9531. return 0; /* can't find valid BIOS pin config */
  9532. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9533. if (err < 0)
  9534. return err;
  9535. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9536. if (err < 0)
  9537. return err;
  9538. err = alc861vd_auto_create_extra_out(spec,
  9539. spec->autocfg.speaker_pins[0],
  9540. "Speaker");
  9541. if (err < 0)
  9542. return err;
  9543. err = alc861vd_auto_create_extra_out(spec,
  9544. spec->autocfg.hp_pins[0],
  9545. "Headphone");
  9546. if (err < 0)
  9547. return err;
  9548. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9549. if (err < 0)
  9550. return err;
  9551. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9552. if (spec->autocfg.dig_out_pin)
  9553. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9554. if (spec->kctl_alloc)
  9555. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9556. spec->init_verbs[spec->num_init_verbs++]
  9557. = alc861vd_volume_init_verbs;
  9558. spec->num_mux_defs = 1;
  9559. spec->input_mux = &spec->private_imux;
  9560. return 1;
  9561. }
  9562. /* additional initialization for auto-configuration model */
  9563. static void alc861vd_auto_init(struct hda_codec *codec)
  9564. {
  9565. alc861vd_auto_init_multi_out(codec);
  9566. alc861vd_auto_init_hp_out(codec);
  9567. alc861vd_auto_init_analog_input(codec);
  9568. }
  9569. static int patch_alc861vd(struct hda_codec *codec)
  9570. {
  9571. struct alc_spec *spec;
  9572. int err, board_config;
  9573. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9574. if (spec == NULL)
  9575. return -ENOMEM;
  9576. codec->spec = spec;
  9577. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9578. alc861vd_models,
  9579. alc861vd_cfg_tbl);
  9580. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9581. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9582. "ALC861VD, trying auto-probe from BIOS...\n");
  9583. board_config = ALC861VD_AUTO;
  9584. }
  9585. if (board_config == ALC861VD_AUTO) {
  9586. /* automatic parse from the BIOS config */
  9587. err = alc861vd_parse_auto_config(codec);
  9588. if (err < 0) {
  9589. alc_free(codec);
  9590. return err;
  9591. } else if (!err) {
  9592. printk(KERN_INFO
  9593. "hda_codec: Cannot set up configuration "
  9594. "from BIOS. Using base mode...\n");
  9595. board_config = ALC861VD_3ST;
  9596. }
  9597. }
  9598. if (board_config != ALC861VD_AUTO)
  9599. setup_preset(spec, &alc861vd_presets[board_config]);
  9600. spec->stream_name_analog = "ALC861VD Analog";
  9601. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9602. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9603. spec->stream_name_digital = "ALC861VD Digital";
  9604. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9605. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9606. spec->adc_nids = alc861vd_adc_nids;
  9607. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9608. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9609. spec->num_mixers++;
  9610. codec->patch_ops = alc_patch_ops;
  9611. if (board_config == ALC861VD_AUTO)
  9612. spec->init_hook = alc861vd_auto_init;
  9613. return 0;
  9614. }
  9615. /*
  9616. * ALC662 support
  9617. *
  9618. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9619. * configuration. Each pin widget can choose any input DACs and a mixer.
  9620. * Each ADC is connected from a mixer of all inputs. This makes possible
  9621. * 6-channel independent captures.
  9622. *
  9623. * In addition, an independent DAC for the multi-playback (not used in this
  9624. * driver yet).
  9625. */
  9626. #define ALC662_DIGOUT_NID 0x06
  9627. #define ALC662_DIGIN_NID 0x0a
  9628. static hda_nid_t alc662_dac_nids[4] = {
  9629. /* front, rear, clfe, rear_surr */
  9630. 0x02, 0x03, 0x04
  9631. };
  9632. static hda_nid_t alc662_adc_nids[1] = {
  9633. /* ADC1-2 */
  9634. 0x09,
  9635. };
  9636. /* input MUX */
  9637. /* FIXME: should be a matrix-type input source selection */
  9638. static struct hda_input_mux alc662_capture_source = {
  9639. .num_items = 4,
  9640. .items = {
  9641. { "Mic", 0x0 },
  9642. { "Front Mic", 0x1 },
  9643. { "Line", 0x2 },
  9644. { "CD", 0x4 },
  9645. },
  9646. };
  9647. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9648. .num_items = 2,
  9649. .items = {
  9650. { "Mic", 0x1 },
  9651. { "Line", 0x2 },
  9652. },
  9653. };
  9654. #define alc662_mux_enum_info alc_mux_enum_info
  9655. #define alc662_mux_enum_get alc_mux_enum_get
  9656. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9657. struct snd_ctl_elem_value *ucontrol)
  9658. {
  9659. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9660. struct alc_spec *spec = codec->spec;
  9661. const struct hda_input_mux *imux = spec->input_mux;
  9662. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9663. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9664. hda_nid_t nid = capture_mixers[adc_idx];
  9665. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9666. unsigned int i, idx;
  9667. idx = ucontrol->value.enumerated.item[0];
  9668. if (idx >= imux->num_items)
  9669. idx = imux->num_items - 1;
  9670. if (*cur_val == idx && !codec->in_resume)
  9671. return 0;
  9672. for (i = 0; i < imux->num_items; i++) {
  9673. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  9674. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9675. v | (imux->items[i].index << 8));
  9676. }
  9677. *cur_val = idx;
  9678. return 1;
  9679. }
  9680. /*
  9681. * 2ch mode
  9682. */
  9683. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9684. { 2, NULL }
  9685. };
  9686. /*
  9687. * 2ch mode
  9688. */
  9689. static struct hda_verb alc662_3ST_ch2_init[] = {
  9690. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9691. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9692. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9693. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9694. { } /* end */
  9695. };
  9696. /*
  9697. * 6ch mode
  9698. */
  9699. static struct hda_verb alc662_3ST_ch6_init[] = {
  9700. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9701. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9702. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9703. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9704. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9705. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9706. { } /* end */
  9707. };
  9708. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9709. { 2, alc662_3ST_ch2_init },
  9710. { 6, alc662_3ST_ch6_init },
  9711. };
  9712. /*
  9713. * 2ch mode
  9714. */
  9715. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9716. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9717. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9718. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9719. { } /* end */
  9720. };
  9721. /*
  9722. * 6ch mode
  9723. */
  9724. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9725. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9726. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9727. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9728. { } /* end */
  9729. };
  9730. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9731. { 2, alc662_sixstack_ch6_init },
  9732. { 6, alc662_sixstack_ch8_init },
  9733. };
  9734. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9735. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9736. */
  9737. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9738. /* output mixer control */
  9739. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9740. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9741. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9742. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9743. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9744. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9745. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9746. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9747. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9748. /*Input mixer control */
  9749. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9750. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9751. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9752. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9753. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9754. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9755. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9756. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9757. /* Capture mixer control */
  9758. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9759. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9760. {
  9761. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9762. .name = "Capture Source",
  9763. .count = 1,
  9764. .info = alc_mux_enum_info,
  9765. .get = alc_mux_enum_get,
  9766. .put = alc_mux_enum_put,
  9767. },
  9768. { } /* end */
  9769. };
  9770. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9771. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9772. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9773. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9774. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9775. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9776. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9777. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9778. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9779. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9780. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9781. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9782. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9783. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9784. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9785. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9786. {
  9787. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9788. /* .name = "Capture Source", */
  9789. .name = "Input Source",
  9790. .count = 1,
  9791. .info = alc662_mux_enum_info,
  9792. .get = alc662_mux_enum_get,
  9793. .put = alc662_mux_enum_put,
  9794. },
  9795. { } /* end */
  9796. };
  9797. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9798. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9799. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9800. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9801. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9802. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9803. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9804. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9805. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9806. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9807. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9808. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9809. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9810. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9811. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9812. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9813. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9814. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9815. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9816. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9817. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9818. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9819. {
  9820. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9821. /* .name = "Capture Source", */
  9822. .name = "Input Source",
  9823. .count = 1,
  9824. .info = alc662_mux_enum_info,
  9825. .get = alc662_mux_enum_get,
  9826. .put = alc662_mux_enum_put,
  9827. },
  9828. { } /* end */
  9829. };
  9830. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9831. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9832. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9833. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9834. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9835. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9836. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9837. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9838. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9839. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9840. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9841. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9842. {
  9843. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9844. /* .name = "Capture Source", */
  9845. .name = "Input Source",
  9846. .count = 1,
  9847. .info = alc662_mux_enum_info,
  9848. .get = alc662_mux_enum_get,
  9849. .put = alc662_mux_enum_put,
  9850. },
  9851. { } /* end */
  9852. };
  9853. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9854. {
  9855. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9856. .name = "Channel Mode",
  9857. .info = alc_ch_mode_info,
  9858. .get = alc_ch_mode_get,
  9859. .put = alc_ch_mode_put,
  9860. },
  9861. { } /* end */
  9862. };
  9863. static struct hda_verb alc662_init_verbs[] = {
  9864. /* ADC: mute amp left and right */
  9865. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9866. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9867. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9868. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9869. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9870. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9871. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9872. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9873. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9874. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9875. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9876. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9877. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9878. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9879. /* Front Pin: output 0 (0x0c) */
  9880. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9881. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9882. /* Rear Pin: output 1 (0x0d) */
  9883. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9884. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9885. /* CLFE Pin: output 2 (0x0e) */
  9886. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9887. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9888. /* Mic (rear) pin: input vref at 80% */
  9889. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9890. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9891. /* Front Mic pin: input vref at 80% */
  9892. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9893. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9894. /* Line In pin: input */
  9895. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9896. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9897. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9898. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9899. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9900. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9901. /* CD pin widget for input */
  9902. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9903. /* FIXME: use matrix-type input source selection */
  9904. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9905. /* Input mixer */
  9906. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9907. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9908. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9909. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9910. { }
  9911. };
  9912. static struct hda_verb alc662_sue_init_verbs[] = {
  9913. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9914. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9915. {}
  9916. };
  9917. /*
  9918. * generic initialization of ADC, input mixers and output mixers
  9919. */
  9920. static struct hda_verb alc662_auto_init_verbs[] = {
  9921. /*
  9922. * Unmute ADC and set the default input to mic-in
  9923. */
  9924. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9925. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9926. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  9927. * mixer widget
  9928. * Note: PASD motherboards uses the Line In 2 as the input for front
  9929. * panel mic (mic 2)
  9930. */
  9931. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9932. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9933. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9934. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9935. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9936. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9937. /*
  9938. * Set up output mixers (0x0c - 0x0f)
  9939. */
  9940. /* set vol=0 to output mixers */
  9941. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9942. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9943. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9944. /* set up input amps for analog loopback */
  9945. /* Amp Indices: DAC = 0, mixer = 1 */
  9946. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9947. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9948. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9949. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9950. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9951. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9952. /* FIXME: use matrix-type input source selection */
  9953. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9954. /* Input mixer */
  9955. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9956. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9957. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9958. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  9959. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9960. { }
  9961. };
  9962. /* capture mixer elements */
  9963. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  9964. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9965. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9966. {
  9967. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9968. /* The multiple "Capture Source" controls confuse alsamixer
  9969. * So call somewhat different..
  9970. * FIXME: the controls appear in the "playback" view!
  9971. */
  9972. /* .name = "Capture Source", */
  9973. .name = "Input Source",
  9974. .count = 1,
  9975. .info = alc882_mux_enum_info,
  9976. .get = alc882_mux_enum_get,
  9977. .put = alc882_mux_enum_put,
  9978. },
  9979. { } /* end */
  9980. };
  9981. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  9982. {
  9983. unsigned int present;
  9984. unsigned char bits;
  9985. present = snd_hda_codec_read(codec, 0x14, 0,
  9986. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9987. bits = present ? 0x80 : 0;
  9988. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9989. 0x80, bits);
  9990. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9991. 0x80, bits);
  9992. }
  9993. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  9994. {
  9995. unsigned int present;
  9996. unsigned char bits;
  9997. present = snd_hda_codec_read(codec, 0x1b, 0,
  9998. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9999. bits = present ? 0x80 : 0;
  10000. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  10001. 0x80, bits);
  10002. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  10003. 0x80, bits);
  10004. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  10005. 0x80, bits);
  10006. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  10007. 0x80, bits);
  10008. }
  10009. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10010. unsigned int res)
  10011. {
  10012. if ((res >> 26) == ALC880_HP_EVENT)
  10013. alc662_lenovo_101e_all_automute(codec);
  10014. if ((res >> 26) == ALC880_FRONT_EVENT)
  10015. alc662_lenovo_101e_ispeaker_automute(codec);
  10016. }
  10017. /* pcm configuration: identiacal with ALC880 */
  10018. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10019. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10020. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10021. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10022. /*
  10023. * configuration and preset
  10024. */
  10025. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10026. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10027. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10028. [ALC662_3ST_6ch] = "3stack-6ch",
  10029. [ALC662_5ST_DIG] = "6stack-dig",
  10030. [ALC662_LENOVO_101E] = "lenovo-101e",
  10031. [ALC662_AUTO] = "auto",
  10032. };
  10033. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10034. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10035. {}
  10036. };
  10037. static struct alc_config_preset alc662_presets[] = {
  10038. [ALC662_3ST_2ch_DIG] = {
  10039. .mixers = { alc662_3ST_2ch_mixer },
  10040. .init_verbs = { alc662_init_verbs },
  10041. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10042. .dac_nids = alc662_dac_nids,
  10043. .dig_out_nid = ALC662_DIGOUT_NID,
  10044. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10045. .adc_nids = alc662_adc_nids,
  10046. .dig_in_nid = ALC662_DIGIN_NID,
  10047. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10048. .channel_mode = alc662_3ST_2ch_modes,
  10049. .input_mux = &alc662_capture_source,
  10050. },
  10051. [ALC662_3ST_6ch_DIG] = {
  10052. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10053. .init_verbs = { alc662_init_verbs },
  10054. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10055. .dac_nids = alc662_dac_nids,
  10056. .dig_out_nid = ALC662_DIGOUT_NID,
  10057. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10058. .adc_nids = alc662_adc_nids,
  10059. .dig_in_nid = ALC662_DIGIN_NID,
  10060. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10061. .channel_mode = alc662_3ST_6ch_modes,
  10062. .need_dac_fix = 1,
  10063. .input_mux = &alc662_capture_source,
  10064. },
  10065. [ALC662_3ST_6ch] = {
  10066. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10067. .init_verbs = { alc662_init_verbs },
  10068. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10069. .dac_nids = alc662_dac_nids,
  10070. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10071. .adc_nids = alc662_adc_nids,
  10072. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10073. .channel_mode = alc662_3ST_6ch_modes,
  10074. .need_dac_fix = 1,
  10075. .input_mux = &alc662_capture_source,
  10076. },
  10077. [ALC662_5ST_DIG] = {
  10078. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10079. .init_verbs = { alc662_init_verbs },
  10080. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10081. .dac_nids = alc662_dac_nids,
  10082. .dig_out_nid = ALC662_DIGOUT_NID,
  10083. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10084. .adc_nids = alc662_adc_nids,
  10085. .dig_in_nid = ALC662_DIGIN_NID,
  10086. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10087. .channel_mode = alc662_5stack_modes,
  10088. .input_mux = &alc662_capture_source,
  10089. },
  10090. [ALC662_LENOVO_101E] = {
  10091. .mixers = { alc662_lenovo_101e_mixer },
  10092. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10093. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10094. .dac_nids = alc662_dac_nids,
  10095. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10096. .adc_nids = alc662_adc_nids,
  10097. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10098. .channel_mode = alc662_3ST_2ch_modes,
  10099. .input_mux = &alc662_lenovo_101e_capture_source,
  10100. .unsol_event = alc662_lenovo_101e_unsol_event,
  10101. .init_hook = alc662_lenovo_101e_all_automute,
  10102. },
  10103. };
  10104. /*
  10105. * BIOS auto configuration
  10106. */
  10107. /* add playback controls from the parsed DAC table */
  10108. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10109. const struct auto_pin_cfg *cfg)
  10110. {
  10111. char name[32];
  10112. static const char *chname[4] = {
  10113. "Front", "Surround", NULL /*CLFE*/, "Side"
  10114. };
  10115. hda_nid_t nid;
  10116. int i, err;
  10117. for (i = 0; i < cfg->line_outs; i++) {
  10118. if (!spec->multiout.dac_nids[i])
  10119. continue;
  10120. nid = alc880_idx_to_mixer(i);
  10121. if (i == 2) {
  10122. /* Center/LFE */
  10123. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10124. "Center Playback Volume",
  10125. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10126. HDA_OUTPUT));
  10127. if (err < 0)
  10128. return err;
  10129. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10130. "LFE Playback Volume",
  10131. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10132. HDA_OUTPUT));
  10133. if (err < 0)
  10134. return err;
  10135. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10136. "Center Playback Switch",
  10137. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10138. HDA_INPUT));
  10139. if (err < 0)
  10140. return err;
  10141. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10142. "LFE Playback Switch",
  10143. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10144. HDA_INPUT));
  10145. if (err < 0)
  10146. return err;
  10147. } else {
  10148. sprintf(name, "%s Playback Volume", chname[i]);
  10149. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10150. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10151. HDA_OUTPUT));
  10152. if (err < 0)
  10153. return err;
  10154. sprintf(name, "%s Playback Switch", chname[i]);
  10155. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10156. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10157. HDA_INPUT));
  10158. if (err < 0)
  10159. return err;
  10160. }
  10161. }
  10162. return 0;
  10163. }
  10164. /* add playback controls for speaker and HP outputs */
  10165. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10166. const char *pfx)
  10167. {
  10168. hda_nid_t nid;
  10169. int err;
  10170. char name[32];
  10171. if (!pin)
  10172. return 0;
  10173. if (alc880_is_fixed_pin(pin)) {
  10174. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10175. /* printk("DAC nid=%x\n",nid); */
  10176. /* specify the DAC as the extra output */
  10177. if (!spec->multiout.hp_nid)
  10178. spec->multiout.hp_nid = nid;
  10179. else
  10180. spec->multiout.extra_out_nid[0] = nid;
  10181. /* control HP volume/switch on the output mixer amp */
  10182. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10183. sprintf(name, "%s Playback Volume", pfx);
  10184. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10185. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10186. if (err < 0)
  10187. return err;
  10188. sprintf(name, "%s Playback Switch", pfx);
  10189. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10190. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10191. if (err < 0)
  10192. return err;
  10193. } else if (alc880_is_multi_pin(pin)) {
  10194. /* set manual connection */
  10195. /* we have only a switch on HP-out PIN */
  10196. sprintf(name, "%s Playback Switch", pfx);
  10197. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10198. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10199. if (err < 0)
  10200. return err;
  10201. }
  10202. return 0;
  10203. }
  10204. /* create playback/capture controls for input pins */
  10205. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10206. const struct auto_pin_cfg *cfg)
  10207. {
  10208. struct hda_input_mux *imux = &spec->private_imux;
  10209. int i, err, idx;
  10210. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10211. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10212. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10213. err = new_analog_input(spec, cfg->input_pins[i],
  10214. auto_pin_cfg_labels[i],
  10215. idx, 0x0b);
  10216. if (err < 0)
  10217. return err;
  10218. imux->items[imux->num_items].label =
  10219. auto_pin_cfg_labels[i];
  10220. imux->items[imux->num_items].index =
  10221. alc880_input_pin_idx(cfg->input_pins[i]);
  10222. imux->num_items++;
  10223. }
  10224. }
  10225. return 0;
  10226. }
  10227. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10228. hda_nid_t nid, int pin_type,
  10229. int dac_idx)
  10230. {
  10231. /* set as output */
  10232. snd_hda_codec_write(codec, nid, 0,
  10233. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10234. snd_hda_codec_write(codec, nid, 0,
  10235. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10236. /* need the manual connection? */
  10237. if (alc880_is_multi_pin(nid)) {
  10238. struct alc_spec *spec = codec->spec;
  10239. int idx = alc880_multi_pin_idx(nid);
  10240. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10241. AC_VERB_SET_CONNECT_SEL,
  10242. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10243. }
  10244. }
  10245. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10246. {
  10247. struct alc_spec *spec = codec->spec;
  10248. int i;
  10249. for (i = 0; i <= HDA_SIDE; i++) {
  10250. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10251. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10252. if (nid)
  10253. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10254. i);
  10255. }
  10256. }
  10257. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10258. {
  10259. struct alc_spec *spec = codec->spec;
  10260. hda_nid_t pin;
  10261. pin = spec->autocfg.hp_pins[0];
  10262. if (pin) /* connect to front */
  10263. /* use dac 0 */
  10264. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10265. }
  10266. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10267. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10268. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10269. {
  10270. struct alc_spec *spec = codec->spec;
  10271. int i;
  10272. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10273. hda_nid_t nid = spec->autocfg.input_pins[i];
  10274. if (alc662_is_input_pin(nid)) {
  10275. snd_hda_codec_write(codec, nid, 0,
  10276. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10277. (i <= AUTO_PIN_FRONT_MIC ?
  10278. PIN_VREF80 : PIN_IN));
  10279. if (nid != ALC662_PIN_CD_NID)
  10280. snd_hda_codec_write(codec, nid, 0,
  10281. AC_VERB_SET_AMP_GAIN_MUTE,
  10282. AMP_OUT_MUTE);
  10283. }
  10284. }
  10285. }
  10286. static int alc662_parse_auto_config(struct hda_codec *codec)
  10287. {
  10288. struct alc_spec *spec = codec->spec;
  10289. int err;
  10290. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10291. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10292. alc662_ignore);
  10293. if (err < 0)
  10294. return err;
  10295. if (!spec->autocfg.line_outs)
  10296. return 0; /* can't find valid BIOS pin config */
  10297. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10298. if (err < 0)
  10299. return err;
  10300. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10301. if (err < 0)
  10302. return err;
  10303. err = alc662_auto_create_extra_out(spec,
  10304. spec->autocfg.speaker_pins[0],
  10305. "Speaker");
  10306. if (err < 0)
  10307. return err;
  10308. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10309. "Headphone");
  10310. if (err < 0)
  10311. return err;
  10312. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10313. if (err < 0)
  10314. return err;
  10315. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10316. if (spec->autocfg.dig_out_pin)
  10317. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10318. if (spec->kctl_alloc)
  10319. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10320. spec->num_mux_defs = 1;
  10321. spec->input_mux = &spec->private_imux;
  10322. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10323. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10324. spec->num_mixers++;
  10325. return 1;
  10326. }
  10327. /* additional initialization for auto-configuration model */
  10328. static void alc662_auto_init(struct hda_codec *codec)
  10329. {
  10330. alc662_auto_init_multi_out(codec);
  10331. alc662_auto_init_hp_out(codec);
  10332. alc662_auto_init_analog_input(codec);
  10333. }
  10334. static int patch_alc662(struct hda_codec *codec)
  10335. {
  10336. struct alc_spec *spec;
  10337. int err, board_config;
  10338. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10339. if (!spec)
  10340. return -ENOMEM;
  10341. codec->spec = spec;
  10342. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10343. alc662_models,
  10344. alc662_cfg_tbl);
  10345. if (board_config < 0) {
  10346. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10347. "trying auto-probe from BIOS...\n");
  10348. board_config = ALC662_AUTO;
  10349. }
  10350. if (board_config == ALC662_AUTO) {
  10351. /* automatic parse from the BIOS config */
  10352. err = alc662_parse_auto_config(codec);
  10353. if (err < 0) {
  10354. alc_free(codec);
  10355. return err;
  10356. } else if (!err) {
  10357. printk(KERN_INFO
  10358. "hda_codec: Cannot set up configuration "
  10359. "from BIOS. Using base mode...\n");
  10360. board_config = ALC662_3ST_2ch_DIG;
  10361. }
  10362. }
  10363. if (board_config != ALC662_AUTO)
  10364. setup_preset(spec, &alc662_presets[board_config]);
  10365. spec->stream_name_analog = "ALC662 Analog";
  10366. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10367. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10368. spec->stream_name_digital = "ALC662 Digital";
  10369. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10370. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10371. if (!spec->adc_nids && spec->input_mux) {
  10372. spec->adc_nids = alc662_adc_nids;
  10373. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10374. }
  10375. codec->patch_ops = alc_patch_ops;
  10376. if (board_config == ALC662_AUTO)
  10377. spec->init_hook = alc662_auto_init;
  10378. return 0;
  10379. }
  10380. /*
  10381. * patch entries
  10382. */
  10383. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10384. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10385. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10386. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10387. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10388. .patch = patch_alc861 },
  10389. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10390. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10391. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10392. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10393. .patch = patch_alc883 },
  10394. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10395. .patch = patch_alc662 },
  10396. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10397. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10398. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10399. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10400. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10401. {} /* terminator */
  10402. };