patch_realtek.c 418 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671
  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_HP_TC_T5735,
  91. ALC262_BENQ_ED8,
  92. ALC262_SONY_ASSAMD,
  93. ALC262_BENQ_T31,
  94. ALC262_ULTRA,
  95. ALC262_AUTO,
  96. ALC262_MODEL_LAST /* last tag */
  97. };
  98. /* ALC268 models */
  99. enum {
  100. ALC268_3ST,
  101. ALC268_TOSHIBA,
  102. ALC268_ACER,
  103. ALC268_AUTO,
  104. ALC268_MODEL_LAST /* last tag */
  105. };
  106. /* ALC861 models */
  107. enum {
  108. ALC861_3ST,
  109. ALC660_3ST,
  110. ALC861_3ST_DIG,
  111. ALC861_6ST_DIG,
  112. ALC861_UNIWILL_M31,
  113. ALC861_TOSHIBA,
  114. ALC861_ASUS,
  115. ALC861_ASUS_LAPTOP,
  116. ALC861_AUTO,
  117. ALC861_MODEL_LAST,
  118. };
  119. /* ALC861-VD models */
  120. enum {
  121. ALC660VD_3ST,
  122. ALC660VD_3ST_DIG,
  123. ALC861VD_3ST,
  124. ALC861VD_3ST_DIG,
  125. ALC861VD_6ST_DIG,
  126. ALC861VD_LENOVO,
  127. ALC861VD_DALLAS,
  128. ALC861VD_HP,
  129. ALC861VD_AUTO,
  130. ALC861VD_MODEL_LAST,
  131. };
  132. /* ALC662 models */
  133. enum {
  134. ALC662_3ST_2ch_DIG,
  135. ALC662_3ST_6ch_DIG,
  136. ALC662_3ST_6ch,
  137. ALC662_5ST_DIG,
  138. ALC662_LENOVO_101E,
  139. ALC662_ASUS_EEEPC_P701,
  140. ALC662_AUTO,
  141. ALC662_MODEL_LAST,
  142. };
  143. /* ALC882 models */
  144. enum {
  145. ALC882_3ST_DIG,
  146. ALC882_6ST_DIG,
  147. ALC882_ARIMA,
  148. ALC882_W2JC,
  149. ALC882_TARGA,
  150. ALC882_ASUS_A7J,
  151. ALC882_ASUS_A7M,
  152. ALC885_MACPRO,
  153. ALC885_MBP3,
  154. ALC885_IMAC24,
  155. ALC882_AUTO,
  156. ALC882_MODEL_LAST,
  157. };
  158. /* ALC883 models */
  159. enum {
  160. ALC883_3ST_2ch_DIG,
  161. ALC883_3ST_6ch_DIG,
  162. ALC883_3ST_6ch,
  163. ALC883_6ST_DIG,
  164. ALC883_TARGA_DIG,
  165. ALC883_TARGA_2ch_DIG,
  166. ALC883_ACER,
  167. ALC883_ACER_ASPIRE,
  168. ALC883_MEDION,
  169. ALC883_MEDION_MD2,
  170. ALC883_LAPTOP_EAPD,
  171. ALC883_LENOVO_101E_2ch,
  172. ALC883_LENOVO_NB0763,
  173. ALC888_LENOVO_MS7195_DIG,
  174. ALC883_HAIER_W66,
  175. ALC888_6ST_HP,
  176. ALC888_3ST_HP,
  177. ALC883_AUTO,
  178. ALC883_MODEL_LAST,
  179. };
  180. /* for GPIO Poll */
  181. #define GPIO_MASK 0x03
  182. struct alc_spec {
  183. /* codec parameterization */
  184. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  185. unsigned int num_mixers;
  186. const struct hda_verb *init_verbs[5]; /* initialization verbs
  187. * don't forget NULL
  188. * termination!
  189. */
  190. unsigned int num_init_verbs;
  191. char *stream_name_analog; /* analog PCM stream */
  192. struct hda_pcm_stream *stream_analog_playback;
  193. struct hda_pcm_stream *stream_analog_capture;
  194. char *stream_name_digital; /* digital PCM stream */
  195. struct hda_pcm_stream *stream_digital_playback;
  196. struct hda_pcm_stream *stream_digital_capture;
  197. /* playback */
  198. struct hda_multi_out multiout; /* playback set-up
  199. * max_channels, dacs must be set
  200. * dig_out_nid and hp_nid are optional
  201. */
  202. /* capture */
  203. unsigned int num_adc_nids;
  204. hda_nid_t *adc_nids;
  205. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  206. /* capture source */
  207. unsigned int num_mux_defs;
  208. const struct hda_input_mux *input_mux;
  209. unsigned int cur_mux[3];
  210. /* channel model */
  211. const struct hda_channel_mode *channel_mode;
  212. int num_channel_mode;
  213. int need_dac_fix;
  214. /* PCM information */
  215. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  216. /* dynamic controls, init_verbs and input_mux */
  217. struct auto_pin_cfg autocfg;
  218. unsigned int num_kctl_alloc, num_kctl_used;
  219. struct snd_kcontrol_new *kctl_alloc;
  220. struct hda_input_mux private_imux;
  221. hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
  222. /* hooks */
  223. void (*init_hook)(struct hda_codec *codec);
  224. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  225. /* for pin sensing */
  226. unsigned int sense_updated: 1;
  227. unsigned int jack_present: 1;
  228. #ifdef CONFIG_SND_HDA_POWER_SAVE
  229. struct hda_loopback_check loopback;
  230. #endif
  231. };
  232. /*
  233. * configuration template - to be copied to the spec instance
  234. */
  235. struct alc_config_preset {
  236. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  237. * with spec
  238. */
  239. const struct hda_verb *init_verbs[5];
  240. unsigned int num_dacs;
  241. hda_nid_t *dac_nids;
  242. hda_nid_t dig_out_nid; /* optional */
  243. hda_nid_t hp_nid; /* optional */
  244. unsigned int num_adc_nids;
  245. hda_nid_t *adc_nids;
  246. hda_nid_t dig_in_nid;
  247. unsigned int num_channel_mode;
  248. const struct hda_channel_mode *channel_mode;
  249. int need_dac_fix;
  250. unsigned int num_mux_defs;
  251. const struct hda_input_mux *input_mux;
  252. void (*unsol_event)(struct hda_codec *, unsigned int);
  253. void (*init_hook)(struct hda_codec *);
  254. #ifdef CONFIG_SND_HDA_POWER_SAVE
  255. struct hda_amp_list *loopbacks;
  256. #endif
  257. };
  258. /*
  259. * input MUX handling
  260. */
  261. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  262. struct snd_ctl_elem_info *uinfo)
  263. {
  264. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  265. struct alc_spec *spec = codec->spec;
  266. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  267. if (mux_idx >= spec->num_mux_defs)
  268. mux_idx = 0;
  269. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  270. }
  271. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  272. struct snd_ctl_elem_value *ucontrol)
  273. {
  274. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  275. struct alc_spec *spec = codec->spec;
  276. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  277. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  278. return 0;
  279. }
  280. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  281. struct snd_ctl_elem_value *ucontrol)
  282. {
  283. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  284. struct alc_spec *spec = codec->spec;
  285. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  286. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  287. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  288. spec->adc_nids[adc_idx],
  289. &spec->cur_mux[adc_idx]);
  290. }
  291. /*
  292. * channel mode setting
  293. */
  294. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  295. struct snd_ctl_elem_info *uinfo)
  296. {
  297. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  298. struct alc_spec *spec = codec->spec;
  299. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  300. spec->num_channel_mode);
  301. }
  302. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  303. struct snd_ctl_elem_value *ucontrol)
  304. {
  305. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  306. struct alc_spec *spec = codec->spec;
  307. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  308. spec->num_channel_mode,
  309. spec->multiout.max_channels);
  310. }
  311. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  312. struct snd_ctl_elem_value *ucontrol)
  313. {
  314. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  315. struct alc_spec *spec = codec->spec;
  316. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  317. spec->num_channel_mode,
  318. &spec->multiout.max_channels);
  319. if (err >= 0 && spec->need_dac_fix)
  320. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  321. return err;
  322. }
  323. /*
  324. * Control the mode of pin widget settings via the mixer. "pc" is used
  325. * instead of "%" to avoid consequences of accidently treating the % as
  326. * being part of a format specifier. Maximum allowed length of a value is
  327. * 63 characters plus NULL terminator.
  328. *
  329. * Note: some retasking pin complexes seem to ignore requests for input
  330. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  331. * are requested. Therefore order this list so that this behaviour will not
  332. * cause problems when mixer clients move through the enum sequentially.
  333. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  334. * March 2006.
  335. */
  336. static char *alc_pin_mode_names[] = {
  337. "Mic 50pc bias", "Mic 80pc bias",
  338. "Line in", "Line out", "Headphone out",
  339. };
  340. static unsigned char alc_pin_mode_values[] = {
  341. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  342. };
  343. /* The control can present all 5 options, or it can limit the options based
  344. * in the pin being assumed to be exclusively an input or an output pin. In
  345. * addition, "input" pins may or may not process the mic bias option
  346. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  347. * accept requests for bias as of chip versions up to March 2006) and/or
  348. * wiring in the computer.
  349. */
  350. #define ALC_PIN_DIR_IN 0x00
  351. #define ALC_PIN_DIR_OUT 0x01
  352. #define ALC_PIN_DIR_INOUT 0x02
  353. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  354. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  355. /* Info about the pin modes supported by the different pin direction modes.
  356. * For each direction the minimum and maximum values are given.
  357. */
  358. static signed char alc_pin_mode_dir_info[5][2] = {
  359. { 0, 2 }, /* ALC_PIN_DIR_IN */
  360. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  361. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  362. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  363. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  364. };
  365. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  366. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  367. #define alc_pin_mode_n_items(_dir) \
  368. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  369. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  370. struct snd_ctl_elem_info *uinfo)
  371. {
  372. unsigned int item_num = uinfo->value.enumerated.item;
  373. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  374. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  375. uinfo->count = 1;
  376. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  377. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  378. item_num = alc_pin_mode_min(dir);
  379. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  380. return 0;
  381. }
  382. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  383. struct snd_ctl_elem_value *ucontrol)
  384. {
  385. unsigned int i;
  386. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  387. hda_nid_t nid = kcontrol->private_value & 0xffff;
  388. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  389. long *valp = ucontrol->value.integer.value;
  390. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  391. AC_VERB_GET_PIN_WIDGET_CONTROL,
  392. 0x00);
  393. /* Find enumerated value for current pinctl setting */
  394. i = alc_pin_mode_min(dir);
  395. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  396. i++;
  397. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  398. return 0;
  399. }
  400. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  401. struct snd_ctl_elem_value *ucontrol)
  402. {
  403. signed int change;
  404. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  405. hda_nid_t nid = kcontrol->private_value & 0xffff;
  406. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  407. long val = *ucontrol->value.integer.value;
  408. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  409. AC_VERB_GET_PIN_WIDGET_CONTROL,
  410. 0x00);
  411. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  412. val = alc_pin_mode_min(dir);
  413. change = pinctl != alc_pin_mode_values[val];
  414. if (change) {
  415. /* Set pin mode to that requested */
  416. snd_hda_codec_write_cache(codec, nid, 0,
  417. AC_VERB_SET_PIN_WIDGET_CONTROL,
  418. alc_pin_mode_values[val]);
  419. /* Also enable the retasking pin's input/output as required
  420. * for the requested pin mode. Enum values of 2 or less are
  421. * input modes.
  422. *
  423. * Dynamically switching the input/output buffers probably
  424. * reduces noise slightly (particularly on input) so we'll
  425. * do it. However, having both input and output buffers
  426. * enabled simultaneously doesn't seem to be problematic if
  427. * this turns out to be necessary in the future.
  428. */
  429. if (val <= 2) {
  430. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  431. HDA_AMP_MUTE, HDA_AMP_MUTE);
  432. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  433. HDA_AMP_MUTE, 0);
  434. } else {
  435. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  436. HDA_AMP_MUTE, HDA_AMP_MUTE);
  437. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  438. HDA_AMP_MUTE, 0);
  439. }
  440. }
  441. return change;
  442. }
  443. #define ALC_PIN_MODE(xname, nid, dir) \
  444. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  445. .info = alc_pin_mode_info, \
  446. .get = alc_pin_mode_get, \
  447. .put = alc_pin_mode_put, \
  448. .private_value = nid | (dir<<16) }
  449. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  450. * together using a mask with more than one bit set. This control is
  451. * currently used only by the ALC260 test model. At this stage they are not
  452. * needed for any "production" models.
  453. */
  454. #ifdef CONFIG_SND_DEBUG
  455. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  456. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  457. struct snd_ctl_elem_value *ucontrol)
  458. {
  459. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  460. hda_nid_t nid = kcontrol->private_value & 0xffff;
  461. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  462. long *valp = ucontrol->value.integer.value;
  463. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  464. AC_VERB_GET_GPIO_DATA, 0x00);
  465. *valp = (val & mask) != 0;
  466. return 0;
  467. }
  468. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  469. struct snd_ctl_elem_value *ucontrol)
  470. {
  471. signed int change;
  472. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  473. hda_nid_t nid = kcontrol->private_value & 0xffff;
  474. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  475. long val = *ucontrol->value.integer.value;
  476. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  477. AC_VERB_GET_GPIO_DATA,
  478. 0x00);
  479. /* Set/unset the masked GPIO bit(s) as needed */
  480. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  481. if (val == 0)
  482. gpio_data &= ~mask;
  483. else
  484. gpio_data |= mask;
  485. snd_hda_codec_write_cache(codec, nid, 0,
  486. AC_VERB_SET_GPIO_DATA, gpio_data);
  487. return change;
  488. }
  489. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  490. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  491. .info = alc_gpio_data_info, \
  492. .get = alc_gpio_data_get, \
  493. .put = alc_gpio_data_put, \
  494. .private_value = nid | (mask<<16) }
  495. #endif /* CONFIG_SND_DEBUG */
  496. /* A switch control to allow the enabling of the digital IO pins on the
  497. * ALC260. This is incredibly simplistic; the intention of this control is
  498. * to provide something in the test model allowing digital outputs to be
  499. * identified if present. If models are found which can utilise these
  500. * outputs a more complete mixer control can be devised for those models if
  501. * necessary.
  502. */
  503. #ifdef CONFIG_SND_DEBUG
  504. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  505. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  506. struct snd_ctl_elem_value *ucontrol)
  507. {
  508. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  509. hda_nid_t nid = kcontrol->private_value & 0xffff;
  510. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  511. long *valp = ucontrol->value.integer.value;
  512. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  513. AC_VERB_GET_DIGI_CONVERT, 0x00);
  514. *valp = (val & mask) != 0;
  515. return 0;
  516. }
  517. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  518. struct snd_ctl_elem_value *ucontrol)
  519. {
  520. signed int change;
  521. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  522. hda_nid_t nid = kcontrol->private_value & 0xffff;
  523. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  524. long val = *ucontrol->value.integer.value;
  525. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  526. AC_VERB_GET_DIGI_CONVERT,
  527. 0x00);
  528. /* Set/unset the masked control bit(s) as needed */
  529. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  530. if (val==0)
  531. ctrl_data &= ~mask;
  532. else
  533. ctrl_data |= mask;
  534. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  535. ctrl_data);
  536. return change;
  537. }
  538. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  539. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  540. .info = alc_spdif_ctrl_info, \
  541. .get = alc_spdif_ctrl_get, \
  542. .put = alc_spdif_ctrl_put, \
  543. .private_value = nid | (mask<<16) }
  544. #endif /* CONFIG_SND_DEBUG */
  545. /*
  546. * set up from the preset table
  547. */
  548. static void setup_preset(struct alc_spec *spec,
  549. const struct alc_config_preset *preset)
  550. {
  551. int i;
  552. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  553. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  554. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  555. i++)
  556. spec->init_verbs[spec->num_init_verbs++] =
  557. preset->init_verbs[i];
  558. spec->channel_mode = preset->channel_mode;
  559. spec->num_channel_mode = preset->num_channel_mode;
  560. spec->need_dac_fix = preset->need_dac_fix;
  561. spec->multiout.max_channels = spec->channel_mode[0].channels;
  562. spec->multiout.num_dacs = preset->num_dacs;
  563. spec->multiout.dac_nids = preset->dac_nids;
  564. spec->multiout.dig_out_nid = preset->dig_out_nid;
  565. spec->multiout.hp_nid = preset->hp_nid;
  566. spec->num_mux_defs = preset->num_mux_defs;
  567. if (!spec->num_mux_defs)
  568. spec->num_mux_defs = 1;
  569. spec->input_mux = preset->input_mux;
  570. spec->num_adc_nids = preset->num_adc_nids;
  571. spec->adc_nids = preset->adc_nids;
  572. spec->dig_in_nid = preset->dig_in_nid;
  573. spec->unsol_event = preset->unsol_event;
  574. spec->init_hook = preset->init_hook;
  575. #ifdef CONFIG_SND_HDA_POWER_SAVE
  576. spec->loopback.amplist = preset->loopbacks;
  577. #endif
  578. }
  579. /* Enable GPIO mask and set output */
  580. static struct hda_verb alc_gpio1_init_verbs[] = {
  581. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  582. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  583. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  584. { }
  585. };
  586. static struct hda_verb alc_gpio2_init_verbs[] = {
  587. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  588. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  589. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  590. { }
  591. };
  592. static struct hda_verb alc_gpio3_init_verbs[] = {
  593. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  594. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  595. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  596. { }
  597. };
  598. static void alc_sku_automute(struct hda_codec *codec)
  599. {
  600. struct alc_spec *spec = codec->spec;
  601. unsigned int mute;
  602. unsigned int present;
  603. unsigned int hp_nid = spec->autocfg.hp_pins[0];
  604. unsigned int sp_nid = spec->autocfg.speaker_pins[0];
  605. /* need to execute and sync at first */
  606. snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
  607. present = snd_hda_codec_read(codec, hp_nid, 0,
  608. AC_VERB_GET_PIN_SENSE, 0);
  609. spec->jack_present = (present & 0x80000000) != 0;
  610. if (spec->jack_present) {
  611. /* mute internal speaker */
  612. snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
  613. HDA_AMP_MUTE, HDA_AMP_MUTE);
  614. } else {
  615. /* unmute internal speaker if necessary */
  616. mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
  617. snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
  618. HDA_AMP_MUTE, mute);
  619. }
  620. }
  621. /* unsolicited event for HP jack sensing */
  622. static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
  623. {
  624. if (codec->vendor_id == 0x10ec0880)
  625. res >>= 28;
  626. else
  627. res >>= 26;
  628. if (res != ALC880_HP_EVENT)
  629. return;
  630. alc_sku_automute(codec);
  631. }
  632. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  633. * 31 ~ 16 : Manufacture ID
  634. * 15 ~ 8 : SKU ID
  635. * 7 ~ 0 : Assembly ID
  636. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  637. */
  638. static void alc_subsystem_id(struct hda_codec *codec,
  639. unsigned int porta, unsigned int porte,
  640. unsigned int portd)
  641. {
  642. unsigned int ass, tmp, i;
  643. unsigned nid;
  644. struct alc_spec *spec = codec->spec;
  645. ass = codec->subsystem_id & 0xffff;
  646. if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
  647. goto do_sku;
  648. /*
  649. * 31~30 : port conetcivity
  650. * 29~21 : reserve
  651. * 20 : PCBEEP input
  652. * 19~16 : Check sum (15:1)
  653. * 15~1 : Custom
  654. * 0 : override
  655. */
  656. nid = 0x1d;
  657. if (codec->vendor_id == 0x10ec0260)
  658. nid = 0x17;
  659. ass = snd_hda_codec_read(codec, nid, 0,
  660. AC_VERB_GET_CONFIG_DEFAULT, 0);
  661. if (!(ass & 1) && !(ass & 0x100000))
  662. return;
  663. if ((ass >> 30) != 1) /* no physical connection */
  664. return;
  665. /* check sum */
  666. tmp = 0;
  667. for (i = 1; i < 16; i++) {
  668. if ((ass >> i) && 1)
  669. tmp++;
  670. }
  671. if (((ass >> 16) & 0xf) != tmp)
  672. return;
  673. do_sku:
  674. /*
  675. * 0 : override
  676. * 1 : Swap Jack
  677. * 2 : 0 --> Desktop, 1 --> Laptop
  678. * 3~5 : External Amplifier control
  679. * 7~6 : Reserved
  680. */
  681. tmp = (ass & 0x38) >> 3; /* external Amp control */
  682. switch (tmp) {
  683. case 1:
  684. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  685. break;
  686. case 3:
  687. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  688. break;
  689. case 7:
  690. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  691. break;
  692. case 5: /* set EAPD output high */
  693. switch (codec->vendor_id) {
  694. case 0x10ec0260:
  695. snd_hda_codec_write(codec, 0x0f, 0,
  696. AC_VERB_SET_EAPD_BTLENABLE, 2);
  697. snd_hda_codec_write(codec, 0x10, 0,
  698. AC_VERB_SET_EAPD_BTLENABLE, 2);
  699. break;
  700. case 0x10ec0262:
  701. case 0x10ec0267:
  702. case 0x10ec0268:
  703. case 0x10ec0269:
  704. case 0x10ec0862:
  705. case 0x10ec0662:
  706. snd_hda_codec_write(codec, 0x14, 0,
  707. AC_VERB_SET_EAPD_BTLENABLE, 2);
  708. snd_hda_codec_write(codec, 0x15, 0,
  709. AC_VERB_SET_EAPD_BTLENABLE, 2);
  710. break;
  711. }
  712. switch (codec->vendor_id) {
  713. case 0x10ec0260:
  714. snd_hda_codec_write(codec, 0x1a, 0,
  715. AC_VERB_SET_COEF_INDEX, 7);
  716. tmp = snd_hda_codec_read(codec, 0x1a, 0,
  717. AC_VERB_GET_PROC_COEF, 0);
  718. snd_hda_codec_write(codec, 0x1a, 0,
  719. AC_VERB_SET_COEF_INDEX, 7);
  720. snd_hda_codec_write(codec, 0x1a, 0,
  721. AC_VERB_SET_PROC_COEF,
  722. tmp | 0x2010);
  723. break;
  724. case 0x10ec0262:
  725. case 0x10ec0880:
  726. case 0x10ec0882:
  727. case 0x10ec0883:
  728. case 0x10ec0885:
  729. case 0x10ec0888:
  730. snd_hda_codec_write(codec, 0x20, 0,
  731. AC_VERB_SET_COEF_INDEX, 7);
  732. tmp = snd_hda_codec_read(codec, 0x20, 0,
  733. AC_VERB_GET_PROC_COEF, 0);
  734. snd_hda_codec_write(codec, 0x20, 0,
  735. AC_VERB_SET_COEF_INDEX, 7);
  736. snd_hda_codec_write(codec, 0x20, 0,
  737. AC_VERB_SET_PROC_COEF,
  738. tmp | 0x2010);
  739. break;
  740. case 0x10ec0267:
  741. case 0x10ec0268:
  742. snd_hda_codec_write(codec, 0x20, 0,
  743. AC_VERB_SET_COEF_INDEX, 7);
  744. tmp = snd_hda_codec_read(codec, 0x20, 0,
  745. AC_VERB_GET_PROC_COEF, 0);
  746. snd_hda_codec_write(codec, 0x20, 0,
  747. AC_VERB_SET_COEF_INDEX, 7);
  748. snd_hda_codec_write(codec, 0x20, 0,
  749. AC_VERB_SET_PROC_COEF,
  750. tmp | 0x3000);
  751. break;
  752. }
  753. default:
  754. break;
  755. }
  756. /* is laptop and enable the function "Mute internal speaker
  757. * when the external headphone out jack is plugged"
  758. */
  759. if (!(ass & 0x4) || !(ass & 0x8000))
  760. return;
  761. /*
  762. * 10~8 : Jack location
  763. * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
  764. * 14~13: Resvered
  765. * 15 : 1 --> enable the function "Mute internal speaker
  766. * when the external headphone out jack is plugged"
  767. */
  768. if (!spec->autocfg.speaker_pins[0]) {
  769. if (spec->multiout.dac_nids[0])
  770. spec->autocfg.speaker_pins[0] =
  771. spec->multiout.dac_nids[0];
  772. else
  773. return;
  774. }
  775. if (!spec->autocfg.hp_pins[0]) {
  776. tmp = (ass >> 11) & 0x3; /* HP to chassis */
  777. if (tmp == 0)
  778. spec->autocfg.hp_pins[0] = porta;
  779. else if (tmp == 1)
  780. spec->autocfg.hp_pins[0] = porte;
  781. else if (tmp == 2)
  782. spec->autocfg.hp_pins[0] = portd;
  783. else
  784. return;
  785. }
  786. snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
  787. AC_VERB_SET_UNSOLICITED_ENABLE,
  788. AC_USRSP_EN | ALC880_HP_EVENT);
  789. spec->unsol_event = alc_sku_unsol_event;
  790. spec->init_hook = alc_sku_automute;
  791. }
  792. /*
  793. * Fix-up pin default configurations
  794. */
  795. struct alc_pincfg {
  796. hda_nid_t nid;
  797. u32 val;
  798. };
  799. static void alc_fix_pincfg(struct hda_codec *codec,
  800. const struct snd_pci_quirk *quirk,
  801. const struct alc_pincfg **pinfix)
  802. {
  803. const struct alc_pincfg *cfg;
  804. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  805. if (!quirk)
  806. return;
  807. cfg = pinfix[quirk->value];
  808. for (; cfg->nid; cfg++) {
  809. int i;
  810. u32 val = cfg->val;
  811. for (i = 0; i < 4; i++) {
  812. snd_hda_codec_write(codec, cfg->nid, 0,
  813. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  814. val & 0xff);
  815. val >>= 8;
  816. }
  817. }
  818. }
  819. /*
  820. * ALC880 3-stack model
  821. *
  822. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  823. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  824. * F-Mic = 0x1b, HP = 0x19
  825. */
  826. static hda_nid_t alc880_dac_nids[4] = {
  827. /* front, rear, clfe, rear_surr */
  828. 0x02, 0x05, 0x04, 0x03
  829. };
  830. static hda_nid_t alc880_adc_nids[3] = {
  831. /* ADC0-2 */
  832. 0x07, 0x08, 0x09,
  833. };
  834. /* The datasheet says the node 0x07 is connected from inputs,
  835. * but it shows zero connection in the real implementation on some devices.
  836. * Note: this is a 915GAV bug, fixed on 915GLV
  837. */
  838. static hda_nid_t alc880_adc_nids_alt[2] = {
  839. /* ADC1-2 */
  840. 0x08, 0x09,
  841. };
  842. #define ALC880_DIGOUT_NID 0x06
  843. #define ALC880_DIGIN_NID 0x0a
  844. static struct hda_input_mux alc880_capture_source = {
  845. .num_items = 4,
  846. .items = {
  847. { "Mic", 0x0 },
  848. { "Front Mic", 0x3 },
  849. { "Line", 0x2 },
  850. { "CD", 0x4 },
  851. },
  852. };
  853. /* channel source setting (2/6 channel selection for 3-stack) */
  854. /* 2ch mode */
  855. static struct hda_verb alc880_threestack_ch2_init[] = {
  856. /* set line-in to input, mute it */
  857. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  858. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  859. /* set mic-in to input vref 80%, mute it */
  860. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  861. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  862. { } /* end */
  863. };
  864. /* 6ch mode */
  865. static struct hda_verb alc880_threestack_ch6_init[] = {
  866. /* set line-in to output, unmute it */
  867. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  868. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  869. /* set mic-in to output, unmute it */
  870. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  871. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  872. { } /* end */
  873. };
  874. static struct hda_channel_mode alc880_threestack_modes[2] = {
  875. { 2, alc880_threestack_ch2_init },
  876. { 6, alc880_threestack_ch6_init },
  877. };
  878. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  879. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  880. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  881. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  882. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  883. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  884. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  885. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  886. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  887. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  888. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  889. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  890. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  891. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  892. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  893. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  894. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  895. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  896. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  897. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  898. {
  899. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  900. .name = "Channel Mode",
  901. .info = alc_ch_mode_info,
  902. .get = alc_ch_mode_get,
  903. .put = alc_ch_mode_put,
  904. },
  905. { } /* end */
  906. };
  907. /* capture mixer elements */
  908. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  909. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  910. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  911. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  912. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  913. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  914. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  915. {
  916. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  917. /* The multiple "Capture Source" controls confuse alsamixer
  918. * So call somewhat different..
  919. * FIXME: the controls appear in the "playback" view!
  920. */
  921. /* .name = "Capture Source", */
  922. .name = "Input Source",
  923. .count = 3,
  924. .info = alc_mux_enum_info,
  925. .get = alc_mux_enum_get,
  926. .put = alc_mux_enum_put,
  927. },
  928. { } /* end */
  929. };
  930. /* capture mixer elements (in case NID 0x07 not available) */
  931. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  932. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  933. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  934. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  935. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  936. {
  937. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  938. /* The multiple "Capture Source" controls confuse alsamixer
  939. * So call somewhat different..
  940. * FIXME: the controls appear in the "playback" view!
  941. */
  942. /* .name = "Capture Source", */
  943. .name = "Input Source",
  944. .count = 2,
  945. .info = alc_mux_enum_info,
  946. .get = alc_mux_enum_get,
  947. .put = alc_mux_enum_put,
  948. },
  949. { } /* end */
  950. };
  951. /*
  952. * ALC880 5-stack model
  953. *
  954. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  955. * Side = 0x02 (0xd)
  956. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  957. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  958. */
  959. /* additional mixers to alc880_three_stack_mixer */
  960. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  961. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  962. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  963. { } /* end */
  964. };
  965. /* channel source setting (6/8 channel selection for 5-stack) */
  966. /* 6ch mode */
  967. static struct hda_verb alc880_fivestack_ch6_init[] = {
  968. /* set line-in to input, mute it */
  969. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  970. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  971. { } /* end */
  972. };
  973. /* 8ch mode */
  974. static struct hda_verb alc880_fivestack_ch8_init[] = {
  975. /* set line-in to output, unmute it */
  976. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  977. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  978. { } /* end */
  979. };
  980. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  981. { 6, alc880_fivestack_ch6_init },
  982. { 8, alc880_fivestack_ch8_init },
  983. };
  984. /*
  985. * ALC880 6-stack model
  986. *
  987. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  988. * Side = 0x05 (0x0f)
  989. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  990. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  991. */
  992. static hda_nid_t alc880_6st_dac_nids[4] = {
  993. /* front, rear, clfe, rear_surr */
  994. 0x02, 0x03, 0x04, 0x05
  995. };
  996. static struct hda_input_mux alc880_6stack_capture_source = {
  997. .num_items = 4,
  998. .items = {
  999. { "Mic", 0x0 },
  1000. { "Front Mic", 0x1 },
  1001. { "Line", 0x2 },
  1002. { "CD", 0x4 },
  1003. },
  1004. };
  1005. /* fixed 8-channels */
  1006. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  1007. { 8, NULL },
  1008. };
  1009. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  1010. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1011. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1012. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1013. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1014. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1015. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1016. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1017. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1018. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1019. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1020. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1021. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1022. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1023. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1024. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1025. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1026. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1027. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1028. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1029. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1030. {
  1031. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1032. .name = "Channel Mode",
  1033. .info = alc_ch_mode_info,
  1034. .get = alc_ch_mode_get,
  1035. .put = alc_ch_mode_put,
  1036. },
  1037. { } /* end */
  1038. };
  1039. /*
  1040. * ALC880 W810 model
  1041. *
  1042. * W810 has rear IO for:
  1043. * Front (DAC 02)
  1044. * Surround (DAC 03)
  1045. * Center/LFE (DAC 04)
  1046. * Digital out (06)
  1047. *
  1048. * The system also has a pair of internal speakers, and a headphone jack.
  1049. * These are both connected to Line2 on the codec, hence to DAC 02.
  1050. *
  1051. * There is a variable resistor to control the speaker or headphone
  1052. * volume. This is a hardware-only device without a software API.
  1053. *
  1054. * Plugging headphones in will disable the internal speakers. This is
  1055. * implemented in hardware, not via the driver using jack sense. In
  1056. * a similar fashion, plugging into the rear socket marked "front" will
  1057. * disable both the speakers and headphones.
  1058. *
  1059. * For input, there's a microphone jack, and an "audio in" jack.
  1060. * These may not do anything useful with this driver yet, because I
  1061. * haven't setup any initialization verbs for these yet...
  1062. */
  1063. static hda_nid_t alc880_w810_dac_nids[3] = {
  1064. /* front, rear/surround, clfe */
  1065. 0x02, 0x03, 0x04
  1066. };
  1067. /* fixed 6 channels */
  1068. static struct hda_channel_mode alc880_w810_modes[1] = {
  1069. { 6, NULL }
  1070. };
  1071. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  1072. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  1073. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1074. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1075. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1076. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1077. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1078. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1079. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1080. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1081. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1082. { } /* end */
  1083. };
  1084. /*
  1085. * Z710V model
  1086. *
  1087. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  1088. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  1089. * Line = 0x1a
  1090. */
  1091. static hda_nid_t alc880_z71v_dac_nids[1] = {
  1092. 0x02
  1093. };
  1094. #define ALC880_Z71V_HP_DAC 0x03
  1095. /* fixed 2 channels */
  1096. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  1097. { 2, NULL }
  1098. };
  1099. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  1100. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1101. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1102. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1103. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  1104. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1105. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1106. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1107. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1108. { } /* end */
  1109. };
  1110. /* FIXME! */
  1111. /*
  1112. * ALC880 F1734 model
  1113. *
  1114. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  1115. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  1116. */
  1117. static hda_nid_t alc880_f1734_dac_nids[1] = {
  1118. 0x03
  1119. };
  1120. #define ALC880_F1734_HP_DAC 0x02
  1121. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  1122. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1123. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1124. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1125. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1126. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1127. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1128. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1129. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1130. { } /* end */
  1131. };
  1132. /* FIXME! */
  1133. /*
  1134. * ALC880 ASUS model
  1135. *
  1136. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1137. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1138. * Mic = 0x18, Line = 0x1a
  1139. */
  1140. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1141. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1142. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1143. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1144. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1145. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1146. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1147. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1148. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1149. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1150. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1151. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1152. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1153. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1154. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1155. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1156. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1157. {
  1158. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1159. .name = "Channel Mode",
  1160. .info = alc_ch_mode_info,
  1161. .get = alc_ch_mode_get,
  1162. .put = alc_ch_mode_put,
  1163. },
  1164. { } /* end */
  1165. };
  1166. /* FIXME! */
  1167. /*
  1168. * ALC880 ASUS W1V model
  1169. *
  1170. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1171. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1172. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1173. */
  1174. /* additional mixers to alc880_asus_mixer */
  1175. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1176. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1177. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1178. { } /* end */
  1179. };
  1180. /* additional mixers to alc880_asus_mixer */
  1181. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1182. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1183. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1184. { } /* end */
  1185. };
  1186. /* TCL S700 */
  1187. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1188. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1189. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1190. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1191. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1192. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1193. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1194. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1195. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1196. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1197. {
  1198. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1199. /* The multiple "Capture Source" controls confuse alsamixer
  1200. * So call somewhat different..
  1201. * FIXME: the controls appear in the "playback" view!
  1202. */
  1203. /* .name = "Capture Source", */
  1204. .name = "Input Source",
  1205. .count = 1,
  1206. .info = alc_mux_enum_info,
  1207. .get = alc_mux_enum_get,
  1208. .put = alc_mux_enum_put,
  1209. },
  1210. { } /* end */
  1211. };
  1212. /* Uniwill */
  1213. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1214. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1215. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1216. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1217. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1218. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1219. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1220. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1221. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1222. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1223. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1224. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1225. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1226. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1227. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1228. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1229. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1230. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1231. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1232. {
  1233. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1234. .name = "Channel Mode",
  1235. .info = alc_ch_mode_info,
  1236. .get = alc_ch_mode_get,
  1237. .put = alc_ch_mode_put,
  1238. },
  1239. { } /* end */
  1240. };
  1241. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1242. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1243. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1244. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1245. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1246. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1247. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1248. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1249. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1250. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1251. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1252. { } /* end */
  1253. };
  1254. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1255. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1256. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1257. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1258. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1259. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1260. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1261. { } /* end */
  1262. };
  1263. /*
  1264. * build control elements
  1265. */
  1266. static int alc_build_controls(struct hda_codec *codec)
  1267. {
  1268. struct alc_spec *spec = codec->spec;
  1269. int err;
  1270. int i;
  1271. for (i = 0; i < spec->num_mixers; i++) {
  1272. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1273. if (err < 0)
  1274. return err;
  1275. }
  1276. if (spec->multiout.dig_out_nid) {
  1277. err = snd_hda_create_spdif_out_ctls(codec,
  1278. spec->multiout.dig_out_nid);
  1279. if (err < 0)
  1280. return err;
  1281. }
  1282. if (spec->dig_in_nid) {
  1283. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1284. if (err < 0)
  1285. return err;
  1286. }
  1287. return 0;
  1288. }
  1289. /*
  1290. * initialize the codec volumes, etc
  1291. */
  1292. /*
  1293. * generic initialization of ADC, input mixers and output mixers
  1294. */
  1295. static struct hda_verb alc880_volume_init_verbs[] = {
  1296. /*
  1297. * Unmute ADC0-2 and set the default input to mic-in
  1298. */
  1299. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1300. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1301. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1302. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1303. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1304. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1305. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1306. * mixer widget
  1307. * Note: PASD motherboards uses the Line In 2 as the input for front
  1308. * panel mic (mic 2)
  1309. */
  1310. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1311. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1312. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1313. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1314. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1315. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1316. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1317. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1318. /*
  1319. * Set up output mixers (0x0c - 0x0f)
  1320. */
  1321. /* set vol=0 to output mixers */
  1322. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1323. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1324. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1325. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1326. /* set up input amps for analog loopback */
  1327. /* Amp Indices: DAC = 0, mixer = 1 */
  1328. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1329. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1330. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1331. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1332. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1333. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1334. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1335. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1336. { }
  1337. };
  1338. /*
  1339. * 3-stack pin configuration:
  1340. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1341. */
  1342. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1343. /*
  1344. * preset connection lists of input pins
  1345. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1346. */
  1347. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1348. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1349. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1350. /*
  1351. * Set pin mode and muting
  1352. */
  1353. /* set front pin widgets 0x14 for output */
  1354. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1355. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1356. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1357. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1358. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1359. /* Mic2 (as headphone out) for HP output */
  1360. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1361. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1362. /* Line In pin widget for input */
  1363. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1364. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1365. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1366. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1367. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1368. /* CD pin widget for input */
  1369. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1370. { }
  1371. };
  1372. /*
  1373. * 5-stack pin configuration:
  1374. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1375. * line-in/side = 0x1a, f-mic = 0x1b
  1376. */
  1377. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1378. /*
  1379. * preset connection lists of input pins
  1380. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1381. */
  1382. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1383. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1384. /*
  1385. * Set pin mode and muting
  1386. */
  1387. /* set pin widgets 0x14-0x17 for output */
  1388. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1389. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1390. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1391. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1392. /* unmute pins for output (no gain on this amp) */
  1393. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1394. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1395. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1396. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1397. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1398. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1399. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1400. /* Mic2 (as headphone out) for HP output */
  1401. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1402. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1403. /* Line In pin widget for input */
  1404. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1405. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1406. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1407. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1408. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1409. /* CD pin widget for input */
  1410. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1411. { }
  1412. };
  1413. /*
  1414. * W810 pin configuration:
  1415. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1416. */
  1417. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1418. /* hphone/speaker input selector: front DAC */
  1419. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1420. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1421. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1422. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1423. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1424. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1425. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1426. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1427. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1428. { }
  1429. };
  1430. /*
  1431. * Z71V pin configuration:
  1432. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1433. */
  1434. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1435. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1436. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1437. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1438. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1439. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1440. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1441. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1442. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1443. { }
  1444. };
  1445. /*
  1446. * 6-stack pin configuration:
  1447. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1448. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1449. */
  1450. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1451. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1452. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1453. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1454. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1455. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1456. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1457. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1458. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1459. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1460. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1461. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1462. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1463. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1464. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1465. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1466. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1467. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1468. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1469. { }
  1470. };
  1471. /*
  1472. * Uniwill pin configuration:
  1473. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1474. * line = 0x1a
  1475. */
  1476. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1477. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1478. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1479. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1480. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1481. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1482. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1483. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1484. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1485. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1486. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1487. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1488. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1489. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1490. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1491. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1492. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1493. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1494. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1495. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1496. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1497. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1498. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1499. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1500. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1501. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1502. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1503. { }
  1504. };
  1505. /*
  1506. * Uniwill P53
  1507. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1508. */
  1509. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1510. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1511. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1512. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1513. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1514. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1515. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1516. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1517. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1518. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1519. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1520. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1521. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1522. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1523. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1524. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1525. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1526. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1527. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1528. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1529. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1530. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1531. { }
  1532. };
  1533. static struct hda_verb alc880_beep_init_verbs[] = {
  1534. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1535. { }
  1536. };
  1537. /* toggle speaker-output according to the hp-jack state */
  1538. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1539. {
  1540. unsigned int present;
  1541. unsigned char bits;
  1542. present = snd_hda_codec_read(codec, 0x14, 0,
  1543. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1544. bits = present ? HDA_AMP_MUTE : 0;
  1545. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1546. HDA_AMP_MUTE, bits);
  1547. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1548. HDA_AMP_MUTE, bits);
  1549. }
  1550. /* auto-toggle front mic */
  1551. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1552. {
  1553. unsigned int present;
  1554. unsigned char bits;
  1555. present = snd_hda_codec_read(codec, 0x18, 0,
  1556. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1557. bits = present ? HDA_AMP_MUTE : 0;
  1558. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1559. }
  1560. static void alc880_uniwill_automute(struct hda_codec *codec)
  1561. {
  1562. alc880_uniwill_hp_automute(codec);
  1563. alc880_uniwill_mic_automute(codec);
  1564. }
  1565. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1566. unsigned int res)
  1567. {
  1568. /* Looks like the unsol event is incompatible with the standard
  1569. * definition. 4bit tag is placed at 28 bit!
  1570. */
  1571. switch (res >> 28) {
  1572. case ALC880_HP_EVENT:
  1573. alc880_uniwill_hp_automute(codec);
  1574. break;
  1575. case ALC880_MIC_EVENT:
  1576. alc880_uniwill_mic_automute(codec);
  1577. break;
  1578. }
  1579. }
  1580. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1581. {
  1582. unsigned int present;
  1583. unsigned char bits;
  1584. present = snd_hda_codec_read(codec, 0x14, 0,
  1585. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1586. bits = present ? HDA_AMP_MUTE : 0;
  1587. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1588. }
  1589. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1590. {
  1591. unsigned int present;
  1592. present = snd_hda_codec_read(codec, 0x21, 0,
  1593. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1594. present &= HDA_AMP_VOLMASK;
  1595. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1596. HDA_AMP_VOLMASK, present);
  1597. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1598. HDA_AMP_VOLMASK, present);
  1599. }
  1600. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1601. unsigned int res)
  1602. {
  1603. /* Looks like the unsol event is incompatible with the standard
  1604. * definition. 4bit tag is placed at 28 bit!
  1605. */
  1606. if ((res >> 28) == ALC880_HP_EVENT)
  1607. alc880_uniwill_p53_hp_automute(codec);
  1608. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1609. alc880_uniwill_p53_dcvol_automute(codec);
  1610. }
  1611. /* FIXME! */
  1612. /*
  1613. * F1734 pin configuration:
  1614. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1615. */
  1616. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1617. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1618. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1619. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1620. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1621. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1622. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1623. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1624. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1625. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1626. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1627. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1628. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1629. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1630. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1631. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1632. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1633. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1634. { }
  1635. };
  1636. /* FIXME! */
  1637. /*
  1638. * ASUS pin configuration:
  1639. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1640. */
  1641. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1642. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1643. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1644. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1645. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1646. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1647. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1648. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1649. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1650. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1651. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1652. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1653. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1654. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1655. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1656. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1657. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1658. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1659. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1660. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1661. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1662. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1663. { }
  1664. };
  1665. /* Enable GPIO mask and set output */
  1666. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1667. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1668. /* Clevo m520g init */
  1669. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1670. /* headphone output */
  1671. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1672. /* line-out */
  1673. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1674. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1675. /* Line-in */
  1676. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1677. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1678. /* CD */
  1679. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1680. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1681. /* Mic1 (rear panel) */
  1682. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1683. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1684. /* Mic2 (front panel) */
  1685. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1686. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1687. /* headphone */
  1688. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1689. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1690. /* change to EAPD mode */
  1691. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1692. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1693. { }
  1694. };
  1695. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1696. /* change to EAPD mode */
  1697. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1698. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1699. /* Headphone output */
  1700. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1701. /* Front output*/
  1702. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1703. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1704. /* Line In pin widget for input */
  1705. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1706. /* CD pin widget for input */
  1707. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1708. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1709. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1710. /* change to EAPD mode */
  1711. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1712. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1713. { }
  1714. };
  1715. /*
  1716. * LG m1 express dual
  1717. *
  1718. * Pin assignment:
  1719. * Rear Line-In/Out (blue): 0x14
  1720. * Build-in Mic-In: 0x15
  1721. * Speaker-out: 0x17
  1722. * HP-Out (green): 0x1b
  1723. * Mic-In/Out (red): 0x19
  1724. * SPDIF-Out: 0x1e
  1725. */
  1726. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1727. static hda_nid_t alc880_lg_dac_nids[3] = {
  1728. 0x05, 0x02, 0x03
  1729. };
  1730. /* seems analog CD is not working */
  1731. static struct hda_input_mux alc880_lg_capture_source = {
  1732. .num_items = 3,
  1733. .items = {
  1734. { "Mic", 0x1 },
  1735. { "Line", 0x5 },
  1736. { "Internal Mic", 0x6 },
  1737. },
  1738. };
  1739. /* 2,4,6 channel modes */
  1740. static struct hda_verb alc880_lg_ch2_init[] = {
  1741. /* set line-in and mic-in to input */
  1742. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1743. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1744. { }
  1745. };
  1746. static struct hda_verb alc880_lg_ch4_init[] = {
  1747. /* set line-in to out and mic-in to input */
  1748. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1749. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1750. { }
  1751. };
  1752. static struct hda_verb alc880_lg_ch6_init[] = {
  1753. /* set line-in and mic-in to output */
  1754. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1755. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1756. { }
  1757. };
  1758. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1759. { 2, alc880_lg_ch2_init },
  1760. { 4, alc880_lg_ch4_init },
  1761. { 6, alc880_lg_ch6_init },
  1762. };
  1763. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1764. /* FIXME: it's not really "master" but front channels */
  1765. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1766. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1767. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1768. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1769. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1770. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1771. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1772. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1773. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1774. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1775. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1776. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1777. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1778. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1779. {
  1780. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1781. .name = "Channel Mode",
  1782. .info = alc_ch_mode_info,
  1783. .get = alc_ch_mode_get,
  1784. .put = alc_ch_mode_put,
  1785. },
  1786. { } /* end */
  1787. };
  1788. static struct hda_verb alc880_lg_init_verbs[] = {
  1789. /* set capture source to mic-in */
  1790. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1791. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1792. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1793. /* mute all amp mixer inputs */
  1794. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1795. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1796. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1797. /* line-in to input */
  1798. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1799. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1800. /* built-in mic */
  1801. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1802. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1803. /* speaker-out */
  1804. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1805. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1806. /* mic-in to input */
  1807. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1808. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1809. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1810. /* HP-out */
  1811. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1812. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1813. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1814. /* jack sense */
  1815. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1816. { }
  1817. };
  1818. /* toggle speaker-output according to the hp-jack state */
  1819. static void alc880_lg_automute(struct hda_codec *codec)
  1820. {
  1821. unsigned int present;
  1822. unsigned char bits;
  1823. present = snd_hda_codec_read(codec, 0x1b, 0,
  1824. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1825. bits = present ? HDA_AMP_MUTE : 0;
  1826. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1827. HDA_AMP_MUTE, bits);
  1828. }
  1829. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1830. {
  1831. /* Looks like the unsol event is incompatible with the standard
  1832. * definition. 4bit tag is placed at 28 bit!
  1833. */
  1834. if ((res >> 28) == 0x01)
  1835. alc880_lg_automute(codec);
  1836. }
  1837. /*
  1838. * LG LW20
  1839. *
  1840. * Pin assignment:
  1841. * Speaker-out: 0x14
  1842. * Mic-In: 0x18
  1843. * Built-in Mic-In: 0x19
  1844. * Line-In: 0x1b
  1845. * HP-Out: 0x1a
  1846. * SPDIF-Out: 0x1e
  1847. */
  1848. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1849. .num_items = 3,
  1850. .items = {
  1851. { "Mic", 0x0 },
  1852. { "Internal Mic", 0x1 },
  1853. { "Line In", 0x2 },
  1854. },
  1855. };
  1856. #define alc880_lg_lw_modes alc880_threestack_modes
  1857. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1858. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1859. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1860. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1861. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1862. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1863. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1864. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1865. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1866. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1867. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1868. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1869. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1870. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1871. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1872. {
  1873. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1874. .name = "Channel Mode",
  1875. .info = alc_ch_mode_info,
  1876. .get = alc_ch_mode_get,
  1877. .put = alc_ch_mode_put,
  1878. },
  1879. { } /* end */
  1880. };
  1881. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1882. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1883. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1884. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1885. /* set capture source to mic-in */
  1886. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1887. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1888. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1889. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1890. /* speaker-out */
  1891. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1892. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1893. /* HP-out */
  1894. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1895. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1896. /* mic-in to input */
  1897. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1898. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1899. /* built-in mic */
  1900. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1901. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1902. /* jack sense */
  1903. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1904. { }
  1905. };
  1906. /* toggle speaker-output according to the hp-jack state */
  1907. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1908. {
  1909. unsigned int present;
  1910. unsigned char bits;
  1911. present = snd_hda_codec_read(codec, 0x1b, 0,
  1912. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1913. bits = present ? HDA_AMP_MUTE : 0;
  1914. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1915. HDA_AMP_MUTE, bits);
  1916. }
  1917. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1918. {
  1919. /* Looks like the unsol event is incompatible with the standard
  1920. * definition. 4bit tag is placed at 28 bit!
  1921. */
  1922. if ((res >> 28) == 0x01)
  1923. alc880_lg_lw_automute(codec);
  1924. }
  1925. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1926. static struct hda_amp_list alc880_loopbacks[] = {
  1927. { 0x0b, HDA_INPUT, 0 },
  1928. { 0x0b, HDA_INPUT, 1 },
  1929. { 0x0b, HDA_INPUT, 2 },
  1930. { 0x0b, HDA_INPUT, 3 },
  1931. { 0x0b, HDA_INPUT, 4 },
  1932. { } /* end */
  1933. };
  1934. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1935. { 0x0b, HDA_INPUT, 1 },
  1936. { 0x0b, HDA_INPUT, 6 },
  1937. { 0x0b, HDA_INPUT, 7 },
  1938. { } /* end */
  1939. };
  1940. #endif
  1941. /*
  1942. * Common callbacks
  1943. */
  1944. static int alc_init(struct hda_codec *codec)
  1945. {
  1946. struct alc_spec *spec = codec->spec;
  1947. unsigned int i;
  1948. for (i = 0; i < spec->num_init_verbs; i++)
  1949. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1950. if (spec->init_hook)
  1951. spec->init_hook(codec);
  1952. return 0;
  1953. }
  1954. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1955. {
  1956. struct alc_spec *spec = codec->spec;
  1957. if (spec->unsol_event)
  1958. spec->unsol_event(codec, res);
  1959. }
  1960. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1961. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1962. {
  1963. struct alc_spec *spec = codec->spec;
  1964. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1965. }
  1966. #endif
  1967. /*
  1968. * Analog playback callbacks
  1969. */
  1970. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1971. struct hda_codec *codec,
  1972. struct snd_pcm_substream *substream)
  1973. {
  1974. struct alc_spec *spec = codec->spec;
  1975. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1976. }
  1977. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1978. struct hda_codec *codec,
  1979. unsigned int stream_tag,
  1980. unsigned int format,
  1981. struct snd_pcm_substream *substream)
  1982. {
  1983. struct alc_spec *spec = codec->spec;
  1984. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1985. stream_tag, format, substream);
  1986. }
  1987. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1988. struct hda_codec *codec,
  1989. struct snd_pcm_substream *substream)
  1990. {
  1991. struct alc_spec *spec = codec->spec;
  1992. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1993. }
  1994. /*
  1995. * Digital out
  1996. */
  1997. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1998. struct hda_codec *codec,
  1999. struct snd_pcm_substream *substream)
  2000. {
  2001. struct alc_spec *spec = codec->spec;
  2002. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  2003. }
  2004. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  2005. struct hda_codec *codec,
  2006. unsigned int stream_tag,
  2007. unsigned int format,
  2008. struct snd_pcm_substream *substream)
  2009. {
  2010. struct alc_spec *spec = codec->spec;
  2011. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  2012. stream_tag, format, substream);
  2013. }
  2014. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  2015. struct hda_codec *codec,
  2016. struct snd_pcm_substream *substream)
  2017. {
  2018. struct alc_spec *spec = codec->spec;
  2019. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  2020. }
  2021. /*
  2022. * Analog capture
  2023. */
  2024. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  2025. struct hda_codec *codec,
  2026. unsigned int stream_tag,
  2027. unsigned int format,
  2028. struct snd_pcm_substream *substream)
  2029. {
  2030. struct alc_spec *spec = codec->spec;
  2031. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  2032. stream_tag, 0, format);
  2033. return 0;
  2034. }
  2035. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2036. struct hda_codec *codec,
  2037. struct snd_pcm_substream *substream)
  2038. {
  2039. struct alc_spec *spec = codec->spec;
  2040. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  2041. 0, 0, 0);
  2042. return 0;
  2043. }
  2044. /*
  2045. */
  2046. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  2047. .substreams = 1,
  2048. .channels_min = 2,
  2049. .channels_max = 8,
  2050. /* NID is set in alc_build_pcms */
  2051. .ops = {
  2052. .open = alc880_playback_pcm_open,
  2053. .prepare = alc880_playback_pcm_prepare,
  2054. .cleanup = alc880_playback_pcm_cleanup
  2055. },
  2056. };
  2057. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  2058. .substreams = 2,
  2059. .channels_min = 2,
  2060. .channels_max = 2,
  2061. /* NID is set in alc_build_pcms */
  2062. .ops = {
  2063. .prepare = alc880_capture_pcm_prepare,
  2064. .cleanup = alc880_capture_pcm_cleanup
  2065. },
  2066. };
  2067. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  2068. .substreams = 1,
  2069. .channels_min = 2,
  2070. .channels_max = 2,
  2071. /* NID is set in alc_build_pcms */
  2072. .ops = {
  2073. .open = alc880_dig_playback_pcm_open,
  2074. .close = alc880_dig_playback_pcm_close,
  2075. .prepare = alc880_dig_playback_pcm_prepare
  2076. },
  2077. };
  2078. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  2079. .substreams = 1,
  2080. .channels_min = 2,
  2081. .channels_max = 2,
  2082. /* NID is set in alc_build_pcms */
  2083. };
  2084. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  2085. static struct hda_pcm_stream alc_pcm_null_playback = {
  2086. .substreams = 0,
  2087. .channels_min = 0,
  2088. .channels_max = 0,
  2089. };
  2090. static int alc_build_pcms(struct hda_codec *codec)
  2091. {
  2092. struct alc_spec *spec = codec->spec;
  2093. struct hda_pcm *info = spec->pcm_rec;
  2094. int i;
  2095. codec->num_pcms = 1;
  2096. codec->pcm_info = info;
  2097. info->name = spec->stream_name_analog;
  2098. if (spec->stream_analog_playback) {
  2099. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  2100. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  2101. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  2102. }
  2103. if (spec->stream_analog_capture) {
  2104. snd_assert(spec->adc_nids, return -EINVAL);
  2105. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2106. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  2107. }
  2108. if (spec->channel_mode) {
  2109. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  2110. for (i = 0; i < spec->num_channel_mode; i++) {
  2111. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  2112. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  2113. }
  2114. }
  2115. }
  2116. /* SPDIF for stream index #1 */
  2117. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  2118. codec->num_pcms = 2;
  2119. info = spec->pcm_rec + 1;
  2120. info->name = spec->stream_name_digital;
  2121. if (spec->multiout.dig_out_nid &&
  2122. spec->stream_digital_playback) {
  2123. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  2124. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  2125. }
  2126. if (spec->dig_in_nid &&
  2127. spec->stream_digital_capture) {
  2128. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  2129. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  2130. }
  2131. }
  2132. /* If the use of more than one ADC is requested for the current
  2133. * model, configure a second analog capture-only PCM.
  2134. */
  2135. /* Additional Analaog capture for index #2 */
  2136. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  2137. spec->adc_nids) {
  2138. codec->num_pcms = 3;
  2139. info = spec->pcm_rec + 2;
  2140. info->name = spec->stream_name_analog;
  2141. /* No playback stream for second PCM */
  2142. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2143. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2144. if (spec->stream_analog_capture) {
  2145. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2146. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2147. }
  2148. }
  2149. return 0;
  2150. }
  2151. static void alc_free(struct hda_codec *codec)
  2152. {
  2153. struct alc_spec *spec = codec->spec;
  2154. unsigned int i;
  2155. if (!spec)
  2156. return;
  2157. if (spec->kctl_alloc) {
  2158. for (i = 0; i < spec->num_kctl_used; i++)
  2159. kfree(spec->kctl_alloc[i].name);
  2160. kfree(spec->kctl_alloc);
  2161. }
  2162. kfree(spec);
  2163. }
  2164. /*
  2165. */
  2166. static struct hda_codec_ops alc_patch_ops = {
  2167. .build_controls = alc_build_controls,
  2168. .build_pcms = alc_build_pcms,
  2169. .init = alc_init,
  2170. .free = alc_free,
  2171. .unsol_event = alc_unsol_event,
  2172. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2173. .check_power_status = alc_check_power_status,
  2174. #endif
  2175. };
  2176. /*
  2177. * Test configuration for debugging
  2178. *
  2179. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2180. * enum controls.
  2181. */
  2182. #ifdef CONFIG_SND_DEBUG
  2183. static hda_nid_t alc880_test_dac_nids[4] = {
  2184. 0x02, 0x03, 0x04, 0x05
  2185. };
  2186. static struct hda_input_mux alc880_test_capture_source = {
  2187. .num_items = 7,
  2188. .items = {
  2189. { "In-1", 0x0 },
  2190. { "In-2", 0x1 },
  2191. { "In-3", 0x2 },
  2192. { "In-4", 0x3 },
  2193. { "CD", 0x4 },
  2194. { "Front", 0x5 },
  2195. { "Surround", 0x6 },
  2196. },
  2197. };
  2198. static struct hda_channel_mode alc880_test_modes[4] = {
  2199. { 2, NULL },
  2200. { 4, NULL },
  2201. { 6, NULL },
  2202. { 8, NULL },
  2203. };
  2204. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2205. struct snd_ctl_elem_info *uinfo)
  2206. {
  2207. static char *texts[] = {
  2208. "N/A", "Line Out", "HP Out",
  2209. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2210. };
  2211. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2212. uinfo->count = 1;
  2213. uinfo->value.enumerated.items = 8;
  2214. if (uinfo->value.enumerated.item >= 8)
  2215. uinfo->value.enumerated.item = 7;
  2216. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2217. return 0;
  2218. }
  2219. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2220. struct snd_ctl_elem_value *ucontrol)
  2221. {
  2222. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2223. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2224. unsigned int pin_ctl, item = 0;
  2225. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2226. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2227. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2228. if (pin_ctl & AC_PINCTL_HP_EN)
  2229. item = 2;
  2230. else
  2231. item = 1;
  2232. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2233. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2234. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2235. case AC_PINCTL_VREF_50: item = 4; break;
  2236. case AC_PINCTL_VREF_GRD: item = 5; break;
  2237. case AC_PINCTL_VREF_80: item = 6; break;
  2238. case AC_PINCTL_VREF_100: item = 7; break;
  2239. }
  2240. }
  2241. ucontrol->value.enumerated.item[0] = item;
  2242. return 0;
  2243. }
  2244. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2245. struct snd_ctl_elem_value *ucontrol)
  2246. {
  2247. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2248. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2249. static unsigned int ctls[] = {
  2250. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2251. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2252. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2253. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2254. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2255. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2256. };
  2257. unsigned int old_ctl, new_ctl;
  2258. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2259. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2260. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2261. if (old_ctl != new_ctl) {
  2262. int val;
  2263. snd_hda_codec_write_cache(codec, nid, 0,
  2264. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2265. new_ctl);
  2266. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2267. HDA_AMP_MUTE : 0;
  2268. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2269. HDA_AMP_MUTE, val);
  2270. return 1;
  2271. }
  2272. return 0;
  2273. }
  2274. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2275. struct snd_ctl_elem_info *uinfo)
  2276. {
  2277. static char *texts[] = {
  2278. "Front", "Surround", "CLFE", "Side"
  2279. };
  2280. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2281. uinfo->count = 1;
  2282. uinfo->value.enumerated.items = 4;
  2283. if (uinfo->value.enumerated.item >= 4)
  2284. uinfo->value.enumerated.item = 3;
  2285. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2286. return 0;
  2287. }
  2288. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2289. struct snd_ctl_elem_value *ucontrol)
  2290. {
  2291. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2292. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2293. unsigned int sel;
  2294. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2295. ucontrol->value.enumerated.item[0] = sel & 3;
  2296. return 0;
  2297. }
  2298. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2299. struct snd_ctl_elem_value *ucontrol)
  2300. {
  2301. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2302. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2303. unsigned int sel;
  2304. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2305. if (ucontrol->value.enumerated.item[0] != sel) {
  2306. sel = ucontrol->value.enumerated.item[0] & 3;
  2307. snd_hda_codec_write_cache(codec, nid, 0,
  2308. AC_VERB_SET_CONNECT_SEL, sel);
  2309. return 1;
  2310. }
  2311. return 0;
  2312. }
  2313. #define PIN_CTL_TEST(xname,nid) { \
  2314. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2315. .name = xname, \
  2316. .info = alc_test_pin_ctl_info, \
  2317. .get = alc_test_pin_ctl_get, \
  2318. .put = alc_test_pin_ctl_put, \
  2319. .private_value = nid \
  2320. }
  2321. #define PIN_SRC_TEST(xname,nid) { \
  2322. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2323. .name = xname, \
  2324. .info = alc_test_pin_src_info, \
  2325. .get = alc_test_pin_src_get, \
  2326. .put = alc_test_pin_src_put, \
  2327. .private_value = nid \
  2328. }
  2329. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2330. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2331. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2332. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2333. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2334. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2335. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2336. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2337. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2338. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2339. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2340. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2341. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2342. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2343. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2344. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2345. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2346. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2347. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2348. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2349. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2350. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2351. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2352. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2353. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2354. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2355. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2356. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2357. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2358. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2359. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2360. {
  2361. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2362. .name = "Channel Mode",
  2363. .info = alc_ch_mode_info,
  2364. .get = alc_ch_mode_get,
  2365. .put = alc_ch_mode_put,
  2366. },
  2367. { } /* end */
  2368. };
  2369. static struct hda_verb alc880_test_init_verbs[] = {
  2370. /* Unmute inputs of 0x0c - 0x0f */
  2371. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2372. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2373. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2374. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2375. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2376. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2377. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2378. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2379. /* Vol output for 0x0c-0x0f */
  2380. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2381. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2382. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2383. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2384. /* Set output pins 0x14-0x17 */
  2385. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2386. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2387. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2388. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2389. /* Unmute output pins 0x14-0x17 */
  2390. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2391. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2392. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2393. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2394. /* Set input pins 0x18-0x1c */
  2395. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2396. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2397. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2398. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2399. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2400. /* Mute input pins 0x18-0x1b */
  2401. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2402. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2403. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2404. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2405. /* ADC set up */
  2406. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2407. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2408. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2409. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2410. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2411. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2412. /* Analog input/passthru */
  2413. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2414. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2415. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2416. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2417. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2418. { }
  2419. };
  2420. #endif
  2421. /*
  2422. */
  2423. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2424. [ALC880_3ST] = "3stack",
  2425. [ALC880_TCL_S700] = "tcl",
  2426. [ALC880_3ST_DIG] = "3stack-digout",
  2427. [ALC880_CLEVO] = "clevo",
  2428. [ALC880_5ST] = "5stack",
  2429. [ALC880_5ST_DIG] = "5stack-digout",
  2430. [ALC880_W810] = "w810",
  2431. [ALC880_Z71V] = "z71v",
  2432. [ALC880_6ST] = "6stack",
  2433. [ALC880_6ST_DIG] = "6stack-digout",
  2434. [ALC880_ASUS] = "asus",
  2435. [ALC880_ASUS_W1V] = "asus-w1v",
  2436. [ALC880_ASUS_DIG] = "asus-dig",
  2437. [ALC880_ASUS_DIG2] = "asus-dig2",
  2438. [ALC880_UNIWILL_DIG] = "uniwill",
  2439. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2440. [ALC880_FUJITSU] = "fujitsu",
  2441. [ALC880_F1734] = "F1734",
  2442. [ALC880_LG] = "lg",
  2443. [ALC880_LG_LW] = "lg-lw",
  2444. #ifdef CONFIG_SND_DEBUG
  2445. [ALC880_TEST] = "test",
  2446. #endif
  2447. [ALC880_AUTO] = "auto",
  2448. };
  2449. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2450. /* Broken BIOS configuration */
  2451. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2452. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2453. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2454. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2455. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2456. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2457. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2458. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2459. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2460. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2461. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2462. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2463. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2464. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2465. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2466. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2467. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2468. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2469. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2470. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2471. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2472. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2473. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2474. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2475. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2476. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2477. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2478. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2479. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2480. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2481. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2482. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2483. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2484. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2485. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2486. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2487. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2488. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2489. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2490. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2491. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2492. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2493. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2494. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2495. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2496. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2497. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2498. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2499. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2500. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2501. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2502. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2503. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2504. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2505. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2506. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2507. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2508. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2509. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2510. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2511. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2512. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2513. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2514. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2515. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2516. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2517. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2518. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2519. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2520. {}
  2521. };
  2522. /*
  2523. * ALC880 codec presets
  2524. */
  2525. static struct alc_config_preset alc880_presets[] = {
  2526. [ALC880_3ST] = {
  2527. .mixers = { alc880_three_stack_mixer },
  2528. .init_verbs = { alc880_volume_init_verbs,
  2529. alc880_pin_3stack_init_verbs },
  2530. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2531. .dac_nids = alc880_dac_nids,
  2532. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2533. .channel_mode = alc880_threestack_modes,
  2534. .need_dac_fix = 1,
  2535. .input_mux = &alc880_capture_source,
  2536. },
  2537. [ALC880_3ST_DIG] = {
  2538. .mixers = { alc880_three_stack_mixer },
  2539. .init_verbs = { alc880_volume_init_verbs,
  2540. alc880_pin_3stack_init_verbs },
  2541. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2542. .dac_nids = alc880_dac_nids,
  2543. .dig_out_nid = ALC880_DIGOUT_NID,
  2544. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2545. .channel_mode = alc880_threestack_modes,
  2546. .need_dac_fix = 1,
  2547. .input_mux = &alc880_capture_source,
  2548. },
  2549. [ALC880_TCL_S700] = {
  2550. .mixers = { alc880_tcl_s700_mixer },
  2551. .init_verbs = { alc880_volume_init_verbs,
  2552. alc880_pin_tcl_S700_init_verbs,
  2553. alc880_gpio2_init_verbs },
  2554. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2555. .dac_nids = alc880_dac_nids,
  2556. .hp_nid = 0x03,
  2557. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2558. .channel_mode = alc880_2_jack_modes,
  2559. .input_mux = &alc880_capture_source,
  2560. },
  2561. [ALC880_5ST] = {
  2562. .mixers = { alc880_three_stack_mixer,
  2563. alc880_five_stack_mixer},
  2564. .init_verbs = { alc880_volume_init_verbs,
  2565. alc880_pin_5stack_init_verbs },
  2566. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2567. .dac_nids = alc880_dac_nids,
  2568. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2569. .channel_mode = alc880_fivestack_modes,
  2570. .input_mux = &alc880_capture_source,
  2571. },
  2572. [ALC880_5ST_DIG] = {
  2573. .mixers = { alc880_three_stack_mixer,
  2574. alc880_five_stack_mixer },
  2575. .init_verbs = { alc880_volume_init_verbs,
  2576. alc880_pin_5stack_init_verbs },
  2577. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2578. .dac_nids = alc880_dac_nids,
  2579. .dig_out_nid = ALC880_DIGOUT_NID,
  2580. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2581. .channel_mode = alc880_fivestack_modes,
  2582. .input_mux = &alc880_capture_source,
  2583. },
  2584. [ALC880_6ST] = {
  2585. .mixers = { alc880_six_stack_mixer },
  2586. .init_verbs = { alc880_volume_init_verbs,
  2587. alc880_pin_6stack_init_verbs },
  2588. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2589. .dac_nids = alc880_6st_dac_nids,
  2590. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2591. .channel_mode = alc880_sixstack_modes,
  2592. .input_mux = &alc880_6stack_capture_source,
  2593. },
  2594. [ALC880_6ST_DIG] = {
  2595. .mixers = { alc880_six_stack_mixer },
  2596. .init_verbs = { alc880_volume_init_verbs,
  2597. alc880_pin_6stack_init_verbs },
  2598. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2599. .dac_nids = alc880_6st_dac_nids,
  2600. .dig_out_nid = ALC880_DIGOUT_NID,
  2601. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2602. .channel_mode = alc880_sixstack_modes,
  2603. .input_mux = &alc880_6stack_capture_source,
  2604. },
  2605. [ALC880_W810] = {
  2606. .mixers = { alc880_w810_base_mixer },
  2607. .init_verbs = { alc880_volume_init_verbs,
  2608. alc880_pin_w810_init_verbs,
  2609. alc880_gpio2_init_verbs },
  2610. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2611. .dac_nids = alc880_w810_dac_nids,
  2612. .dig_out_nid = ALC880_DIGOUT_NID,
  2613. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2614. .channel_mode = alc880_w810_modes,
  2615. .input_mux = &alc880_capture_source,
  2616. },
  2617. [ALC880_Z71V] = {
  2618. .mixers = { alc880_z71v_mixer },
  2619. .init_verbs = { alc880_volume_init_verbs,
  2620. alc880_pin_z71v_init_verbs },
  2621. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2622. .dac_nids = alc880_z71v_dac_nids,
  2623. .dig_out_nid = ALC880_DIGOUT_NID,
  2624. .hp_nid = 0x03,
  2625. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2626. .channel_mode = alc880_2_jack_modes,
  2627. .input_mux = &alc880_capture_source,
  2628. },
  2629. [ALC880_F1734] = {
  2630. .mixers = { alc880_f1734_mixer },
  2631. .init_verbs = { alc880_volume_init_verbs,
  2632. alc880_pin_f1734_init_verbs },
  2633. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2634. .dac_nids = alc880_f1734_dac_nids,
  2635. .hp_nid = 0x02,
  2636. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2637. .channel_mode = alc880_2_jack_modes,
  2638. .input_mux = &alc880_capture_source,
  2639. },
  2640. [ALC880_ASUS] = {
  2641. .mixers = { alc880_asus_mixer },
  2642. .init_verbs = { alc880_volume_init_verbs,
  2643. alc880_pin_asus_init_verbs,
  2644. alc880_gpio1_init_verbs },
  2645. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2646. .dac_nids = alc880_asus_dac_nids,
  2647. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2648. .channel_mode = alc880_asus_modes,
  2649. .need_dac_fix = 1,
  2650. .input_mux = &alc880_capture_source,
  2651. },
  2652. [ALC880_ASUS_DIG] = {
  2653. .mixers = { alc880_asus_mixer },
  2654. .init_verbs = { alc880_volume_init_verbs,
  2655. alc880_pin_asus_init_verbs,
  2656. alc880_gpio1_init_verbs },
  2657. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2658. .dac_nids = alc880_asus_dac_nids,
  2659. .dig_out_nid = ALC880_DIGOUT_NID,
  2660. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2661. .channel_mode = alc880_asus_modes,
  2662. .need_dac_fix = 1,
  2663. .input_mux = &alc880_capture_source,
  2664. },
  2665. [ALC880_ASUS_DIG2] = {
  2666. .mixers = { alc880_asus_mixer },
  2667. .init_verbs = { alc880_volume_init_verbs,
  2668. alc880_pin_asus_init_verbs,
  2669. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2670. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2671. .dac_nids = alc880_asus_dac_nids,
  2672. .dig_out_nid = ALC880_DIGOUT_NID,
  2673. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2674. .channel_mode = alc880_asus_modes,
  2675. .need_dac_fix = 1,
  2676. .input_mux = &alc880_capture_source,
  2677. },
  2678. [ALC880_ASUS_W1V] = {
  2679. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2680. .init_verbs = { alc880_volume_init_verbs,
  2681. alc880_pin_asus_init_verbs,
  2682. alc880_gpio1_init_verbs },
  2683. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2684. .dac_nids = alc880_asus_dac_nids,
  2685. .dig_out_nid = ALC880_DIGOUT_NID,
  2686. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2687. .channel_mode = alc880_asus_modes,
  2688. .need_dac_fix = 1,
  2689. .input_mux = &alc880_capture_source,
  2690. },
  2691. [ALC880_UNIWILL_DIG] = {
  2692. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2693. .init_verbs = { alc880_volume_init_verbs,
  2694. alc880_pin_asus_init_verbs },
  2695. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2696. .dac_nids = alc880_asus_dac_nids,
  2697. .dig_out_nid = ALC880_DIGOUT_NID,
  2698. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2699. .channel_mode = alc880_asus_modes,
  2700. .need_dac_fix = 1,
  2701. .input_mux = &alc880_capture_source,
  2702. },
  2703. [ALC880_UNIWILL] = {
  2704. .mixers = { alc880_uniwill_mixer },
  2705. .init_verbs = { alc880_volume_init_verbs,
  2706. alc880_uniwill_init_verbs },
  2707. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2708. .dac_nids = alc880_asus_dac_nids,
  2709. .dig_out_nid = ALC880_DIGOUT_NID,
  2710. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2711. .channel_mode = alc880_threestack_modes,
  2712. .need_dac_fix = 1,
  2713. .input_mux = &alc880_capture_source,
  2714. .unsol_event = alc880_uniwill_unsol_event,
  2715. .init_hook = alc880_uniwill_automute,
  2716. },
  2717. [ALC880_UNIWILL_P53] = {
  2718. .mixers = { alc880_uniwill_p53_mixer },
  2719. .init_verbs = { alc880_volume_init_verbs,
  2720. alc880_uniwill_p53_init_verbs },
  2721. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2722. .dac_nids = alc880_asus_dac_nids,
  2723. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2724. .channel_mode = alc880_threestack_modes,
  2725. .input_mux = &alc880_capture_source,
  2726. .unsol_event = alc880_uniwill_p53_unsol_event,
  2727. .init_hook = alc880_uniwill_p53_hp_automute,
  2728. },
  2729. [ALC880_FUJITSU] = {
  2730. .mixers = { alc880_fujitsu_mixer,
  2731. alc880_pcbeep_mixer, },
  2732. .init_verbs = { alc880_volume_init_verbs,
  2733. alc880_uniwill_p53_init_verbs,
  2734. alc880_beep_init_verbs },
  2735. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2736. .dac_nids = alc880_dac_nids,
  2737. .dig_out_nid = ALC880_DIGOUT_NID,
  2738. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2739. .channel_mode = alc880_2_jack_modes,
  2740. .input_mux = &alc880_capture_source,
  2741. .unsol_event = alc880_uniwill_p53_unsol_event,
  2742. .init_hook = alc880_uniwill_p53_hp_automute,
  2743. },
  2744. [ALC880_CLEVO] = {
  2745. .mixers = { alc880_three_stack_mixer },
  2746. .init_verbs = { alc880_volume_init_verbs,
  2747. alc880_pin_clevo_init_verbs },
  2748. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2749. .dac_nids = alc880_dac_nids,
  2750. .hp_nid = 0x03,
  2751. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2752. .channel_mode = alc880_threestack_modes,
  2753. .need_dac_fix = 1,
  2754. .input_mux = &alc880_capture_source,
  2755. },
  2756. [ALC880_LG] = {
  2757. .mixers = { alc880_lg_mixer },
  2758. .init_verbs = { alc880_volume_init_verbs,
  2759. alc880_lg_init_verbs },
  2760. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2761. .dac_nids = alc880_lg_dac_nids,
  2762. .dig_out_nid = ALC880_DIGOUT_NID,
  2763. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2764. .channel_mode = alc880_lg_ch_modes,
  2765. .need_dac_fix = 1,
  2766. .input_mux = &alc880_lg_capture_source,
  2767. .unsol_event = alc880_lg_unsol_event,
  2768. .init_hook = alc880_lg_automute,
  2769. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2770. .loopbacks = alc880_lg_loopbacks,
  2771. #endif
  2772. },
  2773. [ALC880_LG_LW] = {
  2774. .mixers = { alc880_lg_lw_mixer },
  2775. .init_verbs = { alc880_volume_init_verbs,
  2776. alc880_lg_lw_init_verbs },
  2777. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2778. .dac_nids = alc880_dac_nids,
  2779. .dig_out_nid = ALC880_DIGOUT_NID,
  2780. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2781. .channel_mode = alc880_lg_lw_modes,
  2782. .input_mux = &alc880_lg_lw_capture_source,
  2783. .unsol_event = alc880_lg_lw_unsol_event,
  2784. .init_hook = alc880_lg_lw_automute,
  2785. },
  2786. #ifdef CONFIG_SND_DEBUG
  2787. [ALC880_TEST] = {
  2788. .mixers = { alc880_test_mixer },
  2789. .init_verbs = { alc880_test_init_verbs },
  2790. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2791. .dac_nids = alc880_test_dac_nids,
  2792. .dig_out_nid = ALC880_DIGOUT_NID,
  2793. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2794. .channel_mode = alc880_test_modes,
  2795. .input_mux = &alc880_test_capture_source,
  2796. },
  2797. #endif
  2798. };
  2799. /*
  2800. * Automatic parse of I/O pins from the BIOS configuration
  2801. */
  2802. #define NUM_CONTROL_ALLOC 32
  2803. #define NUM_VERB_ALLOC 32
  2804. enum {
  2805. ALC_CTL_WIDGET_VOL,
  2806. ALC_CTL_WIDGET_MUTE,
  2807. ALC_CTL_BIND_MUTE,
  2808. };
  2809. static struct snd_kcontrol_new alc880_control_templates[] = {
  2810. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2811. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2812. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2813. };
  2814. /* add dynamic controls */
  2815. static int add_control(struct alc_spec *spec, int type, const char *name,
  2816. unsigned long val)
  2817. {
  2818. struct snd_kcontrol_new *knew;
  2819. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2820. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2821. /* array + terminator */
  2822. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2823. if (!knew)
  2824. return -ENOMEM;
  2825. if (spec->kctl_alloc) {
  2826. memcpy(knew, spec->kctl_alloc,
  2827. sizeof(*knew) * spec->num_kctl_alloc);
  2828. kfree(spec->kctl_alloc);
  2829. }
  2830. spec->kctl_alloc = knew;
  2831. spec->num_kctl_alloc = num;
  2832. }
  2833. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2834. *knew = alc880_control_templates[type];
  2835. knew->name = kstrdup(name, GFP_KERNEL);
  2836. if (!knew->name)
  2837. return -ENOMEM;
  2838. knew->private_value = val;
  2839. spec->num_kctl_used++;
  2840. return 0;
  2841. }
  2842. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2843. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2844. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2845. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2846. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2847. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2848. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2849. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2850. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2851. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2852. #define ALC880_PIN_CD_NID 0x1c
  2853. /* fill in the dac_nids table from the parsed pin configuration */
  2854. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2855. const struct auto_pin_cfg *cfg)
  2856. {
  2857. hda_nid_t nid;
  2858. int assigned[4];
  2859. int i, j;
  2860. memset(assigned, 0, sizeof(assigned));
  2861. spec->multiout.dac_nids = spec->private_dac_nids;
  2862. /* check the pins hardwired to audio widget */
  2863. for (i = 0; i < cfg->line_outs; i++) {
  2864. nid = cfg->line_out_pins[i];
  2865. if (alc880_is_fixed_pin(nid)) {
  2866. int idx = alc880_fixed_pin_idx(nid);
  2867. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2868. assigned[idx] = 1;
  2869. }
  2870. }
  2871. /* left pins can be connect to any audio widget */
  2872. for (i = 0; i < cfg->line_outs; i++) {
  2873. nid = cfg->line_out_pins[i];
  2874. if (alc880_is_fixed_pin(nid))
  2875. continue;
  2876. /* search for an empty channel */
  2877. for (j = 0; j < cfg->line_outs; j++) {
  2878. if (!assigned[j]) {
  2879. spec->multiout.dac_nids[i] =
  2880. alc880_idx_to_dac(j);
  2881. assigned[j] = 1;
  2882. break;
  2883. }
  2884. }
  2885. }
  2886. spec->multiout.num_dacs = cfg->line_outs;
  2887. return 0;
  2888. }
  2889. /* add playback controls from the parsed DAC table */
  2890. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2891. const struct auto_pin_cfg *cfg)
  2892. {
  2893. char name[32];
  2894. static const char *chname[4] = {
  2895. "Front", "Surround", NULL /*CLFE*/, "Side"
  2896. };
  2897. hda_nid_t nid;
  2898. int i, err;
  2899. for (i = 0; i < cfg->line_outs; i++) {
  2900. if (!spec->multiout.dac_nids[i])
  2901. continue;
  2902. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2903. if (i == 2) {
  2904. /* Center/LFE */
  2905. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2906. "Center Playback Volume",
  2907. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2908. HDA_OUTPUT));
  2909. if (err < 0)
  2910. return err;
  2911. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2912. "LFE Playback Volume",
  2913. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2914. HDA_OUTPUT));
  2915. if (err < 0)
  2916. return err;
  2917. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2918. "Center Playback Switch",
  2919. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2920. HDA_INPUT));
  2921. if (err < 0)
  2922. return err;
  2923. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2924. "LFE Playback Switch",
  2925. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2926. HDA_INPUT));
  2927. if (err < 0)
  2928. return err;
  2929. } else {
  2930. sprintf(name, "%s Playback Volume", chname[i]);
  2931. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2932. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2933. HDA_OUTPUT));
  2934. if (err < 0)
  2935. return err;
  2936. sprintf(name, "%s Playback Switch", chname[i]);
  2937. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2938. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2939. HDA_INPUT));
  2940. if (err < 0)
  2941. return err;
  2942. }
  2943. }
  2944. return 0;
  2945. }
  2946. /* add playback controls for speaker and HP outputs */
  2947. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2948. const char *pfx)
  2949. {
  2950. hda_nid_t nid;
  2951. int err;
  2952. char name[32];
  2953. if (!pin)
  2954. return 0;
  2955. if (alc880_is_fixed_pin(pin)) {
  2956. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2957. /* specify the DAC as the extra output */
  2958. if (!spec->multiout.hp_nid)
  2959. spec->multiout.hp_nid = nid;
  2960. else
  2961. spec->multiout.extra_out_nid[0] = nid;
  2962. /* control HP volume/switch on the output mixer amp */
  2963. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2964. sprintf(name, "%s Playback Volume", pfx);
  2965. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2966. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2967. if (err < 0)
  2968. return err;
  2969. sprintf(name, "%s Playback Switch", pfx);
  2970. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2971. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2972. if (err < 0)
  2973. return err;
  2974. } else if (alc880_is_multi_pin(pin)) {
  2975. /* set manual connection */
  2976. /* we have only a switch on HP-out PIN */
  2977. sprintf(name, "%s Playback Switch", pfx);
  2978. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2979. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2980. if (err < 0)
  2981. return err;
  2982. }
  2983. return 0;
  2984. }
  2985. /* create input playback/capture controls for the given pin */
  2986. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2987. const char *ctlname,
  2988. int idx, hda_nid_t mix_nid)
  2989. {
  2990. char name[32];
  2991. int err;
  2992. sprintf(name, "%s Playback Volume", ctlname);
  2993. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2994. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2995. if (err < 0)
  2996. return err;
  2997. sprintf(name, "%s Playback Switch", ctlname);
  2998. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2999. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  3000. if (err < 0)
  3001. return err;
  3002. return 0;
  3003. }
  3004. /* create playback/capture controls for input pins */
  3005. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  3006. const struct auto_pin_cfg *cfg)
  3007. {
  3008. struct hda_input_mux *imux = &spec->private_imux;
  3009. int i, err, idx;
  3010. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3011. if (alc880_is_input_pin(cfg->input_pins[i])) {
  3012. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  3013. err = new_analog_input(spec, cfg->input_pins[i],
  3014. auto_pin_cfg_labels[i],
  3015. idx, 0x0b);
  3016. if (err < 0)
  3017. return err;
  3018. imux->items[imux->num_items].label =
  3019. auto_pin_cfg_labels[i];
  3020. imux->items[imux->num_items].index =
  3021. alc880_input_pin_idx(cfg->input_pins[i]);
  3022. imux->num_items++;
  3023. }
  3024. }
  3025. return 0;
  3026. }
  3027. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  3028. hda_nid_t nid, int pin_type,
  3029. int dac_idx)
  3030. {
  3031. /* set as output */
  3032. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3033. pin_type);
  3034. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3035. AMP_OUT_UNMUTE);
  3036. /* need the manual connection? */
  3037. if (alc880_is_multi_pin(nid)) {
  3038. struct alc_spec *spec = codec->spec;
  3039. int idx = alc880_multi_pin_idx(nid);
  3040. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  3041. AC_VERB_SET_CONNECT_SEL,
  3042. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  3043. }
  3044. }
  3045. static int get_pin_type(int line_out_type)
  3046. {
  3047. if (line_out_type == AUTO_PIN_HP_OUT)
  3048. return PIN_HP;
  3049. else
  3050. return PIN_OUT;
  3051. }
  3052. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  3053. {
  3054. struct alc_spec *spec = codec->spec;
  3055. int i;
  3056. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  3057. for (i = 0; i < spec->autocfg.line_outs; i++) {
  3058. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3059. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3060. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  3061. }
  3062. }
  3063. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  3064. {
  3065. struct alc_spec *spec = codec->spec;
  3066. hda_nid_t pin;
  3067. pin = spec->autocfg.speaker_pins[0];
  3068. if (pin) /* connect to front */
  3069. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  3070. pin = spec->autocfg.hp_pins[0];
  3071. if (pin) /* connect to front */
  3072. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  3073. }
  3074. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  3075. {
  3076. struct alc_spec *spec = codec->spec;
  3077. int i;
  3078. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3079. hda_nid_t nid = spec->autocfg.input_pins[i];
  3080. if (alc880_is_input_pin(nid)) {
  3081. snd_hda_codec_write(codec, nid, 0,
  3082. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3083. i <= AUTO_PIN_FRONT_MIC ?
  3084. PIN_VREF80 : PIN_IN);
  3085. if (nid != ALC880_PIN_CD_NID)
  3086. snd_hda_codec_write(codec, nid, 0,
  3087. AC_VERB_SET_AMP_GAIN_MUTE,
  3088. AMP_OUT_MUTE);
  3089. }
  3090. }
  3091. }
  3092. /* parse the BIOS configuration and set up the alc_spec */
  3093. /* return 1 if successful, 0 if the proper config is not found,
  3094. * or a negative error code
  3095. */
  3096. static int alc880_parse_auto_config(struct hda_codec *codec)
  3097. {
  3098. struct alc_spec *spec = codec->spec;
  3099. int err;
  3100. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  3101. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3102. alc880_ignore);
  3103. if (err < 0)
  3104. return err;
  3105. if (!spec->autocfg.line_outs)
  3106. return 0; /* can't find valid BIOS pin config */
  3107. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  3108. if (err < 0)
  3109. return err;
  3110. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  3111. if (err < 0)
  3112. return err;
  3113. err = alc880_auto_create_extra_out(spec,
  3114. spec->autocfg.speaker_pins[0],
  3115. "Speaker");
  3116. if (err < 0)
  3117. return err;
  3118. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  3119. "Headphone");
  3120. if (err < 0)
  3121. return err;
  3122. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  3123. if (err < 0)
  3124. return err;
  3125. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  3126. if (spec->autocfg.dig_out_pin)
  3127. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  3128. if (spec->autocfg.dig_in_pin)
  3129. spec->dig_in_nid = ALC880_DIGIN_NID;
  3130. if (spec->kctl_alloc)
  3131. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3132. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  3133. spec->num_mux_defs = 1;
  3134. spec->input_mux = &spec->private_imux;
  3135. return 1;
  3136. }
  3137. /* additional initialization for auto-configuration model */
  3138. static void alc880_auto_init(struct hda_codec *codec)
  3139. {
  3140. alc880_auto_init_multi_out(codec);
  3141. alc880_auto_init_extra_out(codec);
  3142. alc880_auto_init_analog_input(codec);
  3143. }
  3144. /*
  3145. * OK, here we have finally the patch for ALC880
  3146. */
  3147. static int patch_alc880(struct hda_codec *codec)
  3148. {
  3149. struct alc_spec *spec;
  3150. int board_config;
  3151. int err;
  3152. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3153. if (spec == NULL)
  3154. return -ENOMEM;
  3155. codec->spec = spec;
  3156. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3157. alc880_models,
  3158. alc880_cfg_tbl);
  3159. if (board_config < 0) {
  3160. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3161. "trying auto-probe from BIOS...\n");
  3162. board_config = ALC880_AUTO;
  3163. }
  3164. if (board_config == ALC880_AUTO) {
  3165. /* automatic parse from the BIOS config */
  3166. err = alc880_parse_auto_config(codec);
  3167. if (err < 0) {
  3168. alc_free(codec);
  3169. return err;
  3170. } else if (!err) {
  3171. printk(KERN_INFO
  3172. "hda_codec: Cannot set up configuration "
  3173. "from BIOS. Using 3-stack mode...\n");
  3174. board_config = ALC880_3ST;
  3175. }
  3176. }
  3177. if (board_config != ALC880_AUTO)
  3178. setup_preset(spec, &alc880_presets[board_config]);
  3179. spec->stream_name_analog = "ALC880 Analog";
  3180. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3181. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3182. spec->stream_name_digital = "ALC880 Digital";
  3183. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3184. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3185. if (!spec->adc_nids && spec->input_mux) {
  3186. /* check whether NID 0x07 is valid */
  3187. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3188. /* get type */
  3189. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3190. if (wcap != AC_WID_AUD_IN) {
  3191. spec->adc_nids = alc880_adc_nids_alt;
  3192. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3193. spec->mixers[spec->num_mixers] =
  3194. alc880_capture_alt_mixer;
  3195. spec->num_mixers++;
  3196. } else {
  3197. spec->adc_nids = alc880_adc_nids;
  3198. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3199. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3200. spec->num_mixers++;
  3201. }
  3202. }
  3203. codec->patch_ops = alc_patch_ops;
  3204. if (board_config == ALC880_AUTO)
  3205. spec->init_hook = alc880_auto_init;
  3206. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3207. if (!spec->loopback.amplist)
  3208. spec->loopback.amplist = alc880_loopbacks;
  3209. #endif
  3210. return 0;
  3211. }
  3212. /*
  3213. * ALC260 support
  3214. */
  3215. static hda_nid_t alc260_dac_nids[1] = {
  3216. /* front */
  3217. 0x02,
  3218. };
  3219. static hda_nid_t alc260_adc_nids[1] = {
  3220. /* ADC0 */
  3221. 0x04,
  3222. };
  3223. static hda_nid_t alc260_adc_nids_alt[1] = {
  3224. /* ADC1 */
  3225. 0x05,
  3226. };
  3227. static hda_nid_t alc260_hp_adc_nids[2] = {
  3228. /* ADC1, 0 */
  3229. 0x05, 0x04
  3230. };
  3231. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3232. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3233. */
  3234. static hda_nid_t alc260_dual_adc_nids[2] = {
  3235. /* ADC0, ADC1 */
  3236. 0x04, 0x05
  3237. };
  3238. #define ALC260_DIGOUT_NID 0x03
  3239. #define ALC260_DIGIN_NID 0x06
  3240. static struct hda_input_mux alc260_capture_source = {
  3241. .num_items = 4,
  3242. .items = {
  3243. { "Mic", 0x0 },
  3244. { "Front Mic", 0x1 },
  3245. { "Line", 0x2 },
  3246. { "CD", 0x4 },
  3247. },
  3248. };
  3249. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3250. * headphone jack and the internal CD lines since these are the only pins at
  3251. * which audio can appear. For flexibility, also allow the option of
  3252. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3253. * connection to the mixer output).
  3254. */
  3255. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3256. {
  3257. .num_items = 3,
  3258. .items = {
  3259. { "Mic/Line", 0x0 },
  3260. { "CD", 0x4 },
  3261. { "Headphone", 0x2 },
  3262. },
  3263. },
  3264. {
  3265. .num_items = 4,
  3266. .items = {
  3267. { "Mic/Line", 0x0 },
  3268. { "CD", 0x4 },
  3269. { "Headphone", 0x2 },
  3270. { "Mixer", 0x5 },
  3271. },
  3272. },
  3273. };
  3274. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3275. * the Fujitsu S702x, but jacks are marked differently.
  3276. */
  3277. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3278. {
  3279. .num_items = 4,
  3280. .items = {
  3281. { "Mic", 0x0 },
  3282. { "Line", 0x2 },
  3283. { "CD", 0x4 },
  3284. { "Headphone", 0x5 },
  3285. },
  3286. },
  3287. {
  3288. .num_items = 5,
  3289. .items = {
  3290. { "Mic", 0x0 },
  3291. { "Line", 0x2 },
  3292. { "CD", 0x4 },
  3293. { "Headphone", 0x6 },
  3294. { "Mixer", 0x5 },
  3295. },
  3296. },
  3297. };
  3298. /*
  3299. * This is just place-holder, so there's something for alc_build_pcms to look
  3300. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3301. * element which allows changing the channel mode, so the verb list is
  3302. * never used.
  3303. */
  3304. static struct hda_channel_mode alc260_modes[1] = {
  3305. { 2, NULL },
  3306. };
  3307. /* Mixer combinations
  3308. *
  3309. * basic: base_output + input + pc_beep + capture
  3310. * HP: base_output + input + capture_alt
  3311. * HP_3013: hp_3013 + input + capture
  3312. * fujitsu: fujitsu + capture
  3313. * acer: acer + capture
  3314. */
  3315. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3316. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3317. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3318. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3319. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3320. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3321. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3322. { } /* end */
  3323. };
  3324. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3325. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3326. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3327. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3328. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3329. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3330. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3331. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3332. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3333. { } /* end */
  3334. };
  3335. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3336. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3337. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3338. { } /* end */
  3339. };
  3340. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3341. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3342. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3343. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3344. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3345. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3346. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3347. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3348. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3349. { } /* end */
  3350. };
  3351. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3352. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3353. */
  3354. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3355. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3356. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3357. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3358. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3359. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3360. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3361. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3362. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3363. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3364. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3365. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3366. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3367. { } /* end */
  3368. };
  3369. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3370. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3371. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3372. * datasheet doesn't mention this restriction. At this stage it's not clear
  3373. * whether this behaviour is intentional or is a hardware bug in chip
  3374. * revisions available in early 2006. Therefore for now allow the
  3375. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3376. * that the lack of mic bias for this NID is intentional we could change the
  3377. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3378. *
  3379. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3380. * don't appear to make the mic bias available from the "line" jack, even
  3381. * though the NID used for this jack (0x14) can supply it. The theory is
  3382. * that perhaps Acer have included blocking capacitors between the ALC260
  3383. * and the output jack. If this turns out to be the case for all such
  3384. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3385. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3386. *
  3387. * The C20x Tablet series have a mono internal speaker which is controlled
  3388. * via the chip's Mono sum widget and pin complex, so include the necessary
  3389. * controls for such models. On models without a "mono speaker" the control
  3390. * won't do anything.
  3391. */
  3392. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3393. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3394. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3395. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3396. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3397. HDA_OUTPUT),
  3398. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3399. HDA_INPUT),
  3400. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3401. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3402. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3403. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3404. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3405. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3406. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3407. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3408. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3409. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3410. { } /* end */
  3411. };
  3412. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3413. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3414. */
  3415. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3416. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3417. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3418. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3419. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3420. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3421. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3422. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3423. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3424. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3425. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3426. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3427. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3428. { } /* end */
  3429. };
  3430. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3431. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3432. */
  3433. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3434. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3435. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3436. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3437. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3438. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3439. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3440. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3441. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3442. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3443. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3444. { } /* end */
  3445. };
  3446. /* capture mixer elements */
  3447. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3448. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3449. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3450. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3451. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3452. {
  3453. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3454. /* The multiple "Capture Source" controls confuse alsamixer
  3455. * So call somewhat different..
  3456. * FIXME: the controls appear in the "playback" view!
  3457. */
  3458. /* .name = "Capture Source", */
  3459. .name = "Input Source",
  3460. .count = 2,
  3461. .info = alc_mux_enum_info,
  3462. .get = alc_mux_enum_get,
  3463. .put = alc_mux_enum_put,
  3464. },
  3465. { } /* end */
  3466. };
  3467. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3468. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3469. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3470. {
  3471. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3472. /* The multiple "Capture Source" controls confuse alsamixer
  3473. * So call somewhat different..
  3474. * FIXME: the controls appear in the "playback" view!
  3475. */
  3476. /* .name = "Capture Source", */
  3477. .name = "Input Source",
  3478. .count = 1,
  3479. .info = alc_mux_enum_info,
  3480. .get = alc_mux_enum_get,
  3481. .put = alc_mux_enum_put,
  3482. },
  3483. { } /* end */
  3484. };
  3485. /*
  3486. * initialization verbs
  3487. */
  3488. static struct hda_verb alc260_init_verbs[] = {
  3489. /* Line In pin widget for input */
  3490. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3491. /* CD pin widget for input */
  3492. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3493. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3494. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3495. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3496. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3497. /* LINE-2 is used for line-out in rear */
  3498. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3499. /* select line-out */
  3500. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3501. /* LINE-OUT pin */
  3502. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3503. /* enable HP */
  3504. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3505. /* enable Mono */
  3506. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3507. /* mute capture amp left and right */
  3508. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3509. /* set connection select to line in (default select for this ADC) */
  3510. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3511. /* mute capture amp left and right */
  3512. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3513. /* set connection select to line in (default select for this ADC) */
  3514. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3515. /* set vol=0 Line-Out mixer amp left and right */
  3516. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3517. /* unmute pin widget amp left and right (no gain on this amp) */
  3518. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3519. /* set vol=0 HP mixer amp left and right */
  3520. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3521. /* unmute pin widget amp left and right (no gain on this amp) */
  3522. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3523. /* set vol=0 Mono mixer amp left and right */
  3524. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3525. /* unmute pin widget amp left and right (no gain on this amp) */
  3526. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3527. /* unmute LINE-2 out pin */
  3528. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3529. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3530. * Line In 2 = 0x03
  3531. */
  3532. /* mute analog inputs */
  3533. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3534. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3535. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3536. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3537. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3538. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3539. /* mute Front out path */
  3540. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3541. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3542. /* mute Headphone out path */
  3543. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3544. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3545. /* mute Mono out path */
  3546. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3547. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3548. { }
  3549. };
  3550. #if 0 /* should be identical with alc260_init_verbs? */
  3551. static struct hda_verb alc260_hp_init_verbs[] = {
  3552. /* Headphone and output */
  3553. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3554. /* mono output */
  3555. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3556. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3557. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3558. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3559. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3560. /* Line In pin widget for input */
  3561. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3562. /* Line-2 pin widget for output */
  3563. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3564. /* CD pin widget for input */
  3565. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3566. /* unmute amp left and right */
  3567. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3568. /* set connection select to line in (default select for this ADC) */
  3569. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3570. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3571. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3572. /* mute pin widget amp left and right (no gain on this amp) */
  3573. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3574. /* unmute HP mixer amp left and right (volume = 0) */
  3575. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3576. /* mute pin widget amp left and right (no gain on this amp) */
  3577. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3578. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3579. * Line In 2 = 0x03
  3580. */
  3581. /* mute analog inputs */
  3582. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3583. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3584. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3585. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3586. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3587. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3588. /* Unmute Front out path */
  3589. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3590. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3591. /* Unmute Headphone out path */
  3592. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3593. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3594. /* Unmute Mono out path */
  3595. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3596. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3597. { }
  3598. };
  3599. #endif
  3600. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3601. /* Line out and output */
  3602. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3603. /* mono output */
  3604. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3605. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3606. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3607. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3608. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3609. /* Line In pin widget for input */
  3610. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3611. /* Headphone pin widget for output */
  3612. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3613. /* CD pin widget for input */
  3614. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3615. /* unmute amp left and right */
  3616. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3617. /* set connection select to line in (default select for this ADC) */
  3618. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3619. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3620. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3621. /* mute pin widget amp left and right (no gain on this amp) */
  3622. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3623. /* unmute HP mixer amp left and right (volume = 0) */
  3624. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3625. /* mute pin widget amp left and right (no gain on this amp) */
  3626. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3627. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3628. * Line In 2 = 0x03
  3629. */
  3630. /* mute analog inputs */
  3631. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3632. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3633. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3634. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3635. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3636. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3637. /* Unmute Front out path */
  3638. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3639. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3640. /* Unmute Headphone out path */
  3641. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3642. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3643. /* Unmute Mono out path */
  3644. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3645. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3646. { }
  3647. };
  3648. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3649. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3650. * audio = 0x16, internal speaker = 0x10.
  3651. */
  3652. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3653. /* Disable all GPIOs */
  3654. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3655. /* Internal speaker is connected to headphone pin */
  3656. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3657. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3658. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3659. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3660. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3661. /* Ensure all other unused pins are disabled and muted. */
  3662. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3663. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3664. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3665. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3666. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3667. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3668. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3669. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3670. /* Disable digital (SPDIF) pins */
  3671. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3672. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3673. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3674. * when acting as an output.
  3675. */
  3676. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3677. /* Start with output sum widgets muted and their output gains at min */
  3678. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3679. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3680. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3681. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3682. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3683. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3684. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3685. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3686. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3687. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3688. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3689. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3690. * If the pin mode is changed by the user the pin mode control will
  3691. * take care of enabling the pin's input/output buffers as needed.
  3692. * Therefore there's no need to enable the input buffer at this
  3693. * stage.
  3694. */
  3695. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3696. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3697. * mixer ctrl)
  3698. */
  3699. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3700. /* Mute capture amp left and right */
  3701. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3702. /* Set ADC connection select to match default mixer setting - line
  3703. * in (on mic1 pin)
  3704. */
  3705. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3706. /* Do the same for the second ADC: mute capture input amp and
  3707. * set ADC connection to line in (on mic1 pin)
  3708. */
  3709. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3710. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3711. /* Mute all inputs to mixer widget (even unconnected ones) */
  3712. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3713. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3714. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3715. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3716. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3717. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3718. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3719. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3720. { }
  3721. };
  3722. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3723. * similar laptops (adapted from Fujitsu init verbs).
  3724. */
  3725. static struct hda_verb alc260_acer_init_verbs[] = {
  3726. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3727. * the headphone jack. Turn this on and rely on the standard mute
  3728. * methods whenever the user wants to turn these outputs off.
  3729. */
  3730. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3731. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3732. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3733. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3734. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3735. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3736. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3737. /* Line In jack is connected to Line1 pin */
  3738. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3739. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3740. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3741. /* Ensure all other unused pins are disabled and muted. */
  3742. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3743. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3744. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3745. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3746. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3747. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3748. /* Disable digital (SPDIF) pins */
  3749. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3750. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3751. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3752. * bus when acting as outputs.
  3753. */
  3754. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3755. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3756. /* Start with output sum widgets muted and their output gains at min */
  3757. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3758. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3759. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3760. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3761. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3762. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3763. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3764. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3765. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3766. /* Unmute Line-out pin widget amp left and right
  3767. * (no equiv mixer ctrl)
  3768. */
  3769. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3770. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3771. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3772. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3773. * inputs. If the pin mode is changed by the user the pin mode control
  3774. * will take care of enabling the pin's input/output buffers as needed.
  3775. * Therefore there's no need to enable the input buffer at this
  3776. * stage.
  3777. */
  3778. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3779. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3780. /* Mute capture amp left and right */
  3781. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3782. /* Set ADC connection select to match default mixer setting - mic
  3783. * (on mic1 pin)
  3784. */
  3785. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3786. /* Do similar with the second ADC: mute capture input amp and
  3787. * set ADC connection to mic to match ALSA's default state.
  3788. */
  3789. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3790. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3791. /* Mute all inputs to mixer widget (even unconnected ones) */
  3792. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3793. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3794. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3795. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3796. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3797. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3798. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3799. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3800. { }
  3801. };
  3802. static struct hda_verb alc260_will_verbs[] = {
  3803. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3804. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3805. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3806. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3807. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3808. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3809. {}
  3810. };
  3811. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3812. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3813. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3814. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3815. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3816. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3817. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3818. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3819. {}
  3820. };
  3821. /* toggle speaker-output according to the hp-jack state */
  3822. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3823. {
  3824. unsigned int present;
  3825. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3826. present = snd_hda_codec_read(codec, 0x0f, 0,
  3827. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3828. if (present) {
  3829. snd_hda_codec_write_cache(codec, 0x01, 0,
  3830. AC_VERB_SET_GPIO_DATA, 1);
  3831. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3832. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3833. PIN_HP);
  3834. } else {
  3835. snd_hda_codec_write_cache(codec, 0x01, 0,
  3836. AC_VERB_SET_GPIO_DATA, 0);
  3837. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3838. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3839. PIN_OUT);
  3840. }
  3841. }
  3842. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3843. unsigned int res)
  3844. {
  3845. if ((res >> 26) == ALC880_HP_EVENT)
  3846. alc260_replacer_672v_automute(codec);
  3847. }
  3848. /* Test configuration for debugging, modelled after the ALC880 test
  3849. * configuration.
  3850. */
  3851. #ifdef CONFIG_SND_DEBUG
  3852. static hda_nid_t alc260_test_dac_nids[1] = {
  3853. 0x02,
  3854. };
  3855. static hda_nid_t alc260_test_adc_nids[2] = {
  3856. 0x04, 0x05,
  3857. };
  3858. /* For testing the ALC260, each input MUX needs its own definition since
  3859. * the signal assignments are different. This assumes that the first ADC
  3860. * is NID 0x04.
  3861. */
  3862. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3863. {
  3864. .num_items = 7,
  3865. .items = {
  3866. { "MIC1 pin", 0x0 },
  3867. { "MIC2 pin", 0x1 },
  3868. { "LINE1 pin", 0x2 },
  3869. { "LINE2 pin", 0x3 },
  3870. { "CD pin", 0x4 },
  3871. { "LINE-OUT pin", 0x5 },
  3872. { "HP-OUT pin", 0x6 },
  3873. },
  3874. },
  3875. {
  3876. .num_items = 8,
  3877. .items = {
  3878. { "MIC1 pin", 0x0 },
  3879. { "MIC2 pin", 0x1 },
  3880. { "LINE1 pin", 0x2 },
  3881. { "LINE2 pin", 0x3 },
  3882. { "CD pin", 0x4 },
  3883. { "Mixer", 0x5 },
  3884. { "LINE-OUT pin", 0x6 },
  3885. { "HP-OUT pin", 0x7 },
  3886. },
  3887. },
  3888. };
  3889. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3890. /* Output driver widgets */
  3891. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3892. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3893. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3894. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3895. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3896. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3897. /* Modes for retasking pin widgets
  3898. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3899. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3900. * mention this restriction. At this stage it's not clear whether
  3901. * this behaviour is intentional or is a hardware bug in chip
  3902. * revisions available at least up until early 2006. Therefore for
  3903. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3904. * choices, but if it turns out that the lack of mic bias for these
  3905. * NIDs is intentional we could change their modes from
  3906. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3907. */
  3908. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3909. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3910. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3911. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3912. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3913. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3914. /* Loopback mixer controls */
  3915. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3916. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3917. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3918. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3919. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3920. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3921. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3922. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3923. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3924. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3925. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3926. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3927. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3928. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3929. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3930. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3931. /* Controls for GPIO pins, assuming they are configured as outputs */
  3932. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3933. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3934. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3935. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3936. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3937. * is ambigious as to which NID is which; testing on laptops which
  3938. * make this output available should provide clarification.
  3939. */
  3940. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3941. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3942. { } /* end */
  3943. };
  3944. static struct hda_verb alc260_test_init_verbs[] = {
  3945. /* Enable all GPIOs as outputs with an initial value of 0 */
  3946. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3947. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3948. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3949. /* Enable retasking pins as output, initially without power amp */
  3950. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3951. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3952. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3953. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3954. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3955. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3956. /* Disable digital (SPDIF) pins initially, but users can enable
  3957. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3958. * payload also sets the generation to 0, output to be in "consumer"
  3959. * PCM format, copyright asserted, no pre-emphasis and no validity
  3960. * control.
  3961. */
  3962. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3963. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3964. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3965. * OUT1 sum bus when acting as an output.
  3966. */
  3967. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3968. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3969. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3970. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3971. /* Start with output sum widgets muted and their output gains at min */
  3972. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3973. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3974. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3975. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3976. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3977. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3978. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3979. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3980. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3981. /* Unmute retasking pin widget output buffers since the default
  3982. * state appears to be output. As the pin mode is changed by the
  3983. * user the pin mode control will take care of enabling the pin's
  3984. * input/output buffers as needed.
  3985. */
  3986. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3987. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3988. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3989. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3990. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3991. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3992. /* Also unmute the mono-out pin widget */
  3993. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3994. /* Mute capture amp left and right */
  3995. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3996. /* Set ADC connection select to match default mixer setting (mic1
  3997. * pin)
  3998. */
  3999. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4000. /* Do the same for the second ADC: mute capture input amp and
  4001. * set ADC connection to mic1 pin
  4002. */
  4003. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4004. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4005. /* Mute all inputs to mixer widget (even unconnected ones) */
  4006. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  4007. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  4008. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  4009. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  4010. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  4011. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  4012. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  4013. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  4014. { }
  4015. };
  4016. #endif
  4017. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  4018. .substreams = 1,
  4019. .channels_min = 2,
  4020. .channels_max = 2,
  4021. };
  4022. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  4023. .substreams = 1,
  4024. .channels_min = 2,
  4025. .channels_max = 2,
  4026. };
  4027. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  4028. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  4029. /*
  4030. * for BIOS auto-configuration
  4031. */
  4032. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  4033. const char *pfx)
  4034. {
  4035. hda_nid_t nid_vol;
  4036. unsigned long vol_val, sw_val;
  4037. char name[32];
  4038. int err;
  4039. if (nid >= 0x0f && nid < 0x11) {
  4040. nid_vol = nid - 0x7;
  4041. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  4042. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  4043. } else if (nid == 0x11) {
  4044. nid_vol = nid - 0x7;
  4045. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  4046. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  4047. } else if (nid >= 0x12 && nid <= 0x15) {
  4048. nid_vol = 0x08;
  4049. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  4050. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  4051. } else
  4052. return 0; /* N/A */
  4053. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  4054. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  4055. if (err < 0)
  4056. return err;
  4057. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  4058. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  4059. if (err < 0)
  4060. return err;
  4061. return 1;
  4062. }
  4063. /* add playback controls from the parsed DAC table */
  4064. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  4065. const struct auto_pin_cfg *cfg)
  4066. {
  4067. hda_nid_t nid;
  4068. int err;
  4069. spec->multiout.num_dacs = 1;
  4070. spec->multiout.dac_nids = spec->private_dac_nids;
  4071. spec->multiout.dac_nids[0] = 0x02;
  4072. nid = cfg->line_out_pins[0];
  4073. if (nid) {
  4074. err = alc260_add_playback_controls(spec, nid, "Front");
  4075. if (err < 0)
  4076. return err;
  4077. }
  4078. nid = cfg->speaker_pins[0];
  4079. if (nid) {
  4080. err = alc260_add_playback_controls(spec, nid, "Speaker");
  4081. if (err < 0)
  4082. return err;
  4083. }
  4084. nid = cfg->hp_pins[0];
  4085. if (nid) {
  4086. err = alc260_add_playback_controls(spec, nid, "Headphone");
  4087. if (err < 0)
  4088. return err;
  4089. }
  4090. return 0;
  4091. }
  4092. /* create playback/capture controls for input pins */
  4093. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  4094. const struct auto_pin_cfg *cfg)
  4095. {
  4096. struct hda_input_mux *imux = &spec->private_imux;
  4097. int i, err, idx;
  4098. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4099. if (cfg->input_pins[i] >= 0x12) {
  4100. idx = cfg->input_pins[i] - 0x12;
  4101. err = new_analog_input(spec, cfg->input_pins[i],
  4102. auto_pin_cfg_labels[i], idx,
  4103. 0x07);
  4104. if (err < 0)
  4105. return err;
  4106. imux->items[imux->num_items].label =
  4107. auto_pin_cfg_labels[i];
  4108. imux->items[imux->num_items].index = idx;
  4109. imux->num_items++;
  4110. }
  4111. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  4112. idx = cfg->input_pins[i] - 0x09;
  4113. err = new_analog_input(spec, cfg->input_pins[i],
  4114. auto_pin_cfg_labels[i], idx,
  4115. 0x07);
  4116. if (err < 0)
  4117. return err;
  4118. imux->items[imux->num_items].label =
  4119. auto_pin_cfg_labels[i];
  4120. imux->items[imux->num_items].index = idx;
  4121. imux->num_items++;
  4122. }
  4123. }
  4124. return 0;
  4125. }
  4126. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  4127. hda_nid_t nid, int pin_type,
  4128. int sel_idx)
  4129. {
  4130. /* set as output */
  4131. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4132. pin_type);
  4133. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4134. AMP_OUT_UNMUTE);
  4135. /* need the manual connection? */
  4136. if (nid >= 0x12) {
  4137. int idx = nid - 0x12;
  4138. snd_hda_codec_write(codec, idx + 0x0b, 0,
  4139. AC_VERB_SET_CONNECT_SEL, sel_idx);
  4140. }
  4141. }
  4142. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4143. {
  4144. struct alc_spec *spec = codec->spec;
  4145. hda_nid_t nid;
  4146. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4147. nid = spec->autocfg.line_out_pins[0];
  4148. if (nid) {
  4149. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4150. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4151. }
  4152. nid = spec->autocfg.speaker_pins[0];
  4153. if (nid)
  4154. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4155. nid = spec->autocfg.hp_pins[0];
  4156. if (nid)
  4157. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4158. }
  4159. #define ALC260_PIN_CD_NID 0x16
  4160. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4161. {
  4162. struct alc_spec *spec = codec->spec;
  4163. int i;
  4164. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4165. hda_nid_t nid = spec->autocfg.input_pins[i];
  4166. if (nid >= 0x12) {
  4167. snd_hda_codec_write(codec, nid, 0,
  4168. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4169. i <= AUTO_PIN_FRONT_MIC ?
  4170. PIN_VREF80 : PIN_IN);
  4171. if (nid != ALC260_PIN_CD_NID)
  4172. snd_hda_codec_write(codec, nid, 0,
  4173. AC_VERB_SET_AMP_GAIN_MUTE,
  4174. AMP_OUT_MUTE);
  4175. }
  4176. }
  4177. }
  4178. /*
  4179. * generic initialization of ADC, input mixers and output mixers
  4180. */
  4181. static struct hda_verb alc260_volume_init_verbs[] = {
  4182. /*
  4183. * Unmute ADC0-1 and set the default input to mic-in
  4184. */
  4185. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4186. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4187. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4188. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4189. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4190. * mixer widget
  4191. * Note: PASD motherboards uses the Line In 2 as the input for
  4192. * front panel mic (mic 2)
  4193. */
  4194. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4195. /* mute analog inputs */
  4196. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4197. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4198. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4199. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4200. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4201. /*
  4202. * Set up output mixers (0x08 - 0x0a)
  4203. */
  4204. /* set vol=0 to output mixers */
  4205. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4206. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4207. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4208. /* set up input amps for analog loopback */
  4209. /* Amp Indices: DAC = 0, mixer = 1 */
  4210. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4211. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4212. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4213. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4214. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4215. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4216. { }
  4217. };
  4218. static int alc260_parse_auto_config(struct hda_codec *codec)
  4219. {
  4220. struct alc_spec *spec = codec->spec;
  4221. unsigned int wcap;
  4222. int err;
  4223. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4224. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4225. alc260_ignore);
  4226. if (err < 0)
  4227. return err;
  4228. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4229. if (err < 0)
  4230. return err;
  4231. if (!spec->kctl_alloc)
  4232. return 0; /* can't find valid BIOS pin config */
  4233. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4234. if (err < 0)
  4235. return err;
  4236. spec->multiout.max_channels = 2;
  4237. if (spec->autocfg.dig_out_pin)
  4238. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4239. if (spec->kctl_alloc)
  4240. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4241. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4242. spec->num_mux_defs = 1;
  4243. spec->input_mux = &spec->private_imux;
  4244. /* check whether NID 0x04 is valid */
  4245. wcap = get_wcaps(codec, 0x04);
  4246. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4247. if (wcap != AC_WID_AUD_IN) {
  4248. spec->adc_nids = alc260_adc_nids_alt;
  4249. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4250. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4251. } else {
  4252. spec->adc_nids = alc260_adc_nids;
  4253. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4254. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4255. }
  4256. spec->num_mixers++;
  4257. return 1;
  4258. }
  4259. /* additional initialization for auto-configuration model */
  4260. static void alc260_auto_init(struct hda_codec *codec)
  4261. {
  4262. alc260_auto_init_multi_out(codec);
  4263. alc260_auto_init_analog_input(codec);
  4264. }
  4265. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4266. static struct hda_amp_list alc260_loopbacks[] = {
  4267. { 0x07, HDA_INPUT, 0 },
  4268. { 0x07, HDA_INPUT, 1 },
  4269. { 0x07, HDA_INPUT, 2 },
  4270. { 0x07, HDA_INPUT, 3 },
  4271. { 0x07, HDA_INPUT, 4 },
  4272. { } /* end */
  4273. };
  4274. #endif
  4275. /*
  4276. * ALC260 configurations
  4277. */
  4278. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4279. [ALC260_BASIC] = "basic",
  4280. [ALC260_HP] = "hp",
  4281. [ALC260_HP_3013] = "hp-3013",
  4282. [ALC260_FUJITSU_S702X] = "fujitsu",
  4283. [ALC260_ACER] = "acer",
  4284. [ALC260_WILL] = "will",
  4285. [ALC260_REPLACER_672V] = "replacer",
  4286. #ifdef CONFIG_SND_DEBUG
  4287. [ALC260_TEST] = "test",
  4288. #endif
  4289. [ALC260_AUTO] = "auto",
  4290. };
  4291. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4292. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4293. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4294. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4295. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4296. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4297. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4298. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4299. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4300. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4301. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4302. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4303. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4304. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4305. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4306. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4307. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4308. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4309. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4310. {}
  4311. };
  4312. static struct alc_config_preset alc260_presets[] = {
  4313. [ALC260_BASIC] = {
  4314. .mixers = { alc260_base_output_mixer,
  4315. alc260_input_mixer,
  4316. alc260_pc_beep_mixer,
  4317. alc260_capture_mixer },
  4318. .init_verbs = { alc260_init_verbs },
  4319. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4320. .dac_nids = alc260_dac_nids,
  4321. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4322. .adc_nids = alc260_adc_nids,
  4323. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4324. .channel_mode = alc260_modes,
  4325. .input_mux = &alc260_capture_source,
  4326. },
  4327. [ALC260_HP] = {
  4328. .mixers = { alc260_base_output_mixer,
  4329. alc260_input_mixer,
  4330. alc260_capture_alt_mixer },
  4331. .init_verbs = { alc260_init_verbs },
  4332. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4333. .dac_nids = alc260_dac_nids,
  4334. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4335. .adc_nids = alc260_hp_adc_nids,
  4336. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4337. .channel_mode = alc260_modes,
  4338. .input_mux = &alc260_capture_source,
  4339. },
  4340. [ALC260_HP_3013] = {
  4341. .mixers = { alc260_hp_3013_mixer,
  4342. alc260_input_mixer,
  4343. alc260_capture_alt_mixer },
  4344. .init_verbs = { alc260_hp_3013_init_verbs },
  4345. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4346. .dac_nids = alc260_dac_nids,
  4347. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4348. .adc_nids = alc260_hp_adc_nids,
  4349. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4350. .channel_mode = alc260_modes,
  4351. .input_mux = &alc260_capture_source,
  4352. },
  4353. [ALC260_FUJITSU_S702X] = {
  4354. .mixers = { alc260_fujitsu_mixer,
  4355. alc260_capture_mixer },
  4356. .init_verbs = { alc260_fujitsu_init_verbs },
  4357. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4358. .dac_nids = alc260_dac_nids,
  4359. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4360. .adc_nids = alc260_dual_adc_nids,
  4361. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4362. .channel_mode = alc260_modes,
  4363. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4364. .input_mux = alc260_fujitsu_capture_sources,
  4365. },
  4366. [ALC260_ACER] = {
  4367. .mixers = { alc260_acer_mixer,
  4368. alc260_capture_mixer },
  4369. .init_verbs = { alc260_acer_init_verbs },
  4370. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4371. .dac_nids = alc260_dac_nids,
  4372. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4373. .adc_nids = alc260_dual_adc_nids,
  4374. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4375. .channel_mode = alc260_modes,
  4376. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4377. .input_mux = alc260_acer_capture_sources,
  4378. },
  4379. [ALC260_WILL] = {
  4380. .mixers = { alc260_will_mixer,
  4381. alc260_capture_mixer },
  4382. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4383. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4384. .dac_nids = alc260_dac_nids,
  4385. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4386. .adc_nids = alc260_adc_nids,
  4387. .dig_out_nid = ALC260_DIGOUT_NID,
  4388. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4389. .channel_mode = alc260_modes,
  4390. .input_mux = &alc260_capture_source,
  4391. },
  4392. [ALC260_REPLACER_672V] = {
  4393. .mixers = { alc260_replacer_672v_mixer,
  4394. alc260_capture_mixer },
  4395. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4396. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4397. .dac_nids = alc260_dac_nids,
  4398. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4399. .adc_nids = alc260_adc_nids,
  4400. .dig_out_nid = ALC260_DIGOUT_NID,
  4401. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4402. .channel_mode = alc260_modes,
  4403. .input_mux = &alc260_capture_source,
  4404. .unsol_event = alc260_replacer_672v_unsol_event,
  4405. .init_hook = alc260_replacer_672v_automute,
  4406. },
  4407. #ifdef CONFIG_SND_DEBUG
  4408. [ALC260_TEST] = {
  4409. .mixers = { alc260_test_mixer,
  4410. alc260_capture_mixer },
  4411. .init_verbs = { alc260_test_init_verbs },
  4412. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4413. .dac_nids = alc260_test_dac_nids,
  4414. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4415. .adc_nids = alc260_test_adc_nids,
  4416. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4417. .channel_mode = alc260_modes,
  4418. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4419. .input_mux = alc260_test_capture_sources,
  4420. },
  4421. #endif
  4422. };
  4423. static int patch_alc260(struct hda_codec *codec)
  4424. {
  4425. struct alc_spec *spec;
  4426. int err, board_config;
  4427. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4428. if (spec == NULL)
  4429. return -ENOMEM;
  4430. codec->spec = spec;
  4431. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4432. alc260_models,
  4433. alc260_cfg_tbl);
  4434. if (board_config < 0) {
  4435. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4436. "trying auto-probe from BIOS...\n");
  4437. board_config = ALC260_AUTO;
  4438. }
  4439. if (board_config == ALC260_AUTO) {
  4440. /* automatic parse from the BIOS config */
  4441. err = alc260_parse_auto_config(codec);
  4442. if (err < 0) {
  4443. alc_free(codec);
  4444. return err;
  4445. } else if (!err) {
  4446. printk(KERN_INFO
  4447. "hda_codec: Cannot set up configuration "
  4448. "from BIOS. Using base mode...\n");
  4449. board_config = ALC260_BASIC;
  4450. }
  4451. }
  4452. if (board_config != ALC260_AUTO)
  4453. setup_preset(spec, &alc260_presets[board_config]);
  4454. spec->stream_name_analog = "ALC260 Analog";
  4455. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4456. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4457. spec->stream_name_digital = "ALC260 Digital";
  4458. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4459. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4460. codec->patch_ops = alc_patch_ops;
  4461. if (board_config == ALC260_AUTO)
  4462. spec->init_hook = alc260_auto_init;
  4463. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4464. if (!spec->loopback.amplist)
  4465. spec->loopback.amplist = alc260_loopbacks;
  4466. #endif
  4467. return 0;
  4468. }
  4469. /*
  4470. * ALC882 support
  4471. *
  4472. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4473. * configuration. Each pin widget can choose any input DACs and a mixer.
  4474. * Each ADC is connected from a mixer of all inputs. This makes possible
  4475. * 6-channel independent captures.
  4476. *
  4477. * In addition, an independent DAC for the multi-playback (not used in this
  4478. * driver yet).
  4479. */
  4480. #define ALC882_DIGOUT_NID 0x06
  4481. #define ALC882_DIGIN_NID 0x0a
  4482. static struct hda_channel_mode alc882_ch_modes[1] = {
  4483. { 8, NULL }
  4484. };
  4485. static hda_nid_t alc882_dac_nids[4] = {
  4486. /* front, rear, clfe, rear_surr */
  4487. 0x02, 0x03, 0x04, 0x05
  4488. };
  4489. /* identical with ALC880 */
  4490. #define alc882_adc_nids alc880_adc_nids
  4491. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4492. /* input MUX */
  4493. /* FIXME: should be a matrix-type input source selection */
  4494. static struct hda_input_mux alc882_capture_source = {
  4495. .num_items = 4,
  4496. .items = {
  4497. { "Mic", 0x0 },
  4498. { "Front Mic", 0x1 },
  4499. { "Line", 0x2 },
  4500. { "CD", 0x4 },
  4501. },
  4502. };
  4503. #define alc882_mux_enum_info alc_mux_enum_info
  4504. #define alc882_mux_enum_get alc_mux_enum_get
  4505. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4506. struct snd_ctl_elem_value *ucontrol)
  4507. {
  4508. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4509. struct alc_spec *spec = codec->spec;
  4510. const struct hda_input_mux *imux = spec->input_mux;
  4511. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4512. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4513. hda_nid_t nid = capture_mixers[adc_idx];
  4514. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4515. unsigned int i, idx;
  4516. idx = ucontrol->value.enumerated.item[0];
  4517. if (idx >= imux->num_items)
  4518. idx = imux->num_items - 1;
  4519. if (*cur_val == idx)
  4520. return 0;
  4521. for (i = 0; i < imux->num_items; i++) {
  4522. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4523. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4524. imux->items[i].index,
  4525. HDA_AMP_MUTE, v);
  4526. }
  4527. *cur_val = idx;
  4528. return 1;
  4529. }
  4530. /*
  4531. * 2ch mode
  4532. */
  4533. static struct hda_verb alc882_3ST_ch2_init[] = {
  4534. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4535. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4536. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4537. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4538. { } /* end */
  4539. };
  4540. /*
  4541. * 6ch mode
  4542. */
  4543. static struct hda_verb alc882_3ST_ch6_init[] = {
  4544. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4545. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4546. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4547. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4548. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4549. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4550. { } /* end */
  4551. };
  4552. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4553. { 2, alc882_3ST_ch2_init },
  4554. { 6, alc882_3ST_ch6_init },
  4555. };
  4556. /*
  4557. * 6ch mode
  4558. */
  4559. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4560. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4561. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4562. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4563. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4564. { } /* end */
  4565. };
  4566. /*
  4567. * 8ch mode
  4568. */
  4569. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4570. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4571. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4572. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4573. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4574. { } /* end */
  4575. };
  4576. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4577. { 6, alc882_sixstack_ch6_init },
  4578. { 8, alc882_sixstack_ch8_init },
  4579. };
  4580. /*
  4581. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4582. */
  4583. /*
  4584. * 2ch mode
  4585. */
  4586. static struct hda_verb alc885_mbp_ch2_init[] = {
  4587. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4588. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4589. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4590. { } /* end */
  4591. };
  4592. /*
  4593. * 6ch mode
  4594. */
  4595. static struct hda_verb alc885_mbp_ch6_init[] = {
  4596. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4597. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4598. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4599. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4600. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4601. { } /* end */
  4602. };
  4603. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4604. { 2, alc885_mbp_ch2_init },
  4605. { 6, alc885_mbp_ch6_init },
  4606. };
  4607. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4608. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4609. */
  4610. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4611. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4612. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4613. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4614. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4615. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4616. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4617. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4618. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4619. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4620. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4621. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4622. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4623. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4624. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4625. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4626. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4627. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4628. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4629. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4630. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4631. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4632. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4633. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4634. { } /* end */
  4635. };
  4636. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4637. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4638. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4639. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4640. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4641. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4642. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4643. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4644. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4645. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4646. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4647. { } /* end */
  4648. };
  4649. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4650. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4651. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4652. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4653. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4654. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4655. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4656. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4657. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4658. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4659. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4660. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4661. { } /* end */
  4662. };
  4663. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4664. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4665. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4666. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4667. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4668. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4669. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4670. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4671. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4672. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4673. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4674. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4675. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4676. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4677. { } /* end */
  4678. };
  4679. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4680. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4681. */
  4682. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4683. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4684. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4685. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4686. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4687. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4688. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4689. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4690. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4691. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4692. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4693. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4694. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4695. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4696. { } /* end */
  4697. };
  4698. static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
  4699. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4700. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4701. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4702. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4703. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4704. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4705. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4706. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4707. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4708. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4709. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4710. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4711. { } /* end */
  4712. };
  4713. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4714. {
  4715. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4716. .name = "Channel Mode",
  4717. .info = alc_ch_mode_info,
  4718. .get = alc_ch_mode_get,
  4719. .put = alc_ch_mode_put,
  4720. },
  4721. { } /* end */
  4722. };
  4723. static struct hda_verb alc882_init_verbs[] = {
  4724. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4725. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4726. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4727. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4728. /* Rear mixer */
  4729. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4730. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4731. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4732. /* CLFE mixer */
  4733. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4734. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4735. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4736. /* Side mixer */
  4737. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4738. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4739. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4740. /* Front Pin: output 0 (0x0c) */
  4741. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4742. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4743. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4744. /* Rear Pin: output 1 (0x0d) */
  4745. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4746. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4747. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4748. /* CLFE Pin: output 2 (0x0e) */
  4749. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4750. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4751. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4752. /* Side Pin: output 3 (0x0f) */
  4753. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4754. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4755. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4756. /* Mic (rear) pin: input vref at 80% */
  4757. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4758. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4759. /* Front Mic pin: input vref at 80% */
  4760. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4761. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4762. /* Line In pin: input */
  4763. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4764. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4765. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4766. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4767. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4768. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4769. /* CD pin widget for input */
  4770. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4771. /* FIXME: use matrix-type input source selection */
  4772. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4773. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4774. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4775. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4776. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4777. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4778. /* Input mixer2 */
  4779. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4780. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4781. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4782. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4783. /* Input mixer3 */
  4784. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4785. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4786. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4787. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4788. /* ADC1: mute amp left and right */
  4789. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4790. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4791. /* ADC2: mute amp left and right */
  4792. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4793. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4794. /* ADC3: mute amp left and right */
  4795. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4796. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4797. { }
  4798. };
  4799. static struct hda_verb alc882_eapd_verbs[] = {
  4800. /* change to EAPD mode */
  4801. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4802. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4803. { }
  4804. };
  4805. /* Mac Pro test */
  4806. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4807. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4808. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4809. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4810. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4811. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4812. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4813. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4814. { } /* end */
  4815. };
  4816. static struct hda_verb alc882_macpro_init_verbs[] = {
  4817. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4818. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4819. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4820. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4821. /* Front Pin: output 0 (0x0c) */
  4822. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4823. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4824. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4825. /* Front Mic pin: input vref at 80% */
  4826. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4827. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4828. /* Speaker: output */
  4829. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4830. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4831. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4832. /* Headphone output (output 0 - 0x0c) */
  4833. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4834. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4835. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4836. /* FIXME: use matrix-type input source selection */
  4837. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4838. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4839. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4840. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4841. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4842. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4843. /* Input mixer2 */
  4844. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4845. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4846. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4847. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4848. /* Input mixer3 */
  4849. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4850. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4851. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4852. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4853. /* ADC1: mute amp left and right */
  4854. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4855. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4856. /* ADC2: mute amp left and right */
  4857. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4858. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4859. /* ADC3: mute amp left and right */
  4860. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4861. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4862. { }
  4863. };
  4864. /* Macbook Pro rev3 */
  4865. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4866. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4867. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4868. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4869. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4870. /* Rear mixer */
  4871. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4872. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4873. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4874. /* Front Pin: output 0 (0x0c) */
  4875. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4876. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4877. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4878. /* HP Pin: output 0 (0x0d) */
  4879. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4880. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4881. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4882. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4883. /* Mic (rear) pin: input vref at 80% */
  4884. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4885. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4886. /* Front Mic pin: input vref at 80% */
  4887. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4888. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4889. /* Line In pin: use output 1 when in LineOut mode */
  4890. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4891. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4892. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4893. /* FIXME: use matrix-type input source selection */
  4894. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4895. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4896. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4897. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4898. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4899. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4900. /* Input mixer2 */
  4901. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4902. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4903. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4904. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4905. /* Input mixer3 */
  4906. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4907. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4908. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4909. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4910. /* ADC1: mute amp left and right */
  4911. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4912. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4913. /* ADC2: mute amp left and right */
  4914. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4915. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4916. /* ADC3: mute amp left and right */
  4917. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4918. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4919. { }
  4920. };
  4921. /* iMac 24 mixer. */
  4922. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4923. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4924. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4925. { } /* end */
  4926. };
  4927. /* iMac 24 init verbs. */
  4928. static struct hda_verb alc885_imac24_init_verbs[] = {
  4929. /* Internal speakers: output 0 (0x0c) */
  4930. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4931. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4932. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4933. /* Internal speakers: output 0 (0x0c) */
  4934. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4935. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4936. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4937. /* Headphone: output 0 (0x0c) */
  4938. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4939. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4940. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4941. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4942. /* Front Mic: input vref at 80% */
  4943. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4944. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4945. { }
  4946. };
  4947. /* Toggle speaker-output according to the hp-jack state */
  4948. static void alc885_imac24_automute(struct hda_codec *codec)
  4949. {
  4950. unsigned int present;
  4951. present = snd_hda_codec_read(codec, 0x14, 0,
  4952. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4953. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4954. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4955. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4956. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4957. }
  4958. /* Processes unsolicited events. */
  4959. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4960. unsigned int res)
  4961. {
  4962. /* Headphone insertion or removal. */
  4963. if ((res >> 26) == ALC880_HP_EVENT)
  4964. alc885_imac24_automute(codec);
  4965. }
  4966. static void alc885_mbp3_automute(struct hda_codec *codec)
  4967. {
  4968. unsigned int present;
  4969. present = snd_hda_codec_read(codec, 0x15, 0,
  4970. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4971. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  4972. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4973. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  4974. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  4975. }
  4976. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  4977. unsigned int res)
  4978. {
  4979. /* Headphone insertion or removal. */
  4980. if ((res >> 26) == ALC880_HP_EVENT)
  4981. alc885_mbp3_automute(codec);
  4982. }
  4983. static struct hda_verb alc882_targa_verbs[] = {
  4984. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4985. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4986. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4987. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4988. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4989. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4990. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4991. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4992. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4993. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4994. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4995. { } /* end */
  4996. };
  4997. /* toggle speaker-output according to the hp-jack state */
  4998. static void alc882_targa_automute(struct hda_codec *codec)
  4999. {
  5000. unsigned int present;
  5001. present = snd_hda_codec_read(codec, 0x14, 0,
  5002. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5003. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  5004. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5005. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5006. present ? 1 : 3);
  5007. }
  5008. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  5009. {
  5010. /* Looks like the unsol event is incompatible with the standard
  5011. * definition. 4bit tag is placed at 26 bit!
  5012. */
  5013. if (((res >> 26) == ALC880_HP_EVENT)) {
  5014. alc882_targa_automute(codec);
  5015. }
  5016. }
  5017. static struct hda_verb alc882_asus_a7j_verbs[] = {
  5018. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5019. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5020. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5021. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5022. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5023. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5024. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5025. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5026. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5027. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5028. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5029. { } /* end */
  5030. };
  5031. static struct hda_verb alc882_asus_a7m_verbs[] = {
  5032. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5033. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5034. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5035. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5036. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5037. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5038. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5039. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5040. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5041. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5042. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5043. { } /* end */
  5044. };
  5045. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  5046. {
  5047. unsigned int gpiostate, gpiomask, gpiodir;
  5048. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  5049. AC_VERB_GET_GPIO_DATA, 0);
  5050. if (!muted)
  5051. gpiostate |= (1 << pin);
  5052. else
  5053. gpiostate &= ~(1 << pin);
  5054. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  5055. AC_VERB_GET_GPIO_MASK, 0);
  5056. gpiomask |= (1 << pin);
  5057. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  5058. AC_VERB_GET_GPIO_DIRECTION, 0);
  5059. gpiodir |= (1 << pin);
  5060. snd_hda_codec_write(codec, codec->afg, 0,
  5061. AC_VERB_SET_GPIO_MASK, gpiomask);
  5062. snd_hda_codec_write(codec, codec->afg, 0,
  5063. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  5064. msleep(1);
  5065. snd_hda_codec_write(codec, codec->afg, 0,
  5066. AC_VERB_SET_GPIO_DATA, gpiostate);
  5067. }
  5068. /* set up GPIO at initialization */
  5069. static void alc885_macpro_init_hook(struct hda_codec *codec)
  5070. {
  5071. alc882_gpio_mute(codec, 0, 0);
  5072. alc882_gpio_mute(codec, 1, 0);
  5073. }
  5074. /* set up GPIO and update auto-muting at initialization */
  5075. static void alc885_imac24_init_hook(struct hda_codec *codec)
  5076. {
  5077. alc885_macpro_init_hook(codec);
  5078. alc885_imac24_automute(codec);
  5079. }
  5080. /*
  5081. * generic initialization of ADC, input mixers and output mixers
  5082. */
  5083. static struct hda_verb alc882_auto_init_verbs[] = {
  5084. /*
  5085. * Unmute ADC0-2 and set the default input to mic-in
  5086. */
  5087. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5088. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5089. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5090. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5091. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5092. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5093. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5094. * mixer widget
  5095. * Note: PASD motherboards uses the Line In 2 as the input for
  5096. * front panel mic (mic 2)
  5097. */
  5098. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5099. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5100. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5101. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5102. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5103. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5104. /*
  5105. * Set up output mixers (0x0c - 0x0f)
  5106. */
  5107. /* set vol=0 to output mixers */
  5108. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5109. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5110. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5111. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5112. /* set up input amps for analog loopback */
  5113. /* Amp Indices: DAC = 0, mixer = 1 */
  5114. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5115. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5116. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5117. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5118. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5119. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5120. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5121. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5122. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5123. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5124. /* FIXME: use matrix-type input source selection */
  5125. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5126. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5127. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5128. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5129. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5130. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5131. /* Input mixer2 */
  5132. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5133. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5134. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5135. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5136. /* Input mixer3 */
  5137. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5138. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5139. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5140. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5141. { }
  5142. };
  5143. /* capture mixer elements */
  5144. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  5145. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5146. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5147. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5148. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5149. {
  5150. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5151. /* The multiple "Capture Source" controls confuse alsamixer
  5152. * So call somewhat different..
  5153. * FIXME: the controls appear in the "playback" view!
  5154. */
  5155. /* .name = "Capture Source", */
  5156. .name = "Input Source",
  5157. .count = 2,
  5158. .info = alc882_mux_enum_info,
  5159. .get = alc882_mux_enum_get,
  5160. .put = alc882_mux_enum_put,
  5161. },
  5162. { } /* end */
  5163. };
  5164. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  5165. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  5166. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  5167. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  5168. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  5169. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  5170. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  5171. {
  5172. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5173. /* The multiple "Capture Source" controls confuse alsamixer
  5174. * So call somewhat different..
  5175. * FIXME: the controls appear in the "playback" view!
  5176. */
  5177. /* .name = "Capture Source", */
  5178. .name = "Input Source",
  5179. .count = 3,
  5180. .info = alc882_mux_enum_info,
  5181. .get = alc882_mux_enum_get,
  5182. .put = alc882_mux_enum_put,
  5183. },
  5184. { } /* end */
  5185. };
  5186. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5187. #define alc882_loopbacks alc880_loopbacks
  5188. #endif
  5189. /* pcm configuration: identiacal with ALC880 */
  5190. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5191. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5192. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5193. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5194. /*
  5195. * configuration and preset
  5196. */
  5197. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5198. [ALC882_3ST_DIG] = "3stack-dig",
  5199. [ALC882_6ST_DIG] = "6stack-dig",
  5200. [ALC882_ARIMA] = "arima",
  5201. [ALC882_W2JC] = "w2jc",
  5202. [ALC882_TARGA] = "targa",
  5203. [ALC882_ASUS_A7J] = "asus-a7j",
  5204. [ALC882_ASUS_A7M] = "asus-a7m",
  5205. [ALC885_MACPRO] = "macpro",
  5206. [ALC885_MBP3] = "mbp3",
  5207. [ALC885_IMAC24] = "imac24",
  5208. [ALC882_AUTO] = "auto",
  5209. };
  5210. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5211. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5212. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5213. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5214. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5215. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5216. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5217. SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
  5218. SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
  5219. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5220. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5221. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5222. {}
  5223. };
  5224. static struct alc_config_preset alc882_presets[] = {
  5225. [ALC882_3ST_DIG] = {
  5226. .mixers = { alc882_base_mixer },
  5227. .init_verbs = { alc882_init_verbs },
  5228. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5229. .dac_nids = alc882_dac_nids,
  5230. .dig_out_nid = ALC882_DIGOUT_NID,
  5231. .dig_in_nid = ALC882_DIGIN_NID,
  5232. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5233. .channel_mode = alc882_ch_modes,
  5234. .need_dac_fix = 1,
  5235. .input_mux = &alc882_capture_source,
  5236. },
  5237. [ALC882_6ST_DIG] = {
  5238. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5239. .init_verbs = { alc882_init_verbs },
  5240. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5241. .dac_nids = alc882_dac_nids,
  5242. .dig_out_nid = ALC882_DIGOUT_NID,
  5243. .dig_in_nid = ALC882_DIGIN_NID,
  5244. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5245. .channel_mode = alc882_sixstack_modes,
  5246. .input_mux = &alc882_capture_source,
  5247. },
  5248. [ALC882_ARIMA] = {
  5249. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5250. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5251. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5252. .dac_nids = alc882_dac_nids,
  5253. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5254. .channel_mode = alc882_sixstack_modes,
  5255. .input_mux = &alc882_capture_source,
  5256. },
  5257. [ALC882_W2JC] = {
  5258. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5259. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5260. alc880_gpio1_init_verbs },
  5261. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5262. .dac_nids = alc882_dac_nids,
  5263. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5264. .channel_mode = alc880_threestack_modes,
  5265. .need_dac_fix = 1,
  5266. .input_mux = &alc882_capture_source,
  5267. .dig_out_nid = ALC882_DIGOUT_NID,
  5268. },
  5269. [ALC885_MBP3] = {
  5270. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5271. .init_verbs = { alc885_mbp3_init_verbs,
  5272. alc880_gpio1_init_verbs },
  5273. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5274. .dac_nids = alc882_dac_nids,
  5275. .channel_mode = alc885_mbp_6ch_modes,
  5276. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5277. .input_mux = &alc882_capture_source,
  5278. .dig_out_nid = ALC882_DIGOUT_NID,
  5279. .dig_in_nid = ALC882_DIGIN_NID,
  5280. .unsol_event = alc885_mbp3_unsol_event,
  5281. .init_hook = alc885_mbp3_automute,
  5282. },
  5283. [ALC885_MACPRO] = {
  5284. .mixers = { alc882_macpro_mixer },
  5285. .init_verbs = { alc882_macpro_init_verbs },
  5286. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5287. .dac_nids = alc882_dac_nids,
  5288. .dig_out_nid = ALC882_DIGOUT_NID,
  5289. .dig_in_nid = ALC882_DIGIN_NID,
  5290. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5291. .channel_mode = alc882_ch_modes,
  5292. .input_mux = &alc882_capture_source,
  5293. .init_hook = alc885_macpro_init_hook,
  5294. },
  5295. [ALC885_IMAC24] = {
  5296. .mixers = { alc885_imac24_mixer },
  5297. .init_verbs = { alc885_imac24_init_verbs },
  5298. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5299. .dac_nids = alc882_dac_nids,
  5300. .dig_out_nid = ALC882_DIGOUT_NID,
  5301. .dig_in_nid = ALC882_DIGIN_NID,
  5302. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5303. .channel_mode = alc882_ch_modes,
  5304. .input_mux = &alc882_capture_source,
  5305. .unsol_event = alc885_imac24_unsol_event,
  5306. .init_hook = alc885_imac24_init_hook,
  5307. },
  5308. [ALC882_TARGA] = {
  5309. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5310. alc882_capture_mixer },
  5311. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5312. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5313. .dac_nids = alc882_dac_nids,
  5314. .dig_out_nid = ALC882_DIGOUT_NID,
  5315. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5316. .adc_nids = alc882_adc_nids,
  5317. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5318. .channel_mode = alc882_3ST_6ch_modes,
  5319. .need_dac_fix = 1,
  5320. .input_mux = &alc882_capture_source,
  5321. .unsol_event = alc882_targa_unsol_event,
  5322. .init_hook = alc882_targa_automute,
  5323. },
  5324. [ALC882_ASUS_A7J] = {
  5325. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5326. alc882_capture_mixer },
  5327. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5328. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5329. .dac_nids = alc882_dac_nids,
  5330. .dig_out_nid = ALC882_DIGOUT_NID,
  5331. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5332. .adc_nids = alc882_adc_nids,
  5333. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5334. .channel_mode = alc882_3ST_6ch_modes,
  5335. .need_dac_fix = 1,
  5336. .input_mux = &alc882_capture_source,
  5337. },
  5338. [ALC882_ASUS_A7M] = {
  5339. .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
  5340. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5341. alc880_gpio1_init_verbs,
  5342. alc882_asus_a7m_verbs },
  5343. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5344. .dac_nids = alc882_dac_nids,
  5345. .dig_out_nid = ALC882_DIGOUT_NID,
  5346. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5347. .channel_mode = alc880_threestack_modes,
  5348. .need_dac_fix = 1,
  5349. .input_mux = &alc882_capture_source,
  5350. },
  5351. };
  5352. /*
  5353. * Pin config fixes
  5354. */
  5355. enum {
  5356. PINFIX_ABIT_AW9D_MAX
  5357. };
  5358. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5359. { 0x15, 0x01080104 }, /* side */
  5360. { 0x16, 0x01011012 }, /* rear */
  5361. { 0x17, 0x01016011 }, /* clfe */
  5362. { }
  5363. };
  5364. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5365. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5366. };
  5367. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5368. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5369. {}
  5370. };
  5371. /*
  5372. * BIOS auto configuration
  5373. */
  5374. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5375. hda_nid_t nid, int pin_type,
  5376. int dac_idx)
  5377. {
  5378. /* set as output */
  5379. struct alc_spec *spec = codec->spec;
  5380. int idx;
  5381. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5382. idx = 4;
  5383. else
  5384. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5385. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5386. pin_type);
  5387. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5388. AMP_OUT_UNMUTE);
  5389. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5390. }
  5391. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5392. {
  5393. struct alc_spec *spec = codec->spec;
  5394. int i;
  5395. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5396. for (i = 0; i <= HDA_SIDE; i++) {
  5397. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5398. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5399. if (nid)
  5400. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5401. i);
  5402. }
  5403. }
  5404. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5405. {
  5406. struct alc_spec *spec = codec->spec;
  5407. hda_nid_t pin;
  5408. pin = spec->autocfg.hp_pins[0];
  5409. if (pin) /* connect to front */
  5410. /* use dac 0 */
  5411. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5412. }
  5413. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5414. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5415. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5416. {
  5417. struct alc_spec *spec = codec->spec;
  5418. int i;
  5419. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5420. hda_nid_t nid = spec->autocfg.input_pins[i];
  5421. if (alc882_is_input_pin(nid)) {
  5422. snd_hda_codec_write(codec, nid, 0,
  5423. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5424. i <= AUTO_PIN_FRONT_MIC ?
  5425. PIN_VREF80 : PIN_IN);
  5426. if (nid != ALC882_PIN_CD_NID)
  5427. snd_hda_codec_write(codec, nid, 0,
  5428. AC_VERB_SET_AMP_GAIN_MUTE,
  5429. AMP_OUT_MUTE);
  5430. }
  5431. }
  5432. }
  5433. /* add mic boosts if needed */
  5434. static int alc_auto_add_mic_boost(struct hda_codec *codec)
  5435. {
  5436. struct alc_spec *spec = codec->spec;
  5437. int err;
  5438. hda_nid_t nid;
  5439. nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
  5440. if (nid) {
  5441. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5442. "Mic Boost",
  5443. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5444. if (err < 0)
  5445. return err;
  5446. }
  5447. nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
  5448. if (nid) {
  5449. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5450. "Front Mic Boost",
  5451. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5452. if (err < 0)
  5453. return err;
  5454. }
  5455. return 0;
  5456. }
  5457. /* almost identical with ALC880 parser... */
  5458. static int alc882_parse_auto_config(struct hda_codec *codec)
  5459. {
  5460. struct alc_spec *spec = codec->spec;
  5461. int err = alc880_parse_auto_config(codec);
  5462. if (err < 0)
  5463. return err;
  5464. else if (!err)
  5465. return 0; /* no config found */
  5466. err = alc_auto_add_mic_boost(codec);
  5467. if (err < 0)
  5468. return err;
  5469. /* hack - override the init verbs */
  5470. spec->init_verbs[0] = alc882_auto_init_verbs;
  5471. return 1; /* config found */
  5472. }
  5473. /* additional initialization for auto-configuration model */
  5474. static void alc882_auto_init(struct hda_codec *codec)
  5475. {
  5476. alc882_auto_init_multi_out(codec);
  5477. alc882_auto_init_hp_out(codec);
  5478. alc882_auto_init_analog_input(codec);
  5479. }
  5480. static int patch_alc882(struct hda_codec *codec)
  5481. {
  5482. struct alc_spec *spec;
  5483. int err, board_config;
  5484. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5485. if (spec == NULL)
  5486. return -ENOMEM;
  5487. codec->spec = spec;
  5488. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5489. alc882_models,
  5490. alc882_cfg_tbl);
  5491. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5492. /* Pick up systems that don't supply PCI SSID */
  5493. switch (codec->subsystem_id) {
  5494. case 0x106b0c00: /* Mac Pro */
  5495. board_config = ALC885_MACPRO;
  5496. break;
  5497. case 0x106b1000: /* iMac 24 */
  5498. board_config = ALC885_IMAC24;
  5499. break;
  5500. case 0x106b2c00: /* Macbook Pro rev3 */
  5501. board_config = ALC885_MBP3;
  5502. break;
  5503. default:
  5504. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5505. "trying auto-probe from BIOS...\n");
  5506. board_config = ALC882_AUTO;
  5507. }
  5508. }
  5509. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5510. if (board_config == ALC882_AUTO) {
  5511. /* automatic parse from the BIOS config */
  5512. err = alc882_parse_auto_config(codec);
  5513. if (err < 0) {
  5514. alc_free(codec);
  5515. return err;
  5516. } else if (!err) {
  5517. printk(KERN_INFO
  5518. "hda_codec: Cannot set up configuration "
  5519. "from BIOS. Using base mode...\n");
  5520. board_config = ALC882_3ST_DIG;
  5521. }
  5522. }
  5523. if (board_config != ALC882_AUTO)
  5524. setup_preset(spec, &alc882_presets[board_config]);
  5525. spec->stream_name_analog = "ALC882 Analog";
  5526. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5527. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5528. spec->stream_name_digital = "ALC882 Digital";
  5529. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5530. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5531. if (!spec->adc_nids && spec->input_mux) {
  5532. /* check whether NID 0x07 is valid */
  5533. unsigned int wcap = get_wcaps(codec, 0x07);
  5534. /* get type */
  5535. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5536. if (wcap != AC_WID_AUD_IN) {
  5537. spec->adc_nids = alc882_adc_nids_alt;
  5538. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5539. spec->mixers[spec->num_mixers] =
  5540. alc882_capture_alt_mixer;
  5541. spec->num_mixers++;
  5542. } else {
  5543. spec->adc_nids = alc882_adc_nids;
  5544. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5545. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5546. spec->num_mixers++;
  5547. }
  5548. }
  5549. codec->patch_ops = alc_patch_ops;
  5550. if (board_config == ALC882_AUTO)
  5551. spec->init_hook = alc882_auto_init;
  5552. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5553. if (!spec->loopback.amplist)
  5554. spec->loopback.amplist = alc882_loopbacks;
  5555. #endif
  5556. return 0;
  5557. }
  5558. /*
  5559. * ALC883 support
  5560. *
  5561. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5562. * configuration. Each pin widget can choose any input DACs and a mixer.
  5563. * Each ADC is connected from a mixer of all inputs. This makes possible
  5564. * 6-channel independent captures.
  5565. *
  5566. * In addition, an independent DAC for the multi-playback (not used in this
  5567. * driver yet).
  5568. */
  5569. #define ALC883_DIGOUT_NID 0x06
  5570. #define ALC883_DIGIN_NID 0x0a
  5571. static hda_nid_t alc883_dac_nids[4] = {
  5572. /* front, rear, clfe, rear_surr */
  5573. 0x02, 0x04, 0x03, 0x05
  5574. };
  5575. static hda_nid_t alc883_adc_nids[2] = {
  5576. /* ADC1-2 */
  5577. 0x08, 0x09,
  5578. };
  5579. /* input MUX */
  5580. /* FIXME: should be a matrix-type input source selection */
  5581. static struct hda_input_mux alc883_capture_source = {
  5582. .num_items = 4,
  5583. .items = {
  5584. { "Mic", 0x0 },
  5585. { "Front Mic", 0x1 },
  5586. { "Line", 0x2 },
  5587. { "CD", 0x4 },
  5588. },
  5589. };
  5590. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5591. .num_items = 2,
  5592. .items = {
  5593. { "Mic", 0x1 },
  5594. { "Line", 0x2 },
  5595. },
  5596. };
  5597. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5598. .num_items = 4,
  5599. .items = {
  5600. { "Mic", 0x0 },
  5601. { "iMic", 0x1 },
  5602. { "Line", 0x2 },
  5603. { "CD", 0x4 },
  5604. },
  5605. };
  5606. #define alc883_mux_enum_info alc_mux_enum_info
  5607. #define alc883_mux_enum_get alc_mux_enum_get
  5608. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5609. struct snd_ctl_elem_value *ucontrol)
  5610. {
  5611. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5612. struct alc_spec *spec = codec->spec;
  5613. const struct hda_input_mux *imux = spec->input_mux;
  5614. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5615. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5616. hda_nid_t nid = capture_mixers[adc_idx];
  5617. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5618. unsigned int i, idx;
  5619. idx = ucontrol->value.enumerated.item[0];
  5620. if (idx >= imux->num_items)
  5621. idx = imux->num_items - 1;
  5622. if (*cur_val == idx)
  5623. return 0;
  5624. for (i = 0; i < imux->num_items; i++) {
  5625. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5626. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5627. imux->items[i].index,
  5628. HDA_AMP_MUTE, v);
  5629. }
  5630. *cur_val = idx;
  5631. return 1;
  5632. }
  5633. /*
  5634. * 2ch mode
  5635. */
  5636. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5637. { 2, NULL }
  5638. };
  5639. /*
  5640. * 2ch mode
  5641. */
  5642. static struct hda_verb alc883_3ST_ch2_init[] = {
  5643. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5644. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5645. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5646. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5647. { } /* end */
  5648. };
  5649. /*
  5650. * 4ch mode
  5651. */
  5652. static struct hda_verb alc883_3ST_ch4_init[] = {
  5653. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5654. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5655. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5656. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5657. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5658. { } /* end */
  5659. };
  5660. /*
  5661. * 6ch mode
  5662. */
  5663. static struct hda_verb alc883_3ST_ch6_init[] = {
  5664. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5665. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5666. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5667. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5668. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5669. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5670. { } /* end */
  5671. };
  5672. static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
  5673. { 2, alc883_3ST_ch2_init },
  5674. { 4, alc883_3ST_ch4_init },
  5675. { 6, alc883_3ST_ch6_init },
  5676. };
  5677. /*
  5678. * 6ch mode
  5679. */
  5680. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5681. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5682. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5683. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5684. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5685. { } /* end */
  5686. };
  5687. /*
  5688. * 8ch mode
  5689. */
  5690. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5691. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5692. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5693. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5694. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5695. { } /* end */
  5696. };
  5697. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5698. { 6, alc883_sixstack_ch6_init },
  5699. { 8, alc883_sixstack_ch8_init },
  5700. };
  5701. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5702. /* eanable EAPD on medion laptop */
  5703. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5704. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5705. { }
  5706. };
  5707. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5708. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5709. */
  5710. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5711. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5712. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5713. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5714. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5715. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5716. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5717. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5718. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5719. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5720. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5721. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5722. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5723. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5724. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5725. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5726. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5727. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5728. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5729. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5730. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5731. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5732. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5733. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5734. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5735. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5736. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5737. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5738. {
  5739. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5740. /* .name = "Capture Source", */
  5741. .name = "Input Source",
  5742. .count = 2,
  5743. .info = alc883_mux_enum_info,
  5744. .get = alc883_mux_enum_get,
  5745. .put = alc883_mux_enum_put,
  5746. },
  5747. { } /* end */
  5748. };
  5749. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5750. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5751. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5752. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5753. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5754. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5755. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5756. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5757. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5758. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5759. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5760. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5761. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5762. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5763. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5764. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5765. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5766. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5767. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5768. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5769. {
  5770. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5771. /* .name = "Capture Source", */
  5772. .name = "Input Source",
  5773. .count = 2,
  5774. .info = alc883_mux_enum_info,
  5775. .get = alc883_mux_enum_get,
  5776. .put = alc883_mux_enum_put,
  5777. },
  5778. { } /* end */
  5779. };
  5780. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5781. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5782. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5783. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5784. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5785. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5786. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5787. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5788. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5789. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5790. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5791. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5792. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5793. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5794. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5795. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5796. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5797. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5798. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5799. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5800. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5801. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5802. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5803. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5804. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5805. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5806. {
  5807. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5808. /* .name = "Capture Source", */
  5809. .name = "Input Source",
  5810. .count = 2,
  5811. .info = alc883_mux_enum_info,
  5812. .get = alc883_mux_enum_get,
  5813. .put = alc883_mux_enum_put,
  5814. },
  5815. { } /* end */
  5816. };
  5817. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5818. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5819. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5820. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5821. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5822. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5823. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5824. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5825. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5826. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5827. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5828. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5829. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5830. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5831. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5832. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5833. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5834. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5835. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5836. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5837. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5838. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5839. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5840. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5841. {
  5842. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5843. /* .name = "Capture Source", */
  5844. .name = "Input Source",
  5845. .count = 1,
  5846. .info = alc883_mux_enum_info,
  5847. .get = alc883_mux_enum_get,
  5848. .put = alc883_mux_enum_put,
  5849. },
  5850. { } /* end */
  5851. };
  5852. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5853. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5854. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5855. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5856. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5857. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5858. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5859. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5860. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5861. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5862. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5863. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5864. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5865. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5866. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5867. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5868. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5869. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5870. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5871. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5872. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5873. {
  5874. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5875. /* .name = "Capture Source", */
  5876. .name = "Input Source",
  5877. .count = 2,
  5878. .info = alc883_mux_enum_info,
  5879. .get = alc883_mux_enum_get,
  5880. .put = alc883_mux_enum_put,
  5881. },
  5882. { } /* end */
  5883. };
  5884. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5885. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5886. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5887. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5888. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5889. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5890. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5891. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5892. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5893. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5894. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5895. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5896. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5897. {
  5898. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5899. /* .name = "Capture Source", */
  5900. .name = "Input Source",
  5901. .count = 2,
  5902. .info = alc883_mux_enum_info,
  5903. .get = alc883_mux_enum_get,
  5904. .put = alc883_mux_enum_put,
  5905. },
  5906. { } /* end */
  5907. };
  5908. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5909. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5910. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5911. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5912. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5913. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5914. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5915. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5916. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5917. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5918. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5919. {
  5920. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5921. /* .name = "Capture Source", */
  5922. .name = "Input Source",
  5923. .count = 1,
  5924. .info = alc883_mux_enum_info,
  5925. .get = alc883_mux_enum_get,
  5926. .put = alc883_mux_enum_put,
  5927. },
  5928. { } /* end */
  5929. };
  5930. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5931. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5932. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5933. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5934. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5935. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5936. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5937. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5938. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5939. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5940. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5941. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5942. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5943. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5944. {
  5945. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5946. /* .name = "Capture Source", */
  5947. .name = "Input Source",
  5948. .count = 2,
  5949. .info = alc883_mux_enum_info,
  5950. .get = alc883_mux_enum_get,
  5951. .put = alc883_mux_enum_put,
  5952. },
  5953. { } /* end */
  5954. };
  5955. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5956. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5957. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5958. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5959. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5960. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5961. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5962. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5963. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5964. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5965. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5966. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5967. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5968. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5969. {
  5970. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5971. /* .name = "Capture Source", */
  5972. .name = "Input Source",
  5973. .count = 2,
  5974. .info = alc883_mux_enum_info,
  5975. .get = alc883_mux_enum_get,
  5976. .put = alc883_mux_enum_put,
  5977. },
  5978. { } /* end */
  5979. };
  5980. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5981. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5982. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5983. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5984. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5985. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5986. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5987. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5988. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5989. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5990. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5991. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5992. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5993. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5994. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5995. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5996. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5997. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5998. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5999. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  6000. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6001. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6002. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6003. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6004. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6005. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6006. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6007. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6008. {
  6009. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6010. /* .name = "Capture Source", */
  6011. .name = "Input Source",
  6012. .count = 2,
  6013. .info = alc883_mux_enum_info,
  6014. .get = alc883_mux_enum_get,
  6015. .put = alc883_mux_enum_put,
  6016. },
  6017. { } /* end */
  6018. };
  6019. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  6020. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6021. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6022. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  6023. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  6024. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  6025. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  6026. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  6027. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  6028. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6029. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6030. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6031. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6032. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6033. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6034. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6035. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6036. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  6037. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6038. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6039. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6040. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6041. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6042. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6043. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6044. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6045. {
  6046. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6047. /* .name = "Capture Source", */
  6048. .name = "Input Source",
  6049. .count = 2,
  6050. .info = alc883_mux_enum_info,
  6051. .get = alc883_mux_enum_get,
  6052. .put = alc883_mux_enum_put,
  6053. },
  6054. { } /* end */
  6055. };
  6056. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  6057. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6058. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6059. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6060. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6061. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6062. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6063. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6064. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6065. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6066. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6067. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6068. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6069. {
  6070. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6071. /* .name = "Capture Source", */
  6072. .name = "Input Source",
  6073. .count = 2,
  6074. .info = alc883_mux_enum_info,
  6075. .get = alc883_mux_enum_get,
  6076. .put = alc883_mux_enum_put,
  6077. },
  6078. { } /* end */
  6079. };
  6080. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  6081. {
  6082. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6083. .name = "Channel Mode",
  6084. .info = alc_ch_mode_info,
  6085. .get = alc_ch_mode_get,
  6086. .put = alc_ch_mode_put,
  6087. },
  6088. { } /* end */
  6089. };
  6090. static struct hda_verb alc883_init_verbs[] = {
  6091. /* ADC1: mute amp left and right */
  6092. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6093. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6094. /* ADC2: mute amp left and right */
  6095. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6096. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6097. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  6098. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6099. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6100. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6101. /* Rear mixer */
  6102. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6103. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6104. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6105. /* CLFE mixer */
  6106. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6107. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6108. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6109. /* Side mixer */
  6110. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6111. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6112. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6113. /* mute analog input loopbacks */
  6114. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6115. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6116. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6117. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6118. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6119. /* Front Pin: output 0 (0x0c) */
  6120. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6121. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6122. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6123. /* Rear Pin: output 1 (0x0d) */
  6124. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6125. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6126. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6127. /* CLFE Pin: output 2 (0x0e) */
  6128. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6129. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6130. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  6131. /* Side Pin: output 3 (0x0f) */
  6132. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6133. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6134. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  6135. /* Mic (rear) pin: input vref at 80% */
  6136. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6137. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6138. /* Front Mic pin: input vref at 80% */
  6139. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6140. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6141. /* Line In pin: input */
  6142. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6143. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6144. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  6145. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6146. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6147. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6148. /* CD pin widget for input */
  6149. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6150. /* FIXME: use matrix-type input source selection */
  6151. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6152. /* Input mixer2 */
  6153. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6154. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6155. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6156. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6157. /* Input mixer3 */
  6158. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6159. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6160. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6161. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6162. { }
  6163. };
  6164. static struct hda_verb alc883_tagra_verbs[] = {
  6165. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6166. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6167. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6168. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6169. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  6170. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  6171. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  6172. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6173. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  6174. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  6175. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  6176. { } /* end */
  6177. };
  6178. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  6179. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6180. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  6181. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  6182. { } /* end */
  6183. };
  6184. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  6185. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6186. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6187. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6188. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6189. { } /* end */
  6190. };
  6191. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  6192. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6193. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6194. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6195. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  6196. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6197. { } /* end */
  6198. };
  6199. static struct hda_verb alc883_haier_w66_verbs[] = {
  6200. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6201. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6202. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6203. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6204. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6205. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6206. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6207. { } /* end */
  6208. };
  6209. static struct hda_verb alc888_6st_hp_verbs[] = {
  6210. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6211. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  6212. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  6213. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  6214. { }
  6215. };
  6216. static struct hda_verb alc888_3st_hp_verbs[] = {
  6217. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6218. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  6219. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  6220. { }
  6221. };
  6222. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  6223. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  6224. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6225. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  6226. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6227. { }
  6228. };
  6229. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  6230. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6231. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6232. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6233. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6234. { }
  6235. };
  6236. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  6237. { 2, alc888_3st_hp_2ch_init },
  6238. { 6, alc888_3st_hp_6ch_init },
  6239. };
  6240. /* toggle front-jack and RCA according to the hp-jack state */
  6241. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6242. {
  6243. unsigned int present;
  6244. present = snd_hda_codec_read(codec, 0x1b, 0,
  6245. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6246. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6247. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6248. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6249. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6250. }
  6251. /* toggle RCA according to the front-jack state */
  6252. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6253. {
  6254. unsigned int present;
  6255. present = snd_hda_codec_read(codec, 0x14, 0,
  6256. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6257. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6258. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6259. }
  6260. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6261. unsigned int res)
  6262. {
  6263. if ((res >> 26) == ALC880_HP_EVENT)
  6264. alc888_lenovo_ms7195_front_automute(codec);
  6265. if ((res >> 26) == ALC880_FRONT_EVENT)
  6266. alc888_lenovo_ms7195_rca_automute(codec);
  6267. }
  6268. static struct hda_verb alc883_medion_md2_verbs[] = {
  6269. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6270. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6271. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6272. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6273. { } /* end */
  6274. };
  6275. /* toggle speaker-output according to the hp-jack state */
  6276. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6277. {
  6278. unsigned int present;
  6279. present = snd_hda_codec_read(codec, 0x14, 0,
  6280. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6281. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6282. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6283. }
  6284. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6285. unsigned int res)
  6286. {
  6287. if ((res >> 26) == ALC880_HP_EVENT)
  6288. alc883_medion_md2_automute(codec);
  6289. }
  6290. /* toggle speaker-output according to the hp-jack state */
  6291. static void alc883_tagra_automute(struct hda_codec *codec)
  6292. {
  6293. unsigned int present;
  6294. unsigned char bits;
  6295. present = snd_hda_codec_read(codec, 0x14, 0,
  6296. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6297. bits = present ? HDA_AMP_MUTE : 0;
  6298. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6299. HDA_AMP_MUTE, bits);
  6300. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6301. present ? 1 : 3);
  6302. }
  6303. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6304. {
  6305. if ((res >> 26) == ALC880_HP_EVENT)
  6306. alc883_tagra_automute(codec);
  6307. }
  6308. static void alc883_haier_w66_automute(struct hda_codec *codec)
  6309. {
  6310. unsigned int present;
  6311. unsigned char bits;
  6312. present = snd_hda_codec_read(codec, 0x1b, 0,
  6313. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6314. bits = present ? 0x80 : 0;
  6315. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6316. 0x80, bits);
  6317. }
  6318. static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
  6319. unsigned int res)
  6320. {
  6321. if ((res >> 26) == ALC880_HP_EVENT)
  6322. alc883_haier_w66_automute(codec);
  6323. }
  6324. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6325. {
  6326. unsigned int present;
  6327. unsigned char bits;
  6328. present = snd_hda_codec_read(codec, 0x14, 0,
  6329. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6330. bits = present ? HDA_AMP_MUTE : 0;
  6331. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6332. HDA_AMP_MUTE, bits);
  6333. }
  6334. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6335. {
  6336. unsigned int present;
  6337. unsigned char bits;
  6338. present = snd_hda_codec_read(codec, 0x1b, 0,
  6339. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6340. bits = present ? HDA_AMP_MUTE : 0;
  6341. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6342. HDA_AMP_MUTE, bits);
  6343. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6344. HDA_AMP_MUTE, bits);
  6345. }
  6346. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6347. unsigned int res)
  6348. {
  6349. if ((res >> 26) == ALC880_HP_EVENT)
  6350. alc883_lenovo_101e_all_automute(codec);
  6351. if ((res >> 26) == ALC880_FRONT_EVENT)
  6352. alc883_lenovo_101e_ispeaker_automute(codec);
  6353. }
  6354. /* toggle speaker-output according to the hp-jack state */
  6355. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6356. {
  6357. unsigned int present;
  6358. present = snd_hda_codec_read(codec, 0x14, 0,
  6359. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6360. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6361. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6362. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6363. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6364. }
  6365. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6366. unsigned int res)
  6367. {
  6368. if ((res >> 26) == ALC880_HP_EVENT)
  6369. alc883_acer_aspire_automute(codec);
  6370. }
  6371. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6372. /* HP Pin: output 0 (0x0c) */
  6373. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6374. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6375. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6376. /* Front Pin: output 0 (0x0c) */
  6377. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6378. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6379. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6380. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6381. /* eanable EAPD on medion laptop */
  6382. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6383. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6384. /* enable unsolicited event */
  6385. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6386. { }
  6387. };
  6388. /*
  6389. * generic initialization of ADC, input mixers and output mixers
  6390. */
  6391. static struct hda_verb alc883_auto_init_verbs[] = {
  6392. /*
  6393. * Unmute ADC0-2 and set the default input to mic-in
  6394. */
  6395. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6396. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6397. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6398. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6399. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6400. * mixer widget
  6401. * Note: PASD motherboards uses the Line In 2 as the input for
  6402. * front panel mic (mic 2)
  6403. */
  6404. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6405. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6406. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6407. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6408. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6409. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6410. /*
  6411. * Set up output mixers (0x0c - 0x0f)
  6412. */
  6413. /* set vol=0 to output mixers */
  6414. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6415. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6416. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6417. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6418. /* set up input amps for analog loopback */
  6419. /* Amp Indices: DAC = 0, mixer = 1 */
  6420. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6421. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6422. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6423. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6424. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6425. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6426. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6427. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6428. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6429. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6430. /* FIXME: use matrix-type input source selection */
  6431. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6432. /* Input mixer1 */
  6433. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6434. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6435. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6436. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6437. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6438. /* Input mixer2 */
  6439. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6440. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6441. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6442. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6443. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6444. { }
  6445. };
  6446. /* capture mixer elements */
  6447. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6448. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6449. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6450. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6451. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6452. {
  6453. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6454. /* The multiple "Capture Source" controls confuse alsamixer
  6455. * So call somewhat different..
  6456. * FIXME: the controls appear in the "playback" view!
  6457. */
  6458. /* .name = "Capture Source", */
  6459. .name = "Input Source",
  6460. .count = 2,
  6461. .info = alc882_mux_enum_info,
  6462. .get = alc882_mux_enum_get,
  6463. .put = alc882_mux_enum_put,
  6464. },
  6465. { } /* end */
  6466. };
  6467. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6468. #define alc883_loopbacks alc880_loopbacks
  6469. #endif
  6470. /* pcm configuration: identiacal with ALC880 */
  6471. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6472. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6473. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6474. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6475. /*
  6476. * configuration and preset
  6477. */
  6478. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6479. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6480. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6481. [ALC883_3ST_6ch] = "3stack-6ch",
  6482. [ALC883_6ST_DIG] = "6stack-dig",
  6483. [ALC883_TARGA_DIG] = "targa-dig",
  6484. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6485. [ALC883_ACER] = "acer",
  6486. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6487. [ALC883_MEDION] = "medion",
  6488. [ALC883_MEDION_MD2] = "medion-md2",
  6489. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6490. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6491. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6492. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6493. [ALC883_HAIER_W66] = "haier-w66",
  6494. [ALC888_6ST_HP] = "6stack-hp",
  6495. [ALC888_3ST_HP] = "3stack-hp",
  6496. [ALC883_AUTO] = "auto",
  6497. };
  6498. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6499. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6500. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6501. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6502. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6503. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6504. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6505. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6506. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6507. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6508. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6509. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6510. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6511. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6512. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6513. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6514. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6515. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6516. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6517. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6518. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6519. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6520. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6521. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6522. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6523. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6524. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6525. SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
  6526. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6527. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6528. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6529. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6530. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6531. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6532. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6533. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6534. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6535. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6536. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6537. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6538. SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
  6539. SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6540. SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
  6541. SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
  6542. {}
  6543. };
  6544. static struct alc_config_preset alc883_presets[] = {
  6545. [ALC883_3ST_2ch_DIG] = {
  6546. .mixers = { alc883_3ST_2ch_mixer },
  6547. .init_verbs = { alc883_init_verbs },
  6548. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6549. .dac_nids = alc883_dac_nids,
  6550. .dig_out_nid = ALC883_DIGOUT_NID,
  6551. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6552. .adc_nids = alc883_adc_nids,
  6553. .dig_in_nid = ALC883_DIGIN_NID,
  6554. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6555. .channel_mode = alc883_3ST_2ch_modes,
  6556. .input_mux = &alc883_capture_source,
  6557. },
  6558. [ALC883_3ST_6ch_DIG] = {
  6559. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6560. .init_verbs = { alc883_init_verbs },
  6561. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6562. .dac_nids = alc883_dac_nids,
  6563. .dig_out_nid = ALC883_DIGOUT_NID,
  6564. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6565. .adc_nids = alc883_adc_nids,
  6566. .dig_in_nid = ALC883_DIGIN_NID,
  6567. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6568. .channel_mode = alc883_3ST_6ch_modes,
  6569. .need_dac_fix = 1,
  6570. .input_mux = &alc883_capture_source,
  6571. },
  6572. [ALC883_3ST_6ch] = {
  6573. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6574. .init_verbs = { alc883_init_verbs },
  6575. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6576. .dac_nids = alc883_dac_nids,
  6577. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6578. .adc_nids = alc883_adc_nids,
  6579. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6580. .channel_mode = alc883_3ST_6ch_modes,
  6581. .need_dac_fix = 1,
  6582. .input_mux = &alc883_capture_source,
  6583. },
  6584. [ALC883_6ST_DIG] = {
  6585. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6586. .init_verbs = { alc883_init_verbs },
  6587. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6588. .dac_nids = alc883_dac_nids,
  6589. .dig_out_nid = ALC883_DIGOUT_NID,
  6590. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6591. .adc_nids = alc883_adc_nids,
  6592. .dig_in_nid = ALC883_DIGIN_NID,
  6593. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6594. .channel_mode = alc883_sixstack_modes,
  6595. .input_mux = &alc883_capture_source,
  6596. },
  6597. [ALC883_TARGA_DIG] = {
  6598. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6599. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6600. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6601. .dac_nids = alc883_dac_nids,
  6602. .dig_out_nid = ALC883_DIGOUT_NID,
  6603. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6604. .adc_nids = alc883_adc_nids,
  6605. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6606. .channel_mode = alc883_3ST_6ch_modes,
  6607. .need_dac_fix = 1,
  6608. .input_mux = &alc883_capture_source,
  6609. .unsol_event = alc883_tagra_unsol_event,
  6610. .init_hook = alc883_tagra_automute,
  6611. },
  6612. [ALC883_TARGA_2ch_DIG] = {
  6613. .mixers = { alc883_tagra_2ch_mixer},
  6614. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6615. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6616. .dac_nids = alc883_dac_nids,
  6617. .dig_out_nid = ALC883_DIGOUT_NID,
  6618. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6619. .adc_nids = alc883_adc_nids,
  6620. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6621. .channel_mode = alc883_3ST_2ch_modes,
  6622. .input_mux = &alc883_capture_source,
  6623. .unsol_event = alc883_tagra_unsol_event,
  6624. .init_hook = alc883_tagra_automute,
  6625. },
  6626. [ALC883_ACER] = {
  6627. .mixers = { alc883_base_mixer },
  6628. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6629. * and the headphone jack. Turn this on and rely on the
  6630. * standard mute methods whenever the user wants to turn
  6631. * these outputs off.
  6632. */
  6633. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6634. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6635. .dac_nids = alc883_dac_nids,
  6636. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6637. .adc_nids = alc883_adc_nids,
  6638. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6639. .channel_mode = alc883_3ST_2ch_modes,
  6640. .input_mux = &alc883_capture_source,
  6641. },
  6642. [ALC883_ACER_ASPIRE] = {
  6643. .mixers = { alc883_acer_aspire_mixer },
  6644. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6645. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6646. .dac_nids = alc883_dac_nids,
  6647. .dig_out_nid = ALC883_DIGOUT_NID,
  6648. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6649. .adc_nids = alc883_adc_nids,
  6650. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6651. .channel_mode = alc883_3ST_2ch_modes,
  6652. .input_mux = &alc883_capture_source,
  6653. .unsol_event = alc883_acer_aspire_unsol_event,
  6654. .init_hook = alc883_acer_aspire_automute,
  6655. },
  6656. [ALC883_MEDION] = {
  6657. .mixers = { alc883_fivestack_mixer,
  6658. alc883_chmode_mixer },
  6659. .init_verbs = { alc883_init_verbs,
  6660. alc883_medion_eapd_verbs },
  6661. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6662. .dac_nids = alc883_dac_nids,
  6663. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6664. .adc_nids = alc883_adc_nids,
  6665. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6666. .channel_mode = alc883_sixstack_modes,
  6667. .input_mux = &alc883_capture_source,
  6668. },
  6669. [ALC883_MEDION_MD2] = {
  6670. .mixers = { alc883_medion_md2_mixer},
  6671. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6672. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6673. .dac_nids = alc883_dac_nids,
  6674. .dig_out_nid = ALC883_DIGOUT_NID,
  6675. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6676. .adc_nids = alc883_adc_nids,
  6677. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6678. .channel_mode = alc883_3ST_2ch_modes,
  6679. .input_mux = &alc883_capture_source,
  6680. .unsol_event = alc883_medion_md2_unsol_event,
  6681. .init_hook = alc883_medion_md2_automute,
  6682. },
  6683. [ALC883_LAPTOP_EAPD] = {
  6684. .mixers = { alc883_base_mixer },
  6685. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6686. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6687. .dac_nids = alc883_dac_nids,
  6688. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6689. .adc_nids = alc883_adc_nids,
  6690. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6691. .channel_mode = alc883_3ST_2ch_modes,
  6692. .input_mux = &alc883_capture_source,
  6693. },
  6694. [ALC883_LENOVO_101E_2ch] = {
  6695. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6696. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6697. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6698. .dac_nids = alc883_dac_nids,
  6699. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6700. .adc_nids = alc883_adc_nids,
  6701. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6702. .channel_mode = alc883_3ST_2ch_modes,
  6703. .input_mux = &alc883_lenovo_101e_capture_source,
  6704. .unsol_event = alc883_lenovo_101e_unsol_event,
  6705. .init_hook = alc883_lenovo_101e_all_automute,
  6706. },
  6707. [ALC883_LENOVO_NB0763] = {
  6708. .mixers = { alc883_lenovo_nb0763_mixer },
  6709. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6710. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6711. .dac_nids = alc883_dac_nids,
  6712. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6713. .adc_nids = alc883_adc_nids,
  6714. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6715. .channel_mode = alc883_3ST_2ch_modes,
  6716. .need_dac_fix = 1,
  6717. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6718. .unsol_event = alc883_medion_md2_unsol_event,
  6719. .init_hook = alc883_medion_md2_automute,
  6720. },
  6721. [ALC888_LENOVO_MS7195_DIG] = {
  6722. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6723. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6724. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6725. .dac_nids = alc883_dac_nids,
  6726. .dig_out_nid = ALC883_DIGOUT_NID,
  6727. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6728. .adc_nids = alc883_adc_nids,
  6729. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6730. .channel_mode = alc883_3ST_6ch_modes,
  6731. .need_dac_fix = 1,
  6732. .input_mux = &alc883_capture_source,
  6733. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6734. .init_hook = alc888_lenovo_ms7195_front_automute,
  6735. },
  6736. [ALC883_HAIER_W66] = {
  6737. .mixers = { alc883_tagra_2ch_mixer},
  6738. .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
  6739. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6740. .dac_nids = alc883_dac_nids,
  6741. .dig_out_nid = ALC883_DIGOUT_NID,
  6742. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6743. .adc_nids = alc883_adc_nids,
  6744. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6745. .channel_mode = alc883_3ST_2ch_modes,
  6746. .input_mux = &alc883_capture_source,
  6747. .unsol_event = alc883_haier_w66_unsol_event,
  6748. .init_hook = alc883_haier_w66_automute,
  6749. },
  6750. [ALC888_6ST_HP] = {
  6751. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6752. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6753. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6754. .dac_nids = alc883_dac_nids,
  6755. .dig_out_nid = ALC883_DIGOUT_NID,
  6756. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6757. .adc_nids = alc883_adc_nids,
  6758. .dig_in_nid = ALC883_DIGIN_NID,
  6759. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6760. .channel_mode = alc883_sixstack_modes,
  6761. .input_mux = &alc883_capture_source,
  6762. },
  6763. [ALC888_3ST_HP] = {
  6764. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6765. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6766. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6767. .dac_nids = alc883_dac_nids,
  6768. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6769. .adc_nids = alc883_adc_nids,
  6770. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6771. .channel_mode = alc888_3st_hp_modes,
  6772. .need_dac_fix = 1,
  6773. .input_mux = &alc883_capture_source,
  6774. },
  6775. };
  6776. /*
  6777. * BIOS auto configuration
  6778. */
  6779. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6780. hda_nid_t nid, int pin_type,
  6781. int dac_idx)
  6782. {
  6783. /* set as output */
  6784. struct alc_spec *spec = codec->spec;
  6785. int idx;
  6786. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6787. idx = 4;
  6788. else
  6789. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6790. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6791. pin_type);
  6792. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6793. AMP_OUT_UNMUTE);
  6794. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6795. }
  6796. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6797. {
  6798. struct alc_spec *spec = codec->spec;
  6799. int i;
  6800. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6801. for (i = 0; i <= HDA_SIDE; i++) {
  6802. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6803. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6804. if (nid)
  6805. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6806. i);
  6807. }
  6808. }
  6809. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6810. {
  6811. struct alc_spec *spec = codec->spec;
  6812. hda_nid_t pin;
  6813. pin = spec->autocfg.hp_pins[0];
  6814. if (pin) /* connect to front */
  6815. /* use dac 0 */
  6816. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6817. }
  6818. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6819. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6820. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6821. {
  6822. struct alc_spec *spec = codec->spec;
  6823. int i;
  6824. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6825. hda_nid_t nid = spec->autocfg.input_pins[i];
  6826. if (alc883_is_input_pin(nid)) {
  6827. snd_hda_codec_write(codec, nid, 0,
  6828. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6829. (i <= AUTO_PIN_FRONT_MIC ?
  6830. PIN_VREF80 : PIN_IN));
  6831. if (nid != ALC883_PIN_CD_NID)
  6832. snd_hda_codec_write(codec, nid, 0,
  6833. AC_VERB_SET_AMP_GAIN_MUTE,
  6834. AMP_OUT_MUTE);
  6835. }
  6836. }
  6837. }
  6838. /* almost identical with ALC880 parser... */
  6839. static int alc883_parse_auto_config(struct hda_codec *codec)
  6840. {
  6841. struct alc_spec *spec = codec->spec;
  6842. int err = alc880_parse_auto_config(codec);
  6843. if (err < 0)
  6844. return err;
  6845. else if (!err)
  6846. return 0; /* no config found */
  6847. err = alc_auto_add_mic_boost(codec);
  6848. if (err < 0)
  6849. return err;
  6850. /* hack - override the init verbs */
  6851. spec->init_verbs[0] = alc883_auto_init_verbs;
  6852. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6853. spec->num_mixers++;
  6854. return 1; /* config found */
  6855. }
  6856. /* additional initialization for auto-configuration model */
  6857. static void alc883_auto_init(struct hda_codec *codec)
  6858. {
  6859. alc883_auto_init_multi_out(codec);
  6860. alc883_auto_init_hp_out(codec);
  6861. alc883_auto_init_analog_input(codec);
  6862. }
  6863. static int patch_alc883(struct hda_codec *codec)
  6864. {
  6865. struct alc_spec *spec;
  6866. int err, board_config;
  6867. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6868. if (spec == NULL)
  6869. return -ENOMEM;
  6870. codec->spec = spec;
  6871. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6872. alc883_models,
  6873. alc883_cfg_tbl);
  6874. if (board_config < 0) {
  6875. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6876. "trying auto-probe from BIOS...\n");
  6877. board_config = ALC883_AUTO;
  6878. }
  6879. if (board_config == ALC883_AUTO) {
  6880. /* automatic parse from the BIOS config */
  6881. err = alc883_parse_auto_config(codec);
  6882. if (err < 0) {
  6883. alc_free(codec);
  6884. return err;
  6885. } else if (!err) {
  6886. printk(KERN_INFO
  6887. "hda_codec: Cannot set up configuration "
  6888. "from BIOS. Using base mode...\n");
  6889. board_config = ALC883_3ST_2ch_DIG;
  6890. }
  6891. }
  6892. if (board_config != ALC883_AUTO)
  6893. setup_preset(spec, &alc883_presets[board_config]);
  6894. spec->stream_name_analog = "ALC883 Analog";
  6895. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6896. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6897. spec->stream_name_digital = "ALC883 Digital";
  6898. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6899. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6900. if (!spec->adc_nids && spec->input_mux) {
  6901. spec->adc_nids = alc883_adc_nids;
  6902. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6903. }
  6904. codec->patch_ops = alc_patch_ops;
  6905. if (board_config == ALC883_AUTO)
  6906. spec->init_hook = alc883_auto_init;
  6907. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6908. if (!spec->loopback.amplist)
  6909. spec->loopback.amplist = alc883_loopbacks;
  6910. #endif
  6911. return 0;
  6912. }
  6913. /*
  6914. * ALC262 support
  6915. */
  6916. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6917. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6918. #define alc262_dac_nids alc260_dac_nids
  6919. #define alc262_adc_nids alc882_adc_nids
  6920. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6921. #define alc262_modes alc260_modes
  6922. #define alc262_capture_source alc882_capture_source
  6923. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6924. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6925. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6926. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6927. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6928. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6929. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6930. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6931. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6932. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6933. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6934. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6935. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6936. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6937. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6938. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6939. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6940. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6941. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6942. { } /* end */
  6943. };
  6944. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6945. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6946. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6947. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6948. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6949. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6950. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6951. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6952. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6953. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6954. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6955. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6956. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6957. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6958. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6959. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6960. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6961. { } /* end */
  6962. };
  6963. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6964. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6965. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6966. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6967. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6968. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6969. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6970. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6971. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6972. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6973. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6974. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6975. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6976. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6977. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6978. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6979. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6980. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6981. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6982. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6983. { } /* end */
  6984. };
  6985. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6986. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6987. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6988. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6989. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6990. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6991. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6992. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6993. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6994. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6995. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6996. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6997. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6998. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6999. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7000. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7001. { } /* end */
  7002. };
  7003. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  7004. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7005. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7006. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  7007. { } /* end */
  7008. };
  7009. static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = {
  7010. .ops = &snd_hda_bind_vol,
  7011. .values = {
  7012. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7013. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7014. 0
  7015. },
  7016. };
  7017. static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = {
  7018. .ops = &snd_hda_bind_sw,
  7019. .values = {
  7020. HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7021. HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  7022. 0
  7023. },
  7024. };
  7025. /* mute/unmute internal speaker according to the hp jack and mute state */
  7026. static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
  7027. {
  7028. struct alc_spec *spec = codec->spec;
  7029. unsigned int mute;
  7030. if (force || !spec->sense_updated) {
  7031. unsigned int present;
  7032. present = snd_hda_codec_read(codec, 0x15, 0,
  7033. AC_VERB_GET_PIN_SENSE, 0);
  7034. spec->jack_present = (present & 0x80000000) != 0;
  7035. spec->sense_updated = 1;
  7036. }
  7037. if (spec->jack_present)
  7038. mute = (0x7080 | ((0)<<8)); /* mute internal speaker */
  7039. else /* unmute internal speaker if necessary */
  7040. mute = (0x7000 | ((0)<<8));
  7041. snd_hda_codec_write(codec, 0x0c, 0,
  7042. AC_VERB_SET_AMP_GAIN_MUTE, mute );
  7043. }
  7044. static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
  7045. unsigned int res)
  7046. {
  7047. if ((res >> 26) != ALC880_HP_EVENT)
  7048. return;
  7049. alc262_hp_t5735_automute(codec, 1);
  7050. }
  7051. static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
  7052. {
  7053. alc262_hp_t5735_automute(codec, 1);
  7054. }
  7055. static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
  7056. HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol),
  7057. HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw),
  7058. HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7059. HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7060. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7061. HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7062. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  7063. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7064. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7065. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7066. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7067. { } /* end */
  7068. };
  7069. static struct hda_verb alc262_hp_t5735_verbs[] = {
  7070. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7071. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7072. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7073. { }
  7074. };
  7075. /* bind hp and internal speaker mute (with plug check) */
  7076. static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
  7077. struct snd_ctl_elem_value *ucontrol)
  7078. {
  7079. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7080. long *valp = ucontrol->value.integer.value;
  7081. int change;
  7082. /* change hp mute */
  7083. change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  7084. HDA_AMP_MUTE,
  7085. valp[0] ? 0 : HDA_AMP_MUTE);
  7086. change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  7087. HDA_AMP_MUTE,
  7088. valp[1] ? 0 : HDA_AMP_MUTE);
  7089. if (change) {
  7090. /* change speaker according to HP jack state */
  7091. struct alc_spec *spec = codec->spec;
  7092. unsigned int mute;
  7093. if (spec->jack_present)
  7094. mute = HDA_AMP_MUTE;
  7095. else
  7096. mute = snd_hda_codec_amp_read(codec, 0x15, 0,
  7097. HDA_OUTPUT, 0);
  7098. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7099. HDA_AMP_MUTE, mute);
  7100. }
  7101. return change;
  7102. }
  7103. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  7104. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7105. {
  7106. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7107. .name = "Master Playback Switch",
  7108. .info = snd_hda_mixer_amp_switch_info,
  7109. .get = snd_hda_mixer_amp_switch_get,
  7110. .put = alc262_sony_master_sw_put,
  7111. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  7112. },
  7113. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7114. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7115. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7116. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7117. { } /* end */
  7118. };
  7119. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  7120. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7121. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7122. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7123. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7124. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7125. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7126. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7127. { } /* end */
  7128. };
  7129. #define alc262_capture_mixer alc882_capture_mixer
  7130. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  7131. /*
  7132. * generic initialization of ADC, input mixers and output mixers
  7133. */
  7134. static struct hda_verb alc262_init_verbs[] = {
  7135. /*
  7136. * Unmute ADC0-2 and set the default input to mic-in
  7137. */
  7138. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7139. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7140. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7141. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7142. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7143. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7144. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7145. * mixer widget
  7146. * Note: PASD motherboards uses the Line In 2 as the input for
  7147. * front panel mic (mic 2)
  7148. */
  7149. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7150. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7151. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7152. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7153. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7154. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7155. /*
  7156. * Set up output mixers (0x0c - 0x0e)
  7157. */
  7158. /* set vol=0 to output mixers */
  7159. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7160. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7161. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7162. /* set up input amps for analog loopback */
  7163. /* Amp Indices: DAC = 0, mixer = 1 */
  7164. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7165. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7166. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7167. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7168. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7169. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7170. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7171. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7172. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7173. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7174. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7175. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7176. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7177. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7178. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7179. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7180. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7181. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7182. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7183. /* FIXME: use matrix-type input source selection */
  7184. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7185. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7186. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7187. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7188. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7189. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7190. /* Input mixer2 */
  7191. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7192. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7193. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7194. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7195. /* Input mixer3 */
  7196. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7197. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7198. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7199. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7200. { }
  7201. };
  7202. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  7203. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7204. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7205. {}
  7206. };
  7207. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  7208. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7209. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7210. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7211. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7212. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7213. {}
  7214. };
  7215. static struct hda_verb alc262_sony_unsol_verbs[] = {
  7216. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7217. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7218. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  7219. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7220. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7221. };
  7222. /* mute/unmute internal speaker according to the hp jack and mute state */
  7223. static void alc262_hippo_automute(struct hda_codec *codec)
  7224. {
  7225. struct alc_spec *spec = codec->spec;
  7226. unsigned int mute;
  7227. unsigned int present;
  7228. /* need to execute and sync at first */
  7229. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7230. present = snd_hda_codec_read(codec, 0x15, 0,
  7231. AC_VERB_GET_PIN_SENSE, 0);
  7232. spec->jack_present = (present & 0x80000000) != 0;
  7233. if (spec->jack_present) {
  7234. /* mute internal speaker */
  7235. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7236. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7237. } else {
  7238. /* unmute internal speaker if necessary */
  7239. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7240. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7241. HDA_AMP_MUTE, mute);
  7242. }
  7243. }
  7244. /* unsolicited event for HP jack sensing */
  7245. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  7246. unsigned int res)
  7247. {
  7248. if ((res >> 26) != ALC880_HP_EVENT)
  7249. return;
  7250. alc262_hippo_automute(codec);
  7251. }
  7252. static void alc262_hippo1_automute(struct hda_codec *codec)
  7253. {
  7254. unsigned int mute;
  7255. unsigned int present;
  7256. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  7257. present = snd_hda_codec_read(codec, 0x1b, 0,
  7258. AC_VERB_GET_PIN_SENSE, 0);
  7259. present = (present & 0x80000000) != 0;
  7260. if (present) {
  7261. /* mute internal speaker */
  7262. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7263. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7264. } else {
  7265. /* unmute internal speaker if necessary */
  7266. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  7267. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7268. HDA_AMP_MUTE, mute);
  7269. }
  7270. }
  7271. /* unsolicited event for HP jack sensing */
  7272. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  7273. unsigned int res)
  7274. {
  7275. if ((res >> 26) != ALC880_HP_EVENT)
  7276. return;
  7277. alc262_hippo1_automute(codec);
  7278. }
  7279. /*
  7280. * fujitsu model
  7281. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  7282. */
  7283. #define ALC_HP_EVENT 0x37
  7284. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  7285. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  7286. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7287. {}
  7288. };
  7289. static struct hda_input_mux alc262_fujitsu_capture_source = {
  7290. .num_items = 3,
  7291. .items = {
  7292. { "Mic", 0x0 },
  7293. { "Int Mic", 0x1 },
  7294. { "CD", 0x4 },
  7295. },
  7296. };
  7297. static struct hda_input_mux alc262_HP_capture_source = {
  7298. .num_items = 5,
  7299. .items = {
  7300. { "Mic", 0x0 },
  7301. { "Front Mic", 0x1 },
  7302. { "Line", 0x2 },
  7303. { "CD", 0x4 },
  7304. { "AUX IN", 0x6 },
  7305. },
  7306. };
  7307. static struct hda_input_mux alc262_HP_D7000_capture_source = {
  7308. .num_items = 4,
  7309. .items = {
  7310. { "Mic", 0x0 },
  7311. { "Front Mic", 0x2 },
  7312. { "Line", 0x1 },
  7313. { "CD", 0x4 },
  7314. },
  7315. };
  7316. /* mute/unmute internal speaker according to the hp jack and mute state */
  7317. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  7318. {
  7319. struct alc_spec *spec = codec->spec;
  7320. unsigned int mute;
  7321. if (force || !spec->sense_updated) {
  7322. unsigned int present;
  7323. /* need to execute and sync at first */
  7324. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  7325. present = snd_hda_codec_read(codec, 0x14, 0,
  7326. AC_VERB_GET_PIN_SENSE, 0);
  7327. spec->jack_present = (present & 0x80000000) != 0;
  7328. spec->sense_updated = 1;
  7329. }
  7330. if (spec->jack_present) {
  7331. /* mute internal speaker */
  7332. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7333. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7334. } else {
  7335. /* unmute internal speaker if necessary */
  7336. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7337. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7338. HDA_AMP_MUTE, mute);
  7339. }
  7340. }
  7341. /* unsolicited event for HP jack sensing */
  7342. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  7343. unsigned int res)
  7344. {
  7345. if ((res >> 26) != ALC_HP_EVENT)
  7346. return;
  7347. alc262_fujitsu_automute(codec, 1);
  7348. }
  7349. /* bind volumes of both NID 0x0c and 0x0d */
  7350. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  7351. .ops = &snd_hda_bind_vol,
  7352. .values = {
  7353. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7354. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7355. 0
  7356. },
  7357. };
  7358. /* bind hp and internal speaker mute (with plug check) */
  7359. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  7360. struct snd_ctl_elem_value *ucontrol)
  7361. {
  7362. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7363. long *valp = ucontrol->value.integer.value;
  7364. int change;
  7365. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7366. HDA_AMP_MUTE,
  7367. valp[0] ? 0 : HDA_AMP_MUTE);
  7368. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7369. HDA_AMP_MUTE,
  7370. valp[1] ? 0 : HDA_AMP_MUTE);
  7371. if (change)
  7372. alc262_fujitsu_automute(codec, 0);
  7373. return change;
  7374. }
  7375. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  7376. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  7377. {
  7378. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7379. .name = "Master Playback Switch",
  7380. .info = snd_hda_mixer_amp_switch_info,
  7381. .get = snd_hda_mixer_amp_switch_get,
  7382. .put = alc262_fujitsu_master_sw_put,
  7383. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7384. },
  7385. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7386. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7387. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7388. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7389. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7390. HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
  7391. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7392. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7393. { } /* end */
  7394. };
  7395. /* additional init verbs for Benq laptops */
  7396. static struct hda_verb alc262_EAPD_verbs[] = {
  7397. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7398. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7399. {}
  7400. };
  7401. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7402. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7403. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7404. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7405. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7406. {}
  7407. };
  7408. /* Samsung Q1 Ultra Vista model setup */
  7409. static struct snd_kcontrol_new alc262_ultra_mixer[] = {
  7410. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7411. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7412. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7413. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7414. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7415. HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
  7416. { } /* end */
  7417. };
  7418. static struct hda_verb alc262_ultra_verbs[] = {
  7419. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7420. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7421. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7422. /* Mic is on Node 0x19 */
  7423. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7424. {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
  7425. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7426. {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
  7427. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7428. {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
  7429. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7430. {}
  7431. };
  7432. static struct hda_input_mux alc262_ultra_capture_source = {
  7433. .num_items = 1,
  7434. .items = {
  7435. { "Mic", 0x1 },
  7436. },
  7437. };
  7438. /* mute/unmute internal speaker according to the hp jack and mute state */
  7439. static void alc262_ultra_automute(struct hda_codec *codec)
  7440. {
  7441. struct alc_spec *spec = codec->spec;
  7442. unsigned int mute;
  7443. unsigned int present;
  7444. /* need to execute and sync at first */
  7445. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7446. present = snd_hda_codec_read(codec, 0x15, 0,
  7447. AC_VERB_GET_PIN_SENSE, 0);
  7448. spec->jack_present = (present & 0x80000000) != 0;
  7449. if (spec->jack_present) {
  7450. /* mute internal speaker */
  7451. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7452. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7453. } else {
  7454. /* unmute internal speaker if necessary */
  7455. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7456. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7457. HDA_AMP_MUTE, mute);
  7458. }
  7459. }
  7460. /* unsolicited event for HP jack sensing */
  7461. static void alc262_ultra_unsol_event(struct hda_codec *codec,
  7462. unsigned int res)
  7463. {
  7464. if ((res >> 26) != ALC880_HP_EVENT)
  7465. return;
  7466. alc262_ultra_automute(codec);
  7467. }
  7468. /* add playback controls from the parsed DAC table */
  7469. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7470. const struct auto_pin_cfg *cfg)
  7471. {
  7472. hda_nid_t nid;
  7473. int err;
  7474. spec->multiout.num_dacs = 1; /* only use one dac */
  7475. spec->multiout.dac_nids = spec->private_dac_nids;
  7476. spec->multiout.dac_nids[0] = 2;
  7477. nid = cfg->line_out_pins[0];
  7478. if (nid) {
  7479. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7480. "Front Playback Volume",
  7481. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7482. if (err < 0)
  7483. return err;
  7484. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7485. "Front Playback Switch",
  7486. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7487. if (err < 0)
  7488. return err;
  7489. }
  7490. nid = cfg->speaker_pins[0];
  7491. if (nid) {
  7492. if (nid == 0x16) {
  7493. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7494. "Speaker Playback Volume",
  7495. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7496. HDA_OUTPUT));
  7497. if (err < 0)
  7498. return err;
  7499. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7500. "Speaker Playback Switch",
  7501. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7502. HDA_OUTPUT));
  7503. if (err < 0)
  7504. return err;
  7505. } else {
  7506. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7507. "Speaker Playback Switch",
  7508. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7509. HDA_OUTPUT));
  7510. if (err < 0)
  7511. return err;
  7512. }
  7513. }
  7514. nid = cfg->hp_pins[0];
  7515. if (nid) {
  7516. /* spec->multiout.hp_nid = 2; */
  7517. if (nid == 0x16) {
  7518. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7519. "Headphone Playback Volume",
  7520. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7521. HDA_OUTPUT));
  7522. if (err < 0)
  7523. return err;
  7524. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7525. "Headphone Playback Switch",
  7526. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7527. HDA_OUTPUT));
  7528. if (err < 0)
  7529. return err;
  7530. } else {
  7531. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7532. "Headphone Playback Switch",
  7533. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7534. HDA_OUTPUT));
  7535. if (err < 0)
  7536. return err;
  7537. }
  7538. }
  7539. return 0;
  7540. }
  7541. /* identical with ALC880 */
  7542. #define alc262_auto_create_analog_input_ctls \
  7543. alc880_auto_create_analog_input_ctls
  7544. /*
  7545. * generic initialization of ADC, input mixers and output mixers
  7546. */
  7547. static struct hda_verb alc262_volume_init_verbs[] = {
  7548. /*
  7549. * Unmute ADC0-2 and set the default input to mic-in
  7550. */
  7551. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7552. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7553. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7554. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7555. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7556. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7557. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7558. * mixer widget
  7559. * Note: PASD motherboards uses the Line In 2 as the input for
  7560. * front panel mic (mic 2)
  7561. */
  7562. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7563. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7564. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7565. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7566. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7567. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7568. /*
  7569. * Set up output mixers (0x0c - 0x0f)
  7570. */
  7571. /* set vol=0 to output mixers */
  7572. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7573. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7574. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7575. /* set up input amps for analog loopback */
  7576. /* Amp Indices: DAC = 0, mixer = 1 */
  7577. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7578. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7579. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7580. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7581. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7582. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7583. /* FIXME: use matrix-type input source selection */
  7584. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7585. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7586. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7587. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7588. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7589. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7590. /* Input mixer2 */
  7591. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7592. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7593. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7594. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7595. /* Input mixer3 */
  7596. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7597. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7598. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7599. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7600. { }
  7601. };
  7602. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7603. /*
  7604. * Unmute ADC0-2 and set the default input to mic-in
  7605. */
  7606. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7607. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7608. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7609. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7610. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7611. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7612. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7613. * mixer widget
  7614. * Note: PASD motherboards uses the Line In 2 as the input for
  7615. * front panel mic (mic 2)
  7616. */
  7617. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7618. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7619. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7620. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7621. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7622. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7623. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7624. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7625. /*
  7626. * Set up output mixers (0x0c - 0x0e)
  7627. */
  7628. /* set vol=0 to output mixers */
  7629. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7630. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7631. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7632. /* set up input amps for analog loopback */
  7633. /* Amp Indices: DAC = 0, mixer = 1 */
  7634. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7635. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7636. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7637. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7638. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7639. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7640. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7641. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7642. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7643. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7644. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7645. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7646. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7647. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7648. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7649. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7650. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7651. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7652. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7653. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7654. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7655. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7656. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7657. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7658. /* FIXME: use matrix-type input source selection */
  7659. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7660. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7661. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7662. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7663. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7664. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7665. /* Input mixer2 */
  7666. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7667. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7668. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7669. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7670. /* Input mixer3 */
  7671. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7672. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7673. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7674. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7675. { }
  7676. };
  7677. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7678. /*
  7679. * Unmute ADC0-2 and set the default input to mic-in
  7680. */
  7681. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7682. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7683. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7684. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7685. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7686. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7687. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7688. * mixer widget
  7689. * Note: PASD motherboards uses the Line In 2 as the input for front
  7690. * panel mic (mic 2)
  7691. */
  7692. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7693. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7694. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7695. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7696. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7697. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7698. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7699. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7700. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7701. /*
  7702. * Set up output mixers (0x0c - 0x0e)
  7703. */
  7704. /* set vol=0 to output mixers */
  7705. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7706. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7707. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7708. /* set up input amps for analog loopback */
  7709. /* Amp Indices: DAC = 0, mixer = 1 */
  7710. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7711. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7712. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7713. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7714. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7715. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7716. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7717. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7718. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7719. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7720. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7721. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7722. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7723. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7724. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7725. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7726. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7727. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7728. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7729. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7730. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7731. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7732. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7733. /* FIXME: use matrix-type input source selection */
  7734. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7735. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7736. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7737. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7738. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7739. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7740. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7741. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7742. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7743. /* Input mixer2 */
  7744. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7745. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7746. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7747. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7748. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7749. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7750. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7751. /* Input mixer3 */
  7752. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7753. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7754. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7755. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7756. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7757. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7758. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7759. { }
  7760. };
  7761. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7762. #define alc262_loopbacks alc880_loopbacks
  7763. #endif
  7764. /* pcm configuration: identiacal with ALC880 */
  7765. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7766. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7767. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7768. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7769. /*
  7770. * BIOS auto configuration
  7771. */
  7772. static int alc262_parse_auto_config(struct hda_codec *codec)
  7773. {
  7774. struct alc_spec *spec = codec->spec;
  7775. int err;
  7776. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7777. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7778. alc262_ignore);
  7779. if (err < 0)
  7780. return err;
  7781. if (!spec->autocfg.line_outs)
  7782. return 0; /* can't find valid BIOS pin config */
  7783. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7784. if (err < 0)
  7785. return err;
  7786. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7787. if (err < 0)
  7788. return err;
  7789. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7790. if (spec->autocfg.dig_out_pin)
  7791. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7792. if (spec->autocfg.dig_in_pin)
  7793. spec->dig_in_nid = ALC262_DIGIN_NID;
  7794. if (spec->kctl_alloc)
  7795. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7796. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7797. spec->num_mux_defs = 1;
  7798. spec->input_mux = &spec->private_imux;
  7799. err = alc_auto_add_mic_boost(codec);
  7800. if (err < 0)
  7801. return err;
  7802. return 1;
  7803. }
  7804. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7805. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7806. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7807. /* init callback for auto-configuration model -- overriding the default init */
  7808. static void alc262_auto_init(struct hda_codec *codec)
  7809. {
  7810. alc262_auto_init_multi_out(codec);
  7811. alc262_auto_init_hp_out(codec);
  7812. alc262_auto_init_analog_input(codec);
  7813. }
  7814. /*
  7815. * configuration and preset
  7816. */
  7817. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7818. [ALC262_BASIC] = "basic",
  7819. [ALC262_HIPPO] = "hippo",
  7820. [ALC262_HIPPO_1] = "hippo_1",
  7821. [ALC262_FUJITSU] = "fujitsu",
  7822. [ALC262_HP_BPC] = "hp-bpc",
  7823. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7824. [ALC262_HP_TC_T5735] = "hp-tc-t5735",
  7825. [ALC262_BENQ_ED8] = "benq",
  7826. [ALC262_BENQ_T31] = "benq-t31",
  7827. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7828. [ALC262_ULTRA] = "ultra",
  7829. [ALC262_AUTO] = "auto",
  7830. };
  7831. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7832. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7833. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7834. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7835. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7836. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7837. SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
  7838. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7839. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7840. SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
  7841. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7842. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7843. SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
  7844. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7845. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7846. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7847. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7848. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7849. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7850. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7851. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7852. SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
  7853. ALC262_HP_TC_T5735),
  7854. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7855. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7856. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7857. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7858. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7859. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7860. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7861. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7862. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7863. SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
  7864. {}
  7865. };
  7866. static struct alc_config_preset alc262_presets[] = {
  7867. [ALC262_BASIC] = {
  7868. .mixers = { alc262_base_mixer },
  7869. .init_verbs = { alc262_init_verbs },
  7870. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7871. .dac_nids = alc262_dac_nids,
  7872. .hp_nid = 0x03,
  7873. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7874. .channel_mode = alc262_modes,
  7875. .input_mux = &alc262_capture_source,
  7876. },
  7877. [ALC262_HIPPO] = {
  7878. .mixers = { alc262_base_mixer },
  7879. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7880. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7881. .dac_nids = alc262_dac_nids,
  7882. .hp_nid = 0x03,
  7883. .dig_out_nid = ALC262_DIGOUT_NID,
  7884. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7885. .channel_mode = alc262_modes,
  7886. .input_mux = &alc262_capture_source,
  7887. .unsol_event = alc262_hippo_unsol_event,
  7888. .init_hook = alc262_hippo_automute,
  7889. },
  7890. [ALC262_HIPPO_1] = {
  7891. .mixers = { alc262_hippo1_mixer },
  7892. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7893. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7894. .dac_nids = alc262_dac_nids,
  7895. .hp_nid = 0x02,
  7896. .dig_out_nid = ALC262_DIGOUT_NID,
  7897. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7898. .channel_mode = alc262_modes,
  7899. .input_mux = &alc262_capture_source,
  7900. .unsol_event = alc262_hippo1_unsol_event,
  7901. .init_hook = alc262_hippo1_automute,
  7902. },
  7903. [ALC262_FUJITSU] = {
  7904. .mixers = { alc262_fujitsu_mixer },
  7905. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
  7906. alc262_fujitsu_unsol_verbs },
  7907. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7908. .dac_nids = alc262_dac_nids,
  7909. .hp_nid = 0x03,
  7910. .dig_out_nid = ALC262_DIGOUT_NID,
  7911. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7912. .channel_mode = alc262_modes,
  7913. .input_mux = &alc262_fujitsu_capture_source,
  7914. .unsol_event = alc262_fujitsu_unsol_event,
  7915. },
  7916. [ALC262_HP_BPC] = {
  7917. .mixers = { alc262_HP_BPC_mixer },
  7918. .init_verbs = { alc262_HP_BPC_init_verbs },
  7919. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7920. .dac_nids = alc262_dac_nids,
  7921. .hp_nid = 0x03,
  7922. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7923. .channel_mode = alc262_modes,
  7924. .input_mux = &alc262_HP_capture_source,
  7925. },
  7926. [ALC262_HP_BPC_D7000_WF] = {
  7927. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7928. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7929. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7930. .dac_nids = alc262_dac_nids,
  7931. .hp_nid = 0x03,
  7932. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7933. .channel_mode = alc262_modes,
  7934. .input_mux = &alc262_HP_D7000_capture_source,
  7935. },
  7936. [ALC262_HP_BPC_D7000_WL] = {
  7937. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7938. alc262_HP_BPC_WildWest_option_mixer },
  7939. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7940. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7941. .dac_nids = alc262_dac_nids,
  7942. .hp_nid = 0x03,
  7943. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7944. .channel_mode = alc262_modes,
  7945. .input_mux = &alc262_HP_D7000_capture_source,
  7946. },
  7947. [ALC262_HP_TC_T5735] = {
  7948. .mixers = { alc262_hp_t5735_mixer },
  7949. .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
  7950. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7951. .dac_nids = alc262_dac_nids,
  7952. .hp_nid = 0x03,
  7953. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7954. .channel_mode = alc262_modes,
  7955. .input_mux = &alc262_capture_source,
  7956. .unsol_event = alc262_hp_t5735_unsol_event,
  7957. .init_hook = alc262_hp_t5735_init_hook,
  7958. },
  7959. [ALC262_BENQ_ED8] = {
  7960. .mixers = { alc262_base_mixer },
  7961. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7962. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7963. .dac_nids = alc262_dac_nids,
  7964. .hp_nid = 0x03,
  7965. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7966. .channel_mode = alc262_modes,
  7967. .input_mux = &alc262_capture_source,
  7968. },
  7969. [ALC262_SONY_ASSAMD] = {
  7970. .mixers = { alc262_sony_mixer },
  7971. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7972. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7973. .dac_nids = alc262_dac_nids,
  7974. .hp_nid = 0x02,
  7975. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7976. .channel_mode = alc262_modes,
  7977. .input_mux = &alc262_capture_source,
  7978. .unsol_event = alc262_hippo_unsol_event,
  7979. .init_hook = alc262_hippo_automute,
  7980. },
  7981. [ALC262_BENQ_T31] = {
  7982. .mixers = { alc262_benq_t31_mixer },
  7983. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7984. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7985. .dac_nids = alc262_dac_nids,
  7986. .hp_nid = 0x03,
  7987. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7988. .channel_mode = alc262_modes,
  7989. .input_mux = &alc262_capture_source,
  7990. .unsol_event = alc262_hippo_unsol_event,
  7991. .init_hook = alc262_hippo_automute,
  7992. },
  7993. [ALC262_ULTRA] = {
  7994. .mixers = { alc262_ultra_mixer },
  7995. .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
  7996. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7997. .dac_nids = alc262_dac_nids,
  7998. .hp_nid = 0x03,
  7999. .dig_out_nid = ALC262_DIGOUT_NID,
  8000. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8001. .channel_mode = alc262_modes,
  8002. .input_mux = &alc262_ultra_capture_source,
  8003. .unsol_event = alc262_ultra_unsol_event,
  8004. .init_hook = alc262_ultra_automute,
  8005. },
  8006. };
  8007. static int patch_alc262(struct hda_codec *codec)
  8008. {
  8009. struct alc_spec *spec;
  8010. int board_config;
  8011. int err;
  8012. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8013. if (spec == NULL)
  8014. return -ENOMEM;
  8015. codec->spec = spec;
  8016. #if 0
  8017. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  8018. * under-run
  8019. */
  8020. {
  8021. int tmp;
  8022. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  8023. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  8024. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  8025. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  8026. }
  8027. #endif
  8028. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  8029. alc262_models,
  8030. alc262_cfg_tbl);
  8031. if (board_config < 0) {
  8032. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  8033. "trying auto-probe from BIOS...\n");
  8034. board_config = ALC262_AUTO;
  8035. }
  8036. if (board_config == ALC262_AUTO) {
  8037. /* automatic parse from the BIOS config */
  8038. err = alc262_parse_auto_config(codec);
  8039. if (err < 0) {
  8040. alc_free(codec);
  8041. return err;
  8042. } else if (!err) {
  8043. printk(KERN_INFO
  8044. "hda_codec: Cannot set up configuration "
  8045. "from BIOS. Using base mode...\n");
  8046. board_config = ALC262_BASIC;
  8047. }
  8048. }
  8049. if (board_config != ALC262_AUTO)
  8050. setup_preset(spec, &alc262_presets[board_config]);
  8051. spec->stream_name_analog = "ALC262 Analog";
  8052. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  8053. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  8054. spec->stream_name_digital = "ALC262 Digital";
  8055. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  8056. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  8057. if (!spec->adc_nids && spec->input_mux) {
  8058. /* check whether NID 0x07 is valid */
  8059. unsigned int wcap = get_wcaps(codec, 0x07);
  8060. /* get type */
  8061. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8062. if (wcap != AC_WID_AUD_IN) {
  8063. spec->adc_nids = alc262_adc_nids_alt;
  8064. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  8065. spec->mixers[spec->num_mixers] =
  8066. alc262_capture_alt_mixer;
  8067. spec->num_mixers++;
  8068. } else {
  8069. spec->adc_nids = alc262_adc_nids;
  8070. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  8071. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  8072. spec->num_mixers++;
  8073. }
  8074. }
  8075. codec->patch_ops = alc_patch_ops;
  8076. if (board_config == ALC262_AUTO)
  8077. spec->init_hook = alc262_auto_init;
  8078. #ifdef CONFIG_SND_HDA_POWER_SAVE
  8079. if (!spec->loopback.amplist)
  8080. spec->loopback.amplist = alc262_loopbacks;
  8081. #endif
  8082. return 0;
  8083. }
  8084. /*
  8085. * ALC268 channel source setting (2 channel)
  8086. */
  8087. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  8088. #define alc268_modes alc260_modes
  8089. static hda_nid_t alc268_dac_nids[2] = {
  8090. /* front, hp */
  8091. 0x02, 0x03
  8092. };
  8093. static hda_nid_t alc268_adc_nids[2] = {
  8094. /* ADC0-1 */
  8095. 0x08, 0x07
  8096. };
  8097. static hda_nid_t alc268_adc_nids_alt[1] = {
  8098. /* ADC0 */
  8099. 0x08
  8100. };
  8101. static struct snd_kcontrol_new alc268_base_mixer[] = {
  8102. /* output mixer control */
  8103. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  8104. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8105. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  8106. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8107. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8108. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8109. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  8110. { }
  8111. };
  8112. static struct hda_verb alc268_eapd_verbs[] = {
  8113. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8114. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8115. { }
  8116. };
  8117. /* Toshiba specific */
  8118. #define alc268_toshiba_automute alc262_hippo_automute
  8119. static struct hda_verb alc268_toshiba_verbs[] = {
  8120. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  8121. { } /* end */
  8122. };
  8123. /* Acer specific */
  8124. /* bind volumes of both NID 0x02 and 0x03 */
  8125. static struct hda_bind_ctls alc268_acer_bind_master_vol = {
  8126. .ops = &snd_hda_bind_vol,
  8127. .values = {
  8128. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  8129. HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
  8130. 0
  8131. },
  8132. };
  8133. /* mute/unmute internal speaker according to the hp jack and mute state */
  8134. static void alc268_acer_automute(struct hda_codec *codec, int force)
  8135. {
  8136. struct alc_spec *spec = codec->spec;
  8137. unsigned int mute;
  8138. if (force || !spec->sense_updated) {
  8139. unsigned int present;
  8140. present = snd_hda_codec_read(codec, 0x14, 0,
  8141. AC_VERB_GET_PIN_SENSE, 0);
  8142. spec->jack_present = (present & 0x80000000) != 0;
  8143. spec->sense_updated = 1;
  8144. }
  8145. if (spec->jack_present)
  8146. mute = HDA_AMP_MUTE; /* mute internal speaker */
  8147. else /* unmute internal speaker if necessary */
  8148. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  8149. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  8150. HDA_AMP_MUTE, mute);
  8151. }
  8152. /* bind hp and internal speaker mute (with plug check) */
  8153. static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
  8154. struct snd_ctl_elem_value *ucontrol)
  8155. {
  8156. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8157. long *valp = ucontrol->value.integer.value;
  8158. int change;
  8159. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8160. HDA_AMP_MUTE,
  8161. valp[0] ? 0 : HDA_AMP_MUTE);
  8162. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8163. HDA_AMP_MUTE,
  8164. valp[1] ? 0 : HDA_AMP_MUTE);
  8165. if (change)
  8166. alc268_acer_automute(codec, 0);
  8167. return change;
  8168. }
  8169. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  8170. /* output mixer control */
  8171. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  8172. {
  8173. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8174. .name = "Master Playback Switch",
  8175. .info = snd_hda_mixer_amp_switch_info,
  8176. .get = snd_hda_mixer_amp_switch_get,
  8177. .put = alc268_acer_master_sw_put,
  8178. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  8179. },
  8180. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8181. HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
  8182. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  8183. { }
  8184. };
  8185. static struct hda_verb alc268_acer_verbs[] = {
  8186. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8187. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8188. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  8189. { }
  8190. };
  8191. /* unsolicited event for HP jack sensing */
  8192. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  8193. unsigned int res)
  8194. {
  8195. if ((res >> 26) != ALC880_HP_EVENT)
  8196. return;
  8197. alc268_toshiba_automute(codec);
  8198. }
  8199. static void alc268_acer_unsol_event(struct hda_codec *codec,
  8200. unsigned int res)
  8201. {
  8202. if ((res >> 26) != ALC880_HP_EVENT)
  8203. return;
  8204. alc268_acer_automute(codec, 1);
  8205. }
  8206. static void alc268_acer_init_hook(struct hda_codec *codec)
  8207. {
  8208. alc268_acer_automute(codec, 1);
  8209. }
  8210. /*
  8211. * generic initialization of ADC, input mixers and output mixers
  8212. */
  8213. static struct hda_verb alc268_base_init_verbs[] = {
  8214. /* Unmute DAC0-1 and set vol = 0 */
  8215. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8216. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8217. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8218. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8219. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8220. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8221. /*
  8222. * Set up output mixers (0x0c - 0x0e)
  8223. */
  8224. /* set vol=0 to output mixers */
  8225. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8226. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8227. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8228. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  8229. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8230. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8231. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  8232. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  8233. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  8234. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8235. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8236. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8237. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8238. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8239. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8240. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8241. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8242. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8243. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8244. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8245. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8246. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8247. /* FIXME: use matrix-type input source selection */
  8248. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  8249. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  8250. /* Input mixer2 */
  8251. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8252. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  8253. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  8254. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  8255. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8256. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  8257. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  8258. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  8259. { }
  8260. };
  8261. /*
  8262. * generic initialization of ADC, input mixers and output mixers
  8263. */
  8264. static struct hda_verb alc268_volume_init_verbs[] = {
  8265. /* set output DAC */
  8266. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8267. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8268. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8269. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8270. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8271. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8272. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8273. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8274. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8275. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8276. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8277. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8278. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8279. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8280. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8281. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8282. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8283. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8284. /* set PCBEEP vol = 0 */
  8285. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  8286. { }
  8287. };
  8288. #define alc268_mux_enum_info alc_mux_enum_info
  8289. #define alc268_mux_enum_get alc_mux_enum_get
  8290. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  8291. struct snd_ctl_elem_value *ucontrol)
  8292. {
  8293. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8294. struct alc_spec *spec = codec->spec;
  8295. const struct hda_input_mux *imux = spec->input_mux;
  8296. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8297. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  8298. hda_nid_t nid = capture_mixers[adc_idx];
  8299. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8300. unsigned int i, idx;
  8301. idx = ucontrol->value.enumerated.item[0];
  8302. if (idx >= imux->num_items)
  8303. idx = imux->num_items - 1;
  8304. if (*cur_val == idx)
  8305. return 0;
  8306. for (i = 0; i < imux->num_items; i++) {
  8307. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  8308. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  8309. imux->items[i].index,
  8310. HDA_AMP_MUTE, v);
  8311. snd_hda_codec_write_cache(codec, nid, 0,
  8312. AC_VERB_SET_CONNECT_SEL,
  8313. idx );
  8314. }
  8315. *cur_val = idx;
  8316. return 1;
  8317. }
  8318. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  8319. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8320. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8321. {
  8322. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8323. /* The multiple "Capture Source" controls confuse alsamixer
  8324. * So call somewhat different..
  8325. * FIXME: the controls appear in the "playback" view!
  8326. */
  8327. /* .name = "Capture Source", */
  8328. .name = "Input Source",
  8329. .count = 1,
  8330. .info = alc268_mux_enum_info,
  8331. .get = alc268_mux_enum_get,
  8332. .put = alc268_mux_enum_put,
  8333. },
  8334. { } /* end */
  8335. };
  8336. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  8337. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8338. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8339. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  8340. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  8341. {
  8342. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8343. /* The multiple "Capture Source" controls confuse alsamixer
  8344. * So call somewhat different..
  8345. * FIXME: the controls appear in the "playback" view!
  8346. */
  8347. /* .name = "Capture Source", */
  8348. .name = "Input Source",
  8349. .count = 2,
  8350. .info = alc268_mux_enum_info,
  8351. .get = alc268_mux_enum_get,
  8352. .put = alc268_mux_enum_put,
  8353. },
  8354. { } /* end */
  8355. };
  8356. static struct hda_input_mux alc268_capture_source = {
  8357. .num_items = 4,
  8358. .items = {
  8359. { "Mic", 0x0 },
  8360. { "Front Mic", 0x1 },
  8361. { "Line", 0x2 },
  8362. { "CD", 0x3 },
  8363. },
  8364. };
  8365. /* create input playback/capture controls for the given pin */
  8366. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  8367. const char *ctlname, int idx)
  8368. {
  8369. char name[32];
  8370. int err;
  8371. sprintf(name, "%s Playback Volume", ctlname);
  8372. if (nid == 0x14) {
  8373. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8374. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  8375. HDA_OUTPUT));
  8376. if (err < 0)
  8377. return err;
  8378. } else if (nid == 0x15) {
  8379. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8380. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  8381. HDA_OUTPUT));
  8382. if (err < 0)
  8383. return err;
  8384. } else
  8385. return -1;
  8386. sprintf(name, "%s Playback Switch", ctlname);
  8387. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8388. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  8389. if (err < 0)
  8390. return err;
  8391. return 0;
  8392. }
  8393. /* add playback controls from the parsed DAC table */
  8394. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  8395. const struct auto_pin_cfg *cfg)
  8396. {
  8397. hda_nid_t nid;
  8398. int err;
  8399. spec->multiout.num_dacs = 2; /* only use one dac */
  8400. spec->multiout.dac_nids = spec->private_dac_nids;
  8401. spec->multiout.dac_nids[0] = 2;
  8402. spec->multiout.dac_nids[1] = 3;
  8403. nid = cfg->line_out_pins[0];
  8404. if (nid)
  8405. alc268_new_analog_output(spec, nid, "Front", 0);
  8406. nid = cfg->speaker_pins[0];
  8407. if (nid == 0x1d) {
  8408. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8409. "Speaker Playback Volume",
  8410. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  8411. if (err < 0)
  8412. return err;
  8413. }
  8414. nid = cfg->hp_pins[0];
  8415. if (nid)
  8416. alc268_new_analog_output(spec, nid, "Headphone", 0);
  8417. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  8418. if (nid == 0x16) {
  8419. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8420. "Mono Playback Switch",
  8421. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  8422. if (err < 0)
  8423. return err;
  8424. }
  8425. return 0;
  8426. }
  8427. /* create playback/capture controls for input pins */
  8428. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  8429. const struct auto_pin_cfg *cfg)
  8430. {
  8431. struct hda_input_mux *imux = &spec->private_imux;
  8432. int i, idx1;
  8433. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8434. switch(cfg->input_pins[i]) {
  8435. case 0x18:
  8436. idx1 = 0; /* Mic 1 */
  8437. break;
  8438. case 0x19:
  8439. idx1 = 1; /* Mic 2 */
  8440. break;
  8441. case 0x1a:
  8442. idx1 = 2; /* Line In */
  8443. break;
  8444. case 0x1c:
  8445. idx1 = 3; /* CD */
  8446. break;
  8447. default:
  8448. continue;
  8449. }
  8450. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8451. imux->items[imux->num_items].index = idx1;
  8452. imux->num_items++;
  8453. }
  8454. return 0;
  8455. }
  8456. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  8457. {
  8458. struct alc_spec *spec = codec->spec;
  8459. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  8460. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  8461. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  8462. unsigned int dac_vol1, dac_vol2;
  8463. if (speaker_nid) {
  8464. snd_hda_codec_write(codec, speaker_nid, 0,
  8465. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  8466. snd_hda_codec_write(codec, 0x0f, 0,
  8467. AC_VERB_SET_AMP_GAIN_MUTE,
  8468. AMP_IN_UNMUTE(1));
  8469. snd_hda_codec_write(codec, 0x10, 0,
  8470. AC_VERB_SET_AMP_GAIN_MUTE,
  8471. AMP_IN_UNMUTE(1));
  8472. } else {
  8473. snd_hda_codec_write(codec, 0x0f, 0,
  8474. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8475. snd_hda_codec_write(codec, 0x10, 0,
  8476. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8477. }
  8478. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  8479. if (line_nid == 0x14)
  8480. dac_vol2 = AMP_OUT_ZERO;
  8481. else if (line_nid == 0x15)
  8482. dac_vol1 = AMP_OUT_ZERO;
  8483. if (hp_nid == 0x14)
  8484. dac_vol2 = AMP_OUT_ZERO;
  8485. else if (hp_nid == 0x15)
  8486. dac_vol1 = AMP_OUT_ZERO;
  8487. if (line_nid != 0x16 || hp_nid != 0x16 ||
  8488. spec->autocfg.line_out_pins[1] != 0x16 ||
  8489. spec->autocfg.line_out_pins[2] != 0x16)
  8490. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  8491. snd_hda_codec_write(codec, 0x02, 0,
  8492. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  8493. snd_hda_codec_write(codec, 0x03, 0,
  8494. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  8495. }
  8496. /* pcm configuration: identiacal with ALC880 */
  8497. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  8498. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  8499. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  8500. /*
  8501. * BIOS auto configuration
  8502. */
  8503. static int alc268_parse_auto_config(struct hda_codec *codec)
  8504. {
  8505. struct alc_spec *spec = codec->spec;
  8506. int err;
  8507. static hda_nid_t alc268_ignore[] = { 0 };
  8508. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8509. alc268_ignore);
  8510. if (err < 0)
  8511. return err;
  8512. if (!spec->autocfg.line_outs)
  8513. return 0; /* can't find valid BIOS pin config */
  8514. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8515. if (err < 0)
  8516. return err;
  8517. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8518. if (err < 0)
  8519. return err;
  8520. spec->multiout.max_channels = 2;
  8521. /* digital only support output */
  8522. if (spec->autocfg.dig_out_pin)
  8523. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  8524. if (spec->kctl_alloc)
  8525. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8526. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  8527. spec->num_mux_defs = 1;
  8528. spec->input_mux = &spec->private_imux;
  8529. err = alc_auto_add_mic_boost(codec);
  8530. if (err < 0)
  8531. return err;
  8532. return 1;
  8533. }
  8534. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  8535. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  8536. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  8537. /* init callback for auto-configuration model -- overriding the default init */
  8538. static void alc268_auto_init(struct hda_codec *codec)
  8539. {
  8540. alc268_auto_init_multi_out(codec);
  8541. alc268_auto_init_hp_out(codec);
  8542. alc268_auto_init_mono_speaker_out(codec);
  8543. alc268_auto_init_analog_input(codec);
  8544. }
  8545. /*
  8546. * configuration and preset
  8547. */
  8548. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8549. [ALC268_3ST] = "3stack",
  8550. [ALC268_TOSHIBA] = "toshiba",
  8551. [ALC268_ACER] = "acer",
  8552. [ALC268_AUTO] = "auto",
  8553. };
  8554. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8555. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8556. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8557. SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
  8558. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8559. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8560. SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
  8561. SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
  8562. {}
  8563. };
  8564. static struct alc_config_preset alc268_presets[] = {
  8565. [ALC268_3ST] = {
  8566. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8567. .init_verbs = { alc268_base_init_verbs },
  8568. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8569. .dac_nids = alc268_dac_nids,
  8570. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8571. .adc_nids = alc268_adc_nids_alt,
  8572. .hp_nid = 0x03,
  8573. .dig_out_nid = ALC268_DIGOUT_NID,
  8574. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8575. .channel_mode = alc268_modes,
  8576. .input_mux = &alc268_capture_source,
  8577. },
  8578. [ALC268_TOSHIBA] = {
  8579. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8580. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8581. alc268_toshiba_verbs },
  8582. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8583. .dac_nids = alc268_dac_nids,
  8584. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8585. .adc_nids = alc268_adc_nids_alt,
  8586. .hp_nid = 0x03,
  8587. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8588. .channel_mode = alc268_modes,
  8589. .input_mux = &alc268_capture_source,
  8590. .unsol_event = alc268_toshiba_unsol_event,
  8591. .init_hook = alc268_toshiba_automute,
  8592. },
  8593. [ALC268_ACER] = {
  8594. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8595. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8596. alc268_acer_verbs },
  8597. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8598. .dac_nids = alc268_dac_nids,
  8599. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8600. .adc_nids = alc268_adc_nids_alt,
  8601. .hp_nid = 0x02,
  8602. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8603. .channel_mode = alc268_modes,
  8604. .input_mux = &alc268_capture_source,
  8605. .unsol_event = alc268_acer_unsol_event,
  8606. .init_hook = alc268_acer_init_hook,
  8607. },
  8608. };
  8609. static int patch_alc268(struct hda_codec *codec)
  8610. {
  8611. struct alc_spec *spec;
  8612. int board_config;
  8613. int err;
  8614. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8615. if (spec == NULL)
  8616. return -ENOMEM;
  8617. codec->spec = spec;
  8618. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8619. alc268_models,
  8620. alc268_cfg_tbl);
  8621. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8622. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8623. "trying auto-probe from BIOS...\n");
  8624. board_config = ALC268_AUTO;
  8625. }
  8626. if (board_config == ALC268_AUTO) {
  8627. /* automatic parse from the BIOS config */
  8628. err = alc268_parse_auto_config(codec);
  8629. if (err < 0) {
  8630. alc_free(codec);
  8631. return err;
  8632. } else if (!err) {
  8633. printk(KERN_INFO
  8634. "hda_codec: Cannot set up configuration "
  8635. "from BIOS. Using base mode...\n");
  8636. board_config = ALC268_3ST;
  8637. }
  8638. }
  8639. if (board_config != ALC268_AUTO)
  8640. setup_preset(spec, &alc268_presets[board_config]);
  8641. spec->stream_name_analog = "ALC268 Analog";
  8642. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8643. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8644. spec->stream_name_digital = "ALC268 Digital";
  8645. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8646. if (board_config == ALC268_AUTO) {
  8647. if (!spec->adc_nids && spec->input_mux) {
  8648. /* check whether NID 0x07 is valid */
  8649. unsigned int wcap = get_wcaps(codec, 0x07);
  8650. /* get type */
  8651. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8652. if (wcap != AC_WID_AUD_IN) {
  8653. spec->adc_nids = alc268_adc_nids_alt;
  8654. spec->num_adc_nids =
  8655. ARRAY_SIZE(alc268_adc_nids_alt);
  8656. spec->mixers[spec->num_mixers] =
  8657. alc268_capture_alt_mixer;
  8658. spec->num_mixers++;
  8659. } else {
  8660. spec->adc_nids = alc268_adc_nids;
  8661. spec->num_adc_nids =
  8662. ARRAY_SIZE(alc268_adc_nids);
  8663. spec->mixers[spec->num_mixers] =
  8664. alc268_capture_mixer;
  8665. spec->num_mixers++;
  8666. }
  8667. }
  8668. }
  8669. codec->patch_ops = alc_patch_ops;
  8670. if (board_config == ALC268_AUTO)
  8671. spec->init_hook = alc268_auto_init;
  8672. return 0;
  8673. }
  8674. /*
  8675. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8676. */
  8677. /*
  8678. * set the path ways for 2 channel output
  8679. * need to set the codec line out and mic 1 pin widgets to inputs
  8680. */
  8681. static struct hda_verb alc861_threestack_ch2_init[] = {
  8682. /* set pin widget 1Ah (line in) for input */
  8683. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8684. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8685. * the vref
  8686. */
  8687. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8688. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8689. #if 0
  8690. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8691. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8692. #endif
  8693. { } /* end */
  8694. };
  8695. /*
  8696. * 6ch mode
  8697. * need to set the codec line out and mic 1 pin widgets to outputs
  8698. */
  8699. static struct hda_verb alc861_threestack_ch6_init[] = {
  8700. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8701. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8702. /* set pin widget 18h (mic1) for output (CLFE)*/
  8703. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8704. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8705. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8706. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8707. #if 0
  8708. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8709. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8710. #endif
  8711. { } /* end */
  8712. };
  8713. static struct hda_channel_mode alc861_threestack_modes[2] = {
  8714. { 2, alc861_threestack_ch2_init },
  8715. { 6, alc861_threestack_ch6_init },
  8716. };
  8717. /* Set mic1 as input and unmute the mixer */
  8718. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  8719. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8720. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8721. { } /* end */
  8722. };
  8723. /* Set mic1 as output and mute mixer */
  8724. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  8725. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8726. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8727. { } /* end */
  8728. };
  8729. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  8730. { 2, alc861_uniwill_m31_ch2_init },
  8731. { 4, alc861_uniwill_m31_ch4_init },
  8732. };
  8733. /* Set mic1 and line-in as input and unmute the mixer */
  8734. static struct hda_verb alc861_asus_ch2_init[] = {
  8735. /* set pin widget 1Ah (line in) for input */
  8736. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8737. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8738. * the vref
  8739. */
  8740. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8741. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8742. #if 0
  8743. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8744. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8745. #endif
  8746. { } /* end */
  8747. };
  8748. /* Set mic1 nad line-in as output and mute mixer */
  8749. static struct hda_verb alc861_asus_ch6_init[] = {
  8750. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8751. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8752. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8753. /* set pin widget 18h (mic1) for output (CLFE)*/
  8754. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8755. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8756. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8757. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8758. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8759. #if 0
  8760. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8761. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8762. #endif
  8763. { } /* end */
  8764. };
  8765. static struct hda_channel_mode alc861_asus_modes[2] = {
  8766. { 2, alc861_asus_ch2_init },
  8767. { 6, alc861_asus_ch6_init },
  8768. };
  8769. /* patch-ALC861 */
  8770. static struct snd_kcontrol_new alc861_base_mixer[] = {
  8771. /* output mixer control */
  8772. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8773. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8774. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8775. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8776. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8777. /*Input mixer control */
  8778. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8779. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8780. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8781. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8782. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8783. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8784. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8785. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8786. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8787. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8788. /* Capture mixer control */
  8789. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8790. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8791. {
  8792. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8793. .name = "Capture Source",
  8794. .count = 1,
  8795. .info = alc_mux_enum_info,
  8796. .get = alc_mux_enum_get,
  8797. .put = alc_mux_enum_put,
  8798. },
  8799. { } /* end */
  8800. };
  8801. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8802. /* output mixer control */
  8803. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8804. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8805. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8806. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8807. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8808. /* Input mixer control */
  8809. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8810. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8811. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8812. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8813. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8814. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8815. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8816. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8817. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8818. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8819. /* Capture mixer control */
  8820. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8821. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8822. {
  8823. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8824. .name = "Capture Source",
  8825. .count = 1,
  8826. .info = alc_mux_enum_info,
  8827. .get = alc_mux_enum_get,
  8828. .put = alc_mux_enum_put,
  8829. },
  8830. {
  8831. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8832. .name = "Channel Mode",
  8833. .info = alc_ch_mode_info,
  8834. .get = alc_ch_mode_get,
  8835. .put = alc_ch_mode_put,
  8836. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8837. },
  8838. { } /* end */
  8839. };
  8840. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8841. /* output mixer control */
  8842. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8843. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8844. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8845. /*Capture mixer control */
  8846. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8847. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8848. {
  8849. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8850. .name = "Capture Source",
  8851. .count = 1,
  8852. .info = alc_mux_enum_info,
  8853. .get = alc_mux_enum_get,
  8854. .put = alc_mux_enum_put,
  8855. },
  8856. { } /* end */
  8857. };
  8858. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8859. /* output mixer control */
  8860. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8861. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8862. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8863. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8864. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8865. /* Input mixer control */
  8866. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8867. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8868. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8869. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8870. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8871. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8872. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8873. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8874. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8875. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8876. /* Capture mixer control */
  8877. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8878. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8879. {
  8880. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8881. .name = "Capture Source",
  8882. .count = 1,
  8883. .info = alc_mux_enum_info,
  8884. .get = alc_mux_enum_get,
  8885. .put = alc_mux_enum_put,
  8886. },
  8887. {
  8888. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8889. .name = "Channel Mode",
  8890. .info = alc_ch_mode_info,
  8891. .get = alc_ch_mode_get,
  8892. .put = alc_ch_mode_put,
  8893. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8894. },
  8895. { } /* end */
  8896. };
  8897. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8898. /* output mixer control */
  8899. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8900. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8901. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8902. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8903. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8904. /* Input mixer control */
  8905. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8906. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8907. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8908. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8909. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8910. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8911. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8912. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8913. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8914. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8915. /* Capture mixer control */
  8916. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8917. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8918. {
  8919. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8920. .name = "Capture Source",
  8921. .count = 1,
  8922. .info = alc_mux_enum_info,
  8923. .get = alc_mux_enum_get,
  8924. .put = alc_mux_enum_put,
  8925. },
  8926. {
  8927. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8928. .name = "Channel Mode",
  8929. .info = alc_ch_mode_info,
  8930. .get = alc_ch_mode_get,
  8931. .put = alc_ch_mode_put,
  8932. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8933. },
  8934. { }
  8935. };
  8936. /* additional mixer */
  8937. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8938. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8939. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8940. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8941. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8942. { }
  8943. };
  8944. /*
  8945. * generic initialization of ADC, input mixers and output mixers
  8946. */
  8947. static struct hda_verb alc861_base_init_verbs[] = {
  8948. /*
  8949. * Unmute ADC0 and set the default input to mic-in
  8950. */
  8951. /* port-A for surround (rear panel) */
  8952. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8953. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8954. /* port-B for mic-in (rear panel) with vref */
  8955. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8956. /* port-C for line-in (rear panel) */
  8957. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8958. /* port-D for Front */
  8959. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8960. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8961. /* port-E for HP out (front panel) */
  8962. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8963. /* route front PCM to HP */
  8964. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8965. /* port-F for mic-in (front panel) with vref */
  8966. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8967. /* port-G for CLFE (rear panel) */
  8968. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8969. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8970. /* port-H for side (rear panel) */
  8971. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8972. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8973. /* CD-in */
  8974. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8975. /* route front mic to ADC1*/
  8976. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8977. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8978. /* Unmute DAC0~3 & spdif out*/
  8979. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8980. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8981. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8982. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8983. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8984. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8985. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8986. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8987. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8988. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8989. /* Unmute Stereo Mixer 15 */
  8990. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8991. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8992. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8993. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8994. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8995. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8996. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8997. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8998. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8999. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9000. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9001. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9002. /* hp used DAC 3 (Front) */
  9003. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9004. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9005. { }
  9006. };
  9007. static struct hda_verb alc861_threestack_init_verbs[] = {
  9008. /*
  9009. * Unmute ADC0 and set the default input to mic-in
  9010. */
  9011. /* port-A for surround (rear panel) */
  9012. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9013. /* port-B for mic-in (rear panel) with vref */
  9014. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9015. /* port-C for line-in (rear panel) */
  9016. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9017. /* port-D for Front */
  9018. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9019. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9020. /* port-E for HP out (front panel) */
  9021. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  9022. /* route front PCM to HP */
  9023. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9024. /* port-F for mic-in (front panel) with vref */
  9025. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9026. /* port-G for CLFE (rear panel) */
  9027. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9028. /* port-H for side (rear panel) */
  9029. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9030. /* CD-in */
  9031. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9032. /* route front mic to ADC1*/
  9033. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9034. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9035. /* Unmute DAC0~3 & spdif out*/
  9036. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9037. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9038. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9039. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9040. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9041. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9042. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9043. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9044. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9045. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9046. /* Unmute Stereo Mixer 15 */
  9047. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9048. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9049. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9050. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9051. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9052. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9053. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9054. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9055. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9056. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9057. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9058. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9059. /* hp used DAC 3 (Front) */
  9060. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9061. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9062. { }
  9063. };
  9064. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  9065. /*
  9066. * Unmute ADC0 and set the default input to mic-in
  9067. */
  9068. /* port-A for surround (rear panel) */
  9069. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9070. /* port-B for mic-in (rear panel) with vref */
  9071. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9072. /* port-C for line-in (rear panel) */
  9073. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9074. /* port-D for Front */
  9075. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9076. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9077. /* port-E for HP out (front panel) */
  9078. /* this has to be set to VREF80 */
  9079. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9080. /* route front PCM to HP */
  9081. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9082. /* port-F for mic-in (front panel) with vref */
  9083. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9084. /* port-G for CLFE (rear panel) */
  9085. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9086. /* port-H for side (rear panel) */
  9087. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9088. /* CD-in */
  9089. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9090. /* route front mic to ADC1*/
  9091. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9092. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9093. /* Unmute DAC0~3 & spdif out*/
  9094. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9095. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9096. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9097. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9098. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9099. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9100. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9101. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9102. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9103. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9104. /* Unmute Stereo Mixer 15 */
  9105. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9106. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9107. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9108. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9109. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9110. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9111. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9112. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9113. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9114. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9115. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9116. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9117. /* hp used DAC 3 (Front) */
  9118. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9119. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9120. { }
  9121. };
  9122. static struct hda_verb alc861_asus_init_verbs[] = {
  9123. /*
  9124. * Unmute ADC0 and set the default input to mic-in
  9125. */
  9126. /* port-A for surround (rear panel)
  9127. * according to codec#0 this is the HP jack
  9128. */
  9129. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  9130. /* route front PCM to HP */
  9131. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9132. /* port-B for mic-in (rear panel) with vref */
  9133. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9134. /* port-C for line-in (rear panel) */
  9135. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9136. /* port-D for Front */
  9137. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9138. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9139. /* port-E for HP out (front panel) */
  9140. /* this has to be set to VREF80 */
  9141. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9142. /* route front PCM to HP */
  9143. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9144. /* port-F for mic-in (front panel) with vref */
  9145. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9146. /* port-G for CLFE (rear panel) */
  9147. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9148. /* port-H for side (rear panel) */
  9149. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9150. /* CD-in */
  9151. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9152. /* route front mic to ADC1*/
  9153. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9154. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9155. /* Unmute DAC0~3 & spdif out*/
  9156. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9157. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9158. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9159. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9160. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9161. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9162. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9163. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9164. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9165. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9166. /* Unmute Stereo Mixer 15 */
  9167. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9168. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9169. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9170. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9171. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9172. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9173. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9174. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9175. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9176. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9177. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9178. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9179. /* hp used DAC 3 (Front) */
  9180. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9181. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9182. { }
  9183. };
  9184. /* additional init verbs for ASUS laptops */
  9185. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  9186. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  9187. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  9188. { }
  9189. };
  9190. /*
  9191. * generic initialization of ADC, input mixers and output mixers
  9192. */
  9193. static struct hda_verb alc861_auto_init_verbs[] = {
  9194. /*
  9195. * Unmute ADC0 and set the default input to mic-in
  9196. */
  9197. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  9198. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9199. /* Unmute DAC0~3 & spdif out*/
  9200. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9201. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9202. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9203. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9204. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9205. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9206. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9207. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9208. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9209. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9210. /* Unmute Stereo Mixer 15 */
  9211. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9212. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9213. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9214. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  9215. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9216. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9217. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9218. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9219. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9220. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9221. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9222. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9223. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9224. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9225. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9226. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9227. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9228. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9229. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9230. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9231. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  9232. { }
  9233. };
  9234. static struct hda_verb alc861_toshiba_init_verbs[] = {
  9235. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9236. { }
  9237. };
  9238. /* toggle speaker-output according to the hp-jack state */
  9239. static void alc861_toshiba_automute(struct hda_codec *codec)
  9240. {
  9241. unsigned int present;
  9242. present = snd_hda_codec_read(codec, 0x0f, 0,
  9243. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9244. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  9245. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9246. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  9247. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  9248. }
  9249. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  9250. unsigned int res)
  9251. {
  9252. if ((res >> 26) == ALC880_HP_EVENT)
  9253. alc861_toshiba_automute(codec);
  9254. }
  9255. /* pcm configuration: identiacal with ALC880 */
  9256. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  9257. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  9258. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  9259. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  9260. #define ALC861_DIGOUT_NID 0x07
  9261. static struct hda_channel_mode alc861_8ch_modes[1] = {
  9262. { 8, NULL }
  9263. };
  9264. static hda_nid_t alc861_dac_nids[4] = {
  9265. /* front, surround, clfe, side */
  9266. 0x03, 0x06, 0x05, 0x04
  9267. };
  9268. static hda_nid_t alc660_dac_nids[3] = {
  9269. /* front, clfe, surround */
  9270. 0x03, 0x05, 0x06
  9271. };
  9272. static hda_nid_t alc861_adc_nids[1] = {
  9273. /* ADC0-2 */
  9274. 0x08,
  9275. };
  9276. static struct hda_input_mux alc861_capture_source = {
  9277. .num_items = 5,
  9278. .items = {
  9279. { "Mic", 0x0 },
  9280. { "Front Mic", 0x3 },
  9281. { "Line", 0x1 },
  9282. { "CD", 0x4 },
  9283. { "Mixer", 0x5 },
  9284. },
  9285. };
  9286. /* fill in the dac_nids table from the parsed pin configuration */
  9287. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  9288. const struct auto_pin_cfg *cfg)
  9289. {
  9290. int i;
  9291. hda_nid_t nid;
  9292. spec->multiout.dac_nids = spec->private_dac_nids;
  9293. for (i = 0; i < cfg->line_outs; i++) {
  9294. nid = cfg->line_out_pins[i];
  9295. if (nid) {
  9296. if (i >= ARRAY_SIZE(alc861_dac_nids))
  9297. continue;
  9298. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  9299. }
  9300. }
  9301. spec->multiout.num_dacs = cfg->line_outs;
  9302. return 0;
  9303. }
  9304. /* add playback controls from the parsed DAC table */
  9305. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  9306. const struct auto_pin_cfg *cfg)
  9307. {
  9308. char name[32];
  9309. static const char *chname[4] = {
  9310. "Front", "Surround", NULL /*CLFE*/, "Side"
  9311. };
  9312. hda_nid_t nid;
  9313. int i, idx, err;
  9314. for (i = 0; i < cfg->line_outs; i++) {
  9315. nid = spec->multiout.dac_nids[i];
  9316. if (!nid)
  9317. continue;
  9318. if (nid == 0x05) {
  9319. /* Center/LFE */
  9320. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9321. "Center Playback Switch",
  9322. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9323. HDA_OUTPUT));
  9324. if (err < 0)
  9325. return err;
  9326. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9327. "LFE Playback Switch",
  9328. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9329. HDA_OUTPUT));
  9330. if (err < 0)
  9331. return err;
  9332. } else {
  9333. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  9334. idx++)
  9335. if (nid == alc861_dac_nids[idx])
  9336. break;
  9337. sprintf(name, "%s Playback Switch", chname[idx]);
  9338. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9339. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9340. HDA_OUTPUT));
  9341. if (err < 0)
  9342. return err;
  9343. }
  9344. }
  9345. return 0;
  9346. }
  9347. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  9348. {
  9349. int err;
  9350. hda_nid_t nid;
  9351. if (!pin)
  9352. return 0;
  9353. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  9354. nid = 0x03;
  9355. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  9356. "Headphone Playback Switch",
  9357. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9358. if (err < 0)
  9359. return err;
  9360. spec->multiout.hp_nid = nid;
  9361. }
  9362. return 0;
  9363. }
  9364. /* create playback/capture controls for input pins */
  9365. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  9366. const struct auto_pin_cfg *cfg)
  9367. {
  9368. struct hda_input_mux *imux = &spec->private_imux;
  9369. int i, err, idx, idx1;
  9370. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9371. switch (cfg->input_pins[i]) {
  9372. case 0x0c:
  9373. idx1 = 1;
  9374. idx = 2; /* Line In */
  9375. break;
  9376. case 0x0f:
  9377. idx1 = 2;
  9378. idx = 2; /* Line In */
  9379. break;
  9380. case 0x0d:
  9381. idx1 = 0;
  9382. idx = 1; /* Mic In */
  9383. break;
  9384. case 0x10:
  9385. idx1 = 3;
  9386. idx = 1; /* Mic In */
  9387. break;
  9388. case 0x11:
  9389. idx1 = 4;
  9390. idx = 0; /* CD */
  9391. break;
  9392. default:
  9393. continue;
  9394. }
  9395. err = new_analog_input(spec, cfg->input_pins[i],
  9396. auto_pin_cfg_labels[i], idx, 0x15);
  9397. if (err < 0)
  9398. return err;
  9399. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  9400. imux->items[imux->num_items].index = idx1;
  9401. imux->num_items++;
  9402. }
  9403. return 0;
  9404. }
  9405. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  9406. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9407. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9408. {
  9409. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9410. /* The multiple "Capture Source" controls confuse alsamixer
  9411. * So call somewhat different..
  9412. *FIXME: the controls appear in the "playback" view!
  9413. */
  9414. /* .name = "Capture Source", */
  9415. .name = "Input Source",
  9416. .count = 1,
  9417. .info = alc_mux_enum_info,
  9418. .get = alc_mux_enum_get,
  9419. .put = alc_mux_enum_put,
  9420. },
  9421. { } /* end */
  9422. };
  9423. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  9424. hda_nid_t nid,
  9425. int pin_type, int dac_idx)
  9426. {
  9427. /* set as output */
  9428. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  9429. pin_type);
  9430. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9431. AMP_OUT_UNMUTE);
  9432. }
  9433. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  9434. {
  9435. struct alc_spec *spec = codec->spec;
  9436. int i;
  9437. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  9438. for (i = 0; i < spec->autocfg.line_outs; i++) {
  9439. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9440. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9441. if (nid)
  9442. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  9443. spec->multiout.dac_nids[i]);
  9444. }
  9445. }
  9446. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  9447. {
  9448. struct alc_spec *spec = codec->spec;
  9449. hda_nid_t pin;
  9450. pin = spec->autocfg.hp_pins[0];
  9451. if (pin) /* connect to front */
  9452. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  9453. spec->multiout.dac_nids[0]);
  9454. }
  9455. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  9456. {
  9457. struct alc_spec *spec = codec->spec;
  9458. int i;
  9459. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9460. hda_nid_t nid = spec->autocfg.input_pins[i];
  9461. if (nid >= 0x0c && nid <= 0x11) {
  9462. snd_hda_codec_write(codec, nid, 0,
  9463. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9464. i <= AUTO_PIN_FRONT_MIC ?
  9465. PIN_VREF80 : PIN_IN);
  9466. }
  9467. }
  9468. }
  9469. /* parse the BIOS configuration and set up the alc_spec */
  9470. /* return 1 if successful, 0 if the proper config is not found,
  9471. * or a negative error code
  9472. */
  9473. static int alc861_parse_auto_config(struct hda_codec *codec)
  9474. {
  9475. struct alc_spec *spec = codec->spec;
  9476. int err;
  9477. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  9478. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9479. alc861_ignore);
  9480. if (err < 0)
  9481. return err;
  9482. if (!spec->autocfg.line_outs)
  9483. return 0; /* can't find valid BIOS pin config */
  9484. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  9485. if (err < 0)
  9486. return err;
  9487. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9488. if (err < 0)
  9489. return err;
  9490. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  9491. if (err < 0)
  9492. return err;
  9493. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9494. if (err < 0)
  9495. return err;
  9496. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9497. if (spec->autocfg.dig_out_pin)
  9498. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  9499. if (spec->kctl_alloc)
  9500. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9501. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  9502. spec->num_mux_defs = 1;
  9503. spec->input_mux = &spec->private_imux;
  9504. spec->adc_nids = alc861_adc_nids;
  9505. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  9506. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  9507. spec->num_mixers++;
  9508. return 1;
  9509. }
  9510. /* additional initialization for auto-configuration model */
  9511. static void alc861_auto_init(struct hda_codec *codec)
  9512. {
  9513. alc861_auto_init_multi_out(codec);
  9514. alc861_auto_init_hp_out(codec);
  9515. alc861_auto_init_analog_input(codec);
  9516. }
  9517. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9518. static struct hda_amp_list alc861_loopbacks[] = {
  9519. { 0x15, HDA_INPUT, 0 },
  9520. { 0x15, HDA_INPUT, 1 },
  9521. { 0x15, HDA_INPUT, 2 },
  9522. { 0x15, HDA_INPUT, 3 },
  9523. { } /* end */
  9524. };
  9525. #endif
  9526. /*
  9527. * configuration and preset
  9528. */
  9529. static const char *alc861_models[ALC861_MODEL_LAST] = {
  9530. [ALC861_3ST] = "3stack",
  9531. [ALC660_3ST] = "3stack-660",
  9532. [ALC861_3ST_DIG] = "3stack-dig",
  9533. [ALC861_6ST_DIG] = "6stack-dig",
  9534. [ALC861_UNIWILL_M31] = "uniwill-m31",
  9535. [ALC861_TOSHIBA] = "toshiba",
  9536. [ALC861_ASUS] = "asus",
  9537. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  9538. [ALC861_AUTO] = "auto",
  9539. };
  9540. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  9541. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9542. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9543. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9544. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9545. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9546. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9547. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9548. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9549. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9550. * Any other models that need this preset?
  9551. */
  9552. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9553. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9554. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  9555. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9556. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9557. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9558. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9559. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9560. {}
  9561. };
  9562. static struct alc_config_preset alc861_presets[] = {
  9563. [ALC861_3ST] = {
  9564. .mixers = { alc861_3ST_mixer },
  9565. .init_verbs = { alc861_threestack_init_verbs },
  9566. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9567. .dac_nids = alc861_dac_nids,
  9568. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9569. .channel_mode = alc861_threestack_modes,
  9570. .need_dac_fix = 1,
  9571. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9572. .adc_nids = alc861_adc_nids,
  9573. .input_mux = &alc861_capture_source,
  9574. },
  9575. [ALC861_3ST_DIG] = {
  9576. .mixers = { alc861_base_mixer },
  9577. .init_verbs = { alc861_threestack_init_verbs },
  9578. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9579. .dac_nids = alc861_dac_nids,
  9580. .dig_out_nid = ALC861_DIGOUT_NID,
  9581. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9582. .channel_mode = alc861_threestack_modes,
  9583. .need_dac_fix = 1,
  9584. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9585. .adc_nids = alc861_adc_nids,
  9586. .input_mux = &alc861_capture_source,
  9587. },
  9588. [ALC861_6ST_DIG] = {
  9589. .mixers = { alc861_base_mixer },
  9590. .init_verbs = { alc861_base_init_verbs },
  9591. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9592. .dac_nids = alc861_dac_nids,
  9593. .dig_out_nid = ALC861_DIGOUT_NID,
  9594. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  9595. .channel_mode = alc861_8ch_modes,
  9596. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9597. .adc_nids = alc861_adc_nids,
  9598. .input_mux = &alc861_capture_source,
  9599. },
  9600. [ALC660_3ST] = {
  9601. .mixers = { alc861_3ST_mixer },
  9602. .init_verbs = { alc861_threestack_init_verbs },
  9603. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  9604. .dac_nids = alc660_dac_nids,
  9605. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9606. .channel_mode = alc861_threestack_modes,
  9607. .need_dac_fix = 1,
  9608. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9609. .adc_nids = alc861_adc_nids,
  9610. .input_mux = &alc861_capture_source,
  9611. },
  9612. [ALC861_UNIWILL_M31] = {
  9613. .mixers = { alc861_uniwill_m31_mixer },
  9614. .init_verbs = { alc861_uniwill_m31_init_verbs },
  9615. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9616. .dac_nids = alc861_dac_nids,
  9617. .dig_out_nid = ALC861_DIGOUT_NID,
  9618. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9619. .channel_mode = alc861_uniwill_m31_modes,
  9620. .need_dac_fix = 1,
  9621. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9622. .adc_nids = alc861_adc_nids,
  9623. .input_mux = &alc861_capture_source,
  9624. },
  9625. [ALC861_TOSHIBA] = {
  9626. .mixers = { alc861_toshiba_mixer },
  9627. .init_verbs = { alc861_base_init_verbs,
  9628. alc861_toshiba_init_verbs },
  9629. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9630. .dac_nids = alc861_dac_nids,
  9631. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9632. .channel_mode = alc883_3ST_2ch_modes,
  9633. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9634. .adc_nids = alc861_adc_nids,
  9635. .input_mux = &alc861_capture_source,
  9636. .unsol_event = alc861_toshiba_unsol_event,
  9637. .init_hook = alc861_toshiba_automute,
  9638. },
  9639. [ALC861_ASUS] = {
  9640. .mixers = { alc861_asus_mixer },
  9641. .init_verbs = { alc861_asus_init_verbs },
  9642. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9643. .dac_nids = alc861_dac_nids,
  9644. .dig_out_nid = ALC861_DIGOUT_NID,
  9645. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  9646. .channel_mode = alc861_asus_modes,
  9647. .need_dac_fix = 1,
  9648. .hp_nid = 0x06,
  9649. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9650. .adc_nids = alc861_adc_nids,
  9651. .input_mux = &alc861_capture_source,
  9652. },
  9653. [ALC861_ASUS_LAPTOP] = {
  9654. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  9655. .init_verbs = { alc861_asus_init_verbs,
  9656. alc861_asus_laptop_init_verbs },
  9657. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9658. .dac_nids = alc861_dac_nids,
  9659. .dig_out_nid = ALC861_DIGOUT_NID,
  9660. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9661. .channel_mode = alc883_3ST_2ch_modes,
  9662. .need_dac_fix = 1,
  9663. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9664. .adc_nids = alc861_adc_nids,
  9665. .input_mux = &alc861_capture_source,
  9666. },
  9667. };
  9668. static int patch_alc861(struct hda_codec *codec)
  9669. {
  9670. struct alc_spec *spec;
  9671. int board_config;
  9672. int err;
  9673. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9674. if (spec == NULL)
  9675. return -ENOMEM;
  9676. codec->spec = spec;
  9677. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9678. alc861_models,
  9679. alc861_cfg_tbl);
  9680. if (board_config < 0) {
  9681. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9682. "trying auto-probe from BIOS...\n");
  9683. board_config = ALC861_AUTO;
  9684. }
  9685. if (board_config == ALC861_AUTO) {
  9686. /* automatic parse from the BIOS config */
  9687. err = alc861_parse_auto_config(codec);
  9688. if (err < 0) {
  9689. alc_free(codec);
  9690. return err;
  9691. } else if (!err) {
  9692. printk(KERN_INFO
  9693. "hda_codec: Cannot set up configuration "
  9694. "from BIOS. Using base mode...\n");
  9695. board_config = ALC861_3ST_DIG;
  9696. }
  9697. }
  9698. if (board_config != ALC861_AUTO)
  9699. setup_preset(spec, &alc861_presets[board_config]);
  9700. spec->stream_name_analog = "ALC861 Analog";
  9701. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  9702. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  9703. spec->stream_name_digital = "ALC861 Digital";
  9704. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  9705. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  9706. codec->patch_ops = alc_patch_ops;
  9707. if (board_config == ALC861_AUTO)
  9708. spec->init_hook = alc861_auto_init;
  9709. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9710. if (!spec->loopback.amplist)
  9711. spec->loopback.amplist = alc861_loopbacks;
  9712. #endif
  9713. return 0;
  9714. }
  9715. /*
  9716. * ALC861-VD support
  9717. *
  9718. * Based on ALC882
  9719. *
  9720. * In addition, an independent DAC
  9721. */
  9722. #define ALC861VD_DIGOUT_NID 0x06
  9723. static hda_nid_t alc861vd_dac_nids[4] = {
  9724. /* front, surr, clfe, side surr */
  9725. 0x02, 0x03, 0x04, 0x05
  9726. };
  9727. /* dac_nids for ALC660vd are in a different order - according to
  9728. * Realtek's driver.
  9729. * This should probably tesult in a different mixer for 6stack models
  9730. * of ALC660vd codecs, but for now there is only 3stack mixer
  9731. * - and it is the same as in 861vd.
  9732. * adc_nids in ALC660vd are (is) the same as in 861vd
  9733. */
  9734. static hda_nid_t alc660vd_dac_nids[3] = {
  9735. /* front, rear, clfe, rear_surr */
  9736. 0x02, 0x04, 0x03
  9737. };
  9738. static hda_nid_t alc861vd_adc_nids[1] = {
  9739. /* ADC0 */
  9740. 0x09,
  9741. };
  9742. /* input MUX */
  9743. /* FIXME: should be a matrix-type input source selection */
  9744. static struct hda_input_mux alc861vd_capture_source = {
  9745. .num_items = 4,
  9746. .items = {
  9747. { "Mic", 0x0 },
  9748. { "Front Mic", 0x1 },
  9749. { "Line", 0x2 },
  9750. { "CD", 0x4 },
  9751. },
  9752. };
  9753. static struct hda_input_mux alc861vd_dallas_capture_source = {
  9754. .num_items = 3,
  9755. .items = {
  9756. { "Front Mic", 0x0 },
  9757. { "ATAPI Mic", 0x1 },
  9758. { "Line In", 0x5 },
  9759. },
  9760. };
  9761. static struct hda_input_mux alc861vd_hp_capture_source = {
  9762. .num_items = 2,
  9763. .items = {
  9764. { "Front Mic", 0x0 },
  9765. { "ATAPI Mic", 0x1 },
  9766. },
  9767. };
  9768. #define alc861vd_mux_enum_info alc_mux_enum_info
  9769. #define alc861vd_mux_enum_get alc_mux_enum_get
  9770. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  9771. struct snd_ctl_elem_value *ucontrol)
  9772. {
  9773. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9774. struct alc_spec *spec = codec->spec;
  9775. const struct hda_input_mux *imux = spec->input_mux;
  9776. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9777. static hda_nid_t capture_mixers[1] = { 0x22 };
  9778. hda_nid_t nid = capture_mixers[adc_idx];
  9779. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9780. unsigned int i, idx;
  9781. idx = ucontrol->value.enumerated.item[0];
  9782. if (idx >= imux->num_items)
  9783. idx = imux->num_items - 1;
  9784. if (*cur_val == idx)
  9785. return 0;
  9786. for (i = 0; i < imux->num_items; i++) {
  9787. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9788. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9789. imux->items[i].index,
  9790. HDA_AMP_MUTE, v);
  9791. }
  9792. *cur_val = idx;
  9793. return 1;
  9794. }
  9795. /*
  9796. * 2ch mode
  9797. */
  9798. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9799. { 2, NULL }
  9800. };
  9801. /*
  9802. * 6ch mode
  9803. */
  9804. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9805. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9806. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9807. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9808. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9809. { } /* end */
  9810. };
  9811. /*
  9812. * 8ch mode
  9813. */
  9814. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9815. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9816. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9817. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9818. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9819. { } /* end */
  9820. };
  9821. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9822. { 6, alc861vd_6stack_ch6_init },
  9823. { 8, alc861vd_6stack_ch8_init },
  9824. };
  9825. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9826. {
  9827. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9828. .name = "Channel Mode",
  9829. .info = alc_ch_mode_info,
  9830. .get = alc_ch_mode_get,
  9831. .put = alc_ch_mode_put,
  9832. },
  9833. { } /* end */
  9834. };
  9835. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9836. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9837. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9838. {
  9839. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9840. /* The multiple "Capture Source" controls confuse alsamixer
  9841. * So call somewhat different..
  9842. *FIXME: the controls appear in the "playback" view!
  9843. */
  9844. /* .name = "Capture Source", */
  9845. .name = "Input Source",
  9846. .count = 1,
  9847. .info = alc861vd_mux_enum_info,
  9848. .get = alc861vd_mux_enum_get,
  9849. .put = alc861vd_mux_enum_put,
  9850. },
  9851. { } /* end */
  9852. };
  9853. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9854. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9855. */
  9856. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9857. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9858. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9859. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9860. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9861. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9862. HDA_OUTPUT),
  9863. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9864. HDA_OUTPUT),
  9865. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9866. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9867. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9868. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9869. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9870. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9871. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9872. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9873. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9874. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9875. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9876. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9877. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9878. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9879. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9880. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9881. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9882. { } /* end */
  9883. };
  9884. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9885. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9886. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9887. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9888. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9889. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9890. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9891. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9892. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9893. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9894. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9895. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9896. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9897. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9898. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9899. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9900. { } /* end */
  9901. };
  9902. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9903. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9904. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9905. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9906. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9907. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9908. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9909. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9910. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9911. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9912. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9913. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9914. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9915. { } /* end */
  9916. };
  9917. /* Pin assignment: Front=0x14, HP = 0x15,
  9918. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9919. */
  9920. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9921. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9922. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9923. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9924. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9925. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9926. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9927. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9928. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9929. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9930. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9931. { } /* end */
  9932. };
  9933. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  9934. * Front Mic=0x18, ATAPI Mic = 0x19,
  9935. */
  9936. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  9937. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9938. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9939. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9940. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9941. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9942. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9943. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9944. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9945. { } /* end */
  9946. };
  9947. /*
  9948. * generic initialization of ADC, input mixers and output mixers
  9949. */
  9950. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9951. /*
  9952. * Unmute ADC0 and set the default input to mic-in
  9953. */
  9954. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9955. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9956. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9957. * the analog-loopback mixer widget
  9958. */
  9959. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9960. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9961. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9962. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9963. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9964. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9965. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9966. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9967. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9968. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9969. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9970. /*
  9971. * Set up output mixers (0x02 - 0x05)
  9972. */
  9973. /* set vol=0 to output mixers */
  9974. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9975. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9976. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9977. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9978. /* set up input amps for analog loopback */
  9979. /* Amp Indices: DAC = 0, mixer = 1 */
  9980. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9981. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9982. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9983. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9984. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9985. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9986. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9987. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9988. { }
  9989. };
  9990. /*
  9991. * 3-stack pin configuration:
  9992. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9993. */
  9994. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9995. /*
  9996. * Set pin mode and muting
  9997. */
  9998. /* set front pin widgets 0x14 for output */
  9999. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10000. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10001. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  10002. /* Mic (rear) pin: input vref at 80% */
  10003. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10004. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10005. /* Front Mic pin: input vref at 80% */
  10006. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10007. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10008. /* Line In pin: input */
  10009. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10010. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10011. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10012. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10013. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10014. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10015. /* CD pin widget for input */
  10016. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10017. { }
  10018. };
  10019. /*
  10020. * 6-stack pin configuration:
  10021. */
  10022. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  10023. /*
  10024. * Set pin mode and muting
  10025. */
  10026. /* set front pin widgets 0x14 for output */
  10027. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10028. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10029. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  10030. /* Rear Pin: output 1 (0x0d) */
  10031. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10032. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10033. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  10034. /* CLFE Pin: output 2 (0x0e) */
  10035. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10036. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10037. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  10038. /* Side Pin: output 3 (0x0f) */
  10039. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10040. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10041. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  10042. /* Mic (rear) pin: input vref at 80% */
  10043. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10044. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10045. /* Front Mic pin: input vref at 80% */
  10046. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10047. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10048. /* Line In pin: input */
  10049. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10050. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10051. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10052. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10053. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10054. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10055. /* CD pin widget for input */
  10056. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10057. { }
  10058. };
  10059. static struct hda_verb alc861vd_eapd_verbs[] = {
  10060. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  10061. { }
  10062. };
  10063. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  10064. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10065. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10066. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  10067. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  10068. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  10069. {}
  10070. };
  10071. /* toggle speaker-output according to the hp-jack state */
  10072. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  10073. {
  10074. unsigned int present;
  10075. unsigned char bits;
  10076. present = snd_hda_codec_read(codec, 0x1b, 0,
  10077. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10078. bits = present ? HDA_AMP_MUTE : 0;
  10079. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10080. HDA_AMP_MUTE, bits);
  10081. }
  10082. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  10083. {
  10084. unsigned int present;
  10085. unsigned char bits;
  10086. present = snd_hda_codec_read(codec, 0x18, 0,
  10087. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10088. bits = present ? HDA_AMP_MUTE : 0;
  10089. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  10090. HDA_AMP_MUTE, bits);
  10091. }
  10092. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  10093. {
  10094. alc861vd_lenovo_hp_automute(codec);
  10095. alc861vd_lenovo_mic_automute(codec);
  10096. }
  10097. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  10098. unsigned int res)
  10099. {
  10100. switch (res >> 26) {
  10101. case ALC880_HP_EVENT:
  10102. alc861vd_lenovo_hp_automute(codec);
  10103. break;
  10104. case ALC880_MIC_EVENT:
  10105. alc861vd_lenovo_mic_automute(codec);
  10106. break;
  10107. }
  10108. }
  10109. static struct hda_verb alc861vd_dallas_verbs[] = {
  10110. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10111. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10112. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10113. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10114. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10115. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10116. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10117. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10118. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10119. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10120. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10121. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10122. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10123. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10124. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10125. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10126. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10127. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10128. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10129. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10130. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  10131. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10132. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  10133. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10134. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10135. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10136. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10137. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10138. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10139. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10140. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10141. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10142. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10143. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10144. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  10145. { } /* end */
  10146. };
  10147. /* toggle speaker-output according to the hp-jack state */
  10148. static void alc861vd_dallas_automute(struct hda_codec *codec)
  10149. {
  10150. unsigned int present;
  10151. present = snd_hda_codec_read(codec, 0x15, 0,
  10152. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10153. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10154. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  10155. }
  10156. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  10157. {
  10158. if ((res >> 26) == ALC880_HP_EVENT)
  10159. alc861vd_dallas_automute(codec);
  10160. }
  10161. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10162. #define alc861vd_loopbacks alc880_loopbacks
  10163. #endif
  10164. /* pcm configuration: identiacal with ALC880 */
  10165. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  10166. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  10167. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  10168. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  10169. /*
  10170. * configuration and preset
  10171. */
  10172. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  10173. [ALC660VD_3ST] = "3stack-660",
  10174. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  10175. [ALC861VD_3ST] = "3stack",
  10176. [ALC861VD_3ST_DIG] = "3stack-digout",
  10177. [ALC861VD_6ST_DIG] = "6stack-digout",
  10178. [ALC861VD_LENOVO] = "lenovo",
  10179. [ALC861VD_DALLAS] = "dallas",
  10180. [ALC861VD_HP] = "hp",
  10181. [ALC861VD_AUTO] = "auto",
  10182. };
  10183. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  10184. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  10185. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  10186. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  10187. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  10188. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  10189. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  10190. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  10191. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  10192. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  10193. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  10194. SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
  10195. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  10196. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  10197. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  10198. {}
  10199. };
  10200. static struct alc_config_preset alc861vd_presets[] = {
  10201. [ALC660VD_3ST] = {
  10202. .mixers = { alc861vd_3st_mixer },
  10203. .init_verbs = { alc861vd_volume_init_verbs,
  10204. alc861vd_3stack_init_verbs },
  10205. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10206. .dac_nids = alc660vd_dac_nids,
  10207. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10208. .adc_nids = alc861vd_adc_nids,
  10209. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10210. .channel_mode = alc861vd_3stack_2ch_modes,
  10211. .input_mux = &alc861vd_capture_source,
  10212. },
  10213. [ALC660VD_3ST_DIG] = {
  10214. .mixers = { alc861vd_3st_mixer },
  10215. .init_verbs = { alc861vd_volume_init_verbs,
  10216. alc861vd_3stack_init_verbs },
  10217. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10218. .dac_nids = alc660vd_dac_nids,
  10219. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10220. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10221. .adc_nids = alc861vd_adc_nids,
  10222. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10223. .channel_mode = alc861vd_3stack_2ch_modes,
  10224. .input_mux = &alc861vd_capture_source,
  10225. },
  10226. [ALC861VD_3ST] = {
  10227. .mixers = { alc861vd_3st_mixer },
  10228. .init_verbs = { alc861vd_volume_init_verbs,
  10229. alc861vd_3stack_init_verbs },
  10230. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10231. .dac_nids = alc861vd_dac_nids,
  10232. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10233. .channel_mode = alc861vd_3stack_2ch_modes,
  10234. .input_mux = &alc861vd_capture_source,
  10235. },
  10236. [ALC861VD_3ST_DIG] = {
  10237. .mixers = { alc861vd_3st_mixer },
  10238. .init_verbs = { alc861vd_volume_init_verbs,
  10239. alc861vd_3stack_init_verbs },
  10240. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10241. .dac_nids = alc861vd_dac_nids,
  10242. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10243. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10244. .channel_mode = alc861vd_3stack_2ch_modes,
  10245. .input_mux = &alc861vd_capture_source,
  10246. },
  10247. [ALC861VD_6ST_DIG] = {
  10248. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  10249. .init_verbs = { alc861vd_volume_init_verbs,
  10250. alc861vd_6stack_init_verbs },
  10251. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10252. .dac_nids = alc861vd_dac_nids,
  10253. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10254. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  10255. .channel_mode = alc861vd_6stack_modes,
  10256. .input_mux = &alc861vd_capture_source,
  10257. },
  10258. [ALC861VD_LENOVO] = {
  10259. .mixers = { alc861vd_lenovo_mixer },
  10260. .init_verbs = { alc861vd_volume_init_verbs,
  10261. alc861vd_3stack_init_verbs,
  10262. alc861vd_eapd_verbs,
  10263. alc861vd_lenovo_unsol_verbs },
  10264. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10265. .dac_nids = alc660vd_dac_nids,
  10266. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10267. .adc_nids = alc861vd_adc_nids,
  10268. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10269. .channel_mode = alc861vd_3stack_2ch_modes,
  10270. .input_mux = &alc861vd_capture_source,
  10271. .unsol_event = alc861vd_lenovo_unsol_event,
  10272. .init_hook = alc861vd_lenovo_automute,
  10273. },
  10274. [ALC861VD_DALLAS] = {
  10275. .mixers = { alc861vd_dallas_mixer },
  10276. .init_verbs = { alc861vd_dallas_verbs },
  10277. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10278. .dac_nids = alc861vd_dac_nids,
  10279. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10280. .adc_nids = alc861vd_adc_nids,
  10281. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10282. .channel_mode = alc861vd_3stack_2ch_modes,
  10283. .input_mux = &alc861vd_dallas_capture_source,
  10284. .unsol_event = alc861vd_dallas_unsol_event,
  10285. .init_hook = alc861vd_dallas_automute,
  10286. },
  10287. [ALC861VD_HP] = {
  10288. .mixers = { alc861vd_hp_mixer },
  10289. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  10290. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10291. .dac_nids = alc861vd_dac_nids,
  10292. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10293. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10294. .adc_nids = alc861vd_adc_nids,
  10295. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10296. .channel_mode = alc861vd_3stack_2ch_modes,
  10297. .input_mux = &alc861vd_hp_capture_source,
  10298. .unsol_event = alc861vd_dallas_unsol_event,
  10299. .init_hook = alc861vd_dallas_automute,
  10300. },
  10301. };
  10302. /*
  10303. * BIOS auto configuration
  10304. */
  10305. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  10306. hda_nid_t nid, int pin_type, int dac_idx)
  10307. {
  10308. /* set as output */
  10309. snd_hda_codec_write(codec, nid, 0,
  10310. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10311. snd_hda_codec_write(codec, nid, 0,
  10312. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10313. }
  10314. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  10315. {
  10316. struct alc_spec *spec = codec->spec;
  10317. int i;
  10318. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  10319. for (i = 0; i <= HDA_SIDE; i++) {
  10320. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10321. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10322. if (nid)
  10323. alc861vd_auto_set_output_and_unmute(codec, nid,
  10324. pin_type, i);
  10325. }
  10326. }
  10327. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  10328. {
  10329. struct alc_spec *spec = codec->spec;
  10330. hda_nid_t pin;
  10331. pin = spec->autocfg.hp_pins[0];
  10332. if (pin) /* connect to front and use dac 0 */
  10333. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10334. }
  10335. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  10336. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  10337. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  10338. {
  10339. struct alc_spec *spec = codec->spec;
  10340. int i;
  10341. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10342. hda_nid_t nid = spec->autocfg.input_pins[i];
  10343. if (alc861vd_is_input_pin(nid)) {
  10344. snd_hda_codec_write(codec, nid, 0,
  10345. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10346. i <= AUTO_PIN_FRONT_MIC ?
  10347. PIN_VREF80 : PIN_IN);
  10348. if (nid != ALC861VD_PIN_CD_NID)
  10349. snd_hda_codec_write(codec, nid, 0,
  10350. AC_VERB_SET_AMP_GAIN_MUTE,
  10351. AMP_OUT_MUTE);
  10352. }
  10353. }
  10354. }
  10355. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  10356. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  10357. /* add playback controls from the parsed DAC table */
  10358. /* Based on ALC880 version. But ALC861VD has separate,
  10359. * different NIDs for mute/unmute switch and volume control */
  10360. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  10361. const struct auto_pin_cfg *cfg)
  10362. {
  10363. char name[32];
  10364. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  10365. hda_nid_t nid_v, nid_s;
  10366. int i, err;
  10367. for (i = 0; i < cfg->line_outs; i++) {
  10368. if (!spec->multiout.dac_nids[i])
  10369. continue;
  10370. nid_v = alc861vd_idx_to_mixer_vol(
  10371. alc880_dac_to_idx(
  10372. spec->multiout.dac_nids[i]));
  10373. nid_s = alc861vd_idx_to_mixer_switch(
  10374. alc880_dac_to_idx(
  10375. spec->multiout.dac_nids[i]));
  10376. if (i == 2) {
  10377. /* Center/LFE */
  10378. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10379. "Center Playback Volume",
  10380. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  10381. HDA_OUTPUT));
  10382. if (err < 0)
  10383. return err;
  10384. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10385. "LFE Playback Volume",
  10386. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  10387. HDA_OUTPUT));
  10388. if (err < 0)
  10389. return err;
  10390. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10391. "Center Playback Switch",
  10392. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  10393. HDA_INPUT));
  10394. if (err < 0)
  10395. return err;
  10396. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10397. "LFE Playback Switch",
  10398. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  10399. HDA_INPUT));
  10400. if (err < 0)
  10401. return err;
  10402. } else {
  10403. sprintf(name, "%s Playback Volume", chname[i]);
  10404. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10405. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  10406. HDA_OUTPUT));
  10407. if (err < 0)
  10408. return err;
  10409. sprintf(name, "%s Playback Switch", chname[i]);
  10410. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10411. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  10412. HDA_INPUT));
  10413. if (err < 0)
  10414. return err;
  10415. }
  10416. }
  10417. return 0;
  10418. }
  10419. /* add playback controls for speaker and HP outputs */
  10420. /* Based on ALC880 version. But ALC861VD has separate,
  10421. * different NIDs for mute/unmute switch and volume control */
  10422. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  10423. hda_nid_t pin, const char *pfx)
  10424. {
  10425. hda_nid_t nid_v, nid_s;
  10426. int err;
  10427. char name[32];
  10428. if (!pin)
  10429. return 0;
  10430. if (alc880_is_fixed_pin(pin)) {
  10431. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10432. /* specify the DAC as the extra output */
  10433. if (!spec->multiout.hp_nid)
  10434. spec->multiout.hp_nid = nid_v;
  10435. else
  10436. spec->multiout.extra_out_nid[0] = nid_v;
  10437. /* control HP volume/switch on the output mixer amp */
  10438. nid_v = alc861vd_idx_to_mixer_vol(
  10439. alc880_fixed_pin_idx(pin));
  10440. nid_s = alc861vd_idx_to_mixer_switch(
  10441. alc880_fixed_pin_idx(pin));
  10442. sprintf(name, "%s Playback Volume", pfx);
  10443. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10444. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  10445. if (err < 0)
  10446. return err;
  10447. sprintf(name, "%s Playback Switch", pfx);
  10448. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10449. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  10450. if (err < 0)
  10451. return err;
  10452. } else if (alc880_is_multi_pin(pin)) {
  10453. /* set manual connection */
  10454. /* we have only a switch on HP-out PIN */
  10455. sprintf(name, "%s Playback Switch", pfx);
  10456. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10457. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10458. if (err < 0)
  10459. return err;
  10460. }
  10461. return 0;
  10462. }
  10463. /* parse the BIOS configuration and set up the alc_spec
  10464. * return 1 if successful, 0 if the proper config is not found,
  10465. * or a negative error code
  10466. * Based on ALC880 version - had to change it to override
  10467. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  10468. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  10469. {
  10470. struct alc_spec *spec = codec->spec;
  10471. int err;
  10472. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  10473. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10474. alc861vd_ignore);
  10475. if (err < 0)
  10476. return err;
  10477. if (!spec->autocfg.line_outs)
  10478. return 0; /* can't find valid BIOS pin config */
  10479. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10480. if (err < 0)
  10481. return err;
  10482. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10483. if (err < 0)
  10484. return err;
  10485. err = alc861vd_auto_create_extra_out(spec,
  10486. spec->autocfg.speaker_pins[0],
  10487. "Speaker");
  10488. if (err < 0)
  10489. return err;
  10490. err = alc861vd_auto_create_extra_out(spec,
  10491. spec->autocfg.hp_pins[0],
  10492. "Headphone");
  10493. if (err < 0)
  10494. return err;
  10495. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10496. if (err < 0)
  10497. return err;
  10498. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10499. if (spec->autocfg.dig_out_pin)
  10500. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  10501. if (spec->kctl_alloc)
  10502. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10503. spec->init_verbs[spec->num_init_verbs++]
  10504. = alc861vd_volume_init_verbs;
  10505. spec->num_mux_defs = 1;
  10506. spec->input_mux = &spec->private_imux;
  10507. err = alc_auto_add_mic_boost(codec);
  10508. if (err < 0)
  10509. return err;
  10510. return 1;
  10511. }
  10512. /* additional initialization for auto-configuration model */
  10513. static void alc861vd_auto_init(struct hda_codec *codec)
  10514. {
  10515. alc861vd_auto_init_multi_out(codec);
  10516. alc861vd_auto_init_hp_out(codec);
  10517. alc861vd_auto_init_analog_input(codec);
  10518. }
  10519. static int patch_alc861vd(struct hda_codec *codec)
  10520. {
  10521. struct alc_spec *spec;
  10522. int err, board_config;
  10523. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10524. if (spec == NULL)
  10525. return -ENOMEM;
  10526. codec->spec = spec;
  10527. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  10528. alc861vd_models,
  10529. alc861vd_cfg_tbl);
  10530. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  10531. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  10532. "ALC861VD, trying auto-probe from BIOS...\n");
  10533. board_config = ALC861VD_AUTO;
  10534. }
  10535. if (board_config == ALC861VD_AUTO) {
  10536. /* automatic parse from the BIOS config */
  10537. err = alc861vd_parse_auto_config(codec);
  10538. if (err < 0) {
  10539. alc_free(codec);
  10540. return err;
  10541. } else if (!err) {
  10542. printk(KERN_INFO
  10543. "hda_codec: Cannot set up configuration "
  10544. "from BIOS. Using base mode...\n");
  10545. board_config = ALC861VD_3ST;
  10546. }
  10547. }
  10548. if (board_config != ALC861VD_AUTO)
  10549. setup_preset(spec, &alc861vd_presets[board_config]);
  10550. spec->stream_name_analog = "ALC861VD Analog";
  10551. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10552. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10553. spec->stream_name_digital = "ALC861VD Digital";
  10554. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10555. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10556. spec->adc_nids = alc861vd_adc_nids;
  10557. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10558. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10559. spec->num_mixers++;
  10560. codec->patch_ops = alc_patch_ops;
  10561. if (board_config == ALC861VD_AUTO)
  10562. spec->init_hook = alc861vd_auto_init;
  10563. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10564. if (!spec->loopback.amplist)
  10565. spec->loopback.amplist = alc861vd_loopbacks;
  10566. #endif
  10567. return 0;
  10568. }
  10569. /*
  10570. * ALC662 support
  10571. *
  10572. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  10573. * configuration. Each pin widget can choose any input DACs and a mixer.
  10574. * Each ADC is connected from a mixer of all inputs. This makes possible
  10575. * 6-channel independent captures.
  10576. *
  10577. * In addition, an independent DAC for the multi-playback (not used in this
  10578. * driver yet).
  10579. */
  10580. #define ALC662_DIGOUT_NID 0x06
  10581. #define ALC662_DIGIN_NID 0x0a
  10582. static hda_nid_t alc662_dac_nids[4] = {
  10583. /* front, rear, clfe, rear_surr */
  10584. 0x02, 0x03, 0x04
  10585. };
  10586. static hda_nid_t alc662_adc_nids[1] = {
  10587. /* ADC1-2 */
  10588. 0x09,
  10589. };
  10590. /* input MUX */
  10591. /* FIXME: should be a matrix-type input source selection */
  10592. static struct hda_input_mux alc662_capture_source = {
  10593. .num_items = 4,
  10594. .items = {
  10595. { "Mic", 0x0 },
  10596. { "Front Mic", 0x1 },
  10597. { "Line", 0x2 },
  10598. { "CD", 0x4 },
  10599. },
  10600. };
  10601. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  10602. .num_items = 2,
  10603. .items = {
  10604. { "Mic", 0x1 },
  10605. { "Line", 0x2 },
  10606. },
  10607. };
  10608. static struct hda_input_mux alc662_eeepc_capture_source = {
  10609. .num_items = 2,
  10610. .items = {
  10611. { "i-Mic", 0x1 },
  10612. { "e-Mic", 0x0 },
  10613. },
  10614. };
  10615. #define alc662_mux_enum_info alc_mux_enum_info
  10616. #define alc662_mux_enum_get alc_mux_enum_get
  10617. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  10618. struct snd_ctl_elem_value *ucontrol)
  10619. {
  10620. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10621. struct alc_spec *spec = codec->spec;
  10622. const struct hda_input_mux *imux = spec->input_mux;
  10623. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10624. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  10625. hda_nid_t nid = capture_mixers[adc_idx];
  10626. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10627. unsigned int i, idx;
  10628. idx = ucontrol->value.enumerated.item[0];
  10629. if (idx >= imux->num_items)
  10630. idx = imux->num_items - 1;
  10631. if (*cur_val == idx)
  10632. return 0;
  10633. for (i = 0; i < imux->num_items; i++) {
  10634. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10635. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10636. imux->items[i].index,
  10637. HDA_AMP_MUTE, v);
  10638. }
  10639. *cur_val = idx;
  10640. return 1;
  10641. }
  10642. /*
  10643. * 2ch mode
  10644. */
  10645. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  10646. { 2, NULL }
  10647. };
  10648. /*
  10649. * 2ch mode
  10650. */
  10651. static struct hda_verb alc662_3ST_ch2_init[] = {
  10652. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  10653. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10654. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  10655. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10656. { } /* end */
  10657. };
  10658. /*
  10659. * 6ch mode
  10660. */
  10661. static struct hda_verb alc662_3ST_ch6_init[] = {
  10662. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10663. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10664. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  10665. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10666. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10667. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  10668. { } /* end */
  10669. };
  10670. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  10671. { 2, alc662_3ST_ch2_init },
  10672. { 6, alc662_3ST_ch6_init },
  10673. };
  10674. /*
  10675. * 2ch mode
  10676. */
  10677. static struct hda_verb alc662_sixstack_ch6_init[] = {
  10678. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10679. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10680. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10681. { } /* end */
  10682. };
  10683. /*
  10684. * 6ch mode
  10685. */
  10686. static struct hda_verb alc662_sixstack_ch8_init[] = {
  10687. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10688. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10689. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10690. { } /* end */
  10691. };
  10692. static struct hda_channel_mode alc662_5stack_modes[2] = {
  10693. { 2, alc662_sixstack_ch6_init },
  10694. { 6, alc662_sixstack_ch8_init },
  10695. };
  10696. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10697. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10698. */
  10699. static struct snd_kcontrol_new alc662_base_mixer[] = {
  10700. /* output mixer control */
  10701. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  10702. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  10703. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  10704. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  10705. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10706. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10707. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10708. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10709. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10710. /*Input mixer control */
  10711. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  10712. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  10713. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  10714. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  10715. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  10716. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  10717. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  10718. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  10719. /* Capture mixer control */
  10720. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10721. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10722. {
  10723. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10724. .name = "Capture Source",
  10725. .count = 1,
  10726. .info = alc_mux_enum_info,
  10727. .get = alc_mux_enum_get,
  10728. .put = alc_mux_enum_put,
  10729. },
  10730. { } /* end */
  10731. };
  10732. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  10733. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10734. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10735. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10736. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10737. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10738. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10739. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10740. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10741. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10742. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10743. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10744. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10745. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10746. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10747. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10748. {
  10749. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10750. /* .name = "Capture Source", */
  10751. .name = "Input Source",
  10752. .count = 1,
  10753. .info = alc662_mux_enum_info,
  10754. .get = alc662_mux_enum_get,
  10755. .put = alc662_mux_enum_put,
  10756. },
  10757. { } /* end */
  10758. };
  10759. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  10760. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10761. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10762. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10763. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  10764. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10765. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10766. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10767. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10768. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10769. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10770. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10771. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10772. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10773. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10774. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10775. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10776. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10777. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10778. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10779. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10780. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10781. {
  10782. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10783. /* .name = "Capture Source", */
  10784. .name = "Input Source",
  10785. .count = 1,
  10786. .info = alc662_mux_enum_info,
  10787. .get = alc662_mux_enum_get,
  10788. .put = alc662_mux_enum_put,
  10789. },
  10790. { } /* end */
  10791. };
  10792. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  10793. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10794. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10795. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10796. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  10797. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10798. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10799. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10800. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10801. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10802. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10803. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10804. {
  10805. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10806. /* .name = "Capture Source", */
  10807. .name = "Input Source",
  10808. .count = 1,
  10809. .info = alc662_mux_enum_info,
  10810. .get = alc662_mux_enum_get,
  10811. .put = alc662_mux_enum_put,
  10812. },
  10813. { } /* end */
  10814. };
  10815. static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
  10816. HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  10817. HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10818. HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10819. HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
  10820. HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10821. HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10822. HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
  10823. HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10824. HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10825. { } /* end */
  10826. };
  10827. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  10828. {
  10829. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10830. .name = "Channel Mode",
  10831. .info = alc_ch_mode_info,
  10832. .get = alc_ch_mode_get,
  10833. .put = alc_ch_mode_put,
  10834. },
  10835. { } /* end */
  10836. };
  10837. static struct hda_verb alc662_init_verbs[] = {
  10838. /* ADC: mute amp left and right */
  10839. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10840. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10841. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10842. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10843. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10844. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10845. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10846. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10847. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10848. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10849. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10850. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10851. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10852. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10853. /* Front Pin: output 0 (0x0c) */
  10854. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10855. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10856. /* Rear Pin: output 1 (0x0d) */
  10857. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10858. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10859. /* CLFE Pin: output 2 (0x0e) */
  10860. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10861. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10862. /* Mic (rear) pin: input vref at 80% */
  10863. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10864. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10865. /* Front Mic pin: input vref at 80% */
  10866. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10867. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10868. /* Line In pin: input */
  10869. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10870. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10871. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10872. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10873. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10874. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10875. /* CD pin widget for input */
  10876. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10877. /* FIXME: use matrix-type input source selection */
  10878. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10879. /* Input mixer */
  10880. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10881. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10882. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10883. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10884. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10885. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10886. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10887. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10888. { }
  10889. };
  10890. static struct hda_verb alc662_sue_init_verbs[] = {
  10891. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10892. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10893. {}
  10894. };
  10895. static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
  10896. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  10897. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  10898. {}
  10899. };
  10900. /*
  10901. * generic initialization of ADC, input mixers and output mixers
  10902. */
  10903. static struct hda_verb alc662_auto_init_verbs[] = {
  10904. /*
  10905. * Unmute ADC and set the default input to mic-in
  10906. */
  10907. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10908. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10909. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10910. * mixer widget
  10911. * Note: PASD motherboards uses the Line In 2 as the input for front
  10912. * panel mic (mic 2)
  10913. */
  10914. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10915. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10916. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10917. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10918. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10919. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10920. /*
  10921. * Set up output mixers (0x0c - 0x0f)
  10922. */
  10923. /* set vol=0 to output mixers */
  10924. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10925. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10926. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10927. /* set up input amps for analog loopback */
  10928. /* Amp Indices: DAC = 0, mixer = 1 */
  10929. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10930. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10931. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10932. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10933. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10934. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10935. /* FIXME: use matrix-type input source selection */
  10936. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10937. /* Input mixer */
  10938. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10939. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10940. { }
  10941. };
  10942. /* capture mixer elements */
  10943. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10944. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10945. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10946. {
  10947. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10948. /* The multiple "Capture Source" controls confuse alsamixer
  10949. * So call somewhat different..
  10950. * FIXME: the controls appear in the "playback" view!
  10951. */
  10952. /* .name = "Capture Source", */
  10953. .name = "Input Source",
  10954. .count = 1,
  10955. .info = alc882_mux_enum_info,
  10956. .get = alc882_mux_enum_get,
  10957. .put = alc882_mux_enum_put,
  10958. },
  10959. { } /* end */
  10960. };
  10961. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10962. {
  10963. unsigned int present;
  10964. unsigned char bits;
  10965. present = snd_hda_codec_read(codec, 0x14, 0,
  10966. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10967. bits = present ? HDA_AMP_MUTE : 0;
  10968. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10969. HDA_AMP_MUTE, bits);
  10970. }
  10971. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10972. {
  10973. unsigned int present;
  10974. unsigned char bits;
  10975. present = snd_hda_codec_read(codec, 0x1b, 0,
  10976. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10977. bits = present ? HDA_AMP_MUTE : 0;
  10978. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10979. HDA_AMP_MUTE, bits);
  10980. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10981. HDA_AMP_MUTE, bits);
  10982. }
  10983. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10984. unsigned int res)
  10985. {
  10986. if ((res >> 26) == ALC880_HP_EVENT)
  10987. alc662_lenovo_101e_all_automute(codec);
  10988. if ((res >> 26) == ALC880_FRONT_EVENT)
  10989. alc662_lenovo_101e_ispeaker_automute(codec);
  10990. }
  10991. static void alc662_eeepc_mic_automute(struct hda_codec *codec)
  10992. {
  10993. unsigned int present;
  10994. present = snd_hda_codec_read(codec, 0x18, 0,
  10995. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10996. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10997. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  10998. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  10999. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  11000. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  11001. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  11002. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  11003. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  11004. }
  11005. /* unsolicited event for HP jack sensing */
  11006. static void alc662_eeepc_unsol_event(struct hda_codec *codec,
  11007. unsigned int res)
  11008. {
  11009. if ((res >> 26) == ALC880_HP_EVENT)
  11010. alc262_hippo1_automute( codec );
  11011. if ((res >> 26) == ALC880_MIC_EVENT)
  11012. alc662_eeepc_mic_automute(codec);
  11013. }
  11014. static void alc662_eeepc_inithook(struct hda_codec *codec)
  11015. {
  11016. alc262_hippo1_automute( codec );
  11017. alc662_eeepc_mic_automute(codec);
  11018. }
  11019. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11020. #define alc662_loopbacks alc880_loopbacks
  11021. #endif
  11022. /* pcm configuration: identiacal with ALC880 */
  11023. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  11024. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  11025. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  11026. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  11027. /*
  11028. * configuration and preset
  11029. */
  11030. static const char *alc662_models[ALC662_MODEL_LAST] = {
  11031. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  11032. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  11033. [ALC662_3ST_6ch] = "3stack-6ch",
  11034. [ALC662_5ST_DIG] = "6stack-dig",
  11035. [ALC662_LENOVO_101E] = "lenovo-101e",
  11036. [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
  11037. [ALC662_AUTO] = "auto",
  11038. };
  11039. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  11040. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  11041. SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
  11042. {}
  11043. };
  11044. static struct alc_config_preset alc662_presets[] = {
  11045. [ALC662_3ST_2ch_DIG] = {
  11046. .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
  11047. .init_verbs = { alc662_init_verbs },
  11048. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11049. .dac_nids = alc662_dac_nids,
  11050. .dig_out_nid = ALC662_DIGOUT_NID,
  11051. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11052. .adc_nids = alc662_adc_nids,
  11053. .dig_in_nid = ALC662_DIGIN_NID,
  11054. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  11055. .channel_mode = alc662_3ST_2ch_modes,
  11056. .input_mux = &alc662_capture_source,
  11057. },
  11058. [ALC662_3ST_6ch_DIG] = {
  11059. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  11060. alc662_capture_mixer },
  11061. .init_verbs = { alc662_init_verbs },
  11062. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11063. .dac_nids = alc662_dac_nids,
  11064. .dig_out_nid = ALC662_DIGOUT_NID,
  11065. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11066. .adc_nids = alc662_adc_nids,
  11067. .dig_in_nid = ALC662_DIGIN_NID,
  11068. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  11069. .channel_mode = alc662_3ST_6ch_modes,
  11070. .need_dac_fix = 1,
  11071. .input_mux = &alc662_capture_source,
  11072. },
  11073. [ALC662_3ST_6ch] = {
  11074. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  11075. alc662_capture_mixer },
  11076. .init_verbs = { alc662_init_verbs },
  11077. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11078. .dac_nids = alc662_dac_nids,
  11079. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11080. .adc_nids = alc662_adc_nids,
  11081. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  11082. .channel_mode = alc662_3ST_6ch_modes,
  11083. .need_dac_fix = 1,
  11084. .input_mux = &alc662_capture_source,
  11085. },
  11086. [ALC662_5ST_DIG] = {
  11087. .mixers = { alc662_base_mixer, alc662_chmode_mixer,
  11088. alc662_capture_mixer },
  11089. .init_verbs = { alc662_init_verbs },
  11090. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11091. .dac_nids = alc662_dac_nids,
  11092. .dig_out_nid = ALC662_DIGOUT_NID,
  11093. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11094. .adc_nids = alc662_adc_nids,
  11095. .dig_in_nid = ALC662_DIGIN_NID,
  11096. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  11097. .channel_mode = alc662_5stack_modes,
  11098. .input_mux = &alc662_capture_source,
  11099. },
  11100. [ALC662_LENOVO_101E] = {
  11101. .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
  11102. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  11103. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11104. .dac_nids = alc662_dac_nids,
  11105. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11106. .adc_nids = alc662_adc_nids,
  11107. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  11108. .channel_mode = alc662_3ST_2ch_modes,
  11109. .input_mux = &alc662_lenovo_101e_capture_source,
  11110. .unsol_event = alc662_lenovo_101e_unsol_event,
  11111. .init_hook = alc662_lenovo_101e_all_automute,
  11112. },
  11113. [ALC662_ASUS_EEEPC_P701] = {
  11114. .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
  11115. .init_verbs = { alc662_init_verbs,
  11116. alc662_eeepc_sue_init_verbs },
  11117. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11118. .dac_nids = alc662_dac_nids,
  11119. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  11120. .adc_nids = alc662_adc_nids,
  11121. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  11122. .channel_mode = alc662_3ST_2ch_modes,
  11123. .input_mux = &alc662_eeepc_capture_source,
  11124. .unsol_event = alc662_eeepc_unsol_event,
  11125. .init_hook = alc662_eeepc_inithook,
  11126. },
  11127. };
  11128. /*
  11129. * BIOS auto configuration
  11130. */
  11131. /* add playback controls from the parsed DAC table */
  11132. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  11133. const struct auto_pin_cfg *cfg)
  11134. {
  11135. char name[32];
  11136. static const char *chname[4] = {
  11137. "Front", "Surround", NULL /*CLFE*/, "Side"
  11138. };
  11139. hda_nid_t nid;
  11140. int i, err;
  11141. for (i = 0; i < cfg->line_outs; i++) {
  11142. if (!spec->multiout.dac_nids[i])
  11143. continue;
  11144. nid = alc880_idx_to_dac(i);
  11145. if (i == 2) {
  11146. /* Center/LFE */
  11147. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  11148. "Center Playback Volume",
  11149. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  11150. HDA_OUTPUT));
  11151. if (err < 0)
  11152. return err;
  11153. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  11154. "LFE Playback Volume",
  11155. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  11156. HDA_OUTPUT));
  11157. if (err < 0)
  11158. return err;
  11159. err = add_control(spec, ALC_CTL_BIND_MUTE,
  11160. "Center Playback Switch",
  11161. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  11162. HDA_INPUT));
  11163. if (err < 0)
  11164. return err;
  11165. err = add_control(spec, ALC_CTL_BIND_MUTE,
  11166. "LFE Playback Switch",
  11167. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  11168. HDA_INPUT));
  11169. if (err < 0)
  11170. return err;
  11171. } else {
  11172. sprintf(name, "%s Playback Volume", chname[i]);
  11173. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  11174. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  11175. HDA_OUTPUT));
  11176. if (err < 0)
  11177. return err;
  11178. sprintf(name, "%s Playback Switch", chname[i]);
  11179. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  11180. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  11181. HDA_INPUT));
  11182. if (err < 0)
  11183. return err;
  11184. }
  11185. }
  11186. return 0;
  11187. }
  11188. /* add playback controls for speaker and HP outputs */
  11189. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  11190. const char *pfx)
  11191. {
  11192. hda_nid_t nid;
  11193. int err;
  11194. char name[32];
  11195. if (!pin)
  11196. return 0;
  11197. if (alc880_is_fixed_pin(pin)) {
  11198. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  11199. /* printk("DAC nid=%x\n",nid); */
  11200. /* specify the DAC as the extra output */
  11201. if (!spec->multiout.hp_nid)
  11202. spec->multiout.hp_nid = nid;
  11203. else
  11204. spec->multiout.extra_out_nid[0] = nid;
  11205. /* control HP volume/switch on the output mixer amp */
  11206. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  11207. sprintf(name, "%s Playback Volume", pfx);
  11208. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  11209. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  11210. if (err < 0)
  11211. return err;
  11212. sprintf(name, "%s Playback Switch", pfx);
  11213. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  11214. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  11215. if (err < 0)
  11216. return err;
  11217. } else if (alc880_is_multi_pin(pin)) {
  11218. /* set manual connection */
  11219. /* we have only a switch on HP-out PIN */
  11220. sprintf(name, "%s Playback Switch", pfx);
  11221. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  11222. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  11223. if (err < 0)
  11224. return err;
  11225. }
  11226. return 0;
  11227. }
  11228. /* create playback/capture controls for input pins */
  11229. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  11230. const struct auto_pin_cfg *cfg)
  11231. {
  11232. struct hda_input_mux *imux = &spec->private_imux;
  11233. int i, err, idx;
  11234. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11235. if (alc880_is_input_pin(cfg->input_pins[i])) {
  11236. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  11237. err = new_analog_input(spec, cfg->input_pins[i],
  11238. auto_pin_cfg_labels[i],
  11239. idx, 0x0b);
  11240. if (err < 0)
  11241. return err;
  11242. imux->items[imux->num_items].label =
  11243. auto_pin_cfg_labels[i];
  11244. imux->items[imux->num_items].index =
  11245. alc880_input_pin_idx(cfg->input_pins[i]);
  11246. imux->num_items++;
  11247. }
  11248. }
  11249. return 0;
  11250. }
  11251. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  11252. hda_nid_t nid, int pin_type,
  11253. int dac_idx)
  11254. {
  11255. /* set as output */
  11256. snd_hda_codec_write(codec, nid, 0,
  11257. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  11258. snd_hda_codec_write(codec, nid, 0,
  11259. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  11260. /* need the manual connection? */
  11261. if (alc880_is_multi_pin(nid)) {
  11262. struct alc_spec *spec = codec->spec;
  11263. int idx = alc880_multi_pin_idx(nid);
  11264. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  11265. AC_VERB_SET_CONNECT_SEL,
  11266. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  11267. }
  11268. }
  11269. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  11270. {
  11271. struct alc_spec *spec = codec->spec;
  11272. int i;
  11273. for (i = 0; i <= HDA_SIDE; i++) {
  11274. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  11275. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  11276. if (nid)
  11277. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  11278. i);
  11279. }
  11280. }
  11281. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  11282. {
  11283. struct alc_spec *spec = codec->spec;
  11284. hda_nid_t pin;
  11285. pin = spec->autocfg.hp_pins[0];
  11286. if (pin) /* connect to front */
  11287. /* use dac 0 */
  11288. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  11289. }
  11290. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  11291. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  11292. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  11293. {
  11294. struct alc_spec *spec = codec->spec;
  11295. int i;
  11296. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11297. hda_nid_t nid = spec->autocfg.input_pins[i];
  11298. if (alc662_is_input_pin(nid)) {
  11299. snd_hda_codec_write(codec, nid, 0,
  11300. AC_VERB_SET_PIN_WIDGET_CONTROL,
  11301. (i <= AUTO_PIN_FRONT_MIC ?
  11302. PIN_VREF80 : PIN_IN));
  11303. if (nid != ALC662_PIN_CD_NID)
  11304. snd_hda_codec_write(codec, nid, 0,
  11305. AC_VERB_SET_AMP_GAIN_MUTE,
  11306. AMP_OUT_MUTE);
  11307. }
  11308. }
  11309. }
  11310. static int alc662_parse_auto_config(struct hda_codec *codec)
  11311. {
  11312. struct alc_spec *spec = codec->spec;
  11313. int err;
  11314. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  11315. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  11316. alc662_ignore);
  11317. if (err < 0)
  11318. return err;
  11319. if (!spec->autocfg.line_outs)
  11320. return 0; /* can't find valid BIOS pin config */
  11321. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  11322. if (err < 0)
  11323. return err;
  11324. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  11325. if (err < 0)
  11326. return err;
  11327. err = alc662_auto_create_extra_out(spec,
  11328. spec->autocfg.speaker_pins[0],
  11329. "Speaker");
  11330. if (err < 0)
  11331. return err;
  11332. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  11333. "Headphone");
  11334. if (err < 0)
  11335. return err;
  11336. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  11337. if (err < 0)
  11338. return err;
  11339. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  11340. if (spec->autocfg.dig_out_pin)
  11341. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  11342. if (spec->kctl_alloc)
  11343. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  11344. spec->num_mux_defs = 1;
  11345. spec->input_mux = &spec->private_imux;
  11346. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  11347. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  11348. spec->num_mixers++;
  11349. return 1;
  11350. }
  11351. /* additional initialization for auto-configuration model */
  11352. static void alc662_auto_init(struct hda_codec *codec)
  11353. {
  11354. alc662_auto_init_multi_out(codec);
  11355. alc662_auto_init_hp_out(codec);
  11356. alc662_auto_init_analog_input(codec);
  11357. }
  11358. static int patch_alc662(struct hda_codec *codec)
  11359. {
  11360. struct alc_spec *spec;
  11361. int err, board_config;
  11362. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  11363. if (!spec)
  11364. return -ENOMEM;
  11365. codec->spec = spec;
  11366. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  11367. alc662_models,
  11368. alc662_cfg_tbl);
  11369. if (board_config < 0) {
  11370. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  11371. "trying auto-probe from BIOS...\n");
  11372. board_config = ALC662_AUTO;
  11373. }
  11374. if (board_config == ALC662_AUTO) {
  11375. /* automatic parse from the BIOS config */
  11376. err = alc662_parse_auto_config(codec);
  11377. if (err < 0) {
  11378. alc_free(codec);
  11379. return err;
  11380. } else if (!err) {
  11381. printk(KERN_INFO
  11382. "hda_codec: Cannot set up configuration "
  11383. "from BIOS. Using base mode...\n");
  11384. board_config = ALC662_3ST_2ch_DIG;
  11385. }
  11386. }
  11387. if (board_config != ALC662_AUTO)
  11388. setup_preset(spec, &alc662_presets[board_config]);
  11389. spec->stream_name_analog = "ALC662 Analog";
  11390. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  11391. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  11392. spec->stream_name_digital = "ALC662 Digital";
  11393. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  11394. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  11395. if (!spec->adc_nids && spec->input_mux) {
  11396. spec->adc_nids = alc662_adc_nids;
  11397. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  11398. }
  11399. codec->patch_ops = alc_patch_ops;
  11400. if (board_config == ALC662_AUTO)
  11401. spec->init_hook = alc662_auto_init;
  11402. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11403. if (!spec->loopback.amplist)
  11404. spec->loopback.amplist = alc662_loopbacks;
  11405. #endif
  11406. return 0;
  11407. }
  11408. /*
  11409. * patch entries
  11410. */
  11411. struct hda_codec_preset snd_hda_preset_realtek[] = {
  11412. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  11413. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  11414. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  11415. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  11416. .patch = patch_alc861 },
  11417. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  11418. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  11419. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  11420. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  11421. .patch = patch_alc883 },
  11422. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  11423. .patch = patch_alc662 },
  11424. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  11425. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  11426. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  11427. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  11428. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  11429. {} /* terminator */
  11430. };