patch_realtek.c 382 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540
  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. * Line-In: 0x1b
  1721. * HP-Out: 0x1a
  1722. * SPDIF-Out: 0x1e
  1723. */
  1724. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1725. .num_items = 3,
  1726. .items = {
  1727. { "Mic", 0x0 },
  1728. { "Internal Mic", 0x1 },
  1729. { "Line In", 0x2 },
  1730. },
  1731. };
  1732. #define alc880_lg_lw_modes alc880_threestack_modes
  1733. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1734. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1735. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1736. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1737. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1738. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1739. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1740. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1741. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1742. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1743. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1744. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1745. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1746. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1747. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1748. {
  1749. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1750. .name = "Channel Mode",
  1751. .info = alc_ch_mode_info,
  1752. .get = alc_ch_mode_get,
  1753. .put = alc_ch_mode_put,
  1754. },
  1755. { } /* end */
  1756. };
  1757. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1758. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1759. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1760. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1761. /* set capture source to mic-in */
  1762. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1763. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1764. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1765. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1766. /* speaker-out */
  1767. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1768. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1769. /* HP-out */
  1770. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1771. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1772. /* mic-in to input */
  1773. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1774. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1775. /* built-in mic */
  1776. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1777. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1778. /* jack sense */
  1779. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1780. { }
  1781. };
  1782. /* toggle speaker-output according to the hp-jack state */
  1783. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1784. {
  1785. unsigned int present;
  1786. unsigned char bits;
  1787. present = snd_hda_codec_read(codec, 0x1b, 0,
  1788. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1789. bits = present ? 0x80 : 0;
  1790. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1791. 0x80, bits);
  1792. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1793. 0x80, bits);
  1794. }
  1795. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1796. {
  1797. /* Looks like the unsol event is incompatible with the standard
  1798. * definition. 4bit tag is placed at 28 bit!
  1799. */
  1800. if ((res >> 28) == 0x01)
  1801. alc880_lg_lw_automute(codec);
  1802. }
  1803. /*
  1804. * Common callbacks
  1805. */
  1806. static int alc_init(struct hda_codec *codec)
  1807. {
  1808. struct alc_spec *spec = codec->spec;
  1809. unsigned int i;
  1810. for (i = 0; i < spec->num_init_verbs; i++)
  1811. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1812. if (spec->init_hook)
  1813. spec->init_hook(codec);
  1814. return 0;
  1815. }
  1816. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1817. {
  1818. struct alc_spec *spec = codec->spec;
  1819. if (spec->unsol_event)
  1820. spec->unsol_event(codec, res);
  1821. }
  1822. #ifdef CONFIG_PM
  1823. /*
  1824. * resume
  1825. */
  1826. static int alc_resume(struct hda_codec *codec)
  1827. {
  1828. struct alc_spec *spec = codec->spec;
  1829. int i;
  1830. alc_init(codec);
  1831. for (i = 0; i < spec->num_mixers; i++)
  1832. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1833. if (spec->multiout.dig_out_nid)
  1834. snd_hda_resume_spdif_out(codec);
  1835. if (spec->dig_in_nid)
  1836. snd_hda_resume_spdif_in(codec);
  1837. return 0;
  1838. }
  1839. #endif
  1840. /*
  1841. * Analog playback callbacks
  1842. */
  1843. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1844. struct hda_codec *codec,
  1845. struct snd_pcm_substream *substream)
  1846. {
  1847. struct alc_spec *spec = codec->spec;
  1848. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1849. }
  1850. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1851. struct hda_codec *codec,
  1852. unsigned int stream_tag,
  1853. unsigned int format,
  1854. struct snd_pcm_substream *substream)
  1855. {
  1856. struct alc_spec *spec = codec->spec;
  1857. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1858. stream_tag, format, substream);
  1859. }
  1860. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1861. struct hda_codec *codec,
  1862. struct snd_pcm_substream *substream)
  1863. {
  1864. struct alc_spec *spec = codec->spec;
  1865. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1866. }
  1867. /*
  1868. * Digital out
  1869. */
  1870. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1871. struct hda_codec *codec,
  1872. struct snd_pcm_substream *substream)
  1873. {
  1874. struct alc_spec *spec = codec->spec;
  1875. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1876. }
  1877. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1878. struct hda_codec *codec,
  1879. unsigned int stream_tag,
  1880. unsigned int format,
  1881. struct snd_pcm_substream *substream)
  1882. {
  1883. struct alc_spec *spec = codec->spec;
  1884. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1885. stream_tag, format, substream);
  1886. }
  1887. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1888. struct hda_codec *codec,
  1889. struct snd_pcm_substream *substream)
  1890. {
  1891. struct alc_spec *spec = codec->spec;
  1892. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1893. }
  1894. /*
  1895. * Analog capture
  1896. */
  1897. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1898. struct hda_codec *codec,
  1899. unsigned int stream_tag,
  1900. unsigned int format,
  1901. struct snd_pcm_substream *substream)
  1902. {
  1903. struct alc_spec *spec = codec->spec;
  1904. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1905. stream_tag, 0, format);
  1906. return 0;
  1907. }
  1908. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1909. struct hda_codec *codec,
  1910. struct snd_pcm_substream *substream)
  1911. {
  1912. struct alc_spec *spec = codec->spec;
  1913. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1914. 0, 0, 0);
  1915. return 0;
  1916. }
  1917. /*
  1918. */
  1919. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1920. .substreams = 1,
  1921. .channels_min = 2,
  1922. .channels_max = 8,
  1923. /* NID is set in alc_build_pcms */
  1924. .ops = {
  1925. .open = alc880_playback_pcm_open,
  1926. .prepare = alc880_playback_pcm_prepare,
  1927. .cleanup = alc880_playback_pcm_cleanup
  1928. },
  1929. };
  1930. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1931. .substreams = 2,
  1932. .channels_min = 2,
  1933. .channels_max = 2,
  1934. /* NID is set in alc_build_pcms */
  1935. .ops = {
  1936. .prepare = alc880_capture_pcm_prepare,
  1937. .cleanup = alc880_capture_pcm_cleanup
  1938. },
  1939. };
  1940. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1941. .substreams = 1,
  1942. .channels_min = 2,
  1943. .channels_max = 2,
  1944. /* NID is set in alc_build_pcms */
  1945. .ops = {
  1946. .open = alc880_dig_playback_pcm_open,
  1947. .close = alc880_dig_playback_pcm_close,
  1948. .prepare = alc880_dig_playback_pcm_prepare
  1949. },
  1950. };
  1951. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1952. .substreams = 1,
  1953. .channels_min = 2,
  1954. .channels_max = 2,
  1955. /* NID is set in alc_build_pcms */
  1956. };
  1957. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1958. static struct hda_pcm_stream alc_pcm_null_playback = {
  1959. .substreams = 0,
  1960. .channels_min = 0,
  1961. .channels_max = 0,
  1962. };
  1963. static int alc_build_pcms(struct hda_codec *codec)
  1964. {
  1965. struct alc_spec *spec = codec->spec;
  1966. struct hda_pcm *info = spec->pcm_rec;
  1967. int i;
  1968. codec->num_pcms = 1;
  1969. codec->pcm_info = info;
  1970. info->name = spec->stream_name_analog;
  1971. if (spec->stream_analog_playback) {
  1972. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1973. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1974. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1975. }
  1976. if (spec->stream_analog_capture) {
  1977. snd_assert(spec->adc_nids, return -EINVAL);
  1978. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1979. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1980. }
  1981. if (spec->channel_mode) {
  1982. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1983. for (i = 0; i < spec->num_channel_mode; i++) {
  1984. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1985. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1986. }
  1987. }
  1988. }
  1989. /* SPDIF for stream index #1 */
  1990. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1991. codec->num_pcms = 2;
  1992. info = spec->pcm_rec + 1;
  1993. info->name = spec->stream_name_digital;
  1994. if (spec->multiout.dig_out_nid &&
  1995. spec->stream_digital_playback) {
  1996. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1997. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1998. }
  1999. if (spec->dig_in_nid &&
  2000. spec->stream_digital_capture) {
  2001. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  2002. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  2003. }
  2004. }
  2005. /* If the use of more than one ADC is requested for the current
  2006. * model, configure a second analog capture-only PCM.
  2007. */
  2008. /* Additional Analaog capture for index #2 */
  2009. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  2010. spec->adc_nids) {
  2011. codec->num_pcms = 3;
  2012. info = spec->pcm_rec + 2;
  2013. info->name = spec->stream_name_analog;
  2014. /* No playback stream for second PCM */
  2015. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2016. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2017. if (spec->stream_analog_capture) {
  2018. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2019. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2020. }
  2021. }
  2022. return 0;
  2023. }
  2024. static void alc_free(struct hda_codec *codec)
  2025. {
  2026. struct alc_spec *spec = codec->spec;
  2027. unsigned int i;
  2028. if (!spec)
  2029. return;
  2030. if (spec->kctl_alloc) {
  2031. for (i = 0; i < spec->num_kctl_used; i++)
  2032. kfree(spec->kctl_alloc[i].name);
  2033. kfree(spec->kctl_alloc);
  2034. }
  2035. kfree(spec);
  2036. }
  2037. /*
  2038. */
  2039. static struct hda_codec_ops alc_patch_ops = {
  2040. .build_controls = alc_build_controls,
  2041. .build_pcms = alc_build_pcms,
  2042. .init = alc_init,
  2043. .free = alc_free,
  2044. .unsol_event = alc_unsol_event,
  2045. #ifdef CONFIG_PM
  2046. .resume = alc_resume,
  2047. #endif
  2048. };
  2049. /*
  2050. * Test configuration for debugging
  2051. *
  2052. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2053. * enum controls.
  2054. */
  2055. #ifdef CONFIG_SND_DEBUG
  2056. static hda_nid_t alc880_test_dac_nids[4] = {
  2057. 0x02, 0x03, 0x04, 0x05
  2058. };
  2059. static struct hda_input_mux alc880_test_capture_source = {
  2060. .num_items = 7,
  2061. .items = {
  2062. { "In-1", 0x0 },
  2063. { "In-2", 0x1 },
  2064. { "In-3", 0x2 },
  2065. { "In-4", 0x3 },
  2066. { "CD", 0x4 },
  2067. { "Front", 0x5 },
  2068. { "Surround", 0x6 },
  2069. },
  2070. };
  2071. static struct hda_channel_mode alc880_test_modes[4] = {
  2072. { 2, NULL },
  2073. { 4, NULL },
  2074. { 6, NULL },
  2075. { 8, NULL },
  2076. };
  2077. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2078. struct snd_ctl_elem_info *uinfo)
  2079. {
  2080. static char *texts[] = {
  2081. "N/A", "Line Out", "HP Out",
  2082. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2083. };
  2084. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2085. uinfo->count = 1;
  2086. uinfo->value.enumerated.items = 8;
  2087. if (uinfo->value.enumerated.item >= 8)
  2088. uinfo->value.enumerated.item = 7;
  2089. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2090. return 0;
  2091. }
  2092. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2093. struct snd_ctl_elem_value *ucontrol)
  2094. {
  2095. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2096. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2097. unsigned int pin_ctl, item = 0;
  2098. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2099. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2100. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2101. if (pin_ctl & AC_PINCTL_HP_EN)
  2102. item = 2;
  2103. else
  2104. item = 1;
  2105. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2106. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2107. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2108. case AC_PINCTL_VREF_50: item = 4; break;
  2109. case AC_PINCTL_VREF_GRD: item = 5; break;
  2110. case AC_PINCTL_VREF_80: item = 6; break;
  2111. case AC_PINCTL_VREF_100: item = 7; break;
  2112. }
  2113. }
  2114. ucontrol->value.enumerated.item[0] = item;
  2115. return 0;
  2116. }
  2117. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2118. struct snd_ctl_elem_value *ucontrol)
  2119. {
  2120. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2121. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2122. static unsigned int ctls[] = {
  2123. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2124. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2125. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2126. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2127. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2128. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2129. };
  2130. unsigned int old_ctl, new_ctl;
  2131. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2132. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2133. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2134. if (old_ctl != new_ctl) {
  2135. snd_hda_codec_write(codec, nid, 0,
  2136. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2137. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2138. (ucontrol->value.enumerated.item[0] >= 3 ?
  2139. 0xb080 : 0xb000));
  2140. return 1;
  2141. }
  2142. return 0;
  2143. }
  2144. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2145. struct snd_ctl_elem_info *uinfo)
  2146. {
  2147. static char *texts[] = {
  2148. "Front", "Surround", "CLFE", "Side"
  2149. };
  2150. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2151. uinfo->count = 1;
  2152. uinfo->value.enumerated.items = 4;
  2153. if (uinfo->value.enumerated.item >= 4)
  2154. uinfo->value.enumerated.item = 3;
  2155. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2156. return 0;
  2157. }
  2158. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2159. struct snd_ctl_elem_value *ucontrol)
  2160. {
  2161. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2162. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2163. unsigned int sel;
  2164. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2165. ucontrol->value.enumerated.item[0] = sel & 3;
  2166. return 0;
  2167. }
  2168. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2169. struct snd_ctl_elem_value *ucontrol)
  2170. {
  2171. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2172. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2173. unsigned int sel;
  2174. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2175. if (ucontrol->value.enumerated.item[0] != sel) {
  2176. sel = ucontrol->value.enumerated.item[0] & 3;
  2177. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2178. return 1;
  2179. }
  2180. return 0;
  2181. }
  2182. #define PIN_CTL_TEST(xname,nid) { \
  2183. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2184. .name = xname, \
  2185. .info = alc_test_pin_ctl_info, \
  2186. .get = alc_test_pin_ctl_get, \
  2187. .put = alc_test_pin_ctl_put, \
  2188. .private_value = nid \
  2189. }
  2190. #define PIN_SRC_TEST(xname,nid) { \
  2191. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2192. .name = xname, \
  2193. .info = alc_test_pin_src_info, \
  2194. .get = alc_test_pin_src_get, \
  2195. .put = alc_test_pin_src_put, \
  2196. .private_value = nid \
  2197. }
  2198. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2199. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2200. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2201. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2202. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2203. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2204. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2205. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2206. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2207. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2208. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2209. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2210. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2211. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2212. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2213. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2214. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2215. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2216. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2217. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2218. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2219. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2220. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2221. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2222. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2223. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2224. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2225. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2226. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2227. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2228. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2229. {
  2230. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2231. .name = "Channel Mode",
  2232. .info = alc_ch_mode_info,
  2233. .get = alc_ch_mode_get,
  2234. .put = alc_ch_mode_put,
  2235. },
  2236. { } /* end */
  2237. };
  2238. static struct hda_verb alc880_test_init_verbs[] = {
  2239. /* Unmute inputs of 0x0c - 0x0f */
  2240. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2241. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2242. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2243. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2244. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2245. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2246. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2247. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2248. /* Vol output for 0x0c-0x0f */
  2249. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2250. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2251. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2252. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2253. /* Set output pins 0x14-0x17 */
  2254. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2255. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2256. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2257. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2258. /* Unmute output pins 0x14-0x17 */
  2259. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2260. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2261. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2262. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2263. /* Set input pins 0x18-0x1c */
  2264. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2265. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2266. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2267. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2268. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2269. /* Mute input pins 0x18-0x1b */
  2270. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2271. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2272. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2273. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2274. /* ADC set up */
  2275. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2276. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2277. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2278. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2279. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2280. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2281. /* Analog input/passthru */
  2282. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2283. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2284. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2285. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2286. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2287. { }
  2288. };
  2289. #endif
  2290. /*
  2291. */
  2292. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2293. [ALC880_3ST] = "3stack",
  2294. [ALC880_TCL_S700] = "tcl",
  2295. [ALC880_3ST_DIG] = "3stack-digout",
  2296. [ALC880_CLEVO] = "clevo",
  2297. [ALC880_5ST] = "5stack",
  2298. [ALC880_5ST_DIG] = "5stack-digout",
  2299. [ALC880_W810] = "w810",
  2300. [ALC880_Z71V] = "z71v",
  2301. [ALC880_6ST] = "6stack",
  2302. [ALC880_6ST_DIG] = "6stack-digout",
  2303. [ALC880_ASUS] = "asus",
  2304. [ALC880_ASUS_W1V] = "asus-w1v",
  2305. [ALC880_ASUS_DIG] = "asus-dig",
  2306. [ALC880_ASUS_DIG2] = "asus-dig2",
  2307. [ALC880_UNIWILL_DIG] = "uniwill",
  2308. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2309. [ALC880_FUJITSU] = "fujitsu",
  2310. [ALC880_F1734] = "F1734",
  2311. [ALC880_LG] = "lg",
  2312. [ALC880_LG_LW] = "lg-lw",
  2313. #ifdef CONFIG_SND_DEBUG
  2314. [ALC880_TEST] = "test",
  2315. #endif
  2316. [ALC880_AUTO] = "auto",
  2317. };
  2318. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2319. /* Broken BIOS configuration */
  2320. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2321. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2322. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2323. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2324. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2325. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2326. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2327. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2328. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2329. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2330. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2331. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2332. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2333. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2334. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2335. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2336. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2337. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2338. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2339. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2340. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2341. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2342. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2343. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2344. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2345. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2346. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2347. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2348. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2349. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2350. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2351. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2352. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2353. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2354. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2355. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2356. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2357. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2358. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2359. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2360. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2361. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2362. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2363. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2364. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2365. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2366. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2367. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2368. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2369. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2370. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2371. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2372. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2373. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2374. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2375. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2376. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2377. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2378. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2379. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2380. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2381. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2382. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2383. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2384. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2385. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2386. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2387. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2388. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2389. {}
  2390. };
  2391. /*
  2392. * ALC880 codec presets
  2393. */
  2394. static struct alc_config_preset alc880_presets[] = {
  2395. [ALC880_3ST] = {
  2396. .mixers = { alc880_three_stack_mixer },
  2397. .init_verbs = { alc880_volume_init_verbs,
  2398. alc880_pin_3stack_init_verbs },
  2399. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2400. .dac_nids = alc880_dac_nids,
  2401. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2402. .channel_mode = alc880_threestack_modes,
  2403. .need_dac_fix = 1,
  2404. .input_mux = &alc880_capture_source,
  2405. },
  2406. [ALC880_3ST_DIG] = {
  2407. .mixers = { alc880_three_stack_mixer },
  2408. .init_verbs = { alc880_volume_init_verbs,
  2409. alc880_pin_3stack_init_verbs },
  2410. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2411. .dac_nids = alc880_dac_nids,
  2412. .dig_out_nid = ALC880_DIGOUT_NID,
  2413. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2414. .channel_mode = alc880_threestack_modes,
  2415. .need_dac_fix = 1,
  2416. .input_mux = &alc880_capture_source,
  2417. },
  2418. [ALC880_TCL_S700] = {
  2419. .mixers = { alc880_tcl_s700_mixer },
  2420. .init_verbs = { alc880_volume_init_verbs,
  2421. alc880_pin_tcl_S700_init_verbs,
  2422. alc880_gpio2_init_verbs },
  2423. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2424. .dac_nids = alc880_dac_nids,
  2425. .hp_nid = 0x03,
  2426. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2427. .channel_mode = alc880_2_jack_modes,
  2428. .input_mux = &alc880_capture_source,
  2429. },
  2430. [ALC880_5ST] = {
  2431. .mixers = { alc880_three_stack_mixer,
  2432. alc880_five_stack_mixer},
  2433. .init_verbs = { alc880_volume_init_verbs,
  2434. alc880_pin_5stack_init_verbs },
  2435. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2436. .dac_nids = alc880_dac_nids,
  2437. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2438. .channel_mode = alc880_fivestack_modes,
  2439. .input_mux = &alc880_capture_source,
  2440. },
  2441. [ALC880_5ST_DIG] = {
  2442. .mixers = { alc880_three_stack_mixer,
  2443. alc880_five_stack_mixer },
  2444. .init_verbs = { alc880_volume_init_verbs,
  2445. alc880_pin_5stack_init_verbs },
  2446. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2447. .dac_nids = alc880_dac_nids,
  2448. .dig_out_nid = ALC880_DIGOUT_NID,
  2449. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2450. .channel_mode = alc880_fivestack_modes,
  2451. .input_mux = &alc880_capture_source,
  2452. },
  2453. [ALC880_6ST] = {
  2454. .mixers = { alc880_six_stack_mixer },
  2455. .init_verbs = { alc880_volume_init_verbs,
  2456. alc880_pin_6stack_init_verbs },
  2457. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2458. .dac_nids = alc880_6st_dac_nids,
  2459. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2460. .channel_mode = alc880_sixstack_modes,
  2461. .input_mux = &alc880_6stack_capture_source,
  2462. },
  2463. [ALC880_6ST_DIG] = {
  2464. .mixers = { alc880_six_stack_mixer },
  2465. .init_verbs = { alc880_volume_init_verbs,
  2466. alc880_pin_6stack_init_verbs },
  2467. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2468. .dac_nids = alc880_6st_dac_nids,
  2469. .dig_out_nid = ALC880_DIGOUT_NID,
  2470. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2471. .channel_mode = alc880_sixstack_modes,
  2472. .input_mux = &alc880_6stack_capture_source,
  2473. },
  2474. [ALC880_W810] = {
  2475. .mixers = { alc880_w810_base_mixer },
  2476. .init_verbs = { alc880_volume_init_verbs,
  2477. alc880_pin_w810_init_verbs,
  2478. alc880_gpio2_init_verbs },
  2479. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2480. .dac_nids = alc880_w810_dac_nids,
  2481. .dig_out_nid = ALC880_DIGOUT_NID,
  2482. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2483. .channel_mode = alc880_w810_modes,
  2484. .input_mux = &alc880_capture_source,
  2485. },
  2486. [ALC880_Z71V] = {
  2487. .mixers = { alc880_z71v_mixer },
  2488. .init_verbs = { alc880_volume_init_verbs,
  2489. alc880_pin_z71v_init_verbs },
  2490. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2491. .dac_nids = alc880_z71v_dac_nids,
  2492. .dig_out_nid = ALC880_DIGOUT_NID,
  2493. .hp_nid = 0x03,
  2494. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2495. .channel_mode = alc880_2_jack_modes,
  2496. .input_mux = &alc880_capture_source,
  2497. },
  2498. [ALC880_F1734] = {
  2499. .mixers = { alc880_f1734_mixer },
  2500. .init_verbs = { alc880_volume_init_verbs,
  2501. alc880_pin_f1734_init_verbs },
  2502. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2503. .dac_nids = alc880_f1734_dac_nids,
  2504. .hp_nid = 0x02,
  2505. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2506. .channel_mode = alc880_2_jack_modes,
  2507. .input_mux = &alc880_capture_source,
  2508. },
  2509. [ALC880_ASUS] = {
  2510. .mixers = { alc880_asus_mixer },
  2511. .init_verbs = { alc880_volume_init_verbs,
  2512. alc880_pin_asus_init_verbs,
  2513. alc880_gpio1_init_verbs },
  2514. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2515. .dac_nids = alc880_asus_dac_nids,
  2516. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2517. .channel_mode = alc880_asus_modes,
  2518. .need_dac_fix = 1,
  2519. .input_mux = &alc880_capture_source,
  2520. },
  2521. [ALC880_ASUS_DIG] = {
  2522. .mixers = { alc880_asus_mixer },
  2523. .init_verbs = { alc880_volume_init_verbs,
  2524. alc880_pin_asus_init_verbs,
  2525. alc880_gpio1_init_verbs },
  2526. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2527. .dac_nids = alc880_asus_dac_nids,
  2528. .dig_out_nid = ALC880_DIGOUT_NID,
  2529. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2530. .channel_mode = alc880_asus_modes,
  2531. .need_dac_fix = 1,
  2532. .input_mux = &alc880_capture_source,
  2533. },
  2534. [ALC880_ASUS_DIG2] = {
  2535. .mixers = { alc880_asus_mixer },
  2536. .init_verbs = { alc880_volume_init_verbs,
  2537. alc880_pin_asus_init_verbs,
  2538. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2539. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2540. .dac_nids = alc880_asus_dac_nids,
  2541. .dig_out_nid = ALC880_DIGOUT_NID,
  2542. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2543. .channel_mode = alc880_asus_modes,
  2544. .need_dac_fix = 1,
  2545. .input_mux = &alc880_capture_source,
  2546. },
  2547. [ALC880_ASUS_W1V] = {
  2548. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2549. .init_verbs = { alc880_volume_init_verbs,
  2550. alc880_pin_asus_init_verbs,
  2551. alc880_gpio1_init_verbs },
  2552. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2553. .dac_nids = alc880_asus_dac_nids,
  2554. .dig_out_nid = ALC880_DIGOUT_NID,
  2555. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2556. .channel_mode = alc880_asus_modes,
  2557. .need_dac_fix = 1,
  2558. .input_mux = &alc880_capture_source,
  2559. },
  2560. [ALC880_UNIWILL_DIG] = {
  2561. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2562. .init_verbs = { alc880_volume_init_verbs,
  2563. alc880_pin_asus_init_verbs },
  2564. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2565. .dac_nids = alc880_asus_dac_nids,
  2566. .dig_out_nid = ALC880_DIGOUT_NID,
  2567. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2568. .channel_mode = alc880_asus_modes,
  2569. .need_dac_fix = 1,
  2570. .input_mux = &alc880_capture_source,
  2571. },
  2572. [ALC880_UNIWILL] = {
  2573. .mixers = { alc880_uniwill_mixer },
  2574. .init_verbs = { alc880_volume_init_verbs,
  2575. alc880_uniwill_init_verbs },
  2576. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2577. .dac_nids = alc880_asus_dac_nids,
  2578. .dig_out_nid = ALC880_DIGOUT_NID,
  2579. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2580. .channel_mode = alc880_threestack_modes,
  2581. .need_dac_fix = 1,
  2582. .input_mux = &alc880_capture_source,
  2583. .unsol_event = alc880_uniwill_unsol_event,
  2584. .init_hook = alc880_uniwill_automute,
  2585. },
  2586. [ALC880_UNIWILL_P53] = {
  2587. .mixers = { alc880_uniwill_p53_mixer },
  2588. .init_verbs = { alc880_volume_init_verbs,
  2589. alc880_uniwill_p53_init_verbs },
  2590. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2591. .dac_nids = alc880_asus_dac_nids,
  2592. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2593. .channel_mode = alc880_threestack_modes,
  2594. .input_mux = &alc880_capture_source,
  2595. .unsol_event = alc880_uniwill_p53_unsol_event,
  2596. .init_hook = alc880_uniwill_p53_hp_automute,
  2597. },
  2598. [ALC880_FUJITSU] = {
  2599. .mixers = { alc880_fujitsu_mixer,
  2600. alc880_pcbeep_mixer, },
  2601. .init_verbs = { alc880_volume_init_verbs,
  2602. alc880_uniwill_p53_init_verbs,
  2603. alc880_beep_init_verbs },
  2604. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2605. .dac_nids = alc880_dac_nids,
  2606. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2607. .channel_mode = alc880_2_jack_modes,
  2608. .input_mux = &alc880_capture_source,
  2609. .unsol_event = alc880_uniwill_p53_unsol_event,
  2610. .init_hook = alc880_uniwill_p53_hp_automute,
  2611. },
  2612. [ALC880_CLEVO] = {
  2613. .mixers = { alc880_three_stack_mixer },
  2614. .init_verbs = { alc880_volume_init_verbs,
  2615. alc880_pin_clevo_init_verbs },
  2616. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2617. .dac_nids = alc880_dac_nids,
  2618. .hp_nid = 0x03,
  2619. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2620. .channel_mode = alc880_threestack_modes,
  2621. .need_dac_fix = 1,
  2622. .input_mux = &alc880_capture_source,
  2623. },
  2624. [ALC880_LG] = {
  2625. .mixers = { alc880_lg_mixer },
  2626. .init_verbs = { alc880_volume_init_verbs,
  2627. alc880_lg_init_verbs },
  2628. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2629. .dac_nids = alc880_lg_dac_nids,
  2630. .dig_out_nid = ALC880_DIGOUT_NID,
  2631. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2632. .channel_mode = alc880_lg_ch_modes,
  2633. .need_dac_fix = 1,
  2634. .input_mux = &alc880_lg_capture_source,
  2635. .unsol_event = alc880_lg_unsol_event,
  2636. .init_hook = alc880_lg_automute,
  2637. },
  2638. [ALC880_LG_LW] = {
  2639. .mixers = { alc880_lg_lw_mixer },
  2640. .init_verbs = { alc880_volume_init_verbs,
  2641. alc880_lg_lw_init_verbs },
  2642. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2643. .dac_nids = alc880_dac_nids,
  2644. .dig_out_nid = ALC880_DIGOUT_NID,
  2645. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2646. .channel_mode = alc880_lg_lw_modes,
  2647. .input_mux = &alc880_lg_lw_capture_source,
  2648. .unsol_event = alc880_lg_lw_unsol_event,
  2649. .init_hook = alc880_lg_lw_automute,
  2650. },
  2651. #ifdef CONFIG_SND_DEBUG
  2652. [ALC880_TEST] = {
  2653. .mixers = { alc880_test_mixer },
  2654. .init_verbs = { alc880_test_init_verbs },
  2655. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2656. .dac_nids = alc880_test_dac_nids,
  2657. .dig_out_nid = ALC880_DIGOUT_NID,
  2658. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2659. .channel_mode = alc880_test_modes,
  2660. .input_mux = &alc880_test_capture_source,
  2661. },
  2662. #endif
  2663. };
  2664. /*
  2665. * Automatic parse of I/O pins from the BIOS configuration
  2666. */
  2667. #define NUM_CONTROL_ALLOC 32
  2668. #define NUM_VERB_ALLOC 32
  2669. enum {
  2670. ALC_CTL_WIDGET_VOL,
  2671. ALC_CTL_WIDGET_MUTE,
  2672. ALC_CTL_BIND_MUTE,
  2673. };
  2674. static struct snd_kcontrol_new alc880_control_templates[] = {
  2675. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2676. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2677. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2678. };
  2679. /* add dynamic controls */
  2680. static int add_control(struct alc_spec *spec, int type, const char *name,
  2681. unsigned long val)
  2682. {
  2683. struct snd_kcontrol_new *knew;
  2684. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2685. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2686. /* array + terminator */
  2687. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2688. if (!knew)
  2689. return -ENOMEM;
  2690. if (spec->kctl_alloc) {
  2691. memcpy(knew, spec->kctl_alloc,
  2692. sizeof(*knew) * spec->num_kctl_alloc);
  2693. kfree(spec->kctl_alloc);
  2694. }
  2695. spec->kctl_alloc = knew;
  2696. spec->num_kctl_alloc = num;
  2697. }
  2698. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2699. *knew = alc880_control_templates[type];
  2700. knew->name = kstrdup(name, GFP_KERNEL);
  2701. if (!knew->name)
  2702. return -ENOMEM;
  2703. knew->private_value = val;
  2704. spec->num_kctl_used++;
  2705. return 0;
  2706. }
  2707. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2708. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2709. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2710. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2711. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2712. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2713. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2714. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2715. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2716. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2717. #define ALC880_PIN_CD_NID 0x1c
  2718. /* fill in the dac_nids table from the parsed pin configuration */
  2719. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2720. const struct auto_pin_cfg *cfg)
  2721. {
  2722. hda_nid_t nid;
  2723. int assigned[4];
  2724. int i, j;
  2725. memset(assigned, 0, sizeof(assigned));
  2726. spec->multiout.dac_nids = spec->private_dac_nids;
  2727. /* check the pins hardwired to audio widget */
  2728. for (i = 0; i < cfg->line_outs; i++) {
  2729. nid = cfg->line_out_pins[i];
  2730. if (alc880_is_fixed_pin(nid)) {
  2731. int idx = alc880_fixed_pin_idx(nid);
  2732. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2733. assigned[idx] = 1;
  2734. }
  2735. }
  2736. /* left pins can be connect to any audio widget */
  2737. for (i = 0; i < cfg->line_outs; i++) {
  2738. nid = cfg->line_out_pins[i];
  2739. if (alc880_is_fixed_pin(nid))
  2740. continue;
  2741. /* search for an empty channel */
  2742. for (j = 0; j < cfg->line_outs; j++) {
  2743. if (!assigned[j]) {
  2744. spec->multiout.dac_nids[i] =
  2745. alc880_idx_to_dac(j);
  2746. assigned[j] = 1;
  2747. break;
  2748. }
  2749. }
  2750. }
  2751. spec->multiout.num_dacs = cfg->line_outs;
  2752. return 0;
  2753. }
  2754. /* add playback controls from the parsed DAC table */
  2755. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2756. const struct auto_pin_cfg *cfg)
  2757. {
  2758. char name[32];
  2759. static const char *chname[4] = {
  2760. "Front", "Surround", NULL /*CLFE*/, "Side"
  2761. };
  2762. hda_nid_t nid;
  2763. int i, err;
  2764. for (i = 0; i < cfg->line_outs; i++) {
  2765. if (!spec->multiout.dac_nids[i])
  2766. continue;
  2767. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2768. if (i == 2) {
  2769. /* Center/LFE */
  2770. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2771. "Center Playback Volume",
  2772. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2773. HDA_OUTPUT));
  2774. if (err < 0)
  2775. return err;
  2776. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2777. "LFE Playback Volume",
  2778. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2779. HDA_OUTPUT));
  2780. if (err < 0)
  2781. return err;
  2782. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2783. "Center Playback Switch",
  2784. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2785. HDA_INPUT));
  2786. if (err < 0)
  2787. return err;
  2788. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2789. "LFE Playback Switch",
  2790. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2791. HDA_INPUT));
  2792. if (err < 0)
  2793. return err;
  2794. } else {
  2795. sprintf(name, "%s Playback Volume", chname[i]);
  2796. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2797. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2798. HDA_OUTPUT));
  2799. if (err < 0)
  2800. return err;
  2801. sprintf(name, "%s Playback Switch", chname[i]);
  2802. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2803. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2804. HDA_INPUT));
  2805. if (err < 0)
  2806. return err;
  2807. }
  2808. }
  2809. return 0;
  2810. }
  2811. /* add playback controls for speaker and HP outputs */
  2812. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2813. const char *pfx)
  2814. {
  2815. hda_nid_t nid;
  2816. int err;
  2817. char name[32];
  2818. if (!pin)
  2819. return 0;
  2820. if (alc880_is_fixed_pin(pin)) {
  2821. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2822. /* specify the DAC as the extra output */
  2823. if (!spec->multiout.hp_nid)
  2824. spec->multiout.hp_nid = nid;
  2825. else
  2826. spec->multiout.extra_out_nid[0] = nid;
  2827. /* control HP volume/switch on the output mixer amp */
  2828. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2829. sprintf(name, "%s Playback Volume", pfx);
  2830. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2831. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2832. if (err < 0)
  2833. return err;
  2834. sprintf(name, "%s Playback Switch", pfx);
  2835. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2836. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2837. if (err < 0)
  2838. return err;
  2839. } else if (alc880_is_multi_pin(pin)) {
  2840. /* set manual connection */
  2841. /* we have only a switch on HP-out PIN */
  2842. sprintf(name, "%s Playback Switch", pfx);
  2843. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2844. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2845. if (err < 0)
  2846. return err;
  2847. }
  2848. return 0;
  2849. }
  2850. /* create input playback/capture controls for the given pin */
  2851. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2852. const char *ctlname,
  2853. int idx, hda_nid_t mix_nid)
  2854. {
  2855. char name[32];
  2856. int err;
  2857. sprintf(name, "%s Playback Volume", ctlname);
  2858. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2859. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2860. if (err < 0)
  2861. return err;
  2862. sprintf(name, "%s Playback Switch", ctlname);
  2863. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2864. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2865. if (err < 0)
  2866. return err;
  2867. return 0;
  2868. }
  2869. /* create playback/capture controls for input pins */
  2870. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2871. const struct auto_pin_cfg *cfg)
  2872. {
  2873. struct hda_input_mux *imux = &spec->private_imux;
  2874. int i, err, idx;
  2875. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2876. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2877. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2878. err = new_analog_input(spec, cfg->input_pins[i],
  2879. auto_pin_cfg_labels[i],
  2880. idx, 0x0b);
  2881. if (err < 0)
  2882. return err;
  2883. imux->items[imux->num_items].label =
  2884. auto_pin_cfg_labels[i];
  2885. imux->items[imux->num_items].index =
  2886. alc880_input_pin_idx(cfg->input_pins[i]);
  2887. imux->num_items++;
  2888. }
  2889. }
  2890. return 0;
  2891. }
  2892. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2893. hda_nid_t nid, int pin_type,
  2894. int dac_idx)
  2895. {
  2896. /* set as output */
  2897. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2898. pin_type);
  2899. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2900. AMP_OUT_UNMUTE);
  2901. /* need the manual connection? */
  2902. if (alc880_is_multi_pin(nid)) {
  2903. struct alc_spec *spec = codec->spec;
  2904. int idx = alc880_multi_pin_idx(nid);
  2905. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2906. AC_VERB_SET_CONNECT_SEL,
  2907. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2908. }
  2909. }
  2910. static int get_pin_type(int line_out_type)
  2911. {
  2912. if (line_out_type == AUTO_PIN_HP_OUT)
  2913. return PIN_HP;
  2914. else
  2915. return PIN_OUT;
  2916. }
  2917. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2918. {
  2919. struct alc_spec *spec = codec->spec;
  2920. int i;
  2921. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2922. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2923. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2924. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2925. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2926. }
  2927. }
  2928. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2929. {
  2930. struct alc_spec *spec = codec->spec;
  2931. hda_nid_t pin;
  2932. pin = spec->autocfg.speaker_pins[0];
  2933. if (pin) /* connect to front */
  2934. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2935. pin = spec->autocfg.hp_pins[0];
  2936. if (pin) /* connect to front */
  2937. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2938. }
  2939. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2940. {
  2941. struct alc_spec *spec = codec->spec;
  2942. int i;
  2943. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2944. hda_nid_t nid = spec->autocfg.input_pins[i];
  2945. if (alc880_is_input_pin(nid)) {
  2946. snd_hda_codec_write(codec, nid, 0,
  2947. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2948. i <= AUTO_PIN_FRONT_MIC ?
  2949. PIN_VREF80 : PIN_IN);
  2950. if (nid != ALC880_PIN_CD_NID)
  2951. snd_hda_codec_write(codec, nid, 0,
  2952. AC_VERB_SET_AMP_GAIN_MUTE,
  2953. AMP_OUT_MUTE);
  2954. }
  2955. }
  2956. }
  2957. /* parse the BIOS configuration and set up the alc_spec */
  2958. /* return 1 if successful, 0 if the proper config is not found,
  2959. * or a negative error code
  2960. */
  2961. static int alc880_parse_auto_config(struct hda_codec *codec)
  2962. {
  2963. struct alc_spec *spec = codec->spec;
  2964. int err;
  2965. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2966. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2967. alc880_ignore);
  2968. if (err < 0)
  2969. return err;
  2970. if (!spec->autocfg.line_outs)
  2971. return 0; /* can't find valid BIOS pin config */
  2972. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2973. if (err < 0)
  2974. return err;
  2975. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2976. if (err < 0)
  2977. return err;
  2978. err = alc880_auto_create_extra_out(spec,
  2979. spec->autocfg.speaker_pins[0],
  2980. "Speaker");
  2981. if (err < 0)
  2982. return err;
  2983. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2984. "Headphone");
  2985. if (err < 0)
  2986. return err;
  2987. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2988. if (err < 0)
  2989. return err;
  2990. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2991. if (spec->autocfg.dig_out_pin)
  2992. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2993. if (spec->autocfg.dig_in_pin)
  2994. spec->dig_in_nid = ALC880_DIGIN_NID;
  2995. if (spec->kctl_alloc)
  2996. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2997. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2998. spec->num_mux_defs = 1;
  2999. spec->input_mux = &spec->private_imux;
  3000. return 1;
  3001. }
  3002. /* additional initialization for auto-configuration model */
  3003. static void alc880_auto_init(struct hda_codec *codec)
  3004. {
  3005. alc880_auto_init_multi_out(codec);
  3006. alc880_auto_init_extra_out(codec);
  3007. alc880_auto_init_analog_input(codec);
  3008. }
  3009. /*
  3010. * OK, here we have finally the patch for ALC880
  3011. */
  3012. static int patch_alc880(struct hda_codec *codec)
  3013. {
  3014. struct alc_spec *spec;
  3015. int board_config;
  3016. int err;
  3017. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3018. if (spec == NULL)
  3019. return -ENOMEM;
  3020. codec->spec = spec;
  3021. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3022. alc880_models,
  3023. alc880_cfg_tbl);
  3024. if (board_config < 0) {
  3025. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3026. "trying auto-probe from BIOS...\n");
  3027. board_config = ALC880_AUTO;
  3028. }
  3029. if (board_config == ALC880_AUTO) {
  3030. /* automatic parse from the BIOS config */
  3031. err = alc880_parse_auto_config(codec);
  3032. if (err < 0) {
  3033. alc_free(codec);
  3034. return err;
  3035. } else if (!err) {
  3036. printk(KERN_INFO
  3037. "hda_codec: Cannot set up configuration "
  3038. "from BIOS. Using 3-stack mode...\n");
  3039. board_config = ALC880_3ST;
  3040. }
  3041. }
  3042. if (board_config != ALC880_AUTO)
  3043. setup_preset(spec, &alc880_presets[board_config]);
  3044. spec->stream_name_analog = "ALC880 Analog";
  3045. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3046. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3047. spec->stream_name_digital = "ALC880 Digital";
  3048. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3049. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3050. if (!spec->adc_nids && spec->input_mux) {
  3051. /* check whether NID 0x07 is valid */
  3052. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3053. /* get type */
  3054. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3055. if (wcap != AC_WID_AUD_IN) {
  3056. spec->adc_nids = alc880_adc_nids_alt;
  3057. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3058. spec->mixers[spec->num_mixers] =
  3059. alc880_capture_alt_mixer;
  3060. spec->num_mixers++;
  3061. } else {
  3062. spec->adc_nids = alc880_adc_nids;
  3063. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3064. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3065. spec->num_mixers++;
  3066. }
  3067. }
  3068. codec->patch_ops = alc_patch_ops;
  3069. if (board_config == ALC880_AUTO)
  3070. spec->init_hook = alc880_auto_init;
  3071. return 0;
  3072. }
  3073. /*
  3074. * ALC260 support
  3075. */
  3076. static hda_nid_t alc260_dac_nids[1] = {
  3077. /* front */
  3078. 0x02,
  3079. };
  3080. static hda_nid_t alc260_adc_nids[1] = {
  3081. /* ADC0 */
  3082. 0x04,
  3083. };
  3084. static hda_nid_t alc260_adc_nids_alt[1] = {
  3085. /* ADC1 */
  3086. 0x05,
  3087. };
  3088. static hda_nid_t alc260_hp_adc_nids[2] = {
  3089. /* ADC1, 0 */
  3090. 0x05, 0x04
  3091. };
  3092. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3093. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3094. */
  3095. static hda_nid_t alc260_dual_adc_nids[2] = {
  3096. /* ADC0, ADC1 */
  3097. 0x04, 0x05
  3098. };
  3099. #define ALC260_DIGOUT_NID 0x03
  3100. #define ALC260_DIGIN_NID 0x06
  3101. static struct hda_input_mux alc260_capture_source = {
  3102. .num_items = 4,
  3103. .items = {
  3104. { "Mic", 0x0 },
  3105. { "Front Mic", 0x1 },
  3106. { "Line", 0x2 },
  3107. { "CD", 0x4 },
  3108. },
  3109. };
  3110. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3111. * headphone jack and the internal CD lines since these are the only pins at
  3112. * which audio can appear. For flexibility, also allow the option of
  3113. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3114. * connection to the mixer output).
  3115. */
  3116. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3117. {
  3118. .num_items = 3,
  3119. .items = {
  3120. { "Mic/Line", 0x0 },
  3121. { "CD", 0x4 },
  3122. { "Headphone", 0x2 },
  3123. },
  3124. },
  3125. {
  3126. .num_items = 4,
  3127. .items = {
  3128. { "Mic/Line", 0x0 },
  3129. { "CD", 0x4 },
  3130. { "Headphone", 0x2 },
  3131. { "Mixer", 0x5 },
  3132. },
  3133. },
  3134. };
  3135. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3136. * the Fujitsu S702x, but jacks are marked differently.
  3137. */
  3138. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3139. {
  3140. .num_items = 4,
  3141. .items = {
  3142. { "Mic", 0x0 },
  3143. { "Line", 0x2 },
  3144. { "CD", 0x4 },
  3145. { "Headphone", 0x5 },
  3146. },
  3147. },
  3148. {
  3149. .num_items = 5,
  3150. .items = {
  3151. { "Mic", 0x0 },
  3152. { "Line", 0x2 },
  3153. { "CD", 0x4 },
  3154. { "Headphone", 0x6 },
  3155. { "Mixer", 0x5 },
  3156. },
  3157. },
  3158. };
  3159. /*
  3160. * This is just place-holder, so there's something for alc_build_pcms to look
  3161. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3162. * element which allows changing the channel mode, so the verb list is
  3163. * never used.
  3164. */
  3165. static struct hda_channel_mode alc260_modes[1] = {
  3166. { 2, NULL },
  3167. };
  3168. /* Mixer combinations
  3169. *
  3170. * basic: base_output + input + pc_beep + capture
  3171. * HP: base_output + input + capture_alt
  3172. * HP_3013: hp_3013 + input + capture
  3173. * fujitsu: fujitsu + capture
  3174. * acer: acer + capture
  3175. */
  3176. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3177. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3178. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3179. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3180. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3181. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3182. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3183. { } /* end */
  3184. };
  3185. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3186. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3187. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3188. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3189. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3190. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3191. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3192. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3193. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3194. { } /* end */
  3195. };
  3196. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3197. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3198. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3199. { } /* end */
  3200. };
  3201. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3202. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3203. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3204. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3205. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3206. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3207. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3208. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3209. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3210. { } /* end */
  3211. };
  3212. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3213. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3214. */
  3215. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3216. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3217. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3218. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3219. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3220. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3221. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3222. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3223. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3224. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3225. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3226. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3227. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3228. { } /* end */
  3229. };
  3230. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3231. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3232. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3233. * datasheet doesn't mention this restriction. At this stage it's not clear
  3234. * whether this behaviour is intentional or is a hardware bug in chip
  3235. * revisions available in early 2006. Therefore for now allow the
  3236. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3237. * that the lack of mic bias for this NID is intentional we could change the
  3238. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3239. *
  3240. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3241. * don't appear to make the mic bias available from the "line" jack, even
  3242. * though the NID used for this jack (0x14) can supply it. The theory is
  3243. * that perhaps Acer have included blocking capacitors between the ALC260
  3244. * and the output jack. If this turns out to be the case for all such
  3245. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3246. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3247. *
  3248. * The C20x Tablet series have a mono internal speaker which is controlled
  3249. * via the chip's Mono sum widget and pin complex, so include the necessary
  3250. * controls for such models. On models without a "mono speaker" the control
  3251. * won't do anything.
  3252. */
  3253. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3254. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3255. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3256. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3257. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3258. HDA_OUTPUT),
  3259. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3260. HDA_INPUT),
  3261. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3262. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3263. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3264. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3265. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3266. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3267. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3268. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3269. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3270. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3271. { } /* end */
  3272. };
  3273. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3274. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3275. */
  3276. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3277. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3278. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3279. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3280. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3281. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3282. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3283. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3284. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3285. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3286. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3287. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3288. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3289. { } /* end */
  3290. };
  3291. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3292. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3293. */
  3294. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3295. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3296. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3297. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3298. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3299. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3300. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3301. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3302. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3303. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3304. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3305. { } /* end */
  3306. };
  3307. /* capture mixer elements */
  3308. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3309. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3310. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3311. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3312. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3313. {
  3314. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3315. /* The multiple "Capture Source" controls confuse alsamixer
  3316. * So call somewhat different..
  3317. * FIXME: the controls appear in the "playback" view!
  3318. */
  3319. /* .name = "Capture Source", */
  3320. .name = "Input Source",
  3321. .count = 2,
  3322. .info = alc_mux_enum_info,
  3323. .get = alc_mux_enum_get,
  3324. .put = alc_mux_enum_put,
  3325. },
  3326. { } /* end */
  3327. };
  3328. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3329. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3330. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3331. {
  3332. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3333. /* The multiple "Capture Source" controls confuse alsamixer
  3334. * So call somewhat different..
  3335. * FIXME: the controls appear in the "playback" view!
  3336. */
  3337. /* .name = "Capture Source", */
  3338. .name = "Input Source",
  3339. .count = 1,
  3340. .info = alc_mux_enum_info,
  3341. .get = alc_mux_enum_get,
  3342. .put = alc_mux_enum_put,
  3343. },
  3344. { } /* end */
  3345. };
  3346. /*
  3347. * initialization verbs
  3348. */
  3349. static struct hda_verb alc260_init_verbs[] = {
  3350. /* Line In pin widget for input */
  3351. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3352. /* CD pin widget for input */
  3353. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3354. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3355. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3356. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3357. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3358. /* LINE-2 is used for line-out in rear */
  3359. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3360. /* select line-out */
  3361. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3362. /* LINE-OUT pin */
  3363. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3364. /* enable HP */
  3365. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3366. /* enable Mono */
  3367. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3368. /* mute capture amp left and right */
  3369. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3370. /* set connection select to line in (default select for this ADC) */
  3371. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3372. /* mute capture amp left and right */
  3373. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3374. /* set connection select to line in (default select for this ADC) */
  3375. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3376. /* set vol=0 Line-Out mixer amp left and right */
  3377. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3378. /* unmute pin widget amp left and right (no gain on this amp) */
  3379. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3380. /* set vol=0 HP mixer amp left and right */
  3381. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3382. /* unmute pin widget amp left and right (no gain on this amp) */
  3383. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3384. /* set vol=0 Mono mixer amp left and right */
  3385. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3386. /* unmute pin widget amp left and right (no gain on this amp) */
  3387. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3388. /* unmute LINE-2 out pin */
  3389. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3390. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3391. * Line In 2 = 0x03
  3392. */
  3393. /* mute CD */
  3394. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3395. /* mute Line In */
  3396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3397. /* mute Mic */
  3398. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3399. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3400. /* mute Front out path */
  3401. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3402. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3403. /* mute Headphone out path */
  3404. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3405. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3406. /* mute Mono out path */
  3407. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3408. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3409. { }
  3410. };
  3411. #if 0 /* should be identical with alc260_init_verbs? */
  3412. static struct hda_verb alc260_hp_init_verbs[] = {
  3413. /* Headphone and output */
  3414. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3415. /* mono output */
  3416. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3417. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3418. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3419. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3420. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3421. /* Line In pin widget for input */
  3422. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3423. /* Line-2 pin widget for output */
  3424. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3425. /* CD pin widget for input */
  3426. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3427. /* unmute amp left and right */
  3428. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3429. /* set connection select to line in (default select for this ADC) */
  3430. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3431. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3432. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3433. /* mute pin widget amp left and right (no gain on this amp) */
  3434. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3435. /* unmute HP mixer amp left and right (volume = 0) */
  3436. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3437. /* mute pin widget amp left and right (no gain on this amp) */
  3438. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3439. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3440. * Line In 2 = 0x03
  3441. */
  3442. /* unmute CD */
  3443. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3444. /* unmute Line In */
  3445. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3446. /* unmute Mic */
  3447. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3448. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3449. /* Unmute Front out path */
  3450. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3451. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3452. /* Unmute Headphone out path */
  3453. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3454. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3455. /* Unmute Mono out path */
  3456. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3457. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3458. { }
  3459. };
  3460. #endif
  3461. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3462. /* Line out and output */
  3463. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3464. /* mono output */
  3465. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3466. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3467. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3468. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3469. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3470. /* Line In pin widget for input */
  3471. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3472. /* Headphone pin widget for output */
  3473. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3474. /* CD pin widget for input */
  3475. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3476. /* unmute amp left and right */
  3477. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3478. /* set connection select to line in (default select for this ADC) */
  3479. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3480. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3481. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3482. /* mute pin widget amp left and right (no gain on this amp) */
  3483. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3484. /* unmute HP mixer amp left and right (volume = 0) */
  3485. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3486. /* mute pin widget amp left and right (no gain on this amp) */
  3487. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3488. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3489. * Line In 2 = 0x03
  3490. */
  3491. /* unmute CD */
  3492. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3493. /* unmute Line In */
  3494. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3495. /* unmute Mic */
  3496. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3497. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3498. /* Unmute Front out path */
  3499. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3500. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3501. /* Unmute Headphone out path */
  3502. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3503. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3504. /* Unmute Mono out path */
  3505. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3506. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3507. { }
  3508. };
  3509. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3510. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3511. * audio = 0x16, internal speaker = 0x10.
  3512. */
  3513. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3514. /* Disable all GPIOs */
  3515. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3516. /* Internal speaker is connected to headphone pin */
  3517. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3518. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3519. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3520. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3521. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3522. /* Ensure all other unused pins are disabled and muted. */
  3523. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3524. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3525. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3526. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3527. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3528. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3529. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3530. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3531. /* Disable digital (SPDIF) pins */
  3532. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3533. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3534. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3535. * when acting as an output.
  3536. */
  3537. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3538. /* Start with output sum widgets muted and their output gains at min */
  3539. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3540. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3541. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3542. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3543. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3544. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3545. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3546. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3547. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3548. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3549. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3550. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3551. * If the pin mode is changed by the user the pin mode control will
  3552. * take care of enabling the pin's input/output buffers as needed.
  3553. * Therefore there's no need to enable the input buffer at this
  3554. * stage.
  3555. */
  3556. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3557. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3558. * mixer ctrl)
  3559. */
  3560. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3561. /* Mute capture amp left and right */
  3562. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3563. /* Set ADC connection select to match default mixer setting - line
  3564. * in (on mic1 pin)
  3565. */
  3566. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3567. /* Do the same for the second ADC: mute capture input amp and
  3568. * set ADC connection to line in (on mic1 pin)
  3569. */
  3570. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3571. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3572. /* Mute all inputs to mixer widget (even unconnected ones) */
  3573. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3575. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3576. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3578. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3579. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3580. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3581. { }
  3582. };
  3583. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3584. * similar laptops (adapted from Fujitsu init verbs).
  3585. */
  3586. static struct hda_verb alc260_acer_init_verbs[] = {
  3587. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3588. * the headphone jack. Turn this on and rely on the standard mute
  3589. * methods whenever the user wants to turn these outputs off.
  3590. */
  3591. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3592. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3593. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3594. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3595. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3596. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3597. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3598. /* Line In jack is connected to Line1 pin */
  3599. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3600. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3601. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3602. /* Ensure all other unused pins are disabled and muted. */
  3603. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3604. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3605. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3606. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3607. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3608. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3609. /* Disable digital (SPDIF) pins */
  3610. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3611. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3612. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3613. * bus when acting as outputs.
  3614. */
  3615. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3616. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3617. /* Start with output sum widgets muted and their output gains at min */
  3618. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3619. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3620. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3621. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3622. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3623. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3624. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3625. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3626. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3627. /* Unmute Line-out pin widget amp left and right
  3628. * (no equiv mixer ctrl)
  3629. */
  3630. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3631. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3632. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3633. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3634. * inputs. If the pin mode is changed by the user the pin mode control
  3635. * will take care of enabling the pin's input/output buffers as needed.
  3636. * Therefore there's no need to enable the input buffer at this
  3637. * stage.
  3638. */
  3639. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3640. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3641. /* Mute capture amp left and right */
  3642. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3643. /* Set ADC connection select to match default mixer setting - mic
  3644. * (on mic1 pin)
  3645. */
  3646. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3647. /* Do similar with the second ADC: mute capture input amp and
  3648. * set ADC connection to mic to match ALSA's default state.
  3649. */
  3650. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3651. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3652. /* Mute all inputs to mixer widget (even unconnected ones) */
  3653. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3658. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3659. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3660. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3661. { }
  3662. };
  3663. static struct hda_verb alc260_will_verbs[] = {
  3664. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3665. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3666. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3667. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3668. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3669. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3670. {}
  3671. };
  3672. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3673. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3674. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3675. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3676. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3677. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3678. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3679. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3680. {}
  3681. };
  3682. /* toggle speaker-output according to the hp-jack state */
  3683. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3684. {
  3685. unsigned int present;
  3686. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3687. present = snd_hda_codec_read(codec, 0x0f, 0,
  3688. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3689. if (present) {
  3690. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3691. snd_hda_codec_write(codec, 0x0f, 0,
  3692. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3693. } else {
  3694. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3695. snd_hda_codec_write(codec, 0x0f, 0,
  3696. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3697. }
  3698. }
  3699. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3700. unsigned int res)
  3701. {
  3702. if ((res >> 26) == ALC880_HP_EVENT)
  3703. alc260_replacer_672v_automute(codec);
  3704. }
  3705. /* Test configuration for debugging, modelled after the ALC880 test
  3706. * configuration.
  3707. */
  3708. #ifdef CONFIG_SND_DEBUG
  3709. static hda_nid_t alc260_test_dac_nids[1] = {
  3710. 0x02,
  3711. };
  3712. static hda_nid_t alc260_test_adc_nids[2] = {
  3713. 0x04, 0x05,
  3714. };
  3715. /* For testing the ALC260, each input MUX needs its own definition since
  3716. * the signal assignments are different. This assumes that the first ADC
  3717. * is NID 0x04.
  3718. */
  3719. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3720. {
  3721. .num_items = 7,
  3722. .items = {
  3723. { "MIC1 pin", 0x0 },
  3724. { "MIC2 pin", 0x1 },
  3725. { "LINE1 pin", 0x2 },
  3726. { "LINE2 pin", 0x3 },
  3727. { "CD pin", 0x4 },
  3728. { "LINE-OUT pin", 0x5 },
  3729. { "HP-OUT pin", 0x6 },
  3730. },
  3731. },
  3732. {
  3733. .num_items = 8,
  3734. .items = {
  3735. { "MIC1 pin", 0x0 },
  3736. { "MIC2 pin", 0x1 },
  3737. { "LINE1 pin", 0x2 },
  3738. { "LINE2 pin", 0x3 },
  3739. { "CD pin", 0x4 },
  3740. { "Mixer", 0x5 },
  3741. { "LINE-OUT pin", 0x6 },
  3742. { "HP-OUT pin", 0x7 },
  3743. },
  3744. },
  3745. };
  3746. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3747. /* Output driver widgets */
  3748. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3749. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3750. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3751. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3752. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3753. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3754. /* Modes for retasking pin widgets
  3755. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3756. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3757. * mention this restriction. At this stage it's not clear whether
  3758. * this behaviour is intentional or is a hardware bug in chip
  3759. * revisions available at least up until early 2006. Therefore for
  3760. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3761. * choices, but if it turns out that the lack of mic bias for these
  3762. * NIDs is intentional we could change their modes from
  3763. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3764. */
  3765. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3766. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3767. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3768. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3769. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3770. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3771. /* Loopback mixer controls */
  3772. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3773. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3774. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3775. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3776. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3777. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3778. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3779. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3780. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3781. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3782. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3783. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3784. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3785. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3786. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3787. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3788. /* Controls for GPIO pins, assuming they are configured as outputs */
  3789. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3790. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3791. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3792. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3793. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3794. * is ambigious as to which NID is which; testing on laptops which
  3795. * make this output available should provide clarification.
  3796. */
  3797. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3798. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3799. { } /* end */
  3800. };
  3801. static struct hda_verb alc260_test_init_verbs[] = {
  3802. /* Enable all GPIOs as outputs with an initial value of 0 */
  3803. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3804. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3805. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3806. /* Enable retasking pins as output, initially without power amp */
  3807. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3808. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3809. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3810. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3811. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3812. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3813. /* Disable digital (SPDIF) pins initially, but users can enable
  3814. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3815. * payload also sets the generation to 0, output to be in "consumer"
  3816. * PCM format, copyright asserted, no pre-emphasis and no validity
  3817. * control.
  3818. */
  3819. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3820. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3821. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3822. * OUT1 sum bus when acting as an output.
  3823. */
  3824. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3825. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3826. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3827. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3828. /* Start with output sum widgets muted and their output gains at min */
  3829. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3830. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3831. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3832. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3833. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3834. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3835. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3836. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3837. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3838. /* Unmute retasking pin widget output buffers since the default
  3839. * state appears to be output. As the pin mode is changed by the
  3840. * user the pin mode control will take care of enabling the pin's
  3841. * input/output buffers as needed.
  3842. */
  3843. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3844. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3845. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3846. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3847. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3848. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3849. /* Also unmute the mono-out pin widget */
  3850. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3851. /* Mute capture amp left and right */
  3852. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3853. /* Set ADC connection select to match default mixer setting (mic1
  3854. * pin)
  3855. */
  3856. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3857. /* Do the same for the second ADC: mute capture input amp and
  3858. * set ADC connection to mic1 pin
  3859. */
  3860. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3861. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3862. /* Mute all inputs to mixer widget (even unconnected ones) */
  3863. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3864. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3865. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3866. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3867. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3871. { }
  3872. };
  3873. #endif
  3874. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3875. .substreams = 1,
  3876. .channels_min = 2,
  3877. .channels_max = 2,
  3878. };
  3879. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3880. .substreams = 1,
  3881. .channels_min = 2,
  3882. .channels_max = 2,
  3883. };
  3884. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3885. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3886. /*
  3887. * for BIOS auto-configuration
  3888. */
  3889. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3890. const char *pfx)
  3891. {
  3892. hda_nid_t nid_vol;
  3893. unsigned long vol_val, sw_val;
  3894. char name[32];
  3895. int err;
  3896. if (nid >= 0x0f && nid < 0x11) {
  3897. nid_vol = nid - 0x7;
  3898. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3899. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3900. } else if (nid == 0x11) {
  3901. nid_vol = nid - 0x7;
  3902. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3903. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3904. } else if (nid >= 0x12 && nid <= 0x15) {
  3905. nid_vol = 0x08;
  3906. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3907. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3908. } else
  3909. return 0; /* N/A */
  3910. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3911. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3912. if (err < 0)
  3913. return err;
  3914. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3915. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3916. if (err < 0)
  3917. return err;
  3918. return 1;
  3919. }
  3920. /* add playback controls from the parsed DAC table */
  3921. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3922. const struct auto_pin_cfg *cfg)
  3923. {
  3924. hda_nid_t nid;
  3925. int err;
  3926. spec->multiout.num_dacs = 1;
  3927. spec->multiout.dac_nids = spec->private_dac_nids;
  3928. spec->multiout.dac_nids[0] = 0x02;
  3929. nid = cfg->line_out_pins[0];
  3930. if (nid) {
  3931. err = alc260_add_playback_controls(spec, nid, "Front");
  3932. if (err < 0)
  3933. return err;
  3934. }
  3935. nid = cfg->speaker_pins[0];
  3936. if (nid) {
  3937. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3938. if (err < 0)
  3939. return err;
  3940. }
  3941. nid = cfg->hp_pins[0];
  3942. if (nid) {
  3943. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3944. if (err < 0)
  3945. return err;
  3946. }
  3947. return 0;
  3948. }
  3949. /* create playback/capture controls for input pins */
  3950. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3951. const struct auto_pin_cfg *cfg)
  3952. {
  3953. struct hda_input_mux *imux = &spec->private_imux;
  3954. int i, err, idx;
  3955. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3956. if (cfg->input_pins[i] >= 0x12) {
  3957. idx = cfg->input_pins[i] - 0x12;
  3958. err = new_analog_input(spec, cfg->input_pins[i],
  3959. auto_pin_cfg_labels[i], idx,
  3960. 0x07);
  3961. if (err < 0)
  3962. return err;
  3963. imux->items[imux->num_items].label =
  3964. auto_pin_cfg_labels[i];
  3965. imux->items[imux->num_items].index = idx;
  3966. imux->num_items++;
  3967. }
  3968. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3969. idx = cfg->input_pins[i] - 0x09;
  3970. err = new_analog_input(spec, cfg->input_pins[i],
  3971. auto_pin_cfg_labels[i], idx,
  3972. 0x07);
  3973. if (err < 0)
  3974. return err;
  3975. imux->items[imux->num_items].label =
  3976. auto_pin_cfg_labels[i];
  3977. imux->items[imux->num_items].index = idx;
  3978. imux->num_items++;
  3979. }
  3980. }
  3981. return 0;
  3982. }
  3983. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3984. hda_nid_t nid, int pin_type,
  3985. int sel_idx)
  3986. {
  3987. /* set as output */
  3988. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3989. pin_type);
  3990. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3991. AMP_OUT_UNMUTE);
  3992. /* need the manual connection? */
  3993. if (nid >= 0x12) {
  3994. int idx = nid - 0x12;
  3995. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3996. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3997. }
  3998. }
  3999. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4000. {
  4001. struct alc_spec *spec = codec->spec;
  4002. hda_nid_t nid;
  4003. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4004. nid = spec->autocfg.line_out_pins[0];
  4005. if (nid) {
  4006. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4007. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4008. }
  4009. nid = spec->autocfg.speaker_pins[0];
  4010. if (nid)
  4011. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4012. nid = spec->autocfg.hp_pins[0];
  4013. if (nid)
  4014. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4015. }
  4016. #define ALC260_PIN_CD_NID 0x16
  4017. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4018. {
  4019. struct alc_spec *spec = codec->spec;
  4020. int i;
  4021. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4022. hda_nid_t nid = spec->autocfg.input_pins[i];
  4023. if (nid >= 0x12) {
  4024. snd_hda_codec_write(codec, nid, 0,
  4025. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4026. i <= AUTO_PIN_FRONT_MIC ?
  4027. PIN_VREF80 : PIN_IN);
  4028. if (nid != ALC260_PIN_CD_NID)
  4029. snd_hda_codec_write(codec, nid, 0,
  4030. AC_VERB_SET_AMP_GAIN_MUTE,
  4031. AMP_OUT_MUTE);
  4032. }
  4033. }
  4034. }
  4035. /*
  4036. * generic initialization of ADC, input mixers and output mixers
  4037. */
  4038. static struct hda_verb alc260_volume_init_verbs[] = {
  4039. /*
  4040. * Unmute ADC0-1 and set the default input to mic-in
  4041. */
  4042. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4043. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4044. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4045. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4046. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4047. * mixer widget
  4048. * Note: PASD motherboards uses the Line In 2 as the input for
  4049. * front panel mic (mic 2)
  4050. */
  4051. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4052. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4053. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4054. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4055. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4056. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4057. /*
  4058. * Set up output mixers (0x08 - 0x0a)
  4059. */
  4060. /* set vol=0 to output mixers */
  4061. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4062. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4063. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4064. /* set up input amps for analog loopback */
  4065. /* Amp Indices: DAC = 0, mixer = 1 */
  4066. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4067. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4068. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4069. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4070. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4071. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4072. { }
  4073. };
  4074. static int alc260_parse_auto_config(struct hda_codec *codec)
  4075. {
  4076. struct alc_spec *spec = codec->spec;
  4077. unsigned int wcap;
  4078. int err;
  4079. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4080. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4081. alc260_ignore);
  4082. if (err < 0)
  4083. return err;
  4084. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4085. if (err < 0)
  4086. return err;
  4087. if (!spec->kctl_alloc)
  4088. return 0; /* can't find valid BIOS pin config */
  4089. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4090. if (err < 0)
  4091. return err;
  4092. spec->multiout.max_channels = 2;
  4093. if (spec->autocfg.dig_out_pin)
  4094. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4095. if (spec->kctl_alloc)
  4096. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4097. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4098. spec->num_mux_defs = 1;
  4099. spec->input_mux = &spec->private_imux;
  4100. /* check whether NID 0x04 is valid */
  4101. wcap = get_wcaps(codec, 0x04);
  4102. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4103. if (wcap != AC_WID_AUD_IN) {
  4104. spec->adc_nids = alc260_adc_nids_alt;
  4105. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4106. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4107. } else {
  4108. spec->adc_nids = alc260_adc_nids;
  4109. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4110. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4111. }
  4112. spec->num_mixers++;
  4113. return 1;
  4114. }
  4115. /* additional initialization for auto-configuration model */
  4116. static void alc260_auto_init(struct hda_codec *codec)
  4117. {
  4118. alc260_auto_init_multi_out(codec);
  4119. alc260_auto_init_analog_input(codec);
  4120. }
  4121. /*
  4122. * ALC260 configurations
  4123. */
  4124. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4125. [ALC260_BASIC] = "basic",
  4126. [ALC260_HP] = "hp",
  4127. [ALC260_HP_3013] = "hp-3013",
  4128. [ALC260_FUJITSU_S702X] = "fujitsu",
  4129. [ALC260_ACER] = "acer",
  4130. [ALC260_WILL] = "will",
  4131. [ALC260_REPLACER_672V] = "replacer",
  4132. #ifdef CONFIG_SND_DEBUG
  4133. [ALC260_TEST] = "test",
  4134. #endif
  4135. [ALC260_AUTO] = "auto",
  4136. };
  4137. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4138. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4139. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4140. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4141. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4142. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4143. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4144. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4145. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4146. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4147. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4148. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4149. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4150. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4151. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4152. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4153. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4154. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4155. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4156. {}
  4157. };
  4158. static struct alc_config_preset alc260_presets[] = {
  4159. [ALC260_BASIC] = {
  4160. .mixers = { alc260_base_output_mixer,
  4161. alc260_input_mixer,
  4162. alc260_pc_beep_mixer,
  4163. alc260_capture_mixer },
  4164. .init_verbs = { alc260_init_verbs },
  4165. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4166. .dac_nids = alc260_dac_nids,
  4167. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4168. .adc_nids = alc260_adc_nids,
  4169. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4170. .channel_mode = alc260_modes,
  4171. .input_mux = &alc260_capture_source,
  4172. },
  4173. [ALC260_HP] = {
  4174. .mixers = { alc260_base_output_mixer,
  4175. alc260_input_mixer,
  4176. alc260_capture_alt_mixer },
  4177. .init_verbs = { alc260_init_verbs },
  4178. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4179. .dac_nids = alc260_dac_nids,
  4180. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4181. .adc_nids = alc260_hp_adc_nids,
  4182. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4183. .channel_mode = alc260_modes,
  4184. .input_mux = &alc260_capture_source,
  4185. },
  4186. [ALC260_HP_3013] = {
  4187. .mixers = { alc260_hp_3013_mixer,
  4188. alc260_input_mixer,
  4189. alc260_capture_alt_mixer },
  4190. .init_verbs = { alc260_hp_3013_init_verbs },
  4191. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4192. .dac_nids = alc260_dac_nids,
  4193. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4194. .adc_nids = alc260_hp_adc_nids,
  4195. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4196. .channel_mode = alc260_modes,
  4197. .input_mux = &alc260_capture_source,
  4198. },
  4199. [ALC260_FUJITSU_S702X] = {
  4200. .mixers = { alc260_fujitsu_mixer,
  4201. alc260_capture_mixer },
  4202. .init_verbs = { alc260_fujitsu_init_verbs },
  4203. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4204. .dac_nids = alc260_dac_nids,
  4205. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4206. .adc_nids = alc260_dual_adc_nids,
  4207. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4208. .channel_mode = alc260_modes,
  4209. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4210. .input_mux = alc260_fujitsu_capture_sources,
  4211. },
  4212. [ALC260_ACER] = {
  4213. .mixers = { alc260_acer_mixer,
  4214. alc260_capture_mixer },
  4215. .init_verbs = { alc260_acer_init_verbs },
  4216. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4217. .dac_nids = alc260_dac_nids,
  4218. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4219. .adc_nids = alc260_dual_adc_nids,
  4220. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4221. .channel_mode = alc260_modes,
  4222. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4223. .input_mux = alc260_acer_capture_sources,
  4224. },
  4225. [ALC260_WILL] = {
  4226. .mixers = { alc260_will_mixer,
  4227. alc260_capture_mixer },
  4228. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4229. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4230. .dac_nids = alc260_dac_nids,
  4231. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4232. .adc_nids = alc260_adc_nids,
  4233. .dig_out_nid = ALC260_DIGOUT_NID,
  4234. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4235. .channel_mode = alc260_modes,
  4236. .input_mux = &alc260_capture_source,
  4237. },
  4238. [ALC260_REPLACER_672V] = {
  4239. .mixers = { alc260_replacer_672v_mixer,
  4240. alc260_capture_mixer },
  4241. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4242. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4243. .dac_nids = alc260_dac_nids,
  4244. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4245. .adc_nids = alc260_adc_nids,
  4246. .dig_out_nid = ALC260_DIGOUT_NID,
  4247. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4248. .channel_mode = alc260_modes,
  4249. .input_mux = &alc260_capture_source,
  4250. .unsol_event = alc260_replacer_672v_unsol_event,
  4251. .init_hook = alc260_replacer_672v_automute,
  4252. },
  4253. #ifdef CONFIG_SND_DEBUG
  4254. [ALC260_TEST] = {
  4255. .mixers = { alc260_test_mixer,
  4256. alc260_capture_mixer },
  4257. .init_verbs = { alc260_test_init_verbs },
  4258. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4259. .dac_nids = alc260_test_dac_nids,
  4260. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4261. .adc_nids = alc260_test_adc_nids,
  4262. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4263. .channel_mode = alc260_modes,
  4264. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4265. .input_mux = alc260_test_capture_sources,
  4266. },
  4267. #endif
  4268. };
  4269. static int patch_alc260(struct hda_codec *codec)
  4270. {
  4271. struct alc_spec *spec;
  4272. int err, board_config;
  4273. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4274. if (spec == NULL)
  4275. return -ENOMEM;
  4276. codec->spec = spec;
  4277. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4278. alc260_models,
  4279. alc260_cfg_tbl);
  4280. if (board_config < 0) {
  4281. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4282. "trying auto-probe from BIOS...\n");
  4283. board_config = ALC260_AUTO;
  4284. }
  4285. if (board_config == ALC260_AUTO) {
  4286. /* automatic parse from the BIOS config */
  4287. err = alc260_parse_auto_config(codec);
  4288. if (err < 0) {
  4289. alc_free(codec);
  4290. return err;
  4291. } else if (!err) {
  4292. printk(KERN_INFO
  4293. "hda_codec: Cannot set up configuration "
  4294. "from BIOS. Using base mode...\n");
  4295. board_config = ALC260_BASIC;
  4296. }
  4297. }
  4298. if (board_config != ALC260_AUTO)
  4299. setup_preset(spec, &alc260_presets[board_config]);
  4300. spec->stream_name_analog = "ALC260 Analog";
  4301. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4302. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4303. spec->stream_name_digital = "ALC260 Digital";
  4304. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4305. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4306. codec->patch_ops = alc_patch_ops;
  4307. if (board_config == ALC260_AUTO)
  4308. spec->init_hook = alc260_auto_init;
  4309. return 0;
  4310. }
  4311. /*
  4312. * ALC882 support
  4313. *
  4314. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4315. * configuration. Each pin widget can choose any input DACs and a mixer.
  4316. * Each ADC is connected from a mixer of all inputs. This makes possible
  4317. * 6-channel independent captures.
  4318. *
  4319. * In addition, an independent DAC for the multi-playback (not used in this
  4320. * driver yet).
  4321. */
  4322. #define ALC882_DIGOUT_NID 0x06
  4323. #define ALC882_DIGIN_NID 0x0a
  4324. static struct hda_channel_mode alc882_ch_modes[1] = {
  4325. { 8, NULL }
  4326. };
  4327. static hda_nid_t alc882_dac_nids[4] = {
  4328. /* front, rear, clfe, rear_surr */
  4329. 0x02, 0x03, 0x04, 0x05
  4330. };
  4331. /* identical with ALC880 */
  4332. #define alc882_adc_nids alc880_adc_nids
  4333. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4334. /* input MUX */
  4335. /* FIXME: should be a matrix-type input source selection */
  4336. static struct hda_input_mux alc882_capture_source = {
  4337. .num_items = 4,
  4338. .items = {
  4339. { "Mic", 0x0 },
  4340. { "Front Mic", 0x1 },
  4341. { "Line", 0x2 },
  4342. { "CD", 0x4 },
  4343. },
  4344. };
  4345. #define alc882_mux_enum_info alc_mux_enum_info
  4346. #define alc882_mux_enum_get alc_mux_enum_get
  4347. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4348. struct snd_ctl_elem_value *ucontrol)
  4349. {
  4350. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4351. struct alc_spec *spec = codec->spec;
  4352. const struct hda_input_mux *imux = spec->input_mux;
  4353. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4354. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4355. hda_nid_t nid = capture_mixers[adc_idx];
  4356. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4357. unsigned int i, idx;
  4358. idx = ucontrol->value.enumerated.item[0];
  4359. if (idx >= imux->num_items)
  4360. idx = imux->num_items - 1;
  4361. if (*cur_val == idx && !codec->in_resume)
  4362. return 0;
  4363. for (i = 0; i < imux->num_items; i++) {
  4364. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4365. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4366. v | (imux->items[i].index << 8));
  4367. }
  4368. *cur_val = idx;
  4369. return 1;
  4370. }
  4371. /*
  4372. * 2ch mode
  4373. */
  4374. static struct hda_verb alc882_3ST_ch2_init[] = {
  4375. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4376. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4377. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4378. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4379. { } /* end */
  4380. };
  4381. /*
  4382. * 6ch mode
  4383. */
  4384. static struct hda_verb alc882_3ST_ch6_init[] = {
  4385. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4386. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4387. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4388. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4389. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4390. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4391. { } /* end */
  4392. };
  4393. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4394. { 2, alc882_3ST_ch2_init },
  4395. { 6, alc882_3ST_ch6_init },
  4396. };
  4397. /*
  4398. * 6ch mode
  4399. */
  4400. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4401. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4402. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4403. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4404. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4405. { } /* end */
  4406. };
  4407. /*
  4408. * 8ch mode
  4409. */
  4410. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4411. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4412. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4413. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4414. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4415. { } /* end */
  4416. };
  4417. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4418. { 6, alc882_sixstack_ch6_init },
  4419. { 8, alc882_sixstack_ch8_init },
  4420. };
  4421. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4422. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4423. */
  4424. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4425. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4426. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4427. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4428. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4429. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4430. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4431. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4432. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4433. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4434. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4435. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4436. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4437. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4438. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4439. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4440. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4441. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4442. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4443. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4444. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4445. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4446. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4447. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4448. { } /* end */
  4449. };
  4450. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4451. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4452. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4453. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4454. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4455. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4456. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4457. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4458. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4459. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4460. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4461. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4462. { } /* end */
  4463. };
  4464. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4465. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4466. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4467. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4468. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4469. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4470. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4471. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4472. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4473. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4474. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4475. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4476. { } /* end */
  4477. };
  4478. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4479. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4480. */
  4481. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4482. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4483. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4484. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4485. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4486. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4487. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4488. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4489. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4490. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4491. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4492. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4493. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4494. { } /* end */
  4495. };
  4496. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4497. {
  4498. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4499. .name = "Channel Mode",
  4500. .info = alc_ch_mode_info,
  4501. .get = alc_ch_mode_get,
  4502. .put = alc_ch_mode_put,
  4503. },
  4504. { } /* end */
  4505. };
  4506. static struct hda_verb alc882_init_verbs[] = {
  4507. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4508. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4509. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4510. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4511. /* Rear mixer */
  4512. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4513. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4514. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4515. /* CLFE mixer */
  4516. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4517. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4518. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4519. /* Side mixer */
  4520. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4521. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4522. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4523. /* Front Pin: output 0 (0x0c) */
  4524. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4525. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4526. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4527. /* Rear Pin: output 1 (0x0d) */
  4528. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4529. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4530. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4531. /* CLFE Pin: output 2 (0x0e) */
  4532. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4533. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4534. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4535. /* Side Pin: output 3 (0x0f) */
  4536. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4537. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4538. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4539. /* Mic (rear) pin: input vref at 80% */
  4540. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4541. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4542. /* Front Mic pin: input vref at 80% */
  4543. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4544. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4545. /* Line In pin: input */
  4546. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4547. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4548. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4549. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4550. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4551. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4552. /* CD pin widget for input */
  4553. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4554. /* FIXME: use matrix-type input source selection */
  4555. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4556. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4557. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4558. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4559. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4560. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4561. /* Input mixer2 */
  4562. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4563. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4564. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4565. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4566. /* Input mixer3 */
  4567. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4568. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4569. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4570. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4571. /* ADC1: mute amp left and right */
  4572. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4573. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4574. /* ADC2: mute amp left and right */
  4575. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4576. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4577. /* ADC3: mute amp left and right */
  4578. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4579. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4580. { }
  4581. };
  4582. static struct hda_verb alc882_eapd_verbs[] = {
  4583. /* change to EAPD mode */
  4584. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4585. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4586. { }
  4587. };
  4588. /* Mac Pro test */
  4589. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4590. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4591. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4592. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4593. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4594. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4595. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4596. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4597. { } /* end */
  4598. };
  4599. static struct hda_verb alc882_macpro_init_verbs[] = {
  4600. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4601. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4602. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4603. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4604. /* Front Pin: output 0 (0x0c) */
  4605. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4606. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4607. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4608. /* Front Mic pin: input vref at 80% */
  4609. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4610. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4611. /* Speaker: output */
  4612. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4613. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4614. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4615. /* Headphone output (output 0 - 0x0c) */
  4616. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4617. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4618. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4619. /* FIXME: use matrix-type input source selection */
  4620. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4621. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4622. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4623. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4624. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4625. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4626. /* Input mixer2 */
  4627. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4628. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4629. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4630. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4631. /* Input mixer3 */
  4632. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4633. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4634. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4635. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4636. /* ADC1: mute amp left and right */
  4637. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4638. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4639. /* ADC2: mute amp left and right */
  4640. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4641. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4642. /* ADC3: mute amp left and right */
  4643. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4644. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4645. { }
  4646. };
  4647. static struct hda_verb alc882_targa_verbs[] = {
  4648. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4649. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4650. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4651. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4652. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4653. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4654. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4655. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4656. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4657. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4658. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4659. { } /* end */
  4660. };
  4661. /* toggle speaker-output according to the hp-jack state */
  4662. static void alc882_targa_automute(struct hda_codec *codec)
  4663. {
  4664. unsigned int present;
  4665. present = snd_hda_codec_read(codec, 0x14, 0,
  4666. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4667. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4668. 0x80, present ? 0x80 : 0);
  4669. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4670. 0x80, present ? 0x80 : 0);
  4671. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4672. }
  4673. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4674. {
  4675. /* Looks like the unsol event is incompatible with the standard
  4676. * definition. 4bit tag is placed at 26 bit!
  4677. */
  4678. if (((res >> 26) == ALC880_HP_EVENT)) {
  4679. alc882_targa_automute(codec);
  4680. }
  4681. }
  4682. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4683. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4684. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4685. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4686. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4687. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4688. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4689. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4690. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4691. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4692. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4693. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4694. { } /* end */
  4695. };
  4696. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4697. {
  4698. unsigned int gpiostate, gpiomask, gpiodir;
  4699. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4700. AC_VERB_GET_GPIO_DATA, 0);
  4701. if (!muted)
  4702. gpiostate |= (1 << pin);
  4703. else
  4704. gpiostate &= ~(1 << pin);
  4705. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4706. AC_VERB_GET_GPIO_MASK, 0);
  4707. gpiomask |= (1 << pin);
  4708. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4709. AC_VERB_GET_GPIO_DIRECTION, 0);
  4710. gpiodir |= (1 << pin);
  4711. snd_hda_codec_write(codec, codec->afg, 0,
  4712. AC_VERB_SET_GPIO_MASK, gpiomask);
  4713. snd_hda_codec_write(codec, codec->afg, 0,
  4714. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4715. msleep(1);
  4716. snd_hda_codec_write(codec, codec->afg, 0,
  4717. AC_VERB_SET_GPIO_DATA, gpiostate);
  4718. }
  4719. /*
  4720. * generic initialization of ADC, input mixers and output mixers
  4721. */
  4722. static struct hda_verb alc882_auto_init_verbs[] = {
  4723. /*
  4724. * Unmute ADC0-2 and set the default input to mic-in
  4725. */
  4726. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4727. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4728. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4729. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4730. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4731. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4732. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4733. * mixer widget
  4734. * Note: PASD motherboards uses the Line In 2 as the input for
  4735. * front panel mic (mic 2)
  4736. */
  4737. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4738. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4739. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4740. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4741. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4742. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4743. /*
  4744. * Set up output mixers (0x0c - 0x0f)
  4745. */
  4746. /* set vol=0 to output mixers */
  4747. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4748. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4749. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4750. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4751. /* set up input amps for analog loopback */
  4752. /* Amp Indices: DAC = 0, mixer = 1 */
  4753. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4754. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4755. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4756. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4757. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4758. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4759. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4760. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4761. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4762. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4763. /* FIXME: use matrix-type input source selection */
  4764. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4765. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4766. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4767. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4768. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4769. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4770. /* Input mixer2 */
  4771. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4772. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4773. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4774. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4775. /* Input mixer3 */
  4776. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4777. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4778. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4779. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4780. { }
  4781. };
  4782. /* capture mixer elements */
  4783. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4784. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4785. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4786. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4787. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4788. {
  4789. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4790. /* The multiple "Capture Source" controls confuse alsamixer
  4791. * So call somewhat different..
  4792. * FIXME: the controls appear in the "playback" view!
  4793. */
  4794. /* .name = "Capture Source", */
  4795. .name = "Input Source",
  4796. .count = 2,
  4797. .info = alc882_mux_enum_info,
  4798. .get = alc882_mux_enum_get,
  4799. .put = alc882_mux_enum_put,
  4800. },
  4801. { } /* end */
  4802. };
  4803. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4804. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4805. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4806. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4807. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4808. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4809. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4810. {
  4811. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4812. /* The multiple "Capture Source" controls confuse alsamixer
  4813. * So call somewhat different..
  4814. * FIXME: the controls appear in the "playback" view!
  4815. */
  4816. /* .name = "Capture Source", */
  4817. .name = "Input Source",
  4818. .count = 3,
  4819. .info = alc882_mux_enum_info,
  4820. .get = alc882_mux_enum_get,
  4821. .put = alc882_mux_enum_put,
  4822. },
  4823. { } /* end */
  4824. };
  4825. /* pcm configuration: identiacal with ALC880 */
  4826. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4827. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4828. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4829. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4830. /*
  4831. * configuration and preset
  4832. */
  4833. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4834. [ALC882_3ST_DIG] = "3stack-dig",
  4835. [ALC882_6ST_DIG] = "6stack-dig",
  4836. [ALC882_ARIMA] = "arima",
  4837. [ALC882_W2JC] = "w2jc",
  4838. [ALC885_MACPRO] = "macpro",
  4839. [ALC882_AUTO] = "auto",
  4840. };
  4841. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4842. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4843. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4844. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4845. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4846. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4847. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4848. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4849. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4850. {}
  4851. };
  4852. static struct alc_config_preset alc882_presets[] = {
  4853. [ALC882_3ST_DIG] = {
  4854. .mixers = { alc882_base_mixer },
  4855. .init_verbs = { alc882_init_verbs },
  4856. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4857. .dac_nids = alc882_dac_nids,
  4858. .dig_out_nid = ALC882_DIGOUT_NID,
  4859. .dig_in_nid = ALC882_DIGIN_NID,
  4860. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4861. .channel_mode = alc882_ch_modes,
  4862. .need_dac_fix = 1,
  4863. .input_mux = &alc882_capture_source,
  4864. },
  4865. [ALC882_6ST_DIG] = {
  4866. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4867. .init_verbs = { alc882_init_verbs },
  4868. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4869. .dac_nids = alc882_dac_nids,
  4870. .dig_out_nid = ALC882_DIGOUT_NID,
  4871. .dig_in_nid = ALC882_DIGIN_NID,
  4872. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4873. .channel_mode = alc882_sixstack_modes,
  4874. .input_mux = &alc882_capture_source,
  4875. },
  4876. [ALC882_ARIMA] = {
  4877. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4878. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4879. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4880. .dac_nids = alc882_dac_nids,
  4881. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4882. .channel_mode = alc882_sixstack_modes,
  4883. .input_mux = &alc882_capture_source,
  4884. },
  4885. [ALC882_W2JC] = {
  4886. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4887. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4888. alc880_gpio1_init_verbs },
  4889. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4890. .dac_nids = alc882_dac_nids,
  4891. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4892. .channel_mode = alc880_threestack_modes,
  4893. .need_dac_fix = 1,
  4894. .input_mux = &alc882_capture_source,
  4895. .dig_out_nid = ALC882_DIGOUT_NID,
  4896. },
  4897. [ALC885_MACPRO] = {
  4898. .mixers = { alc882_macpro_mixer },
  4899. .init_verbs = { alc882_macpro_init_verbs },
  4900. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4901. .dac_nids = alc882_dac_nids,
  4902. .dig_out_nid = ALC882_DIGOUT_NID,
  4903. .dig_in_nid = ALC882_DIGIN_NID,
  4904. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4905. .channel_mode = alc882_ch_modes,
  4906. .input_mux = &alc882_capture_source,
  4907. },
  4908. [ALC882_TARGA] = {
  4909. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4910. alc882_capture_mixer },
  4911. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4912. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4913. .dac_nids = alc882_dac_nids,
  4914. .dig_out_nid = ALC882_DIGOUT_NID,
  4915. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4916. .adc_nids = alc882_adc_nids,
  4917. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4918. .channel_mode = alc882_3ST_6ch_modes,
  4919. .need_dac_fix = 1,
  4920. .input_mux = &alc882_capture_source,
  4921. .unsol_event = alc882_targa_unsol_event,
  4922. .init_hook = alc882_targa_automute,
  4923. },
  4924. [ALC882_ASUS_A7J] = {
  4925. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4926. alc882_capture_mixer },
  4927. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4928. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4929. .dac_nids = alc882_dac_nids,
  4930. .dig_out_nid = ALC882_DIGOUT_NID,
  4931. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4932. .adc_nids = alc882_adc_nids,
  4933. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4934. .channel_mode = alc882_3ST_6ch_modes,
  4935. .need_dac_fix = 1,
  4936. .input_mux = &alc882_capture_source,
  4937. },
  4938. };
  4939. /*
  4940. * Pin config fixes
  4941. */
  4942. enum {
  4943. PINFIX_ABIT_AW9D_MAX
  4944. };
  4945. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  4946. { 0x15, 0x01080104 }, /* side */
  4947. { 0x16, 0x01011012 }, /* rear */
  4948. { 0x17, 0x01016011 }, /* clfe */
  4949. { }
  4950. };
  4951. static const struct alc_pincfg *alc882_pin_fixes[] = {
  4952. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  4953. };
  4954. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  4955. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  4956. {}
  4957. };
  4958. /*
  4959. * BIOS auto configuration
  4960. */
  4961. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  4962. hda_nid_t nid, int pin_type,
  4963. int dac_idx)
  4964. {
  4965. /* set as output */
  4966. struct alc_spec *spec = codec->spec;
  4967. int idx;
  4968. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  4969. idx = 4;
  4970. else
  4971. idx = spec->multiout.dac_nids[dac_idx] - 2;
  4972. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4973. pin_type);
  4974. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4975. AMP_OUT_UNMUTE);
  4976. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  4977. }
  4978. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  4979. {
  4980. struct alc_spec *spec = codec->spec;
  4981. int i;
  4982. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  4983. for (i = 0; i <= HDA_SIDE; i++) {
  4984. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  4985. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4986. if (nid)
  4987. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  4988. i);
  4989. }
  4990. }
  4991. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  4992. {
  4993. struct alc_spec *spec = codec->spec;
  4994. hda_nid_t pin;
  4995. pin = spec->autocfg.hp_pins[0];
  4996. if (pin) /* connect to front */
  4997. /* use dac 0 */
  4998. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  4999. }
  5000. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5001. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5002. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5003. {
  5004. struct alc_spec *spec = codec->spec;
  5005. int i;
  5006. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5007. hda_nid_t nid = spec->autocfg.input_pins[i];
  5008. if (alc882_is_input_pin(nid)) {
  5009. snd_hda_codec_write(codec, nid, 0,
  5010. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5011. i <= AUTO_PIN_FRONT_MIC ?
  5012. PIN_VREF80 : PIN_IN);
  5013. if (nid != ALC882_PIN_CD_NID)
  5014. snd_hda_codec_write(codec, nid, 0,
  5015. AC_VERB_SET_AMP_GAIN_MUTE,
  5016. AMP_OUT_MUTE);
  5017. }
  5018. }
  5019. }
  5020. /* almost identical with ALC880 parser... */
  5021. static int alc882_parse_auto_config(struct hda_codec *codec)
  5022. {
  5023. struct alc_spec *spec = codec->spec;
  5024. int err = alc880_parse_auto_config(codec);
  5025. if (err < 0)
  5026. return err;
  5027. else if (err > 0)
  5028. /* hack - override the init verbs */
  5029. spec->init_verbs[0] = alc882_auto_init_verbs;
  5030. return err;
  5031. }
  5032. /* additional initialization for auto-configuration model */
  5033. static void alc882_auto_init(struct hda_codec *codec)
  5034. {
  5035. alc882_auto_init_multi_out(codec);
  5036. alc882_auto_init_hp_out(codec);
  5037. alc882_auto_init_analog_input(codec);
  5038. }
  5039. static int patch_alc882(struct hda_codec *codec)
  5040. {
  5041. struct alc_spec *spec;
  5042. int err, board_config;
  5043. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5044. if (spec == NULL)
  5045. return -ENOMEM;
  5046. codec->spec = spec;
  5047. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5048. alc882_models,
  5049. alc882_cfg_tbl);
  5050. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5051. /* Pick up systems that don't supply PCI SSID */
  5052. switch (codec->subsystem_id) {
  5053. case 0x106b0c00: /* Mac Pro */
  5054. board_config = ALC885_MACPRO;
  5055. break;
  5056. default:
  5057. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5058. "trying auto-probe from BIOS...\n");
  5059. board_config = ALC882_AUTO;
  5060. }
  5061. }
  5062. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5063. if (board_config == ALC882_AUTO) {
  5064. /* automatic parse from the BIOS config */
  5065. err = alc882_parse_auto_config(codec);
  5066. if (err < 0) {
  5067. alc_free(codec);
  5068. return err;
  5069. } else if (!err) {
  5070. printk(KERN_INFO
  5071. "hda_codec: Cannot set up configuration "
  5072. "from BIOS. Using base mode...\n");
  5073. board_config = ALC882_3ST_DIG;
  5074. }
  5075. }
  5076. if (board_config != ALC882_AUTO)
  5077. setup_preset(spec, &alc882_presets[board_config]);
  5078. if (board_config == ALC885_MACPRO) {
  5079. alc882_gpio_mute(codec, 0, 0);
  5080. alc882_gpio_mute(codec, 1, 0);
  5081. }
  5082. spec->stream_name_analog = "ALC882 Analog";
  5083. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5084. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5085. spec->stream_name_digital = "ALC882 Digital";
  5086. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5087. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5088. if (!spec->adc_nids && spec->input_mux) {
  5089. /* check whether NID 0x07 is valid */
  5090. unsigned int wcap = get_wcaps(codec, 0x07);
  5091. /* get type */
  5092. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5093. if (wcap != AC_WID_AUD_IN) {
  5094. spec->adc_nids = alc882_adc_nids_alt;
  5095. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5096. spec->mixers[spec->num_mixers] =
  5097. alc882_capture_alt_mixer;
  5098. spec->num_mixers++;
  5099. } else {
  5100. spec->adc_nids = alc882_adc_nids;
  5101. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5102. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5103. spec->num_mixers++;
  5104. }
  5105. }
  5106. codec->patch_ops = alc_patch_ops;
  5107. if (board_config == ALC882_AUTO)
  5108. spec->init_hook = alc882_auto_init;
  5109. return 0;
  5110. }
  5111. /*
  5112. * ALC883 support
  5113. *
  5114. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5115. * configuration. Each pin widget can choose any input DACs and a mixer.
  5116. * Each ADC is connected from a mixer of all inputs. This makes possible
  5117. * 6-channel independent captures.
  5118. *
  5119. * In addition, an independent DAC for the multi-playback (not used in this
  5120. * driver yet).
  5121. */
  5122. #define ALC883_DIGOUT_NID 0x06
  5123. #define ALC883_DIGIN_NID 0x0a
  5124. static hda_nid_t alc883_dac_nids[4] = {
  5125. /* front, rear, clfe, rear_surr */
  5126. 0x02, 0x04, 0x03, 0x05
  5127. };
  5128. static hda_nid_t alc883_adc_nids[2] = {
  5129. /* ADC1-2 */
  5130. 0x08, 0x09,
  5131. };
  5132. /* input MUX */
  5133. /* FIXME: should be a matrix-type input source selection */
  5134. static struct hda_input_mux alc883_capture_source = {
  5135. .num_items = 4,
  5136. .items = {
  5137. { "Mic", 0x0 },
  5138. { "Front Mic", 0x1 },
  5139. { "Line", 0x2 },
  5140. { "CD", 0x4 },
  5141. },
  5142. };
  5143. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5144. .num_items = 2,
  5145. .items = {
  5146. { "Mic", 0x1 },
  5147. { "Line", 0x2 },
  5148. },
  5149. };
  5150. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5151. .num_items = 4,
  5152. .items = {
  5153. { "Mic", 0x0 },
  5154. { "iMic", 0x1 },
  5155. { "Line", 0x2 },
  5156. { "CD", 0x4 },
  5157. },
  5158. };
  5159. #define alc883_mux_enum_info alc_mux_enum_info
  5160. #define alc883_mux_enum_get alc_mux_enum_get
  5161. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5162. struct snd_ctl_elem_value *ucontrol)
  5163. {
  5164. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5165. struct alc_spec *spec = codec->spec;
  5166. const struct hda_input_mux *imux = spec->input_mux;
  5167. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5168. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5169. hda_nid_t nid = capture_mixers[adc_idx];
  5170. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5171. unsigned int i, idx;
  5172. idx = ucontrol->value.enumerated.item[0];
  5173. if (idx >= imux->num_items)
  5174. idx = imux->num_items - 1;
  5175. if (*cur_val == idx && !codec->in_resume)
  5176. return 0;
  5177. for (i = 0; i < imux->num_items; i++) {
  5178. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5179. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5180. v | (imux->items[i].index << 8));
  5181. }
  5182. *cur_val = idx;
  5183. return 1;
  5184. }
  5185. /*
  5186. * 2ch mode
  5187. */
  5188. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5189. { 2, NULL }
  5190. };
  5191. /*
  5192. * 2ch mode
  5193. */
  5194. static struct hda_verb alc883_3ST_ch2_init[] = {
  5195. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5196. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5197. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5198. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5199. { } /* end */
  5200. };
  5201. /*
  5202. * 6ch mode
  5203. */
  5204. static struct hda_verb alc883_3ST_ch6_init[] = {
  5205. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5206. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5207. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5208. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5209. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5210. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5211. { } /* end */
  5212. };
  5213. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5214. { 2, alc883_3ST_ch2_init },
  5215. { 6, alc883_3ST_ch6_init },
  5216. };
  5217. /*
  5218. * 6ch mode
  5219. */
  5220. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5221. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5222. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5223. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5224. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5225. { } /* end */
  5226. };
  5227. /*
  5228. * 8ch mode
  5229. */
  5230. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5231. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5232. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5233. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5234. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5235. { } /* end */
  5236. };
  5237. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5238. { 6, alc883_sixstack_ch6_init },
  5239. { 8, alc883_sixstack_ch8_init },
  5240. };
  5241. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5242. /* eanable EAPD on medion laptop */
  5243. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5244. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5245. { }
  5246. };
  5247. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5248. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5249. */
  5250. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5251. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5252. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5253. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5254. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5255. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5256. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5257. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5258. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5259. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5260. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5261. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5262. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5263. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5264. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5265. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5266. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5267. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5268. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5269. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5270. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5271. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5272. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5273. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5274. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5275. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5276. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5277. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5278. {
  5279. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5280. /* .name = "Capture Source", */
  5281. .name = "Input Source",
  5282. .count = 2,
  5283. .info = alc883_mux_enum_info,
  5284. .get = alc883_mux_enum_get,
  5285. .put = alc883_mux_enum_put,
  5286. },
  5287. { } /* end */
  5288. };
  5289. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5290. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5291. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5292. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5293. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5294. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5295. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5296. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5297. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5298. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5299. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5300. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5301. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5302. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5303. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5304. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5305. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5306. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5307. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5308. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5309. {
  5310. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5311. /* .name = "Capture Source", */
  5312. .name = "Input Source",
  5313. .count = 2,
  5314. .info = alc883_mux_enum_info,
  5315. .get = alc883_mux_enum_get,
  5316. .put = alc883_mux_enum_put,
  5317. },
  5318. { } /* end */
  5319. };
  5320. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5321. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5322. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5323. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5324. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5325. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5326. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5327. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5328. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5329. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5330. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5331. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5332. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5333. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5334. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5335. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5336. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5337. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5338. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5339. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5340. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5341. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5342. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5343. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5344. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5345. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5346. {
  5347. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5348. /* .name = "Capture Source", */
  5349. .name = "Input Source",
  5350. .count = 2,
  5351. .info = alc883_mux_enum_info,
  5352. .get = alc883_mux_enum_get,
  5353. .put = alc883_mux_enum_put,
  5354. },
  5355. { } /* end */
  5356. };
  5357. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5358. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5359. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5360. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5361. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5362. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5363. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5364. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5365. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5366. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5367. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5368. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5369. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5370. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5371. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5372. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5373. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5374. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5375. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5376. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5377. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5378. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5379. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5380. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5381. {
  5382. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5383. /* .name = "Capture Source", */
  5384. .name = "Input Source",
  5385. .count = 1,
  5386. .info = alc883_mux_enum_info,
  5387. .get = alc883_mux_enum_get,
  5388. .put = alc883_mux_enum_put,
  5389. },
  5390. { } /* end */
  5391. };
  5392. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5393. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5394. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5395. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5396. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5397. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5398. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5399. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5400. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5401. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5402. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5403. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5404. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5405. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5406. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5407. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5408. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5409. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5410. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5411. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5412. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5413. {
  5414. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5415. /* .name = "Capture Source", */
  5416. .name = "Input Source",
  5417. .count = 2,
  5418. .info = alc883_mux_enum_info,
  5419. .get = alc883_mux_enum_get,
  5420. .put = alc883_mux_enum_put,
  5421. },
  5422. { } /* end */
  5423. };
  5424. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5425. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5426. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5427. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5428. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5429. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5430. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5431. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5432. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5433. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5434. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5435. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5436. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5437. {
  5438. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5439. /* .name = "Capture Source", */
  5440. .name = "Input Source",
  5441. .count = 2,
  5442. .info = alc883_mux_enum_info,
  5443. .get = alc883_mux_enum_get,
  5444. .put = alc883_mux_enum_put,
  5445. },
  5446. { } /* end */
  5447. };
  5448. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5449. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5450. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5451. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5452. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5453. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5454. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5455. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5456. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5457. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5458. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5459. {
  5460. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5461. /* .name = "Capture Source", */
  5462. .name = "Input Source",
  5463. .count = 1,
  5464. .info = alc883_mux_enum_info,
  5465. .get = alc883_mux_enum_get,
  5466. .put = alc883_mux_enum_put,
  5467. },
  5468. { } /* end */
  5469. };
  5470. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5471. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5472. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5473. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5474. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5475. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5476. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5477. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5478. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5479. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5480. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5481. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5482. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5483. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5484. {
  5485. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5486. /* .name = "Capture Source", */
  5487. .name = "Input Source",
  5488. .count = 2,
  5489. .info = alc883_mux_enum_info,
  5490. .get = alc883_mux_enum_get,
  5491. .put = alc883_mux_enum_put,
  5492. },
  5493. { } /* end */
  5494. };
  5495. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5496. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5497. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5498. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5499. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5500. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5501. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5502. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5503. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5504. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5505. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5506. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5507. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5508. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5509. {
  5510. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5511. /* .name = "Capture Source", */
  5512. .name = "Input Source",
  5513. .count = 2,
  5514. .info = alc883_mux_enum_info,
  5515. .get = alc883_mux_enum_get,
  5516. .put = alc883_mux_enum_put,
  5517. },
  5518. { } /* end */
  5519. };
  5520. static struct snd_kcontrol_new alc888_hp_nettle_mixer[] = {
  5521. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5522. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5523. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5524. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5525. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5526. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5527. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5528. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5529. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5530. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5531. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5532. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5533. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5534. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5535. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5536. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5537. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5538. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5539. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5540. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5541. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5542. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5543. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5544. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5545. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5546. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5547. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5548. {
  5549. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5550. /* .name = "Capture Source", */
  5551. .name = "Input Source",
  5552. .count = 2,
  5553. .info = alc883_mux_enum_info,
  5554. .get = alc883_mux_enum_get,
  5555. .put = alc883_mux_enum_put,
  5556. },
  5557. { } /* end */
  5558. };
  5559. static struct snd_kcontrol_new alc888_hp_lucknow_mixer[] = {
  5560. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5561. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5562. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5563. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5564. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5565. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5566. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5567. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5568. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5569. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5570. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5571. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5572. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5573. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5574. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5575. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5576. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5577. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5578. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5579. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5580. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5581. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5582. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5583. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5584. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5585. {
  5586. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5587. /* .name = "Capture Source", */
  5588. .name = "Input Source",
  5589. .count = 2,
  5590. .info = alc883_mux_enum_info,
  5591. .get = alc883_mux_enum_get,
  5592. .put = alc883_mux_enum_put,
  5593. },
  5594. { } /* end */
  5595. };
  5596. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5597. {
  5598. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5599. .name = "Channel Mode",
  5600. .info = alc_ch_mode_info,
  5601. .get = alc_ch_mode_get,
  5602. .put = alc_ch_mode_put,
  5603. },
  5604. { } /* end */
  5605. };
  5606. static struct hda_verb alc883_init_verbs[] = {
  5607. /* ADC1: mute amp left and right */
  5608. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5609. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5610. /* ADC2: mute amp left and right */
  5611. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5612. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5613. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5614. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5615. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5616. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5617. /* Rear mixer */
  5618. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5619. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5620. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5621. /* CLFE mixer */
  5622. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5623. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5624. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5625. /* Side mixer */
  5626. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5627. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5628. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5629. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5630. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5631. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5632. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5633. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5634. /* Front Pin: output 0 (0x0c) */
  5635. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5636. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5637. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5638. /* Rear Pin: output 1 (0x0d) */
  5639. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5640. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5641. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5642. /* CLFE Pin: output 2 (0x0e) */
  5643. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5644. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5645. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5646. /* Side Pin: output 3 (0x0f) */
  5647. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5648. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5649. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5650. /* Mic (rear) pin: input vref at 80% */
  5651. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5652. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5653. /* Front Mic pin: input vref at 80% */
  5654. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5655. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5656. /* Line In pin: input */
  5657. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5658. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5659. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5660. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5661. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5662. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5663. /* CD pin widget for input */
  5664. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5665. /* FIXME: use matrix-type input source selection */
  5666. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5667. /* Input mixer2 */
  5668. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5669. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5670. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5671. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5672. /* Input mixer3 */
  5673. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5674. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5675. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5676. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5677. { }
  5678. };
  5679. static struct hda_verb alc883_tagra_verbs[] = {
  5680. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5681. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5682. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5683. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5684. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5685. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5686. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5687. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5688. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5689. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5690. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5691. { } /* end */
  5692. };
  5693. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5694. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5695. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5696. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5697. { } /* end */
  5698. };
  5699. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5700. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5701. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5702. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5703. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5704. { } /* end */
  5705. };
  5706. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5707. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5708. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5709. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5710. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5711. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5712. { } /* end */
  5713. };
  5714. static struct hda_verb alc888_hp_nettle_verbs[] = {
  5715. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5716. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  5717. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  5718. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  5719. { }
  5720. };
  5721. static struct hda_verb alc888_hp_lucknow_verbs[] = {
  5722. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5723. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  5724. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  5725. { }
  5726. };
  5727. static struct hda_verb alc888_hp_lucknow_2ch_init[] = {
  5728. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5729. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5730. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5731. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5732. { }
  5733. };
  5734. static struct hda_verb alc888_hp_lucknow_6ch_init[] = {
  5735. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5736. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5737. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5738. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5739. { }
  5740. };
  5741. static struct hda_channel_mode alc888_hp_lucknow_modes[2] = {
  5742. { 2, alc888_hp_lucknow_2ch_init },
  5743. { 6, alc888_hp_lucknow_6ch_init },
  5744. };
  5745. /* toggle front-jack and RCA according to the hp-jack state */
  5746. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5747. {
  5748. unsigned int present;
  5749. present = snd_hda_codec_read(codec, 0x1b, 0,
  5750. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5751. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5752. 0x80, present ? 0x80 : 0);
  5753. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5754. 0x80, present ? 0x80 : 0);
  5755. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5756. 0x80, present ? 0x80 : 0);
  5757. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5758. 0x80, present ? 0x80 : 0);
  5759. }
  5760. /* toggle RCA according to the front-jack state */
  5761. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5762. {
  5763. unsigned int present;
  5764. present = snd_hda_codec_read(codec, 0x14, 0,
  5765. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5766. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5767. 0x80, present ? 0x80 : 0);
  5768. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5769. 0x80, present ? 0x80 : 0);
  5770. }
  5771. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5772. unsigned int res)
  5773. {
  5774. if ((res >> 26) == ALC880_HP_EVENT)
  5775. alc888_lenovo_ms7195_front_automute(codec);
  5776. if ((res >> 26) == ALC880_FRONT_EVENT)
  5777. alc888_lenovo_ms7195_rca_automute(codec);
  5778. }
  5779. static struct hda_verb alc883_medion_md2_verbs[] = {
  5780. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5781. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5782. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5783. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5784. { } /* end */
  5785. };
  5786. /* toggle speaker-output according to the hp-jack state */
  5787. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5788. {
  5789. unsigned int present;
  5790. present = snd_hda_codec_read(codec, 0x14, 0,
  5791. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5792. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5793. 0x80, present ? 0x80 : 0);
  5794. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5795. 0x80, present ? 0x80 : 0);
  5796. }
  5797. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5798. unsigned int res)
  5799. {
  5800. if ((res >> 26) == ALC880_HP_EVENT)
  5801. alc883_medion_md2_automute(codec);
  5802. }
  5803. /* toggle speaker-output according to the hp-jack state */
  5804. static void alc883_tagra_automute(struct hda_codec *codec)
  5805. {
  5806. unsigned int present;
  5807. unsigned char bits;
  5808. present = snd_hda_codec_read(codec, 0x14, 0,
  5809. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5810. bits = present ? 0x80 : 0;
  5811. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5812. 0x80, bits);
  5813. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5814. 0x80, bits);
  5815. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5816. present ? 1 : 3);
  5817. }
  5818. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5819. {
  5820. if ((res >> 26) == ALC880_HP_EVENT)
  5821. alc883_tagra_automute(codec);
  5822. }
  5823. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5824. {
  5825. unsigned int present;
  5826. unsigned char bits;
  5827. present = snd_hda_codec_read(codec, 0x14, 0,
  5828. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5829. bits = present ? 0x80 : 0;
  5830. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5831. 0x80, bits);
  5832. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5833. 0x80, bits);
  5834. }
  5835. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5836. {
  5837. unsigned int present;
  5838. unsigned char bits;
  5839. present = snd_hda_codec_read(codec, 0x1b, 0,
  5840. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5841. bits = present ? 0x80 : 0;
  5842. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5843. 0x80, bits);
  5844. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5845. 0x80, bits);
  5846. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5847. 0x80, bits);
  5848. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5849. 0x80, bits);
  5850. }
  5851. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5852. unsigned int res)
  5853. {
  5854. if ((res >> 26) == ALC880_HP_EVENT)
  5855. alc883_lenovo_101e_all_automute(codec);
  5856. if ((res >> 26) == ALC880_FRONT_EVENT)
  5857. alc883_lenovo_101e_ispeaker_automute(codec);
  5858. }
  5859. /*
  5860. * generic initialization of ADC, input mixers and output mixers
  5861. */
  5862. static struct hda_verb alc883_auto_init_verbs[] = {
  5863. /*
  5864. * Unmute ADC0-2 and set the default input to mic-in
  5865. */
  5866. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5867. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5868. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5869. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5870. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5871. * mixer widget
  5872. * Note: PASD motherboards uses the Line In 2 as the input for
  5873. * front panel mic (mic 2)
  5874. */
  5875. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5876. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5877. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5878. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5879. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5880. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5881. /*
  5882. * Set up output mixers (0x0c - 0x0f)
  5883. */
  5884. /* set vol=0 to output mixers */
  5885. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5886. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5887. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5888. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5889. /* set up input amps for analog loopback */
  5890. /* Amp Indices: DAC = 0, mixer = 1 */
  5891. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5892. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5893. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5894. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5895. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5896. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5897. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5898. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5899. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5900. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5901. /* FIXME: use matrix-type input source selection */
  5902. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5903. /* Input mixer1 */
  5904. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5905. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5906. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5907. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5908. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5909. /* Input mixer2 */
  5910. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5911. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5912. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5913. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5914. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5915. { }
  5916. };
  5917. /* capture mixer elements */
  5918. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5919. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5920. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5921. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5922. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5923. {
  5924. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5925. /* The multiple "Capture Source" controls confuse alsamixer
  5926. * So call somewhat different..
  5927. * FIXME: the controls appear in the "playback" view!
  5928. */
  5929. /* .name = "Capture Source", */
  5930. .name = "Input Source",
  5931. .count = 2,
  5932. .info = alc882_mux_enum_info,
  5933. .get = alc882_mux_enum_get,
  5934. .put = alc882_mux_enum_put,
  5935. },
  5936. { } /* end */
  5937. };
  5938. /* pcm configuration: identiacal with ALC880 */
  5939. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5940. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5941. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5942. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5943. /*
  5944. * configuration and preset
  5945. */
  5946. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5947. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  5948. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  5949. [ALC883_3ST_6ch] = "3stack-6ch",
  5950. [ALC883_6ST_DIG] = "6stack-dig",
  5951. [ALC883_TARGA_DIG] = "targa-dig",
  5952. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  5953. [ALC883_ACER] = "acer",
  5954. [ALC883_MEDION] = "medion",
  5955. [ALC883_MEDION_MD2] = "medion-md2",
  5956. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  5957. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  5958. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  5959. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  5960. [ALC888_HP_NETTLE] = "hp-nettle",
  5961. [ALC888_HP_LUCKNOW] = "hp-lucknow",
  5962. [ALC883_AUTO] = "auto",
  5963. };
  5964. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  5965. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  5966. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  5967. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  5968. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  5969. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  5970. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  5971. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  5972. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  5973. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  5974. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  5975. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  5976. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  5977. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  5978. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  5979. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  5980. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  5981. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  5982. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  5983. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  5984. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  5985. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  5986. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  5987. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  5988. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  5989. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  5990. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  5991. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  5992. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  5993. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  5994. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5995. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  5996. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_HP_NETTLE),
  5997. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_HP_LUCKNOW),
  5998. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_HP_LUCKNOW),
  5999. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6000. {}
  6001. };
  6002. static struct alc_config_preset alc883_presets[] = {
  6003. [ALC883_3ST_2ch_DIG] = {
  6004. .mixers = { alc883_3ST_2ch_mixer },
  6005. .init_verbs = { alc883_init_verbs },
  6006. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6007. .dac_nids = alc883_dac_nids,
  6008. .dig_out_nid = ALC883_DIGOUT_NID,
  6009. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6010. .adc_nids = alc883_adc_nids,
  6011. .dig_in_nid = ALC883_DIGIN_NID,
  6012. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6013. .channel_mode = alc883_3ST_2ch_modes,
  6014. .input_mux = &alc883_capture_source,
  6015. },
  6016. [ALC883_3ST_6ch_DIG] = {
  6017. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6018. .init_verbs = { alc883_init_verbs },
  6019. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6020. .dac_nids = alc883_dac_nids,
  6021. .dig_out_nid = ALC883_DIGOUT_NID,
  6022. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6023. .adc_nids = alc883_adc_nids,
  6024. .dig_in_nid = ALC883_DIGIN_NID,
  6025. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6026. .channel_mode = alc883_3ST_6ch_modes,
  6027. .need_dac_fix = 1,
  6028. .input_mux = &alc883_capture_source,
  6029. },
  6030. [ALC883_3ST_6ch] = {
  6031. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6032. .init_verbs = { alc883_init_verbs },
  6033. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6034. .dac_nids = alc883_dac_nids,
  6035. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6036. .adc_nids = alc883_adc_nids,
  6037. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6038. .channel_mode = alc883_3ST_6ch_modes,
  6039. .need_dac_fix = 1,
  6040. .input_mux = &alc883_capture_source,
  6041. },
  6042. [ALC883_6ST_DIG] = {
  6043. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6044. .init_verbs = { alc883_init_verbs },
  6045. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6046. .dac_nids = alc883_dac_nids,
  6047. .dig_out_nid = ALC883_DIGOUT_NID,
  6048. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6049. .adc_nids = alc883_adc_nids,
  6050. .dig_in_nid = ALC883_DIGIN_NID,
  6051. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6052. .channel_mode = alc883_sixstack_modes,
  6053. .input_mux = &alc883_capture_source,
  6054. },
  6055. [ALC883_TARGA_DIG] = {
  6056. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6057. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6058. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6059. .dac_nids = alc883_dac_nids,
  6060. .dig_out_nid = ALC883_DIGOUT_NID,
  6061. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6062. .adc_nids = alc883_adc_nids,
  6063. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6064. .channel_mode = alc883_3ST_6ch_modes,
  6065. .need_dac_fix = 1,
  6066. .input_mux = &alc883_capture_source,
  6067. .unsol_event = alc883_tagra_unsol_event,
  6068. .init_hook = alc883_tagra_automute,
  6069. },
  6070. [ALC883_TARGA_2ch_DIG] = {
  6071. .mixers = { alc883_tagra_2ch_mixer},
  6072. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6073. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6074. .dac_nids = alc883_dac_nids,
  6075. .dig_out_nid = ALC883_DIGOUT_NID,
  6076. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6077. .adc_nids = alc883_adc_nids,
  6078. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6079. .channel_mode = alc883_3ST_2ch_modes,
  6080. .input_mux = &alc883_capture_source,
  6081. .unsol_event = alc883_tagra_unsol_event,
  6082. .init_hook = alc883_tagra_automute,
  6083. },
  6084. [ALC883_ACER] = {
  6085. .mixers = { alc883_base_mixer,
  6086. alc883_chmode_mixer },
  6087. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6088. * and the headphone jack. Turn this on and rely on the
  6089. * standard mute methods whenever the user wants to turn
  6090. * these outputs off.
  6091. */
  6092. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6093. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6094. .dac_nids = alc883_dac_nids,
  6095. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6096. .adc_nids = alc883_adc_nids,
  6097. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6098. .channel_mode = alc883_3ST_2ch_modes,
  6099. .input_mux = &alc883_capture_source,
  6100. },
  6101. [ALC883_MEDION] = {
  6102. .mixers = { alc883_fivestack_mixer,
  6103. alc883_chmode_mixer },
  6104. .init_verbs = { alc883_init_verbs,
  6105. alc883_medion_eapd_verbs },
  6106. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6107. .dac_nids = alc883_dac_nids,
  6108. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6109. .adc_nids = alc883_adc_nids,
  6110. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6111. .channel_mode = alc883_sixstack_modes,
  6112. .input_mux = &alc883_capture_source,
  6113. },
  6114. [ALC883_MEDION_MD2] = {
  6115. .mixers = { alc883_medion_md2_mixer},
  6116. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6117. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6118. .dac_nids = alc883_dac_nids,
  6119. .dig_out_nid = ALC883_DIGOUT_NID,
  6120. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6121. .adc_nids = alc883_adc_nids,
  6122. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6123. .channel_mode = alc883_3ST_2ch_modes,
  6124. .input_mux = &alc883_capture_source,
  6125. .unsol_event = alc883_medion_md2_unsol_event,
  6126. .init_hook = alc883_medion_md2_automute,
  6127. },
  6128. [ALC883_LAPTOP_EAPD] = {
  6129. .mixers = { alc883_base_mixer,
  6130. alc883_chmode_mixer },
  6131. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6132. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6133. .dac_nids = alc883_dac_nids,
  6134. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6135. .adc_nids = alc883_adc_nids,
  6136. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6137. .channel_mode = alc883_3ST_2ch_modes,
  6138. .input_mux = &alc883_capture_source,
  6139. },
  6140. [ALC883_LENOVO_101E_2ch] = {
  6141. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6142. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6143. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6144. .dac_nids = alc883_dac_nids,
  6145. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6146. .adc_nids = alc883_adc_nids,
  6147. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6148. .channel_mode = alc883_3ST_2ch_modes,
  6149. .input_mux = &alc883_lenovo_101e_capture_source,
  6150. .unsol_event = alc883_lenovo_101e_unsol_event,
  6151. .init_hook = alc883_lenovo_101e_all_automute,
  6152. },
  6153. [ALC883_LENOVO_NB0763] = {
  6154. .mixers = { alc883_lenovo_nb0763_mixer },
  6155. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6156. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6157. .dac_nids = alc883_dac_nids,
  6158. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6159. .adc_nids = alc883_adc_nids,
  6160. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6161. .channel_mode = alc883_3ST_2ch_modes,
  6162. .need_dac_fix = 1,
  6163. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6164. .unsol_event = alc883_medion_md2_unsol_event,
  6165. .init_hook = alc883_medion_md2_automute,
  6166. },
  6167. [ALC888_LENOVO_MS7195_DIG] = {
  6168. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6169. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6170. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6171. .dac_nids = alc883_dac_nids,
  6172. .dig_out_nid = ALC883_DIGOUT_NID,
  6173. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6174. .adc_nids = alc883_adc_nids,
  6175. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6176. .channel_mode = alc883_3ST_6ch_modes,
  6177. .need_dac_fix = 1,
  6178. .input_mux = &alc883_capture_source,
  6179. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6180. .init_hook = alc888_lenovo_ms7195_front_automute,
  6181. },
  6182. [ALC888_HP_NETTLE] = {
  6183. .mixers = { alc888_hp_nettle_mixer, alc883_chmode_mixer },
  6184. .init_verbs = { alc883_init_verbs, alc888_hp_nettle_verbs },
  6185. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6186. .dac_nids = alc883_dac_nids,
  6187. .dig_out_nid = ALC883_DIGOUT_NID,
  6188. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6189. .adc_nids = alc883_adc_nids,
  6190. .dig_in_nid = ALC883_DIGIN_NID,
  6191. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6192. .channel_mode = alc883_sixstack_modes,
  6193. .input_mux = &alc883_capture_source,
  6194. },
  6195. [ALC888_HP_LUCKNOW] = {
  6196. .mixers = { alc888_hp_lucknow_mixer, alc883_chmode_mixer },
  6197. .init_verbs = { alc883_init_verbs, alc888_hp_lucknow_verbs },
  6198. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6199. .dac_nids = alc883_dac_nids,
  6200. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6201. .adc_nids = alc883_adc_nids,
  6202. .num_channel_mode = ARRAY_SIZE(alc888_hp_lucknow_modes),
  6203. .channel_mode = alc888_hp_lucknow_modes,
  6204. .need_dac_fix = 1,
  6205. .input_mux = &alc883_capture_source,
  6206. },
  6207. };
  6208. /*
  6209. * BIOS auto configuration
  6210. */
  6211. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6212. hda_nid_t nid, int pin_type,
  6213. int dac_idx)
  6214. {
  6215. /* set as output */
  6216. struct alc_spec *spec = codec->spec;
  6217. int idx;
  6218. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6219. idx = 4;
  6220. else
  6221. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6222. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6223. pin_type);
  6224. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6225. AMP_OUT_UNMUTE);
  6226. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6227. }
  6228. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6229. {
  6230. struct alc_spec *spec = codec->spec;
  6231. int i;
  6232. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6233. for (i = 0; i <= HDA_SIDE; i++) {
  6234. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6235. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6236. if (nid)
  6237. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6238. i);
  6239. }
  6240. }
  6241. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6242. {
  6243. struct alc_spec *spec = codec->spec;
  6244. hda_nid_t pin;
  6245. pin = spec->autocfg.hp_pins[0];
  6246. if (pin) /* connect to front */
  6247. /* use dac 0 */
  6248. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6249. }
  6250. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6251. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6252. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6253. {
  6254. struct alc_spec *spec = codec->spec;
  6255. int i;
  6256. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6257. hda_nid_t nid = spec->autocfg.input_pins[i];
  6258. if (alc883_is_input_pin(nid)) {
  6259. snd_hda_codec_write(codec, nid, 0,
  6260. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6261. (i <= AUTO_PIN_FRONT_MIC ?
  6262. PIN_VREF80 : PIN_IN));
  6263. if (nid != ALC883_PIN_CD_NID)
  6264. snd_hda_codec_write(codec, nid, 0,
  6265. AC_VERB_SET_AMP_GAIN_MUTE,
  6266. AMP_OUT_MUTE);
  6267. }
  6268. }
  6269. }
  6270. /* almost identical with ALC880 parser... */
  6271. static int alc883_parse_auto_config(struct hda_codec *codec)
  6272. {
  6273. struct alc_spec *spec = codec->spec;
  6274. int err = alc880_parse_auto_config(codec);
  6275. if (err < 0)
  6276. return err;
  6277. else if (err > 0)
  6278. /* hack - override the init verbs */
  6279. spec->init_verbs[0] = alc883_auto_init_verbs;
  6280. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6281. spec->num_mixers++;
  6282. return err;
  6283. }
  6284. /* additional initialization for auto-configuration model */
  6285. static void alc883_auto_init(struct hda_codec *codec)
  6286. {
  6287. alc883_auto_init_multi_out(codec);
  6288. alc883_auto_init_hp_out(codec);
  6289. alc883_auto_init_analog_input(codec);
  6290. }
  6291. static int patch_alc883(struct hda_codec *codec)
  6292. {
  6293. struct alc_spec *spec;
  6294. int err, board_config;
  6295. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6296. if (spec == NULL)
  6297. return -ENOMEM;
  6298. codec->spec = spec;
  6299. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6300. alc883_models,
  6301. alc883_cfg_tbl);
  6302. if (board_config < 0) {
  6303. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6304. "trying auto-probe from BIOS...\n");
  6305. board_config = ALC883_AUTO;
  6306. }
  6307. if (board_config == ALC883_AUTO) {
  6308. /* automatic parse from the BIOS config */
  6309. err = alc883_parse_auto_config(codec);
  6310. if (err < 0) {
  6311. alc_free(codec);
  6312. return err;
  6313. } else if (!err) {
  6314. printk(KERN_INFO
  6315. "hda_codec: Cannot set up configuration "
  6316. "from BIOS. Using base mode...\n");
  6317. board_config = ALC883_3ST_2ch_DIG;
  6318. }
  6319. }
  6320. if (board_config != ALC883_AUTO)
  6321. setup_preset(spec, &alc883_presets[board_config]);
  6322. spec->stream_name_analog = "ALC883 Analog";
  6323. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6324. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6325. spec->stream_name_digital = "ALC883 Digital";
  6326. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6327. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6328. if (!spec->adc_nids && spec->input_mux) {
  6329. spec->adc_nids = alc883_adc_nids;
  6330. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6331. }
  6332. codec->patch_ops = alc_patch_ops;
  6333. if (board_config == ALC883_AUTO)
  6334. spec->init_hook = alc883_auto_init;
  6335. return 0;
  6336. }
  6337. /*
  6338. * ALC262 support
  6339. */
  6340. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6341. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6342. #define alc262_dac_nids alc260_dac_nids
  6343. #define alc262_adc_nids alc882_adc_nids
  6344. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6345. #define alc262_modes alc260_modes
  6346. #define alc262_capture_source alc882_capture_source
  6347. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6348. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6349. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6350. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6351. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6352. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6353. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6354. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6355. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6356. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6357. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6358. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6359. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6360. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6361. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6362. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6363. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6364. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6365. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6366. { } /* end */
  6367. };
  6368. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6369. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6370. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6371. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6372. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6373. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6374. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6375. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6376. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6377. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6378. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6379. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6380. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6381. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6382. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6383. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6384. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6385. { } /* end */
  6386. };
  6387. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6388. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6389. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6390. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6391. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6392. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6393. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6394. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6395. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6396. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6397. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6398. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6399. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6400. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6401. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6402. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6403. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6404. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6405. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6406. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6407. { } /* end */
  6408. };
  6409. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6410. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6411. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6412. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6413. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6414. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6415. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6416. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6417. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6418. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6419. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6420. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6421. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6422. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6423. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6424. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6425. { } /* end */
  6426. };
  6427. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6428. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6429. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6430. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6431. { } /* end */
  6432. };
  6433. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6434. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6435. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6436. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6437. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6438. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6439. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6440. { } /* end */
  6441. };
  6442. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6443. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6444. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6445. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6446. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6447. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6448. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6449. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6450. { } /* end */
  6451. };
  6452. #define alc262_capture_mixer alc882_capture_mixer
  6453. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6454. /*
  6455. * generic initialization of ADC, input mixers and output mixers
  6456. */
  6457. static struct hda_verb alc262_init_verbs[] = {
  6458. /*
  6459. * Unmute ADC0-2 and set the default input to mic-in
  6460. */
  6461. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6462. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6463. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6464. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6465. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6466. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6467. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6468. * mixer widget
  6469. * Note: PASD motherboards uses the Line In 2 as the input for
  6470. * front panel mic (mic 2)
  6471. */
  6472. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6473. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6474. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6475. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6476. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6477. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6478. /*
  6479. * Set up output mixers (0x0c - 0x0e)
  6480. */
  6481. /* set vol=0 to output mixers */
  6482. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6483. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6484. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6485. /* set up input amps for analog loopback */
  6486. /* Amp Indices: DAC = 0, mixer = 1 */
  6487. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6488. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6489. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6490. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6491. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6492. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6493. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6494. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6495. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6496. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6497. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6498. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6499. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6500. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6501. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6502. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6503. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6504. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6505. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6506. /* FIXME: use matrix-type input source selection */
  6507. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6508. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6509. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6510. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6511. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6512. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6513. /* Input mixer2 */
  6514. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6515. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6516. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6517. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6518. /* Input mixer3 */
  6519. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6520. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6521. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6522. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6523. { }
  6524. };
  6525. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6526. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6527. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6528. {}
  6529. };
  6530. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6531. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6532. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6533. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6534. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6535. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6536. {}
  6537. };
  6538. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6539. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6540. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6541. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6542. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6543. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6544. };
  6545. /* mute/unmute internal speaker according to the hp jack and mute state */
  6546. static void alc262_hippo_automute(struct hda_codec *codec, int force)
  6547. {
  6548. struct alc_spec *spec = codec->spec;
  6549. unsigned int mute;
  6550. if (force || !spec->sense_updated) {
  6551. unsigned int present;
  6552. /* need to execute and sync at first */
  6553. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6554. present = snd_hda_codec_read(codec, 0x15, 0,
  6555. AC_VERB_GET_PIN_SENSE, 0);
  6556. spec->jack_present = (present & 0x80000000) != 0;
  6557. spec->sense_updated = 1;
  6558. }
  6559. if (spec->jack_present) {
  6560. /* mute internal speaker */
  6561. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6562. 0x80, 0x80);
  6563. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6564. 0x80, 0x80);
  6565. } else {
  6566. /* unmute internal speaker if necessary */
  6567. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6568. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6569. 0x80, mute & 0x80);
  6570. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6571. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6572. 0x80, mute & 0x80);
  6573. }
  6574. }
  6575. /* unsolicited event for HP jack sensing */
  6576. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6577. unsigned int res)
  6578. {
  6579. if ((res >> 26) != ALC880_HP_EVENT)
  6580. return;
  6581. alc262_hippo_automute(codec, 1);
  6582. }
  6583. static void alc262_hippo1_automute(struct hda_codec *codec, int force)
  6584. {
  6585. struct alc_spec *spec = codec->spec;
  6586. unsigned int mute;
  6587. if (force || !spec->sense_updated) {
  6588. unsigned int present;
  6589. /* need to execute and sync at first */
  6590. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6591. present = snd_hda_codec_read(codec, 0x1b, 0,
  6592. AC_VERB_GET_PIN_SENSE, 0);
  6593. spec->jack_present = (present & 0x80000000) != 0;
  6594. spec->sense_updated = 1;
  6595. }
  6596. if (spec->jack_present) {
  6597. /* mute internal speaker */
  6598. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6599. 0x80, 0x80);
  6600. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6601. 0x80, 0x80);
  6602. } else {
  6603. /* unmute internal speaker if necessary */
  6604. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6605. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6606. 0x80, mute & 0x80);
  6607. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6608. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6609. 0x80, mute & 0x80);
  6610. }
  6611. }
  6612. /* unsolicited event for HP jack sensing */
  6613. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6614. unsigned int res)
  6615. {
  6616. if ((res >> 26) != ALC880_HP_EVENT)
  6617. return;
  6618. alc262_hippo1_automute(codec, 1);
  6619. }
  6620. /*
  6621. * fujitsu model
  6622. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6623. */
  6624. #define ALC_HP_EVENT 0x37
  6625. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6626. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6627. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6628. {}
  6629. };
  6630. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6631. .num_items = 2,
  6632. .items = {
  6633. { "Mic", 0x0 },
  6634. { "CD", 0x4 },
  6635. },
  6636. };
  6637. static struct hda_input_mux alc262_HP_capture_source = {
  6638. .num_items = 5,
  6639. .items = {
  6640. { "Mic", 0x0 },
  6641. { "Front Mic", 0x3 },
  6642. { "Line", 0x2 },
  6643. { "CD", 0x4 },
  6644. { "AUX IN", 0x6 },
  6645. },
  6646. };
  6647. /* mute/unmute internal speaker according to the hp jack and mute state */
  6648. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6649. {
  6650. struct alc_spec *spec = codec->spec;
  6651. unsigned int mute;
  6652. if (force || !spec->sense_updated) {
  6653. unsigned int present;
  6654. /* need to execute and sync at first */
  6655. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6656. present = snd_hda_codec_read(codec, 0x14, 0,
  6657. AC_VERB_GET_PIN_SENSE, 0);
  6658. spec->jack_present = (present & 0x80000000) != 0;
  6659. spec->sense_updated = 1;
  6660. }
  6661. if (spec->jack_present) {
  6662. /* mute internal speaker */
  6663. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6664. 0x80, 0x80);
  6665. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6666. 0x80, 0x80);
  6667. } else {
  6668. /* unmute internal speaker if necessary */
  6669. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6670. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6671. 0x80, mute & 0x80);
  6672. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6673. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6674. 0x80, mute & 0x80);
  6675. }
  6676. }
  6677. /* unsolicited event for HP jack sensing */
  6678. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6679. unsigned int res)
  6680. {
  6681. if ((res >> 26) != ALC_HP_EVENT)
  6682. return;
  6683. alc262_fujitsu_automute(codec, 1);
  6684. }
  6685. /* bind volumes of both NID 0x0c and 0x0d */
  6686. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6687. struct snd_ctl_elem_value *ucontrol)
  6688. {
  6689. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6690. long *valp = ucontrol->value.integer.value;
  6691. int change;
  6692. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6693. 0x7f, valp[0] & 0x7f);
  6694. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6695. 0x7f, valp[1] & 0x7f);
  6696. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6697. 0x7f, valp[0] & 0x7f);
  6698. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6699. 0x7f, valp[1] & 0x7f);
  6700. return change;
  6701. }
  6702. /* bind hp and internal speaker mute (with plug check) */
  6703. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6704. struct snd_ctl_elem_value *ucontrol)
  6705. {
  6706. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6707. long *valp = ucontrol->value.integer.value;
  6708. int change;
  6709. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6710. 0x80, valp[0] ? 0 : 0x80);
  6711. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6712. 0x80, valp[1] ? 0 : 0x80);
  6713. if (change || codec->in_resume)
  6714. alc262_fujitsu_automute(codec, codec->in_resume);
  6715. return change;
  6716. }
  6717. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6718. {
  6719. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6720. .name = "Master Playback Volume",
  6721. .info = snd_hda_mixer_amp_volume_info,
  6722. .get = snd_hda_mixer_amp_volume_get,
  6723. .put = alc262_fujitsu_master_vol_put,
  6724. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6725. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6726. },
  6727. {
  6728. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6729. .name = "Master Playback Switch",
  6730. .info = snd_hda_mixer_amp_switch_info,
  6731. .get = snd_hda_mixer_amp_switch_get,
  6732. .put = alc262_fujitsu_master_sw_put,
  6733. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6734. },
  6735. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6736. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6737. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6738. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6739. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6740. { } /* end */
  6741. };
  6742. /* additional init verbs for Benq laptops */
  6743. static struct hda_verb alc262_EAPD_verbs[] = {
  6744. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6745. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6746. {}
  6747. };
  6748. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  6749. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6750. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6751. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6752. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6753. {}
  6754. };
  6755. /* add playback controls from the parsed DAC table */
  6756. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6757. const struct auto_pin_cfg *cfg)
  6758. {
  6759. hda_nid_t nid;
  6760. int err;
  6761. spec->multiout.num_dacs = 1; /* only use one dac */
  6762. spec->multiout.dac_nids = spec->private_dac_nids;
  6763. spec->multiout.dac_nids[0] = 2;
  6764. nid = cfg->line_out_pins[0];
  6765. if (nid) {
  6766. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6767. "Front Playback Volume",
  6768. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6769. if (err < 0)
  6770. return err;
  6771. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6772. "Front Playback Switch",
  6773. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6774. if (err < 0)
  6775. return err;
  6776. }
  6777. nid = cfg->speaker_pins[0];
  6778. if (nid) {
  6779. if (nid == 0x16) {
  6780. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6781. "Speaker Playback Volume",
  6782. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6783. HDA_OUTPUT));
  6784. if (err < 0)
  6785. return err;
  6786. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6787. "Speaker Playback Switch",
  6788. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6789. HDA_OUTPUT));
  6790. if (err < 0)
  6791. return err;
  6792. } else {
  6793. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6794. "Speaker Playback Switch",
  6795. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6796. HDA_OUTPUT));
  6797. if (err < 0)
  6798. return err;
  6799. }
  6800. }
  6801. nid = cfg->hp_pins[0];
  6802. if (nid) {
  6803. /* spec->multiout.hp_nid = 2; */
  6804. if (nid == 0x16) {
  6805. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6806. "Headphone Playback Volume",
  6807. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6808. HDA_OUTPUT));
  6809. if (err < 0)
  6810. return err;
  6811. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6812. "Headphone Playback Switch",
  6813. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6814. HDA_OUTPUT));
  6815. if (err < 0)
  6816. return err;
  6817. } else {
  6818. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6819. "Headphone Playback Switch",
  6820. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6821. HDA_OUTPUT));
  6822. if (err < 0)
  6823. return err;
  6824. }
  6825. }
  6826. return 0;
  6827. }
  6828. /* identical with ALC880 */
  6829. #define alc262_auto_create_analog_input_ctls \
  6830. alc880_auto_create_analog_input_ctls
  6831. /*
  6832. * generic initialization of ADC, input mixers and output mixers
  6833. */
  6834. static struct hda_verb alc262_volume_init_verbs[] = {
  6835. /*
  6836. * Unmute ADC0-2 and set the default input to mic-in
  6837. */
  6838. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6839. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6840. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6841. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6842. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6843. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6844. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6845. * mixer widget
  6846. * Note: PASD motherboards uses the Line In 2 as the input for
  6847. * front panel mic (mic 2)
  6848. */
  6849. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6850. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6851. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6852. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6853. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6854. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6855. /*
  6856. * Set up output mixers (0x0c - 0x0f)
  6857. */
  6858. /* set vol=0 to output mixers */
  6859. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6860. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6861. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6862. /* set up input amps for analog loopback */
  6863. /* Amp Indices: DAC = 0, mixer = 1 */
  6864. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6865. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6866. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6867. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6868. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6869. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6870. /* FIXME: use matrix-type input source selection */
  6871. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6872. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6873. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6874. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6875. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6876. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6877. /* Input mixer2 */
  6878. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6879. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6880. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6881. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6882. /* Input mixer3 */
  6883. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6884. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6885. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6886. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6887. { }
  6888. };
  6889. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6890. /*
  6891. * Unmute ADC0-2 and set the default input to mic-in
  6892. */
  6893. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6894. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6895. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6896. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6897. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6898. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6899. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6900. * mixer widget
  6901. * Note: PASD motherboards uses the Line In 2 as the input for
  6902. * front panel mic (mic 2)
  6903. */
  6904. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6905. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6906. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6907. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6908. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6909. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6910. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6911. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6912. /*
  6913. * Set up output mixers (0x0c - 0x0e)
  6914. */
  6915. /* set vol=0 to output mixers */
  6916. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6917. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6918. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6919. /* set up input amps for analog loopback */
  6920. /* Amp Indices: DAC = 0, mixer = 1 */
  6921. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6922. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6923. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6924. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6925. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6926. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6927. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6928. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6929. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6930. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6931. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6932. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6933. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6934. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6935. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6936. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6937. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6938. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6939. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6940. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6941. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6942. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  6943. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6944. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  6945. /* FIXME: use matrix-type input source selection */
  6946. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6947. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6948. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6949. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6950. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6951. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6952. /* Input mixer2 */
  6953. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6954. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6955. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6956. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6957. /* Input mixer3 */
  6958. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6959. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  6960. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  6961. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  6962. { }
  6963. };
  6964. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  6965. /*
  6966. * Unmute ADC0-2 and set the default input to mic-in
  6967. */
  6968. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6969. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6970. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6971. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6972. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6973. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6974. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6975. * mixer widget
  6976. * Note: PASD motherboards uses the Line In 2 as the input for front
  6977. * panel mic (mic 2)
  6978. */
  6979. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6980. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6981. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6982. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6983. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6984. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6985. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6986. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6987. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  6988. /*
  6989. * Set up output mixers (0x0c - 0x0e)
  6990. */
  6991. /* set vol=0 to output mixers */
  6992. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6993. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6994. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6995. /* set up input amps for analog loopback */
  6996. /* Amp Indices: DAC = 0, mixer = 1 */
  6997. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6998. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6999. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7000. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7001. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7002. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7003. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7004. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7005. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7006. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7007. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7008. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7009. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7010. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7011. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7012. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7013. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7014. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7015. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7016. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7017. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7018. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7019. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7020. /* FIXME: use matrix-type input source selection */
  7021. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7022. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7023. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7024. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7025. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7026. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7027. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7028. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7029. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7030. /* Input mixer2 */
  7031. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7032. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7033. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7034. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7035. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7036. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7037. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7038. /* Input mixer3 */
  7039. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7040. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7041. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7042. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7043. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7044. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7045. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7046. { }
  7047. };
  7048. /* pcm configuration: identiacal with ALC880 */
  7049. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7050. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7051. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7052. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7053. /*
  7054. * BIOS auto configuration
  7055. */
  7056. static int alc262_parse_auto_config(struct hda_codec *codec)
  7057. {
  7058. struct alc_spec *spec = codec->spec;
  7059. int err;
  7060. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7061. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7062. alc262_ignore);
  7063. if (err < 0)
  7064. return err;
  7065. if (!spec->autocfg.line_outs)
  7066. return 0; /* can't find valid BIOS pin config */
  7067. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7068. if (err < 0)
  7069. return err;
  7070. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7071. if (err < 0)
  7072. return err;
  7073. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7074. if (spec->autocfg.dig_out_pin)
  7075. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7076. if (spec->autocfg.dig_in_pin)
  7077. spec->dig_in_nid = ALC262_DIGIN_NID;
  7078. if (spec->kctl_alloc)
  7079. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7080. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7081. spec->num_mux_defs = 1;
  7082. spec->input_mux = &spec->private_imux;
  7083. return 1;
  7084. }
  7085. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7086. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7087. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7088. /* init callback for auto-configuration model -- overriding the default init */
  7089. static void alc262_auto_init(struct hda_codec *codec)
  7090. {
  7091. alc262_auto_init_multi_out(codec);
  7092. alc262_auto_init_hp_out(codec);
  7093. alc262_auto_init_analog_input(codec);
  7094. }
  7095. /*
  7096. * configuration and preset
  7097. */
  7098. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7099. [ALC262_BASIC] = "basic",
  7100. [ALC262_HIPPO] = "hippo",
  7101. [ALC262_HIPPO_1] = "hippo_1",
  7102. [ALC262_FUJITSU] = "fujitsu",
  7103. [ALC262_HP_BPC] = "hp-bpc",
  7104. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7105. [ALC262_BENQ_ED8] = "benq",
  7106. [ALC262_BENQ_T31] = "benq-t31",
  7107. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7108. [ALC262_AUTO] = "auto",
  7109. };
  7110. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7111. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7112. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7113. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7114. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7115. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7116. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7117. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7118. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7119. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7120. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7121. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7122. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7123. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7124. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7125. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7126. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7127. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7128. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7129. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7130. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7131. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7132. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7133. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7134. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7135. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7136. {}
  7137. };
  7138. static struct alc_config_preset alc262_presets[] = {
  7139. [ALC262_BASIC] = {
  7140. .mixers = { alc262_base_mixer },
  7141. .init_verbs = { alc262_init_verbs },
  7142. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7143. .dac_nids = alc262_dac_nids,
  7144. .hp_nid = 0x03,
  7145. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7146. .channel_mode = alc262_modes,
  7147. .input_mux = &alc262_capture_source,
  7148. },
  7149. [ALC262_HIPPO] = {
  7150. .mixers = { alc262_base_mixer },
  7151. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7152. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7153. .dac_nids = alc262_dac_nids,
  7154. .hp_nid = 0x03,
  7155. .dig_out_nid = ALC262_DIGOUT_NID,
  7156. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7157. .channel_mode = alc262_modes,
  7158. .input_mux = &alc262_capture_source,
  7159. .unsol_event = alc262_hippo_unsol_event,
  7160. },
  7161. [ALC262_HIPPO_1] = {
  7162. .mixers = { alc262_hippo1_mixer },
  7163. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7164. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7165. .dac_nids = alc262_dac_nids,
  7166. .hp_nid = 0x02,
  7167. .dig_out_nid = ALC262_DIGOUT_NID,
  7168. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7169. .channel_mode = alc262_modes,
  7170. .input_mux = &alc262_capture_source,
  7171. .unsol_event = alc262_hippo1_unsol_event,
  7172. },
  7173. [ALC262_FUJITSU] = {
  7174. .mixers = { alc262_fujitsu_mixer },
  7175. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7176. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7177. .dac_nids = alc262_dac_nids,
  7178. .hp_nid = 0x03,
  7179. .dig_out_nid = ALC262_DIGOUT_NID,
  7180. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7181. .channel_mode = alc262_modes,
  7182. .input_mux = &alc262_fujitsu_capture_source,
  7183. .unsol_event = alc262_fujitsu_unsol_event,
  7184. },
  7185. [ALC262_HP_BPC] = {
  7186. .mixers = { alc262_HP_BPC_mixer },
  7187. .init_verbs = { alc262_HP_BPC_init_verbs },
  7188. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7189. .dac_nids = alc262_dac_nids,
  7190. .hp_nid = 0x03,
  7191. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7192. .channel_mode = alc262_modes,
  7193. .input_mux = &alc262_HP_capture_source,
  7194. },
  7195. [ALC262_HP_BPC_D7000_WF] = {
  7196. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7197. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7198. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7199. .dac_nids = alc262_dac_nids,
  7200. .hp_nid = 0x03,
  7201. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7202. .channel_mode = alc262_modes,
  7203. .input_mux = &alc262_HP_capture_source,
  7204. },
  7205. [ALC262_HP_BPC_D7000_WL] = {
  7206. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7207. alc262_HP_BPC_WildWest_option_mixer },
  7208. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7209. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7210. .dac_nids = alc262_dac_nids,
  7211. .hp_nid = 0x03,
  7212. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7213. .channel_mode = alc262_modes,
  7214. .input_mux = &alc262_HP_capture_source,
  7215. },
  7216. [ALC262_BENQ_ED8] = {
  7217. .mixers = { alc262_base_mixer },
  7218. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7219. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7220. .dac_nids = alc262_dac_nids,
  7221. .hp_nid = 0x03,
  7222. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7223. .channel_mode = alc262_modes,
  7224. .input_mux = &alc262_capture_source,
  7225. },
  7226. [ALC262_SONY_ASSAMD] = {
  7227. .mixers = { alc262_sony_mixer },
  7228. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7229. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7230. .dac_nids = alc262_dac_nids,
  7231. .hp_nid = 0x02,
  7232. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7233. .channel_mode = alc262_modes,
  7234. .input_mux = &alc262_capture_source,
  7235. .unsol_event = alc262_hippo_unsol_event,
  7236. },
  7237. [ALC262_BENQ_T31] = {
  7238. .mixers = { alc262_benq_t31_mixer },
  7239. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7240. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7241. .dac_nids = alc262_dac_nids,
  7242. .hp_nid = 0x03,
  7243. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7244. .channel_mode = alc262_modes,
  7245. .input_mux = &alc262_capture_source,
  7246. .unsol_event = alc262_hippo_unsol_event,
  7247. },
  7248. };
  7249. static int patch_alc262(struct hda_codec *codec)
  7250. {
  7251. struct alc_spec *spec;
  7252. int board_config;
  7253. int err;
  7254. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7255. if (spec == NULL)
  7256. return -ENOMEM;
  7257. codec->spec = spec;
  7258. #if 0
  7259. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7260. * under-run
  7261. */
  7262. {
  7263. int tmp;
  7264. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7265. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7266. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7267. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7268. }
  7269. #endif
  7270. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7271. alc262_models,
  7272. alc262_cfg_tbl);
  7273. if (board_config < 0) {
  7274. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7275. "trying auto-probe from BIOS...\n");
  7276. board_config = ALC262_AUTO;
  7277. }
  7278. if (board_config == ALC262_AUTO) {
  7279. /* automatic parse from the BIOS config */
  7280. err = alc262_parse_auto_config(codec);
  7281. if (err < 0) {
  7282. alc_free(codec);
  7283. return err;
  7284. } else if (!err) {
  7285. printk(KERN_INFO
  7286. "hda_codec: Cannot set up configuration "
  7287. "from BIOS. Using base mode...\n");
  7288. board_config = ALC262_BASIC;
  7289. }
  7290. }
  7291. if (board_config != ALC262_AUTO)
  7292. setup_preset(spec, &alc262_presets[board_config]);
  7293. spec->stream_name_analog = "ALC262 Analog";
  7294. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7295. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7296. spec->stream_name_digital = "ALC262 Digital";
  7297. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7298. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7299. if (!spec->adc_nids && spec->input_mux) {
  7300. /* check whether NID 0x07 is valid */
  7301. unsigned int wcap = get_wcaps(codec, 0x07);
  7302. /* get type */
  7303. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7304. if (wcap != AC_WID_AUD_IN) {
  7305. spec->adc_nids = alc262_adc_nids_alt;
  7306. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7307. spec->mixers[spec->num_mixers] =
  7308. alc262_capture_alt_mixer;
  7309. spec->num_mixers++;
  7310. } else {
  7311. spec->adc_nids = alc262_adc_nids;
  7312. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7313. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7314. spec->num_mixers++;
  7315. }
  7316. }
  7317. codec->patch_ops = alc_patch_ops;
  7318. if (board_config == ALC262_AUTO)
  7319. spec->init_hook = alc262_auto_init;
  7320. return 0;
  7321. }
  7322. /*
  7323. * ALC268 channel source setting (2 channel)
  7324. */
  7325. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7326. #define alc268_modes alc260_modes
  7327. static hda_nid_t alc268_dac_nids[2] = {
  7328. /* front, hp */
  7329. 0x02, 0x03
  7330. };
  7331. static hda_nid_t alc268_adc_nids[2] = {
  7332. /* ADC0-1 */
  7333. 0x08, 0x07
  7334. };
  7335. static hda_nid_t alc268_adc_nids_alt[1] = {
  7336. /* ADC0 */
  7337. 0x08
  7338. };
  7339. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7340. /* output mixer control */
  7341. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7342. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7343. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7344. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7345. { }
  7346. };
  7347. /*
  7348. * generic initialization of ADC, input mixers and output mixers
  7349. */
  7350. static struct hda_verb alc268_base_init_verbs[] = {
  7351. /* Unmute DAC0-1 and set vol = 0 */
  7352. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7353. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7354. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7355. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7356. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7357. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7358. /*
  7359. * Set up output mixers (0x0c - 0x0e)
  7360. */
  7361. /* set vol=0 to output mixers */
  7362. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7363. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7364. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7365. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7366. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7367. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7368. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7369. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7370. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7371. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7372. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7373. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7374. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7375. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7376. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7377. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7378. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7379. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7380. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7381. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7382. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7383. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7384. /* FIXME: use matrix-type input source selection */
  7385. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7386. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7387. /* Input mixer2 */
  7388. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7389. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7390. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7391. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7392. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7393. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7394. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7395. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7396. { }
  7397. };
  7398. /*
  7399. * generic initialization of ADC, input mixers and output mixers
  7400. */
  7401. static struct hda_verb alc268_volume_init_verbs[] = {
  7402. /* set output DAC */
  7403. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7404. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7405. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7406. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7407. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7408. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7409. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7410. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7411. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7412. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7413. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7414. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7415. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7416. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7417. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7418. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7419. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7420. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7421. /* set PCBEEP vol = 0 */
  7422. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7423. { }
  7424. };
  7425. #define alc268_mux_enum_info alc_mux_enum_info
  7426. #define alc268_mux_enum_get alc_mux_enum_get
  7427. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7428. struct snd_ctl_elem_value *ucontrol)
  7429. {
  7430. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7431. struct alc_spec *spec = codec->spec;
  7432. const struct hda_input_mux *imux = spec->input_mux;
  7433. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7434. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7435. hda_nid_t nid = capture_mixers[adc_idx];
  7436. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7437. unsigned int i, idx;
  7438. idx = ucontrol->value.enumerated.item[0];
  7439. if (idx >= imux->num_items)
  7440. idx = imux->num_items - 1;
  7441. if (*cur_val == idx && !codec->in_resume)
  7442. return 0;
  7443. for (i = 0; i < imux->num_items; i++) {
  7444. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7445. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7446. v | (imux->items[i].index << 8));
  7447. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
  7448. idx );
  7449. }
  7450. *cur_val = idx;
  7451. return 1;
  7452. }
  7453. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7454. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7455. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7456. {
  7457. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7458. /* The multiple "Capture Source" controls confuse alsamixer
  7459. * So call somewhat different..
  7460. * FIXME: the controls appear in the "playback" view!
  7461. */
  7462. /* .name = "Capture Source", */
  7463. .name = "Input Source",
  7464. .count = 1,
  7465. .info = alc268_mux_enum_info,
  7466. .get = alc268_mux_enum_get,
  7467. .put = alc268_mux_enum_put,
  7468. },
  7469. { } /* end */
  7470. };
  7471. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7472. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7473. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7474. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7475. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7476. {
  7477. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7478. /* The multiple "Capture Source" controls confuse alsamixer
  7479. * So call somewhat different..
  7480. * FIXME: the controls appear in the "playback" view!
  7481. */
  7482. /* .name = "Capture Source", */
  7483. .name = "Input Source",
  7484. .count = 2,
  7485. .info = alc268_mux_enum_info,
  7486. .get = alc268_mux_enum_get,
  7487. .put = alc268_mux_enum_put,
  7488. },
  7489. { } /* end */
  7490. };
  7491. static struct hda_input_mux alc268_capture_source = {
  7492. .num_items = 4,
  7493. .items = {
  7494. { "Mic", 0x0 },
  7495. { "Front Mic", 0x1 },
  7496. { "Line", 0x2 },
  7497. { "CD", 0x3 },
  7498. },
  7499. };
  7500. /* create input playback/capture controls for the given pin */
  7501. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7502. const char *ctlname, int idx)
  7503. {
  7504. char name[32];
  7505. int err;
  7506. sprintf(name, "%s Playback Volume", ctlname);
  7507. if (nid == 0x14) {
  7508. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7509. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7510. HDA_OUTPUT));
  7511. if (err < 0)
  7512. return err;
  7513. } else if (nid == 0x15) {
  7514. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7515. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7516. HDA_OUTPUT));
  7517. if (err < 0)
  7518. return err;
  7519. } else
  7520. return -1;
  7521. sprintf(name, "%s Playback Switch", ctlname);
  7522. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7523. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7524. if (err < 0)
  7525. return err;
  7526. return 0;
  7527. }
  7528. /* add playback controls from the parsed DAC table */
  7529. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7530. const struct auto_pin_cfg *cfg)
  7531. {
  7532. hda_nid_t nid;
  7533. int err;
  7534. spec->multiout.num_dacs = 2; /* only use one dac */
  7535. spec->multiout.dac_nids = spec->private_dac_nids;
  7536. spec->multiout.dac_nids[0] = 2;
  7537. spec->multiout.dac_nids[1] = 3;
  7538. nid = cfg->line_out_pins[0];
  7539. if (nid)
  7540. alc268_new_analog_output(spec, nid, "Front", 0);
  7541. nid = cfg->speaker_pins[0];
  7542. if (nid == 0x1d) {
  7543. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7544. "Speaker Playback Volume",
  7545. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7546. if (err < 0)
  7547. return err;
  7548. }
  7549. nid = cfg->hp_pins[0];
  7550. if (nid)
  7551. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7552. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7553. if (nid == 0x16) {
  7554. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7555. "Mono Playback Switch",
  7556. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7557. if (err < 0)
  7558. return err;
  7559. }
  7560. return 0;
  7561. }
  7562. /* create playback/capture controls for input pins */
  7563. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7564. const struct auto_pin_cfg *cfg)
  7565. {
  7566. struct hda_input_mux *imux = &spec->private_imux;
  7567. int i, idx1;
  7568. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7569. switch(cfg->input_pins[i]) {
  7570. case 0x18:
  7571. idx1 = 0; /* Mic 1 */
  7572. break;
  7573. case 0x19:
  7574. idx1 = 1; /* Mic 2 */
  7575. break;
  7576. case 0x1a:
  7577. idx1 = 2; /* Line In */
  7578. break;
  7579. case 0x1c:
  7580. idx1 = 3; /* CD */
  7581. break;
  7582. default:
  7583. continue;
  7584. }
  7585. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7586. imux->items[imux->num_items].index = idx1;
  7587. imux->num_items++;
  7588. }
  7589. return 0;
  7590. }
  7591. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7592. {
  7593. struct alc_spec *spec = codec->spec;
  7594. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7595. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7596. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7597. unsigned int dac_vol1, dac_vol2;
  7598. if (speaker_nid) {
  7599. snd_hda_codec_write(codec, speaker_nid, 0,
  7600. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7601. snd_hda_codec_write(codec, 0x0f, 0,
  7602. AC_VERB_SET_AMP_GAIN_MUTE,
  7603. AMP_IN_UNMUTE(1));
  7604. snd_hda_codec_write(codec, 0x10, 0,
  7605. AC_VERB_SET_AMP_GAIN_MUTE,
  7606. AMP_IN_UNMUTE(1));
  7607. } else {
  7608. snd_hda_codec_write(codec, 0x0f, 0,
  7609. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7610. snd_hda_codec_write(codec, 0x10, 0,
  7611. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7612. }
  7613. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7614. if (line_nid == 0x14)
  7615. dac_vol2 = AMP_OUT_ZERO;
  7616. else if (line_nid == 0x15)
  7617. dac_vol1 = AMP_OUT_ZERO;
  7618. if (hp_nid == 0x14)
  7619. dac_vol2 = AMP_OUT_ZERO;
  7620. else if (hp_nid == 0x15)
  7621. dac_vol1 = AMP_OUT_ZERO;
  7622. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7623. spec->autocfg.line_out_pins[1] != 0x16 ||
  7624. spec->autocfg.line_out_pins[2] != 0x16)
  7625. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7626. snd_hda_codec_write(codec, 0x02, 0,
  7627. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7628. snd_hda_codec_write(codec, 0x03, 0,
  7629. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7630. }
  7631. /* pcm configuration: identiacal with ALC880 */
  7632. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7633. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7634. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7635. /*
  7636. * BIOS auto configuration
  7637. */
  7638. static int alc268_parse_auto_config(struct hda_codec *codec)
  7639. {
  7640. struct alc_spec *spec = codec->spec;
  7641. int err;
  7642. static hda_nid_t alc268_ignore[] = { 0 };
  7643. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7644. alc268_ignore);
  7645. if (err < 0)
  7646. return err;
  7647. if (!spec->autocfg.line_outs)
  7648. return 0; /* can't find valid BIOS pin config */
  7649. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7650. if (err < 0)
  7651. return err;
  7652. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7653. if (err < 0)
  7654. return err;
  7655. spec->multiout.max_channels = 2;
  7656. /* digital only support output */
  7657. if (spec->autocfg.dig_out_pin)
  7658. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7659. if (spec->kctl_alloc)
  7660. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7661. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7662. spec->num_mux_defs = 1;
  7663. spec->input_mux = &spec->private_imux;
  7664. return 1;
  7665. }
  7666. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7667. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7668. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7669. /* init callback for auto-configuration model -- overriding the default init */
  7670. static void alc268_auto_init(struct hda_codec *codec)
  7671. {
  7672. alc268_auto_init_multi_out(codec);
  7673. alc268_auto_init_hp_out(codec);
  7674. alc268_auto_init_mono_speaker_out(codec);
  7675. alc268_auto_init_analog_input(codec);
  7676. }
  7677. /*
  7678. * configuration and preset
  7679. */
  7680. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7681. [ALC268_3ST] = "3stack",
  7682. [ALC268_AUTO] = "auto",
  7683. };
  7684. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7685. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7686. {}
  7687. };
  7688. static struct alc_config_preset alc268_presets[] = {
  7689. [ALC268_3ST] = {
  7690. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7691. .init_verbs = { alc268_base_init_verbs },
  7692. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7693. .dac_nids = alc268_dac_nids,
  7694. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7695. .adc_nids = alc268_adc_nids_alt,
  7696. .hp_nid = 0x03,
  7697. .dig_out_nid = ALC268_DIGOUT_NID,
  7698. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7699. .channel_mode = alc268_modes,
  7700. .input_mux = &alc268_capture_source,
  7701. },
  7702. };
  7703. static int patch_alc268(struct hda_codec *codec)
  7704. {
  7705. struct alc_spec *spec;
  7706. int board_config;
  7707. int err;
  7708. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7709. if (spec == NULL)
  7710. return -ENOMEM;
  7711. codec->spec = spec;
  7712. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7713. alc268_models,
  7714. alc268_cfg_tbl);
  7715. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7716. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7717. "trying auto-probe from BIOS...\n");
  7718. board_config = ALC268_AUTO;
  7719. }
  7720. if (board_config == ALC268_AUTO) {
  7721. /* automatic parse from the BIOS config */
  7722. err = alc268_parse_auto_config(codec);
  7723. if (err < 0) {
  7724. alc_free(codec);
  7725. return err;
  7726. } else if (!err) {
  7727. printk(KERN_INFO
  7728. "hda_codec: Cannot set up configuration "
  7729. "from BIOS. Using base mode...\n");
  7730. board_config = ALC268_3ST;
  7731. }
  7732. }
  7733. if (board_config != ALC268_AUTO)
  7734. setup_preset(spec, &alc268_presets[board_config]);
  7735. spec->stream_name_analog = "ALC268 Analog";
  7736. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7737. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7738. spec->stream_name_digital = "ALC268 Digital";
  7739. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7740. if (board_config == ALC268_AUTO) {
  7741. if (!spec->adc_nids && spec->input_mux) {
  7742. /* check whether NID 0x07 is valid */
  7743. unsigned int wcap = get_wcaps(codec, 0x07);
  7744. /* get type */
  7745. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7746. if (wcap != AC_WID_AUD_IN) {
  7747. spec->adc_nids = alc268_adc_nids_alt;
  7748. spec->num_adc_nids =
  7749. ARRAY_SIZE(alc268_adc_nids_alt);
  7750. spec->mixers[spec->num_mixers] =
  7751. alc268_capture_alt_mixer;
  7752. spec->num_mixers++;
  7753. } else {
  7754. spec->adc_nids = alc268_adc_nids;
  7755. spec->num_adc_nids =
  7756. ARRAY_SIZE(alc268_adc_nids);
  7757. spec->mixers[spec->num_mixers] =
  7758. alc268_capture_mixer;
  7759. spec->num_mixers++;
  7760. }
  7761. }
  7762. }
  7763. codec->patch_ops = alc_patch_ops;
  7764. if (board_config == ALC268_AUTO)
  7765. spec->init_hook = alc268_auto_init;
  7766. return 0;
  7767. }
  7768. /*
  7769. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7770. */
  7771. /*
  7772. * set the path ways for 2 channel output
  7773. * need to set the codec line out and mic 1 pin widgets to inputs
  7774. */
  7775. static struct hda_verb alc861_threestack_ch2_init[] = {
  7776. /* set pin widget 1Ah (line in) for input */
  7777. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7778. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7779. * the vref
  7780. */
  7781. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7782. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7783. #if 0
  7784. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7785. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7786. #endif
  7787. { } /* end */
  7788. };
  7789. /*
  7790. * 6ch mode
  7791. * need to set the codec line out and mic 1 pin widgets to outputs
  7792. */
  7793. static struct hda_verb alc861_threestack_ch6_init[] = {
  7794. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7795. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7796. /* set pin widget 18h (mic1) for output (CLFE)*/
  7797. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7798. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7799. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7800. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7801. #if 0
  7802. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7803. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7804. #endif
  7805. { } /* end */
  7806. };
  7807. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7808. { 2, alc861_threestack_ch2_init },
  7809. { 6, alc861_threestack_ch6_init },
  7810. };
  7811. /* Set mic1 as input and unmute the mixer */
  7812. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7813. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7814. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7815. { } /* end */
  7816. };
  7817. /* Set mic1 as output and mute mixer */
  7818. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7819. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7820. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7821. { } /* end */
  7822. };
  7823. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7824. { 2, alc861_uniwill_m31_ch2_init },
  7825. { 4, alc861_uniwill_m31_ch4_init },
  7826. };
  7827. /* Set mic1 and line-in as input and unmute the mixer */
  7828. static struct hda_verb alc861_asus_ch2_init[] = {
  7829. /* set pin widget 1Ah (line in) for input */
  7830. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7831. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7832. * the vref
  7833. */
  7834. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7835. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7836. #if 0
  7837. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7838. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7839. #endif
  7840. { } /* end */
  7841. };
  7842. /* Set mic1 nad line-in as output and mute mixer */
  7843. static struct hda_verb alc861_asus_ch6_init[] = {
  7844. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7845. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7846. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7847. /* set pin widget 18h (mic1) for output (CLFE)*/
  7848. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7849. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7850. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7851. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7852. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7853. #if 0
  7854. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7855. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7856. #endif
  7857. { } /* end */
  7858. };
  7859. static struct hda_channel_mode alc861_asus_modes[2] = {
  7860. { 2, alc861_asus_ch2_init },
  7861. { 6, alc861_asus_ch6_init },
  7862. };
  7863. /* patch-ALC861 */
  7864. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7865. /* output mixer control */
  7866. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7867. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7868. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7869. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7870. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7871. /*Input mixer control */
  7872. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7873. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7874. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7875. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7876. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7877. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7878. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7879. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7880. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7881. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7882. /* Capture mixer control */
  7883. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7884. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7885. {
  7886. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7887. .name = "Capture Source",
  7888. .count = 1,
  7889. .info = alc_mux_enum_info,
  7890. .get = alc_mux_enum_get,
  7891. .put = alc_mux_enum_put,
  7892. },
  7893. { } /* end */
  7894. };
  7895. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7896. /* output mixer control */
  7897. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7898. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7899. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7900. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7901. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7902. /* Input mixer control */
  7903. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7904. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7905. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7906. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7907. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7908. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7909. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7910. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7911. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7912. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7913. /* Capture mixer control */
  7914. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7915. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7916. {
  7917. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7918. .name = "Capture Source",
  7919. .count = 1,
  7920. .info = alc_mux_enum_info,
  7921. .get = alc_mux_enum_get,
  7922. .put = alc_mux_enum_put,
  7923. },
  7924. {
  7925. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7926. .name = "Channel Mode",
  7927. .info = alc_ch_mode_info,
  7928. .get = alc_ch_mode_get,
  7929. .put = alc_ch_mode_put,
  7930. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7931. },
  7932. { } /* end */
  7933. };
  7934. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  7935. /* output mixer control */
  7936. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7937. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7938. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7939. /*Capture mixer control */
  7940. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7941. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7942. {
  7943. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7944. .name = "Capture Source",
  7945. .count = 1,
  7946. .info = alc_mux_enum_info,
  7947. .get = alc_mux_enum_get,
  7948. .put = alc_mux_enum_put,
  7949. },
  7950. { } /* end */
  7951. };
  7952. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  7953. /* output mixer control */
  7954. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7955. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7956. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7957. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7958. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7959. /* Input mixer control */
  7960. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7961. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7962. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7963. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7964. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7965. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7966. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7967. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7968. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7969. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7970. /* Capture mixer control */
  7971. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7972. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7973. {
  7974. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7975. .name = "Capture Source",
  7976. .count = 1,
  7977. .info = alc_mux_enum_info,
  7978. .get = alc_mux_enum_get,
  7979. .put = alc_mux_enum_put,
  7980. },
  7981. {
  7982. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7983. .name = "Channel Mode",
  7984. .info = alc_ch_mode_info,
  7985. .get = alc_ch_mode_get,
  7986. .put = alc_ch_mode_put,
  7987. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  7988. },
  7989. { } /* end */
  7990. };
  7991. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  7992. /* output mixer control */
  7993. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7994. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7995. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7996. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7997. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7998. /* Input mixer control */
  7999. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8000. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8001. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8002. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8003. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8004. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8005. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8006. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8007. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8008. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8009. /* Capture mixer control */
  8010. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8011. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8012. {
  8013. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8014. .name = "Capture Source",
  8015. .count = 1,
  8016. .info = alc_mux_enum_info,
  8017. .get = alc_mux_enum_get,
  8018. .put = alc_mux_enum_put,
  8019. },
  8020. {
  8021. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8022. .name = "Channel Mode",
  8023. .info = alc_ch_mode_info,
  8024. .get = alc_ch_mode_get,
  8025. .put = alc_ch_mode_put,
  8026. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8027. },
  8028. { }
  8029. };
  8030. /* additional mixer */
  8031. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8032. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8033. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8034. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8035. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8036. { }
  8037. };
  8038. /*
  8039. * generic initialization of ADC, input mixers and output mixers
  8040. */
  8041. static struct hda_verb alc861_base_init_verbs[] = {
  8042. /*
  8043. * Unmute ADC0 and set the default input to mic-in
  8044. */
  8045. /* port-A for surround (rear panel) */
  8046. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8047. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8048. /* port-B for mic-in (rear panel) with vref */
  8049. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8050. /* port-C for line-in (rear panel) */
  8051. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8052. /* port-D for Front */
  8053. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8054. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8055. /* port-E for HP out (front panel) */
  8056. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8057. /* route front PCM to HP */
  8058. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8059. /* port-F for mic-in (front panel) with vref */
  8060. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8061. /* port-G for CLFE (rear panel) */
  8062. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8063. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8064. /* port-H for side (rear panel) */
  8065. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8066. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8067. /* CD-in */
  8068. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8069. /* route front mic to ADC1*/
  8070. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8071. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8072. /* Unmute DAC0~3 & spdif out*/
  8073. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8074. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8075. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8076. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8077. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8078. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8079. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8080. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8081. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8082. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8083. /* Unmute Stereo Mixer 15 */
  8084. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8085. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8086. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8087. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8088. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8089. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8090. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8091. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8092. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8093. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8094. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8095. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8096. /* hp used DAC 3 (Front) */
  8097. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8098. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8099. { }
  8100. };
  8101. static struct hda_verb alc861_threestack_init_verbs[] = {
  8102. /*
  8103. * Unmute ADC0 and set the default input to mic-in
  8104. */
  8105. /* port-A for surround (rear panel) */
  8106. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8107. /* port-B for mic-in (rear panel) with vref */
  8108. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8109. /* port-C for line-in (rear panel) */
  8110. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8111. /* port-D for Front */
  8112. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8113. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8114. /* port-E for HP out (front panel) */
  8115. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8116. /* route front PCM to HP */
  8117. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8118. /* port-F for mic-in (front panel) with vref */
  8119. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8120. /* port-G for CLFE (rear panel) */
  8121. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8122. /* port-H for side (rear panel) */
  8123. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8124. /* CD-in */
  8125. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8126. /* route front mic to ADC1*/
  8127. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8128. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8129. /* Unmute DAC0~3 & spdif out*/
  8130. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8131. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8132. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8133. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8134. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8135. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8136. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8137. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8138. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8139. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8140. /* Unmute Stereo Mixer 15 */
  8141. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8142. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8143. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8144. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8145. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8146. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8147. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8148. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8149. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8150. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8151. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8152. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8153. /* hp used DAC 3 (Front) */
  8154. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8155. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8156. { }
  8157. };
  8158. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8159. /*
  8160. * Unmute ADC0 and set the default input to mic-in
  8161. */
  8162. /* port-A for surround (rear panel) */
  8163. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8164. /* port-B for mic-in (rear panel) with vref */
  8165. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8166. /* port-C for line-in (rear panel) */
  8167. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8168. /* port-D for Front */
  8169. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8170. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8171. /* port-E for HP out (front panel) */
  8172. /* this has to be set to VREF80 */
  8173. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8174. /* route front PCM to HP */
  8175. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8176. /* port-F for mic-in (front panel) with vref */
  8177. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8178. /* port-G for CLFE (rear panel) */
  8179. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8180. /* port-H for side (rear panel) */
  8181. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8182. /* CD-in */
  8183. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8184. /* route front mic to ADC1*/
  8185. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8186. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8187. /* Unmute DAC0~3 & spdif out*/
  8188. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8189. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8190. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8191. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8192. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8193. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8194. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8195. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8196. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8197. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8198. /* Unmute Stereo Mixer 15 */
  8199. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8200. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8201. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8202. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8203. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8204. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8205. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8206. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8207. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8208. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8209. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8210. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8211. /* hp used DAC 3 (Front) */
  8212. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8213. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8214. { }
  8215. };
  8216. static struct hda_verb alc861_asus_init_verbs[] = {
  8217. /*
  8218. * Unmute ADC0 and set the default input to mic-in
  8219. */
  8220. /* port-A for surround (rear panel)
  8221. * according to codec#0 this is the HP jack
  8222. */
  8223. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8224. /* route front PCM to HP */
  8225. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8226. /* port-B for mic-in (rear panel) with vref */
  8227. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8228. /* port-C for line-in (rear panel) */
  8229. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8230. /* port-D for Front */
  8231. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8232. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8233. /* port-E for HP out (front panel) */
  8234. /* this has to be set to VREF80 */
  8235. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8236. /* route front PCM to HP */
  8237. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8238. /* port-F for mic-in (front panel) with vref */
  8239. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8240. /* port-G for CLFE (rear panel) */
  8241. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8242. /* port-H for side (rear panel) */
  8243. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8244. /* CD-in */
  8245. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8246. /* route front mic to ADC1*/
  8247. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8248. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8249. /* Unmute DAC0~3 & spdif out*/
  8250. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8251. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8252. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8253. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8254. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8255. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8256. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8257. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8258. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8259. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8260. /* Unmute Stereo Mixer 15 */
  8261. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8262. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8263. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8264. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8265. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8266. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8267. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8268. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8269. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8270. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8271. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8272. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8273. /* hp used DAC 3 (Front) */
  8274. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8275. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8276. { }
  8277. };
  8278. /* additional init verbs for ASUS laptops */
  8279. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8280. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8281. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8282. { }
  8283. };
  8284. /*
  8285. * generic initialization of ADC, input mixers and output mixers
  8286. */
  8287. static struct hda_verb alc861_auto_init_verbs[] = {
  8288. /*
  8289. * Unmute ADC0 and set the default input to mic-in
  8290. */
  8291. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8292. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8293. /* Unmute DAC0~3 & spdif out*/
  8294. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8295. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8296. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8297. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8298. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8299. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8300. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8301. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8302. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8303. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8304. /* Unmute Stereo Mixer 15 */
  8305. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8306. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8307. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8308. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8309. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8310. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8311. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8312. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8313. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8314. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8315. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8316. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8317. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8318. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8319. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8320. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8321. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8322. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8323. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8324. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8325. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8326. { }
  8327. };
  8328. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8329. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8330. { }
  8331. };
  8332. /* toggle speaker-output according to the hp-jack state */
  8333. static void alc861_toshiba_automute(struct hda_codec *codec)
  8334. {
  8335. unsigned int present;
  8336. present = snd_hda_codec_read(codec, 0x0f, 0,
  8337. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8338. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  8339. 0x80, present ? 0x80 : 0);
  8340. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  8341. 0x80, present ? 0x80 : 0);
  8342. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  8343. 0x80, present ? 0 : 0x80);
  8344. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  8345. 0x80, present ? 0 : 0x80);
  8346. }
  8347. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8348. unsigned int res)
  8349. {
  8350. if ((res >> 26) == ALC880_HP_EVENT)
  8351. alc861_toshiba_automute(codec);
  8352. }
  8353. /* pcm configuration: identiacal with ALC880 */
  8354. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8355. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8356. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8357. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8358. #define ALC861_DIGOUT_NID 0x07
  8359. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8360. { 8, NULL }
  8361. };
  8362. static hda_nid_t alc861_dac_nids[4] = {
  8363. /* front, surround, clfe, side */
  8364. 0x03, 0x06, 0x05, 0x04
  8365. };
  8366. static hda_nid_t alc660_dac_nids[3] = {
  8367. /* front, clfe, surround */
  8368. 0x03, 0x05, 0x06
  8369. };
  8370. static hda_nid_t alc861_adc_nids[1] = {
  8371. /* ADC0-2 */
  8372. 0x08,
  8373. };
  8374. static struct hda_input_mux alc861_capture_source = {
  8375. .num_items = 5,
  8376. .items = {
  8377. { "Mic", 0x0 },
  8378. { "Front Mic", 0x3 },
  8379. { "Line", 0x1 },
  8380. { "CD", 0x4 },
  8381. { "Mixer", 0x5 },
  8382. },
  8383. };
  8384. /* fill in the dac_nids table from the parsed pin configuration */
  8385. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8386. const struct auto_pin_cfg *cfg)
  8387. {
  8388. int i;
  8389. hda_nid_t nid;
  8390. spec->multiout.dac_nids = spec->private_dac_nids;
  8391. for (i = 0; i < cfg->line_outs; i++) {
  8392. nid = cfg->line_out_pins[i];
  8393. if (nid) {
  8394. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8395. continue;
  8396. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8397. }
  8398. }
  8399. spec->multiout.num_dacs = cfg->line_outs;
  8400. return 0;
  8401. }
  8402. /* add playback controls from the parsed DAC table */
  8403. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8404. const struct auto_pin_cfg *cfg)
  8405. {
  8406. char name[32];
  8407. static const char *chname[4] = {
  8408. "Front", "Surround", NULL /*CLFE*/, "Side"
  8409. };
  8410. hda_nid_t nid;
  8411. int i, idx, err;
  8412. for (i = 0; i < cfg->line_outs; i++) {
  8413. nid = spec->multiout.dac_nids[i];
  8414. if (!nid)
  8415. continue;
  8416. if (nid == 0x05) {
  8417. /* Center/LFE */
  8418. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8419. "Center Playback Switch",
  8420. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8421. HDA_OUTPUT));
  8422. if (err < 0)
  8423. return err;
  8424. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8425. "LFE Playback Switch",
  8426. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8427. HDA_OUTPUT));
  8428. if (err < 0)
  8429. return err;
  8430. } else {
  8431. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8432. idx++)
  8433. if (nid == alc861_dac_nids[idx])
  8434. break;
  8435. sprintf(name, "%s Playback Switch", chname[idx]);
  8436. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8437. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8438. HDA_OUTPUT));
  8439. if (err < 0)
  8440. return err;
  8441. }
  8442. }
  8443. return 0;
  8444. }
  8445. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8446. {
  8447. int err;
  8448. hda_nid_t nid;
  8449. if (!pin)
  8450. return 0;
  8451. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8452. nid = 0x03;
  8453. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8454. "Headphone Playback Switch",
  8455. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8456. if (err < 0)
  8457. return err;
  8458. spec->multiout.hp_nid = nid;
  8459. }
  8460. return 0;
  8461. }
  8462. /* create playback/capture controls for input pins */
  8463. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8464. const struct auto_pin_cfg *cfg)
  8465. {
  8466. struct hda_input_mux *imux = &spec->private_imux;
  8467. int i, err, idx, idx1;
  8468. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8469. switch (cfg->input_pins[i]) {
  8470. case 0x0c:
  8471. idx1 = 1;
  8472. idx = 2; /* Line In */
  8473. break;
  8474. case 0x0f:
  8475. idx1 = 2;
  8476. idx = 2; /* Line In */
  8477. break;
  8478. case 0x0d:
  8479. idx1 = 0;
  8480. idx = 1; /* Mic In */
  8481. break;
  8482. case 0x10:
  8483. idx1 = 3;
  8484. idx = 1; /* Mic In */
  8485. break;
  8486. case 0x11:
  8487. idx1 = 4;
  8488. idx = 0; /* CD */
  8489. break;
  8490. default:
  8491. continue;
  8492. }
  8493. err = new_analog_input(spec, cfg->input_pins[i],
  8494. auto_pin_cfg_labels[i], idx, 0x15);
  8495. if (err < 0)
  8496. return err;
  8497. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8498. imux->items[imux->num_items].index = idx1;
  8499. imux->num_items++;
  8500. }
  8501. return 0;
  8502. }
  8503. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8504. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8505. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8506. {
  8507. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8508. /* The multiple "Capture Source" controls confuse alsamixer
  8509. * So call somewhat different..
  8510. *FIXME: the controls appear in the "playback" view!
  8511. */
  8512. /* .name = "Capture Source", */
  8513. .name = "Input Source",
  8514. .count = 1,
  8515. .info = alc_mux_enum_info,
  8516. .get = alc_mux_enum_get,
  8517. .put = alc_mux_enum_put,
  8518. },
  8519. { } /* end */
  8520. };
  8521. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8522. hda_nid_t nid,
  8523. int pin_type, int dac_idx)
  8524. {
  8525. /* set as output */
  8526. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8527. pin_type);
  8528. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8529. AMP_OUT_UNMUTE);
  8530. }
  8531. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8532. {
  8533. struct alc_spec *spec = codec->spec;
  8534. int i;
  8535. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8536. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8537. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8538. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8539. if (nid)
  8540. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8541. spec->multiout.dac_nids[i]);
  8542. }
  8543. }
  8544. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8545. {
  8546. struct alc_spec *spec = codec->spec;
  8547. hda_nid_t pin;
  8548. pin = spec->autocfg.hp_pins[0];
  8549. if (pin) /* connect to front */
  8550. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8551. spec->multiout.dac_nids[0]);
  8552. }
  8553. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8554. {
  8555. struct alc_spec *spec = codec->spec;
  8556. int i;
  8557. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8558. hda_nid_t nid = spec->autocfg.input_pins[i];
  8559. if (nid >= 0x0c && nid <= 0x11) {
  8560. snd_hda_codec_write(codec, nid, 0,
  8561. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8562. i <= AUTO_PIN_FRONT_MIC ?
  8563. PIN_VREF80 : PIN_IN);
  8564. }
  8565. }
  8566. }
  8567. /* parse the BIOS configuration and set up the alc_spec */
  8568. /* return 1 if successful, 0 if the proper config is not found,
  8569. * or a negative error code
  8570. */
  8571. static int alc861_parse_auto_config(struct hda_codec *codec)
  8572. {
  8573. struct alc_spec *spec = codec->spec;
  8574. int err;
  8575. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8576. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8577. alc861_ignore);
  8578. if (err < 0)
  8579. return err;
  8580. if (!spec->autocfg.line_outs)
  8581. return 0; /* can't find valid BIOS pin config */
  8582. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8583. if (err < 0)
  8584. return err;
  8585. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8586. if (err < 0)
  8587. return err;
  8588. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8589. if (err < 0)
  8590. return err;
  8591. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8592. if (err < 0)
  8593. return err;
  8594. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8595. if (spec->autocfg.dig_out_pin)
  8596. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8597. if (spec->kctl_alloc)
  8598. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8599. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8600. spec->num_mux_defs = 1;
  8601. spec->input_mux = &spec->private_imux;
  8602. spec->adc_nids = alc861_adc_nids;
  8603. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8604. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8605. spec->num_mixers++;
  8606. return 1;
  8607. }
  8608. /* additional initialization for auto-configuration model */
  8609. static void alc861_auto_init(struct hda_codec *codec)
  8610. {
  8611. alc861_auto_init_multi_out(codec);
  8612. alc861_auto_init_hp_out(codec);
  8613. alc861_auto_init_analog_input(codec);
  8614. }
  8615. /*
  8616. * configuration and preset
  8617. */
  8618. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8619. [ALC861_3ST] = "3stack",
  8620. [ALC660_3ST] = "3stack-660",
  8621. [ALC861_3ST_DIG] = "3stack-dig",
  8622. [ALC861_6ST_DIG] = "6stack-dig",
  8623. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8624. [ALC861_TOSHIBA] = "toshiba",
  8625. [ALC861_ASUS] = "asus",
  8626. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8627. [ALC861_AUTO] = "auto",
  8628. };
  8629. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8630. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8631. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8632. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8633. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8634. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  8635. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8636. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  8637. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8638. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  8639. * Any other models that need this preset?
  8640. */
  8641. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  8642. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8643. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8644. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8645. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8646. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8647. {}
  8648. };
  8649. static struct alc_config_preset alc861_presets[] = {
  8650. [ALC861_3ST] = {
  8651. .mixers = { alc861_3ST_mixer },
  8652. .init_verbs = { alc861_threestack_init_verbs },
  8653. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8654. .dac_nids = alc861_dac_nids,
  8655. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8656. .channel_mode = alc861_threestack_modes,
  8657. .need_dac_fix = 1,
  8658. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8659. .adc_nids = alc861_adc_nids,
  8660. .input_mux = &alc861_capture_source,
  8661. },
  8662. [ALC861_3ST_DIG] = {
  8663. .mixers = { alc861_base_mixer },
  8664. .init_verbs = { alc861_threestack_init_verbs },
  8665. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8666. .dac_nids = alc861_dac_nids,
  8667. .dig_out_nid = ALC861_DIGOUT_NID,
  8668. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8669. .channel_mode = alc861_threestack_modes,
  8670. .need_dac_fix = 1,
  8671. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8672. .adc_nids = alc861_adc_nids,
  8673. .input_mux = &alc861_capture_source,
  8674. },
  8675. [ALC861_6ST_DIG] = {
  8676. .mixers = { alc861_base_mixer },
  8677. .init_verbs = { alc861_base_init_verbs },
  8678. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8679. .dac_nids = alc861_dac_nids,
  8680. .dig_out_nid = ALC861_DIGOUT_NID,
  8681. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8682. .channel_mode = alc861_8ch_modes,
  8683. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8684. .adc_nids = alc861_adc_nids,
  8685. .input_mux = &alc861_capture_source,
  8686. },
  8687. [ALC660_3ST] = {
  8688. .mixers = { alc861_3ST_mixer },
  8689. .init_verbs = { alc861_threestack_init_verbs },
  8690. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8691. .dac_nids = alc660_dac_nids,
  8692. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8693. .channel_mode = alc861_threestack_modes,
  8694. .need_dac_fix = 1,
  8695. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8696. .adc_nids = alc861_adc_nids,
  8697. .input_mux = &alc861_capture_source,
  8698. },
  8699. [ALC861_UNIWILL_M31] = {
  8700. .mixers = { alc861_uniwill_m31_mixer },
  8701. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8702. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8703. .dac_nids = alc861_dac_nids,
  8704. .dig_out_nid = ALC861_DIGOUT_NID,
  8705. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8706. .channel_mode = alc861_uniwill_m31_modes,
  8707. .need_dac_fix = 1,
  8708. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8709. .adc_nids = alc861_adc_nids,
  8710. .input_mux = &alc861_capture_source,
  8711. },
  8712. [ALC861_TOSHIBA] = {
  8713. .mixers = { alc861_toshiba_mixer },
  8714. .init_verbs = { alc861_base_init_verbs,
  8715. alc861_toshiba_init_verbs },
  8716. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8717. .dac_nids = alc861_dac_nids,
  8718. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8719. .channel_mode = alc883_3ST_2ch_modes,
  8720. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8721. .adc_nids = alc861_adc_nids,
  8722. .input_mux = &alc861_capture_source,
  8723. .unsol_event = alc861_toshiba_unsol_event,
  8724. .init_hook = alc861_toshiba_automute,
  8725. },
  8726. [ALC861_ASUS] = {
  8727. .mixers = { alc861_asus_mixer },
  8728. .init_verbs = { alc861_asus_init_verbs },
  8729. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8730. .dac_nids = alc861_dac_nids,
  8731. .dig_out_nid = ALC861_DIGOUT_NID,
  8732. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8733. .channel_mode = alc861_asus_modes,
  8734. .need_dac_fix = 1,
  8735. .hp_nid = 0x06,
  8736. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8737. .adc_nids = alc861_adc_nids,
  8738. .input_mux = &alc861_capture_source,
  8739. },
  8740. [ALC861_ASUS_LAPTOP] = {
  8741. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8742. .init_verbs = { alc861_asus_init_verbs,
  8743. alc861_asus_laptop_init_verbs },
  8744. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8745. .dac_nids = alc861_dac_nids,
  8746. .dig_out_nid = ALC861_DIGOUT_NID,
  8747. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8748. .channel_mode = alc883_3ST_2ch_modes,
  8749. .need_dac_fix = 1,
  8750. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8751. .adc_nids = alc861_adc_nids,
  8752. .input_mux = &alc861_capture_source,
  8753. },
  8754. };
  8755. static int patch_alc861(struct hda_codec *codec)
  8756. {
  8757. struct alc_spec *spec;
  8758. int board_config;
  8759. int err;
  8760. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8761. if (spec == NULL)
  8762. return -ENOMEM;
  8763. codec->spec = spec;
  8764. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8765. alc861_models,
  8766. alc861_cfg_tbl);
  8767. if (board_config < 0) {
  8768. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8769. "trying auto-probe from BIOS...\n");
  8770. board_config = ALC861_AUTO;
  8771. }
  8772. if (board_config == ALC861_AUTO) {
  8773. /* automatic parse from the BIOS config */
  8774. err = alc861_parse_auto_config(codec);
  8775. if (err < 0) {
  8776. alc_free(codec);
  8777. return err;
  8778. } else if (!err) {
  8779. printk(KERN_INFO
  8780. "hda_codec: Cannot set up configuration "
  8781. "from BIOS. Using base mode...\n");
  8782. board_config = ALC861_3ST_DIG;
  8783. }
  8784. }
  8785. if (board_config != ALC861_AUTO)
  8786. setup_preset(spec, &alc861_presets[board_config]);
  8787. spec->stream_name_analog = "ALC861 Analog";
  8788. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8789. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8790. spec->stream_name_digital = "ALC861 Digital";
  8791. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8792. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8793. codec->patch_ops = alc_patch_ops;
  8794. if (board_config == ALC861_AUTO)
  8795. spec->init_hook = alc861_auto_init;
  8796. return 0;
  8797. }
  8798. /*
  8799. * ALC861-VD support
  8800. *
  8801. * Based on ALC882
  8802. *
  8803. * In addition, an independent DAC
  8804. */
  8805. #define ALC861VD_DIGOUT_NID 0x06
  8806. static hda_nid_t alc861vd_dac_nids[4] = {
  8807. /* front, surr, clfe, side surr */
  8808. 0x02, 0x03, 0x04, 0x05
  8809. };
  8810. /* dac_nids for ALC660vd are in a different order - according to
  8811. * Realtek's driver.
  8812. * This should probably tesult in a different mixer for 6stack models
  8813. * of ALC660vd codecs, but for now there is only 3stack mixer
  8814. * - and it is the same as in 861vd.
  8815. * adc_nids in ALC660vd are (is) the same as in 861vd
  8816. */
  8817. static hda_nid_t alc660vd_dac_nids[3] = {
  8818. /* front, rear, clfe, rear_surr */
  8819. 0x02, 0x04, 0x03
  8820. };
  8821. static hda_nid_t alc861vd_adc_nids[1] = {
  8822. /* ADC0 */
  8823. 0x09,
  8824. };
  8825. /* input MUX */
  8826. /* FIXME: should be a matrix-type input source selection */
  8827. static struct hda_input_mux alc861vd_capture_source = {
  8828. .num_items = 4,
  8829. .items = {
  8830. { "Mic", 0x0 },
  8831. { "Front Mic", 0x1 },
  8832. { "Line", 0x2 },
  8833. { "CD", 0x4 },
  8834. },
  8835. };
  8836. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8837. .num_items = 3,
  8838. .items = {
  8839. { "Front Mic", 0x0 },
  8840. { "ATAPI Mic", 0x1 },
  8841. { "Line In", 0x5 },
  8842. },
  8843. };
  8844. #define alc861vd_mux_enum_info alc_mux_enum_info
  8845. #define alc861vd_mux_enum_get alc_mux_enum_get
  8846. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8847. struct snd_ctl_elem_value *ucontrol)
  8848. {
  8849. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8850. struct alc_spec *spec = codec->spec;
  8851. const struct hda_input_mux *imux = spec->input_mux;
  8852. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8853. static hda_nid_t capture_mixers[1] = { 0x22 };
  8854. hda_nid_t nid = capture_mixers[adc_idx];
  8855. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8856. unsigned int i, idx;
  8857. idx = ucontrol->value.enumerated.item[0];
  8858. if (idx >= imux->num_items)
  8859. idx = imux->num_items - 1;
  8860. if (*cur_val == idx && !codec->in_resume)
  8861. return 0;
  8862. for (i = 0; i < imux->num_items; i++) {
  8863. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8864. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8865. v | (imux->items[i].index << 8));
  8866. }
  8867. *cur_val = idx;
  8868. return 1;
  8869. }
  8870. /*
  8871. * 2ch mode
  8872. */
  8873. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8874. { 2, NULL }
  8875. };
  8876. /*
  8877. * 6ch mode
  8878. */
  8879. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8880. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8881. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8882. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8883. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8884. { } /* end */
  8885. };
  8886. /*
  8887. * 8ch mode
  8888. */
  8889. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8890. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8891. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8892. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8893. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8894. { } /* end */
  8895. };
  8896. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8897. { 6, alc861vd_6stack_ch6_init },
  8898. { 8, alc861vd_6stack_ch8_init },
  8899. };
  8900. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8901. {
  8902. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8903. .name = "Channel Mode",
  8904. .info = alc_ch_mode_info,
  8905. .get = alc_ch_mode_get,
  8906. .put = alc_ch_mode_put,
  8907. },
  8908. { } /* end */
  8909. };
  8910. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8911. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8912. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8913. {
  8914. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8915. /* The multiple "Capture Source" controls confuse alsamixer
  8916. * So call somewhat different..
  8917. *FIXME: the controls appear in the "playback" view!
  8918. */
  8919. /* .name = "Capture Source", */
  8920. .name = "Input Source",
  8921. .count = 1,
  8922. .info = alc861vd_mux_enum_info,
  8923. .get = alc861vd_mux_enum_get,
  8924. .put = alc861vd_mux_enum_put,
  8925. },
  8926. { } /* end */
  8927. };
  8928. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8929. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8930. */
  8931. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  8932. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8933. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8934. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8935. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  8936. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  8937. HDA_OUTPUT),
  8938. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  8939. HDA_OUTPUT),
  8940. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  8941. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  8942. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  8943. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  8944. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8945. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8946. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8947. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8948. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8949. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8950. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8951. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8952. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8953. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8954. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8955. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8956. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8957. { } /* end */
  8958. };
  8959. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  8960. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8961. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8962. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8963. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8964. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8965. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8966. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8967. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8968. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8969. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8970. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8971. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8972. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8973. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  8974. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  8975. { } /* end */
  8976. };
  8977. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  8978. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8979. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  8980. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8981. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  8982. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8983. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8984. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8985. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8986. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  8987. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  8988. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  8989. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  8990. { } /* end */
  8991. };
  8992. /* Pin assignment: Front=0x14, HP = 0x15,
  8993. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  8994. */
  8995. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  8996. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8997. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  8998. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  8999. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9000. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9001. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9002. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9003. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9004. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9005. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9006. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9007. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9008. {
  9009. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9010. /* .name = "Capture Source", */
  9011. .name = "Input Source",
  9012. .count = 1,
  9013. .info = alc882_mux_enum_info,
  9014. .get = alc882_mux_enum_get,
  9015. .put = alc882_mux_enum_put,
  9016. },
  9017. { } /* end */
  9018. };
  9019. /*
  9020. * generic initialization of ADC, input mixers and output mixers
  9021. */
  9022. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9023. /*
  9024. * Unmute ADC0 and set the default input to mic-in
  9025. */
  9026. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9027. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9028. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9029. * the analog-loopback mixer widget
  9030. */
  9031. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9032. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9033. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9034. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9035. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9036. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9037. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9038. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9039. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9040. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9041. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9042. /*
  9043. * Set up output mixers (0x02 - 0x05)
  9044. */
  9045. /* set vol=0 to output mixers */
  9046. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9047. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9048. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9049. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9050. /* set up input amps for analog loopback */
  9051. /* Amp Indices: DAC = 0, mixer = 1 */
  9052. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9053. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9054. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9055. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9056. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9057. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9058. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9059. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9060. { }
  9061. };
  9062. /*
  9063. * 3-stack pin configuration:
  9064. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9065. */
  9066. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9067. /*
  9068. * Set pin mode and muting
  9069. */
  9070. /* set front pin widgets 0x14 for output */
  9071. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9072. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9073. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9074. /* Mic (rear) pin: input vref at 80% */
  9075. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9076. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9077. /* Front Mic pin: input vref at 80% */
  9078. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9079. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9080. /* Line In pin: input */
  9081. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9082. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9083. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9084. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9085. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9086. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9087. /* CD pin widget for input */
  9088. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9089. { }
  9090. };
  9091. /*
  9092. * 6-stack pin configuration:
  9093. */
  9094. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9095. /*
  9096. * Set pin mode and muting
  9097. */
  9098. /* set front pin widgets 0x14 for output */
  9099. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9100. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9101. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9102. /* Rear Pin: output 1 (0x0d) */
  9103. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9104. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9105. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9106. /* CLFE Pin: output 2 (0x0e) */
  9107. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9108. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9109. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9110. /* Side Pin: output 3 (0x0f) */
  9111. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9112. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9113. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9114. /* Mic (rear) pin: input vref at 80% */
  9115. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9116. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9117. /* Front Mic pin: input vref at 80% */
  9118. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9119. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9120. /* Line In pin: input */
  9121. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9122. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9123. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9124. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9125. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9126. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9127. /* CD pin widget for input */
  9128. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9129. { }
  9130. };
  9131. static struct hda_verb alc861vd_eapd_verbs[] = {
  9132. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9133. { }
  9134. };
  9135. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9136. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9137. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9138. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9139. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9140. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9141. {}
  9142. };
  9143. /* toggle speaker-output according to the hp-jack state */
  9144. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9145. {
  9146. unsigned int present;
  9147. unsigned char bits;
  9148. present = snd_hda_codec_read(codec, 0x1b, 0,
  9149. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9150. bits = present ? 0x80 : 0;
  9151. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9152. 0x80, bits);
  9153. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9154. 0x80, bits);
  9155. }
  9156. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9157. {
  9158. unsigned int present;
  9159. unsigned char bits;
  9160. present = snd_hda_codec_read(codec, 0x18, 0,
  9161. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9162. bits = present ? 0x80 : 0;
  9163. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  9164. 0x80, bits);
  9165. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  9166. 0x80, bits);
  9167. }
  9168. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9169. {
  9170. alc861vd_lenovo_hp_automute(codec);
  9171. alc861vd_lenovo_mic_automute(codec);
  9172. }
  9173. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9174. unsigned int res)
  9175. {
  9176. switch (res >> 26) {
  9177. case ALC880_HP_EVENT:
  9178. alc861vd_lenovo_hp_automute(codec);
  9179. break;
  9180. case ALC880_MIC_EVENT:
  9181. alc861vd_lenovo_mic_automute(codec);
  9182. break;
  9183. }
  9184. }
  9185. static struct hda_verb alc861vd_dallas_verbs[] = {
  9186. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9187. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9188. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9189. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9191. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9193. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9195. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9197. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9198. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9199. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9200. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9201. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9202. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9203. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9204. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9205. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9206. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9207. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9208. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9209. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9210. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9211. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9212. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9213. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9214. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9215. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9216. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9217. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9218. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9219. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9220. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9221. { } /* end */
  9222. };
  9223. /* toggle speaker-output according to the hp-jack state */
  9224. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9225. {
  9226. unsigned int present;
  9227. present = snd_hda_codec_read(codec, 0x15, 0,
  9228. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9229. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9230. 0x80, present ? 0x80 : 0);
  9231. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9232. 0x80, present ? 0x80 : 0);
  9233. }
  9234. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9235. {
  9236. if ((res >> 26) == ALC880_HP_EVENT)
  9237. alc861vd_dallas_automute(codec);
  9238. }
  9239. /* pcm configuration: identiacal with ALC880 */
  9240. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9241. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9242. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9243. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9244. /*
  9245. * configuration and preset
  9246. */
  9247. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9248. [ALC660VD_3ST] = "3stack-660",
  9249. [ALC660VD_3ST_DIG]= "3stack-660-digout",
  9250. [ALC861VD_3ST] = "3stack",
  9251. [ALC861VD_3ST_DIG] = "3stack-digout",
  9252. [ALC861VD_6ST_DIG] = "6stack-digout",
  9253. [ALC861VD_LENOVO] = "lenovo",
  9254. [ALC861VD_DALLAS] = "dallas",
  9255. [ALC861VD_AUTO] = "auto",
  9256. };
  9257. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9258. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9259. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9260. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9261. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9262. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9263. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9264. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9265. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9266. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9267. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9268. {}
  9269. };
  9270. static struct alc_config_preset alc861vd_presets[] = {
  9271. [ALC660VD_3ST] = {
  9272. .mixers = { alc861vd_3st_mixer },
  9273. .init_verbs = { alc861vd_volume_init_verbs,
  9274. alc861vd_3stack_init_verbs },
  9275. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9276. .dac_nids = alc660vd_dac_nids,
  9277. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9278. .adc_nids = alc861vd_adc_nids,
  9279. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9280. .channel_mode = alc861vd_3stack_2ch_modes,
  9281. .input_mux = &alc861vd_capture_source,
  9282. },
  9283. [ALC660VD_3ST_DIG] = {
  9284. .mixers = { alc861vd_3st_mixer },
  9285. .init_verbs = { alc861vd_volume_init_verbs,
  9286. alc861vd_3stack_init_verbs },
  9287. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9288. .dac_nids = alc660vd_dac_nids,
  9289. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9290. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9291. .adc_nids = alc861vd_adc_nids,
  9292. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9293. .channel_mode = alc861vd_3stack_2ch_modes,
  9294. .input_mux = &alc861vd_capture_source,
  9295. },
  9296. [ALC861VD_3ST] = {
  9297. .mixers = { alc861vd_3st_mixer },
  9298. .init_verbs = { alc861vd_volume_init_verbs,
  9299. alc861vd_3stack_init_verbs },
  9300. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9301. .dac_nids = alc861vd_dac_nids,
  9302. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9303. .channel_mode = alc861vd_3stack_2ch_modes,
  9304. .input_mux = &alc861vd_capture_source,
  9305. },
  9306. [ALC861VD_3ST_DIG] = {
  9307. .mixers = { alc861vd_3st_mixer },
  9308. .init_verbs = { alc861vd_volume_init_verbs,
  9309. alc861vd_3stack_init_verbs },
  9310. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9311. .dac_nids = alc861vd_dac_nids,
  9312. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9313. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9314. .channel_mode = alc861vd_3stack_2ch_modes,
  9315. .input_mux = &alc861vd_capture_source,
  9316. },
  9317. [ALC861VD_6ST_DIG] = {
  9318. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9319. .init_verbs = { alc861vd_volume_init_verbs,
  9320. alc861vd_6stack_init_verbs },
  9321. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9322. .dac_nids = alc861vd_dac_nids,
  9323. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9324. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9325. .channel_mode = alc861vd_6stack_modes,
  9326. .input_mux = &alc861vd_capture_source,
  9327. },
  9328. [ALC861VD_LENOVO] = {
  9329. .mixers = { alc861vd_lenovo_mixer },
  9330. .init_verbs = { alc861vd_volume_init_verbs,
  9331. alc861vd_3stack_init_verbs,
  9332. alc861vd_eapd_verbs,
  9333. alc861vd_lenovo_unsol_verbs },
  9334. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9335. .dac_nids = alc660vd_dac_nids,
  9336. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9337. .adc_nids = alc861vd_adc_nids,
  9338. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9339. .channel_mode = alc861vd_3stack_2ch_modes,
  9340. .input_mux = &alc861vd_capture_source,
  9341. .unsol_event = alc861vd_lenovo_unsol_event,
  9342. .init_hook = alc861vd_lenovo_automute,
  9343. },
  9344. [ALC861VD_DALLAS] = {
  9345. .mixers = { alc861vd_dallas_mixer },
  9346. .init_verbs = { alc861vd_dallas_verbs },
  9347. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9348. .dac_nids = alc861vd_dac_nids,
  9349. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9350. .adc_nids = alc861vd_adc_nids,
  9351. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9352. .channel_mode = alc861vd_3stack_2ch_modes,
  9353. .input_mux = &alc861vd_dallas_capture_source,
  9354. .unsol_event = alc861vd_dallas_unsol_event,
  9355. .init_hook = alc861vd_dallas_automute,
  9356. },
  9357. };
  9358. /*
  9359. * BIOS auto configuration
  9360. */
  9361. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9362. hda_nid_t nid, int pin_type, int dac_idx)
  9363. {
  9364. /* set as output */
  9365. snd_hda_codec_write(codec, nid, 0,
  9366. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9367. snd_hda_codec_write(codec, nid, 0,
  9368. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9369. }
  9370. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9371. {
  9372. struct alc_spec *spec = codec->spec;
  9373. int i;
  9374. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9375. for (i = 0; i <= HDA_SIDE; i++) {
  9376. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9377. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9378. if (nid)
  9379. alc861vd_auto_set_output_and_unmute(codec, nid,
  9380. pin_type, i);
  9381. }
  9382. }
  9383. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9384. {
  9385. struct alc_spec *spec = codec->spec;
  9386. hda_nid_t pin;
  9387. pin = spec->autocfg.hp_pins[0];
  9388. if (pin) /* connect to front and use dac 0 */
  9389. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9390. }
  9391. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9392. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9393. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9394. {
  9395. struct alc_spec *spec = codec->spec;
  9396. int i;
  9397. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9398. hda_nid_t nid = spec->autocfg.input_pins[i];
  9399. if (alc861vd_is_input_pin(nid)) {
  9400. snd_hda_codec_write(codec, nid, 0,
  9401. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9402. i <= AUTO_PIN_FRONT_MIC ?
  9403. PIN_VREF80 : PIN_IN);
  9404. if (nid != ALC861VD_PIN_CD_NID)
  9405. snd_hda_codec_write(codec, nid, 0,
  9406. AC_VERB_SET_AMP_GAIN_MUTE,
  9407. AMP_OUT_MUTE);
  9408. }
  9409. }
  9410. }
  9411. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9412. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9413. /* add playback controls from the parsed DAC table */
  9414. /* Based on ALC880 version. But ALC861VD has separate,
  9415. * different NIDs for mute/unmute switch and volume control */
  9416. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9417. const struct auto_pin_cfg *cfg)
  9418. {
  9419. char name[32];
  9420. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9421. hda_nid_t nid_v, nid_s;
  9422. int i, err;
  9423. for (i = 0; i < cfg->line_outs; i++) {
  9424. if (!spec->multiout.dac_nids[i])
  9425. continue;
  9426. nid_v = alc861vd_idx_to_mixer_vol(
  9427. alc880_dac_to_idx(
  9428. spec->multiout.dac_nids[i]));
  9429. nid_s = alc861vd_idx_to_mixer_switch(
  9430. alc880_dac_to_idx(
  9431. spec->multiout.dac_nids[i]));
  9432. if (i == 2) {
  9433. /* Center/LFE */
  9434. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9435. "Center Playback Volume",
  9436. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9437. HDA_OUTPUT));
  9438. if (err < 0)
  9439. return err;
  9440. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9441. "LFE Playback Volume",
  9442. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9443. HDA_OUTPUT));
  9444. if (err < 0)
  9445. return err;
  9446. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9447. "Center Playback Switch",
  9448. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9449. HDA_INPUT));
  9450. if (err < 0)
  9451. return err;
  9452. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9453. "LFE Playback Switch",
  9454. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9455. HDA_INPUT));
  9456. if (err < 0)
  9457. return err;
  9458. } else {
  9459. sprintf(name, "%s Playback Volume", chname[i]);
  9460. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9461. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9462. HDA_OUTPUT));
  9463. if (err < 0)
  9464. return err;
  9465. sprintf(name, "%s Playback Switch", chname[i]);
  9466. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9467. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9468. HDA_INPUT));
  9469. if (err < 0)
  9470. return err;
  9471. }
  9472. }
  9473. return 0;
  9474. }
  9475. /* add playback controls for speaker and HP outputs */
  9476. /* Based on ALC880 version. But ALC861VD has separate,
  9477. * different NIDs for mute/unmute switch and volume control */
  9478. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9479. hda_nid_t pin, const char *pfx)
  9480. {
  9481. hda_nid_t nid_v, nid_s;
  9482. int err;
  9483. char name[32];
  9484. if (!pin)
  9485. return 0;
  9486. if (alc880_is_fixed_pin(pin)) {
  9487. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9488. /* specify the DAC as the extra output */
  9489. if (!spec->multiout.hp_nid)
  9490. spec->multiout.hp_nid = nid_v;
  9491. else
  9492. spec->multiout.extra_out_nid[0] = nid_v;
  9493. /* control HP volume/switch on the output mixer amp */
  9494. nid_v = alc861vd_idx_to_mixer_vol(
  9495. alc880_fixed_pin_idx(pin));
  9496. nid_s = alc861vd_idx_to_mixer_switch(
  9497. alc880_fixed_pin_idx(pin));
  9498. sprintf(name, "%s Playback Volume", pfx);
  9499. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9500. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9501. if (err < 0)
  9502. return err;
  9503. sprintf(name, "%s Playback Switch", pfx);
  9504. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9505. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9506. if (err < 0)
  9507. return err;
  9508. } else if (alc880_is_multi_pin(pin)) {
  9509. /* set manual connection */
  9510. /* we have only a switch on HP-out PIN */
  9511. sprintf(name, "%s Playback Switch", pfx);
  9512. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9513. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9514. if (err < 0)
  9515. return err;
  9516. }
  9517. return 0;
  9518. }
  9519. /* parse the BIOS configuration and set up the alc_spec
  9520. * return 1 if successful, 0 if the proper config is not found,
  9521. * or a negative error code
  9522. * Based on ALC880 version - had to change it to override
  9523. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9524. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9525. {
  9526. struct alc_spec *spec = codec->spec;
  9527. int err;
  9528. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9529. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9530. alc861vd_ignore);
  9531. if (err < 0)
  9532. return err;
  9533. if (!spec->autocfg.line_outs)
  9534. return 0; /* can't find valid BIOS pin config */
  9535. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9536. if (err < 0)
  9537. return err;
  9538. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9539. if (err < 0)
  9540. return err;
  9541. err = alc861vd_auto_create_extra_out(spec,
  9542. spec->autocfg.speaker_pins[0],
  9543. "Speaker");
  9544. if (err < 0)
  9545. return err;
  9546. err = alc861vd_auto_create_extra_out(spec,
  9547. spec->autocfg.hp_pins[0],
  9548. "Headphone");
  9549. if (err < 0)
  9550. return err;
  9551. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9552. if (err < 0)
  9553. return err;
  9554. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9555. if (spec->autocfg.dig_out_pin)
  9556. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9557. if (spec->kctl_alloc)
  9558. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9559. spec->init_verbs[spec->num_init_verbs++]
  9560. = alc861vd_volume_init_verbs;
  9561. spec->num_mux_defs = 1;
  9562. spec->input_mux = &spec->private_imux;
  9563. return 1;
  9564. }
  9565. /* additional initialization for auto-configuration model */
  9566. static void alc861vd_auto_init(struct hda_codec *codec)
  9567. {
  9568. alc861vd_auto_init_multi_out(codec);
  9569. alc861vd_auto_init_hp_out(codec);
  9570. alc861vd_auto_init_analog_input(codec);
  9571. }
  9572. static int patch_alc861vd(struct hda_codec *codec)
  9573. {
  9574. struct alc_spec *spec;
  9575. int err, board_config;
  9576. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9577. if (spec == NULL)
  9578. return -ENOMEM;
  9579. codec->spec = spec;
  9580. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9581. alc861vd_models,
  9582. alc861vd_cfg_tbl);
  9583. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9584. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9585. "ALC861VD, trying auto-probe from BIOS...\n");
  9586. board_config = ALC861VD_AUTO;
  9587. }
  9588. if (board_config == ALC861VD_AUTO) {
  9589. /* automatic parse from the BIOS config */
  9590. err = alc861vd_parse_auto_config(codec);
  9591. if (err < 0) {
  9592. alc_free(codec);
  9593. return err;
  9594. } else if (!err) {
  9595. printk(KERN_INFO
  9596. "hda_codec: Cannot set up configuration "
  9597. "from BIOS. Using base mode...\n");
  9598. board_config = ALC861VD_3ST;
  9599. }
  9600. }
  9601. if (board_config != ALC861VD_AUTO)
  9602. setup_preset(spec, &alc861vd_presets[board_config]);
  9603. spec->stream_name_analog = "ALC861VD Analog";
  9604. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9605. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9606. spec->stream_name_digital = "ALC861VD Digital";
  9607. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9608. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9609. spec->adc_nids = alc861vd_adc_nids;
  9610. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9611. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9612. spec->num_mixers++;
  9613. codec->patch_ops = alc_patch_ops;
  9614. if (board_config == ALC861VD_AUTO)
  9615. spec->init_hook = alc861vd_auto_init;
  9616. return 0;
  9617. }
  9618. /*
  9619. * ALC662 support
  9620. *
  9621. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9622. * configuration. Each pin widget can choose any input DACs and a mixer.
  9623. * Each ADC is connected from a mixer of all inputs. This makes possible
  9624. * 6-channel independent captures.
  9625. *
  9626. * In addition, an independent DAC for the multi-playback (not used in this
  9627. * driver yet).
  9628. */
  9629. #define ALC662_DIGOUT_NID 0x06
  9630. #define ALC662_DIGIN_NID 0x0a
  9631. static hda_nid_t alc662_dac_nids[4] = {
  9632. /* front, rear, clfe, rear_surr */
  9633. 0x02, 0x03, 0x04
  9634. };
  9635. static hda_nid_t alc662_adc_nids[1] = {
  9636. /* ADC1-2 */
  9637. 0x09,
  9638. };
  9639. /* input MUX */
  9640. /* FIXME: should be a matrix-type input source selection */
  9641. static struct hda_input_mux alc662_capture_source = {
  9642. .num_items = 4,
  9643. .items = {
  9644. { "Mic", 0x0 },
  9645. { "Front Mic", 0x1 },
  9646. { "Line", 0x2 },
  9647. { "CD", 0x4 },
  9648. },
  9649. };
  9650. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9651. .num_items = 2,
  9652. .items = {
  9653. { "Mic", 0x1 },
  9654. { "Line", 0x2 },
  9655. },
  9656. };
  9657. #define alc662_mux_enum_info alc_mux_enum_info
  9658. #define alc662_mux_enum_get alc_mux_enum_get
  9659. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9660. struct snd_ctl_elem_value *ucontrol)
  9661. {
  9662. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9663. struct alc_spec *spec = codec->spec;
  9664. const struct hda_input_mux *imux = spec->input_mux;
  9665. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9666. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9667. hda_nid_t nid = capture_mixers[adc_idx];
  9668. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9669. unsigned int i, idx;
  9670. idx = ucontrol->value.enumerated.item[0];
  9671. if (idx >= imux->num_items)
  9672. idx = imux->num_items - 1;
  9673. if (*cur_val == idx && !codec->in_resume)
  9674. return 0;
  9675. for (i = 0; i < imux->num_items; i++) {
  9676. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  9677. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9678. v | (imux->items[i].index << 8));
  9679. }
  9680. *cur_val = idx;
  9681. return 1;
  9682. }
  9683. /*
  9684. * 2ch mode
  9685. */
  9686. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9687. { 2, NULL }
  9688. };
  9689. /*
  9690. * 2ch mode
  9691. */
  9692. static struct hda_verb alc662_3ST_ch2_init[] = {
  9693. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9694. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9695. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9696. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9697. { } /* end */
  9698. };
  9699. /*
  9700. * 6ch mode
  9701. */
  9702. static struct hda_verb alc662_3ST_ch6_init[] = {
  9703. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9704. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9705. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9706. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9707. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9708. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9709. { } /* end */
  9710. };
  9711. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9712. { 2, alc662_3ST_ch2_init },
  9713. { 6, alc662_3ST_ch6_init },
  9714. };
  9715. /*
  9716. * 2ch mode
  9717. */
  9718. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9719. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9720. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9721. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9722. { } /* end */
  9723. };
  9724. /*
  9725. * 6ch mode
  9726. */
  9727. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9728. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9729. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9730. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9731. { } /* end */
  9732. };
  9733. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9734. { 2, alc662_sixstack_ch6_init },
  9735. { 6, alc662_sixstack_ch8_init },
  9736. };
  9737. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9738. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9739. */
  9740. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9741. /* output mixer control */
  9742. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9743. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9744. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9745. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9746. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9747. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9748. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9749. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9750. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9751. /*Input mixer control */
  9752. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9753. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9754. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9755. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9756. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9757. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9758. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9759. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9760. /* Capture mixer control */
  9761. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9762. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9763. {
  9764. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9765. .name = "Capture Source",
  9766. .count = 1,
  9767. .info = alc_mux_enum_info,
  9768. .get = alc_mux_enum_get,
  9769. .put = alc_mux_enum_put,
  9770. },
  9771. { } /* end */
  9772. };
  9773. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9774. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9775. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9776. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9777. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9778. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9779. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9780. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9781. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9782. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9783. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9784. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9785. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9786. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9787. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9788. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9789. {
  9790. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9791. /* .name = "Capture Source", */
  9792. .name = "Input Source",
  9793. .count = 1,
  9794. .info = alc662_mux_enum_info,
  9795. .get = alc662_mux_enum_get,
  9796. .put = alc662_mux_enum_put,
  9797. },
  9798. { } /* end */
  9799. };
  9800. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9801. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9802. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9803. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9804. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9805. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9806. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9807. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9808. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9809. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9810. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9811. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9812. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9813. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9814. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9815. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9816. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9817. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9818. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9819. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9820. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9821. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9822. {
  9823. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9824. /* .name = "Capture Source", */
  9825. .name = "Input Source",
  9826. .count = 1,
  9827. .info = alc662_mux_enum_info,
  9828. .get = alc662_mux_enum_get,
  9829. .put = alc662_mux_enum_put,
  9830. },
  9831. { } /* end */
  9832. };
  9833. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9834. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9835. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9836. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9837. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9838. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9839. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9840. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9841. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9842. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9843. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9844. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9845. {
  9846. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9847. /* .name = "Capture Source", */
  9848. .name = "Input Source",
  9849. .count = 1,
  9850. .info = alc662_mux_enum_info,
  9851. .get = alc662_mux_enum_get,
  9852. .put = alc662_mux_enum_put,
  9853. },
  9854. { } /* end */
  9855. };
  9856. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9857. {
  9858. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9859. .name = "Channel Mode",
  9860. .info = alc_ch_mode_info,
  9861. .get = alc_ch_mode_get,
  9862. .put = alc_ch_mode_put,
  9863. },
  9864. { } /* end */
  9865. };
  9866. static struct hda_verb alc662_init_verbs[] = {
  9867. /* ADC: mute amp left and right */
  9868. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9869. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9870. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9871. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9872. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9873. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9874. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9875. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9876. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9877. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9878. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9879. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9880. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9881. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9882. /* Front Pin: output 0 (0x0c) */
  9883. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9884. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9885. /* Rear Pin: output 1 (0x0d) */
  9886. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9887. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9888. /* CLFE Pin: output 2 (0x0e) */
  9889. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9890. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9891. /* Mic (rear) pin: input vref at 80% */
  9892. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9893. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9894. /* Front Mic pin: input vref at 80% */
  9895. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9896. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9897. /* Line In pin: input */
  9898. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9899. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9900. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9901. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9902. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9903. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9904. /* CD pin widget for input */
  9905. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9906. /* FIXME: use matrix-type input source selection */
  9907. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9908. /* Input mixer */
  9909. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9910. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9911. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9912. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9913. { }
  9914. };
  9915. static struct hda_verb alc662_sue_init_verbs[] = {
  9916. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9917. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9918. {}
  9919. };
  9920. /*
  9921. * generic initialization of ADC, input mixers and output mixers
  9922. */
  9923. static struct hda_verb alc662_auto_init_verbs[] = {
  9924. /*
  9925. * Unmute ADC and set the default input to mic-in
  9926. */
  9927. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9928. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9929. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  9930. * mixer widget
  9931. * Note: PASD motherboards uses the Line In 2 as the input for front
  9932. * panel mic (mic 2)
  9933. */
  9934. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9935. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9936. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9937. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9938. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9939. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9940. /*
  9941. * Set up output mixers (0x0c - 0x0f)
  9942. */
  9943. /* set vol=0 to output mixers */
  9944. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9945. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9946. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9947. /* set up input amps for analog loopback */
  9948. /* Amp Indices: DAC = 0, mixer = 1 */
  9949. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9950. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9951. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9952. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9953. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9954. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9955. /* FIXME: use matrix-type input source selection */
  9956. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9957. /* Input mixer */
  9958. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9959. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9960. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9961. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  9962. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9963. { }
  9964. };
  9965. /* capture mixer elements */
  9966. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  9967. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9968. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9969. {
  9970. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9971. /* The multiple "Capture Source" controls confuse alsamixer
  9972. * So call somewhat different..
  9973. * FIXME: the controls appear in the "playback" view!
  9974. */
  9975. /* .name = "Capture Source", */
  9976. .name = "Input Source",
  9977. .count = 1,
  9978. .info = alc882_mux_enum_info,
  9979. .get = alc882_mux_enum_get,
  9980. .put = alc882_mux_enum_put,
  9981. },
  9982. { } /* end */
  9983. };
  9984. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  9985. {
  9986. unsigned int present;
  9987. unsigned char bits;
  9988. present = snd_hda_codec_read(codec, 0x14, 0,
  9989. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9990. bits = present ? 0x80 : 0;
  9991. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  9992. 0x80, bits);
  9993. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  9994. 0x80, bits);
  9995. }
  9996. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  9997. {
  9998. unsigned int present;
  9999. unsigned char bits;
  10000. present = snd_hda_codec_read(codec, 0x1b, 0,
  10001. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10002. bits = present ? 0x80 : 0;
  10003. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  10004. 0x80, bits);
  10005. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  10006. 0x80, bits);
  10007. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  10008. 0x80, bits);
  10009. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  10010. 0x80, bits);
  10011. }
  10012. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10013. unsigned int res)
  10014. {
  10015. if ((res >> 26) == ALC880_HP_EVENT)
  10016. alc662_lenovo_101e_all_automute(codec);
  10017. if ((res >> 26) == ALC880_FRONT_EVENT)
  10018. alc662_lenovo_101e_ispeaker_automute(codec);
  10019. }
  10020. /* pcm configuration: identiacal with ALC880 */
  10021. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10022. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10023. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10024. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10025. /*
  10026. * configuration and preset
  10027. */
  10028. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10029. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10030. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10031. [ALC662_3ST_6ch] = "3stack-6ch",
  10032. [ALC662_5ST_DIG] = "6stack-dig",
  10033. [ALC662_LENOVO_101E] = "lenovo-101e",
  10034. [ALC662_AUTO] = "auto",
  10035. };
  10036. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10037. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10038. {}
  10039. };
  10040. static struct alc_config_preset alc662_presets[] = {
  10041. [ALC662_3ST_2ch_DIG] = {
  10042. .mixers = { alc662_3ST_2ch_mixer },
  10043. .init_verbs = { alc662_init_verbs },
  10044. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10045. .dac_nids = alc662_dac_nids,
  10046. .dig_out_nid = ALC662_DIGOUT_NID,
  10047. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10048. .adc_nids = alc662_adc_nids,
  10049. .dig_in_nid = ALC662_DIGIN_NID,
  10050. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10051. .channel_mode = alc662_3ST_2ch_modes,
  10052. .input_mux = &alc662_capture_source,
  10053. },
  10054. [ALC662_3ST_6ch_DIG] = {
  10055. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10056. .init_verbs = { alc662_init_verbs },
  10057. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10058. .dac_nids = alc662_dac_nids,
  10059. .dig_out_nid = ALC662_DIGOUT_NID,
  10060. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10061. .adc_nids = alc662_adc_nids,
  10062. .dig_in_nid = ALC662_DIGIN_NID,
  10063. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10064. .channel_mode = alc662_3ST_6ch_modes,
  10065. .need_dac_fix = 1,
  10066. .input_mux = &alc662_capture_source,
  10067. },
  10068. [ALC662_3ST_6ch] = {
  10069. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10070. .init_verbs = { alc662_init_verbs },
  10071. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10072. .dac_nids = alc662_dac_nids,
  10073. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10074. .adc_nids = alc662_adc_nids,
  10075. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10076. .channel_mode = alc662_3ST_6ch_modes,
  10077. .need_dac_fix = 1,
  10078. .input_mux = &alc662_capture_source,
  10079. },
  10080. [ALC662_5ST_DIG] = {
  10081. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10082. .init_verbs = { alc662_init_verbs },
  10083. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10084. .dac_nids = alc662_dac_nids,
  10085. .dig_out_nid = ALC662_DIGOUT_NID,
  10086. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10087. .adc_nids = alc662_adc_nids,
  10088. .dig_in_nid = ALC662_DIGIN_NID,
  10089. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10090. .channel_mode = alc662_5stack_modes,
  10091. .input_mux = &alc662_capture_source,
  10092. },
  10093. [ALC662_LENOVO_101E] = {
  10094. .mixers = { alc662_lenovo_101e_mixer },
  10095. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10096. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10097. .dac_nids = alc662_dac_nids,
  10098. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10099. .adc_nids = alc662_adc_nids,
  10100. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10101. .channel_mode = alc662_3ST_2ch_modes,
  10102. .input_mux = &alc662_lenovo_101e_capture_source,
  10103. .unsol_event = alc662_lenovo_101e_unsol_event,
  10104. .init_hook = alc662_lenovo_101e_all_automute,
  10105. },
  10106. };
  10107. /*
  10108. * BIOS auto configuration
  10109. */
  10110. /* add playback controls from the parsed DAC table */
  10111. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10112. const struct auto_pin_cfg *cfg)
  10113. {
  10114. char name[32];
  10115. static const char *chname[4] = {
  10116. "Front", "Surround", NULL /*CLFE*/, "Side"
  10117. };
  10118. hda_nid_t nid;
  10119. int i, err;
  10120. for (i = 0; i < cfg->line_outs; i++) {
  10121. if (!spec->multiout.dac_nids[i])
  10122. continue;
  10123. nid = alc880_idx_to_mixer(i);
  10124. if (i == 2) {
  10125. /* Center/LFE */
  10126. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10127. "Center Playback Volume",
  10128. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10129. HDA_OUTPUT));
  10130. if (err < 0)
  10131. return err;
  10132. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10133. "LFE Playback Volume",
  10134. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10135. HDA_OUTPUT));
  10136. if (err < 0)
  10137. return err;
  10138. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10139. "Center Playback Switch",
  10140. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10141. HDA_INPUT));
  10142. if (err < 0)
  10143. return err;
  10144. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10145. "LFE Playback Switch",
  10146. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10147. HDA_INPUT));
  10148. if (err < 0)
  10149. return err;
  10150. } else {
  10151. sprintf(name, "%s Playback Volume", chname[i]);
  10152. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10153. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10154. HDA_OUTPUT));
  10155. if (err < 0)
  10156. return err;
  10157. sprintf(name, "%s Playback Switch", chname[i]);
  10158. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10159. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10160. HDA_INPUT));
  10161. if (err < 0)
  10162. return err;
  10163. }
  10164. }
  10165. return 0;
  10166. }
  10167. /* add playback controls for speaker and HP outputs */
  10168. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10169. const char *pfx)
  10170. {
  10171. hda_nid_t nid;
  10172. int err;
  10173. char name[32];
  10174. if (!pin)
  10175. return 0;
  10176. if (alc880_is_fixed_pin(pin)) {
  10177. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10178. /* printk("DAC nid=%x\n",nid); */
  10179. /* specify the DAC as the extra output */
  10180. if (!spec->multiout.hp_nid)
  10181. spec->multiout.hp_nid = nid;
  10182. else
  10183. spec->multiout.extra_out_nid[0] = nid;
  10184. /* control HP volume/switch on the output mixer amp */
  10185. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10186. sprintf(name, "%s Playback Volume", pfx);
  10187. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10188. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10189. if (err < 0)
  10190. return err;
  10191. sprintf(name, "%s Playback Switch", pfx);
  10192. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10193. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10194. if (err < 0)
  10195. return err;
  10196. } else if (alc880_is_multi_pin(pin)) {
  10197. /* set manual connection */
  10198. /* we have only a switch on HP-out PIN */
  10199. sprintf(name, "%s Playback Switch", pfx);
  10200. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10201. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10202. if (err < 0)
  10203. return err;
  10204. }
  10205. return 0;
  10206. }
  10207. /* create playback/capture controls for input pins */
  10208. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10209. const struct auto_pin_cfg *cfg)
  10210. {
  10211. struct hda_input_mux *imux = &spec->private_imux;
  10212. int i, err, idx;
  10213. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10214. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10215. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10216. err = new_analog_input(spec, cfg->input_pins[i],
  10217. auto_pin_cfg_labels[i],
  10218. idx, 0x0b);
  10219. if (err < 0)
  10220. return err;
  10221. imux->items[imux->num_items].label =
  10222. auto_pin_cfg_labels[i];
  10223. imux->items[imux->num_items].index =
  10224. alc880_input_pin_idx(cfg->input_pins[i]);
  10225. imux->num_items++;
  10226. }
  10227. }
  10228. return 0;
  10229. }
  10230. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10231. hda_nid_t nid, int pin_type,
  10232. int dac_idx)
  10233. {
  10234. /* set as output */
  10235. snd_hda_codec_write(codec, nid, 0,
  10236. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10237. snd_hda_codec_write(codec, nid, 0,
  10238. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10239. /* need the manual connection? */
  10240. if (alc880_is_multi_pin(nid)) {
  10241. struct alc_spec *spec = codec->spec;
  10242. int idx = alc880_multi_pin_idx(nid);
  10243. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10244. AC_VERB_SET_CONNECT_SEL,
  10245. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10246. }
  10247. }
  10248. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10249. {
  10250. struct alc_spec *spec = codec->spec;
  10251. int i;
  10252. for (i = 0; i <= HDA_SIDE; i++) {
  10253. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10254. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10255. if (nid)
  10256. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10257. i);
  10258. }
  10259. }
  10260. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10261. {
  10262. struct alc_spec *spec = codec->spec;
  10263. hda_nid_t pin;
  10264. pin = spec->autocfg.hp_pins[0];
  10265. if (pin) /* connect to front */
  10266. /* use dac 0 */
  10267. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10268. }
  10269. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10270. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10271. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10272. {
  10273. struct alc_spec *spec = codec->spec;
  10274. int i;
  10275. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10276. hda_nid_t nid = spec->autocfg.input_pins[i];
  10277. if (alc662_is_input_pin(nid)) {
  10278. snd_hda_codec_write(codec, nid, 0,
  10279. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10280. (i <= AUTO_PIN_FRONT_MIC ?
  10281. PIN_VREF80 : PIN_IN));
  10282. if (nid != ALC662_PIN_CD_NID)
  10283. snd_hda_codec_write(codec, nid, 0,
  10284. AC_VERB_SET_AMP_GAIN_MUTE,
  10285. AMP_OUT_MUTE);
  10286. }
  10287. }
  10288. }
  10289. static int alc662_parse_auto_config(struct hda_codec *codec)
  10290. {
  10291. struct alc_spec *spec = codec->spec;
  10292. int err;
  10293. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10294. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10295. alc662_ignore);
  10296. if (err < 0)
  10297. return err;
  10298. if (!spec->autocfg.line_outs)
  10299. return 0; /* can't find valid BIOS pin config */
  10300. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10301. if (err < 0)
  10302. return err;
  10303. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10304. if (err < 0)
  10305. return err;
  10306. err = alc662_auto_create_extra_out(spec,
  10307. spec->autocfg.speaker_pins[0],
  10308. "Speaker");
  10309. if (err < 0)
  10310. return err;
  10311. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10312. "Headphone");
  10313. if (err < 0)
  10314. return err;
  10315. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10316. if (err < 0)
  10317. return err;
  10318. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10319. if (spec->autocfg.dig_out_pin)
  10320. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10321. if (spec->kctl_alloc)
  10322. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10323. spec->num_mux_defs = 1;
  10324. spec->input_mux = &spec->private_imux;
  10325. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10326. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10327. spec->num_mixers++;
  10328. return 1;
  10329. }
  10330. /* additional initialization for auto-configuration model */
  10331. static void alc662_auto_init(struct hda_codec *codec)
  10332. {
  10333. alc662_auto_init_multi_out(codec);
  10334. alc662_auto_init_hp_out(codec);
  10335. alc662_auto_init_analog_input(codec);
  10336. }
  10337. static int patch_alc662(struct hda_codec *codec)
  10338. {
  10339. struct alc_spec *spec;
  10340. int err, board_config;
  10341. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10342. if (!spec)
  10343. return -ENOMEM;
  10344. codec->spec = spec;
  10345. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10346. alc662_models,
  10347. alc662_cfg_tbl);
  10348. if (board_config < 0) {
  10349. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10350. "trying auto-probe from BIOS...\n");
  10351. board_config = ALC662_AUTO;
  10352. }
  10353. if (board_config == ALC662_AUTO) {
  10354. /* automatic parse from the BIOS config */
  10355. err = alc662_parse_auto_config(codec);
  10356. if (err < 0) {
  10357. alc_free(codec);
  10358. return err;
  10359. } else if (!err) {
  10360. printk(KERN_INFO
  10361. "hda_codec: Cannot set up configuration "
  10362. "from BIOS. Using base mode...\n");
  10363. board_config = ALC662_3ST_2ch_DIG;
  10364. }
  10365. }
  10366. if (board_config != ALC662_AUTO)
  10367. setup_preset(spec, &alc662_presets[board_config]);
  10368. spec->stream_name_analog = "ALC662 Analog";
  10369. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10370. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10371. spec->stream_name_digital = "ALC662 Digital";
  10372. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10373. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10374. if (!spec->adc_nids && spec->input_mux) {
  10375. spec->adc_nids = alc662_adc_nids;
  10376. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10377. }
  10378. codec->patch_ops = alc_patch_ops;
  10379. if (board_config == ALC662_AUTO)
  10380. spec->init_hook = alc662_auto_init;
  10381. return 0;
  10382. }
  10383. /*
  10384. * patch entries
  10385. */
  10386. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10387. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10388. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10389. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10390. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10391. .patch = patch_alc861 },
  10392. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10393. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10394. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10395. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10396. .patch = patch_alc883 },
  10397. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10398. .patch = patch_alc662 },
  10399. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10400. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10401. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10402. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10403. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10404. {} /* terminator */
  10405. };