patch_realtek.c 429 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037
  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. /* ALC269 models */
  107. enum {
  108. ALC269_BASIC,
  109. ALC269_AUTO,
  110. ALC269_MODEL_LAST /* last tag */
  111. };
  112. /* ALC861 models */
  113. enum {
  114. ALC861_3ST,
  115. ALC660_3ST,
  116. ALC861_3ST_DIG,
  117. ALC861_6ST_DIG,
  118. ALC861_UNIWILL_M31,
  119. ALC861_TOSHIBA,
  120. ALC861_ASUS,
  121. ALC861_ASUS_LAPTOP,
  122. ALC861_AUTO,
  123. ALC861_MODEL_LAST,
  124. };
  125. /* ALC861-VD models */
  126. enum {
  127. ALC660VD_3ST,
  128. ALC660VD_3ST_DIG,
  129. ALC861VD_3ST,
  130. ALC861VD_3ST_DIG,
  131. ALC861VD_6ST_DIG,
  132. ALC861VD_LENOVO,
  133. ALC861VD_DALLAS,
  134. ALC861VD_HP,
  135. ALC861VD_AUTO,
  136. ALC861VD_MODEL_LAST,
  137. };
  138. /* ALC662 models */
  139. enum {
  140. ALC662_3ST_2ch_DIG,
  141. ALC662_3ST_6ch_DIG,
  142. ALC662_3ST_6ch,
  143. ALC662_5ST_DIG,
  144. ALC662_LENOVO_101E,
  145. ALC662_ASUS_EEEPC_P701,
  146. ALC662_AUTO,
  147. ALC662_MODEL_LAST,
  148. };
  149. /* ALC882 models */
  150. enum {
  151. ALC882_3ST_DIG,
  152. ALC882_6ST_DIG,
  153. ALC882_ARIMA,
  154. ALC882_W2JC,
  155. ALC882_TARGA,
  156. ALC882_ASUS_A7J,
  157. ALC882_ASUS_A7M,
  158. ALC885_MACPRO,
  159. ALC885_MBP3,
  160. ALC885_IMAC24,
  161. ALC882_AUTO,
  162. ALC882_MODEL_LAST,
  163. };
  164. /* ALC883 models */
  165. enum {
  166. ALC883_3ST_2ch_DIG,
  167. ALC883_3ST_6ch_DIG,
  168. ALC883_3ST_6ch,
  169. ALC883_6ST_DIG,
  170. ALC883_TARGA_DIG,
  171. ALC883_TARGA_2ch_DIG,
  172. ALC883_ACER,
  173. ALC883_ACER_ASPIRE,
  174. ALC883_MEDION,
  175. ALC883_MEDION_MD2,
  176. ALC883_LAPTOP_EAPD,
  177. ALC883_LENOVO_101E_2ch,
  178. ALC883_LENOVO_NB0763,
  179. ALC888_LENOVO_MS7195_DIG,
  180. ALC883_HAIER_W66,
  181. ALC888_6ST_HP,
  182. ALC888_3ST_HP,
  183. ALC883_AUTO,
  184. ALC883_MODEL_LAST,
  185. };
  186. /* for GPIO Poll */
  187. #define GPIO_MASK 0x03
  188. struct alc_spec {
  189. /* codec parameterization */
  190. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  191. unsigned int num_mixers;
  192. const struct hda_verb *init_verbs[5]; /* initialization verbs
  193. * don't forget NULL
  194. * termination!
  195. */
  196. unsigned int num_init_verbs;
  197. char *stream_name_analog; /* analog PCM stream */
  198. struct hda_pcm_stream *stream_analog_playback;
  199. struct hda_pcm_stream *stream_analog_capture;
  200. char *stream_name_digital; /* digital PCM stream */
  201. struct hda_pcm_stream *stream_digital_playback;
  202. struct hda_pcm_stream *stream_digital_capture;
  203. /* playback */
  204. struct hda_multi_out multiout; /* playback set-up
  205. * max_channels, dacs must be set
  206. * dig_out_nid and hp_nid are optional
  207. */
  208. /* capture */
  209. unsigned int num_adc_nids;
  210. hda_nid_t *adc_nids;
  211. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  212. /* capture source */
  213. unsigned int num_mux_defs;
  214. const struct hda_input_mux *input_mux;
  215. unsigned int cur_mux[3];
  216. /* channel model */
  217. const struct hda_channel_mode *channel_mode;
  218. int num_channel_mode;
  219. int need_dac_fix;
  220. /* PCM information */
  221. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  222. /* dynamic controls, init_verbs and input_mux */
  223. struct auto_pin_cfg autocfg;
  224. unsigned int num_kctl_alloc, num_kctl_used;
  225. struct snd_kcontrol_new *kctl_alloc;
  226. struct hda_input_mux private_imux;
  227. hda_nid_t private_dac_nids[AUTO_CFG_MAX_OUTS];
  228. /* hooks */
  229. void (*init_hook)(struct hda_codec *codec);
  230. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  231. /* for pin sensing */
  232. unsigned int sense_updated: 1;
  233. unsigned int jack_present: 1;
  234. #ifdef CONFIG_SND_HDA_POWER_SAVE
  235. struct hda_loopback_check loopback;
  236. #endif
  237. };
  238. /*
  239. * configuration template - to be copied to the spec instance
  240. */
  241. struct alc_config_preset {
  242. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  243. * with spec
  244. */
  245. const struct hda_verb *init_verbs[5];
  246. unsigned int num_dacs;
  247. hda_nid_t *dac_nids;
  248. hda_nid_t dig_out_nid; /* optional */
  249. hda_nid_t hp_nid; /* optional */
  250. unsigned int num_adc_nids;
  251. hda_nid_t *adc_nids;
  252. hda_nid_t dig_in_nid;
  253. unsigned int num_channel_mode;
  254. const struct hda_channel_mode *channel_mode;
  255. int need_dac_fix;
  256. unsigned int num_mux_defs;
  257. const struct hda_input_mux *input_mux;
  258. void (*unsol_event)(struct hda_codec *, unsigned int);
  259. void (*init_hook)(struct hda_codec *);
  260. #ifdef CONFIG_SND_HDA_POWER_SAVE
  261. struct hda_amp_list *loopbacks;
  262. #endif
  263. };
  264. /*
  265. * input MUX handling
  266. */
  267. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  268. struct snd_ctl_elem_info *uinfo)
  269. {
  270. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  271. struct alc_spec *spec = codec->spec;
  272. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  273. if (mux_idx >= spec->num_mux_defs)
  274. mux_idx = 0;
  275. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  276. }
  277. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  278. struct snd_ctl_elem_value *ucontrol)
  279. {
  280. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  281. struct alc_spec *spec = codec->spec;
  282. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  283. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  284. return 0;
  285. }
  286. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  287. struct snd_ctl_elem_value *ucontrol)
  288. {
  289. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  290. struct alc_spec *spec = codec->spec;
  291. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  292. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  293. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  294. spec->adc_nids[adc_idx],
  295. &spec->cur_mux[adc_idx]);
  296. }
  297. /*
  298. * channel mode setting
  299. */
  300. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  301. struct snd_ctl_elem_info *uinfo)
  302. {
  303. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  304. struct alc_spec *spec = codec->spec;
  305. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  306. spec->num_channel_mode);
  307. }
  308. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  309. struct snd_ctl_elem_value *ucontrol)
  310. {
  311. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  312. struct alc_spec *spec = codec->spec;
  313. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  314. spec->num_channel_mode,
  315. spec->multiout.max_channels);
  316. }
  317. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  318. struct snd_ctl_elem_value *ucontrol)
  319. {
  320. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  321. struct alc_spec *spec = codec->spec;
  322. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  323. spec->num_channel_mode,
  324. &spec->multiout.max_channels);
  325. if (err >= 0 && spec->need_dac_fix)
  326. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  327. return err;
  328. }
  329. /*
  330. * Control the mode of pin widget settings via the mixer. "pc" is used
  331. * instead of "%" to avoid consequences of accidently treating the % as
  332. * being part of a format specifier. Maximum allowed length of a value is
  333. * 63 characters plus NULL terminator.
  334. *
  335. * Note: some retasking pin complexes seem to ignore requests for input
  336. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  337. * are requested. Therefore order this list so that this behaviour will not
  338. * cause problems when mixer clients move through the enum sequentially.
  339. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  340. * March 2006.
  341. */
  342. static char *alc_pin_mode_names[] = {
  343. "Mic 50pc bias", "Mic 80pc bias",
  344. "Line in", "Line out", "Headphone out",
  345. };
  346. static unsigned char alc_pin_mode_values[] = {
  347. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  348. };
  349. /* The control can present all 5 options, or it can limit the options based
  350. * in the pin being assumed to be exclusively an input or an output pin. In
  351. * addition, "input" pins may or may not process the mic bias option
  352. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  353. * accept requests for bias as of chip versions up to March 2006) and/or
  354. * wiring in the computer.
  355. */
  356. #define ALC_PIN_DIR_IN 0x00
  357. #define ALC_PIN_DIR_OUT 0x01
  358. #define ALC_PIN_DIR_INOUT 0x02
  359. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  360. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  361. /* Info about the pin modes supported by the different pin direction modes.
  362. * For each direction the minimum and maximum values are given.
  363. */
  364. static signed char alc_pin_mode_dir_info[5][2] = {
  365. { 0, 2 }, /* ALC_PIN_DIR_IN */
  366. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  367. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  368. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  369. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  370. };
  371. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  372. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  373. #define alc_pin_mode_n_items(_dir) \
  374. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  375. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  376. struct snd_ctl_elem_info *uinfo)
  377. {
  378. unsigned int item_num = uinfo->value.enumerated.item;
  379. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  380. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  381. uinfo->count = 1;
  382. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  383. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  384. item_num = alc_pin_mode_min(dir);
  385. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  386. return 0;
  387. }
  388. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  389. struct snd_ctl_elem_value *ucontrol)
  390. {
  391. unsigned int i;
  392. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  393. hda_nid_t nid = kcontrol->private_value & 0xffff;
  394. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  395. long *valp = ucontrol->value.integer.value;
  396. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  397. AC_VERB_GET_PIN_WIDGET_CONTROL,
  398. 0x00);
  399. /* Find enumerated value for current pinctl setting */
  400. i = alc_pin_mode_min(dir);
  401. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  402. i++;
  403. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  404. return 0;
  405. }
  406. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  407. struct snd_ctl_elem_value *ucontrol)
  408. {
  409. signed int change;
  410. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  411. hda_nid_t nid = kcontrol->private_value & 0xffff;
  412. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  413. long val = *ucontrol->value.integer.value;
  414. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  415. AC_VERB_GET_PIN_WIDGET_CONTROL,
  416. 0x00);
  417. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  418. val = alc_pin_mode_min(dir);
  419. change = pinctl != alc_pin_mode_values[val];
  420. if (change) {
  421. /* Set pin mode to that requested */
  422. snd_hda_codec_write_cache(codec, nid, 0,
  423. AC_VERB_SET_PIN_WIDGET_CONTROL,
  424. alc_pin_mode_values[val]);
  425. /* Also enable the retasking pin's input/output as required
  426. * for the requested pin mode. Enum values of 2 or less are
  427. * input modes.
  428. *
  429. * Dynamically switching the input/output buffers probably
  430. * reduces noise slightly (particularly on input) so we'll
  431. * do it. However, having both input and output buffers
  432. * enabled simultaneously doesn't seem to be problematic if
  433. * this turns out to be necessary in the future.
  434. */
  435. if (val <= 2) {
  436. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  437. HDA_AMP_MUTE, HDA_AMP_MUTE);
  438. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  439. HDA_AMP_MUTE, 0);
  440. } else {
  441. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  442. HDA_AMP_MUTE, HDA_AMP_MUTE);
  443. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  444. HDA_AMP_MUTE, 0);
  445. }
  446. }
  447. return change;
  448. }
  449. #define ALC_PIN_MODE(xname, nid, dir) \
  450. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  451. .info = alc_pin_mode_info, \
  452. .get = alc_pin_mode_get, \
  453. .put = alc_pin_mode_put, \
  454. .private_value = nid | (dir<<16) }
  455. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  456. * together using a mask with more than one bit set. This control is
  457. * currently used only by the ALC260 test model. At this stage they are not
  458. * needed for any "production" models.
  459. */
  460. #ifdef CONFIG_SND_DEBUG
  461. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  462. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  463. struct snd_ctl_elem_value *ucontrol)
  464. {
  465. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  466. hda_nid_t nid = kcontrol->private_value & 0xffff;
  467. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  468. long *valp = ucontrol->value.integer.value;
  469. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  470. AC_VERB_GET_GPIO_DATA, 0x00);
  471. *valp = (val & mask) != 0;
  472. return 0;
  473. }
  474. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  475. struct snd_ctl_elem_value *ucontrol)
  476. {
  477. signed int change;
  478. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  479. hda_nid_t nid = kcontrol->private_value & 0xffff;
  480. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  481. long val = *ucontrol->value.integer.value;
  482. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  483. AC_VERB_GET_GPIO_DATA,
  484. 0x00);
  485. /* Set/unset the masked GPIO bit(s) as needed */
  486. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  487. if (val == 0)
  488. gpio_data &= ~mask;
  489. else
  490. gpio_data |= mask;
  491. snd_hda_codec_write_cache(codec, nid, 0,
  492. AC_VERB_SET_GPIO_DATA, gpio_data);
  493. return change;
  494. }
  495. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  496. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  497. .info = alc_gpio_data_info, \
  498. .get = alc_gpio_data_get, \
  499. .put = alc_gpio_data_put, \
  500. .private_value = nid | (mask<<16) }
  501. #endif /* CONFIG_SND_DEBUG */
  502. /* A switch control to allow the enabling of the digital IO pins on the
  503. * ALC260. This is incredibly simplistic; the intention of this control is
  504. * to provide something in the test model allowing digital outputs to be
  505. * identified if present. If models are found which can utilise these
  506. * outputs a more complete mixer control can be devised for those models if
  507. * necessary.
  508. */
  509. #ifdef CONFIG_SND_DEBUG
  510. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  511. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  512. struct snd_ctl_elem_value *ucontrol)
  513. {
  514. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  515. hda_nid_t nid = kcontrol->private_value & 0xffff;
  516. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  517. long *valp = ucontrol->value.integer.value;
  518. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  519. AC_VERB_GET_DIGI_CONVERT, 0x00);
  520. *valp = (val & mask) != 0;
  521. return 0;
  522. }
  523. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  524. struct snd_ctl_elem_value *ucontrol)
  525. {
  526. signed int change;
  527. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  528. hda_nid_t nid = kcontrol->private_value & 0xffff;
  529. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  530. long val = *ucontrol->value.integer.value;
  531. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  532. AC_VERB_GET_DIGI_CONVERT,
  533. 0x00);
  534. /* Set/unset the masked control bit(s) as needed */
  535. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  536. if (val==0)
  537. ctrl_data &= ~mask;
  538. else
  539. ctrl_data |= mask;
  540. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  541. ctrl_data);
  542. return change;
  543. }
  544. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  545. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  546. .info = alc_spdif_ctrl_info, \
  547. .get = alc_spdif_ctrl_get, \
  548. .put = alc_spdif_ctrl_put, \
  549. .private_value = nid | (mask<<16) }
  550. #endif /* CONFIG_SND_DEBUG */
  551. /*
  552. * set up from the preset table
  553. */
  554. static void setup_preset(struct alc_spec *spec,
  555. const struct alc_config_preset *preset)
  556. {
  557. int i;
  558. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  559. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  560. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  561. i++)
  562. spec->init_verbs[spec->num_init_verbs++] =
  563. preset->init_verbs[i];
  564. spec->channel_mode = preset->channel_mode;
  565. spec->num_channel_mode = preset->num_channel_mode;
  566. spec->need_dac_fix = preset->need_dac_fix;
  567. spec->multiout.max_channels = spec->channel_mode[0].channels;
  568. spec->multiout.num_dacs = preset->num_dacs;
  569. spec->multiout.dac_nids = preset->dac_nids;
  570. spec->multiout.dig_out_nid = preset->dig_out_nid;
  571. spec->multiout.hp_nid = preset->hp_nid;
  572. spec->num_mux_defs = preset->num_mux_defs;
  573. if (!spec->num_mux_defs)
  574. spec->num_mux_defs = 1;
  575. spec->input_mux = preset->input_mux;
  576. spec->num_adc_nids = preset->num_adc_nids;
  577. spec->adc_nids = preset->adc_nids;
  578. spec->dig_in_nid = preset->dig_in_nid;
  579. spec->unsol_event = preset->unsol_event;
  580. spec->init_hook = preset->init_hook;
  581. #ifdef CONFIG_SND_HDA_POWER_SAVE
  582. spec->loopback.amplist = preset->loopbacks;
  583. #endif
  584. }
  585. /* Enable GPIO mask and set output */
  586. static struct hda_verb alc_gpio1_init_verbs[] = {
  587. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  588. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  589. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  590. { }
  591. };
  592. static struct hda_verb alc_gpio2_init_verbs[] = {
  593. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  594. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  595. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  596. { }
  597. };
  598. static struct hda_verb alc_gpio3_init_verbs[] = {
  599. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  600. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  601. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  602. { }
  603. };
  604. static void alc_sku_automute(struct hda_codec *codec)
  605. {
  606. struct alc_spec *spec = codec->spec;
  607. unsigned int mute;
  608. unsigned int present;
  609. unsigned int hp_nid = spec->autocfg.hp_pins[0];
  610. unsigned int sp_nid = spec->autocfg.speaker_pins[0];
  611. /* need to execute and sync at first */
  612. snd_hda_codec_read(codec, hp_nid, 0, AC_VERB_SET_PIN_SENSE, 0);
  613. present = snd_hda_codec_read(codec, hp_nid, 0,
  614. AC_VERB_GET_PIN_SENSE, 0);
  615. spec->jack_present = (present & 0x80000000) != 0;
  616. if (spec->jack_present) {
  617. /* mute internal speaker */
  618. snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
  619. HDA_AMP_MUTE, HDA_AMP_MUTE);
  620. } else {
  621. /* unmute internal speaker if necessary */
  622. mute = snd_hda_codec_amp_read(codec, hp_nid, 0, HDA_OUTPUT, 0);
  623. snd_hda_codec_amp_stereo(codec, sp_nid, HDA_OUTPUT, 0,
  624. HDA_AMP_MUTE, mute);
  625. }
  626. }
  627. /* unsolicited event for HP jack sensing */
  628. static void alc_sku_unsol_event(struct hda_codec *codec, unsigned int res)
  629. {
  630. if (codec->vendor_id == 0x10ec0880)
  631. res >>= 28;
  632. else
  633. res >>= 26;
  634. if (res != ALC880_HP_EVENT)
  635. return;
  636. alc_sku_automute(codec);
  637. }
  638. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  639. * 31 ~ 16 : Manufacture ID
  640. * 15 ~ 8 : SKU ID
  641. * 7 ~ 0 : Assembly ID
  642. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  643. */
  644. static void alc_subsystem_id(struct hda_codec *codec,
  645. unsigned int porta, unsigned int porte,
  646. unsigned int portd)
  647. {
  648. unsigned int ass, tmp, i;
  649. unsigned nid;
  650. struct alc_spec *spec = codec->spec;
  651. ass = codec->subsystem_id & 0xffff;
  652. if ((ass != codec->bus->pci->subsystem_device) && (ass & 1))
  653. goto do_sku;
  654. /*
  655. * 31~30 : port conetcivity
  656. * 29~21 : reserve
  657. * 20 : PCBEEP input
  658. * 19~16 : Check sum (15:1)
  659. * 15~1 : Custom
  660. * 0 : override
  661. */
  662. nid = 0x1d;
  663. if (codec->vendor_id == 0x10ec0260)
  664. nid = 0x17;
  665. ass = snd_hda_codec_read(codec, nid, 0,
  666. AC_VERB_GET_CONFIG_DEFAULT, 0);
  667. if (!(ass & 1) && !(ass & 0x100000))
  668. return;
  669. if ((ass >> 30) != 1) /* no physical connection */
  670. return;
  671. /* check sum */
  672. tmp = 0;
  673. for (i = 1; i < 16; i++) {
  674. if ((ass >> i) && 1)
  675. tmp++;
  676. }
  677. if (((ass >> 16) & 0xf) != tmp)
  678. return;
  679. do_sku:
  680. /*
  681. * 0 : override
  682. * 1 : Swap Jack
  683. * 2 : 0 --> Desktop, 1 --> Laptop
  684. * 3~5 : External Amplifier control
  685. * 7~6 : Reserved
  686. */
  687. tmp = (ass & 0x38) >> 3; /* external Amp control */
  688. switch (tmp) {
  689. case 1:
  690. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  691. break;
  692. case 3:
  693. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  694. break;
  695. case 7:
  696. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  697. break;
  698. case 5: /* set EAPD output high */
  699. switch (codec->vendor_id) {
  700. case 0x10ec0260:
  701. snd_hda_codec_write(codec, 0x0f, 0,
  702. AC_VERB_SET_EAPD_BTLENABLE, 2);
  703. snd_hda_codec_write(codec, 0x10, 0,
  704. AC_VERB_SET_EAPD_BTLENABLE, 2);
  705. break;
  706. case 0x10ec0262:
  707. case 0x10ec0267:
  708. case 0x10ec0268:
  709. case 0x10ec0269:
  710. case 0x10ec0862:
  711. case 0x10ec0662:
  712. snd_hda_codec_write(codec, 0x14, 0,
  713. AC_VERB_SET_EAPD_BTLENABLE, 2);
  714. snd_hda_codec_write(codec, 0x15, 0,
  715. AC_VERB_SET_EAPD_BTLENABLE, 2);
  716. break;
  717. }
  718. switch (codec->vendor_id) {
  719. case 0x10ec0260:
  720. snd_hda_codec_write(codec, 0x1a, 0,
  721. AC_VERB_SET_COEF_INDEX, 7);
  722. tmp = snd_hda_codec_read(codec, 0x1a, 0,
  723. AC_VERB_GET_PROC_COEF, 0);
  724. snd_hda_codec_write(codec, 0x1a, 0,
  725. AC_VERB_SET_COEF_INDEX, 7);
  726. snd_hda_codec_write(codec, 0x1a, 0,
  727. AC_VERB_SET_PROC_COEF,
  728. tmp | 0x2010);
  729. break;
  730. case 0x10ec0262:
  731. case 0x10ec0880:
  732. case 0x10ec0882:
  733. case 0x10ec0883:
  734. case 0x10ec0885:
  735. case 0x10ec0888:
  736. snd_hda_codec_write(codec, 0x20, 0,
  737. AC_VERB_SET_COEF_INDEX, 7);
  738. tmp = snd_hda_codec_read(codec, 0x20, 0,
  739. AC_VERB_GET_PROC_COEF, 0);
  740. snd_hda_codec_write(codec, 0x20, 0,
  741. AC_VERB_SET_COEF_INDEX, 7);
  742. snd_hda_codec_write(codec, 0x20, 0,
  743. AC_VERB_SET_PROC_COEF,
  744. tmp | 0x2010);
  745. break;
  746. case 0x10ec0267:
  747. case 0x10ec0268:
  748. snd_hda_codec_write(codec, 0x20, 0,
  749. AC_VERB_SET_COEF_INDEX, 7);
  750. tmp = snd_hda_codec_read(codec, 0x20, 0,
  751. AC_VERB_GET_PROC_COEF, 0);
  752. snd_hda_codec_write(codec, 0x20, 0,
  753. AC_VERB_SET_COEF_INDEX, 7);
  754. snd_hda_codec_write(codec, 0x20, 0,
  755. AC_VERB_SET_PROC_COEF,
  756. tmp | 0x3000);
  757. break;
  758. }
  759. default:
  760. break;
  761. }
  762. /* is laptop and enable the function "Mute internal speaker
  763. * when the external headphone out jack is plugged"
  764. */
  765. if (!(ass & 0x4) || !(ass & 0x8000))
  766. return;
  767. /*
  768. * 10~8 : Jack location
  769. * 12~11: Headphone out -> 00: PortA, 01: PortE, 02: PortD, 03: Resvered
  770. * 14~13: Resvered
  771. * 15 : 1 --> enable the function "Mute internal speaker
  772. * when the external headphone out jack is plugged"
  773. */
  774. if (!spec->autocfg.speaker_pins[0]) {
  775. if (spec->multiout.dac_nids[0])
  776. spec->autocfg.speaker_pins[0] =
  777. spec->multiout.dac_nids[0];
  778. else
  779. return;
  780. }
  781. if (!spec->autocfg.hp_pins[0]) {
  782. tmp = (ass >> 11) & 0x3; /* HP to chassis */
  783. if (tmp == 0)
  784. spec->autocfg.hp_pins[0] = porta;
  785. else if (tmp == 1)
  786. spec->autocfg.hp_pins[0] = porte;
  787. else if (tmp == 2)
  788. spec->autocfg.hp_pins[0] = portd;
  789. else
  790. return;
  791. }
  792. snd_hda_codec_write(codec, spec->autocfg.hp_pins[0], 0,
  793. AC_VERB_SET_UNSOLICITED_ENABLE,
  794. AC_USRSP_EN | ALC880_HP_EVENT);
  795. spec->unsol_event = alc_sku_unsol_event;
  796. spec->init_hook = alc_sku_automute;
  797. }
  798. /*
  799. * Fix-up pin default configurations
  800. */
  801. struct alc_pincfg {
  802. hda_nid_t nid;
  803. u32 val;
  804. };
  805. static void alc_fix_pincfg(struct hda_codec *codec,
  806. const struct snd_pci_quirk *quirk,
  807. const struct alc_pincfg **pinfix)
  808. {
  809. const struct alc_pincfg *cfg;
  810. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  811. if (!quirk)
  812. return;
  813. cfg = pinfix[quirk->value];
  814. for (; cfg->nid; cfg++) {
  815. int i;
  816. u32 val = cfg->val;
  817. for (i = 0; i < 4; i++) {
  818. snd_hda_codec_write(codec, cfg->nid, 0,
  819. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  820. val & 0xff);
  821. val >>= 8;
  822. }
  823. }
  824. }
  825. /*
  826. * ALC880 3-stack model
  827. *
  828. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  829. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  830. * F-Mic = 0x1b, HP = 0x19
  831. */
  832. static hda_nid_t alc880_dac_nids[4] = {
  833. /* front, rear, clfe, rear_surr */
  834. 0x02, 0x05, 0x04, 0x03
  835. };
  836. static hda_nid_t alc880_adc_nids[3] = {
  837. /* ADC0-2 */
  838. 0x07, 0x08, 0x09,
  839. };
  840. /* The datasheet says the node 0x07 is connected from inputs,
  841. * but it shows zero connection in the real implementation on some devices.
  842. * Note: this is a 915GAV bug, fixed on 915GLV
  843. */
  844. static hda_nid_t alc880_adc_nids_alt[2] = {
  845. /* ADC1-2 */
  846. 0x08, 0x09,
  847. };
  848. #define ALC880_DIGOUT_NID 0x06
  849. #define ALC880_DIGIN_NID 0x0a
  850. static struct hda_input_mux alc880_capture_source = {
  851. .num_items = 4,
  852. .items = {
  853. { "Mic", 0x0 },
  854. { "Front Mic", 0x3 },
  855. { "Line", 0x2 },
  856. { "CD", 0x4 },
  857. },
  858. };
  859. /* channel source setting (2/6 channel selection for 3-stack) */
  860. /* 2ch mode */
  861. static struct hda_verb alc880_threestack_ch2_init[] = {
  862. /* set line-in to input, mute it */
  863. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  864. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  865. /* set mic-in to input vref 80%, mute it */
  866. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  867. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  868. { } /* end */
  869. };
  870. /* 6ch mode */
  871. static struct hda_verb alc880_threestack_ch6_init[] = {
  872. /* set line-in to output, unmute it */
  873. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  874. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  875. /* set mic-in to output, unmute it */
  876. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  877. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  878. { } /* end */
  879. };
  880. static struct hda_channel_mode alc880_threestack_modes[2] = {
  881. { 2, alc880_threestack_ch2_init },
  882. { 6, alc880_threestack_ch6_init },
  883. };
  884. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  885. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  886. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  887. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  888. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  889. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  890. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  891. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  892. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  893. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  894. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  895. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  896. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  897. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  898. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  899. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  900. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  901. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  902. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  903. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  904. {
  905. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  906. .name = "Channel Mode",
  907. .info = alc_ch_mode_info,
  908. .get = alc_ch_mode_get,
  909. .put = alc_ch_mode_put,
  910. },
  911. { } /* end */
  912. };
  913. /* capture mixer elements */
  914. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  915. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  916. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  917. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  918. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  919. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  920. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  921. {
  922. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  923. /* The multiple "Capture Source" controls confuse alsamixer
  924. * So call somewhat different..
  925. * FIXME: the controls appear in the "playback" view!
  926. */
  927. /* .name = "Capture Source", */
  928. .name = "Input Source",
  929. .count = 3,
  930. .info = alc_mux_enum_info,
  931. .get = alc_mux_enum_get,
  932. .put = alc_mux_enum_put,
  933. },
  934. { } /* end */
  935. };
  936. /* capture mixer elements (in case NID 0x07 not available) */
  937. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  938. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  939. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  940. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  941. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  942. {
  943. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  944. /* The multiple "Capture Source" controls confuse alsamixer
  945. * So call somewhat different..
  946. * FIXME: the controls appear in the "playback" view!
  947. */
  948. /* .name = "Capture Source", */
  949. .name = "Input Source",
  950. .count = 2,
  951. .info = alc_mux_enum_info,
  952. .get = alc_mux_enum_get,
  953. .put = alc_mux_enum_put,
  954. },
  955. { } /* end */
  956. };
  957. /*
  958. * ALC880 5-stack model
  959. *
  960. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  961. * Side = 0x02 (0xd)
  962. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  963. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  964. */
  965. /* additional mixers to alc880_three_stack_mixer */
  966. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  967. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  968. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  969. { } /* end */
  970. };
  971. /* channel source setting (6/8 channel selection for 5-stack) */
  972. /* 6ch mode */
  973. static struct hda_verb alc880_fivestack_ch6_init[] = {
  974. /* set line-in to input, mute it */
  975. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  976. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  977. { } /* end */
  978. };
  979. /* 8ch mode */
  980. static struct hda_verb alc880_fivestack_ch8_init[] = {
  981. /* set line-in to output, unmute it */
  982. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  983. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  984. { } /* end */
  985. };
  986. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  987. { 6, alc880_fivestack_ch6_init },
  988. { 8, alc880_fivestack_ch8_init },
  989. };
  990. /*
  991. * ALC880 6-stack model
  992. *
  993. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  994. * Side = 0x05 (0x0f)
  995. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  996. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  997. */
  998. static hda_nid_t alc880_6st_dac_nids[4] = {
  999. /* front, rear, clfe, rear_surr */
  1000. 0x02, 0x03, 0x04, 0x05
  1001. };
  1002. static struct hda_input_mux alc880_6stack_capture_source = {
  1003. .num_items = 4,
  1004. .items = {
  1005. { "Mic", 0x0 },
  1006. { "Front Mic", 0x1 },
  1007. { "Line", 0x2 },
  1008. { "CD", 0x4 },
  1009. },
  1010. };
  1011. /* fixed 8-channels */
  1012. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  1013. { 8, NULL },
  1014. };
  1015. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  1016. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1017. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1018. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1019. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1020. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1021. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1022. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1023. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1024. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1025. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  1026. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1027. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1028. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1029. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1030. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1031. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1032. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1033. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1034. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1035. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1036. {
  1037. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1038. .name = "Channel Mode",
  1039. .info = alc_ch_mode_info,
  1040. .get = alc_ch_mode_get,
  1041. .put = alc_ch_mode_put,
  1042. },
  1043. { } /* end */
  1044. };
  1045. /*
  1046. * ALC880 W810 model
  1047. *
  1048. * W810 has rear IO for:
  1049. * Front (DAC 02)
  1050. * Surround (DAC 03)
  1051. * Center/LFE (DAC 04)
  1052. * Digital out (06)
  1053. *
  1054. * The system also has a pair of internal speakers, and a headphone jack.
  1055. * These are both connected to Line2 on the codec, hence to DAC 02.
  1056. *
  1057. * There is a variable resistor to control the speaker or headphone
  1058. * volume. This is a hardware-only device without a software API.
  1059. *
  1060. * Plugging headphones in will disable the internal speakers. This is
  1061. * implemented in hardware, not via the driver using jack sense. In
  1062. * a similar fashion, plugging into the rear socket marked "front" will
  1063. * disable both the speakers and headphones.
  1064. *
  1065. * For input, there's a microphone jack, and an "audio in" jack.
  1066. * These may not do anything useful with this driver yet, because I
  1067. * haven't setup any initialization verbs for these yet...
  1068. */
  1069. static hda_nid_t alc880_w810_dac_nids[3] = {
  1070. /* front, rear/surround, clfe */
  1071. 0x02, 0x03, 0x04
  1072. };
  1073. /* fixed 6 channels */
  1074. static struct hda_channel_mode alc880_w810_modes[1] = {
  1075. { 6, NULL }
  1076. };
  1077. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  1078. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  1079. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1080. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1081. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1082. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1083. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1084. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1085. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1086. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1087. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1088. { } /* end */
  1089. };
  1090. /*
  1091. * Z710V model
  1092. *
  1093. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  1094. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  1095. * Line = 0x1a
  1096. */
  1097. static hda_nid_t alc880_z71v_dac_nids[1] = {
  1098. 0x02
  1099. };
  1100. #define ALC880_Z71V_HP_DAC 0x03
  1101. /* fixed 2 channels */
  1102. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  1103. { 2, NULL }
  1104. };
  1105. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  1106. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1107. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1108. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1109. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  1110. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1111. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1112. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1113. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1114. { } /* end */
  1115. };
  1116. /* FIXME! */
  1117. /*
  1118. * ALC880 F1734 model
  1119. *
  1120. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  1121. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  1122. */
  1123. static hda_nid_t alc880_f1734_dac_nids[1] = {
  1124. 0x03
  1125. };
  1126. #define ALC880_F1734_HP_DAC 0x02
  1127. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  1128. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1129. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1130. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1131. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1132. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1133. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1134. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1135. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1136. { } /* end */
  1137. };
  1138. /* FIXME! */
  1139. /*
  1140. * ALC880 ASUS model
  1141. *
  1142. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1143. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1144. * Mic = 0x18, Line = 0x1a
  1145. */
  1146. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1147. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1148. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1149. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1150. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1151. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1152. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1153. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1154. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1155. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1156. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1157. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1158. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1159. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1160. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1161. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1162. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1163. {
  1164. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1165. .name = "Channel Mode",
  1166. .info = alc_ch_mode_info,
  1167. .get = alc_ch_mode_get,
  1168. .put = alc_ch_mode_put,
  1169. },
  1170. { } /* end */
  1171. };
  1172. /* FIXME! */
  1173. /*
  1174. * ALC880 ASUS W1V model
  1175. *
  1176. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1177. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1178. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1179. */
  1180. /* additional mixers to alc880_asus_mixer */
  1181. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1182. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1183. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1184. { } /* end */
  1185. };
  1186. /* additional mixers to alc880_asus_mixer */
  1187. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1188. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1189. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1190. { } /* end */
  1191. };
  1192. /* TCL S700 */
  1193. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1194. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1195. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1196. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1197. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1198. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1199. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1200. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1201. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1202. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1203. {
  1204. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1205. /* The multiple "Capture Source" controls confuse alsamixer
  1206. * So call somewhat different..
  1207. * FIXME: the controls appear in the "playback" view!
  1208. */
  1209. /* .name = "Capture Source", */
  1210. .name = "Input Source",
  1211. .count = 1,
  1212. .info = alc_mux_enum_info,
  1213. .get = alc_mux_enum_get,
  1214. .put = alc_mux_enum_put,
  1215. },
  1216. { } /* end */
  1217. };
  1218. /* Uniwill */
  1219. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1220. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1221. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1222. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1223. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1224. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1225. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1226. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1227. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1228. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1229. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1230. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1231. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1232. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1233. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1234. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1235. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1236. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1237. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1238. {
  1239. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1240. .name = "Channel Mode",
  1241. .info = alc_ch_mode_info,
  1242. .get = alc_ch_mode_get,
  1243. .put = alc_ch_mode_put,
  1244. },
  1245. { } /* end */
  1246. };
  1247. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1248. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1249. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1250. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1251. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1252. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1253. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1254. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1255. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1256. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1257. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1258. { } /* end */
  1259. };
  1260. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1261. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1262. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1263. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1264. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1265. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1266. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1267. { } /* end */
  1268. };
  1269. /*
  1270. * build control elements
  1271. */
  1272. static int alc_build_controls(struct hda_codec *codec)
  1273. {
  1274. struct alc_spec *spec = codec->spec;
  1275. int err;
  1276. int i;
  1277. for (i = 0; i < spec->num_mixers; i++) {
  1278. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1279. if (err < 0)
  1280. return err;
  1281. }
  1282. if (spec->multiout.dig_out_nid) {
  1283. err = snd_hda_create_spdif_out_ctls(codec,
  1284. spec->multiout.dig_out_nid);
  1285. if (err < 0)
  1286. return err;
  1287. }
  1288. if (spec->dig_in_nid) {
  1289. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1290. if (err < 0)
  1291. return err;
  1292. }
  1293. return 0;
  1294. }
  1295. /*
  1296. * initialize the codec volumes, etc
  1297. */
  1298. /*
  1299. * generic initialization of ADC, input mixers and output mixers
  1300. */
  1301. static struct hda_verb alc880_volume_init_verbs[] = {
  1302. /*
  1303. * Unmute ADC0-2 and set the default input to mic-in
  1304. */
  1305. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1306. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1307. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1308. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1309. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1310. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1311. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1312. * mixer widget
  1313. * Note: PASD motherboards uses the Line In 2 as the input for front
  1314. * panel mic (mic 2)
  1315. */
  1316. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1317. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1318. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1319. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1320. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1321. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1322. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1323. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1324. /*
  1325. * Set up output mixers (0x0c - 0x0f)
  1326. */
  1327. /* set vol=0 to output mixers */
  1328. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1329. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1330. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1331. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1332. /* set up input amps for analog loopback */
  1333. /* Amp Indices: DAC = 0, mixer = 1 */
  1334. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1335. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1336. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1337. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1338. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1339. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1340. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1341. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1342. { }
  1343. };
  1344. /*
  1345. * 3-stack pin configuration:
  1346. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1347. */
  1348. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1349. /*
  1350. * preset connection lists of input pins
  1351. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1352. */
  1353. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1354. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1355. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1356. /*
  1357. * Set pin mode and muting
  1358. */
  1359. /* set front pin widgets 0x14 for output */
  1360. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1361. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1362. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1363. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1364. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1365. /* Mic2 (as headphone out) for HP output */
  1366. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1367. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1368. /* Line In pin widget for input */
  1369. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1370. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1371. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1372. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1373. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1374. /* CD pin widget for input */
  1375. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1376. { }
  1377. };
  1378. /*
  1379. * 5-stack pin configuration:
  1380. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1381. * line-in/side = 0x1a, f-mic = 0x1b
  1382. */
  1383. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1384. /*
  1385. * preset connection lists of input pins
  1386. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1387. */
  1388. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1389. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1390. /*
  1391. * Set pin mode and muting
  1392. */
  1393. /* set pin widgets 0x14-0x17 for output */
  1394. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1395. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1396. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1397. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1398. /* unmute pins for output (no gain on this amp) */
  1399. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1400. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1401. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1402. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1403. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1404. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1405. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1406. /* Mic2 (as headphone out) for HP output */
  1407. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1408. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1409. /* Line In pin widget for input */
  1410. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1411. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1412. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1413. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1414. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1415. /* CD pin widget for input */
  1416. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1417. { }
  1418. };
  1419. /*
  1420. * W810 pin configuration:
  1421. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1422. */
  1423. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1424. /* hphone/speaker input selector: front DAC */
  1425. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1426. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1427. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1428. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1429. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1430. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1431. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1432. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1433. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1434. { }
  1435. };
  1436. /*
  1437. * Z71V pin configuration:
  1438. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1439. */
  1440. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1441. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1442. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1443. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1444. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1445. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1446. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1447. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1448. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1449. { }
  1450. };
  1451. /*
  1452. * 6-stack pin configuration:
  1453. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1454. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1455. */
  1456. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1457. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1458. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1459. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1460. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1461. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1462. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1463. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1464. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1465. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1466. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1467. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1468. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1469. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1470. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1471. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1472. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1473. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1474. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1475. { }
  1476. };
  1477. /*
  1478. * Uniwill pin configuration:
  1479. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1480. * line = 0x1a
  1481. */
  1482. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1483. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1484. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1485. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1486. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1487. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1488. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1489. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1490. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1491. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1492. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1493. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1494. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1495. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1496. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1497. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1498. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1499. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1500. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1501. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1502. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1503. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1504. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1505. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1506. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1507. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1508. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1509. { }
  1510. };
  1511. /*
  1512. * Uniwill P53
  1513. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1514. */
  1515. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1516. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1517. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1518. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1519. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1520. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1521. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1522. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1523. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1524. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1525. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1526. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1527. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1528. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1529. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1530. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1531. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1532. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1533. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1534. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1535. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1536. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1537. { }
  1538. };
  1539. static struct hda_verb alc880_beep_init_verbs[] = {
  1540. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1541. { }
  1542. };
  1543. /* toggle speaker-output according to the hp-jack state */
  1544. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1545. {
  1546. unsigned int present;
  1547. unsigned char bits;
  1548. present = snd_hda_codec_read(codec, 0x14, 0,
  1549. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1550. bits = present ? HDA_AMP_MUTE : 0;
  1551. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1552. HDA_AMP_MUTE, bits);
  1553. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1554. HDA_AMP_MUTE, bits);
  1555. }
  1556. /* auto-toggle front mic */
  1557. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1558. {
  1559. unsigned int present;
  1560. unsigned char bits;
  1561. present = snd_hda_codec_read(codec, 0x18, 0,
  1562. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1563. bits = present ? HDA_AMP_MUTE : 0;
  1564. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1565. }
  1566. static void alc880_uniwill_automute(struct hda_codec *codec)
  1567. {
  1568. alc880_uniwill_hp_automute(codec);
  1569. alc880_uniwill_mic_automute(codec);
  1570. }
  1571. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1572. unsigned int res)
  1573. {
  1574. /* Looks like the unsol event is incompatible with the standard
  1575. * definition. 4bit tag is placed at 28 bit!
  1576. */
  1577. switch (res >> 28) {
  1578. case ALC880_HP_EVENT:
  1579. alc880_uniwill_hp_automute(codec);
  1580. break;
  1581. case ALC880_MIC_EVENT:
  1582. alc880_uniwill_mic_automute(codec);
  1583. break;
  1584. }
  1585. }
  1586. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1587. {
  1588. unsigned int present;
  1589. unsigned char bits;
  1590. present = snd_hda_codec_read(codec, 0x14, 0,
  1591. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1592. bits = present ? HDA_AMP_MUTE : 0;
  1593. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1594. }
  1595. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1596. {
  1597. unsigned int present;
  1598. present = snd_hda_codec_read(codec, 0x21, 0,
  1599. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1600. present &= HDA_AMP_VOLMASK;
  1601. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1602. HDA_AMP_VOLMASK, present);
  1603. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1604. HDA_AMP_VOLMASK, present);
  1605. }
  1606. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1607. unsigned int res)
  1608. {
  1609. /* Looks like the unsol event is incompatible with the standard
  1610. * definition. 4bit tag is placed at 28 bit!
  1611. */
  1612. if ((res >> 28) == ALC880_HP_EVENT)
  1613. alc880_uniwill_p53_hp_automute(codec);
  1614. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1615. alc880_uniwill_p53_dcvol_automute(codec);
  1616. }
  1617. /* FIXME! */
  1618. /*
  1619. * F1734 pin configuration:
  1620. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1621. */
  1622. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1623. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1624. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1625. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1626. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1627. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1628. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1629. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1630. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1631. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1632. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1633. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1634. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1635. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1636. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1637. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1638. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1639. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1640. { }
  1641. };
  1642. /* FIXME! */
  1643. /*
  1644. * ASUS pin configuration:
  1645. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1646. */
  1647. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1648. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1649. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1650. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1651. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1652. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1653. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1654. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1655. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1656. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1657. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1658. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1659. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1660. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1661. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1662. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1663. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1664. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1665. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1666. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1667. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1668. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1669. { }
  1670. };
  1671. /* Enable GPIO mask and set output */
  1672. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1673. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1674. /* Clevo m520g init */
  1675. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1676. /* headphone output */
  1677. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1678. /* line-out */
  1679. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1680. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1681. /* Line-in */
  1682. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1683. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1684. /* CD */
  1685. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1686. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1687. /* Mic1 (rear panel) */
  1688. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1689. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1690. /* Mic2 (front panel) */
  1691. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1692. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1693. /* headphone */
  1694. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1695. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1696. /* change to EAPD mode */
  1697. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1698. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1699. { }
  1700. };
  1701. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1702. /* change to EAPD mode */
  1703. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1704. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1705. /* Headphone output */
  1706. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1707. /* Front output*/
  1708. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1709. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1710. /* Line In pin widget for input */
  1711. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1712. /* CD pin widget for input */
  1713. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1714. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1715. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1716. /* change to EAPD mode */
  1717. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1718. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1719. { }
  1720. };
  1721. /*
  1722. * LG m1 express dual
  1723. *
  1724. * Pin assignment:
  1725. * Rear Line-In/Out (blue): 0x14
  1726. * Build-in Mic-In: 0x15
  1727. * Speaker-out: 0x17
  1728. * HP-Out (green): 0x1b
  1729. * Mic-In/Out (red): 0x19
  1730. * SPDIF-Out: 0x1e
  1731. */
  1732. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1733. static hda_nid_t alc880_lg_dac_nids[3] = {
  1734. 0x05, 0x02, 0x03
  1735. };
  1736. /* seems analog CD is not working */
  1737. static struct hda_input_mux alc880_lg_capture_source = {
  1738. .num_items = 3,
  1739. .items = {
  1740. { "Mic", 0x1 },
  1741. { "Line", 0x5 },
  1742. { "Internal Mic", 0x6 },
  1743. },
  1744. };
  1745. /* 2,4,6 channel modes */
  1746. static struct hda_verb alc880_lg_ch2_init[] = {
  1747. /* set line-in and mic-in to input */
  1748. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1749. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1750. { }
  1751. };
  1752. static struct hda_verb alc880_lg_ch4_init[] = {
  1753. /* set line-in to out and mic-in to input */
  1754. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1755. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1756. { }
  1757. };
  1758. static struct hda_verb alc880_lg_ch6_init[] = {
  1759. /* set line-in and mic-in to output */
  1760. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1761. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1762. { }
  1763. };
  1764. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1765. { 2, alc880_lg_ch2_init },
  1766. { 4, alc880_lg_ch4_init },
  1767. { 6, alc880_lg_ch6_init },
  1768. };
  1769. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1770. /* FIXME: it's not really "master" but front channels */
  1771. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1772. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1773. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1774. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1775. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1776. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1777. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1778. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1779. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1780. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1781. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1782. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1783. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1784. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1785. {
  1786. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1787. .name = "Channel Mode",
  1788. .info = alc_ch_mode_info,
  1789. .get = alc_ch_mode_get,
  1790. .put = alc_ch_mode_put,
  1791. },
  1792. { } /* end */
  1793. };
  1794. static struct hda_verb alc880_lg_init_verbs[] = {
  1795. /* set capture source to mic-in */
  1796. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1797. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1798. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1799. /* mute all amp mixer inputs */
  1800. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1801. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1802. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1803. /* line-in to input */
  1804. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1805. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1806. /* built-in mic */
  1807. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1808. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1809. /* speaker-out */
  1810. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1811. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1812. /* mic-in to input */
  1813. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1814. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1815. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1816. /* HP-out */
  1817. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1818. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1819. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1820. /* jack sense */
  1821. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1822. { }
  1823. };
  1824. /* toggle speaker-output according to the hp-jack state */
  1825. static void alc880_lg_automute(struct hda_codec *codec)
  1826. {
  1827. unsigned int present;
  1828. unsigned char bits;
  1829. present = snd_hda_codec_read(codec, 0x1b, 0,
  1830. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1831. bits = present ? HDA_AMP_MUTE : 0;
  1832. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1833. HDA_AMP_MUTE, bits);
  1834. }
  1835. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1836. {
  1837. /* Looks like the unsol event is incompatible with the standard
  1838. * definition. 4bit tag is placed at 28 bit!
  1839. */
  1840. if ((res >> 28) == 0x01)
  1841. alc880_lg_automute(codec);
  1842. }
  1843. /*
  1844. * LG LW20
  1845. *
  1846. * Pin assignment:
  1847. * Speaker-out: 0x14
  1848. * Mic-In: 0x18
  1849. * Built-in Mic-In: 0x19
  1850. * Line-In: 0x1b
  1851. * HP-Out: 0x1a
  1852. * SPDIF-Out: 0x1e
  1853. */
  1854. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1855. .num_items = 3,
  1856. .items = {
  1857. { "Mic", 0x0 },
  1858. { "Internal Mic", 0x1 },
  1859. { "Line In", 0x2 },
  1860. },
  1861. };
  1862. #define alc880_lg_lw_modes alc880_threestack_modes
  1863. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1864. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1865. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1866. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1867. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1868. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1869. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1870. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1871. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1872. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1873. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1874. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1875. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1876. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1877. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1878. {
  1879. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1880. .name = "Channel Mode",
  1881. .info = alc_ch_mode_info,
  1882. .get = alc_ch_mode_get,
  1883. .put = alc_ch_mode_put,
  1884. },
  1885. { } /* end */
  1886. };
  1887. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1888. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1889. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1890. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1891. /* set capture source to mic-in */
  1892. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1893. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1894. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1895. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1896. /* speaker-out */
  1897. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1898. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1899. /* HP-out */
  1900. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1901. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1902. /* mic-in to input */
  1903. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1904. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1905. /* built-in mic */
  1906. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1907. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1908. /* jack sense */
  1909. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1910. { }
  1911. };
  1912. /* toggle speaker-output according to the hp-jack state */
  1913. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1914. {
  1915. unsigned int present;
  1916. unsigned char bits;
  1917. present = snd_hda_codec_read(codec, 0x1b, 0,
  1918. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1919. bits = present ? HDA_AMP_MUTE : 0;
  1920. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1921. HDA_AMP_MUTE, bits);
  1922. }
  1923. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1924. {
  1925. /* Looks like the unsol event is incompatible with the standard
  1926. * definition. 4bit tag is placed at 28 bit!
  1927. */
  1928. if ((res >> 28) == 0x01)
  1929. alc880_lg_lw_automute(codec);
  1930. }
  1931. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1932. static struct hda_amp_list alc880_loopbacks[] = {
  1933. { 0x0b, HDA_INPUT, 0 },
  1934. { 0x0b, HDA_INPUT, 1 },
  1935. { 0x0b, HDA_INPUT, 2 },
  1936. { 0x0b, HDA_INPUT, 3 },
  1937. { 0x0b, HDA_INPUT, 4 },
  1938. { } /* end */
  1939. };
  1940. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1941. { 0x0b, HDA_INPUT, 1 },
  1942. { 0x0b, HDA_INPUT, 6 },
  1943. { 0x0b, HDA_INPUT, 7 },
  1944. { } /* end */
  1945. };
  1946. #endif
  1947. /*
  1948. * Common callbacks
  1949. */
  1950. static int alc_init(struct hda_codec *codec)
  1951. {
  1952. struct alc_spec *spec = codec->spec;
  1953. unsigned int i;
  1954. for (i = 0; i < spec->num_init_verbs; i++)
  1955. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1956. if (spec->init_hook)
  1957. spec->init_hook(codec);
  1958. return 0;
  1959. }
  1960. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1961. {
  1962. struct alc_spec *spec = codec->spec;
  1963. if (spec->unsol_event)
  1964. spec->unsol_event(codec, res);
  1965. }
  1966. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1967. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1968. {
  1969. struct alc_spec *spec = codec->spec;
  1970. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1971. }
  1972. #endif
  1973. /*
  1974. * Analog playback callbacks
  1975. */
  1976. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1977. struct hda_codec *codec,
  1978. struct snd_pcm_substream *substream)
  1979. {
  1980. struct alc_spec *spec = codec->spec;
  1981. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1982. }
  1983. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1984. struct hda_codec *codec,
  1985. unsigned int stream_tag,
  1986. unsigned int format,
  1987. struct snd_pcm_substream *substream)
  1988. {
  1989. struct alc_spec *spec = codec->spec;
  1990. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1991. stream_tag, format, substream);
  1992. }
  1993. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1994. struct hda_codec *codec,
  1995. struct snd_pcm_substream *substream)
  1996. {
  1997. struct alc_spec *spec = codec->spec;
  1998. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1999. }
  2000. /*
  2001. * Digital out
  2002. */
  2003. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  2004. struct hda_codec *codec,
  2005. struct snd_pcm_substream *substream)
  2006. {
  2007. struct alc_spec *spec = codec->spec;
  2008. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  2009. }
  2010. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  2011. struct hda_codec *codec,
  2012. unsigned int stream_tag,
  2013. unsigned int format,
  2014. struct snd_pcm_substream *substream)
  2015. {
  2016. struct alc_spec *spec = codec->spec;
  2017. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  2018. stream_tag, format, substream);
  2019. }
  2020. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  2021. struct hda_codec *codec,
  2022. struct snd_pcm_substream *substream)
  2023. {
  2024. struct alc_spec *spec = codec->spec;
  2025. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  2026. }
  2027. /*
  2028. * Analog capture
  2029. */
  2030. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  2031. struct hda_codec *codec,
  2032. unsigned int stream_tag,
  2033. unsigned int format,
  2034. struct snd_pcm_substream *substream)
  2035. {
  2036. struct alc_spec *spec = codec->spec;
  2037. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  2038. stream_tag, 0, format);
  2039. return 0;
  2040. }
  2041. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  2042. struct hda_codec *codec,
  2043. struct snd_pcm_substream *substream)
  2044. {
  2045. struct alc_spec *spec = codec->spec;
  2046. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  2047. 0, 0, 0);
  2048. return 0;
  2049. }
  2050. /*
  2051. */
  2052. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  2053. .substreams = 1,
  2054. .channels_min = 2,
  2055. .channels_max = 8,
  2056. /* NID is set in alc_build_pcms */
  2057. .ops = {
  2058. .open = alc880_playback_pcm_open,
  2059. .prepare = alc880_playback_pcm_prepare,
  2060. .cleanup = alc880_playback_pcm_cleanup
  2061. },
  2062. };
  2063. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  2064. .substreams = 2,
  2065. .channels_min = 2,
  2066. .channels_max = 2,
  2067. /* NID is set in alc_build_pcms */
  2068. .ops = {
  2069. .prepare = alc880_capture_pcm_prepare,
  2070. .cleanup = alc880_capture_pcm_cleanup
  2071. },
  2072. };
  2073. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  2074. .substreams = 1,
  2075. .channels_min = 2,
  2076. .channels_max = 2,
  2077. /* NID is set in alc_build_pcms */
  2078. .ops = {
  2079. .open = alc880_dig_playback_pcm_open,
  2080. .close = alc880_dig_playback_pcm_close,
  2081. .prepare = alc880_dig_playback_pcm_prepare
  2082. },
  2083. };
  2084. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  2085. .substreams = 1,
  2086. .channels_min = 2,
  2087. .channels_max = 2,
  2088. /* NID is set in alc_build_pcms */
  2089. };
  2090. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  2091. static struct hda_pcm_stream alc_pcm_null_playback = {
  2092. .substreams = 0,
  2093. .channels_min = 0,
  2094. .channels_max = 0,
  2095. };
  2096. static int alc_build_pcms(struct hda_codec *codec)
  2097. {
  2098. struct alc_spec *spec = codec->spec;
  2099. struct hda_pcm *info = spec->pcm_rec;
  2100. int i;
  2101. codec->num_pcms = 1;
  2102. codec->pcm_info = info;
  2103. info->name = spec->stream_name_analog;
  2104. if (spec->stream_analog_playback) {
  2105. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  2106. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  2107. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  2108. }
  2109. if (spec->stream_analog_capture) {
  2110. snd_assert(spec->adc_nids, return -EINVAL);
  2111. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2112. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  2113. }
  2114. if (spec->channel_mode) {
  2115. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  2116. for (i = 0; i < spec->num_channel_mode; i++) {
  2117. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  2118. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  2119. }
  2120. }
  2121. }
  2122. /* SPDIF for stream index #1 */
  2123. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  2124. codec->num_pcms = 2;
  2125. info = spec->pcm_rec + 1;
  2126. info->name = spec->stream_name_digital;
  2127. if (spec->multiout.dig_out_nid &&
  2128. spec->stream_digital_playback) {
  2129. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  2130. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  2131. }
  2132. if (spec->dig_in_nid &&
  2133. spec->stream_digital_capture) {
  2134. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  2135. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  2136. }
  2137. }
  2138. /* If the use of more than one ADC is requested for the current
  2139. * model, configure a second analog capture-only PCM.
  2140. */
  2141. /* Additional Analaog capture for index #2 */
  2142. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  2143. spec->adc_nids) {
  2144. codec->num_pcms = 3;
  2145. info = spec->pcm_rec + 2;
  2146. info->name = spec->stream_name_analog;
  2147. /* No playback stream for second PCM */
  2148. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2149. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2150. if (spec->stream_analog_capture) {
  2151. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2152. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2153. }
  2154. }
  2155. return 0;
  2156. }
  2157. static void alc_free(struct hda_codec *codec)
  2158. {
  2159. struct alc_spec *spec = codec->spec;
  2160. unsigned int i;
  2161. if (!spec)
  2162. return;
  2163. if (spec->kctl_alloc) {
  2164. for (i = 0; i < spec->num_kctl_used; i++)
  2165. kfree(spec->kctl_alloc[i].name);
  2166. kfree(spec->kctl_alloc);
  2167. }
  2168. kfree(spec);
  2169. }
  2170. /*
  2171. */
  2172. static struct hda_codec_ops alc_patch_ops = {
  2173. .build_controls = alc_build_controls,
  2174. .build_pcms = alc_build_pcms,
  2175. .init = alc_init,
  2176. .free = alc_free,
  2177. .unsol_event = alc_unsol_event,
  2178. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2179. .check_power_status = alc_check_power_status,
  2180. #endif
  2181. };
  2182. /*
  2183. * Test configuration for debugging
  2184. *
  2185. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2186. * enum controls.
  2187. */
  2188. #ifdef CONFIG_SND_DEBUG
  2189. static hda_nid_t alc880_test_dac_nids[4] = {
  2190. 0x02, 0x03, 0x04, 0x05
  2191. };
  2192. static struct hda_input_mux alc880_test_capture_source = {
  2193. .num_items = 7,
  2194. .items = {
  2195. { "In-1", 0x0 },
  2196. { "In-2", 0x1 },
  2197. { "In-3", 0x2 },
  2198. { "In-4", 0x3 },
  2199. { "CD", 0x4 },
  2200. { "Front", 0x5 },
  2201. { "Surround", 0x6 },
  2202. },
  2203. };
  2204. static struct hda_channel_mode alc880_test_modes[4] = {
  2205. { 2, NULL },
  2206. { 4, NULL },
  2207. { 6, NULL },
  2208. { 8, NULL },
  2209. };
  2210. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2211. struct snd_ctl_elem_info *uinfo)
  2212. {
  2213. static char *texts[] = {
  2214. "N/A", "Line Out", "HP Out",
  2215. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2216. };
  2217. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2218. uinfo->count = 1;
  2219. uinfo->value.enumerated.items = 8;
  2220. if (uinfo->value.enumerated.item >= 8)
  2221. uinfo->value.enumerated.item = 7;
  2222. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2223. return 0;
  2224. }
  2225. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2226. struct snd_ctl_elem_value *ucontrol)
  2227. {
  2228. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2229. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2230. unsigned int pin_ctl, item = 0;
  2231. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2232. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2233. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2234. if (pin_ctl & AC_PINCTL_HP_EN)
  2235. item = 2;
  2236. else
  2237. item = 1;
  2238. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2239. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2240. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2241. case AC_PINCTL_VREF_50: item = 4; break;
  2242. case AC_PINCTL_VREF_GRD: item = 5; break;
  2243. case AC_PINCTL_VREF_80: item = 6; break;
  2244. case AC_PINCTL_VREF_100: item = 7; break;
  2245. }
  2246. }
  2247. ucontrol->value.enumerated.item[0] = item;
  2248. return 0;
  2249. }
  2250. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2251. struct snd_ctl_elem_value *ucontrol)
  2252. {
  2253. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2254. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2255. static unsigned int ctls[] = {
  2256. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2257. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2258. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2259. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2260. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2261. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2262. };
  2263. unsigned int old_ctl, new_ctl;
  2264. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2265. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2266. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2267. if (old_ctl != new_ctl) {
  2268. int val;
  2269. snd_hda_codec_write_cache(codec, nid, 0,
  2270. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2271. new_ctl);
  2272. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2273. HDA_AMP_MUTE : 0;
  2274. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2275. HDA_AMP_MUTE, val);
  2276. return 1;
  2277. }
  2278. return 0;
  2279. }
  2280. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2281. struct snd_ctl_elem_info *uinfo)
  2282. {
  2283. static char *texts[] = {
  2284. "Front", "Surround", "CLFE", "Side"
  2285. };
  2286. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2287. uinfo->count = 1;
  2288. uinfo->value.enumerated.items = 4;
  2289. if (uinfo->value.enumerated.item >= 4)
  2290. uinfo->value.enumerated.item = 3;
  2291. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2292. return 0;
  2293. }
  2294. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2295. struct snd_ctl_elem_value *ucontrol)
  2296. {
  2297. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2298. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2299. unsigned int sel;
  2300. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2301. ucontrol->value.enumerated.item[0] = sel & 3;
  2302. return 0;
  2303. }
  2304. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2305. struct snd_ctl_elem_value *ucontrol)
  2306. {
  2307. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2308. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2309. unsigned int sel;
  2310. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2311. if (ucontrol->value.enumerated.item[0] != sel) {
  2312. sel = ucontrol->value.enumerated.item[0] & 3;
  2313. snd_hda_codec_write_cache(codec, nid, 0,
  2314. AC_VERB_SET_CONNECT_SEL, sel);
  2315. return 1;
  2316. }
  2317. return 0;
  2318. }
  2319. #define PIN_CTL_TEST(xname,nid) { \
  2320. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2321. .name = xname, \
  2322. .info = alc_test_pin_ctl_info, \
  2323. .get = alc_test_pin_ctl_get, \
  2324. .put = alc_test_pin_ctl_put, \
  2325. .private_value = nid \
  2326. }
  2327. #define PIN_SRC_TEST(xname,nid) { \
  2328. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2329. .name = xname, \
  2330. .info = alc_test_pin_src_info, \
  2331. .get = alc_test_pin_src_get, \
  2332. .put = alc_test_pin_src_put, \
  2333. .private_value = nid \
  2334. }
  2335. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2336. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2337. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2338. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2339. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2340. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2341. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2342. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2343. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2344. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2345. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2346. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2347. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2348. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2349. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2350. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2351. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2352. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2353. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2354. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2355. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2356. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2357. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2358. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2359. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2360. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2361. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2362. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2363. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2364. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2365. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2366. {
  2367. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2368. .name = "Channel Mode",
  2369. .info = alc_ch_mode_info,
  2370. .get = alc_ch_mode_get,
  2371. .put = alc_ch_mode_put,
  2372. },
  2373. { } /* end */
  2374. };
  2375. static struct hda_verb alc880_test_init_verbs[] = {
  2376. /* Unmute inputs of 0x0c - 0x0f */
  2377. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2378. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2379. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2380. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2381. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2382. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2383. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2384. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2385. /* Vol output for 0x0c-0x0f */
  2386. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2387. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2388. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2389. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2390. /* Set output pins 0x14-0x17 */
  2391. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2392. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2393. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2394. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2395. /* Unmute output pins 0x14-0x17 */
  2396. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2397. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2398. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2399. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2400. /* Set input pins 0x18-0x1c */
  2401. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2402. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2403. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2404. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2405. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2406. /* Mute input pins 0x18-0x1b */
  2407. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2408. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2409. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2410. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2411. /* ADC set up */
  2412. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2413. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2414. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2415. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2416. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2417. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2418. /* Analog input/passthru */
  2419. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2420. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2421. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2422. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2423. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2424. { }
  2425. };
  2426. #endif
  2427. /*
  2428. */
  2429. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2430. [ALC880_3ST] = "3stack",
  2431. [ALC880_TCL_S700] = "tcl",
  2432. [ALC880_3ST_DIG] = "3stack-digout",
  2433. [ALC880_CLEVO] = "clevo",
  2434. [ALC880_5ST] = "5stack",
  2435. [ALC880_5ST_DIG] = "5stack-digout",
  2436. [ALC880_W810] = "w810",
  2437. [ALC880_Z71V] = "z71v",
  2438. [ALC880_6ST] = "6stack",
  2439. [ALC880_6ST_DIG] = "6stack-digout",
  2440. [ALC880_ASUS] = "asus",
  2441. [ALC880_ASUS_W1V] = "asus-w1v",
  2442. [ALC880_ASUS_DIG] = "asus-dig",
  2443. [ALC880_ASUS_DIG2] = "asus-dig2",
  2444. [ALC880_UNIWILL_DIG] = "uniwill",
  2445. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2446. [ALC880_FUJITSU] = "fujitsu",
  2447. [ALC880_F1734] = "F1734",
  2448. [ALC880_LG] = "lg",
  2449. [ALC880_LG_LW] = "lg-lw",
  2450. #ifdef CONFIG_SND_DEBUG
  2451. [ALC880_TEST] = "test",
  2452. #endif
  2453. [ALC880_AUTO] = "auto",
  2454. };
  2455. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2456. /* Broken BIOS configuration */
  2457. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2458. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2459. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2460. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2461. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2462. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2463. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2464. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2465. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2466. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2467. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2468. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2469. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2470. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2471. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2472. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2473. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2474. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2475. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2476. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2477. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2478. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2479. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2480. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2481. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2482. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2483. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2484. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2485. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2486. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2487. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2488. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2489. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2490. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2491. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2492. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2493. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2494. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2495. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2496. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2497. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2498. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2499. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2500. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2501. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2502. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2503. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2504. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2505. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2506. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2507. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2508. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2509. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2510. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2511. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2512. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2513. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2514. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2515. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2516. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2517. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2518. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2519. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2520. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2521. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2522. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2523. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2524. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2525. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2526. {}
  2527. };
  2528. /*
  2529. * ALC880 codec presets
  2530. */
  2531. static struct alc_config_preset alc880_presets[] = {
  2532. [ALC880_3ST] = {
  2533. .mixers = { alc880_three_stack_mixer },
  2534. .init_verbs = { alc880_volume_init_verbs,
  2535. alc880_pin_3stack_init_verbs },
  2536. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2537. .dac_nids = alc880_dac_nids,
  2538. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2539. .channel_mode = alc880_threestack_modes,
  2540. .need_dac_fix = 1,
  2541. .input_mux = &alc880_capture_source,
  2542. },
  2543. [ALC880_3ST_DIG] = {
  2544. .mixers = { alc880_three_stack_mixer },
  2545. .init_verbs = { alc880_volume_init_verbs,
  2546. alc880_pin_3stack_init_verbs },
  2547. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2548. .dac_nids = alc880_dac_nids,
  2549. .dig_out_nid = ALC880_DIGOUT_NID,
  2550. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2551. .channel_mode = alc880_threestack_modes,
  2552. .need_dac_fix = 1,
  2553. .input_mux = &alc880_capture_source,
  2554. },
  2555. [ALC880_TCL_S700] = {
  2556. .mixers = { alc880_tcl_s700_mixer },
  2557. .init_verbs = { alc880_volume_init_verbs,
  2558. alc880_pin_tcl_S700_init_verbs,
  2559. alc880_gpio2_init_verbs },
  2560. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2561. .dac_nids = alc880_dac_nids,
  2562. .hp_nid = 0x03,
  2563. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2564. .channel_mode = alc880_2_jack_modes,
  2565. .input_mux = &alc880_capture_source,
  2566. },
  2567. [ALC880_5ST] = {
  2568. .mixers = { alc880_three_stack_mixer,
  2569. alc880_five_stack_mixer},
  2570. .init_verbs = { alc880_volume_init_verbs,
  2571. alc880_pin_5stack_init_verbs },
  2572. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2573. .dac_nids = alc880_dac_nids,
  2574. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2575. .channel_mode = alc880_fivestack_modes,
  2576. .input_mux = &alc880_capture_source,
  2577. },
  2578. [ALC880_5ST_DIG] = {
  2579. .mixers = { alc880_three_stack_mixer,
  2580. alc880_five_stack_mixer },
  2581. .init_verbs = { alc880_volume_init_verbs,
  2582. alc880_pin_5stack_init_verbs },
  2583. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2584. .dac_nids = alc880_dac_nids,
  2585. .dig_out_nid = ALC880_DIGOUT_NID,
  2586. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2587. .channel_mode = alc880_fivestack_modes,
  2588. .input_mux = &alc880_capture_source,
  2589. },
  2590. [ALC880_6ST] = {
  2591. .mixers = { alc880_six_stack_mixer },
  2592. .init_verbs = { alc880_volume_init_verbs,
  2593. alc880_pin_6stack_init_verbs },
  2594. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2595. .dac_nids = alc880_6st_dac_nids,
  2596. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2597. .channel_mode = alc880_sixstack_modes,
  2598. .input_mux = &alc880_6stack_capture_source,
  2599. },
  2600. [ALC880_6ST_DIG] = {
  2601. .mixers = { alc880_six_stack_mixer },
  2602. .init_verbs = { alc880_volume_init_verbs,
  2603. alc880_pin_6stack_init_verbs },
  2604. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2605. .dac_nids = alc880_6st_dac_nids,
  2606. .dig_out_nid = ALC880_DIGOUT_NID,
  2607. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2608. .channel_mode = alc880_sixstack_modes,
  2609. .input_mux = &alc880_6stack_capture_source,
  2610. },
  2611. [ALC880_W810] = {
  2612. .mixers = { alc880_w810_base_mixer },
  2613. .init_verbs = { alc880_volume_init_verbs,
  2614. alc880_pin_w810_init_verbs,
  2615. alc880_gpio2_init_verbs },
  2616. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2617. .dac_nids = alc880_w810_dac_nids,
  2618. .dig_out_nid = ALC880_DIGOUT_NID,
  2619. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2620. .channel_mode = alc880_w810_modes,
  2621. .input_mux = &alc880_capture_source,
  2622. },
  2623. [ALC880_Z71V] = {
  2624. .mixers = { alc880_z71v_mixer },
  2625. .init_verbs = { alc880_volume_init_verbs,
  2626. alc880_pin_z71v_init_verbs },
  2627. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2628. .dac_nids = alc880_z71v_dac_nids,
  2629. .dig_out_nid = ALC880_DIGOUT_NID,
  2630. .hp_nid = 0x03,
  2631. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2632. .channel_mode = alc880_2_jack_modes,
  2633. .input_mux = &alc880_capture_source,
  2634. },
  2635. [ALC880_F1734] = {
  2636. .mixers = { alc880_f1734_mixer },
  2637. .init_verbs = { alc880_volume_init_verbs,
  2638. alc880_pin_f1734_init_verbs },
  2639. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2640. .dac_nids = alc880_f1734_dac_nids,
  2641. .hp_nid = 0x02,
  2642. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2643. .channel_mode = alc880_2_jack_modes,
  2644. .input_mux = &alc880_capture_source,
  2645. },
  2646. [ALC880_ASUS] = {
  2647. .mixers = { alc880_asus_mixer },
  2648. .init_verbs = { alc880_volume_init_verbs,
  2649. alc880_pin_asus_init_verbs,
  2650. alc880_gpio1_init_verbs },
  2651. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2652. .dac_nids = alc880_asus_dac_nids,
  2653. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2654. .channel_mode = alc880_asus_modes,
  2655. .need_dac_fix = 1,
  2656. .input_mux = &alc880_capture_source,
  2657. },
  2658. [ALC880_ASUS_DIG] = {
  2659. .mixers = { alc880_asus_mixer },
  2660. .init_verbs = { alc880_volume_init_verbs,
  2661. alc880_pin_asus_init_verbs,
  2662. alc880_gpio1_init_verbs },
  2663. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2664. .dac_nids = alc880_asus_dac_nids,
  2665. .dig_out_nid = ALC880_DIGOUT_NID,
  2666. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2667. .channel_mode = alc880_asus_modes,
  2668. .need_dac_fix = 1,
  2669. .input_mux = &alc880_capture_source,
  2670. },
  2671. [ALC880_ASUS_DIG2] = {
  2672. .mixers = { alc880_asus_mixer },
  2673. .init_verbs = { alc880_volume_init_verbs,
  2674. alc880_pin_asus_init_verbs,
  2675. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2676. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2677. .dac_nids = alc880_asus_dac_nids,
  2678. .dig_out_nid = ALC880_DIGOUT_NID,
  2679. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2680. .channel_mode = alc880_asus_modes,
  2681. .need_dac_fix = 1,
  2682. .input_mux = &alc880_capture_source,
  2683. },
  2684. [ALC880_ASUS_W1V] = {
  2685. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2686. .init_verbs = { alc880_volume_init_verbs,
  2687. alc880_pin_asus_init_verbs,
  2688. alc880_gpio1_init_verbs },
  2689. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2690. .dac_nids = alc880_asus_dac_nids,
  2691. .dig_out_nid = ALC880_DIGOUT_NID,
  2692. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2693. .channel_mode = alc880_asus_modes,
  2694. .need_dac_fix = 1,
  2695. .input_mux = &alc880_capture_source,
  2696. },
  2697. [ALC880_UNIWILL_DIG] = {
  2698. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2699. .init_verbs = { alc880_volume_init_verbs,
  2700. alc880_pin_asus_init_verbs },
  2701. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2702. .dac_nids = alc880_asus_dac_nids,
  2703. .dig_out_nid = ALC880_DIGOUT_NID,
  2704. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2705. .channel_mode = alc880_asus_modes,
  2706. .need_dac_fix = 1,
  2707. .input_mux = &alc880_capture_source,
  2708. },
  2709. [ALC880_UNIWILL] = {
  2710. .mixers = { alc880_uniwill_mixer },
  2711. .init_verbs = { alc880_volume_init_verbs,
  2712. alc880_uniwill_init_verbs },
  2713. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2714. .dac_nids = alc880_asus_dac_nids,
  2715. .dig_out_nid = ALC880_DIGOUT_NID,
  2716. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2717. .channel_mode = alc880_threestack_modes,
  2718. .need_dac_fix = 1,
  2719. .input_mux = &alc880_capture_source,
  2720. .unsol_event = alc880_uniwill_unsol_event,
  2721. .init_hook = alc880_uniwill_automute,
  2722. },
  2723. [ALC880_UNIWILL_P53] = {
  2724. .mixers = { alc880_uniwill_p53_mixer },
  2725. .init_verbs = { alc880_volume_init_verbs,
  2726. alc880_uniwill_p53_init_verbs },
  2727. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2728. .dac_nids = alc880_asus_dac_nids,
  2729. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2730. .channel_mode = alc880_threestack_modes,
  2731. .input_mux = &alc880_capture_source,
  2732. .unsol_event = alc880_uniwill_p53_unsol_event,
  2733. .init_hook = alc880_uniwill_p53_hp_automute,
  2734. },
  2735. [ALC880_FUJITSU] = {
  2736. .mixers = { alc880_fujitsu_mixer,
  2737. alc880_pcbeep_mixer, },
  2738. .init_verbs = { alc880_volume_init_verbs,
  2739. alc880_uniwill_p53_init_verbs,
  2740. alc880_beep_init_verbs },
  2741. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2742. .dac_nids = alc880_dac_nids,
  2743. .dig_out_nid = ALC880_DIGOUT_NID,
  2744. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2745. .channel_mode = alc880_2_jack_modes,
  2746. .input_mux = &alc880_capture_source,
  2747. .unsol_event = alc880_uniwill_p53_unsol_event,
  2748. .init_hook = alc880_uniwill_p53_hp_automute,
  2749. },
  2750. [ALC880_CLEVO] = {
  2751. .mixers = { alc880_three_stack_mixer },
  2752. .init_verbs = { alc880_volume_init_verbs,
  2753. alc880_pin_clevo_init_verbs },
  2754. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2755. .dac_nids = alc880_dac_nids,
  2756. .hp_nid = 0x03,
  2757. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2758. .channel_mode = alc880_threestack_modes,
  2759. .need_dac_fix = 1,
  2760. .input_mux = &alc880_capture_source,
  2761. },
  2762. [ALC880_LG] = {
  2763. .mixers = { alc880_lg_mixer },
  2764. .init_verbs = { alc880_volume_init_verbs,
  2765. alc880_lg_init_verbs },
  2766. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2767. .dac_nids = alc880_lg_dac_nids,
  2768. .dig_out_nid = ALC880_DIGOUT_NID,
  2769. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2770. .channel_mode = alc880_lg_ch_modes,
  2771. .need_dac_fix = 1,
  2772. .input_mux = &alc880_lg_capture_source,
  2773. .unsol_event = alc880_lg_unsol_event,
  2774. .init_hook = alc880_lg_automute,
  2775. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2776. .loopbacks = alc880_lg_loopbacks,
  2777. #endif
  2778. },
  2779. [ALC880_LG_LW] = {
  2780. .mixers = { alc880_lg_lw_mixer },
  2781. .init_verbs = { alc880_volume_init_verbs,
  2782. alc880_lg_lw_init_verbs },
  2783. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2784. .dac_nids = alc880_dac_nids,
  2785. .dig_out_nid = ALC880_DIGOUT_NID,
  2786. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2787. .channel_mode = alc880_lg_lw_modes,
  2788. .input_mux = &alc880_lg_lw_capture_source,
  2789. .unsol_event = alc880_lg_lw_unsol_event,
  2790. .init_hook = alc880_lg_lw_automute,
  2791. },
  2792. #ifdef CONFIG_SND_DEBUG
  2793. [ALC880_TEST] = {
  2794. .mixers = { alc880_test_mixer },
  2795. .init_verbs = { alc880_test_init_verbs },
  2796. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2797. .dac_nids = alc880_test_dac_nids,
  2798. .dig_out_nid = ALC880_DIGOUT_NID,
  2799. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2800. .channel_mode = alc880_test_modes,
  2801. .input_mux = &alc880_test_capture_source,
  2802. },
  2803. #endif
  2804. };
  2805. /*
  2806. * Automatic parse of I/O pins from the BIOS configuration
  2807. */
  2808. #define NUM_CONTROL_ALLOC 32
  2809. #define NUM_VERB_ALLOC 32
  2810. enum {
  2811. ALC_CTL_WIDGET_VOL,
  2812. ALC_CTL_WIDGET_MUTE,
  2813. ALC_CTL_BIND_MUTE,
  2814. };
  2815. static struct snd_kcontrol_new alc880_control_templates[] = {
  2816. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2817. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2818. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2819. };
  2820. /* add dynamic controls */
  2821. static int add_control(struct alc_spec *spec, int type, const char *name,
  2822. unsigned long val)
  2823. {
  2824. struct snd_kcontrol_new *knew;
  2825. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2826. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2827. /* array + terminator */
  2828. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2829. if (!knew)
  2830. return -ENOMEM;
  2831. if (spec->kctl_alloc) {
  2832. memcpy(knew, spec->kctl_alloc,
  2833. sizeof(*knew) * spec->num_kctl_alloc);
  2834. kfree(spec->kctl_alloc);
  2835. }
  2836. spec->kctl_alloc = knew;
  2837. spec->num_kctl_alloc = num;
  2838. }
  2839. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2840. *knew = alc880_control_templates[type];
  2841. knew->name = kstrdup(name, GFP_KERNEL);
  2842. if (!knew->name)
  2843. return -ENOMEM;
  2844. knew->private_value = val;
  2845. spec->num_kctl_used++;
  2846. return 0;
  2847. }
  2848. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2849. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2850. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2851. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2852. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2853. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2854. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2855. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2856. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2857. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2858. #define ALC880_PIN_CD_NID 0x1c
  2859. /* fill in the dac_nids table from the parsed pin configuration */
  2860. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2861. const struct auto_pin_cfg *cfg)
  2862. {
  2863. hda_nid_t nid;
  2864. int assigned[4];
  2865. int i, j;
  2866. memset(assigned, 0, sizeof(assigned));
  2867. spec->multiout.dac_nids = spec->private_dac_nids;
  2868. /* check the pins hardwired to audio widget */
  2869. for (i = 0; i < cfg->line_outs; i++) {
  2870. nid = cfg->line_out_pins[i];
  2871. if (alc880_is_fixed_pin(nid)) {
  2872. int idx = alc880_fixed_pin_idx(nid);
  2873. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2874. assigned[idx] = 1;
  2875. }
  2876. }
  2877. /* left pins can be connect to any audio widget */
  2878. for (i = 0; i < cfg->line_outs; i++) {
  2879. nid = cfg->line_out_pins[i];
  2880. if (alc880_is_fixed_pin(nid))
  2881. continue;
  2882. /* search for an empty channel */
  2883. for (j = 0; j < cfg->line_outs; j++) {
  2884. if (!assigned[j]) {
  2885. spec->multiout.dac_nids[i] =
  2886. alc880_idx_to_dac(j);
  2887. assigned[j] = 1;
  2888. break;
  2889. }
  2890. }
  2891. }
  2892. spec->multiout.num_dacs = cfg->line_outs;
  2893. return 0;
  2894. }
  2895. /* add playback controls from the parsed DAC table */
  2896. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2897. const struct auto_pin_cfg *cfg)
  2898. {
  2899. char name[32];
  2900. static const char *chname[4] = {
  2901. "Front", "Surround", NULL /*CLFE*/, "Side"
  2902. };
  2903. hda_nid_t nid;
  2904. int i, err;
  2905. for (i = 0; i < cfg->line_outs; i++) {
  2906. if (!spec->multiout.dac_nids[i])
  2907. continue;
  2908. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2909. if (i == 2) {
  2910. /* Center/LFE */
  2911. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2912. "Center Playback Volume",
  2913. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2914. HDA_OUTPUT));
  2915. if (err < 0)
  2916. return err;
  2917. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2918. "LFE Playback Volume",
  2919. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2920. HDA_OUTPUT));
  2921. if (err < 0)
  2922. return err;
  2923. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2924. "Center Playback Switch",
  2925. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2926. HDA_INPUT));
  2927. if (err < 0)
  2928. return err;
  2929. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2930. "LFE Playback Switch",
  2931. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2932. HDA_INPUT));
  2933. if (err < 0)
  2934. return err;
  2935. } else {
  2936. sprintf(name, "%s Playback Volume", chname[i]);
  2937. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2938. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2939. HDA_OUTPUT));
  2940. if (err < 0)
  2941. return err;
  2942. sprintf(name, "%s Playback Switch", chname[i]);
  2943. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2944. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2945. HDA_INPUT));
  2946. if (err < 0)
  2947. return err;
  2948. }
  2949. }
  2950. return 0;
  2951. }
  2952. /* add playback controls for speaker and HP outputs */
  2953. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2954. const char *pfx)
  2955. {
  2956. hda_nid_t nid;
  2957. int err;
  2958. char name[32];
  2959. if (!pin)
  2960. return 0;
  2961. if (alc880_is_fixed_pin(pin)) {
  2962. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2963. /* specify the DAC as the extra output */
  2964. if (!spec->multiout.hp_nid)
  2965. spec->multiout.hp_nid = nid;
  2966. else
  2967. spec->multiout.extra_out_nid[0] = nid;
  2968. /* control HP volume/switch on the output mixer amp */
  2969. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2970. sprintf(name, "%s Playback Volume", pfx);
  2971. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2972. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2973. if (err < 0)
  2974. return err;
  2975. sprintf(name, "%s Playback Switch", pfx);
  2976. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2977. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2978. if (err < 0)
  2979. return err;
  2980. } else if (alc880_is_multi_pin(pin)) {
  2981. /* set manual connection */
  2982. /* we have only a switch on HP-out PIN */
  2983. sprintf(name, "%s Playback Switch", pfx);
  2984. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2985. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2986. if (err < 0)
  2987. return err;
  2988. }
  2989. return 0;
  2990. }
  2991. /* create input playback/capture controls for the given pin */
  2992. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2993. const char *ctlname,
  2994. int idx, hda_nid_t mix_nid)
  2995. {
  2996. char name[32];
  2997. int err;
  2998. sprintf(name, "%s Playback Volume", ctlname);
  2999. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  3000. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  3001. if (err < 0)
  3002. return err;
  3003. sprintf(name, "%s Playback Switch", ctlname);
  3004. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  3005. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  3006. if (err < 0)
  3007. return err;
  3008. return 0;
  3009. }
  3010. /* create playback/capture controls for input pins */
  3011. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  3012. const struct auto_pin_cfg *cfg)
  3013. {
  3014. struct hda_input_mux *imux = &spec->private_imux;
  3015. int i, err, idx;
  3016. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3017. if (alc880_is_input_pin(cfg->input_pins[i])) {
  3018. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  3019. err = new_analog_input(spec, cfg->input_pins[i],
  3020. auto_pin_cfg_labels[i],
  3021. idx, 0x0b);
  3022. if (err < 0)
  3023. return err;
  3024. imux->items[imux->num_items].label =
  3025. auto_pin_cfg_labels[i];
  3026. imux->items[imux->num_items].index =
  3027. alc880_input_pin_idx(cfg->input_pins[i]);
  3028. imux->num_items++;
  3029. }
  3030. }
  3031. return 0;
  3032. }
  3033. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  3034. hda_nid_t nid, int pin_type,
  3035. int dac_idx)
  3036. {
  3037. /* set as output */
  3038. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3039. pin_type);
  3040. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3041. AMP_OUT_UNMUTE);
  3042. /* need the manual connection? */
  3043. if (alc880_is_multi_pin(nid)) {
  3044. struct alc_spec *spec = codec->spec;
  3045. int idx = alc880_multi_pin_idx(nid);
  3046. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  3047. AC_VERB_SET_CONNECT_SEL,
  3048. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  3049. }
  3050. }
  3051. static int get_pin_type(int line_out_type)
  3052. {
  3053. if (line_out_type == AUTO_PIN_HP_OUT)
  3054. return PIN_HP;
  3055. else
  3056. return PIN_OUT;
  3057. }
  3058. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  3059. {
  3060. struct alc_spec *spec = codec->spec;
  3061. int i;
  3062. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  3063. for (i = 0; i < spec->autocfg.line_outs; i++) {
  3064. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  3065. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3066. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  3067. }
  3068. }
  3069. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  3070. {
  3071. struct alc_spec *spec = codec->spec;
  3072. hda_nid_t pin;
  3073. pin = spec->autocfg.speaker_pins[0];
  3074. if (pin) /* connect to front */
  3075. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  3076. pin = spec->autocfg.hp_pins[0];
  3077. if (pin) /* connect to front */
  3078. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  3079. }
  3080. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  3081. {
  3082. struct alc_spec *spec = codec->spec;
  3083. int i;
  3084. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3085. hda_nid_t nid = spec->autocfg.input_pins[i];
  3086. if (alc880_is_input_pin(nid)) {
  3087. snd_hda_codec_write(codec, nid, 0,
  3088. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3089. i <= AUTO_PIN_FRONT_MIC ?
  3090. PIN_VREF80 : PIN_IN);
  3091. if (nid != ALC880_PIN_CD_NID)
  3092. snd_hda_codec_write(codec, nid, 0,
  3093. AC_VERB_SET_AMP_GAIN_MUTE,
  3094. AMP_OUT_MUTE);
  3095. }
  3096. }
  3097. }
  3098. /* parse the BIOS configuration and set up the alc_spec */
  3099. /* return 1 if successful, 0 if the proper config is not found,
  3100. * or a negative error code
  3101. */
  3102. static int alc880_parse_auto_config(struct hda_codec *codec)
  3103. {
  3104. struct alc_spec *spec = codec->spec;
  3105. int err;
  3106. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  3107. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  3108. alc880_ignore);
  3109. if (err < 0)
  3110. return err;
  3111. if (!spec->autocfg.line_outs)
  3112. return 0; /* can't find valid BIOS pin config */
  3113. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  3114. if (err < 0)
  3115. return err;
  3116. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  3117. if (err < 0)
  3118. return err;
  3119. err = alc880_auto_create_extra_out(spec,
  3120. spec->autocfg.speaker_pins[0],
  3121. "Speaker");
  3122. if (err < 0)
  3123. return err;
  3124. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  3125. "Headphone");
  3126. if (err < 0)
  3127. return err;
  3128. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  3129. if (err < 0)
  3130. return err;
  3131. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  3132. if (spec->autocfg.dig_out_pin)
  3133. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  3134. if (spec->autocfg.dig_in_pin)
  3135. spec->dig_in_nid = ALC880_DIGIN_NID;
  3136. if (spec->kctl_alloc)
  3137. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  3138. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  3139. spec->num_mux_defs = 1;
  3140. spec->input_mux = &spec->private_imux;
  3141. return 1;
  3142. }
  3143. /* additional initialization for auto-configuration model */
  3144. static void alc880_auto_init(struct hda_codec *codec)
  3145. {
  3146. alc880_auto_init_multi_out(codec);
  3147. alc880_auto_init_extra_out(codec);
  3148. alc880_auto_init_analog_input(codec);
  3149. }
  3150. /*
  3151. * OK, here we have finally the patch for ALC880
  3152. */
  3153. static int patch_alc880(struct hda_codec *codec)
  3154. {
  3155. struct alc_spec *spec;
  3156. int board_config;
  3157. int err;
  3158. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3159. if (spec == NULL)
  3160. return -ENOMEM;
  3161. codec->spec = spec;
  3162. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3163. alc880_models,
  3164. alc880_cfg_tbl);
  3165. if (board_config < 0) {
  3166. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3167. "trying auto-probe from BIOS...\n");
  3168. board_config = ALC880_AUTO;
  3169. }
  3170. if (board_config == ALC880_AUTO) {
  3171. /* automatic parse from the BIOS config */
  3172. err = alc880_parse_auto_config(codec);
  3173. if (err < 0) {
  3174. alc_free(codec);
  3175. return err;
  3176. } else if (!err) {
  3177. printk(KERN_INFO
  3178. "hda_codec: Cannot set up configuration "
  3179. "from BIOS. Using 3-stack mode...\n");
  3180. board_config = ALC880_3ST;
  3181. }
  3182. }
  3183. if (board_config != ALC880_AUTO)
  3184. setup_preset(spec, &alc880_presets[board_config]);
  3185. spec->stream_name_analog = "ALC880 Analog";
  3186. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3187. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3188. spec->stream_name_digital = "ALC880 Digital";
  3189. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3190. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3191. if (!spec->adc_nids && spec->input_mux) {
  3192. /* check whether NID 0x07 is valid */
  3193. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3194. /* get type */
  3195. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3196. if (wcap != AC_WID_AUD_IN) {
  3197. spec->adc_nids = alc880_adc_nids_alt;
  3198. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3199. spec->mixers[spec->num_mixers] =
  3200. alc880_capture_alt_mixer;
  3201. spec->num_mixers++;
  3202. } else {
  3203. spec->adc_nids = alc880_adc_nids;
  3204. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3205. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3206. spec->num_mixers++;
  3207. }
  3208. }
  3209. codec->patch_ops = alc_patch_ops;
  3210. if (board_config == ALC880_AUTO)
  3211. spec->init_hook = alc880_auto_init;
  3212. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3213. if (!spec->loopback.amplist)
  3214. spec->loopback.amplist = alc880_loopbacks;
  3215. #endif
  3216. return 0;
  3217. }
  3218. /*
  3219. * ALC260 support
  3220. */
  3221. static hda_nid_t alc260_dac_nids[1] = {
  3222. /* front */
  3223. 0x02,
  3224. };
  3225. static hda_nid_t alc260_adc_nids[1] = {
  3226. /* ADC0 */
  3227. 0x04,
  3228. };
  3229. static hda_nid_t alc260_adc_nids_alt[1] = {
  3230. /* ADC1 */
  3231. 0x05,
  3232. };
  3233. static hda_nid_t alc260_hp_adc_nids[2] = {
  3234. /* ADC1, 0 */
  3235. 0x05, 0x04
  3236. };
  3237. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3238. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3239. */
  3240. static hda_nid_t alc260_dual_adc_nids[2] = {
  3241. /* ADC0, ADC1 */
  3242. 0x04, 0x05
  3243. };
  3244. #define ALC260_DIGOUT_NID 0x03
  3245. #define ALC260_DIGIN_NID 0x06
  3246. static struct hda_input_mux alc260_capture_source = {
  3247. .num_items = 4,
  3248. .items = {
  3249. { "Mic", 0x0 },
  3250. { "Front Mic", 0x1 },
  3251. { "Line", 0x2 },
  3252. { "CD", 0x4 },
  3253. },
  3254. };
  3255. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3256. * headphone jack and the internal CD lines since these are the only pins at
  3257. * which audio can appear. For flexibility, also allow the option of
  3258. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3259. * connection to the mixer output).
  3260. */
  3261. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3262. {
  3263. .num_items = 3,
  3264. .items = {
  3265. { "Mic/Line", 0x0 },
  3266. { "CD", 0x4 },
  3267. { "Headphone", 0x2 },
  3268. },
  3269. },
  3270. {
  3271. .num_items = 4,
  3272. .items = {
  3273. { "Mic/Line", 0x0 },
  3274. { "CD", 0x4 },
  3275. { "Headphone", 0x2 },
  3276. { "Mixer", 0x5 },
  3277. },
  3278. },
  3279. };
  3280. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3281. * the Fujitsu S702x, but jacks are marked differently.
  3282. */
  3283. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3284. {
  3285. .num_items = 4,
  3286. .items = {
  3287. { "Mic", 0x0 },
  3288. { "Line", 0x2 },
  3289. { "CD", 0x4 },
  3290. { "Headphone", 0x5 },
  3291. },
  3292. },
  3293. {
  3294. .num_items = 5,
  3295. .items = {
  3296. { "Mic", 0x0 },
  3297. { "Line", 0x2 },
  3298. { "CD", 0x4 },
  3299. { "Headphone", 0x6 },
  3300. { "Mixer", 0x5 },
  3301. },
  3302. },
  3303. };
  3304. /*
  3305. * This is just place-holder, so there's something for alc_build_pcms to look
  3306. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3307. * element which allows changing the channel mode, so the verb list is
  3308. * never used.
  3309. */
  3310. static struct hda_channel_mode alc260_modes[1] = {
  3311. { 2, NULL },
  3312. };
  3313. /* Mixer combinations
  3314. *
  3315. * basic: base_output + input + pc_beep + capture
  3316. * HP: base_output + input + capture_alt
  3317. * HP_3013: hp_3013 + input + capture
  3318. * fujitsu: fujitsu + capture
  3319. * acer: acer + capture
  3320. */
  3321. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3322. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3323. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3324. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3325. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3326. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3327. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3328. { } /* end */
  3329. };
  3330. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3331. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3332. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3333. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3334. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3335. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3336. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3337. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3338. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3339. { } /* end */
  3340. };
  3341. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3342. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3343. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3344. { } /* end */
  3345. };
  3346. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3347. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3348. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3349. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3350. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3351. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3352. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3353. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3354. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3355. { } /* end */
  3356. };
  3357. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3358. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3359. */
  3360. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3361. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3362. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3363. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3364. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3365. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3366. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3367. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3368. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3369. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3370. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3371. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3372. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3373. { } /* end */
  3374. };
  3375. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3376. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3377. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3378. * datasheet doesn't mention this restriction. At this stage it's not clear
  3379. * whether this behaviour is intentional or is a hardware bug in chip
  3380. * revisions available in early 2006. Therefore for now allow the
  3381. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3382. * that the lack of mic bias for this NID is intentional we could change the
  3383. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3384. *
  3385. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3386. * don't appear to make the mic bias available from the "line" jack, even
  3387. * though the NID used for this jack (0x14) can supply it. The theory is
  3388. * that perhaps Acer have included blocking capacitors between the ALC260
  3389. * and the output jack. If this turns out to be the case for all such
  3390. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3391. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3392. *
  3393. * The C20x Tablet series have a mono internal speaker which is controlled
  3394. * via the chip's Mono sum widget and pin complex, so include the necessary
  3395. * controls for such models. On models without a "mono speaker" the control
  3396. * won't do anything.
  3397. */
  3398. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3399. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3400. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3401. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3402. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3403. HDA_OUTPUT),
  3404. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3405. HDA_INPUT),
  3406. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3407. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3408. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3409. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3410. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3411. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3412. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3413. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3414. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3415. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3416. { } /* end */
  3417. };
  3418. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3419. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3420. */
  3421. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3422. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3423. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3424. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3425. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3426. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3427. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3428. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3429. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3430. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3431. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3432. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3433. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3434. { } /* end */
  3435. };
  3436. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3437. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3438. */
  3439. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3440. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3441. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3442. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3443. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3444. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3445. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3446. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3447. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3448. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3449. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3450. { } /* end */
  3451. };
  3452. /* capture mixer elements */
  3453. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3454. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3455. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3456. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3457. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3458. {
  3459. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3460. /* The multiple "Capture Source" controls confuse alsamixer
  3461. * So call somewhat different..
  3462. * FIXME: the controls appear in the "playback" view!
  3463. */
  3464. /* .name = "Capture Source", */
  3465. .name = "Input Source",
  3466. .count = 2,
  3467. .info = alc_mux_enum_info,
  3468. .get = alc_mux_enum_get,
  3469. .put = alc_mux_enum_put,
  3470. },
  3471. { } /* end */
  3472. };
  3473. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3474. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3475. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3476. {
  3477. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3478. /* The multiple "Capture Source" controls confuse alsamixer
  3479. * So call somewhat different..
  3480. * FIXME: the controls appear in the "playback" view!
  3481. */
  3482. /* .name = "Capture Source", */
  3483. .name = "Input Source",
  3484. .count = 1,
  3485. .info = alc_mux_enum_info,
  3486. .get = alc_mux_enum_get,
  3487. .put = alc_mux_enum_put,
  3488. },
  3489. { } /* end */
  3490. };
  3491. /*
  3492. * initialization verbs
  3493. */
  3494. static struct hda_verb alc260_init_verbs[] = {
  3495. /* Line In pin widget for input */
  3496. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3497. /* CD pin widget for input */
  3498. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3499. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3500. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3501. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3502. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3503. /* LINE-2 is used for line-out in rear */
  3504. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3505. /* select line-out */
  3506. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3507. /* LINE-OUT pin */
  3508. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3509. /* enable HP */
  3510. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3511. /* enable Mono */
  3512. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3513. /* mute capture amp left and right */
  3514. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3515. /* set connection select to line in (default select for this ADC) */
  3516. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3517. /* mute capture amp left and right */
  3518. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3519. /* set connection select to line in (default select for this ADC) */
  3520. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3521. /* set vol=0 Line-Out mixer amp left and right */
  3522. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3523. /* unmute pin widget amp left and right (no gain on this amp) */
  3524. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3525. /* set vol=0 HP mixer amp left and right */
  3526. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3527. /* unmute pin widget amp left and right (no gain on this amp) */
  3528. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3529. /* set vol=0 Mono mixer amp left and right */
  3530. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3531. /* unmute pin widget amp left and right (no gain on this amp) */
  3532. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3533. /* unmute LINE-2 out pin */
  3534. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3535. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3536. * Line In 2 = 0x03
  3537. */
  3538. /* mute analog inputs */
  3539. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3540. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3541. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3542. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3543. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3544. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3545. /* mute Front out path */
  3546. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3547. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3548. /* mute Headphone out path */
  3549. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3550. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3551. /* mute Mono out path */
  3552. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3553. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3554. { }
  3555. };
  3556. #if 0 /* should be identical with alc260_init_verbs? */
  3557. static struct hda_verb alc260_hp_init_verbs[] = {
  3558. /* Headphone and output */
  3559. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3560. /* mono output */
  3561. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3562. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3563. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3564. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3565. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3566. /* Line In pin widget for input */
  3567. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3568. /* Line-2 pin widget for output */
  3569. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3570. /* CD pin widget for input */
  3571. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3572. /* unmute amp left and right */
  3573. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3574. /* set connection select to line in (default select for this ADC) */
  3575. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3576. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3577. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3578. /* mute pin widget amp left and right (no gain on this amp) */
  3579. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3580. /* unmute HP mixer amp left and right (volume = 0) */
  3581. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3582. /* mute pin widget amp left and right (no gain on this amp) */
  3583. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3584. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3585. * Line In 2 = 0x03
  3586. */
  3587. /* mute analog inputs */
  3588. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3589. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3590. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3591. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3592. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3593. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3594. /* Unmute Front out path */
  3595. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3596. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3597. /* Unmute Headphone out path */
  3598. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3599. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3600. /* Unmute Mono out path */
  3601. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3602. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3603. { }
  3604. };
  3605. #endif
  3606. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3607. /* Line out and output */
  3608. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3609. /* mono output */
  3610. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3611. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3612. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3613. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3614. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3615. /* Line In pin widget for input */
  3616. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3617. /* Headphone pin widget for output */
  3618. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3619. /* CD pin widget for input */
  3620. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3621. /* unmute amp left and right */
  3622. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3623. /* set connection select to line in (default select for this ADC) */
  3624. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3625. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3626. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3627. /* mute pin widget amp left and right (no gain on this amp) */
  3628. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3629. /* unmute HP mixer amp left and right (volume = 0) */
  3630. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3631. /* mute pin widget amp left and right (no gain on this amp) */
  3632. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3633. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3634. * Line In 2 = 0x03
  3635. */
  3636. /* mute analog inputs */
  3637. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3638. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3639. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3640. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3641. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3642. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3643. /* Unmute Front out path */
  3644. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3645. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3646. /* Unmute Headphone out path */
  3647. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3648. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3649. /* Unmute Mono out path */
  3650. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3651. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3652. { }
  3653. };
  3654. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3655. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3656. * audio = 0x16, internal speaker = 0x10.
  3657. */
  3658. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3659. /* Disable all GPIOs */
  3660. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3661. /* Internal speaker is connected to headphone pin */
  3662. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3663. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3664. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3665. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3666. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3667. /* Ensure all other unused pins are disabled and muted. */
  3668. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3669. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3670. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3671. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3672. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3673. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3674. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3675. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3676. /* Disable digital (SPDIF) pins */
  3677. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3678. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3679. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3680. * when acting as an output.
  3681. */
  3682. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3683. /* Start with output sum widgets muted and their output gains at min */
  3684. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3685. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3686. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3687. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3688. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3689. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3690. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3691. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3692. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3693. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3694. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3695. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3696. * If the pin mode is changed by the user the pin mode control will
  3697. * take care of enabling the pin's input/output buffers as needed.
  3698. * Therefore there's no need to enable the input buffer at this
  3699. * stage.
  3700. */
  3701. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3702. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3703. * mixer ctrl)
  3704. */
  3705. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3706. /* Mute capture amp left and right */
  3707. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3708. /* Set ADC connection select to match default mixer setting - line
  3709. * in (on mic1 pin)
  3710. */
  3711. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3712. /* Do the same for the second ADC: mute capture input amp and
  3713. * set ADC connection to line in (on mic1 pin)
  3714. */
  3715. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3716. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3717. /* Mute all inputs to mixer widget (even unconnected ones) */
  3718. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3719. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3720. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3721. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3722. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3723. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3724. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3725. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3726. { }
  3727. };
  3728. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3729. * similar laptops (adapted from Fujitsu init verbs).
  3730. */
  3731. static struct hda_verb alc260_acer_init_verbs[] = {
  3732. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3733. * the headphone jack. Turn this on and rely on the standard mute
  3734. * methods whenever the user wants to turn these outputs off.
  3735. */
  3736. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3737. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3738. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3739. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3740. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3741. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3742. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3743. /* Line In jack is connected to Line1 pin */
  3744. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3745. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3746. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3747. /* Ensure all other unused pins are disabled and muted. */
  3748. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3749. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3750. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3751. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3752. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3753. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3754. /* Disable digital (SPDIF) pins */
  3755. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3756. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3757. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3758. * bus when acting as outputs.
  3759. */
  3760. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3761. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3762. /* Start with output sum widgets muted and their output gains at min */
  3763. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3764. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3765. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3766. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3767. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3768. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3769. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3770. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3771. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3772. /* Unmute Line-out pin widget amp left and right
  3773. * (no equiv mixer ctrl)
  3774. */
  3775. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3776. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3777. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3778. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3779. * inputs. If the pin mode is changed by the user the pin mode control
  3780. * will take care of enabling the pin's input/output buffers as needed.
  3781. * Therefore there's no need to enable the input buffer at this
  3782. * stage.
  3783. */
  3784. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3785. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3786. /* Mute capture amp left and right */
  3787. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3788. /* Set ADC connection select to match default mixer setting - mic
  3789. * (on mic1 pin)
  3790. */
  3791. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3792. /* Do similar with the second ADC: mute capture input amp and
  3793. * set ADC connection to mic to match ALSA's default state.
  3794. */
  3795. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3796. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3797. /* Mute all inputs to mixer widget (even unconnected ones) */
  3798. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3799. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3800. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3801. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3802. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3803. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3804. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3805. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3806. { }
  3807. };
  3808. static struct hda_verb alc260_will_verbs[] = {
  3809. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3810. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3811. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3812. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3813. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3814. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3815. {}
  3816. };
  3817. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3818. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3819. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3820. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3821. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3822. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3823. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3824. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3825. {}
  3826. };
  3827. /* toggle speaker-output according to the hp-jack state */
  3828. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3829. {
  3830. unsigned int present;
  3831. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3832. present = snd_hda_codec_read(codec, 0x0f, 0,
  3833. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3834. if (present) {
  3835. snd_hda_codec_write_cache(codec, 0x01, 0,
  3836. AC_VERB_SET_GPIO_DATA, 1);
  3837. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3838. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3839. PIN_HP);
  3840. } else {
  3841. snd_hda_codec_write_cache(codec, 0x01, 0,
  3842. AC_VERB_SET_GPIO_DATA, 0);
  3843. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3844. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3845. PIN_OUT);
  3846. }
  3847. }
  3848. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3849. unsigned int res)
  3850. {
  3851. if ((res >> 26) == ALC880_HP_EVENT)
  3852. alc260_replacer_672v_automute(codec);
  3853. }
  3854. /* Test configuration for debugging, modelled after the ALC880 test
  3855. * configuration.
  3856. */
  3857. #ifdef CONFIG_SND_DEBUG
  3858. static hda_nid_t alc260_test_dac_nids[1] = {
  3859. 0x02,
  3860. };
  3861. static hda_nid_t alc260_test_adc_nids[2] = {
  3862. 0x04, 0x05,
  3863. };
  3864. /* For testing the ALC260, each input MUX needs its own definition since
  3865. * the signal assignments are different. This assumes that the first ADC
  3866. * is NID 0x04.
  3867. */
  3868. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3869. {
  3870. .num_items = 7,
  3871. .items = {
  3872. { "MIC1 pin", 0x0 },
  3873. { "MIC2 pin", 0x1 },
  3874. { "LINE1 pin", 0x2 },
  3875. { "LINE2 pin", 0x3 },
  3876. { "CD pin", 0x4 },
  3877. { "LINE-OUT pin", 0x5 },
  3878. { "HP-OUT pin", 0x6 },
  3879. },
  3880. },
  3881. {
  3882. .num_items = 8,
  3883. .items = {
  3884. { "MIC1 pin", 0x0 },
  3885. { "MIC2 pin", 0x1 },
  3886. { "LINE1 pin", 0x2 },
  3887. { "LINE2 pin", 0x3 },
  3888. { "CD pin", 0x4 },
  3889. { "Mixer", 0x5 },
  3890. { "LINE-OUT pin", 0x6 },
  3891. { "HP-OUT pin", 0x7 },
  3892. },
  3893. },
  3894. };
  3895. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3896. /* Output driver widgets */
  3897. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3898. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3899. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3900. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3901. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3902. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3903. /* Modes for retasking pin widgets
  3904. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3905. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3906. * mention this restriction. At this stage it's not clear whether
  3907. * this behaviour is intentional or is a hardware bug in chip
  3908. * revisions available at least up until early 2006. Therefore for
  3909. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3910. * choices, but if it turns out that the lack of mic bias for these
  3911. * NIDs is intentional we could change their modes from
  3912. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3913. */
  3914. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3915. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3916. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3917. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3918. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3919. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3920. /* Loopback mixer controls */
  3921. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3922. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3923. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3924. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3925. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3926. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3927. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3928. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3929. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3930. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3931. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3932. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3933. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3934. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3935. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3936. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3937. /* Controls for GPIO pins, assuming they are configured as outputs */
  3938. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3939. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3940. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3941. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3942. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3943. * is ambigious as to which NID is which; testing on laptops which
  3944. * make this output available should provide clarification.
  3945. */
  3946. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3947. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3948. { } /* end */
  3949. };
  3950. static struct hda_verb alc260_test_init_verbs[] = {
  3951. /* Enable all GPIOs as outputs with an initial value of 0 */
  3952. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3953. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3954. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3955. /* Enable retasking pins as output, initially without power amp */
  3956. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3957. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3958. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3959. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3960. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3961. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3962. /* Disable digital (SPDIF) pins initially, but users can enable
  3963. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3964. * payload also sets the generation to 0, output to be in "consumer"
  3965. * PCM format, copyright asserted, no pre-emphasis and no validity
  3966. * control.
  3967. */
  3968. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3969. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3970. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3971. * OUT1 sum bus when acting as an output.
  3972. */
  3973. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3974. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3975. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3976. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3977. /* Start with output sum widgets muted and their output gains at min */
  3978. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3979. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3980. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3981. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3982. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3983. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3984. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3985. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3986. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3987. /* Unmute retasking pin widget output buffers since the default
  3988. * state appears to be output. As the pin mode is changed by the
  3989. * user the pin mode control will take care of enabling the pin's
  3990. * input/output buffers as needed.
  3991. */
  3992. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3993. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3994. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3995. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3996. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3997. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3998. /* Also unmute the mono-out pin widget */
  3999. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4000. /* Mute capture amp left and right */
  4001. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4002. /* Set ADC connection select to match default mixer setting (mic1
  4003. * pin)
  4004. */
  4005. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4006. /* Do the same for the second ADC: mute capture input amp and
  4007. * set ADC connection to mic1 pin
  4008. */
  4009. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4010. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4011. /* Mute all inputs to mixer widget (even unconnected ones) */
  4012. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  4013. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  4014. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  4015. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  4016. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  4017. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  4018. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  4019. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  4020. { }
  4021. };
  4022. #endif
  4023. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  4024. .substreams = 1,
  4025. .channels_min = 2,
  4026. .channels_max = 2,
  4027. };
  4028. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  4029. .substreams = 1,
  4030. .channels_min = 2,
  4031. .channels_max = 2,
  4032. };
  4033. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  4034. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  4035. /*
  4036. * for BIOS auto-configuration
  4037. */
  4038. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  4039. const char *pfx)
  4040. {
  4041. hda_nid_t nid_vol;
  4042. unsigned long vol_val, sw_val;
  4043. char name[32];
  4044. int err;
  4045. if (nid >= 0x0f && nid < 0x11) {
  4046. nid_vol = nid - 0x7;
  4047. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  4048. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  4049. } else if (nid == 0x11) {
  4050. nid_vol = nid - 0x7;
  4051. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  4052. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  4053. } else if (nid >= 0x12 && nid <= 0x15) {
  4054. nid_vol = 0x08;
  4055. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  4056. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  4057. } else
  4058. return 0; /* N/A */
  4059. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  4060. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  4061. if (err < 0)
  4062. return err;
  4063. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  4064. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  4065. if (err < 0)
  4066. return err;
  4067. return 1;
  4068. }
  4069. /* add playback controls from the parsed DAC table */
  4070. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  4071. const struct auto_pin_cfg *cfg)
  4072. {
  4073. hda_nid_t nid;
  4074. int err;
  4075. spec->multiout.num_dacs = 1;
  4076. spec->multiout.dac_nids = spec->private_dac_nids;
  4077. spec->multiout.dac_nids[0] = 0x02;
  4078. nid = cfg->line_out_pins[0];
  4079. if (nid) {
  4080. err = alc260_add_playback_controls(spec, nid, "Front");
  4081. if (err < 0)
  4082. return err;
  4083. }
  4084. nid = cfg->speaker_pins[0];
  4085. if (nid) {
  4086. err = alc260_add_playback_controls(spec, nid, "Speaker");
  4087. if (err < 0)
  4088. return err;
  4089. }
  4090. nid = cfg->hp_pins[0];
  4091. if (nid) {
  4092. err = alc260_add_playback_controls(spec, nid, "Headphone");
  4093. if (err < 0)
  4094. return err;
  4095. }
  4096. return 0;
  4097. }
  4098. /* create playback/capture controls for input pins */
  4099. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  4100. const struct auto_pin_cfg *cfg)
  4101. {
  4102. struct hda_input_mux *imux = &spec->private_imux;
  4103. int i, err, idx;
  4104. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4105. if (cfg->input_pins[i] >= 0x12) {
  4106. idx = cfg->input_pins[i] - 0x12;
  4107. err = new_analog_input(spec, cfg->input_pins[i],
  4108. auto_pin_cfg_labels[i], idx,
  4109. 0x07);
  4110. if (err < 0)
  4111. return err;
  4112. imux->items[imux->num_items].label =
  4113. auto_pin_cfg_labels[i];
  4114. imux->items[imux->num_items].index = idx;
  4115. imux->num_items++;
  4116. }
  4117. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  4118. idx = cfg->input_pins[i] - 0x09;
  4119. err = new_analog_input(spec, cfg->input_pins[i],
  4120. auto_pin_cfg_labels[i], idx,
  4121. 0x07);
  4122. if (err < 0)
  4123. return err;
  4124. imux->items[imux->num_items].label =
  4125. auto_pin_cfg_labels[i];
  4126. imux->items[imux->num_items].index = idx;
  4127. imux->num_items++;
  4128. }
  4129. }
  4130. return 0;
  4131. }
  4132. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  4133. hda_nid_t nid, int pin_type,
  4134. int sel_idx)
  4135. {
  4136. /* set as output */
  4137. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  4138. pin_type);
  4139. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4140. AMP_OUT_UNMUTE);
  4141. /* need the manual connection? */
  4142. if (nid >= 0x12) {
  4143. int idx = nid - 0x12;
  4144. snd_hda_codec_write(codec, idx + 0x0b, 0,
  4145. AC_VERB_SET_CONNECT_SEL, sel_idx);
  4146. }
  4147. }
  4148. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4149. {
  4150. struct alc_spec *spec = codec->spec;
  4151. hda_nid_t nid;
  4152. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4153. nid = spec->autocfg.line_out_pins[0];
  4154. if (nid) {
  4155. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4156. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4157. }
  4158. nid = spec->autocfg.speaker_pins[0];
  4159. if (nid)
  4160. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4161. nid = spec->autocfg.hp_pins[0];
  4162. if (nid)
  4163. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4164. }
  4165. #define ALC260_PIN_CD_NID 0x16
  4166. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4167. {
  4168. struct alc_spec *spec = codec->spec;
  4169. int i;
  4170. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4171. hda_nid_t nid = spec->autocfg.input_pins[i];
  4172. if (nid >= 0x12) {
  4173. snd_hda_codec_write(codec, nid, 0,
  4174. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4175. i <= AUTO_PIN_FRONT_MIC ?
  4176. PIN_VREF80 : PIN_IN);
  4177. if (nid != ALC260_PIN_CD_NID)
  4178. snd_hda_codec_write(codec, nid, 0,
  4179. AC_VERB_SET_AMP_GAIN_MUTE,
  4180. AMP_OUT_MUTE);
  4181. }
  4182. }
  4183. }
  4184. /*
  4185. * generic initialization of ADC, input mixers and output mixers
  4186. */
  4187. static struct hda_verb alc260_volume_init_verbs[] = {
  4188. /*
  4189. * Unmute ADC0-1 and set the default input to mic-in
  4190. */
  4191. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4192. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4193. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4194. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4195. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4196. * mixer widget
  4197. * Note: PASD motherboards uses the Line In 2 as the input for
  4198. * front panel mic (mic 2)
  4199. */
  4200. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4201. /* mute analog inputs */
  4202. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4203. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4204. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4205. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4206. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4207. /*
  4208. * Set up output mixers (0x08 - 0x0a)
  4209. */
  4210. /* set vol=0 to output mixers */
  4211. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4212. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4213. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4214. /* set up input amps for analog loopback */
  4215. /* Amp Indices: DAC = 0, mixer = 1 */
  4216. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4217. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4218. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4219. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4220. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4221. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4222. { }
  4223. };
  4224. static int alc260_parse_auto_config(struct hda_codec *codec)
  4225. {
  4226. struct alc_spec *spec = codec->spec;
  4227. unsigned int wcap;
  4228. int err;
  4229. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4230. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4231. alc260_ignore);
  4232. if (err < 0)
  4233. return err;
  4234. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4235. if (err < 0)
  4236. return err;
  4237. if (!spec->kctl_alloc)
  4238. return 0; /* can't find valid BIOS pin config */
  4239. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4240. if (err < 0)
  4241. return err;
  4242. spec->multiout.max_channels = 2;
  4243. if (spec->autocfg.dig_out_pin)
  4244. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4245. if (spec->kctl_alloc)
  4246. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4247. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4248. spec->num_mux_defs = 1;
  4249. spec->input_mux = &spec->private_imux;
  4250. /* check whether NID 0x04 is valid */
  4251. wcap = get_wcaps(codec, 0x04);
  4252. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4253. if (wcap != AC_WID_AUD_IN) {
  4254. spec->adc_nids = alc260_adc_nids_alt;
  4255. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4256. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4257. } else {
  4258. spec->adc_nids = alc260_adc_nids;
  4259. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4260. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4261. }
  4262. spec->num_mixers++;
  4263. return 1;
  4264. }
  4265. /* additional initialization for auto-configuration model */
  4266. static void alc260_auto_init(struct hda_codec *codec)
  4267. {
  4268. alc260_auto_init_multi_out(codec);
  4269. alc260_auto_init_analog_input(codec);
  4270. }
  4271. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4272. static struct hda_amp_list alc260_loopbacks[] = {
  4273. { 0x07, HDA_INPUT, 0 },
  4274. { 0x07, HDA_INPUT, 1 },
  4275. { 0x07, HDA_INPUT, 2 },
  4276. { 0x07, HDA_INPUT, 3 },
  4277. { 0x07, HDA_INPUT, 4 },
  4278. { } /* end */
  4279. };
  4280. #endif
  4281. /*
  4282. * ALC260 configurations
  4283. */
  4284. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4285. [ALC260_BASIC] = "basic",
  4286. [ALC260_HP] = "hp",
  4287. [ALC260_HP_3013] = "hp-3013",
  4288. [ALC260_FUJITSU_S702X] = "fujitsu",
  4289. [ALC260_ACER] = "acer",
  4290. [ALC260_WILL] = "will",
  4291. [ALC260_REPLACER_672V] = "replacer",
  4292. #ifdef CONFIG_SND_DEBUG
  4293. [ALC260_TEST] = "test",
  4294. #endif
  4295. [ALC260_AUTO] = "auto",
  4296. };
  4297. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4298. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4299. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4300. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4301. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4302. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4303. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4304. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4305. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4306. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4307. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4308. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4309. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4310. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4311. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4312. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4313. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4314. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4315. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4316. {}
  4317. };
  4318. static struct alc_config_preset alc260_presets[] = {
  4319. [ALC260_BASIC] = {
  4320. .mixers = { alc260_base_output_mixer,
  4321. alc260_input_mixer,
  4322. alc260_pc_beep_mixer,
  4323. alc260_capture_mixer },
  4324. .init_verbs = { alc260_init_verbs },
  4325. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4326. .dac_nids = alc260_dac_nids,
  4327. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4328. .adc_nids = alc260_adc_nids,
  4329. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4330. .channel_mode = alc260_modes,
  4331. .input_mux = &alc260_capture_source,
  4332. },
  4333. [ALC260_HP] = {
  4334. .mixers = { alc260_base_output_mixer,
  4335. alc260_input_mixer,
  4336. alc260_capture_alt_mixer },
  4337. .init_verbs = { alc260_init_verbs },
  4338. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4339. .dac_nids = alc260_dac_nids,
  4340. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4341. .adc_nids = alc260_hp_adc_nids,
  4342. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4343. .channel_mode = alc260_modes,
  4344. .input_mux = &alc260_capture_source,
  4345. },
  4346. [ALC260_HP_3013] = {
  4347. .mixers = { alc260_hp_3013_mixer,
  4348. alc260_input_mixer,
  4349. alc260_capture_alt_mixer },
  4350. .init_verbs = { alc260_hp_3013_init_verbs },
  4351. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4352. .dac_nids = alc260_dac_nids,
  4353. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4354. .adc_nids = alc260_hp_adc_nids,
  4355. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4356. .channel_mode = alc260_modes,
  4357. .input_mux = &alc260_capture_source,
  4358. },
  4359. [ALC260_FUJITSU_S702X] = {
  4360. .mixers = { alc260_fujitsu_mixer,
  4361. alc260_capture_mixer },
  4362. .init_verbs = { alc260_fujitsu_init_verbs },
  4363. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4364. .dac_nids = alc260_dac_nids,
  4365. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4366. .adc_nids = alc260_dual_adc_nids,
  4367. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4368. .channel_mode = alc260_modes,
  4369. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4370. .input_mux = alc260_fujitsu_capture_sources,
  4371. },
  4372. [ALC260_ACER] = {
  4373. .mixers = { alc260_acer_mixer,
  4374. alc260_capture_mixer },
  4375. .init_verbs = { alc260_acer_init_verbs },
  4376. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4377. .dac_nids = alc260_dac_nids,
  4378. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4379. .adc_nids = alc260_dual_adc_nids,
  4380. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4381. .channel_mode = alc260_modes,
  4382. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4383. .input_mux = alc260_acer_capture_sources,
  4384. },
  4385. [ALC260_WILL] = {
  4386. .mixers = { alc260_will_mixer,
  4387. alc260_capture_mixer },
  4388. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4389. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4390. .dac_nids = alc260_dac_nids,
  4391. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4392. .adc_nids = alc260_adc_nids,
  4393. .dig_out_nid = ALC260_DIGOUT_NID,
  4394. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4395. .channel_mode = alc260_modes,
  4396. .input_mux = &alc260_capture_source,
  4397. },
  4398. [ALC260_REPLACER_672V] = {
  4399. .mixers = { alc260_replacer_672v_mixer,
  4400. alc260_capture_mixer },
  4401. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4402. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4403. .dac_nids = alc260_dac_nids,
  4404. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4405. .adc_nids = alc260_adc_nids,
  4406. .dig_out_nid = ALC260_DIGOUT_NID,
  4407. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4408. .channel_mode = alc260_modes,
  4409. .input_mux = &alc260_capture_source,
  4410. .unsol_event = alc260_replacer_672v_unsol_event,
  4411. .init_hook = alc260_replacer_672v_automute,
  4412. },
  4413. #ifdef CONFIG_SND_DEBUG
  4414. [ALC260_TEST] = {
  4415. .mixers = { alc260_test_mixer,
  4416. alc260_capture_mixer },
  4417. .init_verbs = { alc260_test_init_verbs },
  4418. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4419. .dac_nids = alc260_test_dac_nids,
  4420. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4421. .adc_nids = alc260_test_adc_nids,
  4422. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4423. .channel_mode = alc260_modes,
  4424. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4425. .input_mux = alc260_test_capture_sources,
  4426. },
  4427. #endif
  4428. };
  4429. static int patch_alc260(struct hda_codec *codec)
  4430. {
  4431. struct alc_spec *spec;
  4432. int err, board_config;
  4433. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4434. if (spec == NULL)
  4435. return -ENOMEM;
  4436. codec->spec = spec;
  4437. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4438. alc260_models,
  4439. alc260_cfg_tbl);
  4440. if (board_config < 0) {
  4441. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4442. "trying auto-probe from BIOS...\n");
  4443. board_config = ALC260_AUTO;
  4444. }
  4445. if (board_config == ALC260_AUTO) {
  4446. /* automatic parse from the BIOS config */
  4447. err = alc260_parse_auto_config(codec);
  4448. if (err < 0) {
  4449. alc_free(codec);
  4450. return err;
  4451. } else if (!err) {
  4452. printk(KERN_INFO
  4453. "hda_codec: Cannot set up configuration "
  4454. "from BIOS. Using base mode...\n");
  4455. board_config = ALC260_BASIC;
  4456. }
  4457. }
  4458. if (board_config != ALC260_AUTO)
  4459. setup_preset(spec, &alc260_presets[board_config]);
  4460. spec->stream_name_analog = "ALC260 Analog";
  4461. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4462. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4463. spec->stream_name_digital = "ALC260 Digital";
  4464. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4465. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4466. codec->patch_ops = alc_patch_ops;
  4467. if (board_config == ALC260_AUTO)
  4468. spec->init_hook = alc260_auto_init;
  4469. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4470. if (!spec->loopback.amplist)
  4471. spec->loopback.amplist = alc260_loopbacks;
  4472. #endif
  4473. return 0;
  4474. }
  4475. /*
  4476. * ALC882 support
  4477. *
  4478. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4479. * configuration. Each pin widget can choose any input DACs and a mixer.
  4480. * Each ADC is connected from a mixer of all inputs. This makes possible
  4481. * 6-channel independent captures.
  4482. *
  4483. * In addition, an independent DAC for the multi-playback (not used in this
  4484. * driver yet).
  4485. */
  4486. #define ALC882_DIGOUT_NID 0x06
  4487. #define ALC882_DIGIN_NID 0x0a
  4488. static struct hda_channel_mode alc882_ch_modes[1] = {
  4489. { 8, NULL }
  4490. };
  4491. static hda_nid_t alc882_dac_nids[4] = {
  4492. /* front, rear, clfe, rear_surr */
  4493. 0x02, 0x03, 0x04, 0x05
  4494. };
  4495. /* identical with ALC880 */
  4496. #define alc882_adc_nids alc880_adc_nids
  4497. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4498. /* input MUX */
  4499. /* FIXME: should be a matrix-type input source selection */
  4500. static struct hda_input_mux alc882_capture_source = {
  4501. .num_items = 4,
  4502. .items = {
  4503. { "Mic", 0x0 },
  4504. { "Front Mic", 0x1 },
  4505. { "Line", 0x2 },
  4506. { "CD", 0x4 },
  4507. },
  4508. };
  4509. #define alc882_mux_enum_info alc_mux_enum_info
  4510. #define alc882_mux_enum_get alc_mux_enum_get
  4511. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4512. struct snd_ctl_elem_value *ucontrol)
  4513. {
  4514. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4515. struct alc_spec *spec = codec->spec;
  4516. const struct hda_input_mux *imux = spec->input_mux;
  4517. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4518. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4519. hda_nid_t nid = capture_mixers[adc_idx];
  4520. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4521. unsigned int i, idx;
  4522. idx = ucontrol->value.enumerated.item[0];
  4523. if (idx >= imux->num_items)
  4524. idx = imux->num_items - 1;
  4525. if (*cur_val == idx)
  4526. return 0;
  4527. for (i = 0; i < imux->num_items; i++) {
  4528. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4529. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4530. imux->items[i].index,
  4531. HDA_AMP_MUTE, v);
  4532. }
  4533. *cur_val = idx;
  4534. return 1;
  4535. }
  4536. /*
  4537. * 2ch mode
  4538. */
  4539. static struct hda_verb alc882_3ST_ch2_init[] = {
  4540. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4541. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4542. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4543. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4544. { } /* end */
  4545. };
  4546. /*
  4547. * 6ch mode
  4548. */
  4549. static struct hda_verb alc882_3ST_ch6_init[] = {
  4550. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4551. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4552. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4553. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4554. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4555. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4556. { } /* end */
  4557. };
  4558. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4559. { 2, alc882_3ST_ch2_init },
  4560. { 6, alc882_3ST_ch6_init },
  4561. };
  4562. /*
  4563. * 6ch mode
  4564. */
  4565. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4566. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4567. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4568. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4569. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4570. { } /* end */
  4571. };
  4572. /*
  4573. * 8ch mode
  4574. */
  4575. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4576. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4577. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4578. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4579. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4580. { } /* end */
  4581. };
  4582. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4583. { 6, alc882_sixstack_ch6_init },
  4584. { 8, alc882_sixstack_ch8_init },
  4585. };
  4586. /*
  4587. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4588. */
  4589. /*
  4590. * 2ch mode
  4591. */
  4592. static struct hda_verb alc885_mbp_ch2_init[] = {
  4593. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4594. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4595. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4596. { } /* end */
  4597. };
  4598. /*
  4599. * 6ch mode
  4600. */
  4601. static struct hda_verb alc885_mbp_ch6_init[] = {
  4602. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4603. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4604. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4605. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4606. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4607. { } /* end */
  4608. };
  4609. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4610. { 2, alc885_mbp_ch2_init },
  4611. { 6, alc885_mbp_ch6_init },
  4612. };
  4613. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4614. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4615. */
  4616. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4617. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4618. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4619. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4620. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4621. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4622. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4623. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4624. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4625. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4626. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4627. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4628. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4629. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4630. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4631. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4632. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4633. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4634. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4635. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4636. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4637. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4638. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4639. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4640. { } /* end */
  4641. };
  4642. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4643. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4644. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4645. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4646. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4647. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4648. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4649. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4650. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4651. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4652. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4653. { } /* end */
  4654. };
  4655. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4656. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4657. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4658. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4659. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4660. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4661. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4662. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4663. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4664. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4665. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4666. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4667. { } /* end */
  4668. };
  4669. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4670. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4671. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4672. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4673. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4674. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4675. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4676. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4677. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4678. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4679. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4680. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4681. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4682. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4683. { } /* end */
  4684. };
  4685. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4686. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4687. */
  4688. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4689. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4690. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4691. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4692. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4693. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4694. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4695. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4696. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4697. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4698. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4699. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4700. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4701. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4702. { } /* end */
  4703. };
  4704. static struct snd_kcontrol_new alc882_asus_a7m_mixer[] = {
  4705. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4706. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4707. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4708. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4709. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4710. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4711. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4712. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4713. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4714. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4715. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4716. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4717. { } /* end */
  4718. };
  4719. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4720. {
  4721. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4722. .name = "Channel Mode",
  4723. .info = alc_ch_mode_info,
  4724. .get = alc_ch_mode_get,
  4725. .put = alc_ch_mode_put,
  4726. },
  4727. { } /* end */
  4728. };
  4729. static struct hda_verb alc882_init_verbs[] = {
  4730. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4731. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4732. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4733. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4734. /* Rear mixer */
  4735. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4736. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4737. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4738. /* CLFE mixer */
  4739. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4740. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4741. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4742. /* Side mixer */
  4743. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4744. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4745. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4746. /* Front Pin: output 0 (0x0c) */
  4747. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4748. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4749. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4750. /* Rear Pin: output 1 (0x0d) */
  4751. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4752. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4753. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4754. /* CLFE Pin: output 2 (0x0e) */
  4755. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4756. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4757. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4758. /* Side Pin: output 3 (0x0f) */
  4759. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4760. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4761. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4762. /* Mic (rear) pin: input vref at 80% */
  4763. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4764. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4765. /* Front Mic pin: input vref at 80% */
  4766. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4767. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4768. /* Line In pin: input */
  4769. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4770. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4771. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4772. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4773. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4774. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4775. /* CD pin widget for input */
  4776. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4777. /* FIXME: use matrix-type input source selection */
  4778. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4779. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4780. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4781. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4782. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4783. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4784. /* Input mixer2 */
  4785. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4786. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4787. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4788. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4789. /* Input mixer3 */
  4790. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4791. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4792. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4793. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4794. /* ADC1: mute amp left and right */
  4795. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4796. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4797. /* ADC2: mute amp left and right */
  4798. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4799. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4800. /* ADC3: mute amp left and right */
  4801. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4802. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4803. { }
  4804. };
  4805. static struct hda_verb alc882_eapd_verbs[] = {
  4806. /* change to EAPD mode */
  4807. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4808. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4809. { }
  4810. };
  4811. /* Mac Pro test */
  4812. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4813. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4814. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4815. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4816. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4817. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4818. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4819. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4820. { } /* end */
  4821. };
  4822. static struct hda_verb alc882_macpro_init_verbs[] = {
  4823. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4824. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4825. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4826. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4827. /* Front Pin: output 0 (0x0c) */
  4828. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4829. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4830. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4831. /* Front Mic pin: input vref at 80% */
  4832. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4833. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4834. /* Speaker: output */
  4835. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4836. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4837. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4838. /* Headphone output (output 0 - 0x0c) */
  4839. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4840. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4841. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4842. /* FIXME: use matrix-type input source selection */
  4843. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4844. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4845. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4846. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4847. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4848. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4849. /* Input mixer2 */
  4850. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4851. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4852. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4853. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4854. /* Input mixer3 */
  4855. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4856. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4857. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4858. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4859. /* ADC1: mute amp left and right */
  4860. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4861. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4862. /* ADC2: mute amp left and right */
  4863. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4864. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4865. /* ADC3: mute amp left and right */
  4866. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4867. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4868. { }
  4869. };
  4870. /* Macbook Pro rev3 */
  4871. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4872. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4873. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4874. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4875. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4876. /* Rear mixer */
  4877. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4878. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4879. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4880. /* Front Pin: output 0 (0x0c) */
  4881. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4882. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4883. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4884. /* HP Pin: output 0 (0x0d) */
  4885. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4886. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4887. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4888. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4889. /* Mic (rear) pin: input vref at 80% */
  4890. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4891. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4892. /* Front Mic pin: input vref at 80% */
  4893. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4894. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4895. /* Line In pin: use output 1 when in LineOut mode */
  4896. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4897. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4898. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4899. /* FIXME: use matrix-type input source selection */
  4900. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4901. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4902. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4903. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4904. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4905. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4906. /* Input mixer2 */
  4907. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4908. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4909. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4910. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4911. /* Input mixer3 */
  4912. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4913. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4914. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4915. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4916. /* ADC1: mute amp left and right */
  4917. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4918. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4919. /* ADC2: mute amp left and right */
  4920. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4921. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4922. /* ADC3: mute amp left and right */
  4923. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4924. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4925. { }
  4926. };
  4927. /* iMac 24 mixer. */
  4928. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4929. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4930. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4931. { } /* end */
  4932. };
  4933. /* iMac 24 init verbs. */
  4934. static struct hda_verb alc885_imac24_init_verbs[] = {
  4935. /* Internal speakers: output 0 (0x0c) */
  4936. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4937. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4938. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4939. /* Internal speakers: output 0 (0x0c) */
  4940. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4941. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4942. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4943. /* Headphone: output 0 (0x0c) */
  4944. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4945. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4946. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4947. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4948. /* Front Mic: input vref at 80% */
  4949. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4950. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4951. { }
  4952. };
  4953. /* Toggle speaker-output according to the hp-jack state */
  4954. static void alc885_imac24_automute(struct hda_codec *codec)
  4955. {
  4956. unsigned int present;
  4957. present = snd_hda_codec_read(codec, 0x14, 0,
  4958. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4959. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4960. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4961. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4962. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4963. }
  4964. /* Processes unsolicited events. */
  4965. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4966. unsigned int res)
  4967. {
  4968. /* Headphone insertion or removal. */
  4969. if ((res >> 26) == ALC880_HP_EVENT)
  4970. alc885_imac24_automute(codec);
  4971. }
  4972. static void alc885_mbp3_automute(struct hda_codec *codec)
  4973. {
  4974. unsigned int present;
  4975. present = snd_hda_codec_read(codec, 0x15, 0,
  4976. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4977. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  4978. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4979. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  4980. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  4981. }
  4982. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  4983. unsigned int res)
  4984. {
  4985. /* Headphone insertion or removal. */
  4986. if ((res >> 26) == ALC880_HP_EVENT)
  4987. alc885_mbp3_automute(codec);
  4988. }
  4989. static struct hda_verb alc882_targa_verbs[] = {
  4990. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4991. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4992. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4993. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4994. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4995. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4996. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4997. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4998. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4999. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5000. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5001. { } /* end */
  5002. };
  5003. /* toggle speaker-output according to the hp-jack state */
  5004. static void alc882_targa_automute(struct hda_codec *codec)
  5005. {
  5006. unsigned int present;
  5007. present = snd_hda_codec_read(codec, 0x14, 0,
  5008. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5009. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  5010. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  5011. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5012. present ? 1 : 3);
  5013. }
  5014. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  5015. {
  5016. /* Looks like the unsol event is incompatible with the standard
  5017. * definition. 4bit tag is placed at 26 bit!
  5018. */
  5019. if (((res >> 26) == ALC880_HP_EVENT)) {
  5020. alc882_targa_automute(codec);
  5021. }
  5022. }
  5023. static struct hda_verb alc882_asus_a7j_verbs[] = {
  5024. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5025. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5026. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5027. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5028. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5029. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5030. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5031. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5032. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5033. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5034. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5035. { } /* end */
  5036. };
  5037. static struct hda_verb alc882_asus_a7m_verbs[] = {
  5038. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5039. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5040. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5041. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5042. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5043. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5044. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5045. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  5046. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5047. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5048. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5049. { } /* end */
  5050. };
  5051. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  5052. {
  5053. unsigned int gpiostate, gpiomask, gpiodir;
  5054. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  5055. AC_VERB_GET_GPIO_DATA, 0);
  5056. if (!muted)
  5057. gpiostate |= (1 << pin);
  5058. else
  5059. gpiostate &= ~(1 << pin);
  5060. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  5061. AC_VERB_GET_GPIO_MASK, 0);
  5062. gpiomask |= (1 << pin);
  5063. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  5064. AC_VERB_GET_GPIO_DIRECTION, 0);
  5065. gpiodir |= (1 << pin);
  5066. snd_hda_codec_write(codec, codec->afg, 0,
  5067. AC_VERB_SET_GPIO_MASK, gpiomask);
  5068. snd_hda_codec_write(codec, codec->afg, 0,
  5069. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  5070. msleep(1);
  5071. snd_hda_codec_write(codec, codec->afg, 0,
  5072. AC_VERB_SET_GPIO_DATA, gpiostate);
  5073. }
  5074. /* set up GPIO at initialization */
  5075. static void alc885_macpro_init_hook(struct hda_codec *codec)
  5076. {
  5077. alc882_gpio_mute(codec, 0, 0);
  5078. alc882_gpio_mute(codec, 1, 0);
  5079. }
  5080. /* set up GPIO and update auto-muting at initialization */
  5081. static void alc885_imac24_init_hook(struct hda_codec *codec)
  5082. {
  5083. alc885_macpro_init_hook(codec);
  5084. alc885_imac24_automute(codec);
  5085. }
  5086. /*
  5087. * generic initialization of ADC, input mixers and output mixers
  5088. */
  5089. static struct hda_verb alc882_auto_init_verbs[] = {
  5090. /*
  5091. * Unmute ADC0-2 and set the default input to mic-in
  5092. */
  5093. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  5094. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5095. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5096. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5097. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5098. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5099. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5100. * mixer widget
  5101. * Note: PASD motherboards uses the Line In 2 as the input for
  5102. * front panel mic (mic 2)
  5103. */
  5104. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5105. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5106. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5107. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5108. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5109. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5110. /*
  5111. * Set up output mixers (0x0c - 0x0f)
  5112. */
  5113. /* set vol=0 to output mixers */
  5114. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5115. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5116. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5117. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5118. /* set up input amps for analog loopback */
  5119. /* Amp Indices: DAC = 0, mixer = 1 */
  5120. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5121. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5122. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5123. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5124. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5125. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5126. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5127. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5128. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5129. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5130. /* FIXME: use matrix-type input source selection */
  5131. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5132. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  5133. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5134. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5135. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5136. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5137. /* Input mixer2 */
  5138. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5139. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5140. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5141. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5142. /* Input mixer3 */
  5143. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  5144. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  5145. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  5146. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  5147. { }
  5148. };
  5149. /* capture mixer elements */
  5150. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  5151. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5152. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5153. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5154. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5155. {
  5156. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5157. /* The multiple "Capture Source" controls confuse alsamixer
  5158. * So call somewhat different..
  5159. * FIXME: the controls appear in the "playback" view!
  5160. */
  5161. /* .name = "Capture Source", */
  5162. .name = "Input Source",
  5163. .count = 2,
  5164. .info = alc882_mux_enum_info,
  5165. .get = alc882_mux_enum_get,
  5166. .put = alc882_mux_enum_put,
  5167. },
  5168. { } /* end */
  5169. };
  5170. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  5171. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  5172. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  5173. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  5174. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  5175. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  5176. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  5177. {
  5178. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5179. /* The multiple "Capture Source" controls confuse alsamixer
  5180. * So call somewhat different..
  5181. * FIXME: the controls appear in the "playback" view!
  5182. */
  5183. /* .name = "Capture Source", */
  5184. .name = "Input Source",
  5185. .count = 3,
  5186. .info = alc882_mux_enum_info,
  5187. .get = alc882_mux_enum_get,
  5188. .put = alc882_mux_enum_put,
  5189. },
  5190. { } /* end */
  5191. };
  5192. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5193. #define alc882_loopbacks alc880_loopbacks
  5194. #endif
  5195. /* pcm configuration: identiacal with ALC880 */
  5196. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5197. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5198. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5199. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5200. /*
  5201. * configuration and preset
  5202. */
  5203. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5204. [ALC882_3ST_DIG] = "3stack-dig",
  5205. [ALC882_6ST_DIG] = "6stack-dig",
  5206. [ALC882_ARIMA] = "arima",
  5207. [ALC882_W2JC] = "w2jc",
  5208. [ALC882_TARGA] = "targa",
  5209. [ALC882_ASUS_A7J] = "asus-a7j",
  5210. [ALC882_ASUS_A7M] = "asus-a7m",
  5211. [ALC885_MACPRO] = "macpro",
  5212. [ALC885_MBP3] = "mbp3",
  5213. [ALC885_IMAC24] = "imac24",
  5214. [ALC882_AUTO] = "auto",
  5215. };
  5216. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5217. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5218. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5219. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5220. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5221. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5222. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5223. SND_PCI_QUIRK(0x1043, 0x1243, "Asus A7J", ALC882_ASUS_A7J),
  5224. SND_PCI_QUIRK(0x1043, 0x13c2, "Asus A7M", ALC882_ASUS_A7M),
  5225. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5226. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5227. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5228. {}
  5229. };
  5230. static struct alc_config_preset alc882_presets[] = {
  5231. [ALC882_3ST_DIG] = {
  5232. .mixers = { alc882_base_mixer },
  5233. .init_verbs = { alc882_init_verbs },
  5234. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5235. .dac_nids = alc882_dac_nids,
  5236. .dig_out_nid = ALC882_DIGOUT_NID,
  5237. .dig_in_nid = ALC882_DIGIN_NID,
  5238. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5239. .channel_mode = alc882_ch_modes,
  5240. .need_dac_fix = 1,
  5241. .input_mux = &alc882_capture_source,
  5242. },
  5243. [ALC882_6ST_DIG] = {
  5244. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5245. .init_verbs = { alc882_init_verbs },
  5246. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5247. .dac_nids = alc882_dac_nids,
  5248. .dig_out_nid = ALC882_DIGOUT_NID,
  5249. .dig_in_nid = ALC882_DIGIN_NID,
  5250. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5251. .channel_mode = alc882_sixstack_modes,
  5252. .input_mux = &alc882_capture_source,
  5253. },
  5254. [ALC882_ARIMA] = {
  5255. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5256. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5257. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5258. .dac_nids = alc882_dac_nids,
  5259. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5260. .channel_mode = alc882_sixstack_modes,
  5261. .input_mux = &alc882_capture_source,
  5262. },
  5263. [ALC882_W2JC] = {
  5264. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5265. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5266. alc880_gpio1_init_verbs },
  5267. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5268. .dac_nids = alc882_dac_nids,
  5269. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5270. .channel_mode = alc880_threestack_modes,
  5271. .need_dac_fix = 1,
  5272. .input_mux = &alc882_capture_source,
  5273. .dig_out_nid = ALC882_DIGOUT_NID,
  5274. },
  5275. [ALC885_MBP3] = {
  5276. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5277. .init_verbs = { alc885_mbp3_init_verbs,
  5278. alc880_gpio1_init_verbs },
  5279. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5280. .dac_nids = alc882_dac_nids,
  5281. .channel_mode = alc885_mbp_6ch_modes,
  5282. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5283. .input_mux = &alc882_capture_source,
  5284. .dig_out_nid = ALC882_DIGOUT_NID,
  5285. .dig_in_nid = ALC882_DIGIN_NID,
  5286. .unsol_event = alc885_mbp3_unsol_event,
  5287. .init_hook = alc885_mbp3_automute,
  5288. },
  5289. [ALC885_MACPRO] = {
  5290. .mixers = { alc882_macpro_mixer },
  5291. .init_verbs = { alc882_macpro_init_verbs },
  5292. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5293. .dac_nids = alc882_dac_nids,
  5294. .dig_out_nid = ALC882_DIGOUT_NID,
  5295. .dig_in_nid = ALC882_DIGIN_NID,
  5296. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5297. .channel_mode = alc882_ch_modes,
  5298. .input_mux = &alc882_capture_source,
  5299. .init_hook = alc885_macpro_init_hook,
  5300. },
  5301. [ALC885_IMAC24] = {
  5302. .mixers = { alc885_imac24_mixer },
  5303. .init_verbs = { alc885_imac24_init_verbs },
  5304. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5305. .dac_nids = alc882_dac_nids,
  5306. .dig_out_nid = ALC882_DIGOUT_NID,
  5307. .dig_in_nid = ALC882_DIGIN_NID,
  5308. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5309. .channel_mode = alc882_ch_modes,
  5310. .input_mux = &alc882_capture_source,
  5311. .unsol_event = alc885_imac24_unsol_event,
  5312. .init_hook = alc885_imac24_init_hook,
  5313. },
  5314. [ALC882_TARGA] = {
  5315. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5316. alc882_capture_mixer },
  5317. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5318. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5319. .dac_nids = alc882_dac_nids,
  5320. .dig_out_nid = ALC882_DIGOUT_NID,
  5321. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5322. .adc_nids = alc882_adc_nids,
  5323. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5324. .channel_mode = alc882_3ST_6ch_modes,
  5325. .need_dac_fix = 1,
  5326. .input_mux = &alc882_capture_source,
  5327. .unsol_event = alc882_targa_unsol_event,
  5328. .init_hook = alc882_targa_automute,
  5329. },
  5330. [ALC882_ASUS_A7J] = {
  5331. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5332. alc882_capture_mixer },
  5333. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5334. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5335. .dac_nids = alc882_dac_nids,
  5336. .dig_out_nid = ALC882_DIGOUT_NID,
  5337. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5338. .adc_nids = alc882_adc_nids,
  5339. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5340. .channel_mode = alc882_3ST_6ch_modes,
  5341. .need_dac_fix = 1,
  5342. .input_mux = &alc882_capture_source,
  5343. },
  5344. [ALC882_ASUS_A7M] = {
  5345. .mixers = { alc882_asus_a7m_mixer, alc882_chmode_mixer },
  5346. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5347. alc880_gpio1_init_verbs,
  5348. alc882_asus_a7m_verbs },
  5349. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5350. .dac_nids = alc882_dac_nids,
  5351. .dig_out_nid = ALC882_DIGOUT_NID,
  5352. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5353. .channel_mode = alc880_threestack_modes,
  5354. .need_dac_fix = 1,
  5355. .input_mux = &alc882_capture_source,
  5356. },
  5357. };
  5358. /*
  5359. * Pin config fixes
  5360. */
  5361. enum {
  5362. PINFIX_ABIT_AW9D_MAX
  5363. };
  5364. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5365. { 0x15, 0x01080104 }, /* side */
  5366. { 0x16, 0x01011012 }, /* rear */
  5367. { 0x17, 0x01016011 }, /* clfe */
  5368. { }
  5369. };
  5370. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5371. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5372. };
  5373. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5374. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5375. {}
  5376. };
  5377. /*
  5378. * BIOS auto configuration
  5379. */
  5380. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5381. hda_nid_t nid, int pin_type,
  5382. int dac_idx)
  5383. {
  5384. /* set as output */
  5385. struct alc_spec *spec = codec->spec;
  5386. int idx;
  5387. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5388. idx = 4;
  5389. else
  5390. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5391. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5392. pin_type);
  5393. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5394. AMP_OUT_UNMUTE);
  5395. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5396. }
  5397. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5398. {
  5399. struct alc_spec *spec = codec->spec;
  5400. int i;
  5401. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5402. for (i = 0; i <= HDA_SIDE; i++) {
  5403. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5404. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5405. if (nid)
  5406. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5407. i);
  5408. }
  5409. }
  5410. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5411. {
  5412. struct alc_spec *spec = codec->spec;
  5413. hda_nid_t pin;
  5414. pin = spec->autocfg.hp_pins[0];
  5415. if (pin) /* connect to front */
  5416. /* use dac 0 */
  5417. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5418. }
  5419. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5420. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5421. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5422. {
  5423. struct alc_spec *spec = codec->spec;
  5424. int i;
  5425. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5426. hda_nid_t nid = spec->autocfg.input_pins[i];
  5427. if (alc882_is_input_pin(nid)) {
  5428. snd_hda_codec_write(codec, nid, 0,
  5429. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5430. i <= AUTO_PIN_FRONT_MIC ?
  5431. PIN_VREF80 : PIN_IN);
  5432. if (nid != ALC882_PIN_CD_NID)
  5433. snd_hda_codec_write(codec, nid, 0,
  5434. AC_VERB_SET_AMP_GAIN_MUTE,
  5435. AMP_OUT_MUTE);
  5436. }
  5437. }
  5438. }
  5439. /* add mic boosts if needed */
  5440. static int alc_auto_add_mic_boost(struct hda_codec *codec)
  5441. {
  5442. struct alc_spec *spec = codec->spec;
  5443. int err;
  5444. hda_nid_t nid;
  5445. nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
  5446. if (nid) {
  5447. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5448. "Mic Boost",
  5449. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5450. if (err < 0)
  5451. return err;
  5452. }
  5453. nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
  5454. if (nid) {
  5455. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5456. "Front Mic Boost",
  5457. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5458. if (err < 0)
  5459. return err;
  5460. }
  5461. return 0;
  5462. }
  5463. /* almost identical with ALC880 parser... */
  5464. static int alc882_parse_auto_config(struct hda_codec *codec)
  5465. {
  5466. struct alc_spec *spec = codec->spec;
  5467. int err = alc880_parse_auto_config(codec);
  5468. if (err < 0)
  5469. return err;
  5470. else if (!err)
  5471. return 0; /* no config found */
  5472. err = alc_auto_add_mic_boost(codec);
  5473. if (err < 0)
  5474. return err;
  5475. /* hack - override the init verbs */
  5476. spec->init_verbs[0] = alc882_auto_init_verbs;
  5477. return 1; /* config found */
  5478. }
  5479. /* additional initialization for auto-configuration model */
  5480. static void alc882_auto_init(struct hda_codec *codec)
  5481. {
  5482. alc882_auto_init_multi_out(codec);
  5483. alc882_auto_init_hp_out(codec);
  5484. alc882_auto_init_analog_input(codec);
  5485. }
  5486. static int patch_alc882(struct hda_codec *codec)
  5487. {
  5488. struct alc_spec *spec;
  5489. int err, board_config;
  5490. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5491. if (spec == NULL)
  5492. return -ENOMEM;
  5493. codec->spec = spec;
  5494. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5495. alc882_models,
  5496. alc882_cfg_tbl);
  5497. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5498. /* Pick up systems that don't supply PCI SSID */
  5499. switch (codec->subsystem_id) {
  5500. case 0x106b0c00: /* Mac Pro */
  5501. board_config = ALC885_MACPRO;
  5502. break;
  5503. case 0x106b1000: /* iMac 24 */
  5504. board_config = ALC885_IMAC24;
  5505. break;
  5506. case 0x106b2c00: /* Macbook Pro rev3 */
  5507. board_config = ALC885_MBP3;
  5508. break;
  5509. default:
  5510. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5511. "trying auto-probe from BIOS...\n");
  5512. board_config = ALC882_AUTO;
  5513. }
  5514. }
  5515. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5516. if (board_config == ALC882_AUTO) {
  5517. /* automatic parse from the BIOS config */
  5518. err = alc882_parse_auto_config(codec);
  5519. if (err < 0) {
  5520. alc_free(codec);
  5521. return err;
  5522. } else if (!err) {
  5523. printk(KERN_INFO
  5524. "hda_codec: Cannot set up configuration "
  5525. "from BIOS. Using base mode...\n");
  5526. board_config = ALC882_3ST_DIG;
  5527. }
  5528. }
  5529. if (board_config != ALC882_AUTO)
  5530. setup_preset(spec, &alc882_presets[board_config]);
  5531. spec->stream_name_analog = "ALC882 Analog";
  5532. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5533. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5534. spec->stream_name_digital = "ALC882 Digital";
  5535. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5536. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5537. if (!spec->adc_nids && spec->input_mux) {
  5538. /* check whether NID 0x07 is valid */
  5539. unsigned int wcap = get_wcaps(codec, 0x07);
  5540. /* get type */
  5541. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5542. if (wcap != AC_WID_AUD_IN) {
  5543. spec->adc_nids = alc882_adc_nids_alt;
  5544. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5545. spec->mixers[spec->num_mixers] =
  5546. alc882_capture_alt_mixer;
  5547. spec->num_mixers++;
  5548. } else {
  5549. spec->adc_nids = alc882_adc_nids;
  5550. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5551. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5552. spec->num_mixers++;
  5553. }
  5554. }
  5555. codec->patch_ops = alc_patch_ops;
  5556. if (board_config == ALC882_AUTO)
  5557. spec->init_hook = alc882_auto_init;
  5558. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5559. if (!spec->loopback.amplist)
  5560. spec->loopback.amplist = alc882_loopbacks;
  5561. #endif
  5562. return 0;
  5563. }
  5564. /*
  5565. * ALC883 support
  5566. *
  5567. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5568. * configuration. Each pin widget can choose any input DACs and a mixer.
  5569. * Each ADC is connected from a mixer of all inputs. This makes possible
  5570. * 6-channel independent captures.
  5571. *
  5572. * In addition, an independent DAC for the multi-playback (not used in this
  5573. * driver yet).
  5574. */
  5575. #define ALC883_DIGOUT_NID 0x06
  5576. #define ALC883_DIGIN_NID 0x0a
  5577. static hda_nid_t alc883_dac_nids[4] = {
  5578. /* front, rear, clfe, rear_surr */
  5579. 0x02, 0x04, 0x03, 0x05
  5580. };
  5581. static hda_nid_t alc883_adc_nids[2] = {
  5582. /* ADC1-2 */
  5583. 0x08, 0x09,
  5584. };
  5585. /* input MUX */
  5586. /* FIXME: should be a matrix-type input source selection */
  5587. static struct hda_input_mux alc883_capture_source = {
  5588. .num_items = 4,
  5589. .items = {
  5590. { "Mic", 0x0 },
  5591. { "Front Mic", 0x1 },
  5592. { "Line", 0x2 },
  5593. { "CD", 0x4 },
  5594. },
  5595. };
  5596. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5597. .num_items = 2,
  5598. .items = {
  5599. { "Mic", 0x1 },
  5600. { "Line", 0x2 },
  5601. },
  5602. };
  5603. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5604. .num_items = 4,
  5605. .items = {
  5606. { "Mic", 0x0 },
  5607. { "iMic", 0x1 },
  5608. { "Line", 0x2 },
  5609. { "CD", 0x4 },
  5610. },
  5611. };
  5612. #define alc883_mux_enum_info alc_mux_enum_info
  5613. #define alc883_mux_enum_get alc_mux_enum_get
  5614. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5615. struct snd_ctl_elem_value *ucontrol)
  5616. {
  5617. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5618. struct alc_spec *spec = codec->spec;
  5619. const struct hda_input_mux *imux = spec->input_mux;
  5620. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5621. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5622. hda_nid_t nid = capture_mixers[adc_idx];
  5623. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5624. unsigned int i, idx;
  5625. idx = ucontrol->value.enumerated.item[0];
  5626. if (idx >= imux->num_items)
  5627. idx = imux->num_items - 1;
  5628. if (*cur_val == idx)
  5629. return 0;
  5630. for (i = 0; i < imux->num_items; i++) {
  5631. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5632. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5633. imux->items[i].index,
  5634. HDA_AMP_MUTE, v);
  5635. }
  5636. *cur_val = idx;
  5637. return 1;
  5638. }
  5639. /*
  5640. * 2ch mode
  5641. */
  5642. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5643. { 2, NULL }
  5644. };
  5645. /*
  5646. * 2ch mode
  5647. */
  5648. static struct hda_verb alc883_3ST_ch2_init[] = {
  5649. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5650. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5651. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5652. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5653. { } /* end */
  5654. };
  5655. /*
  5656. * 4ch mode
  5657. */
  5658. static struct hda_verb alc883_3ST_ch4_init[] = {
  5659. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5660. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5661. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5662. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5663. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5664. { } /* end */
  5665. };
  5666. /*
  5667. * 6ch mode
  5668. */
  5669. static struct hda_verb alc883_3ST_ch6_init[] = {
  5670. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5671. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5672. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5673. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5674. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5675. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5676. { } /* end */
  5677. };
  5678. static struct hda_channel_mode alc883_3ST_6ch_modes[3] = {
  5679. { 2, alc883_3ST_ch2_init },
  5680. { 4, alc883_3ST_ch4_init },
  5681. { 6, alc883_3ST_ch6_init },
  5682. };
  5683. /*
  5684. * 6ch mode
  5685. */
  5686. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5687. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5688. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5689. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5690. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5691. { } /* end */
  5692. };
  5693. /*
  5694. * 8ch mode
  5695. */
  5696. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5697. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5698. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5699. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5700. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5701. { } /* end */
  5702. };
  5703. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5704. { 6, alc883_sixstack_ch6_init },
  5705. { 8, alc883_sixstack_ch8_init },
  5706. };
  5707. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5708. /* eanable EAPD on medion laptop */
  5709. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5710. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5711. { }
  5712. };
  5713. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5714. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5715. */
  5716. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5717. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5718. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5719. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5720. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5721. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5722. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5723. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5724. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5725. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5726. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5727. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5728. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5729. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5730. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5731. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5732. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5733. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5734. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5735. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5736. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5737. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5738. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5739. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5740. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5741. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5742. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5743. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5744. {
  5745. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5746. /* .name = "Capture Source", */
  5747. .name = "Input Source",
  5748. .count = 2,
  5749. .info = alc883_mux_enum_info,
  5750. .get = alc883_mux_enum_get,
  5751. .put = alc883_mux_enum_put,
  5752. },
  5753. { } /* end */
  5754. };
  5755. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5756. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5757. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5758. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5759. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5760. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5761. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5762. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5763. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5764. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5765. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5766. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5767. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5768. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5769. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5770. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5771. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5772. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5773. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5774. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5775. {
  5776. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5777. /* .name = "Capture Source", */
  5778. .name = "Input Source",
  5779. .count = 2,
  5780. .info = alc883_mux_enum_info,
  5781. .get = alc883_mux_enum_get,
  5782. .put = alc883_mux_enum_put,
  5783. },
  5784. { } /* end */
  5785. };
  5786. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5787. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5788. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5789. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5790. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5791. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5792. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5793. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5794. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5795. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5796. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5797. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5798. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5799. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5800. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5801. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5802. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5803. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5804. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5805. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5806. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5807. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5808. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5809. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5810. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5811. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5812. {
  5813. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5814. /* .name = "Capture Source", */
  5815. .name = "Input Source",
  5816. .count = 2,
  5817. .info = alc883_mux_enum_info,
  5818. .get = alc883_mux_enum_get,
  5819. .put = alc883_mux_enum_put,
  5820. },
  5821. { } /* end */
  5822. };
  5823. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5824. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5825. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5826. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5827. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5828. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5829. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5830. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5831. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5832. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5833. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5834. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5835. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5836. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5837. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5838. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5839. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5840. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5841. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5842. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5843. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5844. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5845. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5846. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5847. {
  5848. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5849. /* .name = "Capture Source", */
  5850. .name = "Input Source",
  5851. .count = 1,
  5852. .info = alc883_mux_enum_info,
  5853. .get = alc883_mux_enum_get,
  5854. .put = alc883_mux_enum_put,
  5855. },
  5856. { } /* end */
  5857. };
  5858. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5859. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5860. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5861. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5862. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5863. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5864. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5865. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5866. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5867. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5868. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5869. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5870. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5871. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5872. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5873. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5874. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5875. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5876. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5877. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5878. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5879. {
  5880. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5881. /* .name = "Capture Source", */
  5882. .name = "Input Source",
  5883. .count = 2,
  5884. .info = alc883_mux_enum_info,
  5885. .get = alc883_mux_enum_get,
  5886. .put = alc883_mux_enum_put,
  5887. },
  5888. { } /* end */
  5889. };
  5890. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5891. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5892. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5893. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5894. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5895. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5896. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5897. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5898. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5899. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5900. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5901. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5902. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5903. {
  5904. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5905. /* .name = "Capture Source", */
  5906. .name = "Input Source",
  5907. .count = 2,
  5908. .info = alc883_mux_enum_info,
  5909. .get = alc883_mux_enum_get,
  5910. .put = alc883_mux_enum_put,
  5911. },
  5912. { } /* end */
  5913. };
  5914. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5915. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5916. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5917. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5918. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5919. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5920. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5921. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5922. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5923. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5924. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5925. {
  5926. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5927. /* .name = "Capture Source", */
  5928. .name = "Input Source",
  5929. .count = 1,
  5930. .info = alc883_mux_enum_info,
  5931. .get = alc883_mux_enum_get,
  5932. .put = alc883_mux_enum_put,
  5933. },
  5934. { } /* end */
  5935. };
  5936. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5937. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5938. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5939. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5940. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5941. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5942. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5943. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5944. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5945. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5946. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5947. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5948. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5949. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5950. {
  5951. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5952. /* .name = "Capture Source", */
  5953. .name = "Input Source",
  5954. .count = 2,
  5955. .info = alc883_mux_enum_info,
  5956. .get = alc883_mux_enum_get,
  5957. .put = alc883_mux_enum_put,
  5958. },
  5959. { } /* end */
  5960. };
  5961. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5962. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5963. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5964. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5965. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5966. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5967. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5968. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5969. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5970. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5971. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5972. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5973. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5974. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5975. {
  5976. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5977. /* .name = "Capture Source", */
  5978. .name = "Input Source",
  5979. .count = 2,
  5980. .info = alc883_mux_enum_info,
  5981. .get = alc883_mux_enum_get,
  5982. .put = alc883_mux_enum_put,
  5983. },
  5984. { } /* end */
  5985. };
  5986. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5987. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5988. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5989. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5990. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5991. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5992. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5993. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5994. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5995. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5996. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5997. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5998. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5999. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6000. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6001. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6002. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6003. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6004. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6005. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  6006. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6007. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6008. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6009. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6010. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6011. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6012. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6013. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6014. {
  6015. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6016. /* .name = "Capture Source", */
  6017. .name = "Input Source",
  6018. .count = 2,
  6019. .info = alc883_mux_enum_info,
  6020. .get = alc883_mux_enum_get,
  6021. .put = alc883_mux_enum_put,
  6022. },
  6023. { } /* end */
  6024. };
  6025. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  6026. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6027. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6028. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  6029. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  6030. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  6031. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  6032. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  6033. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  6034. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6035. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6036. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6037. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6038. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6039. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6040. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6041. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6042. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  6043. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6044. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  6045. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6046. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6047. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6048. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6049. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6050. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6051. {
  6052. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6053. /* .name = "Capture Source", */
  6054. .name = "Input Source",
  6055. .count = 2,
  6056. .info = alc883_mux_enum_info,
  6057. .get = alc883_mux_enum_get,
  6058. .put = alc883_mux_enum_put,
  6059. },
  6060. { } /* end */
  6061. };
  6062. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  6063. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6064. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  6065. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6066. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6067. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6068. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6069. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6070. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6071. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6072. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6073. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6074. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6075. {
  6076. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6077. /* .name = "Capture Source", */
  6078. .name = "Input Source",
  6079. .count = 2,
  6080. .info = alc883_mux_enum_info,
  6081. .get = alc883_mux_enum_get,
  6082. .put = alc883_mux_enum_put,
  6083. },
  6084. { } /* end */
  6085. };
  6086. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  6087. {
  6088. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6089. .name = "Channel Mode",
  6090. .info = alc_ch_mode_info,
  6091. .get = alc_ch_mode_get,
  6092. .put = alc_ch_mode_put,
  6093. },
  6094. { } /* end */
  6095. };
  6096. static struct hda_verb alc883_init_verbs[] = {
  6097. /* ADC1: mute amp left and right */
  6098. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6099. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6100. /* ADC2: mute amp left and right */
  6101. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6102. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6103. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  6104. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6105. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6106. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6107. /* Rear mixer */
  6108. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6109. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6110. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6111. /* CLFE mixer */
  6112. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6113. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6114. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6115. /* Side mixer */
  6116. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6117. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6118. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6119. /* mute analog input loopbacks */
  6120. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6121. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6122. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6123. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6124. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6125. /* Front Pin: output 0 (0x0c) */
  6126. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6127. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6128. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6129. /* Rear Pin: output 1 (0x0d) */
  6130. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6131. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6132. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6133. /* CLFE Pin: output 2 (0x0e) */
  6134. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6135. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6136. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  6137. /* Side Pin: output 3 (0x0f) */
  6138. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6139. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6140. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  6141. /* Mic (rear) pin: input vref at 80% */
  6142. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6143. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6144. /* Front Mic pin: input vref at 80% */
  6145. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  6146. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6147. /* Line In pin: input */
  6148. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6149. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  6150. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  6151. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6152. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6153. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6154. /* CD pin widget for input */
  6155. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  6156. /* FIXME: use matrix-type input source selection */
  6157. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6158. /* Input mixer2 */
  6159. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6160. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6161. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6162. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6163. /* Input mixer3 */
  6164. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6165. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6166. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6167. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6168. { }
  6169. };
  6170. static struct hda_verb alc883_tagra_verbs[] = {
  6171. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6172. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6173. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6174. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6175. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  6176. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  6177. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  6178. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6179. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  6180. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  6181. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  6182. { } /* end */
  6183. };
  6184. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  6185. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6186. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  6187. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  6188. { } /* end */
  6189. };
  6190. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  6191. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6192. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6193. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6194. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6195. { } /* end */
  6196. };
  6197. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  6198. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6199. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6200. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6201. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  6202. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6203. { } /* end */
  6204. };
  6205. static struct hda_verb alc883_haier_w66_verbs[] = {
  6206. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6207. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6208. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6209. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6210. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6211. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6212. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6213. { } /* end */
  6214. };
  6215. static struct hda_verb alc888_6st_hp_verbs[] = {
  6216. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6217. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  6218. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  6219. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  6220. { }
  6221. };
  6222. static struct hda_verb alc888_3st_hp_verbs[] = {
  6223. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6224. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  6225. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  6226. { }
  6227. };
  6228. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  6229. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  6230. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6231. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  6232. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6233. { }
  6234. };
  6235. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  6236. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6237. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6238. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6239. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6240. { }
  6241. };
  6242. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  6243. { 2, alc888_3st_hp_2ch_init },
  6244. { 6, alc888_3st_hp_6ch_init },
  6245. };
  6246. /* toggle front-jack and RCA according to the hp-jack state */
  6247. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6248. {
  6249. unsigned int present;
  6250. present = snd_hda_codec_read(codec, 0x1b, 0,
  6251. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6252. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6253. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6254. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6255. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6256. }
  6257. /* toggle RCA according to the front-jack state */
  6258. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6259. {
  6260. unsigned int present;
  6261. present = snd_hda_codec_read(codec, 0x14, 0,
  6262. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6263. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6264. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6265. }
  6266. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6267. unsigned int res)
  6268. {
  6269. if ((res >> 26) == ALC880_HP_EVENT)
  6270. alc888_lenovo_ms7195_front_automute(codec);
  6271. if ((res >> 26) == ALC880_FRONT_EVENT)
  6272. alc888_lenovo_ms7195_rca_automute(codec);
  6273. }
  6274. static struct hda_verb alc883_medion_md2_verbs[] = {
  6275. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6276. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6277. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6278. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6279. { } /* end */
  6280. };
  6281. /* toggle speaker-output according to the hp-jack state */
  6282. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6283. {
  6284. unsigned int present;
  6285. present = snd_hda_codec_read(codec, 0x14, 0,
  6286. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6287. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6288. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6289. }
  6290. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6291. unsigned int res)
  6292. {
  6293. if ((res >> 26) == ALC880_HP_EVENT)
  6294. alc883_medion_md2_automute(codec);
  6295. }
  6296. /* toggle speaker-output according to the hp-jack state */
  6297. static void alc883_tagra_automute(struct hda_codec *codec)
  6298. {
  6299. unsigned int present;
  6300. unsigned char bits;
  6301. present = snd_hda_codec_read(codec, 0x14, 0,
  6302. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6303. bits = present ? HDA_AMP_MUTE : 0;
  6304. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6305. HDA_AMP_MUTE, bits);
  6306. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6307. present ? 1 : 3);
  6308. }
  6309. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6310. {
  6311. if ((res >> 26) == ALC880_HP_EVENT)
  6312. alc883_tagra_automute(codec);
  6313. }
  6314. static void alc883_haier_w66_automute(struct hda_codec *codec)
  6315. {
  6316. unsigned int present;
  6317. unsigned char bits;
  6318. present = snd_hda_codec_read(codec, 0x1b, 0,
  6319. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6320. bits = present ? 0x80 : 0;
  6321. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6322. 0x80, bits);
  6323. }
  6324. static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
  6325. unsigned int res)
  6326. {
  6327. if ((res >> 26) == ALC880_HP_EVENT)
  6328. alc883_haier_w66_automute(codec);
  6329. }
  6330. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6331. {
  6332. unsigned int present;
  6333. unsigned char bits;
  6334. present = snd_hda_codec_read(codec, 0x14, 0,
  6335. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6336. bits = present ? HDA_AMP_MUTE : 0;
  6337. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6338. HDA_AMP_MUTE, bits);
  6339. }
  6340. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6341. {
  6342. unsigned int present;
  6343. unsigned char bits;
  6344. present = snd_hda_codec_read(codec, 0x1b, 0,
  6345. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6346. bits = present ? HDA_AMP_MUTE : 0;
  6347. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6348. HDA_AMP_MUTE, bits);
  6349. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6350. HDA_AMP_MUTE, bits);
  6351. }
  6352. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6353. unsigned int res)
  6354. {
  6355. if ((res >> 26) == ALC880_HP_EVENT)
  6356. alc883_lenovo_101e_all_automute(codec);
  6357. if ((res >> 26) == ALC880_FRONT_EVENT)
  6358. alc883_lenovo_101e_ispeaker_automute(codec);
  6359. }
  6360. /* toggle speaker-output according to the hp-jack state */
  6361. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6362. {
  6363. unsigned int present;
  6364. present = snd_hda_codec_read(codec, 0x14, 0,
  6365. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6366. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6367. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6368. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6369. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6370. }
  6371. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6372. unsigned int res)
  6373. {
  6374. if ((res >> 26) == ALC880_HP_EVENT)
  6375. alc883_acer_aspire_automute(codec);
  6376. }
  6377. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6378. /* HP Pin: output 0 (0x0c) */
  6379. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6380. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6381. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6382. /* Front Pin: output 0 (0x0c) */
  6383. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6384. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6385. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6386. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6387. /* eanable EAPD on medion laptop */
  6388. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6389. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6390. /* enable unsolicited event */
  6391. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6392. { }
  6393. };
  6394. /*
  6395. * generic initialization of ADC, input mixers and output mixers
  6396. */
  6397. static struct hda_verb alc883_auto_init_verbs[] = {
  6398. /*
  6399. * Unmute ADC0-2 and set the default input to mic-in
  6400. */
  6401. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6402. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6403. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6404. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6405. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6406. * mixer widget
  6407. * Note: PASD motherboards uses the Line In 2 as the input for
  6408. * front panel mic (mic 2)
  6409. */
  6410. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6411. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6412. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6413. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6414. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6415. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6416. /*
  6417. * Set up output mixers (0x0c - 0x0f)
  6418. */
  6419. /* set vol=0 to output mixers */
  6420. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6421. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6422. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6423. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6424. /* set up input amps for analog loopback */
  6425. /* Amp Indices: DAC = 0, mixer = 1 */
  6426. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6427. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6428. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6429. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6430. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6431. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6432. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6433. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6434. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6435. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6436. /* FIXME: use matrix-type input source selection */
  6437. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6438. /* Input mixer1 */
  6439. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6440. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6441. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6442. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6443. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6444. /* Input mixer2 */
  6445. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6446. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6447. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6448. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6449. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6450. { }
  6451. };
  6452. /* capture mixer elements */
  6453. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6454. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6455. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6456. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6457. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6458. {
  6459. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6460. /* The multiple "Capture Source" controls confuse alsamixer
  6461. * So call somewhat different..
  6462. * FIXME: the controls appear in the "playback" view!
  6463. */
  6464. /* .name = "Capture Source", */
  6465. .name = "Input Source",
  6466. .count = 2,
  6467. .info = alc882_mux_enum_info,
  6468. .get = alc882_mux_enum_get,
  6469. .put = alc882_mux_enum_put,
  6470. },
  6471. { } /* end */
  6472. };
  6473. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6474. #define alc883_loopbacks alc880_loopbacks
  6475. #endif
  6476. /* pcm configuration: identiacal with ALC880 */
  6477. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6478. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6479. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6480. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6481. /*
  6482. * configuration and preset
  6483. */
  6484. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6485. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6486. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6487. [ALC883_3ST_6ch] = "3stack-6ch",
  6488. [ALC883_6ST_DIG] = "6stack-dig",
  6489. [ALC883_TARGA_DIG] = "targa-dig",
  6490. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6491. [ALC883_ACER] = "acer",
  6492. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6493. [ALC883_MEDION] = "medion",
  6494. [ALC883_MEDION_MD2] = "medion-md2",
  6495. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6496. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6497. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6498. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6499. [ALC883_HAIER_W66] = "haier-w66",
  6500. [ALC888_6ST_HP] = "6stack-hp",
  6501. [ALC888_3ST_HP] = "3stack-hp",
  6502. [ALC883_AUTO] = "auto",
  6503. };
  6504. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6505. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6506. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6507. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6508. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6509. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6510. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6511. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6512. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6513. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6514. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6515. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6516. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6517. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6518. SND_PCI_QUIRK(0x1462, 0x040d, "MSI", ALC883_TARGA_2ch_DIG),
  6519. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6520. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6521. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6522. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6523. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6524. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6525. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6526. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6527. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6528. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6529. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6530. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6531. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6532. SND_PCI_QUIRK(0x1025, 0x0112, "Acer Aspire 9303", ALC883_ACER_ASPIRE),
  6533. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6534. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6535. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6536. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6537. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6538. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6539. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6540. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6541. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6542. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6543. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6544. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6545. SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
  6546. SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6547. SND_PCI_QUIRK(0x1043, 0x8249, "Asus M2A-VM HDMI", ALC883_3ST_6ch_DIG),
  6548. SND_PCI_QUIRK(0x147b, 0x1083, "Abit IP35-PRO", ALC883_6ST_DIG),
  6549. {}
  6550. };
  6551. static struct alc_config_preset alc883_presets[] = {
  6552. [ALC883_3ST_2ch_DIG] = {
  6553. .mixers = { alc883_3ST_2ch_mixer },
  6554. .init_verbs = { alc883_init_verbs },
  6555. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6556. .dac_nids = alc883_dac_nids,
  6557. .dig_out_nid = ALC883_DIGOUT_NID,
  6558. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6559. .adc_nids = alc883_adc_nids,
  6560. .dig_in_nid = ALC883_DIGIN_NID,
  6561. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6562. .channel_mode = alc883_3ST_2ch_modes,
  6563. .input_mux = &alc883_capture_source,
  6564. },
  6565. [ALC883_3ST_6ch_DIG] = {
  6566. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6567. .init_verbs = { alc883_init_verbs },
  6568. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6569. .dac_nids = alc883_dac_nids,
  6570. .dig_out_nid = ALC883_DIGOUT_NID,
  6571. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6572. .adc_nids = alc883_adc_nids,
  6573. .dig_in_nid = ALC883_DIGIN_NID,
  6574. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6575. .channel_mode = alc883_3ST_6ch_modes,
  6576. .need_dac_fix = 1,
  6577. .input_mux = &alc883_capture_source,
  6578. },
  6579. [ALC883_3ST_6ch] = {
  6580. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6581. .init_verbs = { alc883_init_verbs },
  6582. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6583. .dac_nids = alc883_dac_nids,
  6584. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6585. .adc_nids = alc883_adc_nids,
  6586. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6587. .channel_mode = alc883_3ST_6ch_modes,
  6588. .need_dac_fix = 1,
  6589. .input_mux = &alc883_capture_source,
  6590. },
  6591. [ALC883_6ST_DIG] = {
  6592. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6593. .init_verbs = { alc883_init_verbs },
  6594. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6595. .dac_nids = alc883_dac_nids,
  6596. .dig_out_nid = ALC883_DIGOUT_NID,
  6597. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6598. .adc_nids = alc883_adc_nids,
  6599. .dig_in_nid = ALC883_DIGIN_NID,
  6600. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6601. .channel_mode = alc883_sixstack_modes,
  6602. .input_mux = &alc883_capture_source,
  6603. },
  6604. [ALC883_TARGA_DIG] = {
  6605. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6606. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6607. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6608. .dac_nids = alc883_dac_nids,
  6609. .dig_out_nid = ALC883_DIGOUT_NID,
  6610. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6611. .adc_nids = alc883_adc_nids,
  6612. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6613. .channel_mode = alc883_3ST_6ch_modes,
  6614. .need_dac_fix = 1,
  6615. .input_mux = &alc883_capture_source,
  6616. .unsol_event = alc883_tagra_unsol_event,
  6617. .init_hook = alc883_tagra_automute,
  6618. },
  6619. [ALC883_TARGA_2ch_DIG] = {
  6620. .mixers = { alc883_tagra_2ch_mixer},
  6621. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6622. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6623. .dac_nids = alc883_dac_nids,
  6624. .dig_out_nid = ALC883_DIGOUT_NID,
  6625. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6626. .adc_nids = alc883_adc_nids,
  6627. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6628. .channel_mode = alc883_3ST_2ch_modes,
  6629. .input_mux = &alc883_capture_source,
  6630. .unsol_event = alc883_tagra_unsol_event,
  6631. .init_hook = alc883_tagra_automute,
  6632. },
  6633. [ALC883_ACER] = {
  6634. .mixers = { alc883_base_mixer },
  6635. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6636. * and the headphone jack. Turn this on and rely on the
  6637. * standard mute methods whenever the user wants to turn
  6638. * these outputs off.
  6639. */
  6640. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6641. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6642. .dac_nids = alc883_dac_nids,
  6643. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6644. .adc_nids = alc883_adc_nids,
  6645. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6646. .channel_mode = alc883_3ST_2ch_modes,
  6647. .input_mux = &alc883_capture_source,
  6648. },
  6649. [ALC883_ACER_ASPIRE] = {
  6650. .mixers = { alc883_acer_aspire_mixer },
  6651. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6652. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6653. .dac_nids = alc883_dac_nids,
  6654. .dig_out_nid = ALC883_DIGOUT_NID,
  6655. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6656. .adc_nids = alc883_adc_nids,
  6657. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6658. .channel_mode = alc883_3ST_2ch_modes,
  6659. .input_mux = &alc883_capture_source,
  6660. .unsol_event = alc883_acer_aspire_unsol_event,
  6661. .init_hook = alc883_acer_aspire_automute,
  6662. },
  6663. [ALC883_MEDION] = {
  6664. .mixers = { alc883_fivestack_mixer,
  6665. alc883_chmode_mixer },
  6666. .init_verbs = { alc883_init_verbs,
  6667. alc883_medion_eapd_verbs },
  6668. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6669. .dac_nids = alc883_dac_nids,
  6670. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6671. .adc_nids = alc883_adc_nids,
  6672. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6673. .channel_mode = alc883_sixstack_modes,
  6674. .input_mux = &alc883_capture_source,
  6675. },
  6676. [ALC883_MEDION_MD2] = {
  6677. .mixers = { alc883_medion_md2_mixer},
  6678. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6679. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6680. .dac_nids = alc883_dac_nids,
  6681. .dig_out_nid = ALC883_DIGOUT_NID,
  6682. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6683. .adc_nids = alc883_adc_nids,
  6684. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6685. .channel_mode = alc883_3ST_2ch_modes,
  6686. .input_mux = &alc883_capture_source,
  6687. .unsol_event = alc883_medion_md2_unsol_event,
  6688. .init_hook = alc883_medion_md2_automute,
  6689. },
  6690. [ALC883_LAPTOP_EAPD] = {
  6691. .mixers = { alc883_base_mixer },
  6692. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6693. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6694. .dac_nids = alc883_dac_nids,
  6695. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6696. .adc_nids = alc883_adc_nids,
  6697. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6698. .channel_mode = alc883_3ST_2ch_modes,
  6699. .input_mux = &alc883_capture_source,
  6700. },
  6701. [ALC883_LENOVO_101E_2ch] = {
  6702. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6703. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6704. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6705. .dac_nids = alc883_dac_nids,
  6706. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6707. .adc_nids = alc883_adc_nids,
  6708. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6709. .channel_mode = alc883_3ST_2ch_modes,
  6710. .input_mux = &alc883_lenovo_101e_capture_source,
  6711. .unsol_event = alc883_lenovo_101e_unsol_event,
  6712. .init_hook = alc883_lenovo_101e_all_automute,
  6713. },
  6714. [ALC883_LENOVO_NB0763] = {
  6715. .mixers = { alc883_lenovo_nb0763_mixer },
  6716. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6717. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6718. .dac_nids = alc883_dac_nids,
  6719. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6720. .adc_nids = alc883_adc_nids,
  6721. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6722. .channel_mode = alc883_3ST_2ch_modes,
  6723. .need_dac_fix = 1,
  6724. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6725. .unsol_event = alc883_medion_md2_unsol_event,
  6726. .init_hook = alc883_medion_md2_automute,
  6727. },
  6728. [ALC888_LENOVO_MS7195_DIG] = {
  6729. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6730. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6731. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6732. .dac_nids = alc883_dac_nids,
  6733. .dig_out_nid = ALC883_DIGOUT_NID,
  6734. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6735. .adc_nids = alc883_adc_nids,
  6736. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6737. .channel_mode = alc883_3ST_6ch_modes,
  6738. .need_dac_fix = 1,
  6739. .input_mux = &alc883_capture_source,
  6740. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6741. .init_hook = alc888_lenovo_ms7195_front_automute,
  6742. },
  6743. [ALC883_HAIER_W66] = {
  6744. .mixers = { alc883_tagra_2ch_mixer},
  6745. .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
  6746. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6747. .dac_nids = alc883_dac_nids,
  6748. .dig_out_nid = ALC883_DIGOUT_NID,
  6749. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6750. .adc_nids = alc883_adc_nids,
  6751. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6752. .channel_mode = alc883_3ST_2ch_modes,
  6753. .input_mux = &alc883_capture_source,
  6754. .unsol_event = alc883_haier_w66_unsol_event,
  6755. .init_hook = alc883_haier_w66_automute,
  6756. },
  6757. [ALC888_6ST_HP] = {
  6758. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6759. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6760. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6761. .dac_nids = alc883_dac_nids,
  6762. .dig_out_nid = ALC883_DIGOUT_NID,
  6763. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6764. .adc_nids = alc883_adc_nids,
  6765. .dig_in_nid = ALC883_DIGIN_NID,
  6766. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6767. .channel_mode = alc883_sixstack_modes,
  6768. .input_mux = &alc883_capture_source,
  6769. },
  6770. [ALC888_3ST_HP] = {
  6771. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6772. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6773. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6774. .dac_nids = alc883_dac_nids,
  6775. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6776. .adc_nids = alc883_adc_nids,
  6777. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6778. .channel_mode = alc888_3st_hp_modes,
  6779. .need_dac_fix = 1,
  6780. .input_mux = &alc883_capture_source,
  6781. },
  6782. };
  6783. /*
  6784. * BIOS auto configuration
  6785. */
  6786. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6787. hda_nid_t nid, int pin_type,
  6788. int dac_idx)
  6789. {
  6790. /* set as output */
  6791. struct alc_spec *spec = codec->spec;
  6792. int idx;
  6793. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6794. idx = 4;
  6795. else
  6796. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6797. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6798. pin_type);
  6799. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6800. AMP_OUT_UNMUTE);
  6801. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6802. }
  6803. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6804. {
  6805. struct alc_spec *spec = codec->spec;
  6806. int i;
  6807. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6808. for (i = 0; i <= HDA_SIDE; i++) {
  6809. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6810. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6811. if (nid)
  6812. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6813. i);
  6814. }
  6815. }
  6816. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6817. {
  6818. struct alc_spec *spec = codec->spec;
  6819. hda_nid_t pin;
  6820. pin = spec->autocfg.hp_pins[0];
  6821. if (pin) /* connect to front */
  6822. /* use dac 0 */
  6823. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6824. }
  6825. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6826. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6827. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6828. {
  6829. struct alc_spec *spec = codec->spec;
  6830. int i;
  6831. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6832. hda_nid_t nid = spec->autocfg.input_pins[i];
  6833. if (alc883_is_input_pin(nid)) {
  6834. snd_hda_codec_write(codec, nid, 0,
  6835. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6836. (i <= AUTO_PIN_FRONT_MIC ?
  6837. PIN_VREF80 : PIN_IN));
  6838. if (nid != ALC883_PIN_CD_NID)
  6839. snd_hda_codec_write(codec, nid, 0,
  6840. AC_VERB_SET_AMP_GAIN_MUTE,
  6841. AMP_OUT_MUTE);
  6842. }
  6843. }
  6844. }
  6845. /* almost identical with ALC880 parser... */
  6846. static int alc883_parse_auto_config(struct hda_codec *codec)
  6847. {
  6848. struct alc_spec *spec = codec->spec;
  6849. int err = alc880_parse_auto_config(codec);
  6850. if (err < 0)
  6851. return err;
  6852. else if (!err)
  6853. return 0; /* no config found */
  6854. err = alc_auto_add_mic_boost(codec);
  6855. if (err < 0)
  6856. return err;
  6857. /* hack - override the init verbs */
  6858. spec->init_verbs[0] = alc883_auto_init_verbs;
  6859. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6860. spec->num_mixers++;
  6861. return 1; /* config found */
  6862. }
  6863. /* additional initialization for auto-configuration model */
  6864. static void alc883_auto_init(struct hda_codec *codec)
  6865. {
  6866. alc883_auto_init_multi_out(codec);
  6867. alc883_auto_init_hp_out(codec);
  6868. alc883_auto_init_analog_input(codec);
  6869. }
  6870. static int patch_alc883(struct hda_codec *codec)
  6871. {
  6872. struct alc_spec *spec;
  6873. int err, board_config;
  6874. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6875. if (spec == NULL)
  6876. return -ENOMEM;
  6877. codec->spec = spec;
  6878. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6879. alc883_models,
  6880. alc883_cfg_tbl);
  6881. if (board_config < 0) {
  6882. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6883. "trying auto-probe from BIOS...\n");
  6884. board_config = ALC883_AUTO;
  6885. }
  6886. if (board_config == ALC883_AUTO) {
  6887. /* automatic parse from the BIOS config */
  6888. err = alc883_parse_auto_config(codec);
  6889. if (err < 0) {
  6890. alc_free(codec);
  6891. return err;
  6892. } else if (!err) {
  6893. printk(KERN_INFO
  6894. "hda_codec: Cannot set up configuration "
  6895. "from BIOS. Using base mode...\n");
  6896. board_config = ALC883_3ST_2ch_DIG;
  6897. }
  6898. }
  6899. if (board_config != ALC883_AUTO)
  6900. setup_preset(spec, &alc883_presets[board_config]);
  6901. spec->stream_name_analog = "ALC883 Analog";
  6902. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6903. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6904. spec->stream_name_digital = "ALC883 Digital";
  6905. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6906. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6907. if (!spec->adc_nids && spec->input_mux) {
  6908. spec->adc_nids = alc883_adc_nids;
  6909. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6910. }
  6911. codec->patch_ops = alc_patch_ops;
  6912. if (board_config == ALC883_AUTO)
  6913. spec->init_hook = alc883_auto_init;
  6914. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6915. if (!spec->loopback.amplist)
  6916. spec->loopback.amplist = alc883_loopbacks;
  6917. #endif
  6918. return 0;
  6919. }
  6920. /*
  6921. * ALC262 support
  6922. */
  6923. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6924. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6925. #define alc262_dac_nids alc260_dac_nids
  6926. #define alc262_adc_nids alc882_adc_nids
  6927. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6928. #define alc262_modes alc260_modes
  6929. #define alc262_capture_source alc882_capture_source
  6930. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6931. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6932. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6933. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6934. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6935. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6936. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6937. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6938. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6939. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6940. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6941. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6942. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6943. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6944. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6945. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6946. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6947. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6948. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6949. { } /* end */
  6950. };
  6951. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6952. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6953. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6954. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6955. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6956. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6957. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6958. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6959. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6960. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6961. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6962. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6963. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6964. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6965. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6966. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6967. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6968. { } /* end */
  6969. };
  6970. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6971. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6972. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6973. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6974. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6975. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6976. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6977. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6978. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6979. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6980. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6981. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6982. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6983. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6984. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6985. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6986. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6987. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6988. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6989. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6990. { } /* end */
  6991. };
  6992. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6993. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6994. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6995. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6996. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6997. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6998. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6999. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  7000. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  7001. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  7002. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7003. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7004. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7005. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7006. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  7007. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  7008. { } /* end */
  7009. };
  7010. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  7011. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7012. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7013. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  7014. { } /* end */
  7015. };
  7016. static struct hda_bind_ctls alc262_hp_t5735_bind_front_vol = {
  7017. .ops = &snd_hda_bind_vol,
  7018. .values = {
  7019. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7020. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7021. 0
  7022. },
  7023. };
  7024. static struct hda_bind_ctls alc262_hp_t5735_bind_front_sw = {
  7025. .ops = &snd_hda_bind_sw,
  7026. .values = {
  7027. HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7028. HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  7029. 0
  7030. },
  7031. };
  7032. /* mute/unmute internal speaker according to the hp jack and mute state */
  7033. static void alc262_hp_t5735_automute(struct hda_codec *codec, int force)
  7034. {
  7035. struct alc_spec *spec = codec->spec;
  7036. unsigned int mute;
  7037. if (force || !spec->sense_updated) {
  7038. unsigned int present;
  7039. present = snd_hda_codec_read(codec, 0x15, 0,
  7040. AC_VERB_GET_PIN_SENSE, 0);
  7041. spec->jack_present = (present & 0x80000000) != 0;
  7042. spec->sense_updated = 1;
  7043. }
  7044. if (spec->jack_present)
  7045. mute = (0x7080 | ((0)<<8)); /* mute internal speaker */
  7046. else /* unmute internal speaker if necessary */
  7047. mute = (0x7000 | ((0)<<8));
  7048. snd_hda_codec_write(codec, 0x0c, 0,
  7049. AC_VERB_SET_AMP_GAIN_MUTE, mute );
  7050. }
  7051. static void alc262_hp_t5735_unsol_event(struct hda_codec *codec,
  7052. unsigned int res)
  7053. {
  7054. if ((res >> 26) != ALC880_HP_EVENT)
  7055. return;
  7056. alc262_hp_t5735_automute(codec, 1);
  7057. }
  7058. static void alc262_hp_t5735_init_hook(struct hda_codec *codec)
  7059. {
  7060. alc262_hp_t5735_automute(codec, 1);
  7061. }
  7062. static struct snd_kcontrol_new alc262_hp_t5735_mixer[] = {
  7063. HDA_BIND_VOL("PCM Playback Volume", &alc262_hp_t5735_bind_front_vol),
  7064. HDA_BIND_SW("PCM Playback Switch",&alc262_hp_t5735_bind_front_sw),
  7065. HDA_CODEC_VOLUME("LineOut Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7066. HDA_CODEC_MUTE("LineOut Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7067. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7068. HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7069. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  7070. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7071. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7072. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7073. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7074. { } /* end */
  7075. };
  7076. static struct hda_verb alc262_hp_t5735_verbs[] = {
  7077. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7078. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7079. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7080. { }
  7081. };
  7082. /* bind hp and internal speaker mute (with plug check) */
  7083. static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
  7084. struct snd_ctl_elem_value *ucontrol)
  7085. {
  7086. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7087. long *valp = ucontrol->value.integer.value;
  7088. int change;
  7089. /* change hp mute */
  7090. change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  7091. HDA_AMP_MUTE,
  7092. valp[0] ? 0 : HDA_AMP_MUTE);
  7093. change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  7094. HDA_AMP_MUTE,
  7095. valp[1] ? 0 : HDA_AMP_MUTE);
  7096. if (change) {
  7097. /* change speaker according to HP jack state */
  7098. struct alc_spec *spec = codec->spec;
  7099. unsigned int mute;
  7100. if (spec->jack_present)
  7101. mute = HDA_AMP_MUTE;
  7102. else
  7103. mute = snd_hda_codec_amp_read(codec, 0x15, 0,
  7104. HDA_OUTPUT, 0);
  7105. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7106. HDA_AMP_MUTE, mute);
  7107. }
  7108. return change;
  7109. }
  7110. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  7111. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7112. {
  7113. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7114. .name = "Master Playback Switch",
  7115. .info = snd_hda_mixer_amp_switch_info,
  7116. .get = snd_hda_mixer_amp_switch_get,
  7117. .put = alc262_sony_master_sw_put,
  7118. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  7119. },
  7120. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7121. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7122. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7123. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7124. { } /* end */
  7125. };
  7126. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  7127. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7128. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7129. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7130. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7131. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7132. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7133. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7134. { } /* end */
  7135. };
  7136. #define alc262_capture_mixer alc882_capture_mixer
  7137. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  7138. /*
  7139. * generic initialization of ADC, input mixers and output mixers
  7140. */
  7141. static struct hda_verb alc262_init_verbs[] = {
  7142. /*
  7143. * Unmute ADC0-2 and set the default input to mic-in
  7144. */
  7145. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7146. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7147. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7148. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7149. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7150. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7151. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7152. * mixer widget
  7153. * Note: PASD motherboards uses the Line In 2 as the input for
  7154. * front panel mic (mic 2)
  7155. */
  7156. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7157. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7158. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7159. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7160. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7161. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7162. /*
  7163. * Set up output mixers (0x0c - 0x0e)
  7164. */
  7165. /* set vol=0 to output mixers */
  7166. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7167. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7168. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7169. /* set up input amps for analog loopback */
  7170. /* Amp Indices: DAC = 0, mixer = 1 */
  7171. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7172. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7173. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7174. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7175. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7176. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7177. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7178. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7179. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7180. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7181. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7182. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7183. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7184. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7185. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7186. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7187. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7188. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  7189. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7190. /* FIXME: use matrix-type input source selection */
  7191. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7192. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7193. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7194. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7195. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7196. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7197. /* Input mixer2 */
  7198. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7199. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7200. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7201. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7202. /* Input mixer3 */
  7203. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7204. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7205. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7206. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7207. { }
  7208. };
  7209. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  7210. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7211. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7212. {}
  7213. };
  7214. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  7215. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7216. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7217. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  7218. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7219. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7220. {}
  7221. };
  7222. static struct hda_verb alc262_sony_unsol_verbs[] = {
  7223. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7224. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7225. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  7226. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7227. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7228. };
  7229. /* mute/unmute internal speaker according to the hp jack and mute state */
  7230. static void alc262_hippo_automute(struct hda_codec *codec)
  7231. {
  7232. struct alc_spec *spec = codec->spec;
  7233. unsigned int mute;
  7234. unsigned int present;
  7235. /* need to execute and sync at first */
  7236. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7237. present = snd_hda_codec_read(codec, 0x15, 0,
  7238. AC_VERB_GET_PIN_SENSE, 0);
  7239. spec->jack_present = (present & 0x80000000) != 0;
  7240. if (spec->jack_present) {
  7241. /* mute internal speaker */
  7242. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7243. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7244. } else {
  7245. /* unmute internal speaker if necessary */
  7246. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7247. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7248. HDA_AMP_MUTE, mute);
  7249. }
  7250. }
  7251. /* unsolicited event for HP jack sensing */
  7252. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  7253. unsigned int res)
  7254. {
  7255. if ((res >> 26) != ALC880_HP_EVENT)
  7256. return;
  7257. alc262_hippo_automute(codec);
  7258. }
  7259. static void alc262_hippo1_automute(struct hda_codec *codec)
  7260. {
  7261. unsigned int mute;
  7262. unsigned int present;
  7263. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  7264. present = snd_hda_codec_read(codec, 0x1b, 0,
  7265. AC_VERB_GET_PIN_SENSE, 0);
  7266. present = (present & 0x80000000) != 0;
  7267. if (present) {
  7268. /* mute internal speaker */
  7269. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7270. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7271. } else {
  7272. /* unmute internal speaker if necessary */
  7273. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  7274. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7275. HDA_AMP_MUTE, mute);
  7276. }
  7277. }
  7278. /* unsolicited event for HP jack sensing */
  7279. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  7280. unsigned int res)
  7281. {
  7282. if ((res >> 26) != ALC880_HP_EVENT)
  7283. return;
  7284. alc262_hippo1_automute(codec);
  7285. }
  7286. /*
  7287. * fujitsu model
  7288. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  7289. */
  7290. #define ALC_HP_EVENT 0x37
  7291. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  7292. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  7293. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7294. {}
  7295. };
  7296. static struct hda_input_mux alc262_fujitsu_capture_source = {
  7297. .num_items = 3,
  7298. .items = {
  7299. { "Mic", 0x0 },
  7300. { "Int Mic", 0x1 },
  7301. { "CD", 0x4 },
  7302. },
  7303. };
  7304. static struct hda_input_mux alc262_HP_capture_source = {
  7305. .num_items = 5,
  7306. .items = {
  7307. { "Mic", 0x0 },
  7308. { "Front Mic", 0x1 },
  7309. { "Line", 0x2 },
  7310. { "CD", 0x4 },
  7311. { "AUX IN", 0x6 },
  7312. },
  7313. };
  7314. static struct hda_input_mux alc262_HP_D7000_capture_source = {
  7315. .num_items = 4,
  7316. .items = {
  7317. { "Mic", 0x0 },
  7318. { "Front Mic", 0x2 },
  7319. { "Line", 0x1 },
  7320. { "CD", 0x4 },
  7321. },
  7322. };
  7323. /* mute/unmute internal speaker according to the hp jack and mute state */
  7324. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  7325. {
  7326. struct alc_spec *spec = codec->spec;
  7327. unsigned int mute;
  7328. if (force || !spec->sense_updated) {
  7329. unsigned int present;
  7330. /* need to execute and sync at first */
  7331. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  7332. present = snd_hda_codec_read(codec, 0x14, 0,
  7333. AC_VERB_GET_PIN_SENSE, 0);
  7334. spec->jack_present = (present & 0x80000000) != 0;
  7335. spec->sense_updated = 1;
  7336. }
  7337. if (spec->jack_present) {
  7338. /* mute internal speaker */
  7339. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7340. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7341. } else {
  7342. /* unmute internal speaker if necessary */
  7343. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7344. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7345. HDA_AMP_MUTE, mute);
  7346. }
  7347. }
  7348. /* unsolicited event for HP jack sensing */
  7349. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  7350. unsigned int res)
  7351. {
  7352. if ((res >> 26) != ALC_HP_EVENT)
  7353. return;
  7354. alc262_fujitsu_automute(codec, 1);
  7355. }
  7356. /* bind volumes of both NID 0x0c and 0x0d */
  7357. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  7358. .ops = &snd_hda_bind_vol,
  7359. .values = {
  7360. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7361. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7362. 0
  7363. },
  7364. };
  7365. /* bind hp and internal speaker mute (with plug check) */
  7366. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  7367. struct snd_ctl_elem_value *ucontrol)
  7368. {
  7369. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7370. long *valp = ucontrol->value.integer.value;
  7371. int change;
  7372. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7373. HDA_AMP_MUTE,
  7374. valp[0] ? 0 : HDA_AMP_MUTE);
  7375. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7376. HDA_AMP_MUTE,
  7377. valp[1] ? 0 : HDA_AMP_MUTE);
  7378. if (change)
  7379. alc262_fujitsu_automute(codec, 0);
  7380. return change;
  7381. }
  7382. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  7383. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  7384. {
  7385. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7386. .name = "Master Playback Switch",
  7387. .info = snd_hda_mixer_amp_switch_info,
  7388. .get = snd_hda_mixer_amp_switch_get,
  7389. .put = alc262_fujitsu_master_sw_put,
  7390. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7391. },
  7392. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7393. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7394. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7395. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7396. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7397. HDA_CODEC_VOLUME("Int Mic Boost", 0x19, 0, HDA_INPUT),
  7398. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  7399. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  7400. { } /* end */
  7401. };
  7402. /* additional init verbs for Benq laptops */
  7403. static struct hda_verb alc262_EAPD_verbs[] = {
  7404. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7405. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7406. {}
  7407. };
  7408. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7409. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7410. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7411. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7412. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7413. {}
  7414. };
  7415. /* Samsung Q1 Ultra Vista model setup */
  7416. static struct snd_kcontrol_new alc262_ultra_mixer[] = {
  7417. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  7418. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7419. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7420. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  7421. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  7422. HDA_CODEC_VOLUME("Mic Boost", 0x19, 0, HDA_INPUT),
  7423. { } /* end */
  7424. };
  7425. static struct hda_verb alc262_ultra_verbs[] = {
  7426. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  7427. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7428. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7429. /* Mic is on Node 0x19 */
  7430. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7431. {0x22, AC_VERB_SET_CONNECT_SEL, 0x01},
  7432. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7433. {0x23, AC_VERB_SET_CONNECT_SEL, 0x01},
  7434. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7435. {0x24, AC_VERB_SET_CONNECT_SEL, 0x01},
  7436. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7437. {}
  7438. };
  7439. static struct hda_input_mux alc262_ultra_capture_source = {
  7440. .num_items = 1,
  7441. .items = {
  7442. { "Mic", 0x1 },
  7443. },
  7444. };
  7445. /* mute/unmute internal speaker according to the hp jack and mute state */
  7446. static void alc262_ultra_automute(struct hda_codec *codec)
  7447. {
  7448. struct alc_spec *spec = codec->spec;
  7449. unsigned int mute;
  7450. unsigned int present;
  7451. /* need to execute and sync at first */
  7452. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  7453. present = snd_hda_codec_read(codec, 0x15, 0,
  7454. AC_VERB_GET_PIN_SENSE, 0);
  7455. spec->jack_present = (present & 0x80000000) != 0;
  7456. if (spec->jack_present) {
  7457. /* mute internal speaker */
  7458. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7459. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7460. } else {
  7461. /* unmute internal speaker if necessary */
  7462. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  7463. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  7464. HDA_AMP_MUTE, mute);
  7465. }
  7466. }
  7467. /* unsolicited event for HP jack sensing */
  7468. static void alc262_ultra_unsol_event(struct hda_codec *codec,
  7469. unsigned int res)
  7470. {
  7471. if ((res >> 26) != ALC880_HP_EVENT)
  7472. return;
  7473. alc262_ultra_automute(codec);
  7474. }
  7475. /* add playback controls from the parsed DAC table */
  7476. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7477. const struct auto_pin_cfg *cfg)
  7478. {
  7479. hda_nid_t nid;
  7480. int err;
  7481. spec->multiout.num_dacs = 1; /* only use one dac */
  7482. spec->multiout.dac_nids = spec->private_dac_nids;
  7483. spec->multiout.dac_nids[0] = 2;
  7484. nid = cfg->line_out_pins[0];
  7485. if (nid) {
  7486. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7487. "Front Playback Volume",
  7488. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7489. if (err < 0)
  7490. return err;
  7491. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7492. "Front Playback Switch",
  7493. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7494. if (err < 0)
  7495. return err;
  7496. }
  7497. nid = cfg->speaker_pins[0];
  7498. if (nid) {
  7499. if (nid == 0x16) {
  7500. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7501. "Speaker Playback Volume",
  7502. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7503. HDA_OUTPUT));
  7504. if (err < 0)
  7505. return err;
  7506. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7507. "Speaker Playback Switch",
  7508. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7509. HDA_OUTPUT));
  7510. if (err < 0)
  7511. return err;
  7512. } else {
  7513. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7514. "Speaker Playback Switch",
  7515. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7516. HDA_OUTPUT));
  7517. if (err < 0)
  7518. return err;
  7519. }
  7520. }
  7521. nid = cfg->hp_pins[0];
  7522. if (nid) {
  7523. /* spec->multiout.hp_nid = 2; */
  7524. if (nid == 0x16) {
  7525. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7526. "Headphone Playback Volume",
  7527. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7528. HDA_OUTPUT));
  7529. if (err < 0)
  7530. return err;
  7531. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7532. "Headphone Playback Switch",
  7533. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7534. HDA_OUTPUT));
  7535. if (err < 0)
  7536. return err;
  7537. } else {
  7538. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7539. "Headphone Playback Switch",
  7540. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7541. HDA_OUTPUT));
  7542. if (err < 0)
  7543. return err;
  7544. }
  7545. }
  7546. return 0;
  7547. }
  7548. /* identical with ALC880 */
  7549. #define alc262_auto_create_analog_input_ctls \
  7550. alc880_auto_create_analog_input_ctls
  7551. /*
  7552. * generic initialization of ADC, input mixers and output mixers
  7553. */
  7554. static struct hda_verb alc262_volume_init_verbs[] = {
  7555. /*
  7556. * Unmute ADC0-2 and set the default input to mic-in
  7557. */
  7558. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7559. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7560. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7561. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7562. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7563. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7564. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7565. * mixer widget
  7566. * Note: PASD motherboards uses the Line In 2 as the input for
  7567. * front panel mic (mic 2)
  7568. */
  7569. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7570. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7571. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7572. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7573. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7574. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7575. /*
  7576. * Set up output mixers (0x0c - 0x0f)
  7577. */
  7578. /* set vol=0 to output mixers */
  7579. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7580. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7581. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7582. /* set up input amps for analog loopback */
  7583. /* Amp Indices: DAC = 0, mixer = 1 */
  7584. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7585. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7586. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7587. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7588. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7589. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7590. /* FIXME: use matrix-type input source selection */
  7591. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7592. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7593. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7594. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7595. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7596. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7597. /* Input mixer2 */
  7598. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7599. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7600. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7601. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7602. /* Input mixer3 */
  7603. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7604. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7605. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7606. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7607. { }
  7608. };
  7609. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7610. /*
  7611. * Unmute ADC0-2 and set the default input to mic-in
  7612. */
  7613. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7614. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7615. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7616. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7617. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7618. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7619. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7620. * mixer widget
  7621. * Note: PASD motherboards uses the Line In 2 as the input for
  7622. * front panel mic (mic 2)
  7623. */
  7624. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7625. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7626. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7627. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7628. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7629. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7630. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7631. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7632. /*
  7633. * Set up output mixers (0x0c - 0x0e)
  7634. */
  7635. /* set vol=0 to output mixers */
  7636. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7637. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7638. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7639. /* set up input amps for analog loopback */
  7640. /* Amp Indices: DAC = 0, mixer = 1 */
  7641. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7642. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7643. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7644. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7645. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7646. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7647. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7648. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7649. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7650. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7651. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7652. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7653. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7654. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7655. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7656. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7657. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7658. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7659. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7660. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7661. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7662. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7663. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7664. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7665. /* FIXME: use matrix-type input source selection */
  7666. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7667. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7668. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7669. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7670. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7671. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7672. /* Input mixer2 */
  7673. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7674. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7675. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7676. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7677. /* Input mixer3 */
  7678. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7679. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7680. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7681. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7682. { }
  7683. };
  7684. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7685. /*
  7686. * Unmute ADC0-2 and set the default input to mic-in
  7687. */
  7688. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7689. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7690. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7691. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7692. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7693. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7694. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7695. * mixer widget
  7696. * Note: PASD motherboards uses the Line In 2 as the input for front
  7697. * panel mic (mic 2)
  7698. */
  7699. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7700. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7701. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7702. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7703. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7704. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7705. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7706. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7707. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7708. /*
  7709. * Set up output mixers (0x0c - 0x0e)
  7710. */
  7711. /* set vol=0 to output mixers */
  7712. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7713. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7714. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7715. /* set up input amps for analog loopback */
  7716. /* Amp Indices: DAC = 0, mixer = 1 */
  7717. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7718. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7719. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7720. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7721. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7722. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7723. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7724. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7725. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7726. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7727. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7728. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7729. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7730. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7731. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7732. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7733. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7734. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7735. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7736. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7737. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7738. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7739. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7740. /* FIXME: use matrix-type input source selection */
  7741. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7742. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7743. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7744. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7745. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7746. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7747. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7748. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7749. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7750. /* Input mixer2 */
  7751. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7752. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7753. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7754. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7755. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7756. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7757. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7758. /* Input mixer3 */
  7759. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7760. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7761. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7762. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7763. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7764. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7765. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7766. { }
  7767. };
  7768. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7769. #define alc262_loopbacks alc880_loopbacks
  7770. #endif
  7771. /* pcm configuration: identiacal with ALC880 */
  7772. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7773. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7774. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7775. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7776. /*
  7777. * BIOS auto configuration
  7778. */
  7779. static int alc262_parse_auto_config(struct hda_codec *codec)
  7780. {
  7781. struct alc_spec *spec = codec->spec;
  7782. int err;
  7783. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7784. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7785. alc262_ignore);
  7786. if (err < 0)
  7787. return err;
  7788. if (!spec->autocfg.line_outs)
  7789. return 0; /* can't find valid BIOS pin config */
  7790. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7791. if (err < 0)
  7792. return err;
  7793. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7794. if (err < 0)
  7795. return err;
  7796. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7797. if (spec->autocfg.dig_out_pin)
  7798. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7799. if (spec->autocfg.dig_in_pin)
  7800. spec->dig_in_nid = ALC262_DIGIN_NID;
  7801. if (spec->kctl_alloc)
  7802. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7803. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7804. spec->num_mux_defs = 1;
  7805. spec->input_mux = &spec->private_imux;
  7806. err = alc_auto_add_mic_boost(codec);
  7807. if (err < 0)
  7808. return err;
  7809. return 1;
  7810. }
  7811. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7812. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7813. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7814. /* init callback for auto-configuration model -- overriding the default init */
  7815. static void alc262_auto_init(struct hda_codec *codec)
  7816. {
  7817. alc262_auto_init_multi_out(codec);
  7818. alc262_auto_init_hp_out(codec);
  7819. alc262_auto_init_analog_input(codec);
  7820. }
  7821. /*
  7822. * configuration and preset
  7823. */
  7824. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7825. [ALC262_BASIC] = "basic",
  7826. [ALC262_HIPPO] = "hippo",
  7827. [ALC262_HIPPO_1] = "hippo_1",
  7828. [ALC262_FUJITSU] = "fujitsu",
  7829. [ALC262_HP_BPC] = "hp-bpc",
  7830. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7831. [ALC262_HP_TC_T5735] = "hp-tc-t5735",
  7832. [ALC262_BENQ_ED8] = "benq",
  7833. [ALC262_BENQ_T31] = "benq-t31",
  7834. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7835. [ALC262_ULTRA] = "ultra",
  7836. [ALC262_AUTO] = "auto",
  7837. };
  7838. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7839. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7840. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7841. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7842. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7843. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7844. SND_PCI_QUIRK(0x103c, 0x1309, "HP xw4*00", ALC262_HP_BPC),
  7845. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7846. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7847. SND_PCI_QUIRK(0x103c, 0x130a, "HP xw6*00", ALC262_HP_BPC),
  7848. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7849. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7850. SND_PCI_QUIRK(0x103c, 0x130b, "HP xw8*00", ALC262_HP_BPC),
  7851. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7852. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7853. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7854. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7855. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7856. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7857. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7858. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7859. SND_PCI_QUIRK(0x103c, 0x302f, "HP Thin Client T5735",
  7860. ALC262_HP_TC_T5735),
  7861. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7862. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7863. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7864. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7865. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7866. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7867. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7868. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7869. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7870. SND_PCI_QUIRK(0x144d, 0xc032, "Samsung Q1 Ultra", ALC262_ULTRA),
  7871. {}
  7872. };
  7873. static struct alc_config_preset alc262_presets[] = {
  7874. [ALC262_BASIC] = {
  7875. .mixers = { alc262_base_mixer },
  7876. .init_verbs = { alc262_init_verbs },
  7877. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7878. .dac_nids = alc262_dac_nids,
  7879. .hp_nid = 0x03,
  7880. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7881. .channel_mode = alc262_modes,
  7882. .input_mux = &alc262_capture_source,
  7883. },
  7884. [ALC262_HIPPO] = {
  7885. .mixers = { alc262_base_mixer },
  7886. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7887. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7888. .dac_nids = alc262_dac_nids,
  7889. .hp_nid = 0x03,
  7890. .dig_out_nid = ALC262_DIGOUT_NID,
  7891. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7892. .channel_mode = alc262_modes,
  7893. .input_mux = &alc262_capture_source,
  7894. .unsol_event = alc262_hippo_unsol_event,
  7895. .init_hook = alc262_hippo_automute,
  7896. },
  7897. [ALC262_HIPPO_1] = {
  7898. .mixers = { alc262_hippo1_mixer },
  7899. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7900. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7901. .dac_nids = alc262_dac_nids,
  7902. .hp_nid = 0x02,
  7903. .dig_out_nid = ALC262_DIGOUT_NID,
  7904. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7905. .channel_mode = alc262_modes,
  7906. .input_mux = &alc262_capture_source,
  7907. .unsol_event = alc262_hippo1_unsol_event,
  7908. .init_hook = alc262_hippo1_automute,
  7909. },
  7910. [ALC262_FUJITSU] = {
  7911. .mixers = { alc262_fujitsu_mixer },
  7912. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs,
  7913. alc262_fujitsu_unsol_verbs },
  7914. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7915. .dac_nids = alc262_dac_nids,
  7916. .hp_nid = 0x03,
  7917. .dig_out_nid = ALC262_DIGOUT_NID,
  7918. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7919. .channel_mode = alc262_modes,
  7920. .input_mux = &alc262_fujitsu_capture_source,
  7921. .unsol_event = alc262_fujitsu_unsol_event,
  7922. },
  7923. [ALC262_HP_BPC] = {
  7924. .mixers = { alc262_HP_BPC_mixer },
  7925. .init_verbs = { alc262_HP_BPC_init_verbs },
  7926. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7927. .dac_nids = alc262_dac_nids,
  7928. .hp_nid = 0x03,
  7929. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7930. .channel_mode = alc262_modes,
  7931. .input_mux = &alc262_HP_capture_source,
  7932. },
  7933. [ALC262_HP_BPC_D7000_WF] = {
  7934. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7935. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7936. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7937. .dac_nids = alc262_dac_nids,
  7938. .hp_nid = 0x03,
  7939. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7940. .channel_mode = alc262_modes,
  7941. .input_mux = &alc262_HP_D7000_capture_source,
  7942. },
  7943. [ALC262_HP_BPC_D7000_WL] = {
  7944. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7945. alc262_HP_BPC_WildWest_option_mixer },
  7946. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7947. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7948. .dac_nids = alc262_dac_nids,
  7949. .hp_nid = 0x03,
  7950. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7951. .channel_mode = alc262_modes,
  7952. .input_mux = &alc262_HP_D7000_capture_source,
  7953. },
  7954. [ALC262_HP_TC_T5735] = {
  7955. .mixers = { alc262_hp_t5735_mixer },
  7956. .init_verbs = { alc262_init_verbs, alc262_hp_t5735_verbs },
  7957. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7958. .dac_nids = alc262_dac_nids,
  7959. .hp_nid = 0x03,
  7960. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7961. .channel_mode = alc262_modes,
  7962. .input_mux = &alc262_capture_source,
  7963. .unsol_event = alc262_hp_t5735_unsol_event,
  7964. .init_hook = alc262_hp_t5735_init_hook,
  7965. },
  7966. [ALC262_BENQ_ED8] = {
  7967. .mixers = { alc262_base_mixer },
  7968. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7969. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7970. .dac_nids = alc262_dac_nids,
  7971. .hp_nid = 0x03,
  7972. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7973. .channel_mode = alc262_modes,
  7974. .input_mux = &alc262_capture_source,
  7975. },
  7976. [ALC262_SONY_ASSAMD] = {
  7977. .mixers = { alc262_sony_mixer },
  7978. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7979. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7980. .dac_nids = alc262_dac_nids,
  7981. .hp_nid = 0x02,
  7982. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7983. .channel_mode = alc262_modes,
  7984. .input_mux = &alc262_capture_source,
  7985. .unsol_event = alc262_hippo_unsol_event,
  7986. .init_hook = alc262_hippo_automute,
  7987. },
  7988. [ALC262_BENQ_T31] = {
  7989. .mixers = { alc262_benq_t31_mixer },
  7990. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7991. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7992. .dac_nids = alc262_dac_nids,
  7993. .hp_nid = 0x03,
  7994. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7995. .channel_mode = alc262_modes,
  7996. .input_mux = &alc262_capture_source,
  7997. .unsol_event = alc262_hippo_unsol_event,
  7998. .init_hook = alc262_hippo_automute,
  7999. },
  8000. [ALC262_ULTRA] = {
  8001. .mixers = { alc262_ultra_mixer },
  8002. .init_verbs = { alc262_init_verbs, alc262_ultra_verbs },
  8003. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  8004. .dac_nids = alc262_dac_nids,
  8005. .hp_nid = 0x03,
  8006. .dig_out_nid = ALC262_DIGOUT_NID,
  8007. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  8008. .channel_mode = alc262_modes,
  8009. .input_mux = &alc262_ultra_capture_source,
  8010. .unsol_event = alc262_ultra_unsol_event,
  8011. .init_hook = alc262_ultra_automute,
  8012. },
  8013. };
  8014. static int patch_alc262(struct hda_codec *codec)
  8015. {
  8016. struct alc_spec *spec;
  8017. int board_config;
  8018. int err;
  8019. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8020. if (spec == NULL)
  8021. return -ENOMEM;
  8022. codec->spec = spec;
  8023. #if 0
  8024. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  8025. * under-run
  8026. */
  8027. {
  8028. int tmp;
  8029. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  8030. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  8031. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  8032. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  8033. }
  8034. #endif
  8035. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  8036. alc262_models,
  8037. alc262_cfg_tbl);
  8038. if (board_config < 0) {
  8039. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  8040. "trying auto-probe from BIOS...\n");
  8041. board_config = ALC262_AUTO;
  8042. }
  8043. if (board_config == ALC262_AUTO) {
  8044. /* automatic parse from the BIOS config */
  8045. err = alc262_parse_auto_config(codec);
  8046. if (err < 0) {
  8047. alc_free(codec);
  8048. return err;
  8049. } else if (!err) {
  8050. printk(KERN_INFO
  8051. "hda_codec: Cannot set up configuration "
  8052. "from BIOS. Using base mode...\n");
  8053. board_config = ALC262_BASIC;
  8054. }
  8055. }
  8056. if (board_config != ALC262_AUTO)
  8057. setup_preset(spec, &alc262_presets[board_config]);
  8058. spec->stream_name_analog = "ALC262 Analog";
  8059. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  8060. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  8061. spec->stream_name_digital = "ALC262 Digital";
  8062. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  8063. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  8064. if (!spec->adc_nids && spec->input_mux) {
  8065. /* check whether NID 0x07 is valid */
  8066. unsigned int wcap = get_wcaps(codec, 0x07);
  8067. /* get type */
  8068. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8069. if (wcap != AC_WID_AUD_IN) {
  8070. spec->adc_nids = alc262_adc_nids_alt;
  8071. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  8072. spec->mixers[spec->num_mixers] =
  8073. alc262_capture_alt_mixer;
  8074. spec->num_mixers++;
  8075. } else {
  8076. spec->adc_nids = alc262_adc_nids;
  8077. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  8078. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  8079. spec->num_mixers++;
  8080. }
  8081. }
  8082. codec->patch_ops = alc_patch_ops;
  8083. if (board_config == ALC262_AUTO)
  8084. spec->init_hook = alc262_auto_init;
  8085. #ifdef CONFIG_SND_HDA_POWER_SAVE
  8086. if (!spec->loopback.amplist)
  8087. spec->loopback.amplist = alc262_loopbacks;
  8088. #endif
  8089. return 0;
  8090. }
  8091. /*
  8092. * ALC268 channel source setting (2 channel)
  8093. */
  8094. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  8095. #define alc268_modes alc260_modes
  8096. static hda_nid_t alc268_dac_nids[2] = {
  8097. /* front, hp */
  8098. 0x02, 0x03
  8099. };
  8100. static hda_nid_t alc268_adc_nids[2] = {
  8101. /* ADC0-1 */
  8102. 0x08, 0x07
  8103. };
  8104. static hda_nid_t alc268_adc_nids_alt[1] = {
  8105. /* ADC0 */
  8106. 0x08
  8107. };
  8108. static struct snd_kcontrol_new alc268_base_mixer[] = {
  8109. /* output mixer control */
  8110. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  8111. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8112. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  8113. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8114. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8115. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8116. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  8117. { }
  8118. };
  8119. static struct hda_verb alc268_eapd_verbs[] = {
  8120. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8121. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8122. { }
  8123. };
  8124. /* Toshiba specific */
  8125. #define alc268_toshiba_automute alc262_hippo_automute
  8126. static struct hda_verb alc268_toshiba_verbs[] = {
  8127. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  8128. { } /* end */
  8129. };
  8130. /* Acer specific */
  8131. /* bind volumes of both NID 0x02 and 0x03 */
  8132. static struct hda_bind_ctls alc268_acer_bind_master_vol = {
  8133. .ops = &snd_hda_bind_vol,
  8134. .values = {
  8135. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  8136. HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
  8137. 0
  8138. },
  8139. };
  8140. /* mute/unmute internal speaker according to the hp jack and mute state */
  8141. static void alc268_acer_automute(struct hda_codec *codec, int force)
  8142. {
  8143. struct alc_spec *spec = codec->spec;
  8144. unsigned int mute;
  8145. if (force || !spec->sense_updated) {
  8146. unsigned int present;
  8147. present = snd_hda_codec_read(codec, 0x14, 0,
  8148. AC_VERB_GET_PIN_SENSE, 0);
  8149. spec->jack_present = (present & 0x80000000) != 0;
  8150. spec->sense_updated = 1;
  8151. }
  8152. if (spec->jack_present)
  8153. mute = HDA_AMP_MUTE; /* mute internal speaker */
  8154. else /* unmute internal speaker if necessary */
  8155. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  8156. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  8157. HDA_AMP_MUTE, mute);
  8158. }
  8159. /* bind hp and internal speaker mute (with plug check) */
  8160. static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
  8161. struct snd_ctl_elem_value *ucontrol)
  8162. {
  8163. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8164. long *valp = ucontrol->value.integer.value;
  8165. int change;
  8166. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  8167. HDA_AMP_MUTE,
  8168. valp[0] ? 0 : HDA_AMP_MUTE);
  8169. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  8170. HDA_AMP_MUTE,
  8171. valp[1] ? 0 : HDA_AMP_MUTE);
  8172. if (change)
  8173. alc268_acer_automute(codec, 0);
  8174. return change;
  8175. }
  8176. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  8177. /* output mixer control */
  8178. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  8179. {
  8180. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8181. .name = "Master Playback Switch",
  8182. .info = snd_hda_mixer_amp_switch_info,
  8183. .get = snd_hda_mixer_amp_switch_get,
  8184. .put = alc268_acer_master_sw_put,
  8185. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  8186. },
  8187. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8188. HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
  8189. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  8190. { }
  8191. };
  8192. static struct hda_verb alc268_acer_verbs[] = {
  8193. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8194. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8195. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  8196. { }
  8197. };
  8198. /* unsolicited event for HP jack sensing */
  8199. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  8200. unsigned int res)
  8201. {
  8202. if ((res >> 26) != ALC880_HP_EVENT)
  8203. return;
  8204. alc268_toshiba_automute(codec);
  8205. }
  8206. static void alc268_acer_unsol_event(struct hda_codec *codec,
  8207. unsigned int res)
  8208. {
  8209. if ((res >> 26) != ALC880_HP_EVENT)
  8210. return;
  8211. alc268_acer_automute(codec, 1);
  8212. }
  8213. static void alc268_acer_init_hook(struct hda_codec *codec)
  8214. {
  8215. alc268_acer_automute(codec, 1);
  8216. }
  8217. /*
  8218. * generic initialization of ADC, input mixers and output mixers
  8219. */
  8220. static struct hda_verb alc268_base_init_verbs[] = {
  8221. /* Unmute DAC0-1 and set vol = 0 */
  8222. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8223. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8224. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8225. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8226. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8227. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8228. /*
  8229. * Set up output mixers (0x0c - 0x0e)
  8230. */
  8231. /* set vol=0 to output mixers */
  8232. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8233. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8234. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8235. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  8236. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8237. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8238. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  8239. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  8240. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  8241. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8242. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8243. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8244. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8245. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8246. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8247. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8248. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8249. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8250. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8251. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8252. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8253. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8254. /* FIXME: use matrix-type input source selection */
  8255. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  8256. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  8257. /* Input mixer2 */
  8258. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8259. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  8260. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  8261. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  8262. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  8263. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  8264. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  8265. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  8266. { }
  8267. };
  8268. /*
  8269. * generic initialization of ADC, input mixers and output mixers
  8270. */
  8271. static struct hda_verb alc268_volume_init_verbs[] = {
  8272. /* set output DAC */
  8273. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8274. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8275. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8276. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8277. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8278. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  8279. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8280. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8281. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  8282. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8283. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8284. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8285. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8286. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8287. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8288. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8289. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8290. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8291. /* set PCBEEP vol = 0 */
  8292. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  8293. { }
  8294. };
  8295. #define alc268_mux_enum_info alc_mux_enum_info
  8296. #define alc268_mux_enum_get alc_mux_enum_get
  8297. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  8298. struct snd_ctl_elem_value *ucontrol)
  8299. {
  8300. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8301. struct alc_spec *spec = codec->spec;
  8302. const struct hda_input_mux *imux = spec->input_mux;
  8303. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8304. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  8305. hda_nid_t nid = capture_mixers[adc_idx];
  8306. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8307. unsigned int i, idx;
  8308. idx = ucontrol->value.enumerated.item[0];
  8309. if (idx >= imux->num_items)
  8310. idx = imux->num_items - 1;
  8311. if (*cur_val == idx)
  8312. return 0;
  8313. for (i = 0; i < imux->num_items; i++) {
  8314. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  8315. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  8316. imux->items[i].index,
  8317. HDA_AMP_MUTE, v);
  8318. snd_hda_codec_write_cache(codec, nid, 0,
  8319. AC_VERB_SET_CONNECT_SEL,
  8320. idx );
  8321. }
  8322. *cur_val = idx;
  8323. return 1;
  8324. }
  8325. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  8326. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8327. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8328. {
  8329. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8330. /* The multiple "Capture Source" controls confuse alsamixer
  8331. * So call somewhat different..
  8332. * FIXME: the controls appear in the "playback" view!
  8333. */
  8334. /* .name = "Capture Source", */
  8335. .name = "Input Source",
  8336. .count = 1,
  8337. .info = alc268_mux_enum_info,
  8338. .get = alc268_mux_enum_get,
  8339. .put = alc268_mux_enum_put,
  8340. },
  8341. { } /* end */
  8342. };
  8343. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  8344. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  8345. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  8346. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  8347. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  8348. {
  8349. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8350. /* The multiple "Capture Source" controls confuse alsamixer
  8351. * So call somewhat different..
  8352. * FIXME: the controls appear in the "playback" view!
  8353. */
  8354. /* .name = "Capture Source", */
  8355. .name = "Input Source",
  8356. .count = 2,
  8357. .info = alc268_mux_enum_info,
  8358. .get = alc268_mux_enum_get,
  8359. .put = alc268_mux_enum_put,
  8360. },
  8361. { } /* end */
  8362. };
  8363. static struct hda_input_mux alc268_capture_source = {
  8364. .num_items = 4,
  8365. .items = {
  8366. { "Mic", 0x0 },
  8367. { "Front Mic", 0x1 },
  8368. { "Line", 0x2 },
  8369. { "CD", 0x3 },
  8370. },
  8371. };
  8372. /* create input playback/capture controls for the given pin */
  8373. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  8374. const char *ctlname, int idx)
  8375. {
  8376. char name[32];
  8377. int err;
  8378. sprintf(name, "%s Playback Volume", ctlname);
  8379. if (nid == 0x14) {
  8380. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8381. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  8382. HDA_OUTPUT));
  8383. if (err < 0)
  8384. return err;
  8385. } else if (nid == 0x15) {
  8386. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8387. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  8388. HDA_OUTPUT));
  8389. if (err < 0)
  8390. return err;
  8391. } else
  8392. return -1;
  8393. sprintf(name, "%s Playback Switch", ctlname);
  8394. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8395. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  8396. if (err < 0)
  8397. return err;
  8398. return 0;
  8399. }
  8400. /* add playback controls from the parsed DAC table */
  8401. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  8402. const struct auto_pin_cfg *cfg)
  8403. {
  8404. hda_nid_t nid;
  8405. int err;
  8406. spec->multiout.num_dacs = 2; /* only use one dac */
  8407. spec->multiout.dac_nids = spec->private_dac_nids;
  8408. spec->multiout.dac_nids[0] = 2;
  8409. spec->multiout.dac_nids[1] = 3;
  8410. nid = cfg->line_out_pins[0];
  8411. if (nid)
  8412. alc268_new_analog_output(spec, nid, "Front", 0);
  8413. nid = cfg->speaker_pins[0];
  8414. if (nid == 0x1d) {
  8415. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8416. "Speaker Playback Volume",
  8417. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  8418. if (err < 0)
  8419. return err;
  8420. }
  8421. nid = cfg->hp_pins[0];
  8422. if (nid)
  8423. alc268_new_analog_output(spec, nid, "Headphone", 0);
  8424. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  8425. if (nid == 0x16) {
  8426. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8427. "Mono Playback Switch",
  8428. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  8429. if (err < 0)
  8430. return err;
  8431. }
  8432. return 0;
  8433. }
  8434. /* create playback/capture controls for input pins */
  8435. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  8436. const struct auto_pin_cfg *cfg)
  8437. {
  8438. struct hda_input_mux *imux = &spec->private_imux;
  8439. int i, idx1;
  8440. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8441. switch(cfg->input_pins[i]) {
  8442. case 0x18:
  8443. idx1 = 0; /* Mic 1 */
  8444. break;
  8445. case 0x19:
  8446. idx1 = 1; /* Mic 2 */
  8447. break;
  8448. case 0x1a:
  8449. idx1 = 2; /* Line In */
  8450. break;
  8451. case 0x1c:
  8452. idx1 = 3; /* CD */
  8453. break;
  8454. default:
  8455. continue;
  8456. }
  8457. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8458. imux->items[imux->num_items].index = idx1;
  8459. imux->num_items++;
  8460. }
  8461. return 0;
  8462. }
  8463. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  8464. {
  8465. struct alc_spec *spec = codec->spec;
  8466. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  8467. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  8468. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  8469. unsigned int dac_vol1, dac_vol2;
  8470. if (speaker_nid) {
  8471. snd_hda_codec_write(codec, speaker_nid, 0,
  8472. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  8473. snd_hda_codec_write(codec, 0x0f, 0,
  8474. AC_VERB_SET_AMP_GAIN_MUTE,
  8475. AMP_IN_UNMUTE(1));
  8476. snd_hda_codec_write(codec, 0x10, 0,
  8477. AC_VERB_SET_AMP_GAIN_MUTE,
  8478. AMP_IN_UNMUTE(1));
  8479. } else {
  8480. snd_hda_codec_write(codec, 0x0f, 0,
  8481. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8482. snd_hda_codec_write(codec, 0x10, 0,
  8483. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8484. }
  8485. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  8486. if (line_nid == 0x14)
  8487. dac_vol2 = AMP_OUT_ZERO;
  8488. else if (line_nid == 0x15)
  8489. dac_vol1 = AMP_OUT_ZERO;
  8490. if (hp_nid == 0x14)
  8491. dac_vol2 = AMP_OUT_ZERO;
  8492. else if (hp_nid == 0x15)
  8493. dac_vol1 = AMP_OUT_ZERO;
  8494. if (line_nid != 0x16 || hp_nid != 0x16 ||
  8495. spec->autocfg.line_out_pins[1] != 0x16 ||
  8496. spec->autocfg.line_out_pins[2] != 0x16)
  8497. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  8498. snd_hda_codec_write(codec, 0x02, 0,
  8499. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  8500. snd_hda_codec_write(codec, 0x03, 0,
  8501. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  8502. }
  8503. /* pcm configuration: identiacal with ALC880 */
  8504. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  8505. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  8506. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  8507. /*
  8508. * BIOS auto configuration
  8509. */
  8510. static int alc268_parse_auto_config(struct hda_codec *codec)
  8511. {
  8512. struct alc_spec *spec = codec->spec;
  8513. int err;
  8514. static hda_nid_t alc268_ignore[] = { 0 };
  8515. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8516. alc268_ignore);
  8517. if (err < 0)
  8518. return err;
  8519. if (!spec->autocfg.line_outs)
  8520. return 0; /* can't find valid BIOS pin config */
  8521. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8522. if (err < 0)
  8523. return err;
  8524. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8525. if (err < 0)
  8526. return err;
  8527. spec->multiout.max_channels = 2;
  8528. /* digital only support output */
  8529. if (spec->autocfg.dig_out_pin)
  8530. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  8531. if (spec->kctl_alloc)
  8532. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8533. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  8534. spec->num_mux_defs = 1;
  8535. spec->input_mux = &spec->private_imux;
  8536. err = alc_auto_add_mic_boost(codec);
  8537. if (err < 0)
  8538. return err;
  8539. return 1;
  8540. }
  8541. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  8542. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  8543. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  8544. /* init callback for auto-configuration model -- overriding the default init */
  8545. static void alc268_auto_init(struct hda_codec *codec)
  8546. {
  8547. alc268_auto_init_multi_out(codec);
  8548. alc268_auto_init_hp_out(codec);
  8549. alc268_auto_init_mono_speaker_out(codec);
  8550. alc268_auto_init_analog_input(codec);
  8551. }
  8552. /*
  8553. * configuration and preset
  8554. */
  8555. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8556. [ALC268_3ST] = "3stack",
  8557. [ALC268_TOSHIBA] = "toshiba",
  8558. [ALC268_ACER] = "acer",
  8559. [ALC268_AUTO] = "auto",
  8560. };
  8561. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8562. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8563. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8564. SND_PCI_QUIRK(0x1179, 0xff50, "TOSHIBA A305", ALC268_TOSHIBA),
  8565. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8566. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8567. SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
  8568. SND_PCI_QUIRK(0x152d, 0x0763, "Diverse (CPR2000)", ALC268_ACER),
  8569. {}
  8570. };
  8571. static struct alc_config_preset alc268_presets[] = {
  8572. [ALC268_3ST] = {
  8573. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8574. .init_verbs = { alc268_base_init_verbs },
  8575. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8576. .dac_nids = alc268_dac_nids,
  8577. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8578. .adc_nids = alc268_adc_nids_alt,
  8579. .hp_nid = 0x03,
  8580. .dig_out_nid = ALC268_DIGOUT_NID,
  8581. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8582. .channel_mode = alc268_modes,
  8583. .input_mux = &alc268_capture_source,
  8584. },
  8585. [ALC268_TOSHIBA] = {
  8586. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8587. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8588. alc268_toshiba_verbs },
  8589. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8590. .dac_nids = alc268_dac_nids,
  8591. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8592. .adc_nids = alc268_adc_nids_alt,
  8593. .hp_nid = 0x03,
  8594. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8595. .channel_mode = alc268_modes,
  8596. .input_mux = &alc268_capture_source,
  8597. .unsol_event = alc268_toshiba_unsol_event,
  8598. .init_hook = alc268_toshiba_automute,
  8599. },
  8600. [ALC268_ACER] = {
  8601. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8602. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8603. alc268_acer_verbs },
  8604. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8605. .dac_nids = alc268_dac_nids,
  8606. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8607. .adc_nids = alc268_adc_nids_alt,
  8608. .hp_nid = 0x02,
  8609. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8610. .channel_mode = alc268_modes,
  8611. .input_mux = &alc268_capture_source,
  8612. .unsol_event = alc268_acer_unsol_event,
  8613. .init_hook = alc268_acer_init_hook,
  8614. },
  8615. };
  8616. static int patch_alc268(struct hda_codec *codec)
  8617. {
  8618. struct alc_spec *spec;
  8619. int board_config;
  8620. int err;
  8621. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8622. if (spec == NULL)
  8623. return -ENOMEM;
  8624. codec->spec = spec;
  8625. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8626. alc268_models,
  8627. alc268_cfg_tbl);
  8628. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8629. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8630. "trying auto-probe from BIOS...\n");
  8631. board_config = ALC268_AUTO;
  8632. }
  8633. if (board_config == ALC268_AUTO) {
  8634. /* automatic parse from the BIOS config */
  8635. err = alc268_parse_auto_config(codec);
  8636. if (err < 0) {
  8637. alc_free(codec);
  8638. return err;
  8639. } else if (!err) {
  8640. printk(KERN_INFO
  8641. "hda_codec: Cannot set up configuration "
  8642. "from BIOS. Using base mode...\n");
  8643. board_config = ALC268_3ST;
  8644. }
  8645. }
  8646. if (board_config != ALC268_AUTO)
  8647. setup_preset(spec, &alc268_presets[board_config]);
  8648. spec->stream_name_analog = "ALC268 Analog";
  8649. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8650. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8651. spec->stream_name_digital = "ALC268 Digital";
  8652. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8653. if (board_config == ALC268_AUTO) {
  8654. if (!spec->adc_nids && spec->input_mux) {
  8655. /* check whether NID 0x07 is valid */
  8656. unsigned int wcap = get_wcaps(codec, 0x07);
  8657. /* get type */
  8658. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8659. if (wcap != AC_WID_AUD_IN) {
  8660. spec->adc_nids = alc268_adc_nids_alt;
  8661. spec->num_adc_nids =
  8662. ARRAY_SIZE(alc268_adc_nids_alt);
  8663. spec->mixers[spec->num_mixers] =
  8664. alc268_capture_alt_mixer;
  8665. spec->num_mixers++;
  8666. } else {
  8667. spec->adc_nids = alc268_adc_nids;
  8668. spec->num_adc_nids =
  8669. ARRAY_SIZE(alc268_adc_nids);
  8670. spec->mixers[spec->num_mixers] =
  8671. alc268_capture_mixer;
  8672. spec->num_mixers++;
  8673. }
  8674. }
  8675. }
  8676. codec->patch_ops = alc_patch_ops;
  8677. if (board_config == ALC268_AUTO)
  8678. spec->init_hook = alc268_auto_init;
  8679. return 0;
  8680. }
  8681. /*
  8682. * ALC269 channel source setting (2 channel)
  8683. */
  8684. #define ALC269_DIGOUT_NID ALC880_DIGOUT_NID
  8685. #define alc269_dac_nids alc260_dac_nids
  8686. static hda_nid_t alc269_adc_nids[1] = {
  8687. /* ADC1 */
  8688. 0x07,
  8689. };
  8690. #define alc269_modes alc260_modes
  8691. #define alc269_capture_source alc880_lg_lw_capture_source
  8692. static struct snd_kcontrol_new alc269_base_mixer[] = {
  8693. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  8694. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  8695. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  8696. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  8697. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  8698. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  8699. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  8700. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  8701. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  8702. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  8703. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8704. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  8705. { } /* end */
  8706. };
  8707. /* capture mixer elements */
  8708. static struct snd_kcontrol_new alc269_capture_mixer[] = {
  8709. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  8710. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  8711. {
  8712. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8713. /* The multiple "Capture Source" controls confuse alsamixer
  8714. * So call somewhat different..
  8715. * FIXME: the controls appear in the "playback" view!
  8716. */
  8717. /* .name = "Capture Source", */
  8718. .name = "Input Source",
  8719. .count = 1,
  8720. .info = alc_mux_enum_info,
  8721. .get = alc_mux_enum_get,
  8722. .put = alc_mux_enum_put,
  8723. },
  8724. { } /* end */
  8725. };
  8726. /*
  8727. * generic initialization of ADC, input mixers and output mixers
  8728. */
  8729. static struct hda_verb alc269_init_verbs[] = {
  8730. /*
  8731. * Unmute ADC0 and set the default input to mic-in
  8732. */
  8733. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8734. /* Mute input amps (PCBeep, Line In, Mic 1 & Mic 2) of the
  8735. * analog-loopback mixer widget
  8736. * Note: PASD motherboards uses the Line In 2 as the input for
  8737. * front panel mic (mic 2)
  8738. */
  8739. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  8740. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8741. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8742. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  8743. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  8744. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  8745. /*
  8746. * Set up output mixers (0x0c - 0x0e)
  8747. */
  8748. /* set vol=0 to output mixers */
  8749. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8750. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  8751. /* set up input amps for analog loopback */
  8752. /* Amp Indices: DAC = 0, mixer = 1 */
  8753. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8754. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8755. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8756. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8757. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8758. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8759. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8760. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  8761. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  8762. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8763. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  8764. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8765. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  8766. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8767. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8768. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8769. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8770. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8771. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8772. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8773. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  8774. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  8775. /* FIXME: use matrix-type input source selection */
  8776. /* Mixer elements: 0x18, 19, 1a, 1b, 1d, 0b */
  8777. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  8778. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8779. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8780. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  8781. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  8782. /* set EAPD */
  8783. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8784. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  8785. { }
  8786. };
  8787. /* add playback controls from the parsed DAC table */
  8788. static int alc269_auto_create_multi_out_ctls(struct alc_spec *spec,
  8789. const struct auto_pin_cfg *cfg)
  8790. {
  8791. hda_nid_t nid;
  8792. int err;
  8793. spec->multiout.num_dacs = 1; /* only use one dac */
  8794. spec->multiout.dac_nids = spec->private_dac_nids;
  8795. spec->multiout.dac_nids[0] = 2;
  8796. nid = cfg->line_out_pins[0];
  8797. if (nid) {
  8798. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8799. "Front Playback Volume",
  8800. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT));
  8801. if (err < 0)
  8802. return err;
  8803. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8804. "Front Playback Switch",
  8805. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8806. if (err < 0)
  8807. return err;
  8808. }
  8809. nid = cfg->speaker_pins[0];
  8810. if (nid) {
  8811. if (!cfg->line_out_pins[0]) {
  8812. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8813. "Speaker Playback Volume",
  8814. HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
  8815. HDA_OUTPUT));
  8816. if (err < 0)
  8817. return err;
  8818. }
  8819. if (nid == 0x16) {
  8820. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8821. "Speaker Playback Switch",
  8822. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8823. HDA_OUTPUT));
  8824. if (err < 0)
  8825. return err;
  8826. } else {
  8827. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8828. "Speaker Playback Switch",
  8829. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8830. HDA_OUTPUT));
  8831. if (err < 0)
  8832. return err;
  8833. }
  8834. }
  8835. nid = cfg->hp_pins[0];
  8836. if (nid) {
  8837. /* spec->multiout.hp_nid = 2; */
  8838. if (!cfg->line_out_pins[0] && !cfg->speaker_pins[0]) {
  8839. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8840. "Headphone Playback Volume",
  8841. HDA_COMPOSE_AMP_VAL(0x02, 3, 0,
  8842. HDA_OUTPUT));
  8843. if (err < 0)
  8844. return err;
  8845. }
  8846. if (nid == 0x16) {
  8847. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8848. "Headphone Playback Switch",
  8849. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8850. HDA_OUTPUT));
  8851. if (err < 0)
  8852. return err;
  8853. } else {
  8854. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8855. "Headphone Playback Switch",
  8856. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8857. HDA_OUTPUT));
  8858. if (err < 0)
  8859. return err;
  8860. }
  8861. }
  8862. return 0;
  8863. }
  8864. #define alc269_auto_create_analog_input_ctls \
  8865. alc880_auto_create_analog_input_ctls
  8866. #ifdef CONFIG_SND_HDA_POWER_SAVE
  8867. #define alc269_loopbacks alc880_loopbacks
  8868. #endif
  8869. /* pcm configuration: identiacal with ALC880 */
  8870. #define alc269_pcm_analog_playback alc880_pcm_analog_playback
  8871. #define alc269_pcm_analog_capture alc880_pcm_analog_capture
  8872. #define alc269_pcm_digital_playback alc880_pcm_digital_playback
  8873. #define alc269_pcm_digital_capture alc880_pcm_digital_capture
  8874. /*
  8875. * BIOS auto configuration
  8876. */
  8877. static int alc269_parse_auto_config(struct hda_codec *codec)
  8878. {
  8879. struct alc_spec *spec = codec->spec;
  8880. int err;
  8881. static hda_nid_t alc269_ignore[] = { 0x1d, 0 };
  8882. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8883. alc269_ignore);
  8884. if (err < 0)
  8885. return err;
  8886. err = alc269_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8887. if (err < 0)
  8888. return err;
  8889. err = alc269_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8890. if (err < 0)
  8891. return err;
  8892. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8893. if (spec->autocfg.dig_out_pin)
  8894. spec->multiout.dig_out_nid = ALC269_DIGOUT_NID;
  8895. if (spec->kctl_alloc)
  8896. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8897. spec->init_verbs[spec->num_init_verbs++] = alc269_init_verbs;
  8898. spec->num_mux_defs = 1;
  8899. spec->input_mux = &spec->private_imux;
  8900. err = alc_auto_add_mic_boost(codec);
  8901. if (err < 0)
  8902. return err;
  8903. return 1;
  8904. }
  8905. #define alc269_auto_init_multi_out alc882_auto_init_multi_out
  8906. #define alc269_auto_init_hp_out alc882_auto_init_hp_out
  8907. #define alc269_auto_init_analog_input alc882_auto_init_analog_input
  8908. /* init callback for auto-configuration model -- overriding the default init */
  8909. static void alc269_auto_init(struct hda_codec *codec)
  8910. {
  8911. alc269_auto_init_multi_out(codec);
  8912. alc269_auto_init_hp_out(codec);
  8913. alc269_auto_init_analog_input(codec);
  8914. }
  8915. /*
  8916. * configuration and preset
  8917. */
  8918. static const char *alc269_models[ALC269_MODEL_LAST] = {
  8919. [ALC269_BASIC] = "basic",
  8920. };
  8921. static struct snd_pci_quirk alc269_cfg_tbl[] = {
  8922. {}
  8923. };
  8924. static struct alc_config_preset alc269_presets[] = {
  8925. [ALC269_BASIC] = {
  8926. .mixers = { alc269_base_mixer },
  8927. .init_verbs = { alc269_init_verbs },
  8928. .num_dacs = ARRAY_SIZE(alc269_dac_nids),
  8929. .dac_nids = alc269_dac_nids,
  8930. .hp_nid = 0x03,
  8931. .num_channel_mode = ARRAY_SIZE(alc269_modes),
  8932. .channel_mode = alc269_modes,
  8933. .input_mux = &alc269_capture_source,
  8934. },
  8935. };
  8936. static int patch_alc269(struct hda_codec *codec)
  8937. {
  8938. struct alc_spec *spec;
  8939. int board_config;
  8940. int err;
  8941. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8942. if (spec == NULL)
  8943. return -ENOMEM;
  8944. codec->spec = spec;
  8945. board_config = snd_hda_check_board_config(codec, ALC269_MODEL_LAST,
  8946. alc269_models,
  8947. alc269_cfg_tbl);
  8948. if (board_config < 0) {
  8949. printk(KERN_INFO "hda_codec: Unknown model for ALC269, "
  8950. "trying auto-probe from BIOS...\n");
  8951. board_config = ALC269_AUTO;
  8952. }
  8953. if (board_config == ALC269_AUTO) {
  8954. /* automatic parse from the BIOS config */
  8955. err = alc269_parse_auto_config(codec);
  8956. if (err < 0) {
  8957. alc_free(codec);
  8958. return err;
  8959. } else if (!err) {
  8960. printk(KERN_INFO
  8961. "hda_codec: Cannot set up configuration "
  8962. "from BIOS. Using base mode...\n");
  8963. board_config = ALC269_BASIC;
  8964. }
  8965. }
  8966. if (board_config != ALC269_AUTO)
  8967. setup_preset(spec, &alc269_presets[board_config]);
  8968. spec->stream_name_analog = "ALC269 Analog";
  8969. spec->stream_analog_playback = &alc269_pcm_analog_playback;
  8970. spec->stream_analog_capture = &alc269_pcm_analog_capture;
  8971. spec->stream_name_digital = "ALC269 Digital";
  8972. spec->stream_digital_playback = &alc269_pcm_digital_playback;
  8973. spec->stream_digital_capture = &alc269_pcm_digital_capture;
  8974. spec->adc_nids = alc269_adc_nids;
  8975. spec->num_adc_nids = ARRAY_SIZE(alc269_adc_nids);
  8976. spec->mixers[spec->num_mixers] = alc269_capture_mixer;
  8977. spec->num_mixers++;
  8978. codec->patch_ops = alc_patch_ops;
  8979. if (board_config == ALC269_AUTO)
  8980. spec->init_hook = alc269_auto_init;
  8981. #ifdef CONFIG_SND_HDA_POWER_SAVE
  8982. if (!spec->loopback.amplist)
  8983. spec->loopback.amplist = alc269_loopbacks;
  8984. #endif
  8985. return 0;
  8986. }
  8987. /*
  8988. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8989. */
  8990. /*
  8991. * set the path ways for 2 channel output
  8992. * need to set the codec line out and mic 1 pin widgets to inputs
  8993. */
  8994. static struct hda_verb alc861_threestack_ch2_init[] = {
  8995. /* set pin widget 1Ah (line in) for input */
  8996. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8997. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8998. * the vref
  8999. */
  9000. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9001. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  9002. #if 0
  9003. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  9004. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  9005. #endif
  9006. { } /* end */
  9007. };
  9008. /*
  9009. * 6ch mode
  9010. * need to set the codec line out and mic 1 pin widgets to outputs
  9011. */
  9012. static struct hda_verb alc861_threestack_ch6_init[] = {
  9013. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  9014. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9015. /* set pin widget 18h (mic1) for output (CLFE)*/
  9016. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9017. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9018. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9019. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  9020. #if 0
  9021. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  9022. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  9023. #endif
  9024. { } /* end */
  9025. };
  9026. static struct hda_channel_mode alc861_threestack_modes[2] = {
  9027. { 2, alc861_threestack_ch2_init },
  9028. { 6, alc861_threestack_ch6_init },
  9029. };
  9030. /* Set mic1 as input and unmute the mixer */
  9031. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  9032. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9033. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  9034. { } /* end */
  9035. };
  9036. /* Set mic1 as output and mute mixer */
  9037. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  9038. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9039. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  9040. { } /* end */
  9041. };
  9042. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  9043. { 2, alc861_uniwill_m31_ch2_init },
  9044. { 4, alc861_uniwill_m31_ch4_init },
  9045. };
  9046. /* Set mic1 and line-in as input and unmute the mixer */
  9047. static struct hda_verb alc861_asus_ch2_init[] = {
  9048. /* set pin widget 1Ah (line in) for input */
  9049. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9050. /* set pin widget 18h (mic1/2) for input, for mic also enable
  9051. * the vref
  9052. */
  9053. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9054. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  9055. #if 0
  9056. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  9057. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  9058. #endif
  9059. { } /* end */
  9060. };
  9061. /* Set mic1 nad line-in as output and mute mixer */
  9062. static struct hda_verb alc861_asus_ch6_init[] = {
  9063. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  9064. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9065. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  9066. /* set pin widget 18h (mic1) for output (CLFE)*/
  9067. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9068. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  9069. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9070. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9071. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  9072. #if 0
  9073. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  9074. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  9075. #endif
  9076. { } /* end */
  9077. };
  9078. static struct hda_channel_mode alc861_asus_modes[2] = {
  9079. { 2, alc861_asus_ch2_init },
  9080. { 6, alc861_asus_ch6_init },
  9081. };
  9082. /* patch-ALC861 */
  9083. static struct snd_kcontrol_new alc861_base_mixer[] = {
  9084. /* output mixer control */
  9085. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9086. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  9087. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  9088. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  9089. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  9090. /*Input mixer control */
  9091. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  9092. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  9093. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  9094. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  9095. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  9096. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  9097. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  9098. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  9099. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  9100. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  9101. /* Capture mixer control */
  9102. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9103. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9104. {
  9105. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9106. .name = "Capture Source",
  9107. .count = 1,
  9108. .info = alc_mux_enum_info,
  9109. .get = alc_mux_enum_get,
  9110. .put = alc_mux_enum_put,
  9111. },
  9112. { } /* end */
  9113. };
  9114. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  9115. /* output mixer control */
  9116. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9117. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  9118. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  9119. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  9120. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  9121. /* Input mixer control */
  9122. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  9123. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  9124. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  9125. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  9126. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  9127. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  9128. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  9129. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  9130. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  9131. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  9132. /* Capture mixer control */
  9133. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9134. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9135. {
  9136. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9137. .name = "Capture Source",
  9138. .count = 1,
  9139. .info = alc_mux_enum_info,
  9140. .get = alc_mux_enum_get,
  9141. .put = alc_mux_enum_put,
  9142. },
  9143. {
  9144. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9145. .name = "Channel Mode",
  9146. .info = alc_ch_mode_info,
  9147. .get = alc_ch_mode_get,
  9148. .put = alc_ch_mode_put,
  9149. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  9150. },
  9151. { } /* end */
  9152. };
  9153. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  9154. /* output mixer control */
  9155. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9156. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  9157. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  9158. /*Capture mixer control */
  9159. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9160. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9161. {
  9162. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9163. .name = "Capture Source",
  9164. .count = 1,
  9165. .info = alc_mux_enum_info,
  9166. .get = alc_mux_enum_get,
  9167. .put = alc_mux_enum_put,
  9168. },
  9169. { } /* end */
  9170. };
  9171. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  9172. /* output mixer control */
  9173. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9174. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  9175. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  9176. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  9177. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  9178. /* Input mixer control */
  9179. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  9180. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  9181. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  9182. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  9183. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  9184. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  9185. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  9186. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  9187. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  9188. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  9189. /* Capture mixer control */
  9190. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9191. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9192. {
  9193. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9194. .name = "Capture Source",
  9195. .count = 1,
  9196. .info = alc_mux_enum_info,
  9197. .get = alc_mux_enum_get,
  9198. .put = alc_mux_enum_put,
  9199. },
  9200. {
  9201. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9202. .name = "Channel Mode",
  9203. .info = alc_ch_mode_info,
  9204. .get = alc_ch_mode_get,
  9205. .put = alc_ch_mode_put,
  9206. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9207. },
  9208. { } /* end */
  9209. };
  9210. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  9211. /* output mixer control */
  9212. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9213. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  9214. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  9215. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  9216. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  9217. /* Input mixer control */
  9218. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  9219. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  9220. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  9221. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  9222. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  9223. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  9224. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  9225. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  9226. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  9227. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  9228. /* Capture mixer control */
  9229. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9230. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9231. {
  9232. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9233. .name = "Capture Source",
  9234. .count = 1,
  9235. .info = alc_mux_enum_info,
  9236. .get = alc_mux_enum_get,
  9237. .put = alc_mux_enum_put,
  9238. },
  9239. {
  9240. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9241. .name = "Channel Mode",
  9242. .info = alc_ch_mode_info,
  9243. .get = alc_ch_mode_get,
  9244. .put = alc_ch_mode_put,
  9245. .private_value = ARRAY_SIZE(alc861_asus_modes),
  9246. },
  9247. { }
  9248. };
  9249. /* additional mixer */
  9250. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  9251. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  9252. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  9253. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  9254. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  9255. { }
  9256. };
  9257. /*
  9258. * generic initialization of ADC, input mixers and output mixers
  9259. */
  9260. static struct hda_verb alc861_base_init_verbs[] = {
  9261. /*
  9262. * Unmute ADC0 and set the default input to mic-in
  9263. */
  9264. /* port-A for surround (rear panel) */
  9265. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9266. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9267. /* port-B for mic-in (rear panel) with vref */
  9268. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9269. /* port-C for line-in (rear panel) */
  9270. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9271. /* port-D for Front */
  9272. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9273. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9274. /* port-E for HP out (front panel) */
  9275. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  9276. /* route front PCM to HP */
  9277. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9278. /* port-F for mic-in (front panel) with vref */
  9279. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9280. /* port-G for CLFE (rear panel) */
  9281. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9282. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9283. /* port-H for side (rear panel) */
  9284. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9285. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9286. /* CD-in */
  9287. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9288. /* route front mic to ADC1*/
  9289. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9290. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9291. /* Unmute DAC0~3 & spdif out*/
  9292. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9293. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9294. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9295. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9296. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9297. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9298. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9299. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9300. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9301. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9302. /* Unmute Stereo Mixer 15 */
  9303. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9304. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9305. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9306. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9307. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9308. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9309. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9310. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9311. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9312. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9313. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9314. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9315. /* hp used DAC 3 (Front) */
  9316. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9317. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9318. { }
  9319. };
  9320. static struct hda_verb alc861_threestack_init_verbs[] = {
  9321. /*
  9322. * Unmute ADC0 and set the default input to mic-in
  9323. */
  9324. /* port-A for surround (rear panel) */
  9325. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9326. /* port-B for mic-in (rear panel) with vref */
  9327. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9328. /* port-C for line-in (rear panel) */
  9329. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9330. /* port-D for Front */
  9331. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9332. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9333. /* port-E for HP out (front panel) */
  9334. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  9335. /* route front PCM to HP */
  9336. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9337. /* port-F for mic-in (front panel) with vref */
  9338. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9339. /* port-G for CLFE (rear panel) */
  9340. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9341. /* port-H for side (rear panel) */
  9342. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9343. /* CD-in */
  9344. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9345. /* route front mic to ADC1*/
  9346. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9347. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9348. /* Unmute DAC0~3 & spdif out*/
  9349. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9350. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9351. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9352. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9353. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9354. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9355. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9356. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9357. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9358. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9359. /* Unmute Stereo Mixer 15 */
  9360. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9361. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9362. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9363. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9364. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9365. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9366. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9367. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9368. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9369. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9370. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9371. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9372. /* hp used DAC 3 (Front) */
  9373. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9374. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9375. { }
  9376. };
  9377. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  9378. /*
  9379. * Unmute ADC0 and set the default input to mic-in
  9380. */
  9381. /* port-A for surround (rear panel) */
  9382. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9383. /* port-B for mic-in (rear panel) with vref */
  9384. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9385. /* port-C for line-in (rear panel) */
  9386. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9387. /* port-D for Front */
  9388. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9389. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9390. /* port-E for HP out (front panel) */
  9391. /* this has to be set to VREF80 */
  9392. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9393. /* route front PCM to HP */
  9394. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9395. /* port-F for mic-in (front panel) with vref */
  9396. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9397. /* port-G for CLFE (rear panel) */
  9398. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9399. /* port-H for side (rear panel) */
  9400. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9401. /* CD-in */
  9402. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9403. /* route front mic to ADC1*/
  9404. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9405. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9406. /* Unmute DAC0~3 & spdif out*/
  9407. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9408. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9409. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9410. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9411. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9412. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9413. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9414. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9415. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9416. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9417. /* Unmute Stereo Mixer 15 */
  9418. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9419. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9420. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9421. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9422. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9423. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9424. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9425. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9426. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9427. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9428. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9429. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9430. /* hp used DAC 3 (Front) */
  9431. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9432. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9433. { }
  9434. };
  9435. static struct hda_verb alc861_asus_init_verbs[] = {
  9436. /*
  9437. * Unmute ADC0 and set the default input to mic-in
  9438. */
  9439. /* port-A for surround (rear panel)
  9440. * according to codec#0 this is the HP jack
  9441. */
  9442. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  9443. /* route front PCM to HP */
  9444. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9445. /* port-B for mic-in (rear panel) with vref */
  9446. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9447. /* port-C for line-in (rear panel) */
  9448. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9449. /* port-D for Front */
  9450. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9451. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9452. /* port-E for HP out (front panel) */
  9453. /* this has to be set to VREF80 */
  9454. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9455. /* route front PCM to HP */
  9456. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  9457. /* port-F for mic-in (front panel) with vref */
  9458. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  9459. /* port-G for CLFE (rear panel) */
  9460. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9461. /* port-H for side (rear panel) */
  9462. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  9463. /* CD-in */
  9464. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  9465. /* route front mic to ADC1*/
  9466. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  9467. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9468. /* Unmute DAC0~3 & spdif out*/
  9469. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9470. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9471. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9472. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9473. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9474. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9475. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9476. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9477. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9478. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9479. /* Unmute Stereo Mixer 15 */
  9480. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9481. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9482. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9483. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  9484. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9485. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9486. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9487. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9488. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9489. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9490. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9491. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9492. /* hp used DAC 3 (Front) */
  9493. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9494. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9495. { }
  9496. };
  9497. /* additional init verbs for ASUS laptops */
  9498. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  9499. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  9500. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  9501. { }
  9502. };
  9503. /*
  9504. * generic initialization of ADC, input mixers and output mixers
  9505. */
  9506. static struct hda_verb alc861_auto_init_verbs[] = {
  9507. /*
  9508. * Unmute ADC0 and set the default input to mic-in
  9509. */
  9510. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  9511. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9512. /* Unmute DAC0~3 & spdif out*/
  9513. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9514. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9515. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9516. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9517. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9518. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  9519. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9520. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9521. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9522. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9523. /* Unmute Stereo Mixer 15 */
  9524. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9525. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9526. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9527. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  9528. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9529. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9530. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9531. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9532. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9533. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9534. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9535. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9536. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9537. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9538. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9539. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9540. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9541. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9542. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9543. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9544. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  9545. { }
  9546. };
  9547. static struct hda_verb alc861_toshiba_init_verbs[] = {
  9548. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9549. { }
  9550. };
  9551. /* toggle speaker-output according to the hp-jack state */
  9552. static void alc861_toshiba_automute(struct hda_codec *codec)
  9553. {
  9554. unsigned int present;
  9555. present = snd_hda_codec_read(codec, 0x0f, 0,
  9556. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9557. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  9558. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9559. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  9560. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  9561. }
  9562. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  9563. unsigned int res)
  9564. {
  9565. if ((res >> 26) == ALC880_HP_EVENT)
  9566. alc861_toshiba_automute(codec);
  9567. }
  9568. /* pcm configuration: identiacal with ALC880 */
  9569. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  9570. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  9571. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  9572. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  9573. #define ALC861_DIGOUT_NID 0x07
  9574. static struct hda_channel_mode alc861_8ch_modes[1] = {
  9575. { 8, NULL }
  9576. };
  9577. static hda_nid_t alc861_dac_nids[4] = {
  9578. /* front, surround, clfe, side */
  9579. 0x03, 0x06, 0x05, 0x04
  9580. };
  9581. static hda_nid_t alc660_dac_nids[3] = {
  9582. /* front, clfe, surround */
  9583. 0x03, 0x05, 0x06
  9584. };
  9585. static hda_nid_t alc861_adc_nids[1] = {
  9586. /* ADC0-2 */
  9587. 0x08,
  9588. };
  9589. static struct hda_input_mux alc861_capture_source = {
  9590. .num_items = 5,
  9591. .items = {
  9592. { "Mic", 0x0 },
  9593. { "Front Mic", 0x3 },
  9594. { "Line", 0x1 },
  9595. { "CD", 0x4 },
  9596. { "Mixer", 0x5 },
  9597. },
  9598. };
  9599. /* fill in the dac_nids table from the parsed pin configuration */
  9600. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  9601. const struct auto_pin_cfg *cfg)
  9602. {
  9603. int i;
  9604. hda_nid_t nid;
  9605. spec->multiout.dac_nids = spec->private_dac_nids;
  9606. for (i = 0; i < cfg->line_outs; i++) {
  9607. nid = cfg->line_out_pins[i];
  9608. if (nid) {
  9609. if (i >= ARRAY_SIZE(alc861_dac_nids))
  9610. continue;
  9611. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  9612. }
  9613. }
  9614. spec->multiout.num_dacs = cfg->line_outs;
  9615. return 0;
  9616. }
  9617. /* add playback controls from the parsed DAC table */
  9618. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  9619. const struct auto_pin_cfg *cfg)
  9620. {
  9621. char name[32];
  9622. static const char *chname[4] = {
  9623. "Front", "Surround", NULL /*CLFE*/, "Side"
  9624. };
  9625. hda_nid_t nid;
  9626. int i, idx, err;
  9627. for (i = 0; i < cfg->line_outs; i++) {
  9628. nid = spec->multiout.dac_nids[i];
  9629. if (!nid)
  9630. continue;
  9631. if (nid == 0x05) {
  9632. /* Center/LFE */
  9633. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9634. "Center Playback Switch",
  9635. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  9636. HDA_OUTPUT));
  9637. if (err < 0)
  9638. return err;
  9639. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9640. "LFE Playback Switch",
  9641. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  9642. HDA_OUTPUT));
  9643. if (err < 0)
  9644. return err;
  9645. } else {
  9646. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  9647. idx++)
  9648. if (nid == alc861_dac_nids[idx])
  9649. break;
  9650. sprintf(name, "%s Playback Switch", chname[idx]);
  9651. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9652. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  9653. HDA_OUTPUT));
  9654. if (err < 0)
  9655. return err;
  9656. }
  9657. }
  9658. return 0;
  9659. }
  9660. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  9661. {
  9662. int err;
  9663. hda_nid_t nid;
  9664. if (!pin)
  9665. return 0;
  9666. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  9667. nid = 0x03;
  9668. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  9669. "Headphone Playback Switch",
  9670. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  9671. if (err < 0)
  9672. return err;
  9673. spec->multiout.hp_nid = nid;
  9674. }
  9675. return 0;
  9676. }
  9677. /* create playback/capture controls for input pins */
  9678. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  9679. const struct auto_pin_cfg *cfg)
  9680. {
  9681. struct hda_input_mux *imux = &spec->private_imux;
  9682. int i, err, idx, idx1;
  9683. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9684. switch (cfg->input_pins[i]) {
  9685. case 0x0c:
  9686. idx1 = 1;
  9687. idx = 2; /* Line In */
  9688. break;
  9689. case 0x0f:
  9690. idx1 = 2;
  9691. idx = 2; /* Line In */
  9692. break;
  9693. case 0x0d:
  9694. idx1 = 0;
  9695. idx = 1; /* Mic In */
  9696. break;
  9697. case 0x10:
  9698. idx1 = 3;
  9699. idx = 1; /* Mic In */
  9700. break;
  9701. case 0x11:
  9702. idx1 = 4;
  9703. idx = 0; /* CD */
  9704. break;
  9705. default:
  9706. continue;
  9707. }
  9708. err = new_analog_input(spec, cfg->input_pins[i],
  9709. auto_pin_cfg_labels[i], idx, 0x15);
  9710. if (err < 0)
  9711. return err;
  9712. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  9713. imux->items[imux->num_items].index = idx1;
  9714. imux->num_items++;
  9715. }
  9716. return 0;
  9717. }
  9718. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  9719. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9720. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9721. {
  9722. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9723. /* The multiple "Capture Source" controls confuse alsamixer
  9724. * So call somewhat different..
  9725. *FIXME: the controls appear in the "playback" view!
  9726. */
  9727. /* .name = "Capture Source", */
  9728. .name = "Input Source",
  9729. .count = 1,
  9730. .info = alc_mux_enum_info,
  9731. .get = alc_mux_enum_get,
  9732. .put = alc_mux_enum_put,
  9733. },
  9734. { } /* end */
  9735. };
  9736. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  9737. hda_nid_t nid,
  9738. int pin_type, int dac_idx)
  9739. {
  9740. /* set as output */
  9741. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  9742. pin_type);
  9743. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9744. AMP_OUT_UNMUTE);
  9745. }
  9746. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  9747. {
  9748. struct alc_spec *spec = codec->spec;
  9749. int i;
  9750. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  9751. for (i = 0; i < spec->autocfg.line_outs; i++) {
  9752. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9753. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9754. if (nid)
  9755. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  9756. spec->multiout.dac_nids[i]);
  9757. }
  9758. }
  9759. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  9760. {
  9761. struct alc_spec *spec = codec->spec;
  9762. hda_nid_t pin;
  9763. pin = spec->autocfg.hp_pins[0];
  9764. if (pin) /* connect to front */
  9765. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  9766. spec->multiout.dac_nids[0]);
  9767. }
  9768. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  9769. {
  9770. struct alc_spec *spec = codec->spec;
  9771. int i;
  9772. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9773. hda_nid_t nid = spec->autocfg.input_pins[i];
  9774. if (nid >= 0x0c && nid <= 0x11) {
  9775. snd_hda_codec_write(codec, nid, 0,
  9776. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9777. i <= AUTO_PIN_FRONT_MIC ?
  9778. PIN_VREF80 : PIN_IN);
  9779. }
  9780. }
  9781. }
  9782. /* parse the BIOS configuration and set up the alc_spec */
  9783. /* return 1 if successful, 0 if the proper config is not found,
  9784. * or a negative error code
  9785. */
  9786. static int alc861_parse_auto_config(struct hda_codec *codec)
  9787. {
  9788. struct alc_spec *spec = codec->spec;
  9789. int err;
  9790. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  9791. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9792. alc861_ignore);
  9793. if (err < 0)
  9794. return err;
  9795. if (!spec->autocfg.line_outs)
  9796. return 0; /* can't find valid BIOS pin config */
  9797. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  9798. if (err < 0)
  9799. return err;
  9800. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9801. if (err < 0)
  9802. return err;
  9803. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  9804. if (err < 0)
  9805. return err;
  9806. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9807. if (err < 0)
  9808. return err;
  9809. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9810. if (spec->autocfg.dig_out_pin)
  9811. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  9812. if (spec->kctl_alloc)
  9813. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9814. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  9815. spec->num_mux_defs = 1;
  9816. spec->input_mux = &spec->private_imux;
  9817. spec->adc_nids = alc861_adc_nids;
  9818. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  9819. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  9820. spec->num_mixers++;
  9821. return 1;
  9822. }
  9823. /* additional initialization for auto-configuration model */
  9824. static void alc861_auto_init(struct hda_codec *codec)
  9825. {
  9826. alc861_auto_init_multi_out(codec);
  9827. alc861_auto_init_hp_out(codec);
  9828. alc861_auto_init_analog_input(codec);
  9829. }
  9830. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9831. static struct hda_amp_list alc861_loopbacks[] = {
  9832. { 0x15, HDA_INPUT, 0 },
  9833. { 0x15, HDA_INPUT, 1 },
  9834. { 0x15, HDA_INPUT, 2 },
  9835. { 0x15, HDA_INPUT, 3 },
  9836. { } /* end */
  9837. };
  9838. #endif
  9839. /*
  9840. * configuration and preset
  9841. */
  9842. static const char *alc861_models[ALC861_MODEL_LAST] = {
  9843. [ALC861_3ST] = "3stack",
  9844. [ALC660_3ST] = "3stack-660",
  9845. [ALC861_3ST_DIG] = "3stack-dig",
  9846. [ALC861_6ST_DIG] = "6stack-dig",
  9847. [ALC861_UNIWILL_M31] = "uniwill-m31",
  9848. [ALC861_TOSHIBA] = "toshiba",
  9849. [ALC861_ASUS] = "asus",
  9850. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  9851. [ALC861_AUTO] = "auto",
  9852. };
  9853. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  9854. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9855. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9856. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9857. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9858. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9859. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9860. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9861. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9862. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9863. * Any other models that need this preset?
  9864. */
  9865. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9866. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9867. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  9868. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9869. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9870. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9871. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9872. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9873. {}
  9874. };
  9875. static struct alc_config_preset alc861_presets[] = {
  9876. [ALC861_3ST] = {
  9877. .mixers = { alc861_3ST_mixer },
  9878. .init_verbs = { alc861_threestack_init_verbs },
  9879. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9880. .dac_nids = alc861_dac_nids,
  9881. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9882. .channel_mode = alc861_threestack_modes,
  9883. .need_dac_fix = 1,
  9884. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9885. .adc_nids = alc861_adc_nids,
  9886. .input_mux = &alc861_capture_source,
  9887. },
  9888. [ALC861_3ST_DIG] = {
  9889. .mixers = { alc861_base_mixer },
  9890. .init_verbs = { alc861_threestack_init_verbs },
  9891. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9892. .dac_nids = alc861_dac_nids,
  9893. .dig_out_nid = ALC861_DIGOUT_NID,
  9894. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9895. .channel_mode = alc861_threestack_modes,
  9896. .need_dac_fix = 1,
  9897. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9898. .adc_nids = alc861_adc_nids,
  9899. .input_mux = &alc861_capture_source,
  9900. },
  9901. [ALC861_6ST_DIG] = {
  9902. .mixers = { alc861_base_mixer },
  9903. .init_verbs = { alc861_base_init_verbs },
  9904. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9905. .dac_nids = alc861_dac_nids,
  9906. .dig_out_nid = ALC861_DIGOUT_NID,
  9907. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  9908. .channel_mode = alc861_8ch_modes,
  9909. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9910. .adc_nids = alc861_adc_nids,
  9911. .input_mux = &alc861_capture_source,
  9912. },
  9913. [ALC660_3ST] = {
  9914. .mixers = { alc861_3ST_mixer },
  9915. .init_verbs = { alc861_threestack_init_verbs },
  9916. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  9917. .dac_nids = alc660_dac_nids,
  9918. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9919. .channel_mode = alc861_threestack_modes,
  9920. .need_dac_fix = 1,
  9921. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9922. .adc_nids = alc861_adc_nids,
  9923. .input_mux = &alc861_capture_source,
  9924. },
  9925. [ALC861_UNIWILL_M31] = {
  9926. .mixers = { alc861_uniwill_m31_mixer },
  9927. .init_verbs = { alc861_uniwill_m31_init_verbs },
  9928. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9929. .dac_nids = alc861_dac_nids,
  9930. .dig_out_nid = ALC861_DIGOUT_NID,
  9931. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9932. .channel_mode = alc861_uniwill_m31_modes,
  9933. .need_dac_fix = 1,
  9934. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9935. .adc_nids = alc861_adc_nids,
  9936. .input_mux = &alc861_capture_source,
  9937. },
  9938. [ALC861_TOSHIBA] = {
  9939. .mixers = { alc861_toshiba_mixer },
  9940. .init_verbs = { alc861_base_init_verbs,
  9941. alc861_toshiba_init_verbs },
  9942. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9943. .dac_nids = alc861_dac_nids,
  9944. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9945. .channel_mode = alc883_3ST_2ch_modes,
  9946. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9947. .adc_nids = alc861_adc_nids,
  9948. .input_mux = &alc861_capture_source,
  9949. .unsol_event = alc861_toshiba_unsol_event,
  9950. .init_hook = alc861_toshiba_automute,
  9951. },
  9952. [ALC861_ASUS] = {
  9953. .mixers = { alc861_asus_mixer },
  9954. .init_verbs = { alc861_asus_init_verbs },
  9955. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9956. .dac_nids = alc861_dac_nids,
  9957. .dig_out_nid = ALC861_DIGOUT_NID,
  9958. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  9959. .channel_mode = alc861_asus_modes,
  9960. .need_dac_fix = 1,
  9961. .hp_nid = 0x06,
  9962. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9963. .adc_nids = alc861_adc_nids,
  9964. .input_mux = &alc861_capture_source,
  9965. },
  9966. [ALC861_ASUS_LAPTOP] = {
  9967. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  9968. .init_verbs = { alc861_asus_init_verbs,
  9969. alc861_asus_laptop_init_verbs },
  9970. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9971. .dac_nids = alc861_dac_nids,
  9972. .dig_out_nid = ALC861_DIGOUT_NID,
  9973. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9974. .channel_mode = alc883_3ST_2ch_modes,
  9975. .need_dac_fix = 1,
  9976. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9977. .adc_nids = alc861_adc_nids,
  9978. .input_mux = &alc861_capture_source,
  9979. },
  9980. };
  9981. static int patch_alc861(struct hda_codec *codec)
  9982. {
  9983. struct alc_spec *spec;
  9984. int board_config;
  9985. int err;
  9986. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9987. if (spec == NULL)
  9988. return -ENOMEM;
  9989. codec->spec = spec;
  9990. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9991. alc861_models,
  9992. alc861_cfg_tbl);
  9993. if (board_config < 0) {
  9994. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9995. "trying auto-probe from BIOS...\n");
  9996. board_config = ALC861_AUTO;
  9997. }
  9998. if (board_config == ALC861_AUTO) {
  9999. /* automatic parse from the BIOS config */
  10000. err = alc861_parse_auto_config(codec);
  10001. if (err < 0) {
  10002. alc_free(codec);
  10003. return err;
  10004. } else if (!err) {
  10005. printk(KERN_INFO
  10006. "hda_codec: Cannot set up configuration "
  10007. "from BIOS. Using base mode...\n");
  10008. board_config = ALC861_3ST_DIG;
  10009. }
  10010. }
  10011. if (board_config != ALC861_AUTO)
  10012. setup_preset(spec, &alc861_presets[board_config]);
  10013. spec->stream_name_analog = "ALC861 Analog";
  10014. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  10015. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  10016. spec->stream_name_digital = "ALC861 Digital";
  10017. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  10018. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  10019. codec->patch_ops = alc_patch_ops;
  10020. if (board_config == ALC861_AUTO)
  10021. spec->init_hook = alc861_auto_init;
  10022. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10023. if (!spec->loopback.amplist)
  10024. spec->loopback.amplist = alc861_loopbacks;
  10025. #endif
  10026. return 0;
  10027. }
  10028. /*
  10029. * ALC861-VD support
  10030. *
  10031. * Based on ALC882
  10032. *
  10033. * In addition, an independent DAC
  10034. */
  10035. #define ALC861VD_DIGOUT_NID 0x06
  10036. static hda_nid_t alc861vd_dac_nids[4] = {
  10037. /* front, surr, clfe, side surr */
  10038. 0x02, 0x03, 0x04, 0x05
  10039. };
  10040. /* dac_nids for ALC660vd are in a different order - according to
  10041. * Realtek's driver.
  10042. * This should probably tesult in a different mixer for 6stack models
  10043. * of ALC660vd codecs, but for now there is only 3stack mixer
  10044. * - and it is the same as in 861vd.
  10045. * adc_nids in ALC660vd are (is) the same as in 861vd
  10046. */
  10047. static hda_nid_t alc660vd_dac_nids[3] = {
  10048. /* front, rear, clfe, rear_surr */
  10049. 0x02, 0x04, 0x03
  10050. };
  10051. static hda_nid_t alc861vd_adc_nids[1] = {
  10052. /* ADC0 */
  10053. 0x09,
  10054. };
  10055. /* input MUX */
  10056. /* FIXME: should be a matrix-type input source selection */
  10057. static struct hda_input_mux alc861vd_capture_source = {
  10058. .num_items = 4,
  10059. .items = {
  10060. { "Mic", 0x0 },
  10061. { "Front Mic", 0x1 },
  10062. { "Line", 0x2 },
  10063. { "CD", 0x4 },
  10064. },
  10065. };
  10066. static struct hda_input_mux alc861vd_dallas_capture_source = {
  10067. .num_items = 3,
  10068. .items = {
  10069. { "Front Mic", 0x0 },
  10070. { "ATAPI Mic", 0x1 },
  10071. { "Line In", 0x5 },
  10072. },
  10073. };
  10074. static struct hda_input_mux alc861vd_hp_capture_source = {
  10075. .num_items = 2,
  10076. .items = {
  10077. { "Front Mic", 0x0 },
  10078. { "ATAPI Mic", 0x1 },
  10079. },
  10080. };
  10081. #define alc861vd_mux_enum_info alc_mux_enum_info
  10082. #define alc861vd_mux_enum_get alc_mux_enum_get
  10083. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  10084. struct snd_ctl_elem_value *ucontrol)
  10085. {
  10086. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10087. struct alc_spec *spec = codec->spec;
  10088. const struct hda_input_mux *imux = spec->input_mux;
  10089. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10090. static hda_nid_t capture_mixers[1] = { 0x22 };
  10091. hda_nid_t nid = capture_mixers[adc_idx];
  10092. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10093. unsigned int i, idx;
  10094. idx = ucontrol->value.enumerated.item[0];
  10095. if (idx >= imux->num_items)
  10096. idx = imux->num_items - 1;
  10097. if (*cur_val == idx)
  10098. return 0;
  10099. for (i = 0; i < imux->num_items; i++) {
  10100. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10101. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10102. imux->items[i].index,
  10103. HDA_AMP_MUTE, v);
  10104. }
  10105. *cur_val = idx;
  10106. return 1;
  10107. }
  10108. /*
  10109. * 2ch mode
  10110. */
  10111. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  10112. { 2, NULL }
  10113. };
  10114. /*
  10115. * 6ch mode
  10116. */
  10117. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  10118. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10119. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10120. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10121. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10122. { } /* end */
  10123. };
  10124. /*
  10125. * 8ch mode
  10126. */
  10127. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  10128. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10129. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10130. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10131. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10132. { } /* end */
  10133. };
  10134. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  10135. { 6, alc861vd_6stack_ch6_init },
  10136. { 8, alc861vd_6stack_ch8_init },
  10137. };
  10138. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  10139. {
  10140. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10141. .name = "Channel Mode",
  10142. .info = alc_ch_mode_info,
  10143. .get = alc_ch_mode_get,
  10144. .put = alc_ch_mode_put,
  10145. },
  10146. { } /* end */
  10147. };
  10148. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  10149. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10150. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10151. {
  10152. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10153. /* The multiple "Capture Source" controls confuse alsamixer
  10154. * So call somewhat different..
  10155. *FIXME: the controls appear in the "playback" view!
  10156. */
  10157. /* .name = "Capture Source", */
  10158. .name = "Input Source",
  10159. .count = 1,
  10160. .info = alc861vd_mux_enum_info,
  10161. .get = alc861vd_mux_enum_get,
  10162. .put = alc861vd_mux_enum_put,
  10163. },
  10164. { } /* end */
  10165. };
  10166. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10167. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10168. */
  10169. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  10170. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10171. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  10172. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10173. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  10174. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  10175. HDA_OUTPUT),
  10176. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  10177. HDA_OUTPUT),
  10178. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  10179. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  10180. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  10181. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  10182. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10183. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  10184. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10185. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10186. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  10187. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10188. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10189. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10190. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10191. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10192. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10193. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10194. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10195. { } /* end */
  10196. };
  10197. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  10198. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10199. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  10200. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10201. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  10202. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10203. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10204. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  10205. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10206. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10207. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10208. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10209. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10210. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10211. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10212. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10213. { } /* end */
  10214. };
  10215. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  10216. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10217. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  10218. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  10219. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10220. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  10221. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10222. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10223. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  10224. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10225. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10226. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10227. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10228. { } /* end */
  10229. };
  10230. /* Pin assignment: Front=0x14, HP = 0x15,
  10231. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  10232. */
  10233. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  10234. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10235. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  10236. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10237. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  10238. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10239. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10240. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10241. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10242. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10243. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10244. { } /* end */
  10245. };
  10246. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  10247. * Front Mic=0x18, ATAPI Mic = 0x19,
  10248. */
  10249. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  10250. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10251. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  10252. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10253. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  10254. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10255. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10256. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10257. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10258. { } /* end */
  10259. };
  10260. /*
  10261. * generic initialization of ADC, input mixers and output mixers
  10262. */
  10263. static struct hda_verb alc861vd_volume_init_verbs[] = {
  10264. /*
  10265. * Unmute ADC0 and set the default input to mic-in
  10266. */
  10267. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10268. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10269. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  10270. * the analog-loopback mixer widget
  10271. */
  10272. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10273. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10274. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10275. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10276. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10277. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10278. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  10279. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10280. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10281. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10282. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10283. /*
  10284. * Set up output mixers (0x02 - 0x05)
  10285. */
  10286. /* set vol=0 to output mixers */
  10287. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10288. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10289. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10290. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10291. /* set up input amps for analog loopback */
  10292. /* Amp Indices: DAC = 0, mixer = 1 */
  10293. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10294. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10295. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10296. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10297. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10298. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10299. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10300. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10301. { }
  10302. };
  10303. /*
  10304. * 3-stack pin configuration:
  10305. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  10306. */
  10307. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  10308. /*
  10309. * Set pin mode and muting
  10310. */
  10311. /* set front pin widgets 0x14 for output */
  10312. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10313. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10314. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  10315. /* Mic (rear) pin: input vref at 80% */
  10316. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10317. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10318. /* Front Mic pin: input vref at 80% */
  10319. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10320. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10321. /* Line In pin: input */
  10322. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10323. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10324. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10325. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10326. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10327. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10328. /* CD pin widget for input */
  10329. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10330. { }
  10331. };
  10332. /*
  10333. * 6-stack pin configuration:
  10334. */
  10335. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  10336. /*
  10337. * Set pin mode and muting
  10338. */
  10339. /* set front pin widgets 0x14 for output */
  10340. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10341. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10342. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  10343. /* Rear Pin: output 1 (0x0d) */
  10344. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10345. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10346. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  10347. /* CLFE Pin: output 2 (0x0e) */
  10348. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10349. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10350. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  10351. /* Side Pin: output 3 (0x0f) */
  10352. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10353. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10354. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  10355. /* Mic (rear) pin: input vref at 80% */
  10356. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10357. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10358. /* Front Mic pin: input vref at 80% */
  10359. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10360. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10361. /* Line In pin: input */
  10362. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10363. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10364. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10365. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10366. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10367. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10368. /* CD pin widget for input */
  10369. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10370. { }
  10371. };
  10372. static struct hda_verb alc861vd_eapd_verbs[] = {
  10373. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  10374. { }
  10375. };
  10376. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  10377. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10378. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10379. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  10380. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  10381. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  10382. {}
  10383. };
  10384. /* toggle speaker-output according to the hp-jack state */
  10385. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  10386. {
  10387. unsigned int present;
  10388. unsigned char bits;
  10389. present = snd_hda_codec_read(codec, 0x1b, 0,
  10390. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10391. bits = present ? HDA_AMP_MUTE : 0;
  10392. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10393. HDA_AMP_MUTE, bits);
  10394. }
  10395. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  10396. {
  10397. unsigned int present;
  10398. unsigned char bits;
  10399. present = snd_hda_codec_read(codec, 0x18, 0,
  10400. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10401. bits = present ? HDA_AMP_MUTE : 0;
  10402. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  10403. HDA_AMP_MUTE, bits);
  10404. }
  10405. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  10406. {
  10407. alc861vd_lenovo_hp_automute(codec);
  10408. alc861vd_lenovo_mic_automute(codec);
  10409. }
  10410. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  10411. unsigned int res)
  10412. {
  10413. switch (res >> 26) {
  10414. case ALC880_HP_EVENT:
  10415. alc861vd_lenovo_hp_automute(codec);
  10416. break;
  10417. case ALC880_MIC_EVENT:
  10418. alc861vd_lenovo_mic_automute(codec);
  10419. break;
  10420. }
  10421. }
  10422. static struct hda_verb alc861vd_dallas_verbs[] = {
  10423. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10424. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10425. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10426. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10427. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10428. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10429. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10430. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10431. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10432. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10433. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10434. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10435. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10436. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10437. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10438. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10439. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10440. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10441. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10442. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10443. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  10444. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10445. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  10446. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10447. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10448. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10449. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10450. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10451. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10452. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10453. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10454. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10455. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10456. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10457. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  10458. { } /* end */
  10459. };
  10460. /* toggle speaker-output according to the hp-jack state */
  10461. static void alc861vd_dallas_automute(struct hda_codec *codec)
  10462. {
  10463. unsigned int present;
  10464. present = snd_hda_codec_read(codec, 0x15, 0,
  10465. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10466. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10467. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  10468. }
  10469. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  10470. {
  10471. if ((res >> 26) == ALC880_HP_EVENT)
  10472. alc861vd_dallas_automute(codec);
  10473. }
  10474. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10475. #define alc861vd_loopbacks alc880_loopbacks
  10476. #endif
  10477. /* pcm configuration: identiacal with ALC880 */
  10478. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  10479. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  10480. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  10481. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  10482. /*
  10483. * configuration and preset
  10484. */
  10485. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  10486. [ALC660VD_3ST] = "3stack-660",
  10487. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  10488. [ALC861VD_3ST] = "3stack",
  10489. [ALC861VD_3ST_DIG] = "3stack-digout",
  10490. [ALC861VD_6ST_DIG] = "6stack-digout",
  10491. [ALC861VD_LENOVO] = "lenovo",
  10492. [ALC861VD_DALLAS] = "dallas",
  10493. [ALC861VD_HP] = "hp",
  10494. [ALC861VD_AUTO] = "auto",
  10495. };
  10496. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  10497. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  10498. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  10499. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  10500. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  10501. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  10502. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  10503. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  10504. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  10505. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  10506. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  10507. SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
  10508. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  10509. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  10510. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  10511. {}
  10512. };
  10513. static struct alc_config_preset alc861vd_presets[] = {
  10514. [ALC660VD_3ST] = {
  10515. .mixers = { alc861vd_3st_mixer },
  10516. .init_verbs = { alc861vd_volume_init_verbs,
  10517. alc861vd_3stack_init_verbs },
  10518. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10519. .dac_nids = alc660vd_dac_nids,
  10520. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10521. .adc_nids = alc861vd_adc_nids,
  10522. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10523. .channel_mode = alc861vd_3stack_2ch_modes,
  10524. .input_mux = &alc861vd_capture_source,
  10525. },
  10526. [ALC660VD_3ST_DIG] = {
  10527. .mixers = { alc861vd_3st_mixer },
  10528. .init_verbs = { alc861vd_volume_init_verbs,
  10529. alc861vd_3stack_init_verbs },
  10530. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10531. .dac_nids = alc660vd_dac_nids,
  10532. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10533. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10534. .adc_nids = alc861vd_adc_nids,
  10535. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10536. .channel_mode = alc861vd_3stack_2ch_modes,
  10537. .input_mux = &alc861vd_capture_source,
  10538. },
  10539. [ALC861VD_3ST] = {
  10540. .mixers = { alc861vd_3st_mixer },
  10541. .init_verbs = { alc861vd_volume_init_verbs,
  10542. alc861vd_3stack_init_verbs },
  10543. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10544. .dac_nids = alc861vd_dac_nids,
  10545. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10546. .channel_mode = alc861vd_3stack_2ch_modes,
  10547. .input_mux = &alc861vd_capture_source,
  10548. },
  10549. [ALC861VD_3ST_DIG] = {
  10550. .mixers = { alc861vd_3st_mixer },
  10551. .init_verbs = { alc861vd_volume_init_verbs,
  10552. alc861vd_3stack_init_verbs },
  10553. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10554. .dac_nids = alc861vd_dac_nids,
  10555. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10556. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10557. .channel_mode = alc861vd_3stack_2ch_modes,
  10558. .input_mux = &alc861vd_capture_source,
  10559. },
  10560. [ALC861VD_6ST_DIG] = {
  10561. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  10562. .init_verbs = { alc861vd_volume_init_verbs,
  10563. alc861vd_6stack_init_verbs },
  10564. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10565. .dac_nids = alc861vd_dac_nids,
  10566. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10567. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  10568. .channel_mode = alc861vd_6stack_modes,
  10569. .input_mux = &alc861vd_capture_source,
  10570. },
  10571. [ALC861VD_LENOVO] = {
  10572. .mixers = { alc861vd_lenovo_mixer },
  10573. .init_verbs = { alc861vd_volume_init_verbs,
  10574. alc861vd_3stack_init_verbs,
  10575. alc861vd_eapd_verbs,
  10576. alc861vd_lenovo_unsol_verbs },
  10577. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  10578. .dac_nids = alc660vd_dac_nids,
  10579. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10580. .adc_nids = alc861vd_adc_nids,
  10581. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10582. .channel_mode = alc861vd_3stack_2ch_modes,
  10583. .input_mux = &alc861vd_capture_source,
  10584. .unsol_event = alc861vd_lenovo_unsol_event,
  10585. .init_hook = alc861vd_lenovo_automute,
  10586. },
  10587. [ALC861VD_DALLAS] = {
  10588. .mixers = { alc861vd_dallas_mixer },
  10589. .init_verbs = { alc861vd_dallas_verbs },
  10590. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10591. .dac_nids = alc861vd_dac_nids,
  10592. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10593. .adc_nids = alc861vd_adc_nids,
  10594. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10595. .channel_mode = alc861vd_3stack_2ch_modes,
  10596. .input_mux = &alc861vd_dallas_capture_source,
  10597. .unsol_event = alc861vd_dallas_unsol_event,
  10598. .init_hook = alc861vd_dallas_automute,
  10599. },
  10600. [ALC861VD_HP] = {
  10601. .mixers = { alc861vd_hp_mixer },
  10602. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  10603. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  10604. .dac_nids = alc861vd_dac_nids,
  10605. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  10606. .dig_out_nid = ALC861VD_DIGOUT_NID,
  10607. .adc_nids = alc861vd_adc_nids,
  10608. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  10609. .channel_mode = alc861vd_3stack_2ch_modes,
  10610. .input_mux = &alc861vd_hp_capture_source,
  10611. .unsol_event = alc861vd_dallas_unsol_event,
  10612. .init_hook = alc861vd_dallas_automute,
  10613. },
  10614. };
  10615. /*
  10616. * BIOS auto configuration
  10617. */
  10618. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  10619. hda_nid_t nid, int pin_type, int dac_idx)
  10620. {
  10621. /* set as output */
  10622. snd_hda_codec_write(codec, nid, 0,
  10623. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10624. snd_hda_codec_write(codec, nid, 0,
  10625. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10626. }
  10627. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  10628. {
  10629. struct alc_spec *spec = codec->spec;
  10630. int i;
  10631. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  10632. for (i = 0; i <= HDA_SIDE; i++) {
  10633. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10634. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10635. if (nid)
  10636. alc861vd_auto_set_output_and_unmute(codec, nid,
  10637. pin_type, i);
  10638. }
  10639. }
  10640. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  10641. {
  10642. struct alc_spec *spec = codec->spec;
  10643. hda_nid_t pin;
  10644. pin = spec->autocfg.hp_pins[0];
  10645. if (pin) /* connect to front and use dac 0 */
  10646. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10647. }
  10648. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  10649. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  10650. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  10651. {
  10652. struct alc_spec *spec = codec->spec;
  10653. int i;
  10654. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10655. hda_nid_t nid = spec->autocfg.input_pins[i];
  10656. if (alc861vd_is_input_pin(nid)) {
  10657. snd_hda_codec_write(codec, nid, 0,
  10658. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10659. i <= AUTO_PIN_FRONT_MIC ?
  10660. PIN_VREF80 : PIN_IN);
  10661. if (nid != ALC861VD_PIN_CD_NID)
  10662. snd_hda_codec_write(codec, nid, 0,
  10663. AC_VERB_SET_AMP_GAIN_MUTE,
  10664. AMP_OUT_MUTE);
  10665. }
  10666. }
  10667. }
  10668. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  10669. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  10670. /* add playback controls from the parsed DAC table */
  10671. /* Based on ALC880 version. But ALC861VD has separate,
  10672. * different NIDs for mute/unmute switch and volume control */
  10673. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  10674. const struct auto_pin_cfg *cfg)
  10675. {
  10676. char name[32];
  10677. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  10678. hda_nid_t nid_v, nid_s;
  10679. int i, err;
  10680. for (i = 0; i < cfg->line_outs; i++) {
  10681. if (!spec->multiout.dac_nids[i])
  10682. continue;
  10683. nid_v = alc861vd_idx_to_mixer_vol(
  10684. alc880_dac_to_idx(
  10685. spec->multiout.dac_nids[i]));
  10686. nid_s = alc861vd_idx_to_mixer_switch(
  10687. alc880_dac_to_idx(
  10688. spec->multiout.dac_nids[i]));
  10689. if (i == 2) {
  10690. /* Center/LFE */
  10691. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10692. "Center Playback Volume",
  10693. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  10694. HDA_OUTPUT));
  10695. if (err < 0)
  10696. return err;
  10697. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10698. "LFE Playback Volume",
  10699. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  10700. HDA_OUTPUT));
  10701. if (err < 0)
  10702. return err;
  10703. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10704. "Center Playback Switch",
  10705. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  10706. HDA_INPUT));
  10707. if (err < 0)
  10708. return err;
  10709. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10710. "LFE Playback Switch",
  10711. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  10712. HDA_INPUT));
  10713. if (err < 0)
  10714. return err;
  10715. } else {
  10716. sprintf(name, "%s Playback Volume", chname[i]);
  10717. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10718. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  10719. HDA_OUTPUT));
  10720. if (err < 0)
  10721. return err;
  10722. sprintf(name, "%s Playback Switch", chname[i]);
  10723. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10724. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  10725. HDA_INPUT));
  10726. if (err < 0)
  10727. return err;
  10728. }
  10729. }
  10730. return 0;
  10731. }
  10732. /* add playback controls for speaker and HP outputs */
  10733. /* Based on ALC880 version. But ALC861VD has separate,
  10734. * different NIDs for mute/unmute switch and volume control */
  10735. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  10736. hda_nid_t pin, const char *pfx)
  10737. {
  10738. hda_nid_t nid_v, nid_s;
  10739. int err;
  10740. char name[32];
  10741. if (!pin)
  10742. return 0;
  10743. if (alc880_is_fixed_pin(pin)) {
  10744. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10745. /* specify the DAC as the extra output */
  10746. if (!spec->multiout.hp_nid)
  10747. spec->multiout.hp_nid = nid_v;
  10748. else
  10749. spec->multiout.extra_out_nid[0] = nid_v;
  10750. /* control HP volume/switch on the output mixer amp */
  10751. nid_v = alc861vd_idx_to_mixer_vol(
  10752. alc880_fixed_pin_idx(pin));
  10753. nid_s = alc861vd_idx_to_mixer_switch(
  10754. alc880_fixed_pin_idx(pin));
  10755. sprintf(name, "%s Playback Volume", pfx);
  10756. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10757. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  10758. if (err < 0)
  10759. return err;
  10760. sprintf(name, "%s Playback Switch", pfx);
  10761. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10762. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  10763. if (err < 0)
  10764. return err;
  10765. } else if (alc880_is_multi_pin(pin)) {
  10766. /* set manual connection */
  10767. /* we have only a switch on HP-out PIN */
  10768. sprintf(name, "%s Playback Switch", pfx);
  10769. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10770. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10771. if (err < 0)
  10772. return err;
  10773. }
  10774. return 0;
  10775. }
  10776. /* parse the BIOS configuration and set up the alc_spec
  10777. * return 1 if successful, 0 if the proper config is not found,
  10778. * or a negative error code
  10779. * Based on ALC880 version - had to change it to override
  10780. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  10781. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  10782. {
  10783. struct alc_spec *spec = codec->spec;
  10784. int err;
  10785. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  10786. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10787. alc861vd_ignore);
  10788. if (err < 0)
  10789. return err;
  10790. if (!spec->autocfg.line_outs)
  10791. return 0; /* can't find valid BIOS pin config */
  10792. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10793. if (err < 0)
  10794. return err;
  10795. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10796. if (err < 0)
  10797. return err;
  10798. err = alc861vd_auto_create_extra_out(spec,
  10799. spec->autocfg.speaker_pins[0],
  10800. "Speaker");
  10801. if (err < 0)
  10802. return err;
  10803. err = alc861vd_auto_create_extra_out(spec,
  10804. spec->autocfg.hp_pins[0],
  10805. "Headphone");
  10806. if (err < 0)
  10807. return err;
  10808. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10809. if (err < 0)
  10810. return err;
  10811. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10812. if (spec->autocfg.dig_out_pin)
  10813. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  10814. if (spec->kctl_alloc)
  10815. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10816. spec->init_verbs[spec->num_init_verbs++]
  10817. = alc861vd_volume_init_verbs;
  10818. spec->num_mux_defs = 1;
  10819. spec->input_mux = &spec->private_imux;
  10820. err = alc_auto_add_mic_boost(codec);
  10821. if (err < 0)
  10822. return err;
  10823. return 1;
  10824. }
  10825. /* additional initialization for auto-configuration model */
  10826. static void alc861vd_auto_init(struct hda_codec *codec)
  10827. {
  10828. alc861vd_auto_init_multi_out(codec);
  10829. alc861vd_auto_init_hp_out(codec);
  10830. alc861vd_auto_init_analog_input(codec);
  10831. }
  10832. static int patch_alc861vd(struct hda_codec *codec)
  10833. {
  10834. struct alc_spec *spec;
  10835. int err, board_config;
  10836. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10837. if (spec == NULL)
  10838. return -ENOMEM;
  10839. codec->spec = spec;
  10840. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  10841. alc861vd_models,
  10842. alc861vd_cfg_tbl);
  10843. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  10844. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  10845. "ALC861VD, trying auto-probe from BIOS...\n");
  10846. board_config = ALC861VD_AUTO;
  10847. }
  10848. if (board_config == ALC861VD_AUTO) {
  10849. /* automatic parse from the BIOS config */
  10850. err = alc861vd_parse_auto_config(codec);
  10851. if (err < 0) {
  10852. alc_free(codec);
  10853. return err;
  10854. } else if (!err) {
  10855. printk(KERN_INFO
  10856. "hda_codec: Cannot set up configuration "
  10857. "from BIOS. Using base mode...\n");
  10858. board_config = ALC861VD_3ST;
  10859. }
  10860. }
  10861. if (board_config != ALC861VD_AUTO)
  10862. setup_preset(spec, &alc861vd_presets[board_config]);
  10863. spec->stream_name_analog = "ALC861VD Analog";
  10864. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10865. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10866. spec->stream_name_digital = "ALC861VD Digital";
  10867. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10868. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10869. spec->adc_nids = alc861vd_adc_nids;
  10870. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10871. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10872. spec->num_mixers++;
  10873. codec->patch_ops = alc_patch_ops;
  10874. if (board_config == ALC861VD_AUTO)
  10875. spec->init_hook = alc861vd_auto_init;
  10876. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10877. if (!spec->loopback.amplist)
  10878. spec->loopback.amplist = alc861vd_loopbacks;
  10879. #endif
  10880. return 0;
  10881. }
  10882. /*
  10883. * ALC662 support
  10884. *
  10885. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  10886. * configuration. Each pin widget can choose any input DACs and a mixer.
  10887. * Each ADC is connected from a mixer of all inputs. This makes possible
  10888. * 6-channel independent captures.
  10889. *
  10890. * In addition, an independent DAC for the multi-playback (not used in this
  10891. * driver yet).
  10892. */
  10893. #define ALC662_DIGOUT_NID 0x06
  10894. #define ALC662_DIGIN_NID 0x0a
  10895. static hda_nid_t alc662_dac_nids[4] = {
  10896. /* front, rear, clfe, rear_surr */
  10897. 0x02, 0x03, 0x04
  10898. };
  10899. static hda_nid_t alc662_adc_nids[1] = {
  10900. /* ADC1-2 */
  10901. 0x09,
  10902. };
  10903. /* input MUX */
  10904. /* FIXME: should be a matrix-type input source selection */
  10905. static struct hda_input_mux alc662_capture_source = {
  10906. .num_items = 4,
  10907. .items = {
  10908. { "Mic", 0x0 },
  10909. { "Front Mic", 0x1 },
  10910. { "Line", 0x2 },
  10911. { "CD", 0x4 },
  10912. },
  10913. };
  10914. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  10915. .num_items = 2,
  10916. .items = {
  10917. { "Mic", 0x1 },
  10918. { "Line", 0x2 },
  10919. },
  10920. };
  10921. static struct hda_input_mux alc662_eeepc_capture_source = {
  10922. .num_items = 2,
  10923. .items = {
  10924. { "i-Mic", 0x1 },
  10925. { "e-Mic", 0x0 },
  10926. },
  10927. };
  10928. #define alc662_mux_enum_info alc_mux_enum_info
  10929. #define alc662_mux_enum_get alc_mux_enum_get
  10930. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  10931. struct snd_ctl_elem_value *ucontrol)
  10932. {
  10933. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10934. struct alc_spec *spec = codec->spec;
  10935. const struct hda_input_mux *imux = spec->input_mux;
  10936. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10937. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  10938. hda_nid_t nid = capture_mixers[adc_idx];
  10939. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10940. unsigned int i, idx;
  10941. idx = ucontrol->value.enumerated.item[0];
  10942. if (idx >= imux->num_items)
  10943. idx = imux->num_items - 1;
  10944. if (*cur_val == idx)
  10945. return 0;
  10946. for (i = 0; i < imux->num_items; i++) {
  10947. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10948. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10949. imux->items[i].index,
  10950. HDA_AMP_MUTE, v);
  10951. }
  10952. *cur_val = idx;
  10953. return 1;
  10954. }
  10955. /*
  10956. * 2ch mode
  10957. */
  10958. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  10959. { 2, NULL }
  10960. };
  10961. /*
  10962. * 2ch mode
  10963. */
  10964. static struct hda_verb alc662_3ST_ch2_init[] = {
  10965. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  10966. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10967. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  10968. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10969. { } /* end */
  10970. };
  10971. /*
  10972. * 6ch mode
  10973. */
  10974. static struct hda_verb alc662_3ST_ch6_init[] = {
  10975. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10976. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10977. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  10978. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10979. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10980. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  10981. { } /* end */
  10982. };
  10983. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  10984. { 2, alc662_3ST_ch2_init },
  10985. { 6, alc662_3ST_ch6_init },
  10986. };
  10987. /*
  10988. * 2ch mode
  10989. */
  10990. static struct hda_verb alc662_sixstack_ch6_init[] = {
  10991. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10992. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10993. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10994. { } /* end */
  10995. };
  10996. /*
  10997. * 6ch mode
  10998. */
  10999. static struct hda_verb alc662_sixstack_ch8_init[] = {
  11000. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  11001. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  11002. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  11003. { } /* end */
  11004. };
  11005. static struct hda_channel_mode alc662_5stack_modes[2] = {
  11006. { 2, alc662_sixstack_ch6_init },
  11007. { 6, alc662_sixstack_ch8_init },
  11008. };
  11009. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  11010. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  11011. */
  11012. static struct snd_kcontrol_new alc662_base_mixer[] = {
  11013. /* output mixer control */
  11014. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  11015. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  11016. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  11017. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  11018. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  11019. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  11020. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  11021. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  11022. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  11023. /*Input mixer control */
  11024. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  11025. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  11026. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  11027. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  11028. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  11029. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  11030. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  11031. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  11032. /* Capture mixer control */
  11033. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  11034. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  11035. {
  11036. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  11037. .name = "Capture Source",
  11038. .count = 1,
  11039. .info = alc_mux_enum_info,
  11040. .get = alc_mux_enum_get,
  11041. .put = alc_mux_enum_put,
  11042. },
  11043. { } /* end */
  11044. };
  11045. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  11046. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  11047. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  11048. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  11049. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  11050. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  11051. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  11052. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  11053. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  11054. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  11055. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  11056. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  11057. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  11058. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  11059. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  11060. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  11061. {
  11062. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  11063. /* .name = "Capture Source", */
  11064. .name = "Input Source",
  11065. .count = 1,
  11066. .info = alc662_mux_enum_info,
  11067. .get = alc662_mux_enum_get,
  11068. .put = alc662_mux_enum_put,
  11069. },
  11070. { } /* end */
  11071. };
  11072. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  11073. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  11074. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  11075. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  11076. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  11077. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  11078. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  11079. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  11080. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  11081. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  11082. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  11083. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  11084. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  11085. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  11086. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  11087. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  11088. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  11089. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  11090. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  11091. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  11092. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  11093. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  11094. {
  11095. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  11096. /* .name = "Capture Source", */
  11097. .name = "Input Source",
  11098. .count = 1,
  11099. .info = alc662_mux_enum_info,
  11100. .get = alc662_mux_enum_get,
  11101. .put = alc662_mux_enum_put,
  11102. },
  11103. { } /* end */
  11104. };
  11105. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  11106. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  11107. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  11108. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  11109. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  11110. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  11111. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  11112. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  11113. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  11114. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  11115. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  11116. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  11117. {
  11118. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  11119. /* .name = "Capture Source", */
  11120. .name = "Input Source",
  11121. .count = 1,
  11122. .info = alc662_mux_enum_info,
  11123. .get = alc662_mux_enum_get,
  11124. .put = alc662_mux_enum_put,
  11125. },
  11126. { } /* end */
  11127. };
  11128. static struct snd_kcontrol_new alc662_eeepc_p701_mixer[] = {
  11129. HDA_CODEC_MUTE("iSpeaker Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  11130. HDA_CODEC_VOLUME("LineOut Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  11131. HDA_CODEC_MUTE("LineOut Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  11132. HDA_CODEC_VOLUME("e-Mic Boost", 0x18, 0, HDA_INPUT),
  11133. HDA_CODEC_VOLUME("e-Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  11134. HDA_CODEC_MUTE("e-Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  11135. HDA_CODEC_VOLUME("i-Mic Boost", 0x19, 0, HDA_INPUT),
  11136. HDA_CODEC_VOLUME("i-Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  11137. HDA_CODEC_MUTE("i-Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  11138. { } /* end */
  11139. };
  11140. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  11141. {
  11142. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  11143. .name = "Channel Mode",
  11144. .info = alc_ch_mode_info,
  11145. .get = alc_ch_mode_get,
  11146. .put = alc_ch_mode_put,
  11147. },
  11148. { } /* end */
  11149. };
  11150. static struct hda_verb alc662_init_verbs[] = {
  11151. /* ADC: mute amp left and right */
  11152. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  11153. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  11154. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  11155. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  11156. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  11157. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  11158. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  11159. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  11160. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11161. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11162. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11163. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11164. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11165. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11166. /* Front Pin: output 0 (0x0c) */
  11167. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  11168. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  11169. /* Rear Pin: output 1 (0x0d) */
  11170. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  11171. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  11172. /* CLFE Pin: output 2 (0x0e) */
  11173. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  11174. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  11175. /* Mic (rear) pin: input vref at 80% */
  11176. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  11177. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  11178. /* Front Mic pin: input vref at 80% */
  11179. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  11180. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  11181. /* Line In pin: input */
  11182. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  11183. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  11184. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  11185. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  11186. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  11187. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  11188. /* CD pin widget for input */
  11189. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  11190. /* FIXME: use matrix-type input source selection */
  11191. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  11192. /* Input mixer */
  11193. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11194. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11195. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  11196. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  11197. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11198. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11199. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  11200. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  11201. { }
  11202. };
  11203. static struct hda_verb alc662_sue_init_verbs[] = {
  11204. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  11205. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  11206. {}
  11207. };
  11208. static struct hda_verb alc662_eeepc_sue_init_verbs[] = {
  11209. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  11210. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  11211. {}
  11212. };
  11213. /*
  11214. * generic initialization of ADC, input mixers and output mixers
  11215. */
  11216. static struct hda_verb alc662_auto_init_verbs[] = {
  11217. /*
  11218. * Unmute ADC and set the default input to mic-in
  11219. */
  11220. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  11221. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11222. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  11223. * mixer widget
  11224. * Note: PASD motherboards uses the Line In 2 as the input for front
  11225. * panel mic (mic 2)
  11226. */
  11227. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  11228. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  11229. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  11230. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  11231. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  11232. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  11233. /*
  11234. * Set up output mixers (0x0c - 0x0f)
  11235. */
  11236. /* set vol=0 to output mixers */
  11237. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  11238. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  11239. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  11240. /* set up input amps for analog loopback */
  11241. /* Amp Indices: DAC = 0, mixer = 1 */
  11242. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11243. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11244. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11245. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11246. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11247. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  11248. /* FIXME: use matrix-type input source selection */
  11249. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  11250. /* Input mixer */
  11251. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11252. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  11253. { }
  11254. };
  11255. /* capture mixer elements */
  11256. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  11257. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  11258. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  11259. {
  11260. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  11261. /* The multiple "Capture Source" controls confuse alsamixer
  11262. * So call somewhat different..
  11263. * FIXME: the controls appear in the "playback" view!
  11264. */
  11265. /* .name = "Capture Source", */
  11266. .name = "Input Source",
  11267. .count = 1,
  11268. .info = alc882_mux_enum_info,
  11269. .get = alc882_mux_enum_get,
  11270. .put = alc882_mux_enum_put,
  11271. },
  11272. { } /* end */
  11273. };
  11274. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  11275. {
  11276. unsigned int present;
  11277. unsigned char bits;
  11278. present = snd_hda_codec_read(codec, 0x14, 0,
  11279. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  11280. bits = present ? HDA_AMP_MUTE : 0;
  11281. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  11282. HDA_AMP_MUTE, bits);
  11283. }
  11284. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  11285. {
  11286. unsigned int present;
  11287. unsigned char bits;
  11288. present = snd_hda_codec_read(codec, 0x1b, 0,
  11289. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  11290. bits = present ? HDA_AMP_MUTE : 0;
  11291. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  11292. HDA_AMP_MUTE, bits);
  11293. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  11294. HDA_AMP_MUTE, bits);
  11295. }
  11296. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  11297. unsigned int res)
  11298. {
  11299. if ((res >> 26) == ALC880_HP_EVENT)
  11300. alc662_lenovo_101e_all_automute(codec);
  11301. if ((res >> 26) == ALC880_FRONT_EVENT)
  11302. alc662_lenovo_101e_ispeaker_automute(codec);
  11303. }
  11304. static void alc662_eeepc_mic_automute(struct hda_codec *codec)
  11305. {
  11306. unsigned int present;
  11307. present = snd_hda_codec_read(codec, 0x18, 0,
  11308. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  11309. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  11310. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  11311. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  11312. 0x7000 | (0x00 << 8) | (present ? 0 : 0x80));
  11313. snd_hda_codec_write(codec, 0x22, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  11314. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  11315. snd_hda_codec_write(codec, 0x23, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  11316. 0x7000 | (0x01 << 8) | (present ? 0x80 : 0));
  11317. }
  11318. /* unsolicited event for HP jack sensing */
  11319. static void alc662_eeepc_unsol_event(struct hda_codec *codec,
  11320. unsigned int res)
  11321. {
  11322. if ((res >> 26) == ALC880_HP_EVENT)
  11323. alc262_hippo1_automute( codec );
  11324. if ((res >> 26) == ALC880_MIC_EVENT)
  11325. alc662_eeepc_mic_automute(codec);
  11326. }
  11327. static void alc662_eeepc_inithook(struct hda_codec *codec)
  11328. {
  11329. alc262_hippo1_automute( codec );
  11330. alc662_eeepc_mic_automute(codec);
  11331. }
  11332. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11333. #define alc662_loopbacks alc880_loopbacks
  11334. #endif
  11335. /* pcm configuration: identiacal with ALC880 */
  11336. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  11337. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  11338. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  11339. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  11340. /*
  11341. * configuration and preset
  11342. */
  11343. static const char *alc662_models[ALC662_MODEL_LAST] = {
  11344. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  11345. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  11346. [ALC662_3ST_6ch] = "3stack-6ch",
  11347. [ALC662_5ST_DIG] = "6stack-dig",
  11348. [ALC662_LENOVO_101E] = "lenovo-101e",
  11349. [ALC662_ASUS_EEEPC_P701] = "eeepc-p701",
  11350. [ALC662_AUTO] = "auto",
  11351. };
  11352. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  11353. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  11354. SND_PCI_QUIRK(0x1043, 0x82a1, "ASUS Eeepc", ALC662_ASUS_EEEPC_P701),
  11355. {}
  11356. };
  11357. static struct alc_config_preset alc662_presets[] = {
  11358. [ALC662_3ST_2ch_DIG] = {
  11359. .mixers = { alc662_3ST_2ch_mixer, alc662_capture_mixer },
  11360. .init_verbs = { alc662_init_verbs },
  11361. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11362. .dac_nids = alc662_dac_nids,
  11363. .dig_out_nid = ALC662_DIGOUT_NID,
  11364. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11365. .adc_nids = alc662_adc_nids,
  11366. .dig_in_nid = ALC662_DIGIN_NID,
  11367. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  11368. .channel_mode = alc662_3ST_2ch_modes,
  11369. .input_mux = &alc662_capture_source,
  11370. },
  11371. [ALC662_3ST_6ch_DIG] = {
  11372. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  11373. alc662_capture_mixer },
  11374. .init_verbs = { alc662_init_verbs },
  11375. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11376. .dac_nids = alc662_dac_nids,
  11377. .dig_out_nid = ALC662_DIGOUT_NID,
  11378. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11379. .adc_nids = alc662_adc_nids,
  11380. .dig_in_nid = ALC662_DIGIN_NID,
  11381. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  11382. .channel_mode = alc662_3ST_6ch_modes,
  11383. .need_dac_fix = 1,
  11384. .input_mux = &alc662_capture_source,
  11385. },
  11386. [ALC662_3ST_6ch] = {
  11387. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer,
  11388. alc662_capture_mixer },
  11389. .init_verbs = { alc662_init_verbs },
  11390. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11391. .dac_nids = alc662_dac_nids,
  11392. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11393. .adc_nids = alc662_adc_nids,
  11394. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  11395. .channel_mode = alc662_3ST_6ch_modes,
  11396. .need_dac_fix = 1,
  11397. .input_mux = &alc662_capture_source,
  11398. },
  11399. [ALC662_5ST_DIG] = {
  11400. .mixers = { alc662_base_mixer, alc662_chmode_mixer,
  11401. alc662_capture_mixer },
  11402. .init_verbs = { alc662_init_verbs },
  11403. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11404. .dac_nids = alc662_dac_nids,
  11405. .dig_out_nid = ALC662_DIGOUT_NID,
  11406. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11407. .adc_nids = alc662_adc_nids,
  11408. .dig_in_nid = ALC662_DIGIN_NID,
  11409. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  11410. .channel_mode = alc662_5stack_modes,
  11411. .input_mux = &alc662_capture_source,
  11412. },
  11413. [ALC662_LENOVO_101E] = {
  11414. .mixers = { alc662_lenovo_101e_mixer, alc662_capture_mixer },
  11415. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  11416. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11417. .dac_nids = alc662_dac_nids,
  11418. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  11419. .adc_nids = alc662_adc_nids,
  11420. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  11421. .channel_mode = alc662_3ST_2ch_modes,
  11422. .input_mux = &alc662_lenovo_101e_capture_source,
  11423. .unsol_event = alc662_lenovo_101e_unsol_event,
  11424. .init_hook = alc662_lenovo_101e_all_automute,
  11425. },
  11426. [ALC662_ASUS_EEEPC_P701] = {
  11427. .mixers = { alc662_eeepc_p701_mixer, alc662_capture_mixer },
  11428. .init_verbs = { alc662_init_verbs,
  11429. alc662_eeepc_sue_init_verbs },
  11430. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  11431. .dac_nids = alc662_dac_nids,
  11432. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  11433. .adc_nids = alc662_adc_nids,
  11434. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  11435. .channel_mode = alc662_3ST_2ch_modes,
  11436. .input_mux = &alc662_eeepc_capture_source,
  11437. .unsol_event = alc662_eeepc_unsol_event,
  11438. .init_hook = alc662_eeepc_inithook,
  11439. },
  11440. };
  11441. /*
  11442. * BIOS auto configuration
  11443. */
  11444. /* add playback controls from the parsed DAC table */
  11445. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  11446. const struct auto_pin_cfg *cfg)
  11447. {
  11448. char name[32];
  11449. static const char *chname[4] = {
  11450. "Front", "Surround", NULL /*CLFE*/, "Side"
  11451. };
  11452. hda_nid_t nid;
  11453. int i, err;
  11454. for (i = 0; i < cfg->line_outs; i++) {
  11455. if (!spec->multiout.dac_nids[i])
  11456. continue;
  11457. nid = alc880_idx_to_dac(i);
  11458. if (i == 2) {
  11459. /* Center/LFE */
  11460. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  11461. "Center Playback Volume",
  11462. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  11463. HDA_OUTPUT));
  11464. if (err < 0)
  11465. return err;
  11466. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  11467. "LFE Playback Volume",
  11468. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  11469. HDA_OUTPUT));
  11470. if (err < 0)
  11471. return err;
  11472. err = add_control(spec, ALC_CTL_BIND_MUTE,
  11473. "Center Playback Switch",
  11474. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  11475. HDA_INPUT));
  11476. if (err < 0)
  11477. return err;
  11478. err = add_control(spec, ALC_CTL_BIND_MUTE,
  11479. "LFE Playback Switch",
  11480. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  11481. HDA_INPUT));
  11482. if (err < 0)
  11483. return err;
  11484. } else {
  11485. sprintf(name, "%s Playback Volume", chname[i]);
  11486. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  11487. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  11488. HDA_OUTPUT));
  11489. if (err < 0)
  11490. return err;
  11491. sprintf(name, "%s Playback Switch", chname[i]);
  11492. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  11493. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  11494. HDA_INPUT));
  11495. if (err < 0)
  11496. return err;
  11497. }
  11498. }
  11499. return 0;
  11500. }
  11501. /* add playback controls for speaker and HP outputs */
  11502. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  11503. const char *pfx)
  11504. {
  11505. hda_nid_t nid;
  11506. int err;
  11507. char name[32];
  11508. if (!pin)
  11509. return 0;
  11510. if (alc880_is_fixed_pin(pin)) {
  11511. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  11512. /* printk("DAC nid=%x\n",nid); */
  11513. /* specify the DAC as the extra output */
  11514. if (!spec->multiout.hp_nid)
  11515. spec->multiout.hp_nid = nid;
  11516. else
  11517. spec->multiout.extra_out_nid[0] = nid;
  11518. /* control HP volume/switch on the output mixer amp */
  11519. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  11520. sprintf(name, "%s Playback Volume", pfx);
  11521. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  11522. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  11523. if (err < 0)
  11524. return err;
  11525. sprintf(name, "%s Playback Switch", pfx);
  11526. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  11527. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  11528. if (err < 0)
  11529. return err;
  11530. } else if (alc880_is_multi_pin(pin)) {
  11531. /* set manual connection */
  11532. /* we have only a switch on HP-out PIN */
  11533. sprintf(name, "%s Playback Switch", pfx);
  11534. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  11535. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  11536. if (err < 0)
  11537. return err;
  11538. }
  11539. return 0;
  11540. }
  11541. /* create playback/capture controls for input pins */
  11542. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  11543. const struct auto_pin_cfg *cfg)
  11544. {
  11545. struct hda_input_mux *imux = &spec->private_imux;
  11546. int i, err, idx;
  11547. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11548. if (alc880_is_input_pin(cfg->input_pins[i])) {
  11549. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  11550. err = new_analog_input(spec, cfg->input_pins[i],
  11551. auto_pin_cfg_labels[i],
  11552. idx, 0x0b);
  11553. if (err < 0)
  11554. return err;
  11555. imux->items[imux->num_items].label =
  11556. auto_pin_cfg_labels[i];
  11557. imux->items[imux->num_items].index =
  11558. alc880_input_pin_idx(cfg->input_pins[i]);
  11559. imux->num_items++;
  11560. }
  11561. }
  11562. return 0;
  11563. }
  11564. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  11565. hda_nid_t nid, int pin_type,
  11566. int dac_idx)
  11567. {
  11568. /* set as output */
  11569. snd_hda_codec_write(codec, nid, 0,
  11570. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  11571. snd_hda_codec_write(codec, nid, 0,
  11572. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  11573. /* need the manual connection? */
  11574. if (alc880_is_multi_pin(nid)) {
  11575. struct alc_spec *spec = codec->spec;
  11576. int idx = alc880_multi_pin_idx(nid);
  11577. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  11578. AC_VERB_SET_CONNECT_SEL,
  11579. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  11580. }
  11581. }
  11582. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  11583. {
  11584. struct alc_spec *spec = codec->spec;
  11585. int i;
  11586. for (i = 0; i <= HDA_SIDE; i++) {
  11587. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  11588. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  11589. if (nid)
  11590. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  11591. i);
  11592. }
  11593. }
  11594. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  11595. {
  11596. struct alc_spec *spec = codec->spec;
  11597. hda_nid_t pin;
  11598. pin = spec->autocfg.hp_pins[0];
  11599. if (pin) /* connect to front */
  11600. /* use dac 0 */
  11601. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  11602. }
  11603. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  11604. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  11605. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  11606. {
  11607. struct alc_spec *spec = codec->spec;
  11608. int i;
  11609. for (i = 0; i < AUTO_PIN_LAST; i++) {
  11610. hda_nid_t nid = spec->autocfg.input_pins[i];
  11611. if (alc662_is_input_pin(nid)) {
  11612. snd_hda_codec_write(codec, nid, 0,
  11613. AC_VERB_SET_PIN_WIDGET_CONTROL,
  11614. (i <= AUTO_PIN_FRONT_MIC ?
  11615. PIN_VREF80 : PIN_IN));
  11616. if (nid != ALC662_PIN_CD_NID)
  11617. snd_hda_codec_write(codec, nid, 0,
  11618. AC_VERB_SET_AMP_GAIN_MUTE,
  11619. AMP_OUT_MUTE);
  11620. }
  11621. }
  11622. }
  11623. static int alc662_parse_auto_config(struct hda_codec *codec)
  11624. {
  11625. struct alc_spec *spec = codec->spec;
  11626. int err;
  11627. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  11628. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  11629. alc662_ignore);
  11630. if (err < 0)
  11631. return err;
  11632. if (!spec->autocfg.line_outs)
  11633. return 0; /* can't find valid BIOS pin config */
  11634. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  11635. if (err < 0)
  11636. return err;
  11637. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  11638. if (err < 0)
  11639. return err;
  11640. err = alc662_auto_create_extra_out(spec,
  11641. spec->autocfg.speaker_pins[0],
  11642. "Speaker");
  11643. if (err < 0)
  11644. return err;
  11645. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  11646. "Headphone");
  11647. if (err < 0)
  11648. return err;
  11649. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  11650. if (err < 0)
  11651. return err;
  11652. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  11653. if (spec->autocfg.dig_out_pin)
  11654. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  11655. if (spec->kctl_alloc)
  11656. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  11657. spec->num_mux_defs = 1;
  11658. spec->input_mux = &spec->private_imux;
  11659. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  11660. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  11661. spec->num_mixers++;
  11662. return 1;
  11663. }
  11664. /* additional initialization for auto-configuration model */
  11665. static void alc662_auto_init(struct hda_codec *codec)
  11666. {
  11667. alc662_auto_init_multi_out(codec);
  11668. alc662_auto_init_hp_out(codec);
  11669. alc662_auto_init_analog_input(codec);
  11670. }
  11671. static int patch_alc662(struct hda_codec *codec)
  11672. {
  11673. struct alc_spec *spec;
  11674. int err, board_config;
  11675. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  11676. if (!spec)
  11677. return -ENOMEM;
  11678. codec->spec = spec;
  11679. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  11680. alc662_models,
  11681. alc662_cfg_tbl);
  11682. if (board_config < 0) {
  11683. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  11684. "trying auto-probe from BIOS...\n");
  11685. board_config = ALC662_AUTO;
  11686. }
  11687. if (board_config == ALC662_AUTO) {
  11688. /* automatic parse from the BIOS config */
  11689. err = alc662_parse_auto_config(codec);
  11690. if (err < 0) {
  11691. alc_free(codec);
  11692. return err;
  11693. } else if (!err) {
  11694. printk(KERN_INFO
  11695. "hda_codec: Cannot set up configuration "
  11696. "from BIOS. Using base mode...\n");
  11697. board_config = ALC662_3ST_2ch_DIG;
  11698. }
  11699. }
  11700. if (board_config != ALC662_AUTO)
  11701. setup_preset(spec, &alc662_presets[board_config]);
  11702. spec->stream_name_analog = "ALC662 Analog";
  11703. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  11704. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  11705. spec->stream_name_digital = "ALC662 Digital";
  11706. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  11707. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  11708. if (!spec->adc_nids && spec->input_mux) {
  11709. spec->adc_nids = alc662_adc_nids;
  11710. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  11711. }
  11712. codec->patch_ops = alc_patch_ops;
  11713. if (board_config == ALC662_AUTO)
  11714. spec->init_hook = alc662_auto_init;
  11715. #ifdef CONFIG_SND_HDA_POWER_SAVE
  11716. if (!spec->loopback.amplist)
  11717. spec->loopback.amplist = alc662_loopbacks;
  11718. #endif
  11719. return 0;
  11720. }
  11721. /*
  11722. * patch entries
  11723. */
  11724. struct hda_codec_preset snd_hda_preset_realtek[] = {
  11725. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  11726. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  11727. { .id = 0x10ec0267, .name = "ALC267", .patch = patch_alc268 },
  11728. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  11729. { .id = 0x10ec0269, .name = "ALC269", .patch = patch_alc269 },
  11730. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  11731. .patch = patch_alc861 },
  11732. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  11733. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  11734. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  11735. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  11736. .patch = patch_alc883 },
  11737. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  11738. .patch = patch_alc662 },
  11739. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  11740. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  11741. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  11742. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  11743. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  11744. { .id = 0x10ec0889, .name = "ALC889", .patch = patch_alc883 },
  11745. {} /* terminator */
  11746. };