patch_realtek.c 402 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_BENQ_T31,
  93. ALC262_AUTO,
  94. ALC262_MODEL_LAST /* last tag */
  95. };
  96. /* ALC268 models */
  97. enum {
  98. ALC268_3ST,
  99. ALC268_TOSHIBA,
  100. ALC268_ACER,
  101. ALC268_AUTO,
  102. ALC268_MODEL_LAST /* last tag */
  103. };
  104. /* ALC861 models */
  105. enum {
  106. ALC861_3ST,
  107. ALC660_3ST,
  108. ALC861_3ST_DIG,
  109. ALC861_6ST_DIG,
  110. ALC861_UNIWILL_M31,
  111. ALC861_TOSHIBA,
  112. ALC861_ASUS,
  113. ALC861_ASUS_LAPTOP,
  114. ALC861_AUTO,
  115. ALC861_MODEL_LAST,
  116. };
  117. /* ALC861-VD models */
  118. enum {
  119. ALC660VD_3ST,
  120. ALC660VD_3ST_DIG,
  121. ALC861VD_3ST,
  122. ALC861VD_3ST_DIG,
  123. ALC861VD_6ST_DIG,
  124. ALC861VD_LENOVO,
  125. ALC861VD_DALLAS,
  126. ALC861VD_HP,
  127. ALC861VD_AUTO,
  128. ALC861VD_MODEL_LAST,
  129. };
  130. /* ALC662 models */
  131. enum {
  132. ALC662_3ST_2ch_DIG,
  133. ALC662_3ST_6ch_DIG,
  134. ALC662_3ST_6ch,
  135. ALC662_5ST_DIG,
  136. ALC662_LENOVO_101E,
  137. ALC662_AUTO,
  138. ALC662_MODEL_LAST,
  139. };
  140. /* ALC882 models */
  141. enum {
  142. ALC882_3ST_DIG,
  143. ALC882_6ST_DIG,
  144. ALC882_ARIMA,
  145. ALC882_W2JC,
  146. ALC882_TARGA,
  147. ALC882_ASUS_A7J,
  148. ALC885_MACPRO,
  149. ALC885_MBP3,
  150. ALC885_IMAC24,
  151. ALC882_AUTO,
  152. ALC882_MODEL_LAST,
  153. };
  154. /* ALC883 models */
  155. enum {
  156. ALC883_3ST_2ch_DIG,
  157. ALC883_3ST_6ch_DIG,
  158. ALC883_3ST_6ch,
  159. ALC883_6ST_DIG,
  160. ALC883_TARGA_DIG,
  161. ALC883_TARGA_2ch_DIG,
  162. ALC883_ACER,
  163. ALC883_ACER_ASPIRE,
  164. ALC883_MEDION,
  165. ALC883_MEDION_MD2,
  166. ALC883_LAPTOP_EAPD,
  167. ALC883_LENOVO_101E_2ch,
  168. ALC883_LENOVO_NB0763,
  169. ALC888_LENOVO_MS7195_DIG,
  170. ALC883_HAIER_W66,
  171. ALC888_6ST_HP,
  172. ALC888_3ST_HP,
  173. ALC883_AUTO,
  174. ALC883_MODEL_LAST,
  175. };
  176. /* for GPIO Poll */
  177. #define GPIO_MASK 0x03
  178. struct alc_spec {
  179. /* codec parameterization */
  180. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  181. unsigned int num_mixers;
  182. const struct hda_verb *init_verbs[5]; /* initialization verbs
  183. * don't forget NULL
  184. * termination!
  185. */
  186. unsigned int num_init_verbs;
  187. char *stream_name_analog; /* analog PCM stream */
  188. struct hda_pcm_stream *stream_analog_playback;
  189. struct hda_pcm_stream *stream_analog_capture;
  190. char *stream_name_digital; /* digital PCM stream */
  191. struct hda_pcm_stream *stream_digital_playback;
  192. struct hda_pcm_stream *stream_digital_capture;
  193. /* playback */
  194. struct hda_multi_out multiout; /* playback set-up
  195. * max_channels, dacs must be set
  196. * dig_out_nid and hp_nid are optional
  197. */
  198. /* capture */
  199. unsigned int num_adc_nids;
  200. hda_nid_t *adc_nids;
  201. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  202. /* capture source */
  203. unsigned int num_mux_defs;
  204. const struct hda_input_mux *input_mux;
  205. unsigned int cur_mux[3];
  206. /* channel model */
  207. const struct hda_channel_mode *channel_mode;
  208. int num_channel_mode;
  209. int need_dac_fix;
  210. /* PCM information */
  211. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  212. /* dynamic controls, init_verbs and input_mux */
  213. struct auto_pin_cfg autocfg;
  214. unsigned int num_kctl_alloc, num_kctl_used;
  215. struct snd_kcontrol_new *kctl_alloc;
  216. struct hda_input_mux private_imux;
  217. hda_nid_t private_dac_nids[5];
  218. /* hooks */
  219. void (*init_hook)(struct hda_codec *codec);
  220. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  221. /* for pin sensing */
  222. unsigned int sense_updated: 1;
  223. unsigned int jack_present: 1;
  224. #ifdef CONFIG_SND_HDA_POWER_SAVE
  225. struct hda_loopback_check loopback;
  226. #endif
  227. };
  228. /*
  229. * configuration template - to be copied to the spec instance
  230. */
  231. struct alc_config_preset {
  232. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  233. * with spec
  234. */
  235. const struct hda_verb *init_verbs[5];
  236. unsigned int num_dacs;
  237. hda_nid_t *dac_nids;
  238. hda_nid_t dig_out_nid; /* optional */
  239. hda_nid_t hp_nid; /* optional */
  240. unsigned int num_adc_nids;
  241. hda_nid_t *adc_nids;
  242. hda_nid_t dig_in_nid;
  243. unsigned int num_channel_mode;
  244. const struct hda_channel_mode *channel_mode;
  245. int need_dac_fix;
  246. unsigned int num_mux_defs;
  247. const struct hda_input_mux *input_mux;
  248. void (*unsol_event)(struct hda_codec *, unsigned int);
  249. void (*init_hook)(struct hda_codec *);
  250. #ifdef CONFIG_SND_HDA_POWER_SAVE
  251. struct hda_amp_list *loopbacks;
  252. #endif
  253. };
  254. /*
  255. * input MUX handling
  256. */
  257. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  258. struct snd_ctl_elem_info *uinfo)
  259. {
  260. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  261. struct alc_spec *spec = codec->spec;
  262. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  263. if (mux_idx >= spec->num_mux_defs)
  264. mux_idx = 0;
  265. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  266. }
  267. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  268. struct snd_ctl_elem_value *ucontrol)
  269. {
  270. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  271. struct alc_spec *spec = codec->spec;
  272. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  273. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  274. return 0;
  275. }
  276. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  277. struct snd_ctl_elem_value *ucontrol)
  278. {
  279. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  280. struct alc_spec *spec = codec->spec;
  281. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  282. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  283. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  284. spec->adc_nids[adc_idx],
  285. &spec->cur_mux[adc_idx]);
  286. }
  287. /*
  288. * channel mode setting
  289. */
  290. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  291. struct snd_ctl_elem_info *uinfo)
  292. {
  293. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  294. struct alc_spec *spec = codec->spec;
  295. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  296. spec->num_channel_mode);
  297. }
  298. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  299. struct snd_ctl_elem_value *ucontrol)
  300. {
  301. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  302. struct alc_spec *spec = codec->spec;
  303. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  304. spec->num_channel_mode,
  305. spec->multiout.max_channels);
  306. }
  307. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  308. struct snd_ctl_elem_value *ucontrol)
  309. {
  310. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  311. struct alc_spec *spec = codec->spec;
  312. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  313. spec->num_channel_mode,
  314. &spec->multiout.max_channels);
  315. if (err >= 0 && spec->need_dac_fix)
  316. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  317. return err;
  318. }
  319. /*
  320. * Control the mode of pin widget settings via the mixer. "pc" is used
  321. * instead of "%" to avoid consequences of accidently treating the % as
  322. * being part of a format specifier. Maximum allowed length of a value is
  323. * 63 characters plus NULL terminator.
  324. *
  325. * Note: some retasking pin complexes seem to ignore requests for input
  326. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  327. * are requested. Therefore order this list so that this behaviour will not
  328. * cause problems when mixer clients move through the enum sequentially.
  329. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  330. * March 2006.
  331. */
  332. static char *alc_pin_mode_names[] = {
  333. "Mic 50pc bias", "Mic 80pc bias",
  334. "Line in", "Line out", "Headphone out",
  335. };
  336. static unsigned char alc_pin_mode_values[] = {
  337. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  338. };
  339. /* The control can present all 5 options, or it can limit the options based
  340. * in the pin being assumed to be exclusively an input or an output pin. In
  341. * addition, "input" pins may or may not process the mic bias option
  342. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  343. * accept requests for bias as of chip versions up to March 2006) and/or
  344. * wiring in the computer.
  345. */
  346. #define ALC_PIN_DIR_IN 0x00
  347. #define ALC_PIN_DIR_OUT 0x01
  348. #define ALC_PIN_DIR_INOUT 0x02
  349. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  350. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  351. /* Info about the pin modes supported by the different pin direction modes.
  352. * For each direction the minimum and maximum values are given.
  353. */
  354. static signed char alc_pin_mode_dir_info[5][2] = {
  355. { 0, 2 }, /* ALC_PIN_DIR_IN */
  356. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  357. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  358. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  359. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  360. };
  361. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  362. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  363. #define alc_pin_mode_n_items(_dir) \
  364. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  365. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  366. struct snd_ctl_elem_info *uinfo)
  367. {
  368. unsigned int item_num = uinfo->value.enumerated.item;
  369. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  370. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  371. uinfo->count = 1;
  372. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  373. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  374. item_num = alc_pin_mode_min(dir);
  375. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  376. return 0;
  377. }
  378. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  379. struct snd_ctl_elem_value *ucontrol)
  380. {
  381. unsigned int i;
  382. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  383. hda_nid_t nid = kcontrol->private_value & 0xffff;
  384. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  385. long *valp = ucontrol->value.integer.value;
  386. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  387. AC_VERB_GET_PIN_WIDGET_CONTROL,
  388. 0x00);
  389. /* Find enumerated value for current pinctl setting */
  390. i = alc_pin_mode_min(dir);
  391. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  392. i++;
  393. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  394. return 0;
  395. }
  396. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  397. struct snd_ctl_elem_value *ucontrol)
  398. {
  399. signed int change;
  400. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  401. hda_nid_t nid = kcontrol->private_value & 0xffff;
  402. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  403. long val = *ucontrol->value.integer.value;
  404. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  405. AC_VERB_GET_PIN_WIDGET_CONTROL,
  406. 0x00);
  407. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  408. val = alc_pin_mode_min(dir);
  409. change = pinctl != alc_pin_mode_values[val];
  410. if (change) {
  411. /* Set pin mode to that requested */
  412. snd_hda_codec_write_cache(codec, nid, 0,
  413. AC_VERB_SET_PIN_WIDGET_CONTROL,
  414. alc_pin_mode_values[val]);
  415. /* Also enable the retasking pin's input/output as required
  416. * for the requested pin mode. Enum values of 2 or less are
  417. * input modes.
  418. *
  419. * Dynamically switching the input/output buffers probably
  420. * reduces noise slightly (particularly on input) so we'll
  421. * do it. However, having both input and output buffers
  422. * enabled simultaneously doesn't seem to be problematic if
  423. * this turns out to be necessary in the future.
  424. */
  425. if (val <= 2) {
  426. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  427. HDA_AMP_MUTE, HDA_AMP_MUTE);
  428. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  429. HDA_AMP_MUTE, 0);
  430. } else {
  431. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT, 0,
  432. HDA_AMP_MUTE, HDA_AMP_MUTE);
  433. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  434. HDA_AMP_MUTE, 0);
  435. }
  436. }
  437. return change;
  438. }
  439. #define ALC_PIN_MODE(xname, nid, dir) \
  440. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  441. .info = alc_pin_mode_info, \
  442. .get = alc_pin_mode_get, \
  443. .put = alc_pin_mode_put, \
  444. .private_value = nid | (dir<<16) }
  445. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  446. * together using a mask with more than one bit set. This control is
  447. * currently used only by the ALC260 test model. At this stage they are not
  448. * needed for any "production" models.
  449. */
  450. #ifdef CONFIG_SND_DEBUG
  451. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  452. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  453. struct snd_ctl_elem_value *ucontrol)
  454. {
  455. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  456. hda_nid_t nid = kcontrol->private_value & 0xffff;
  457. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  458. long *valp = ucontrol->value.integer.value;
  459. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  460. AC_VERB_GET_GPIO_DATA, 0x00);
  461. *valp = (val & mask) != 0;
  462. return 0;
  463. }
  464. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  465. struct snd_ctl_elem_value *ucontrol)
  466. {
  467. signed int change;
  468. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  469. hda_nid_t nid = kcontrol->private_value & 0xffff;
  470. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  471. long val = *ucontrol->value.integer.value;
  472. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  473. AC_VERB_GET_GPIO_DATA,
  474. 0x00);
  475. /* Set/unset the masked GPIO bit(s) as needed */
  476. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  477. if (val == 0)
  478. gpio_data &= ~mask;
  479. else
  480. gpio_data |= mask;
  481. snd_hda_codec_write_cache(codec, nid, 0,
  482. AC_VERB_SET_GPIO_DATA, gpio_data);
  483. return change;
  484. }
  485. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  486. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  487. .info = alc_gpio_data_info, \
  488. .get = alc_gpio_data_get, \
  489. .put = alc_gpio_data_put, \
  490. .private_value = nid | (mask<<16) }
  491. #endif /* CONFIG_SND_DEBUG */
  492. /* A switch control to allow the enabling of the digital IO pins on the
  493. * ALC260. This is incredibly simplistic; the intention of this control is
  494. * to provide something in the test model allowing digital outputs to be
  495. * identified if present. If models are found which can utilise these
  496. * outputs a more complete mixer control can be devised for those models if
  497. * necessary.
  498. */
  499. #ifdef CONFIG_SND_DEBUG
  500. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  501. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  502. struct snd_ctl_elem_value *ucontrol)
  503. {
  504. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  505. hda_nid_t nid = kcontrol->private_value & 0xffff;
  506. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  507. long *valp = ucontrol->value.integer.value;
  508. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  509. AC_VERB_GET_DIGI_CONVERT, 0x00);
  510. *valp = (val & mask) != 0;
  511. return 0;
  512. }
  513. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  514. struct snd_ctl_elem_value *ucontrol)
  515. {
  516. signed int change;
  517. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  518. hda_nid_t nid = kcontrol->private_value & 0xffff;
  519. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  520. long val = *ucontrol->value.integer.value;
  521. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  522. AC_VERB_GET_DIGI_CONVERT,
  523. 0x00);
  524. /* Set/unset the masked control bit(s) as needed */
  525. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  526. if (val==0)
  527. ctrl_data &= ~mask;
  528. else
  529. ctrl_data |= mask;
  530. snd_hda_codec_write_cache(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  531. ctrl_data);
  532. return change;
  533. }
  534. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  535. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  536. .info = alc_spdif_ctrl_info, \
  537. .get = alc_spdif_ctrl_get, \
  538. .put = alc_spdif_ctrl_put, \
  539. .private_value = nid | (mask<<16) }
  540. #endif /* CONFIG_SND_DEBUG */
  541. /*
  542. * set up from the preset table
  543. */
  544. static void setup_preset(struct alc_spec *spec,
  545. const struct alc_config_preset *preset)
  546. {
  547. int i;
  548. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  549. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  550. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  551. i++)
  552. spec->init_verbs[spec->num_init_verbs++] =
  553. preset->init_verbs[i];
  554. spec->channel_mode = preset->channel_mode;
  555. spec->num_channel_mode = preset->num_channel_mode;
  556. spec->need_dac_fix = preset->need_dac_fix;
  557. spec->multiout.max_channels = spec->channel_mode[0].channels;
  558. spec->multiout.num_dacs = preset->num_dacs;
  559. spec->multiout.dac_nids = preset->dac_nids;
  560. spec->multiout.dig_out_nid = preset->dig_out_nid;
  561. spec->multiout.hp_nid = preset->hp_nid;
  562. spec->num_mux_defs = preset->num_mux_defs;
  563. if (!spec->num_mux_defs)
  564. spec->num_mux_defs = 1;
  565. spec->input_mux = preset->input_mux;
  566. spec->num_adc_nids = preset->num_adc_nids;
  567. spec->adc_nids = preset->adc_nids;
  568. spec->dig_in_nid = preset->dig_in_nid;
  569. spec->unsol_event = preset->unsol_event;
  570. spec->init_hook = preset->init_hook;
  571. #ifdef CONFIG_SND_HDA_POWER_SAVE
  572. spec->loopback.amplist = preset->loopbacks;
  573. #endif
  574. }
  575. /* Enable GPIO mask and set output */
  576. static struct hda_verb alc_gpio1_init_verbs[] = {
  577. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  578. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  579. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  580. { }
  581. };
  582. static struct hda_verb alc_gpio2_init_verbs[] = {
  583. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  584. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  585. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  586. { }
  587. };
  588. static struct hda_verb alc_gpio3_init_verbs[] = {
  589. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  590. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  591. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  592. { }
  593. };
  594. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  595. * 31 ~ 16 : Manufacture ID
  596. * 15 ~ 8 : SKU ID
  597. * 7 ~ 0 : Assembly ID
  598. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  599. */
  600. static void alc_subsystem_id(struct hda_codec *codec,
  601. unsigned int porta, unsigned int porte,
  602. unsigned int portd)
  603. {
  604. unsigned int ass, tmp;
  605. ass = codec->subsystem_id;
  606. if (!(ass & 1))
  607. return;
  608. /* Override */
  609. tmp = (ass & 0x38) >> 3; /* external Amp control */
  610. switch (tmp) {
  611. case 1:
  612. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  613. break;
  614. case 3:
  615. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  616. break;
  617. case 7:
  618. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  619. break;
  620. case 5:
  621. switch (codec->vendor_id) {
  622. case 0x10ec0862:
  623. case 0x10ec0660:
  624. case 0x10ec0662:
  625. case 0x10ec0267:
  626. case 0x10ec0268:
  627. snd_hda_codec_write(codec, 0x14, 0,
  628. AC_VERB_SET_EAPD_BTLENABLE, 2);
  629. snd_hda_codec_write(codec, 0x15, 0,
  630. AC_VERB_SET_EAPD_BTLENABLE, 2);
  631. return;
  632. }
  633. case 6:
  634. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  635. hda_nid_t port = 0;
  636. tmp = (ass & 0x1800) >> 11;
  637. switch (tmp) {
  638. case 0: port = porta; break;
  639. case 1: port = porte; break;
  640. case 2: port = portd; break;
  641. }
  642. if (port)
  643. snd_hda_codec_write(codec, port, 0,
  644. AC_VERB_SET_EAPD_BTLENABLE,
  645. 2);
  646. }
  647. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  648. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  649. (tmp == 5 ? 0x3040 : 0x3050));
  650. break;
  651. }
  652. }
  653. /*
  654. * Fix-up pin default configurations
  655. */
  656. struct alc_pincfg {
  657. hda_nid_t nid;
  658. u32 val;
  659. };
  660. static void alc_fix_pincfg(struct hda_codec *codec,
  661. const struct snd_pci_quirk *quirk,
  662. const struct alc_pincfg **pinfix)
  663. {
  664. const struct alc_pincfg *cfg;
  665. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  666. if (!quirk)
  667. return;
  668. cfg = pinfix[quirk->value];
  669. for (; cfg->nid; cfg++) {
  670. int i;
  671. u32 val = cfg->val;
  672. for (i = 0; i < 4; i++) {
  673. snd_hda_codec_write(codec, cfg->nid, 0,
  674. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  675. val & 0xff);
  676. val >>= 8;
  677. }
  678. }
  679. }
  680. /*
  681. * ALC880 3-stack model
  682. *
  683. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  684. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  685. * F-Mic = 0x1b, HP = 0x19
  686. */
  687. static hda_nid_t alc880_dac_nids[4] = {
  688. /* front, rear, clfe, rear_surr */
  689. 0x02, 0x05, 0x04, 0x03
  690. };
  691. static hda_nid_t alc880_adc_nids[3] = {
  692. /* ADC0-2 */
  693. 0x07, 0x08, 0x09,
  694. };
  695. /* The datasheet says the node 0x07 is connected from inputs,
  696. * but it shows zero connection in the real implementation on some devices.
  697. * Note: this is a 915GAV bug, fixed on 915GLV
  698. */
  699. static hda_nid_t alc880_adc_nids_alt[2] = {
  700. /* ADC1-2 */
  701. 0x08, 0x09,
  702. };
  703. #define ALC880_DIGOUT_NID 0x06
  704. #define ALC880_DIGIN_NID 0x0a
  705. static struct hda_input_mux alc880_capture_source = {
  706. .num_items = 4,
  707. .items = {
  708. { "Mic", 0x0 },
  709. { "Front Mic", 0x3 },
  710. { "Line", 0x2 },
  711. { "CD", 0x4 },
  712. },
  713. };
  714. /* channel source setting (2/6 channel selection for 3-stack) */
  715. /* 2ch mode */
  716. static struct hda_verb alc880_threestack_ch2_init[] = {
  717. /* set line-in to input, mute it */
  718. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  719. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  720. /* set mic-in to input vref 80%, mute it */
  721. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  722. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  723. { } /* end */
  724. };
  725. /* 6ch mode */
  726. static struct hda_verb alc880_threestack_ch6_init[] = {
  727. /* set line-in to output, unmute it */
  728. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  729. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  730. /* set mic-in to output, unmute it */
  731. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  732. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  733. { } /* end */
  734. };
  735. static struct hda_channel_mode alc880_threestack_modes[2] = {
  736. { 2, alc880_threestack_ch2_init },
  737. { 6, alc880_threestack_ch6_init },
  738. };
  739. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  740. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  741. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  742. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  743. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  744. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  745. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  746. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  747. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  748. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  749. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  750. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  751. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  752. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  753. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  754. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  755. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  756. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  757. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  758. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  759. {
  760. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  761. .name = "Channel Mode",
  762. .info = alc_ch_mode_info,
  763. .get = alc_ch_mode_get,
  764. .put = alc_ch_mode_put,
  765. },
  766. { } /* end */
  767. };
  768. /* capture mixer elements */
  769. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  770. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  771. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  772. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  773. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  774. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  775. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  776. {
  777. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  778. /* The multiple "Capture Source" controls confuse alsamixer
  779. * So call somewhat different..
  780. * FIXME: the controls appear in the "playback" view!
  781. */
  782. /* .name = "Capture Source", */
  783. .name = "Input Source",
  784. .count = 3,
  785. .info = alc_mux_enum_info,
  786. .get = alc_mux_enum_get,
  787. .put = alc_mux_enum_put,
  788. },
  789. { } /* end */
  790. };
  791. /* capture mixer elements (in case NID 0x07 not available) */
  792. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  793. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  794. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  795. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  796. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  797. {
  798. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  799. /* The multiple "Capture Source" controls confuse alsamixer
  800. * So call somewhat different..
  801. * FIXME: the controls appear in the "playback" view!
  802. */
  803. /* .name = "Capture Source", */
  804. .name = "Input Source",
  805. .count = 2,
  806. .info = alc_mux_enum_info,
  807. .get = alc_mux_enum_get,
  808. .put = alc_mux_enum_put,
  809. },
  810. { } /* end */
  811. };
  812. /*
  813. * ALC880 5-stack model
  814. *
  815. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  816. * Side = 0x02 (0xd)
  817. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  818. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  819. */
  820. /* additional mixers to alc880_three_stack_mixer */
  821. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  822. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  823. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  824. { } /* end */
  825. };
  826. /* channel source setting (6/8 channel selection for 5-stack) */
  827. /* 6ch mode */
  828. static struct hda_verb alc880_fivestack_ch6_init[] = {
  829. /* set line-in to input, mute it */
  830. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  831. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  832. { } /* end */
  833. };
  834. /* 8ch mode */
  835. static struct hda_verb alc880_fivestack_ch8_init[] = {
  836. /* set line-in to output, unmute it */
  837. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  838. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  839. { } /* end */
  840. };
  841. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  842. { 6, alc880_fivestack_ch6_init },
  843. { 8, alc880_fivestack_ch8_init },
  844. };
  845. /*
  846. * ALC880 6-stack model
  847. *
  848. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  849. * Side = 0x05 (0x0f)
  850. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  851. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  852. */
  853. static hda_nid_t alc880_6st_dac_nids[4] = {
  854. /* front, rear, clfe, rear_surr */
  855. 0x02, 0x03, 0x04, 0x05
  856. };
  857. static struct hda_input_mux alc880_6stack_capture_source = {
  858. .num_items = 4,
  859. .items = {
  860. { "Mic", 0x0 },
  861. { "Front Mic", 0x1 },
  862. { "Line", 0x2 },
  863. { "CD", 0x4 },
  864. },
  865. };
  866. /* fixed 8-channels */
  867. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  868. { 8, NULL },
  869. };
  870. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  871. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  872. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  873. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  874. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  875. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  876. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  877. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  878. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  879. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  880. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  881. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  882. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  883. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  884. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  885. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  886. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  887. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  888. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  889. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  890. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  891. {
  892. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  893. .name = "Channel Mode",
  894. .info = alc_ch_mode_info,
  895. .get = alc_ch_mode_get,
  896. .put = alc_ch_mode_put,
  897. },
  898. { } /* end */
  899. };
  900. /*
  901. * ALC880 W810 model
  902. *
  903. * W810 has rear IO for:
  904. * Front (DAC 02)
  905. * Surround (DAC 03)
  906. * Center/LFE (DAC 04)
  907. * Digital out (06)
  908. *
  909. * The system also has a pair of internal speakers, and a headphone jack.
  910. * These are both connected to Line2 on the codec, hence to DAC 02.
  911. *
  912. * There is a variable resistor to control the speaker or headphone
  913. * volume. This is a hardware-only device without a software API.
  914. *
  915. * Plugging headphones in will disable the internal speakers. This is
  916. * implemented in hardware, not via the driver using jack sense. In
  917. * a similar fashion, plugging into the rear socket marked "front" will
  918. * disable both the speakers and headphones.
  919. *
  920. * For input, there's a microphone jack, and an "audio in" jack.
  921. * These may not do anything useful with this driver yet, because I
  922. * haven't setup any initialization verbs for these yet...
  923. */
  924. static hda_nid_t alc880_w810_dac_nids[3] = {
  925. /* front, rear/surround, clfe */
  926. 0x02, 0x03, 0x04
  927. };
  928. /* fixed 6 channels */
  929. static struct hda_channel_mode alc880_w810_modes[1] = {
  930. { 6, NULL }
  931. };
  932. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  933. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  934. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  935. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  936. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  937. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  938. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  939. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  940. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  941. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  942. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  943. { } /* end */
  944. };
  945. /*
  946. * Z710V model
  947. *
  948. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  949. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  950. * Line = 0x1a
  951. */
  952. static hda_nid_t alc880_z71v_dac_nids[1] = {
  953. 0x02
  954. };
  955. #define ALC880_Z71V_HP_DAC 0x03
  956. /* fixed 2 channels */
  957. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  958. { 2, NULL }
  959. };
  960. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  961. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  962. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  963. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  964. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  965. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  966. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  967. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  968. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  969. { } /* end */
  970. };
  971. /* FIXME! */
  972. /*
  973. * ALC880 F1734 model
  974. *
  975. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  976. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  977. */
  978. static hda_nid_t alc880_f1734_dac_nids[1] = {
  979. 0x03
  980. };
  981. #define ALC880_F1734_HP_DAC 0x02
  982. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  983. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  984. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  985. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  986. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  987. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  988. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  989. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  990. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  991. { } /* end */
  992. };
  993. /* FIXME! */
  994. /*
  995. * ALC880 ASUS model
  996. *
  997. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  998. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  999. * Mic = 0x18, Line = 0x1a
  1000. */
  1001. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  1002. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  1003. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  1004. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1005. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1006. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1007. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  1008. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1009. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1010. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1011. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1012. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1013. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1014. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1015. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1016. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1017. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1018. {
  1019. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1020. .name = "Channel Mode",
  1021. .info = alc_ch_mode_info,
  1022. .get = alc_ch_mode_get,
  1023. .put = alc_ch_mode_put,
  1024. },
  1025. { } /* end */
  1026. };
  1027. /* FIXME! */
  1028. /*
  1029. * ALC880 ASUS W1V model
  1030. *
  1031. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1032. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1033. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1034. */
  1035. /* additional mixers to alc880_asus_mixer */
  1036. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1037. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1038. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1039. { } /* end */
  1040. };
  1041. /* additional mixers to alc880_asus_mixer */
  1042. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1043. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1044. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1045. { } /* end */
  1046. };
  1047. /* TCL S700 */
  1048. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1049. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1050. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1051. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1052. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1053. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1054. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1055. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1056. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1057. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1058. {
  1059. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1060. /* The multiple "Capture Source" controls confuse alsamixer
  1061. * So call somewhat different..
  1062. * FIXME: the controls appear in the "playback" view!
  1063. */
  1064. /* .name = "Capture Source", */
  1065. .name = "Input Source",
  1066. .count = 1,
  1067. .info = alc_mux_enum_info,
  1068. .get = alc_mux_enum_get,
  1069. .put = alc_mux_enum_put,
  1070. },
  1071. { } /* end */
  1072. };
  1073. /* Uniwill */
  1074. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1075. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1076. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1077. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1078. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1079. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1080. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1081. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1082. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1083. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1084. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1085. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1086. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1087. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1088. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1089. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1090. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1091. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1092. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1093. {
  1094. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1095. .name = "Channel Mode",
  1096. .info = alc_ch_mode_info,
  1097. .get = alc_ch_mode_get,
  1098. .put = alc_ch_mode_put,
  1099. },
  1100. { } /* end */
  1101. };
  1102. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1103. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1104. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1105. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1106. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1107. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1108. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1109. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1110. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1111. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1112. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1113. { } /* end */
  1114. };
  1115. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1116. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1117. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1118. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1119. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1120. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1121. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1122. { } /* end */
  1123. };
  1124. /*
  1125. * build control elements
  1126. */
  1127. static int alc_build_controls(struct hda_codec *codec)
  1128. {
  1129. struct alc_spec *spec = codec->spec;
  1130. int err;
  1131. int i;
  1132. for (i = 0; i < spec->num_mixers; i++) {
  1133. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1134. if (err < 0)
  1135. return err;
  1136. }
  1137. if (spec->multiout.dig_out_nid) {
  1138. err = snd_hda_create_spdif_out_ctls(codec,
  1139. spec->multiout.dig_out_nid);
  1140. if (err < 0)
  1141. return err;
  1142. }
  1143. if (spec->dig_in_nid) {
  1144. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1145. if (err < 0)
  1146. return err;
  1147. }
  1148. return 0;
  1149. }
  1150. /*
  1151. * initialize the codec volumes, etc
  1152. */
  1153. /*
  1154. * generic initialization of ADC, input mixers and output mixers
  1155. */
  1156. static struct hda_verb alc880_volume_init_verbs[] = {
  1157. /*
  1158. * Unmute ADC0-2 and set the default input to mic-in
  1159. */
  1160. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1161. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1162. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1163. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1164. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1165. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1166. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1167. * mixer widget
  1168. * Note: PASD motherboards uses the Line In 2 as the input for front
  1169. * panel mic (mic 2)
  1170. */
  1171. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1172. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1173. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1174. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  1175. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  1176. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  1177. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1178. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1179. /*
  1180. * Set up output mixers (0x0c - 0x0f)
  1181. */
  1182. /* set vol=0 to output mixers */
  1183. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1184. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1185. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1186. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1187. /* set up input amps for analog loopback */
  1188. /* Amp Indices: DAC = 0, mixer = 1 */
  1189. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1190. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1191. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1192. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1193. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1194. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1195. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1196. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1197. { }
  1198. };
  1199. /*
  1200. * 3-stack pin configuration:
  1201. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1202. */
  1203. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1204. /*
  1205. * preset connection lists of input pins
  1206. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1207. */
  1208. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1209. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1210. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1211. /*
  1212. * Set pin mode and muting
  1213. */
  1214. /* set front pin widgets 0x14 for output */
  1215. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1216. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1217. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1218. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1219. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1220. /* Mic2 (as headphone out) for HP output */
  1221. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1222. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1223. /* Line In pin widget for input */
  1224. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1225. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1226. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1227. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1228. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1229. /* CD pin widget for input */
  1230. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1231. { }
  1232. };
  1233. /*
  1234. * 5-stack pin configuration:
  1235. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1236. * line-in/side = 0x1a, f-mic = 0x1b
  1237. */
  1238. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1239. /*
  1240. * preset connection lists of input pins
  1241. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1242. */
  1243. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1244. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1245. /*
  1246. * Set pin mode and muting
  1247. */
  1248. /* set pin widgets 0x14-0x17 for output */
  1249. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1250. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1251. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1252. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1253. /* unmute pins for output (no gain on this amp) */
  1254. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1255. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1256. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1257. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1258. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1259. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1260. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1261. /* Mic2 (as headphone out) for HP output */
  1262. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1263. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1264. /* Line In pin widget for input */
  1265. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1266. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1267. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1268. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1269. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1270. /* CD pin widget for input */
  1271. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1272. { }
  1273. };
  1274. /*
  1275. * W810 pin configuration:
  1276. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1277. */
  1278. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1279. /* hphone/speaker input selector: front DAC */
  1280. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1281. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1282. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1283. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1284. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1285. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1286. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1287. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1288. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1289. { }
  1290. };
  1291. /*
  1292. * Z71V pin configuration:
  1293. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1294. */
  1295. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  1296. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1297. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1298. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1299. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1300. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1301. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1302. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1303. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1304. { }
  1305. };
  1306. /*
  1307. * 6-stack pin configuration:
  1308. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1309. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1310. */
  1311. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1312. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1313. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1314. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1315. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1316. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1317. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1318. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1319. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1320. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1321. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1322. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1323. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1324. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1325. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1326. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1327. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1328. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1329. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1330. { }
  1331. };
  1332. /*
  1333. * Uniwill pin configuration:
  1334. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1335. * line = 0x1a
  1336. */
  1337. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1338. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1339. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1340. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1341. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1342. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1343. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1344. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1345. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1346. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1347. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1348. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1349. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1350. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1351. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1352. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1353. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1354. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1355. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1356. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1357. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1358. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1359. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1360. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1361. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1362. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1363. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1364. { }
  1365. };
  1366. /*
  1367. * Uniwill P53
  1368. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1369. */
  1370. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1371. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1372. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1373. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1374. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1375. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1376. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1377. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1378. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1379. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1380. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1381. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1382. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1383. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1384. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1385. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1386. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1387. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1388. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1389. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1390. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1391. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1392. { }
  1393. };
  1394. static struct hda_verb alc880_beep_init_verbs[] = {
  1395. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1396. { }
  1397. };
  1398. /* toggle speaker-output according to the hp-jack state */
  1399. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1400. {
  1401. unsigned int present;
  1402. unsigned char bits;
  1403. present = snd_hda_codec_read(codec, 0x14, 0,
  1404. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1405. bits = present ? HDA_AMP_MUTE : 0;
  1406. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  1407. HDA_AMP_MUTE, bits);
  1408. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  1409. HDA_AMP_MUTE, bits);
  1410. }
  1411. /* auto-toggle front mic */
  1412. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1413. {
  1414. unsigned int present;
  1415. unsigned char bits;
  1416. present = snd_hda_codec_read(codec, 0x18, 0,
  1417. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1418. bits = present ? HDA_AMP_MUTE : 0;
  1419. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1, HDA_AMP_MUTE, bits);
  1420. }
  1421. static void alc880_uniwill_automute(struct hda_codec *codec)
  1422. {
  1423. alc880_uniwill_hp_automute(codec);
  1424. alc880_uniwill_mic_automute(codec);
  1425. }
  1426. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1427. unsigned int res)
  1428. {
  1429. /* Looks like the unsol event is incompatible with the standard
  1430. * definition. 4bit tag is placed at 28 bit!
  1431. */
  1432. switch (res >> 28) {
  1433. case ALC880_HP_EVENT:
  1434. alc880_uniwill_hp_automute(codec);
  1435. break;
  1436. case ALC880_MIC_EVENT:
  1437. alc880_uniwill_mic_automute(codec);
  1438. break;
  1439. }
  1440. }
  1441. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1442. {
  1443. unsigned int present;
  1444. unsigned char bits;
  1445. present = snd_hda_codec_read(codec, 0x14, 0,
  1446. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1447. bits = present ? HDA_AMP_MUTE : 0;
  1448. snd_hda_codec_amp_stereo(codec, 0x15, HDA_INPUT, 0, HDA_AMP_MUTE, bits);
  1449. }
  1450. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1451. {
  1452. unsigned int present;
  1453. present = snd_hda_codec_read(codec, 0x21, 0,
  1454. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0);
  1455. present &= HDA_AMP_VOLMASK;
  1456. snd_hda_codec_amp_stereo(codec, 0x0c, HDA_OUTPUT, 0,
  1457. HDA_AMP_VOLMASK, present);
  1458. snd_hda_codec_amp_stereo(codec, 0x0d, HDA_OUTPUT, 0,
  1459. HDA_AMP_VOLMASK, present);
  1460. }
  1461. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1462. unsigned int res)
  1463. {
  1464. /* Looks like the unsol event is incompatible with the standard
  1465. * definition. 4bit tag is placed at 28 bit!
  1466. */
  1467. if ((res >> 28) == ALC880_HP_EVENT)
  1468. alc880_uniwill_p53_hp_automute(codec);
  1469. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1470. alc880_uniwill_p53_dcvol_automute(codec);
  1471. }
  1472. /* FIXME! */
  1473. /*
  1474. * F1734 pin configuration:
  1475. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1476. */
  1477. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1478. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1479. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1480. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1481. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1482. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1483. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1484. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1485. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1486. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1487. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1488. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1489. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1490. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1491. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1492. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1493. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1494. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1495. { }
  1496. };
  1497. /* FIXME! */
  1498. /*
  1499. * ASUS pin configuration:
  1500. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1501. */
  1502. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1503. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1504. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1505. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1506. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1507. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1508. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1509. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1510. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1511. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1512. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1513. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1514. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1515. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1516. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1517. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1518. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1519. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1520. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1521. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1522. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1523. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1524. { }
  1525. };
  1526. /* Enable GPIO mask and set output */
  1527. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1528. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1529. /* Clevo m520g init */
  1530. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1531. /* headphone output */
  1532. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1533. /* line-out */
  1534. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1535. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1536. /* Line-in */
  1537. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1538. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1539. /* CD */
  1540. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1541. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1542. /* Mic1 (rear panel) */
  1543. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1544. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1545. /* Mic2 (front panel) */
  1546. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1547. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1548. /* headphone */
  1549. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1550. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1551. /* change to EAPD mode */
  1552. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1553. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1554. { }
  1555. };
  1556. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1557. /* change to EAPD mode */
  1558. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1559. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1560. /* Headphone output */
  1561. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1562. /* Front output*/
  1563. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1564. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1565. /* Line In pin widget for input */
  1566. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1567. /* CD pin widget for input */
  1568. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1569. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1570. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1571. /* change to EAPD mode */
  1572. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1573. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1574. { }
  1575. };
  1576. /*
  1577. * LG m1 express dual
  1578. *
  1579. * Pin assignment:
  1580. * Rear Line-In/Out (blue): 0x14
  1581. * Build-in Mic-In: 0x15
  1582. * Speaker-out: 0x17
  1583. * HP-Out (green): 0x1b
  1584. * Mic-In/Out (red): 0x19
  1585. * SPDIF-Out: 0x1e
  1586. */
  1587. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1588. static hda_nid_t alc880_lg_dac_nids[3] = {
  1589. 0x05, 0x02, 0x03
  1590. };
  1591. /* seems analog CD is not working */
  1592. static struct hda_input_mux alc880_lg_capture_source = {
  1593. .num_items = 3,
  1594. .items = {
  1595. { "Mic", 0x1 },
  1596. { "Line", 0x5 },
  1597. { "Internal Mic", 0x6 },
  1598. },
  1599. };
  1600. /* 2,4,6 channel modes */
  1601. static struct hda_verb alc880_lg_ch2_init[] = {
  1602. /* set line-in and mic-in to input */
  1603. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1604. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1605. { }
  1606. };
  1607. static struct hda_verb alc880_lg_ch4_init[] = {
  1608. /* set line-in to out and mic-in to input */
  1609. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1610. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1611. { }
  1612. };
  1613. static struct hda_verb alc880_lg_ch6_init[] = {
  1614. /* set line-in and mic-in to output */
  1615. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1616. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1617. { }
  1618. };
  1619. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1620. { 2, alc880_lg_ch2_init },
  1621. { 4, alc880_lg_ch4_init },
  1622. { 6, alc880_lg_ch6_init },
  1623. };
  1624. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1625. /* FIXME: it's not really "master" but front channels */
  1626. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1627. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1628. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1629. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1630. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1631. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1632. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1633. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1634. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1635. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1636. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1637. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1638. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1639. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1640. {
  1641. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1642. .name = "Channel Mode",
  1643. .info = alc_ch_mode_info,
  1644. .get = alc_ch_mode_get,
  1645. .put = alc_ch_mode_put,
  1646. },
  1647. { } /* end */
  1648. };
  1649. static struct hda_verb alc880_lg_init_verbs[] = {
  1650. /* set capture source to mic-in */
  1651. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1652. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1653. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1654. /* mute all amp mixer inputs */
  1655. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1656. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  1657. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1658. /* line-in to input */
  1659. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1660. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1661. /* built-in mic */
  1662. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1663. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1664. /* speaker-out */
  1665. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1666. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1667. /* mic-in to input */
  1668. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1669. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1670. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1671. /* HP-out */
  1672. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1673. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1674. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1675. /* jack sense */
  1676. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1677. { }
  1678. };
  1679. /* toggle speaker-output according to the hp-jack state */
  1680. static void alc880_lg_automute(struct hda_codec *codec)
  1681. {
  1682. unsigned int present;
  1683. unsigned char bits;
  1684. present = snd_hda_codec_read(codec, 0x1b, 0,
  1685. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1686. bits = present ? HDA_AMP_MUTE : 0;
  1687. snd_hda_codec_amp_stereo(codec, 0x17, HDA_OUTPUT, 0,
  1688. HDA_AMP_MUTE, bits);
  1689. }
  1690. static void alc880_lg_unsol_event(struct hda_codec *codec, unsigned int res)
  1691. {
  1692. /* Looks like the unsol event is incompatible with the standard
  1693. * definition. 4bit tag is placed at 28 bit!
  1694. */
  1695. if ((res >> 28) == 0x01)
  1696. alc880_lg_automute(codec);
  1697. }
  1698. /*
  1699. * LG LW20
  1700. *
  1701. * Pin assignment:
  1702. * Speaker-out: 0x14
  1703. * Mic-In: 0x18
  1704. * Built-in Mic-In: 0x19
  1705. * Line-In: 0x1b
  1706. * HP-Out: 0x1a
  1707. * SPDIF-Out: 0x1e
  1708. */
  1709. static struct hda_input_mux alc880_lg_lw_capture_source = {
  1710. .num_items = 3,
  1711. .items = {
  1712. { "Mic", 0x0 },
  1713. { "Internal Mic", 0x1 },
  1714. { "Line In", 0x2 },
  1715. },
  1716. };
  1717. #define alc880_lg_lw_modes alc880_threestack_modes
  1718. static struct snd_kcontrol_new alc880_lg_lw_mixer[] = {
  1719. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1720. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  1721. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1722. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  1723. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1724. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1725. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1726. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1727. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1728. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1729. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1730. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1731. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  1732. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  1733. {
  1734. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1735. .name = "Channel Mode",
  1736. .info = alc_ch_mode_info,
  1737. .get = alc_ch_mode_get,
  1738. .put = alc_ch_mode_put,
  1739. },
  1740. { } /* end */
  1741. };
  1742. static struct hda_verb alc880_lg_lw_init_verbs[] = {
  1743. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1744. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1745. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1746. /* set capture source to mic-in */
  1747. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1748. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1749. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1750. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  1751. /* speaker-out */
  1752. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1753. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1754. /* HP-out */
  1755. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1756. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1757. /* mic-in to input */
  1758. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1759. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1760. /* built-in mic */
  1761. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1762. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1763. /* jack sense */
  1764. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1765. { }
  1766. };
  1767. /* toggle speaker-output according to the hp-jack state */
  1768. static void alc880_lg_lw_automute(struct hda_codec *codec)
  1769. {
  1770. unsigned int present;
  1771. unsigned char bits;
  1772. present = snd_hda_codec_read(codec, 0x1b, 0,
  1773. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1774. bits = present ? HDA_AMP_MUTE : 0;
  1775. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  1776. HDA_AMP_MUTE, bits);
  1777. }
  1778. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1779. {
  1780. /* Looks like the unsol event is incompatible with the standard
  1781. * definition. 4bit tag is placed at 28 bit!
  1782. */
  1783. if ((res >> 28) == 0x01)
  1784. alc880_lg_lw_automute(codec);
  1785. }
  1786. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1787. static struct hda_amp_list alc880_loopbacks[] = {
  1788. { 0x0b, HDA_INPUT, 0 },
  1789. { 0x0b, HDA_INPUT, 1 },
  1790. { 0x0b, HDA_INPUT, 2 },
  1791. { 0x0b, HDA_INPUT, 3 },
  1792. { 0x0b, HDA_INPUT, 4 },
  1793. { } /* end */
  1794. };
  1795. static struct hda_amp_list alc880_lg_loopbacks[] = {
  1796. { 0x0b, HDA_INPUT, 1 },
  1797. { 0x0b, HDA_INPUT, 6 },
  1798. { 0x0b, HDA_INPUT, 7 },
  1799. { } /* end */
  1800. };
  1801. #endif
  1802. /*
  1803. * Common callbacks
  1804. */
  1805. static int alc_init(struct hda_codec *codec)
  1806. {
  1807. struct alc_spec *spec = codec->spec;
  1808. unsigned int i;
  1809. for (i = 0; i < spec->num_init_verbs; i++)
  1810. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1811. if (spec->init_hook)
  1812. spec->init_hook(codec);
  1813. return 0;
  1814. }
  1815. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1816. {
  1817. struct alc_spec *spec = codec->spec;
  1818. if (spec->unsol_event)
  1819. spec->unsol_event(codec, res);
  1820. }
  1821. #ifdef CONFIG_SND_HDA_POWER_SAVE
  1822. static int alc_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  1823. {
  1824. struct alc_spec *spec = codec->spec;
  1825. return snd_hda_check_amp_list_power(codec, &spec->loopback, nid);
  1826. }
  1827. #endif
  1828. /*
  1829. * Analog playback callbacks
  1830. */
  1831. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1832. struct hda_codec *codec,
  1833. struct snd_pcm_substream *substream)
  1834. {
  1835. struct alc_spec *spec = codec->spec;
  1836. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1837. }
  1838. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1839. struct hda_codec *codec,
  1840. unsigned int stream_tag,
  1841. unsigned int format,
  1842. struct snd_pcm_substream *substream)
  1843. {
  1844. struct alc_spec *spec = codec->spec;
  1845. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1846. stream_tag, format, substream);
  1847. }
  1848. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1849. struct hda_codec *codec,
  1850. struct snd_pcm_substream *substream)
  1851. {
  1852. struct alc_spec *spec = codec->spec;
  1853. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1854. }
  1855. /*
  1856. * Digital out
  1857. */
  1858. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1859. struct hda_codec *codec,
  1860. struct snd_pcm_substream *substream)
  1861. {
  1862. struct alc_spec *spec = codec->spec;
  1863. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1864. }
  1865. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1866. struct hda_codec *codec,
  1867. unsigned int stream_tag,
  1868. unsigned int format,
  1869. struct snd_pcm_substream *substream)
  1870. {
  1871. struct alc_spec *spec = codec->spec;
  1872. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1873. stream_tag, format, substream);
  1874. }
  1875. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1876. struct hda_codec *codec,
  1877. struct snd_pcm_substream *substream)
  1878. {
  1879. struct alc_spec *spec = codec->spec;
  1880. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1881. }
  1882. /*
  1883. * Analog capture
  1884. */
  1885. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1886. struct hda_codec *codec,
  1887. unsigned int stream_tag,
  1888. unsigned int format,
  1889. struct snd_pcm_substream *substream)
  1890. {
  1891. struct alc_spec *spec = codec->spec;
  1892. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1893. stream_tag, 0, format);
  1894. return 0;
  1895. }
  1896. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1897. struct hda_codec *codec,
  1898. struct snd_pcm_substream *substream)
  1899. {
  1900. struct alc_spec *spec = codec->spec;
  1901. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1902. 0, 0, 0);
  1903. return 0;
  1904. }
  1905. /*
  1906. */
  1907. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1908. .substreams = 1,
  1909. .channels_min = 2,
  1910. .channels_max = 8,
  1911. /* NID is set in alc_build_pcms */
  1912. .ops = {
  1913. .open = alc880_playback_pcm_open,
  1914. .prepare = alc880_playback_pcm_prepare,
  1915. .cleanup = alc880_playback_pcm_cleanup
  1916. },
  1917. };
  1918. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1919. .substreams = 2,
  1920. .channels_min = 2,
  1921. .channels_max = 2,
  1922. /* NID is set in alc_build_pcms */
  1923. .ops = {
  1924. .prepare = alc880_capture_pcm_prepare,
  1925. .cleanup = alc880_capture_pcm_cleanup
  1926. },
  1927. };
  1928. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1929. .substreams = 1,
  1930. .channels_min = 2,
  1931. .channels_max = 2,
  1932. /* NID is set in alc_build_pcms */
  1933. .ops = {
  1934. .open = alc880_dig_playback_pcm_open,
  1935. .close = alc880_dig_playback_pcm_close,
  1936. .prepare = alc880_dig_playback_pcm_prepare
  1937. },
  1938. };
  1939. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1940. .substreams = 1,
  1941. .channels_min = 2,
  1942. .channels_max = 2,
  1943. /* NID is set in alc_build_pcms */
  1944. };
  1945. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1946. static struct hda_pcm_stream alc_pcm_null_playback = {
  1947. .substreams = 0,
  1948. .channels_min = 0,
  1949. .channels_max = 0,
  1950. };
  1951. static int alc_build_pcms(struct hda_codec *codec)
  1952. {
  1953. struct alc_spec *spec = codec->spec;
  1954. struct hda_pcm *info = spec->pcm_rec;
  1955. int i;
  1956. codec->num_pcms = 1;
  1957. codec->pcm_info = info;
  1958. info->name = spec->stream_name_analog;
  1959. if (spec->stream_analog_playback) {
  1960. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1961. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1962. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1963. }
  1964. if (spec->stream_analog_capture) {
  1965. snd_assert(spec->adc_nids, return -EINVAL);
  1966. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1967. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1968. }
  1969. if (spec->channel_mode) {
  1970. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1971. for (i = 0; i < spec->num_channel_mode; i++) {
  1972. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1973. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1974. }
  1975. }
  1976. }
  1977. /* SPDIF for stream index #1 */
  1978. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1979. codec->num_pcms = 2;
  1980. info = spec->pcm_rec + 1;
  1981. info->name = spec->stream_name_digital;
  1982. if (spec->multiout.dig_out_nid &&
  1983. spec->stream_digital_playback) {
  1984. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1985. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1986. }
  1987. if (spec->dig_in_nid &&
  1988. spec->stream_digital_capture) {
  1989. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1990. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1991. }
  1992. }
  1993. /* If the use of more than one ADC is requested for the current
  1994. * model, configure a second analog capture-only PCM.
  1995. */
  1996. /* Additional Analaog capture for index #2 */
  1997. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1998. spec->adc_nids) {
  1999. codec->num_pcms = 3;
  2000. info = spec->pcm_rec + 2;
  2001. info->name = spec->stream_name_analog;
  2002. /* No playback stream for second PCM */
  2003. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2004. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2005. if (spec->stream_analog_capture) {
  2006. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2007. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2008. }
  2009. }
  2010. return 0;
  2011. }
  2012. static void alc_free(struct hda_codec *codec)
  2013. {
  2014. struct alc_spec *spec = codec->spec;
  2015. unsigned int i;
  2016. if (!spec)
  2017. return;
  2018. if (spec->kctl_alloc) {
  2019. for (i = 0; i < spec->num_kctl_used; i++)
  2020. kfree(spec->kctl_alloc[i].name);
  2021. kfree(spec->kctl_alloc);
  2022. }
  2023. kfree(spec);
  2024. }
  2025. /*
  2026. */
  2027. static struct hda_codec_ops alc_patch_ops = {
  2028. .build_controls = alc_build_controls,
  2029. .build_pcms = alc_build_pcms,
  2030. .init = alc_init,
  2031. .free = alc_free,
  2032. .unsol_event = alc_unsol_event,
  2033. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2034. .check_power_status = alc_check_power_status,
  2035. #endif
  2036. };
  2037. /*
  2038. * Test configuration for debugging
  2039. *
  2040. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2041. * enum controls.
  2042. */
  2043. #ifdef CONFIG_SND_DEBUG
  2044. static hda_nid_t alc880_test_dac_nids[4] = {
  2045. 0x02, 0x03, 0x04, 0x05
  2046. };
  2047. static struct hda_input_mux alc880_test_capture_source = {
  2048. .num_items = 7,
  2049. .items = {
  2050. { "In-1", 0x0 },
  2051. { "In-2", 0x1 },
  2052. { "In-3", 0x2 },
  2053. { "In-4", 0x3 },
  2054. { "CD", 0x4 },
  2055. { "Front", 0x5 },
  2056. { "Surround", 0x6 },
  2057. },
  2058. };
  2059. static struct hda_channel_mode alc880_test_modes[4] = {
  2060. { 2, NULL },
  2061. { 4, NULL },
  2062. { 6, NULL },
  2063. { 8, NULL },
  2064. };
  2065. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2066. struct snd_ctl_elem_info *uinfo)
  2067. {
  2068. static char *texts[] = {
  2069. "N/A", "Line Out", "HP Out",
  2070. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2071. };
  2072. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2073. uinfo->count = 1;
  2074. uinfo->value.enumerated.items = 8;
  2075. if (uinfo->value.enumerated.item >= 8)
  2076. uinfo->value.enumerated.item = 7;
  2077. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2078. return 0;
  2079. }
  2080. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2081. struct snd_ctl_elem_value *ucontrol)
  2082. {
  2083. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2084. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2085. unsigned int pin_ctl, item = 0;
  2086. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2087. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2088. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2089. if (pin_ctl & AC_PINCTL_HP_EN)
  2090. item = 2;
  2091. else
  2092. item = 1;
  2093. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2094. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2095. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2096. case AC_PINCTL_VREF_50: item = 4; break;
  2097. case AC_PINCTL_VREF_GRD: item = 5; break;
  2098. case AC_PINCTL_VREF_80: item = 6; break;
  2099. case AC_PINCTL_VREF_100: item = 7; break;
  2100. }
  2101. }
  2102. ucontrol->value.enumerated.item[0] = item;
  2103. return 0;
  2104. }
  2105. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2106. struct snd_ctl_elem_value *ucontrol)
  2107. {
  2108. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2109. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2110. static unsigned int ctls[] = {
  2111. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2112. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2113. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2114. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2115. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2116. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2117. };
  2118. unsigned int old_ctl, new_ctl;
  2119. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2120. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2121. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2122. if (old_ctl != new_ctl) {
  2123. int val;
  2124. snd_hda_codec_write_cache(codec, nid, 0,
  2125. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2126. new_ctl);
  2127. val = ucontrol->value.enumerated.item[0] >= 3 ?
  2128. HDA_AMP_MUTE : 0;
  2129. snd_hda_codec_amp_stereo(codec, nid, HDA_OUTPUT, 0,
  2130. HDA_AMP_MUTE, val);
  2131. return 1;
  2132. }
  2133. return 0;
  2134. }
  2135. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2136. struct snd_ctl_elem_info *uinfo)
  2137. {
  2138. static char *texts[] = {
  2139. "Front", "Surround", "CLFE", "Side"
  2140. };
  2141. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2142. uinfo->count = 1;
  2143. uinfo->value.enumerated.items = 4;
  2144. if (uinfo->value.enumerated.item >= 4)
  2145. uinfo->value.enumerated.item = 3;
  2146. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2147. return 0;
  2148. }
  2149. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2150. struct snd_ctl_elem_value *ucontrol)
  2151. {
  2152. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2153. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2154. unsigned int sel;
  2155. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2156. ucontrol->value.enumerated.item[0] = sel & 3;
  2157. return 0;
  2158. }
  2159. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2160. struct snd_ctl_elem_value *ucontrol)
  2161. {
  2162. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2163. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2164. unsigned int sel;
  2165. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2166. if (ucontrol->value.enumerated.item[0] != sel) {
  2167. sel = ucontrol->value.enumerated.item[0] & 3;
  2168. snd_hda_codec_write_cache(codec, nid, 0,
  2169. AC_VERB_SET_CONNECT_SEL, sel);
  2170. return 1;
  2171. }
  2172. return 0;
  2173. }
  2174. #define PIN_CTL_TEST(xname,nid) { \
  2175. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2176. .name = xname, \
  2177. .info = alc_test_pin_ctl_info, \
  2178. .get = alc_test_pin_ctl_get, \
  2179. .put = alc_test_pin_ctl_put, \
  2180. .private_value = nid \
  2181. }
  2182. #define PIN_SRC_TEST(xname,nid) { \
  2183. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2184. .name = xname, \
  2185. .info = alc_test_pin_src_info, \
  2186. .get = alc_test_pin_src_get, \
  2187. .put = alc_test_pin_src_put, \
  2188. .private_value = nid \
  2189. }
  2190. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2191. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2192. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2193. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2194. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2195. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2196. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2197. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2198. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2199. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2200. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2201. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2202. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2203. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2204. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2205. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2206. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2207. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2208. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2209. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2210. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2211. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2212. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2213. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2214. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2215. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2216. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2217. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2218. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2219. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2220. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2221. {
  2222. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2223. .name = "Channel Mode",
  2224. .info = alc_ch_mode_info,
  2225. .get = alc_ch_mode_get,
  2226. .put = alc_ch_mode_put,
  2227. },
  2228. { } /* end */
  2229. };
  2230. static struct hda_verb alc880_test_init_verbs[] = {
  2231. /* Unmute inputs of 0x0c - 0x0f */
  2232. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2233. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2234. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2235. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2236. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2237. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2238. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2239. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2240. /* Vol output for 0x0c-0x0f */
  2241. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2242. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2243. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2244. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2245. /* Set output pins 0x14-0x17 */
  2246. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2247. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2248. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2249. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2250. /* Unmute output pins 0x14-0x17 */
  2251. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2252. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2253. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2254. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2255. /* Set input pins 0x18-0x1c */
  2256. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2257. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2258. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2259. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2260. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2261. /* Mute input pins 0x18-0x1b */
  2262. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2263. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2264. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2265. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2266. /* ADC set up */
  2267. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2268. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2269. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2270. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2271. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2272. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2273. /* Analog input/passthru */
  2274. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2275. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2276. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2277. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2278. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2279. { }
  2280. };
  2281. #endif
  2282. /*
  2283. */
  2284. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2285. [ALC880_3ST] = "3stack",
  2286. [ALC880_TCL_S700] = "tcl",
  2287. [ALC880_3ST_DIG] = "3stack-digout",
  2288. [ALC880_CLEVO] = "clevo",
  2289. [ALC880_5ST] = "5stack",
  2290. [ALC880_5ST_DIG] = "5stack-digout",
  2291. [ALC880_W810] = "w810",
  2292. [ALC880_Z71V] = "z71v",
  2293. [ALC880_6ST] = "6stack",
  2294. [ALC880_6ST_DIG] = "6stack-digout",
  2295. [ALC880_ASUS] = "asus",
  2296. [ALC880_ASUS_W1V] = "asus-w1v",
  2297. [ALC880_ASUS_DIG] = "asus-dig",
  2298. [ALC880_ASUS_DIG2] = "asus-dig2",
  2299. [ALC880_UNIWILL_DIG] = "uniwill",
  2300. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2301. [ALC880_FUJITSU] = "fujitsu",
  2302. [ALC880_F1734] = "F1734",
  2303. [ALC880_LG] = "lg",
  2304. [ALC880_LG_LW] = "lg-lw",
  2305. #ifdef CONFIG_SND_DEBUG
  2306. [ALC880_TEST] = "test",
  2307. #endif
  2308. [ALC880_AUTO] = "auto",
  2309. };
  2310. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2311. /* Broken BIOS configuration */
  2312. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2313. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2314. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2315. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2316. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2317. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2318. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2319. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2320. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2321. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2322. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2323. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2324. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2325. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2326. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2327. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2328. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2329. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2330. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2331. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2332. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2333. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2334. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2335. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2336. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2337. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2338. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2339. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2340. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2341. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2342. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2343. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2344. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2345. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2346. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2347. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2348. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2349. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2350. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2351. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2352. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2353. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2354. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2355. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2356. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2357. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2358. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2359. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2360. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2361. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2362. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2363. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2364. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2365. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2366. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2367. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2368. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2369. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2370. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2371. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2372. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2373. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2374. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2375. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2376. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2377. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2378. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2379. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2380. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2381. {}
  2382. };
  2383. /*
  2384. * ALC880 codec presets
  2385. */
  2386. static struct alc_config_preset alc880_presets[] = {
  2387. [ALC880_3ST] = {
  2388. .mixers = { alc880_three_stack_mixer },
  2389. .init_verbs = { alc880_volume_init_verbs,
  2390. alc880_pin_3stack_init_verbs },
  2391. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2392. .dac_nids = alc880_dac_nids,
  2393. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2394. .channel_mode = alc880_threestack_modes,
  2395. .need_dac_fix = 1,
  2396. .input_mux = &alc880_capture_source,
  2397. },
  2398. [ALC880_3ST_DIG] = {
  2399. .mixers = { alc880_three_stack_mixer },
  2400. .init_verbs = { alc880_volume_init_verbs,
  2401. alc880_pin_3stack_init_verbs },
  2402. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2403. .dac_nids = alc880_dac_nids,
  2404. .dig_out_nid = ALC880_DIGOUT_NID,
  2405. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2406. .channel_mode = alc880_threestack_modes,
  2407. .need_dac_fix = 1,
  2408. .input_mux = &alc880_capture_source,
  2409. },
  2410. [ALC880_TCL_S700] = {
  2411. .mixers = { alc880_tcl_s700_mixer },
  2412. .init_verbs = { alc880_volume_init_verbs,
  2413. alc880_pin_tcl_S700_init_verbs,
  2414. alc880_gpio2_init_verbs },
  2415. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2416. .dac_nids = alc880_dac_nids,
  2417. .hp_nid = 0x03,
  2418. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2419. .channel_mode = alc880_2_jack_modes,
  2420. .input_mux = &alc880_capture_source,
  2421. },
  2422. [ALC880_5ST] = {
  2423. .mixers = { alc880_three_stack_mixer,
  2424. alc880_five_stack_mixer},
  2425. .init_verbs = { alc880_volume_init_verbs,
  2426. alc880_pin_5stack_init_verbs },
  2427. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2428. .dac_nids = alc880_dac_nids,
  2429. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2430. .channel_mode = alc880_fivestack_modes,
  2431. .input_mux = &alc880_capture_source,
  2432. },
  2433. [ALC880_5ST_DIG] = {
  2434. .mixers = { alc880_three_stack_mixer,
  2435. alc880_five_stack_mixer },
  2436. .init_verbs = { alc880_volume_init_verbs,
  2437. alc880_pin_5stack_init_verbs },
  2438. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2439. .dac_nids = alc880_dac_nids,
  2440. .dig_out_nid = ALC880_DIGOUT_NID,
  2441. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2442. .channel_mode = alc880_fivestack_modes,
  2443. .input_mux = &alc880_capture_source,
  2444. },
  2445. [ALC880_6ST] = {
  2446. .mixers = { alc880_six_stack_mixer },
  2447. .init_verbs = { alc880_volume_init_verbs,
  2448. alc880_pin_6stack_init_verbs },
  2449. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2450. .dac_nids = alc880_6st_dac_nids,
  2451. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2452. .channel_mode = alc880_sixstack_modes,
  2453. .input_mux = &alc880_6stack_capture_source,
  2454. },
  2455. [ALC880_6ST_DIG] = {
  2456. .mixers = { alc880_six_stack_mixer },
  2457. .init_verbs = { alc880_volume_init_verbs,
  2458. alc880_pin_6stack_init_verbs },
  2459. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2460. .dac_nids = alc880_6st_dac_nids,
  2461. .dig_out_nid = ALC880_DIGOUT_NID,
  2462. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2463. .channel_mode = alc880_sixstack_modes,
  2464. .input_mux = &alc880_6stack_capture_source,
  2465. },
  2466. [ALC880_W810] = {
  2467. .mixers = { alc880_w810_base_mixer },
  2468. .init_verbs = { alc880_volume_init_verbs,
  2469. alc880_pin_w810_init_verbs,
  2470. alc880_gpio2_init_verbs },
  2471. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2472. .dac_nids = alc880_w810_dac_nids,
  2473. .dig_out_nid = ALC880_DIGOUT_NID,
  2474. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2475. .channel_mode = alc880_w810_modes,
  2476. .input_mux = &alc880_capture_source,
  2477. },
  2478. [ALC880_Z71V] = {
  2479. .mixers = { alc880_z71v_mixer },
  2480. .init_verbs = { alc880_volume_init_verbs,
  2481. alc880_pin_z71v_init_verbs },
  2482. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2483. .dac_nids = alc880_z71v_dac_nids,
  2484. .dig_out_nid = ALC880_DIGOUT_NID,
  2485. .hp_nid = 0x03,
  2486. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2487. .channel_mode = alc880_2_jack_modes,
  2488. .input_mux = &alc880_capture_source,
  2489. },
  2490. [ALC880_F1734] = {
  2491. .mixers = { alc880_f1734_mixer },
  2492. .init_verbs = { alc880_volume_init_verbs,
  2493. alc880_pin_f1734_init_verbs },
  2494. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2495. .dac_nids = alc880_f1734_dac_nids,
  2496. .hp_nid = 0x02,
  2497. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2498. .channel_mode = alc880_2_jack_modes,
  2499. .input_mux = &alc880_capture_source,
  2500. },
  2501. [ALC880_ASUS] = {
  2502. .mixers = { alc880_asus_mixer },
  2503. .init_verbs = { alc880_volume_init_verbs,
  2504. alc880_pin_asus_init_verbs,
  2505. alc880_gpio1_init_verbs },
  2506. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2507. .dac_nids = alc880_asus_dac_nids,
  2508. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2509. .channel_mode = alc880_asus_modes,
  2510. .need_dac_fix = 1,
  2511. .input_mux = &alc880_capture_source,
  2512. },
  2513. [ALC880_ASUS_DIG] = {
  2514. .mixers = { alc880_asus_mixer },
  2515. .init_verbs = { alc880_volume_init_verbs,
  2516. alc880_pin_asus_init_verbs,
  2517. alc880_gpio1_init_verbs },
  2518. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2519. .dac_nids = alc880_asus_dac_nids,
  2520. .dig_out_nid = ALC880_DIGOUT_NID,
  2521. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2522. .channel_mode = alc880_asus_modes,
  2523. .need_dac_fix = 1,
  2524. .input_mux = &alc880_capture_source,
  2525. },
  2526. [ALC880_ASUS_DIG2] = {
  2527. .mixers = { alc880_asus_mixer },
  2528. .init_verbs = { alc880_volume_init_verbs,
  2529. alc880_pin_asus_init_verbs,
  2530. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2531. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2532. .dac_nids = alc880_asus_dac_nids,
  2533. .dig_out_nid = ALC880_DIGOUT_NID,
  2534. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2535. .channel_mode = alc880_asus_modes,
  2536. .need_dac_fix = 1,
  2537. .input_mux = &alc880_capture_source,
  2538. },
  2539. [ALC880_ASUS_W1V] = {
  2540. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2541. .init_verbs = { alc880_volume_init_verbs,
  2542. alc880_pin_asus_init_verbs,
  2543. alc880_gpio1_init_verbs },
  2544. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2545. .dac_nids = alc880_asus_dac_nids,
  2546. .dig_out_nid = ALC880_DIGOUT_NID,
  2547. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2548. .channel_mode = alc880_asus_modes,
  2549. .need_dac_fix = 1,
  2550. .input_mux = &alc880_capture_source,
  2551. },
  2552. [ALC880_UNIWILL_DIG] = {
  2553. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2554. .init_verbs = { alc880_volume_init_verbs,
  2555. alc880_pin_asus_init_verbs },
  2556. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2557. .dac_nids = alc880_asus_dac_nids,
  2558. .dig_out_nid = ALC880_DIGOUT_NID,
  2559. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2560. .channel_mode = alc880_asus_modes,
  2561. .need_dac_fix = 1,
  2562. .input_mux = &alc880_capture_source,
  2563. },
  2564. [ALC880_UNIWILL] = {
  2565. .mixers = { alc880_uniwill_mixer },
  2566. .init_verbs = { alc880_volume_init_verbs,
  2567. alc880_uniwill_init_verbs },
  2568. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2569. .dac_nids = alc880_asus_dac_nids,
  2570. .dig_out_nid = ALC880_DIGOUT_NID,
  2571. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2572. .channel_mode = alc880_threestack_modes,
  2573. .need_dac_fix = 1,
  2574. .input_mux = &alc880_capture_source,
  2575. .unsol_event = alc880_uniwill_unsol_event,
  2576. .init_hook = alc880_uniwill_automute,
  2577. },
  2578. [ALC880_UNIWILL_P53] = {
  2579. .mixers = { alc880_uniwill_p53_mixer },
  2580. .init_verbs = { alc880_volume_init_verbs,
  2581. alc880_uniwill_p53_init_verbs },
  2582. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2583. .dac_nids = alc880_asus_dac_nids,
  2584. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2585. .channel_mode = alc880_threestack_modes,
  2586. .input_mux = &alc880_capture_source,
  2587. .unsol_event = alc880_uniwill_p53_unsol_event,
  2588. .init_hook = alc880_uniwill_p53_hp_automute,
  2589. },
  2590. [ALC880_FUJITSU] = {
  2591. .mixers = { alc880_fujitsu_mixer,
  2592. alc880_pcbeep_mixer, },
  2593. .init_verbs = { alc880_volume_init_verbs,
  2594. alc880_uniwill_p53_init_verbs,
  2595. alc880_beep_init_verbs },
  2596. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2597. .dac_nids = alc880_dac_nids,
  2598. .dig_out_nid = ALC880_DIGOUT_NID,
  2599. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2600. .channel_mode = alc880_2_jack_modes,
  2601. .input_mux = &alc880_capture_source,
  2602. .unsol_event = alc880_uniwill_p53_unsol_event,
  2603. .init_hook = alc880_uniwill_p53_hp_automute,
  2604. },
  2605. [ALC880_CLEVO] = {
  2606. .mixers = { alc880_three_stack_mixer },
  2607. .init_verbs = { alc880_volume_init_verbs,
  2608. alc880_pin_clevo_init_verbs },
  2609. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2610. .dac_nids = alc880_dac_nids,
  2611. .hp_nid = 0x03,
  2612. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2613. .channel_mode = alc880_threestack_modes,
  2614. .need_dac_fix = 1,
  2615. .input_mux = &alc880_capture_source,
  2616. },
  2617. [ALC880_LG] = {
  2618. .mixers = { alc880_lg_mixer },
  2619. .init_verbs = { alc880_volume_init_verbs,
  2620. alc880_lg_init_verbs },
  2621. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2622. .dac_nids = alc880_lg_dac_nids,
  2623. .dig_out_nid = ALC880_DIGOUT_NID,
  2624. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2625. .channel_mode = alc880_lg_ch_modes,
  2626. .need_dac_fix = 1,
  2627. .input_mux = &alc880_lg_capture_source,
  2628. .unsol_event = alc880_lg_unsol_event,
  2629. .init_hook = alc880_lg_automute,
  2630. #ifdef CONFIG_SND_HDA_POWER_SAVE
  2631. .loopbacks = alc880_lg_loopbacks,
  2632. #endif
  2633. },
  2634. [ALC880_LG_LW] = {
  2635. .mixers = { alc880_lg_lw_mixer },
  2636. .init_verbs = { alc880_volume_init_verbs,
  2637. alc880_lg_lw_init_verbs },
  2638. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2639. .dac_nids = alc880_dac_nids,
  2640. .dig_out_nid = ALC880_DIGOUT_NID,
  2641. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2642. .channel_mode = alc880_lg_lw_modes,
  2643. .input_mux = &alc880_lg_lw_capture_source,
  2644. .unsol_event = alc880_lg_lw_unsol_event,
  2645. .init_hook = alc880_lg_lw_automute,
  2646. },
  2647. #ifdef CONFIG_SND_DEBUG
  2648. [ALC880_TEST] = {
  2649. .mixers = { alc880_test_mixer },
  2650. .init_verbs = { alc880_test_init_verbs },
  2651. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2652. .dac_nids = alc880_test_dac_nids,
  2653. .dig_out_nid = ALC880_DIGOUT_NID,
  2654. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2655. .channel_mode = alc880_test_modes,
  2656. .input_mux = &alc880_test_capture_source,
  2657. },
  2658. #endif
  2659. };
  2660. /*
  2661. * Automatic parse of I/O pins from the BIOS configuration
  2662. */
  2663. #define NUM_CONTROL_ALLOC 32
  2664. #define NUM_VERB_ALLOC 32
  2665. enum {
  2666. ALC_CTL_WIDGET_VOL,
  2667. ALC_CTL_WIDGET_MUTE,
  2668. ALC_CTL_BIND_MUTE,
  2669. };
  2670. static struct snd_kcontrol_new alc880_control_templates[] = {
  2671. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2672. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2673. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2674. };
  2675. /* add dynamic controls */
  2676. static int add_control(struct alc_spec *spec, int type, const char *name,
  2677. unsigned long val)
  2678. {
  2679. struct snd_kcontrol_new *knew;
  2680. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2681. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2682. /* array + terminator */
  2683. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2684. if (!knew)
  2685. return -ENOMEM;
  2686. if (spec->kctl_alloc) {
  2687. memcpy(knew, spec->kctl_alloc,
  2688. sizeof(*knew) * spec->num_kctl_alloc);
  2689. kfree(spec->kctl_alloc);
  2690. }
  2691. spec->kctl_alloc = knew;
  2692. spec->num_kctl_alloc = num;
  2693. }
  2694. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2695. *knew = alc880_control_templates[type];
  2696. knew->name = kstrdup(name, GFP_KERNEL);
  2697. if (!knew->name)
  2698. return -ENOMEM;
  2699. knew->private_value = val;
  2700. spec->num_kctl_used++;
  2701. return 0;
  2702. }
  2703. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2704. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2705. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2706. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2707. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2708. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2709. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2710. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2711. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2712. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2713. #define ALC880_PIN_CD_NID 0x1c
  2714. /* fill in the dac_nids table from the parsed pin configuration */
  2715. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2716. const struct auto_pin_cfg *cfg)
  2717. {
  2718. hda_nid_t nid;
  2719. int assigned[4];
  2720. int i, j;
  2721. memset(assigned, 0, sizeof(assigned));
  2722. spec->multiout.dac_nids = spec->private_dac_nids;
  2723. /* check the pins hardwired to audio widget */
  2724. for (i = 0; i < cfg->line_outs; i++) {
  2725. nid = cfg->line_out_pins[i];
  2726. if (alc880_is_fixed_pin(nid)) {
  2727. int idx = alc880_fixed_pin_idx(nid);
  2728. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2729. assigned[idx] = 1;
  2730. }
  2731. }
  2732. /* left pins can be connect to any audio widget */
  2733. for (i = 0; i < cfg->line_outs; i++) {
  2734. nid = cfg->line_out_pins[i];
  2735. if (alc880_is_fixed_pin(nid))
  2736. continue;
  2737. /* search for an empty channel */
  2738. for (j = 0; j < cfg->line_outs; j++) {
  2739. if (!assigned[j]) {
  2740. spec->multiout.dac_nids[i] =
  2741. alc880_idx_to_dac(j);
  2742. assigned[j] = 1;
  2743. break;
  2744. }
  2745. }
  2746. }
  2747. spec->multiout.num_dacs = cfg->line_outs;
  2748. return 0;
  2749. }
  2750. /* add playback controls from the parsed DAC table */
  2751. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2752. const struct auto_pin_cfg *cfg)
  2753. {
  2754. char name[32];
  2755. static const char *chname[4] = {
  2756. "Front", "Surround", NULL /*CLFE*/, "Side"
  2757. };
  2758. hda_nid_t nid;
  2759. int i, err;
  2760. for (i = 0; i < cfg->line_outs; i++) {
  2761. if (!spec->multiout.dac_nids[i])
  2762. continue;
  2763. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2764. if (i == 2) {
  2765. /* Center/LFE */
  2766. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2767. "Center Playback Volume",
  2768. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2769. HDA_OUTPUT));
  2770. if (err < 0)
  2771. return err;
  2772. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2773. "LFE Playback Volume",
  2774. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2775. HDA_OUTPUT));
  2776. if (err < 0)
  2777. return err;
  2778. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2779. "Center Playback Switch",
  2780. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2781. HDA_INPUT));
  2782. if (err < 0)
  2783. return err;
  2784. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2785. "LFE Playback Switch",
  2786. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2787. HDA_INPUT));
  2788. if (err < 0)
  2789. return err;
  2790. } else {
  2791. sprintf(name, "%s Playback Volume", chname[i]);
  2792. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2793. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2794. HDA_OUTPUT));
  2795. if (err < 0)
  2796. return err;
  2797. sprintf(name, "%s Playback Switch", chname[i]);
  2798. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2799. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2800. HDA_INPUT));
  2801. if (err < 0)
  2802. return err;
  2803. }
  2804. }
  2805. return 0;
  2806. }
  2807. /* add playback controls for speaker and HP outputs */
  2808. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2809. const char *pfx)
  2810. {
  2811. hda_nid_t nid;
  2812. int err;
  2813. char name[32];
  2814. if (!pin)
  2815. return 0;
  2816. if (alc880_is_fixed_pin(pin)) {
  2817. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2818. /* specify the DAC as the extra output */
  2819. if (!spec->multiout.hp_nid)
  2820. spec->multiout.hp_nid = nid;
  2821. else
  2822. spec->multiout.extra_out_nid[0] = nid;
  2823. /* control HP volume/switch on the output mixer amp */
  2824. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2825. sprintf(name, "%s Playback Volume", pfx);
  2826. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2827. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2828. if (err < 0)
  2829. return err;
  2830. sprintf(name, "%s Playback Switch", pfx);
  2831. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2832. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2833. if (err < 0)
  2834. return err;
  2835. } else if (alc880_is_multi_pin(pin)) {
  2836. /* set manual connection */
  2837. /* we have only a switch on HP-out PIN */
  2838. sprintf(name, "%s Playback Switch", pfx);
  2839. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2840. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2841. if (err < 0)
  2842. return err;
  2843. }
  2844. return 0;
  2845. }
  2846. /* create input playback/capture controls for the given pin */
  2847. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2848. const char *ctlname,
  2849. int idx, hda_nid_t mix_nid)
  2850. {
  2851. char name[32];
  2852. int err;
  2853. sprintf(name, "%s Playback Volume", ctlname);
  2854. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2855. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2856. if (err < 0)
  2857. return err;
  2858. sprintf(name, "%s Playback Switch", ctlname);
  2859. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2860. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2861. if (err < 0)
  2862. return err;
  2863. return 0;
  2864. }
  2865. /* create playback/capture controls for input pins */
  2866. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2867. const struct auto_pin_cfg *cfg)
  2868. {
  2869. struct hda_input_mux *imux = &spec->private_imux;
  2870. int i, err, idx;
  2871. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2872. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2873. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2874. err = new_analog_input(spec, cfg->input_pins[i],
  2875. auto_pin_cfg_labels[i],
  2876. idx, 0x0b);
  2877. if (err < 0)
  2878. return err;
  2879. imux->items[imux->num_items].label =
  2880. auto_pin_cfg_labels[i];
  2881. imux->items[imux->num_items].index =
  2882. alc880_input_pin_idx(cfg->input_pins[i]);
  2883. imux->num_items++;
  2884. }
  2885. }
  2886. return 0;
  2887. }
  2888. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2889. hda_nid_t nid, int pin_type,
  2890. int dac_idx)
  2891. {
  2892. /* set as output */
  2893. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2894. pin_type);
  2895. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2896. AMP_OUT_UNMUTE);
  2897. /* need the manual connection? */
  2898. if (alc880_is_multi_pin(nid)) {
  2899. struct alc_spec *spec = codec->spec;
  2900. int idx = alc880_multi_pin_idx(nid);
  2901. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2902. AC_VERB_SET_CONNECT_SEL,
  2903. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2904. }
  2905. }
  2906. static int get_pin_type(int line_out_type)
  2907. {
  2908. if (line_out_type == AUTO_PIN_HP_OUT)
  2909. return PIN_HP;
  2910. else
  2911. return PIN_OUT;
  2912. }
  2913. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2914. {
  2915. struct alc_spec *spec = codec->spec;
  2916. int i;
  2917. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2918. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2919. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2920. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2921. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2922. }
  2923. }
  2924. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2925. {
  2926. struct alc_spec *spec = codec->spec;
  2927. hda_nid_t pin;
  2928. pin = spec->autocfg.speaker_pins[0];
  2929. if (pin) /* connect to front */
  2930. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2931. pin = spec->autocfg.hp_pins[0];
  2932. if (pin) /* connect to front */
  2933. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2934. }
  2935. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2936. {
  2937. struct alc_spec *spec = codec->spec;
  2938. int i;
  2939. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2940. hda_nid_t nid = spec->autocfg.input_pins[i];
  2941. if (alc880_is_input_pin(nid)) {
  2942. snd_hda_codec_write(codec, nid, 0,
  2943. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2944. i <= AUTO_PIN_FRONT_MIC ?
  2945. PIN_VREF80 : PIN_IN);
  2946. if (nid != ALC880_PIN_CD_NID)
  2947. snd_hda_codec_write(codec, nid, 0,
  2948. AC_VERB_SET_AMP_GAIN_MUTE,
  2949. AMP_OUT_MUTE);
  2950. }
  2951. }
  2952. }
  2953. /* parse the BIOS configuration and set up the alc_spec */
  2954. /* return 1 if successful, 0 if the proper config is not found,
  2955. * or a negative error code
  2956. */
  2957. static int alc880_parse_auto_config(struct hda_codec *codec)
  2958. {
  2959. struct alc_spec *spec = codec->spec;
  2960. int err;
  2961. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2962. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2963. alc880_ignore);
  2964. if (err < 0)
  2965. return err;
  2966. if (!spec->autocfg.line_outs)
  2967. return 0; /* can't find valid BIOS pin config */
  2968. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2969. if (err < 0)
  2970. return err;
  2971. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2972. if (err < 0)
  2973. return err;
  2974. err = alc880_auto_create_extra_out(spec,
  2975. spec->autocfg.speaker_pins[0],
  2976. "Speaker");
  2977. if (err < 0)
  2978. return err;
  2979. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2980. "Headphone");
  2981. if (err < 0)
  2982. return err;
  2983. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2984. if (err < 0)
  2985. return err;
  2986. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2987. if (spec->autocfg.dig_out_pin)
  2988. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2989. if (spec->autocfg.dig_in_pin)
  2990. spec->dig_in_nid = ALC880_DIGIN_NID;
  2991. if (spec->kctl_alloc)
  2992. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2993. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2994. spec->num_mux_defs = 1;
  2995. spec->input_mux = &spec->private_imux;
  2996. return 1;
  2997. }
  2998. /* additional initialization for auto-configuration model */
  2999. static void alc880_auto_init(struct hda_codec *codec)
  3000. {
  3001. alc880_auto_init_multi_out(codec);
  3002. alc880_auto_init_extra_out(codec);
  3003. alc880_auto_init_analog_input(codec);
  3004. }
  3005. /*
  3006. * OK, here we have finally the patch for ALC880
  3007. */
  3008. static int patch_alc880(struct hda_codec *codec)
  3009. {
  3010. struct alc_spec *spec;
  3011. int board_config;
  3012. int err;
  3013. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3014. if (spec == NULL)
  3015. return -ENOMEM;
  3016. codec->spec = spec;
  3017. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3018. alc880_models,
  3019. alc880_cfg_tbl);
  3020. if (board_config < 0) {
  3021. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3022. "trying auto-probe from BIOS...\n");
  3023. board_config = ALC880_AUTO;
  3024. }
  3025. if (board_config == ALC880_AUTO) {
  3026. /* automatic parse from the BIOS config */
  3027. err = alc880_parse_auto_config(codec);
  3028. if (err < 0) {
  3029. alc_free(codec);
  3030. return err;
  3031. } else if (!err) {
  3032. printk(KERN_INFO
  3033. "hda_codec: Cannot set up configuration "
  3034. "from BIOS. Using 3-stack mode...\n");
  3035. board_config = ALC880_3ST;
  3036. }
  3037. }
  3038. if (board_config != ALC880_AUTO)
  3039. setup_preset(spec, &alc880_presets[board_config]);
  3040. spec->stream_name_analog = "ALC880 Analog";
  3041. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3042. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3043. spec->stream_name_digital = "ALC880 Digital";
  3044. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3045. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3046. if (!spec->adc_nids && spec->input_mux) {
  3047. /* check whether NID 0x07 is valid */
  3048. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3049. /* get type */
  3050. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3051. if (wcap != AC_WID_AUD_IN) {
  3052. spec->adc_nids = alc880_adc_nids_alt;
  3053. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3054. spec->mixers[spec->num_mixers] =
  3055. alc880_capture_alt_mixer;
  3056. spec->num_mixers++;
  3057. } else {
  3058. spec->adc_nids = alc880_adc_nids;
  3059. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3060. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3061. spec->num_mixers++;
  3062. }
  3063. }
  3064. codec->patch_ops = alc_patch_ops;
  3065. if (board_config == ALC880_AUTO)
  3066. spec->init_hook = alc880_auto_init;
  3067. #ifdef CONFIG_SND_HDA_POWER_SAVE
  3068. if (!spec->loopback.amplist)
  3069. spec->loopback.amplist = alc880_loopbacks;
  3070. #endif
  3071. return 0;
  3072. }
  3073. /*
  3074. * ALC260 support
  3075. */
  3076. static hda_nid_t alc260_dac_nids[1] = {
  3077. /* front */
  3078. 0x02,
  3079. };
  3080. static hda_nid_t alc260_adc_nids[1] = {
  3081. /* ADC0 */
  3082. 0x04,
  3083. };
  3084. static hda_nid_t alc260_adc_nids_alt[1] = {
  3085. /* ADC1 */
  3086. 0x05,
  3087. };
  3088. static hda_nid_t alc260_hp_adc_nids[2] = {
  3089. /* ADC1, 0 */
  3090. 0x05, 0x04
  3091. };
  3092. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3093. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3094. */
  3095. static hda_nid_t alc260_dual_adc_nids[2] = {
  3096. /* ADC0, ADC1 */
  3097. 0x04, 0x05
  3098. };
  3099. #define ALC260_DIGOUT_NID 0x03
  3100. #define ALC260_DIGIN_NID 0x06
  3101. static struct hda_input_mux alc260_capture_source = {
  3102. .num_items = 4,
  3103. .items = {
  3104. { "Mic", 0x0 },
  3105. { "Front Mic", 0x1 },
  3106. { "Line", 0x2 },
  3107. { "CD", 0x4 },
  3108. },
  3109. };
  3110. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3111. * headphone jack and the internal CD lines since these are the only pins at
  3112. * which audio can appear. For flexibility, also allow the option of
  3113. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3114. * connection to the mixer output).
  3115. */
  3116. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3117. {
  3118. .num_items = 3,
  3119. .items = {
  3120. { "Mic/Line", 0x0 },
  3121. { "CD", 0x4 },
  3122. { "Headphone", 0x2 },
  3123. },
  3124. },
  3125. {
  3126. .num_items = 4,
  3127. .items = {
  3128. { "Mic/Line", 0x0 },
  3129. { "CD", 0x4 },
  3130. { "Headphone", 0x2 },
  3131. { "Mixer", 0x5 },
  3132. },
  3133. },
  3134. };
  3135. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3136. * the Fujitsu S702x, but jacks are marked differently.
  3137. */
  3138. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3139. {
  3140. .num_items = 4,
  3141. .items = {
  3142. { "Mic", 0x0 },
  3143. { "Line", 0x2 },
  3144. { "CD", 0x4 },
  3145. { "Headphone", 0x5 },
  3146. },
  3147. },
  3148. {
  3149. .num_items = 5,
  3150. .items = {
  3151. { "Mic", 0x0 },
  3152. { "Line", 0x2 },
  3153. { "CD", 0x4 },
  3154. { "Headphone", 0x6 },
  3155. { "Mixer", 0x5 },
  3156. },
  3157. },
  3158. };
  3159. /*
  3160. * This is just place-holder, so there's something for alc_build_pcms to look
  3161. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3162. * element which allows changing the channel mode, so the verb list is
  3163. * never used.
  3164. */
  3165. static struct hda_channel_mode alc260_modes[1] = {
  3166. { 2, NULL },
  3167. };
  3168. /* Mixer combinations
  3169. *
  3170. * basic: base_output + input + pc_beep + capture
  3171. * HP: base_output + input + capture_alt
  3172. * HP_3013: hp_3013 + input + capture
  3173. * fujitsu: fujitsu + capture
  3174. * acer: acer + capture
  3175. */
  3176. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3177. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3178. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3179. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3180. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3181. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3182. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3183. { } /* end */
  3184. };
  3185. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3186. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3187. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3188. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3189. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3190. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3191. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3192. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3193. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3194. { } /* end */
  3195. };
  3196. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3197. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3198. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3199. { } /* end */
  3200. };
  3201. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3202. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3203. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3204. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3205. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3206. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3207. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3208. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3209. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3210. { } /* end */
  3211. };
  3212. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3213. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3214. */
  3215. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3216. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3217. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3218. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3219. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3220. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3221. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3222. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3223. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3224. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3225. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3226. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3227. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3228. { } /* end */
  3229. };
  3230. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3231. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3232. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3233. * datasheet doesn't mention this restriction. At this stage it's not clear
  3234. * whether this behaviour is intentional or is a hardware bug in chip
  3235. * revisions available in early 2006. Therefore for now allow the
  3236. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3237. * that the lack of mic bias for this NID is intentional we could change the
  3238. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3239. *
  3240. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3241. * don't appear to make the mic bias available from the "line" jack, even
  3242. * though the NID used for this jack (0x14) can supply it. The theory is
  3243. * that perhaps Acer have included blocking capacitors between the ALC260
  3244. * and the output jack. If this turns out to be the case for all such
  3245. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3246. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3247. *
  3248. * The C20x Tablet series have a mono internal speaker which is controlled
  3249. * via the chip's Mono sum widget and pin complex, so include the necessary
  3250. * controls for such models. On models without a "mono speaker" the control
  3251. * won't do anything.
  3252. */
  3253. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3254. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3255. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3256. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3257. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3258. HDA_OUTPUT),
  3259. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3260. HDA_INPUT),
  3261. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3262. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3263. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3264. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3265. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3266. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3267. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3268. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3269. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3270. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3271. { } /* end */
  3272. };
  3273. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3274. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3275. */
  3276. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3277. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3278. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3279. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3280. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3281. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3282. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3283. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3284. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3285. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3286. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3287. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3288. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3289. { } /* end */
  3290. };
  3291. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3292. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3293. */
  3294. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3295. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3296. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3297. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3298. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3299. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3300. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3301. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3302. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3303. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3304. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3305. { } /* end */
  3306. };
  3307. /* capture mixer elements */
  3308. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3309. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3310. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3311. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3312. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3313. {
  3314. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3315. /* The multiple "Capture Source" controls confuse alsamixer
  3316. * So call somewhat different..
  3317. * FIXME: the controls appear in the "playback" view!
  3318. */
  3319. /* .name = "Capture Source", */
  3320. .name = "Input Source",
  3321. .count = 2,
  3322. .info = alc_mux_enum_info,
  3323. .get = alc_mux_enum_get,
  3324. .put = alc_mux_enum_put,
  3325. },
  3326. { } /* end */
  3327. };
  3328. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3329. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3330. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3331. {
  3332. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3333. /* The multiple "Capture Source" controls confuse alsamixer
  3334. * So call somewhat different..
  3335. * FIXME: the controls appear in the "playback" view!
  3336. */
  3337. /* .name = "Capture Source", */
  3338. .name = "Input Source",
  3339. .count = 1,
  3340. .info = alc_mux_enum_info,
  3341. .get = alc_mux_enum_get,
  3342. .put = alc_mux_enum_put,
  3343. },
  3344. { } /* end */
  3345. };
  3346. /*
  3347. * initialization verbs
  3348. */
  3349. static struct hda_verb alc260_init_verbs[] = {
  3350. /* Line In pin widget for input */
  3351. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3352. /* CD pin widget for input */
  3353. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3354. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3355. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3356. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3357. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3358. /* LINE-2 is used for line-out in rear */
  3359. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3360. /* select line-out */
  3361. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3362. /* LINE-OUT pin */
  3363. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3364. /* enable HP */
  3365. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3366. /* enable Mono */
  3367. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3368. /* mute capture amp left and right */
  3369. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3370. /* set connection select to line in (default select for this ADC) */
  3371. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3372. /* mute capture amp left and right */
  3373. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3374. /* set connection select to line in (default select for this ADC) */
  3375. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3376. /* set vol=0 Line-Out mixer amp left and right */
  3377. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3378. /* unmute pin widget amp left and right (no gain on this amp) */
  3379. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3380. /* set vol=0 HP mixer amp left and right */
  3381. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3382. /* unmute pin widget amp left and right (no gain on this amp) */
  3383. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3384. /* set vol=0 Mono mixer amp left and right */
  3385. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3386. /* unmute pin widget amp left and right (no gain on this amp) */
  3387. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3388. /* unmute LINE-2 out pin */
  3389. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3390. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3391. * Line In 2 = 0x03
  3392. */
  3393. /* mute analog inputs */
  3394. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3395. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3396. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3397. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3398. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3399. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3400. /* mute Front out path */
  3401. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3402. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3403. /* mute Headphone out path */
  3404. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3405. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3406. /* mute Mono out path */
  3407. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3408. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3409. { }
  3410. };
  3411. #if 0 /* should be identical with alc260_init_verbs? */
  3412. static struct hda_verb alc260_hp_init_verbs[] = {
  3413. /* Headphone and output */
  3414. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3415. /* mono output */
  3416. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3417. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3418. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3419. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3420. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3421. /* Line In pin widget for input */
  3422. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3423. /* Line-2 pin widget for output */
  3424. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3425. /* CD pin widget for input */
  3426. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3427. /* unmute amp left and right */
  3428. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3429. /* set connection select to line in (default select for this ADC) */
  3430. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3431. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3432. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3433. /* mute pin widget amp left and right (no gain on this amp) */
  3434. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3435. /* unmute HP mixer amp left and right (volume = 0) */
  3436. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3437. /* mute pin widget amp left and right (no gain on this amp) */
  3438. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3439. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3440. * Line In 2 = 0x03
  3441. */
  3442. /* mute analog inputs */
  3443. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3444. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3445. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3446. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3447. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3448. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3449. /* Unmute Front out path */
  3450. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3451. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3452. /* Unmute Headphone out path */
  3453. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3454. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3455. /* Unmute Mono out path */
  3456. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3457. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3458. { }
  3459. };
  3460. #endif
  3461. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3462. /* Line out and output */
  3463. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3464. /* mono output */
  3465. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3466. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3467. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3468. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3469. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3470. /* Line In pin widget for input */
  3471. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3472. /* Headphone pin widget for output */
  3473. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3474. /* CD pin widget for input */
  3475. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3476. /* unmute amp left and right */
  3477. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3478. /* set connection select to line in (default select for this ADC) */
  3479. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3480. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3481. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3482. /* mute pin widget amp left and right (no gain on this amp) */
  3483. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3484. /* unmute HP mixer amp left and right (volume = 0) */
  3485. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3486. /* mute pin widget amp left and right (no gain on this amp) */
  3487. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3488. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3489. * Line In 2 = 0x03
  3490. */
  3491. /* mute analog inputs */
  3492. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3493. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3494. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  3495. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  3496. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  3497. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3498. /* Unmute Front out path */
  3499. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3500. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3501. /* Unmute Headphone out path */
  3502. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3503. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3504. /* Unmute Mono out path */
  3505. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3506. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3507. { }
  3508. };
  3509. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3510. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3511. * audio = 0x16, internal speaker = 0x10.
  3512. */
  3513. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3514. /* Disable all GPIOs */
  3515. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3516. /* Internal speaker is connected to headphone pin */
  3517. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3518. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3519. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3520. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3521. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3522. /* Ensure all other unused pins are disabled and muted. */
  3523. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3524. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3525. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3526. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3527. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3528. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3529. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3530. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3531. /* Disable digital (SPDIF) pins */
  3532. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3533. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3534. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3535. * when acting as an output.
  3536. */
  3537. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3538. /* Start with output sum widgets muted and their output gains at min */
  3539. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3540. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3541. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3542. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3543. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3544. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3545. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3546. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3547. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3548. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3549. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3550. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3551. * If the pin mode is changed by the user the pin mode control will
  3552. * take care of enabling the pin's input/output buffers as needed.
  3553. * Therefore there's no need to enable the input buffer at this
  3554. * stage.
  3555. */
  3556. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3557. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3558. * mixer ctrl)
  3559. */
  3560. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3561. /* Mute capture amp left and right */
  3562. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3563. /* Set ADC connection select to match default mixer setting - line
  3564. * in (on mic1 pin)
  3565. */
  3566. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3567. /* Do the same for the second ADC: mute capture input amp and
  3568. * set ADC connection to line in (on mic1 pin)
  3569. */
  3570. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3571. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3572. /* Mute all inputs to mixer widget (even unconnected ones) */
  3573. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3574. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3575. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3576. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3577. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3578. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3579. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3580. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3581. { }
  3582. };
  3583. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3584. * similar laptops (adapted from Fujitsu init verbs).
  3585. */
  3586. static struct hda_verb alc260_acer_init_verbs[] = {
  3587. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3588. * the headphone jack. Turn this on and rely on the standard mute
  3589. * methods whenever the user wants to turn these outputs off.
  3590. */
  3591. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3592. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3593. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3594. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3595. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3596. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3597. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3598. /* Line In jack is connected to Line1 pin */
  3599. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3600. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3601. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3602. /* Ensure all other unused pins are disabled and muted. */
  3603. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3604. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3605. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3606. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3607. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3608. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3609. /* Disable digital (SPDIF) pins */
  3610. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3611. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3612. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3613. * bus when acting as outputs.
  3614. */
  3615. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3616. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3617. /* Start with output sum widgets muted and their output gains at min */
  3618. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3619. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3620. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3621. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3622. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3623. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3624. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3625. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3626. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3627. /* Unmute Line-out pin widget amp left and right
  3628. * (no equiv mixer ctrl)
  3629. */
  3630. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3631. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3632. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3633. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3634. * inputs. If the pin mode is changed by the user the pin mode control
  3635. * will take care of enabling the pin's input/output buffers as needed.
  3636. * Therefore there's no need to enable the input buffer at this
  3637. * stage.
  3638. */
  3639. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3640. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3641. /* Mute capture amp left and right */
  3642. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3643. /* Set ADC connection select to match default mixer setting - mic
  3644. * (on mic1 pin)
  3645. */
  3646. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3647. /* Do similar with the second ADC: mute capture input amp and
  3648. * set ADC connection to mic to match ALSA's default state.
  3649. */
  3650. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3651. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3652. /* Mute all inputs to mixer widget (even unconnected ones) */
  3653. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3654. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3655. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3656. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3657. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3658. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3659. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3660. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3661. { }
  3662. };
  3663. static struct hda_verb alc260_will_verbs[] = {
  3664. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3665. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3666. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3667. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3668. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3669. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3670. {}
  3671. };
  3672. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3673. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3674. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3675. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3676. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3677. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3678. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3679. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3680. {}
  3681. };
  3682. /* toggle speaker-output according to the hp-jack state */
  3683. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3684. {
  3685. unsigned int present;
  3686. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3687. present = snd_hda_codec_read(codec, 0x0f, 0,
  3688. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3689. if (present) {
  3690. snd_hda_codec_write_cache(codec, 0x01, 0,
  3691. AC_VERB_SET_GPIO_DATA, 1);
  3692. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3693. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3694. PIN_HP);
  3695. } else {
  3696. snd_hda_codec_write_cache(codec, 0x01, 0,
  3697. AC_VERB_SET_GPIO_DATA, 0);
  3698. snd_hda_codec_write_cache(codec, 0x0f, 0,
  3699. AC_VERB_SET_PIN_WIDGET_CONTROL,
  3700. PIN_OUT);
  3701. }
  3702. }
  3703. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3704. unsigned int res)
  3705. {
  3706. if ((res >> 26) == ALC880_HP_EVENT)
  3707. alc260_replacer_672v_automute(codec);
  3708. }
  3709. /* Test configuration for debugging, modelled after the ALC880 test
  3710. * configuration.
  3711. */
  3712. #ifdef CONFIG_SND_DEBUG
  3713. static hda_nid_t alc260_test_dac_nids[1] = {
  3714. 0x02,
  3715. };
  3716. static hda_nid_t alc260_test_adc_nids[2] = {
  3717. 0x04, 0x05,
  3718. };
  3719. /* For testing the ALC260, each input MUX needs its own definition since
  3720. * the signal assignments are different. This assumes that the first ADC
  3721. * is NID 0x04.
  3722. */
  3723. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3724. {
  3725. .num_items = 7,
  3726. .items = {
  3727. { "MIC1 pin", 0x0 },
  3728. { "MIC2 pin", 0x1 },
  3729. { "LINE1 pin", 0x2 },
  3730. { "LINE2 pin", 0x3 },
  3731. { "CD pin", 0x4 },
  3732. { "LINE-OUT pin", 0x5 },
  3733. { "HP-OUT pin", 0x6 },
  3734. },
  3735. },
  3736. {
  3737. .num_items = 8,
  3738. .items = {
  3739. { "MIC1 pin", 0x0 },
  3740. { "MIC2 pin", 0x1 },
  3741. { "LINE1 pin", 0x2 },
  3742. { "LINE2 pin", 0x3 },
  3743. { "CD pin", 0x4 },
  3744. { "Mixer", 0x5 },
  3745. { "LINE-OUT pin", 0x6 },
  3746. { "HP-OUT pin", 0x7 },
  3747. },
  3748. },
  3749. };
  3750. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3751. /* Output driver widgets */
  3752. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3753. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3754. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3755. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3756. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3757. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3758. /* Modes for retasking pin widgets
  3759. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3760. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3761. * mention this restriction. At this stage it's not clear whether
  3762. * this behaviour is intentional or is a hardware bug in chip
  3763. * revisions available at least up until early 2006. Therefore for
  3764. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3765. * choices, but if it turns out that the lack of mic bias for these
  3766. * NIDs is intentional we could change their modes from
  3767. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3768. */
  3769. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3770. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3771. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3772. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3773. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3774. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3775. /* Loopback mixer controls */
  3776. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3777. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3778. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3779. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3780. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3781. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3782. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3783. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3784. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3785. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3786. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3787. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3788. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3789. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3790. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3791. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3792. /* Controls for GPIO pins, assuming they are configured as outputs */
  3793. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3794. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3795. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3796. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3797. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3798. * is ambigious as to which NID is which; testing on laptops which
  3799. * make this output available should provide clarification.
  3800. */
  3801. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3802. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3803. { } /* end */
  3804. };
  3805. static struct hda_verb alc260_test_init_verbs[] = {
  3806. /* Enable all GPIOs as outputs with an initial value of 0 */
  3807. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3808. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3809. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3810. /* Enable retasking pins as output, initially without power amp */
  3811. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3812. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3813. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3814. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3815. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3816. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3817. /* Disable digital (SPDIF) pins initially, but users can enable
  3818. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3819. * payload also sets the generation to 0, output to be in "consumer"
  3820. * PCM format, copyright asserted, no pre-emphasis and no validity
  3821. * control.
  3822. */
  3823. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3824. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3825. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3826. * OUT1 sum bus when acting as an output.
  3827. */
  3828. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3829. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3830. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3831. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3832. /* Start with output sum widgets muted and their output gains at min */
  3833. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3834. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3835. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3836. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3837. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3838. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3839. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3840. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3841. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3842. /* Unmute retasking pin widget output buffers since the default
  3843. * state appears to be output. As the pin mode is changed by the
  3844. * user the pin mode control will take care of enabling the pin's
  3845. * input/output buffers as needed.
  3846. */
  3847. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3848. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3849. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3850. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3851. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3852. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3853. /* Also unmute the mono-out pin widget */
  3854. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3855. /* Mute capture amp left and right */
  3856. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3857. /* Set ADC connection select to match default mixer setting (mic1
  3858. * pin)
  3859. */
  3860. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3861. /* Do the same for the second ADC: mute capture input amp and
  3862. * set ADC connection to mic1 pin
  3863. */
  3864. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3865. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3866. /* Mute all inputs to mixer widget (even unconnected ones) */
  3867. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3868. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3870. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3871. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3872. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3873. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3874. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3875. { }
  3876. };
  3877. #endif
  3878. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3879. .substreams = 1,
  3880. .channels_min = 2,
  3881. .channels_max = 2,
  3882. };
  3883. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3884. .substreams = 1,
  3885. .channels_min = 2,
  3886. .channels_max = 2,
  3887. };
  3888. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3889. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3890. /*
  3891. * for BIOS auto-configuration
  3892. */
  3893. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3894. const char *pfx)
  3895. {
  3896. hda_nid_t nid_vol;
  3897. unsigned long vol_val, sw_val;
  3898. char name[32];
  3899. int err;
  3900. if (nid >= 0x0f && nid < 0x11) {
  3901. nid_vol = nid - 0x7;
  3902. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3903. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3904. } else if (nid == 0x11) {
  3905. nid_vol = nid - 0x7;
  3906. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3907. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3908. } else if (nid >= 0x12 && nid <= 0x15) {
  3909. nid_vol = 0x08;
  3910. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3911. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3912. } else
  3913. return 0; /* N/A */
  3914. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3915. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3916. if (err < 0)
  3917. return err;
  3918. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3919. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3920. if (err < 0)
  3921. return err;
  3922. return 1;
  3923. }
  3924. /* add playback controls from the parsed DAC table */
  3925. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3926. const struct auto_pin_cfg *cfg)
  3927. {
  3928. hda_nid_t nid;
  3929. int err;
  3930. spec->multiout.num_dacs = 1;
  3931. spec->multiout.dac_nids = spec->private_dac_nids;
  3932. spec->multiout.dac_nids[0] = 0x02;
  3933. nid = cfg->line_out_pins[0];
  3934. if (nid) {
  3935. err = alc260_add_playback_controls(spec, nid, "Front");
  3936. if (err < 0)
  3937. return err;
  3938. }
  3939. nid = cfg->speaker_pins[0];
  3940. if (nid) {
  3941. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3942. if (err < 0)
  3943. return err;
  3944. }
  3945. nid = cfg->hp_pins[0];
  3946. if (nid) {
  3947. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3948. if (err < 0)
  3949. return err;
  3950. }
  3951. return 0;
  3952. }
  3953. /* create playback/capture controls for input pins */
  3954. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3955. const struct auto_pin_cfg *cfg)
  3956. {
  3957. struct hda_input_mux *imux = &spec->private_imux;
  3958. int i, err, idx;
  3959. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3960. if (cfg->input_pins[i] >= 0x12) {
  3961. idx = cfg->input_pins[i] - 0x12;
  3962. err = new_analog_input(spec, cfg->input_pins[i],
  3963. auto_pin_cfg_labels[i], idx,
  3964. 0x07);
  3965. if (err < 0)
  3966. return err;
  3967. imux->items[imux->num_items].label =
  3968. auto_pin_cfg_labels[i];
  3969. imux->items[imux->num_items].index = idx;
  3970. imux->num_items++;
  3971. }
  3972. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3973. idx = cfg->input_pins[i] - 0x09;
  3974. err = new_analog_input(spec, cfg->input_pins[i],
  3975. auto_pin_cfg_labels[i], idx,
  3976. 0x07);
  3977. if (err < 0)
  3978. return err;
  3979. imux->items[imux->num_items].label =
  3980. auto_pin_cfg_labels[i];
  3981. imux->items[imux->num_items].index = idx;
  3982. imux->num_items++;
  3983. }
  3984. }
  3985. return 0;
  3986. }
  3987. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3988. hda_nid_t nid, int pin_type,
  3989. int sel_idx)
  3990. {
  3991. /* set as output */
  3992. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3993. pin_type);
  3994. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3995. AMP_OUT_UNMUTE);
  3996. /* need the manual connection? */
  3997. if (nid >= 0x12) {
  3998. int idx = nid - 0x12;
  3999. snd_hda_codec_write(codec, idx + 0x0b, 0,
  4000. AC_VERB_SET_CONNECT_SEL, sel_idx);
  4001. }
  4002. }
  4003. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  4004. {
  4005. struct alc_spec *spec = codec->spec;
  4006. hda_nid_t nid;
  4007. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  4008. nid = spec->autocfg.line_out_pins[0];
  4009. if (nid) {
  4010. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  4011. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  4012. }
  4013. nid = spec->autocfg.speaker_pins[0];
  4014. if (nid)
  4015. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  4016. nid = spec->autocfg.hp_pins[0];
  4017. if (nid)
  4018. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4019. }
  4020. #define ALC260_PIN_CD_NID 0x16
  4021. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4022. {
  4023. struct alc_spec *spec = codec->spec;
  4024. int i;
  4025. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4026. hda_nid_t nid = spec->autocfg.input_pins[i];
  4027. if (nid >= 0x12) {
  4028. snd_hda_codec_write(codec, nid, 0,
  4029. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4030. i <= AUTO_PIN_FRONT_MIC ?
  4031. PIN_VREF80 : PIN_IN);
  4032. if (nid != ALC260_PIN_CD_NID)
  4033. snd_hda_codec_write(codec, nid, 0,
  4034. AC_VERB_SET_AMP_GAIN_MUTE,
  4035. AMP_OUT_MUTE);
  4036. }
  4037. }
  4038. }
  4039. /*
  4040. * generic initialization of ADC, input mixers and output mixers
  4041. */
  4042. static struct hda_verb alc260_volume_init_verbs[] = {
  4043. /*
  4044. * Unmute ADC0-1 and set the default input to mic-in
  4045. */
  4046. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4047. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4048. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4049. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4050. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4051. * mixer widget
  4052. * Note: PASD motherboards uses the Line In 2 as the input for
  4053. * front panel mic (mic 2)
  4054. */
  4055. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4056. /* mute analog inputs */
  4057. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4058. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4059. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4060. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4061. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4062. /*
  4063. * Set up output mixers (0x08 - 0x0a)
  4064. */
  4065. /* set vol=0 to output mixers */
  4066. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4067. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4068. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4069. /* set up input amps for analog loopback */
  4070. /* Amp Indices: DAC = 0, mixer = 1 */
  4071. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4072. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4073. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4074. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4075. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4076. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4077. { }
  4078. };
  4079. static int alc260_parse_auto_config(struct hda_codec *codec)
  4080. {
  4081. struct alc_spec *spec = codec->spec;
  4082. unsigned int wcap;
  4083. int err;
  4084. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4085. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4086. alc260_ignore);
  4087. if (err < 0)
  4088. return err;
  4089. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4090. if (err < 0)
  4091. return err;
  4092. if (!spec->kctl_alloc)
  4093. return 0; /* can't find valid BIOS pin config */
  4094. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4095. if (err < 0)
  4096. return err;
  4097. spec->multiout.max_channels = 2;
  4098. if (spec->autocfg.dig_out_pin)
  4099. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4100. if (spec->kctl_alloc)
  4101. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4102. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4103. spec->num_mux_defs = 1;
  4104. spec->input_mux = &spec->private_imux;
  4105. /* check whether NID 0x04 is valid */
  4106. wcap = get_wcaps(codec, 0x04);
  4107. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4108. if (wcap != AC_WID_AUD_IN) {
  4109. spec->adc_nids = alc260_adc_nids_alt;
  4110. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4111. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4112. } else {
  4113. spec->adc_nids = alc260_adc_nids;
  4114. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4115. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4116. }
  4117. spec->num_mixers++;
  4118. return 1;
  4119. }
  4120. /* additional initialization for auto-configuration model */
  4121. static void alc260_auto_init(struct hda_codec *codec)
  4122. {
  4123. alc260_auto_init_multi_out(codec);
  4124. alc260_auto_init_analog_input(codec);
  4125. }
  4126. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4127. static struct hda_amp_list alc260_loopbacks[] = {
  4128. { 0x07, HDA_INPUT, 0 },
  4129. { 0x07, HDA_INPUT, 1 },
  4130. { 0x07, HDA_INPUT, 2 },
  4131. { 0x07, HDA_INPUT, 3 },
  4132. { 0x07, HDA_INPUT, 4 },
  4133. { } /* end */
  4134. };
  4135. #endif
  4136. /*
  4137. * ALC260 configurations
  4138. */
  4139. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4140. [ALC260_BASIC] = "basic",
  4141. [ALC260_HP] = "hp",
  4142. [ALC260_HP_3013] = "hp-3013",
  4143. [ALC260_FUJITSU_S702X] = "fujitsu",
  4144. [ALC260_ACER] = "acer",
  4145. [ALC260_WILL] = "will",
  4146. [ALC260_REPLACER_672V] = "replacer",
  4147. #ifdef CONFIG_SND_DEBUG
  4148. [ALC260_TEST] = "test",
  4149. #endif
  4150. [ALC260_AUTO] = "auto",
  4151. };
  4152. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4153. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4154. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4155. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4156. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4157. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4158. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4159. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4160. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4161. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4162. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4163. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4164. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4165. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4166. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4167. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4168. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4169. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4170. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4171. {}
  4172. };
  4173. static struct alc_config_preset alc260_presets[] = {
  4174. [ALC260_BASIC] = {
  4175. .mixers = { alc260_base_output_mixer,
  4176. alc260_input_mixer,
  4177. alc260_pc_beep_mixer,
  4178. alc260_capture_mixer },
  4179. .init_verbs = { alc260_init_verbs },
  4180. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4181. .dac_nids = alc260_dac_nids,
  4182. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4183. .adc_nids = alc260_adc_nids,
  4184. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4185. .channel_mode = alc260_modes,
  4186. .input_mux = &alc260_capture_source,
  4187. },
  4188. [ALC260_HP] = {
  4189. .mixers = { alc260_base_output_mixer,
  4190. alc260_input_mixer,
  4191. alc260_capture_alt_mixer },
  4192. .init_verbs = { alc260_init_verbs },
  4193. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4194. .dac_nids = alc260_dac_nids,
  4195. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4196. .adc_nids = alc260_hp_adc_nids,
  4197. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4198. .channel_mode = alc260_modes,
  4199. .input_mux = &alc260_capture_source,
  4200. },
  4201. [ALC260_HP_3013] = {
  4202. .mixers = { alc260_hp_3013_mixer,
  4203. alc260_input_mixer,
  4204. alc260_capture_alt_mixer },
  4205. .init_verbs = { alc260_hp_3013_init_verbs },
  4206. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4207. .dac_nids = alc260_dac_nids,
  4208. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4209. .adc_nids = alc260_hp_adc_nids,
  4210. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4211. .channel_mode = alc260_modes,
  4212. .input_mux = &alc260_capture_source,
  4213. },
  4214. [ALC260_FUJITSU_S702X] = {
  4215. .mixers = { alc260_fujitsu_mixer,
  4216. alc260_capture_mixer },
  4217. .init_verbs = { alc260_fujitsu_init_verbs },
  4218. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4219. .dac_nids = alc260_dac_nids,
  4220. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4221. .adc_nids = alc260_dual_adc_nids,
  4222. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4223. .channel_mode = alc260_modes,
  4224. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4225. .input_mux = alc260_fujitsu_capture_sources,
  4226. },
  4227. [ALC260_ACER] = {
  4228. .mixers = { alc260_acer_mixer,
  4229. alc260_capture_mixer },
  4230. .init_verbs = { alc260_acer_init_verbs },
  4231. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4232. .dac_nids = alc260_dac_nids,
  4233. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4234. .adc_nids = alc260_dual_adc_nids,
  4235. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4236. .channel_mode = alc260_modes,
  4237. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4238. .input_mux = alc260_acer_capture_sources,
  4239. },
  4240. [ALC260_WILL] = {
  4241. .mixers = { alc260_will_mixer,
  4242. alc260_capture_mixer },
  4243. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4244. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4245. .dac_nids = alc260_dac_nids,
  4246. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4247. .adc_nids = alc260_adc_nids,
  4248. .dig_out_nid = ALC260_DIGOUT_NID,
  4249. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4250. .channel_mode = alc260_modes,
  4251. .input_mux = &alc260_capture_source,
  4252. },
  4253. [ALC260_REPLACER_672V] = {
  4254. .mixers = { alc260_replacer_672v_mixer,
  4255. alc260_capture_mixer },
  4256. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4257. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4258. .dac_nids = alc260_dac_nids,
  4259. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4260. .adc_nids = alc260_adc_nids,
  4261. .dig_out_nid = ALC260_DIGOUT_NID,
  4262. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4263. .channel_mode = alc260_modes,
  4264. .input_mux = &alc260_capture_source,
  4265. .unsol_event = alc260_replacer_672v_unsol_event,
  4266. .init_hook = alc260_replacer_672v_automute,
  4267. },
  4268. #ifdef CONFIG_SND_DEBUG
  4269. [ALC260_TEST] = {
  4270. .mixers = { alc260_test_mixer,
  4271. alc260_capture_mixer },
  4272. .init_verbs = { alc260_test_init_verbs },
  4273. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4274. .dac_nids = alc260_test_dac_nids,
  4275. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4276. .adc_nids = alc260_test_adc_nids,
  4277. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4278. .channel_mode = alc260_modes,
  4279. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4280. .input_mux = alc260_test_capture_sources,
  4281. },
  4282. #endif
  4283. };
  4284. static int patch_alc260(struct hda_codec *codec)
  4285. {
  4286. struct alc_spec *spec;
  4287. int err, board_config;
  4288. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4289. if (spec == NULL)
  4290. return -ENOMEM;
  4291. codec->spec = spec;
  4292. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4293. alc260_models,
  4294. alc260_cfg_tbl);
  4295. if (board_config < 0) {
  4296. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4297. "trying auto-probe from BIOS...\n");
  4298. board_config = ALC260_AUTO;
  4299. }
  4300. if (board_config == ALC260_AUTO) {
  4301. /* automatic parse from the BIOS config */
  4302. err = alc260_parse_auto_config(codec);
  4303. if (err < 0) {
  4304. alc_free(codec);
  4305. return err;
  4306. } else if (!err) {
  4307. printk(KERN_INFO
  4308. "hda_codec: Cannot set up configuration "
  4309. "from BIOS. Using base mode...\n");
  4310. board_config = ALC260_BASIC;
  4311. }
  4312. }
  4313. if (board_config != ALC260_AUTO)
  4314. setup_preset(spec, &alc260_presets[board_config]);
  4315. spec->stream_name_analog = "ALC260 Analog";
  4316. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4317. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4318. spec->stream_name_digital = "ALC260 Digital";
  4319. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4320. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4321. codec->patch_ops = alc_patch_ops;
  4322. if (board_config == ALC260_AUTO)
  4323. spec->init_hook = alc260_auto_init;
  4324. #ifdef CONFIG_SND_HDA_POWER_SAVE
  4325. if (!spec->loopback.amplist)
  4326. spec->loopback.amplist = alc260_loopbacks;
  4327. #endif
  4328. return 0;
  4329. }
  4330. /*
  4331. * ALC882 support
  4332. *
  4333. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4334. * configuration. Each pin widget can choose any input DACs and a mixer.
  4335. * Each ADC is connected from a mixer of all inputs. This makes possible
  4336. * 6-channel independent captures.
  4337. *
  4338. * In addition, an independent DAC for the multi-playback (not used in this
  4339. * driver yet).
  4340. */
  4341. #define ALC882_DIGOUT_NID 0x06
  4342. #define ALC882_DIGIN_NID 0x0a
  4343. static struct hda_channel_mode alc882_ch_modes[1] = {
  4344. { 8, NULL }
  4345. };
  4346. static hda_nid_t alc882_dac_nids[4] = {
  4347. /* front, rear, clfe, rear_surr */
  4348. 0x02, 0x03, 0x04, 0x05
  4349. };
  4350. /* identical with ALC880 */
  4351. #define alc882_adc_nids alc880_adc_nids
  4352. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4353. /* input MUX */
  4354. /* FIXME: should be a matrix-type input source selection */
  4355. static struct hda_input_mux alc882_capture_source = {
  4356. .num_items = 4,
  4357. .items = {
  4358. { "Mic", 0x0 },
  4359. { "Front Mic", 0x1 },
  4360. { "Line", 0x2 },
  4361. { "CD", 0x4 },
  4362. },
  4363. };
  4364. #define alc882_mux_enum_info alc_mux_enum_info
  4365. #define alc882_mux_enum_get alc_mux_enum_get
  4366. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4367. struct snd_ctl_elem_value *ucontrol)
  4368. {
  4369. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4370. struct alc_spec *spec = codec->spec;
  4371. const struct hda_input_mux *imux = spec->input_mux;
  4372. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4373. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4374. hda_nid_t nid = capture_mixers[adc_idx];
  4375. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4376. unsigned int i, idx;
  4377. idx = ucontrol->value.enumerated.item[0];
  4378. if (idx >= imux->num_items)
  4379. idx = imux->num_items - 1;
  4380. if (*cur_val == idx)
  4381. return 0;
  4382. for (i = 0; i < imux->num_items; i++) {
  4383. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  4384. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  4385. imux->items[i].index,
  4386. HDA_AMP_MUTE, v);
  4387. }
  4388. *cur_val = idx;
  4389. return 1;
  4390. }
  4391. /*
  4392. * 2ch mode
  4393. */
  4394. static struct hda_verb alc882_3ST_ch2_init[] = {
  4395. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4396. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4397. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4398. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4399. { } /* end */
  4400. };
  4401. /*
  4402. * 6ch mode
  4403. */
  4404. static struct hda_verb alc882_3ST_ch6_init[] = {
  4405. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4406. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4407. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4408. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4409. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4410. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4411. { } /* end */
  4412. };
  4413. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4414. { 2, alc882_3ST_ch2_init },
  4415. { 6, alc882_3ST_ch6_init },
  4416. };
  4417. /*
  4418. * 6ch mode
  4419. */
  4420. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4421. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4422. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4423. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4424. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4425. { } /* end */
  4426. };
  4427. /*
  4428. * 8ch mode
  4429. */
  4430. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4431. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4432. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4433. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4434. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4435. { } /* end */
  4436. };
  4437. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4438. { 6, alc882_sixstack_ch6_init },
  4439. { 8, alc882_sixstack_ch8_init },
  4440. };
  4441. /*
  4442. * macbook pro ALC885 can switch LineIn to LineOut without loosing Mic
  4443. */
  4444. /*
  4445. * 2ch mode
  4446. */
  4447. static struct hda_verb alc885_mbp_ch2_init[] = {
  4448. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4449. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4450. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4451. { } /* end */
  4452. };
  4453. /*
  4454. * 6ch mode
  4455. */
  4456. static struct hda_verb alc885_mbp_ch6_init[] = {
  4457. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4458. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4459. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4460. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4461. { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4462. { } /* end */
  4463. };
  4464. static struct hda_channel_mode alc885_mbp_6ch_modes[2] = {
  4465. { 2, alc885_mbp_ch2_init },
  4466. { 6, alc885_mbp_ch6_init },
  4467. };
  4468. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4469. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4470. */
  4471. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4472. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4473. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4474. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4475. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4476. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4477. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4478. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4479. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4480. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4481. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4482. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4483. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4484. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4485. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4486. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4487. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4488. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4489. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4490. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4491. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4492. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4493. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4494. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4495. { } /* end */
  4496. };
  4497. static struct snd_kcontrol_new alc885_mbp3_mixer[] = {
  4498. HDA_CODEC_VOLUME("Master Volume", 0x0c, 0x00, HDA_OUTPUT),
  4499. HDA_BIND_MUTE ("Master Switch", 0x0c, 0x02, HDA_INPUT),
  4500. HDA_CODEC_MUTE ("Speaker Switch", 0x14, 0x00, HDA_OUTPUT),
  4501. HDA_CODEC_VOLUME("Line Out Volume", 0x0d,0x00, HDA_OUTPUT),
  4502. HDA_CODEC_VOLUME("Line In Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4503. HDA_CODEC_MUTE ("Line In Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4504. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x00, HDA_INPUT),
  4505. HDA_CODEC_MUTE ("Mic Playback Switch", 0x0b, 0x00, HDA_INPUT),
  4506. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0x00, HDA_INPUT),
  4507. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0x00, HDA_INPUT),
  4508. { } /* end */
  4509. };
  4510. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4511. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4512. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4513. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4514. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4515. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4516. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4517. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4518. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4519. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4520. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4521. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4522. { } /* end */
  4523. };
  4524. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4525. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4526. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4527. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4528. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4529. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4530. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4531. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4532. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4533. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4534. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4535. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4536. { } /* end */
  4537. };
  4538. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4539. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4540. */
  4541. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4542. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4543. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4544. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4545. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4546. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4547. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4548. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4549. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4550. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4551. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4552. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4553. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4554. { } /* end */
  4555. };
  4556. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4557. {
  4558. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4559. .name = "Channel Mode",
  4560. .info = alc_ch_mode_info,
  4561. .get = alc_ch_mode_get,
  4562. .put = alc_ch_mode_put,
  4563. },
  4564. { } /* end */
  4565. };
  4566. static struct hda_verb alc882_init_verbs[] = {
  4567. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4568. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4569. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4570. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4571. /* Rear mixer */
  4572. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4573. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4574. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4575. /* CLFE mixer */
  4576. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4577. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4578. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4579. /* Side mixer */
  4580. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4581. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4582. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4583. /* Front Pin: output 0 (0x0c) */
  4584. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4585. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4586. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4587. /* Rear Pin: output 1 (0x0d) */
  4588. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4589. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4590. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4591. /* CLFE Pin: output 2 (0x0e) */
  4592. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4593. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4594. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4595. /* Side Pin: output 3 (0x0f) */
  4596. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4597. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4598. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4599. /* Mic (rear) pin: input vref at 80% */
  4600. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4601. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4602. /* Front Mic pin: input vref at 80% */
  4603. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4604. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4605. /* Line In pin: input */
  4606. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4607. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4608. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4609. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4610. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4611. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4612. /* CD pin widget for input */
  4613. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4614. /* FIXME: use matrix-type input source selection */
  4615. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4616. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4617. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4618. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4619. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4620. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4621. /* Input mixer2 */
  4622. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4623. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4624. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4625. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4626. /* Input mixer3 */
  4627. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4628. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4629. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4630. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4631. /* ADC1: mute amp left and right */
  4632. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4633. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4634. /* ADC2: mute amp left and right */
  4635. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4636. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4637. /* ADC3: mute amp left and right */
  4638. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4639. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4640. { }
  4641. };
  4642. static struct hda_verb alc882_eapd_verbs[] = {
  4643. /* change to EAPD mode */
  4644. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4645. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4646. { }
  4647. };
  4648. /* Mac Pro test */
  4649. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4650. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4651. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4652. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4653. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4654. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4655. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4656. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4657. { } /* end */
  4658. };
  4659. static struct hda_verb alc882_macpro_init_verbs[] = {
  4660. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4661. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4662. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4663. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4664. /* Front Pin: output 0 (0x0c) */
  4665. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4666. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4667. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4668. /* Front Mic pin: input vref at 80% */
  4669. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4670. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4671. /* Speaker: output */
  4672. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4673. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4674. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4675. /* Headphone output (output 0 - 0x0c) */
  4676. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4677. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4678. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4679. /* FIXME: use matrix-type input source selection */
  4680. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4681. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4682. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4683. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4684. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4685. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4686. /* Input mixer2 */
  4687. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4688. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4689. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4690. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4691. /* Input mixer3 */
  4692. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4693. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4694. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4695. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4696. /* ADC1: mute amp left and right */
  4697. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4698. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4699. /* ADC2: mute amp left and right */
  4700. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4701. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4702. /* ADC3: mute amp left and right */
  4703. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4704. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4705. { }
  4706. };
  4707. /* Macbook Pro rev3 */
  4708. static struct hda_verb alc885_mbp3_init_verbs[] = {
  4709. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4710. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4711. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4712. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4713. /* Rear mixer */
  4714. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4715. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4716. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4717. /* Front Pin: output 0 (0x0c) */
  4718. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4719. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4720. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4721. /* HP Pin: output 0 (0x0d) */
  4722. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc4},
  4723. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4724. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4725. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4726. /* Mic (rear) pin: input vref at 80% */
  4727. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4728. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4729. /* Front Mic pin: input vref at 80% */
  4730. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4731. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4732. /* Line In pin: use output 1 when in LineOut mode */
  4733. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4734. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4735. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01},
  4736. /* FIXME: use matrix-type input source selection */
  4737. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4738. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4739. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4740. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4741. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4742. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4743. /* Input mixer2 */
  4744. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4745. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4746. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4747. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4748. /* Input mixer3 */
  4749. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4750. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4751. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4752. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4753. /* ADC1: mute amp left and right */
  4754. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4755. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4756. /* ADC2: mute amp left and right */
  4757. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4758. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4759. /* ADC3: mute amp left and right */
  4760. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4761. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4762. { }
  4763. };
  4764. /* iMac 24 mixer. */
  4765. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4766. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4767. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4768. { } /* end */
  4769. };
  4770. /* iMac 24 init verbs. */
  4771. static struct hda_verb alc885_imac24_init_verbs[] = {
  4772. /* Internal speakers: output 0 (0x0c) */
  4773. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4774. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4775. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4776. /* Internal speakers: output 0 (0x0c) */
  4777. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4778. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4779. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4780. /* Headphone: output 0 (0x0c) */
  4781. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4782. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4783. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4784. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4785. /* Front Mic: input vref at 80% */
  4786. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4787. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4788. { }
  4789. };
  4790. /* Toggle speaker-output according to the hp-jack state */
  4791. static void alc885_imac24_automute(struct hda_codec *codec)
  4792. {
  4793. unsigned int present;
  4794. present = snd_hda_codec_read(codec, 0x14, 0,
  4795. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4796. snd_hda_codec_amp_stereo(codec, 0x18, HDA_OUTPUT, 0,
  4797. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4798. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_OUTPUT, 0,
  4799. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4800. }
  4801. /* Processes unsolicited events. */
  4802. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4803. unsigned int res)
  4804. {
  4805. /* Headphone insertion or removal. */
  4806. if ((res >> 26) == ALC880_HP_EVENT)
  4807. alc885_imac24_automute(codec);
  4808. }
  4809. static void alc885_mbp3_automute(struct hda_codec *codec)
  4810. {
  4811. unsigned int present;
  4812. present = snd_hda_codec_read(codec, 0x15, 0,
  4813. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4814. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  4815. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4816. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  4817. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  4818. }
  4819. static void alc885_mbp3_unsol_event(struct hda_codec *codec,
  4820. unsigned int res)
  4821. {
  4822. /* Headphone insertion or removal. */
  4823. if ((res >> 26) == ALC880_HP_EVENT)
  4824. alc885_mbp3_automute(codec);
  4825. }
  4826. static struct hda_verb alc882_targa_verbs[] = {
  4827. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4828. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4829. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4830. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4831. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4832. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4833. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4834. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4835. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4836. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4837. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4838. { } /* end */
  4839. };
  4840. /* toggle speaker-output according to the hp-jack state */
  4841. static void alc882_targa_automute(struct hda_codec *codec)
  4842. {
  4843. unsigned int present;
  4844. present = snd_hda_codec_read(codec, 0x14, 0,
  4845. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4846. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  4847. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  4848. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  4849. present ? 1 : 3);
  4850. }
  4851. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4852. {
  4853. /* Looks like the unsol event is incompatible with the standard
  4854. * definition. 4bit tag is placed at 26 bit!
  4855. */
  4856. if (((res >> 26) == ALC880_HP_EVENT)) {
  4857. alc882_targa_automute(codec);
  4858. }
  4859. }
  4860. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4861. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4862. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4863. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4864. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4865. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4866. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4867. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4868. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4869. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4870. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4871. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4872. { } /* end */
  4873. };
  4874. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4875. {
  4876. unsigned int gpiostate, gpiomask, gpiodir;
  4877. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4878. AC_VERB_GET_GPIO_DATA, 0);
  4879. if (!muted)
  4880. gpiostate |= (1 << pin);
  4881. else
  4882. gpiostate &= ~(1 << pin);
  4883. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4884. AC_VERB_GET_GPIO_MASK, 0);
  4885. gpiomask |= (1 << pin);
  4886. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4887. AC_VERB_GET_GPIO_DIRECTION, 0);
  4888. gpiodir |= (1 << pin);
  4889. snd_hda_codec_write(codec, codec->afg, 0,
  4890. AC_VERB_SET_GPIO_MASK, gpiomask);
  4891. snd_hda_codec_write(codec, codec->afg, 0,
  4892. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4893. msleep(1);
  4894. snd_hda_codec_write(codec, codec->afg, 0,
  4895. AC_VERB_SET_GPIO_DATA, gpiostate);
  4896. }
  4897. /* set up GPIO at initialization */
  4898. static void alc885_macpro_init_hook(struct hda_codec *codec)
  4899. {
  4900. alc882_gpio_mute(codec, 0, 0);
  4901. alc882_gpio_mute(codec, 1, 0);
  4902. }
  4903. /* set up GPIO and update auto-muting at initialization */
  4904. static void alc885_imac24_init_hook(struct hda_codec *codec)
  4905. {
  4906. alc885_macpro_init_hook(codec);
  4907. alc885_imac24_automute(codec);
  4908. }
  4909. /*
  4910. * generic initialization of ADC, input mixers and output mixers
  4911. */
  4912. static struct hda_verb alc882_auto_init_verbs[] = {
  4913. /*
  4914. * Unmute ADC0-2 and set the default input to mic-in
  4915. */
  4916. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4917. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4918. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4919. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4920. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4921. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4922. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4923. * mixer widget
  4924. * Note: PASD motherboards uses the Line In 2 as the input for
  4925. * front panel mic (mic 2)
  4926. */
  4927. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4928. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4929. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4930. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4931. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4932. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4933. /*
  4934. * Set up output mixers (0x0c - 0x0f)
  4935. */
  4936. /* set vol=0 to output mixers */
  4937. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4938. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4939. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4940. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4941. /* set up input amps for analog loopback */
  4942. /* Amp Indices: DAC = 0, mixer = 1 */
  4943. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4944. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4945. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4946. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4947. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4948. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4949. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4950. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4951. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4952. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4953. /* FIXME: use matrix-type input source selection */
  4954. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4955. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4956. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4957. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4958. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4959. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4960. /* Input mixer2 */
  4961. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4962. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4963. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4964. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4965. /* Input mixer3 */
  4966. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4967. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4968. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4969. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4970. { }
  4971. };
  4972. /* capture mixer elements */
  4973. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4974. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4975. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4976. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4977. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4978. {
  4979. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4980. /* The multiple "Capture Source" controls confuse alsamixer
  4981. * So call somewhat different..
  4982. * FIXME: the controls appear in the "playback" view!
  4983. */
  4984. /* .name = "Capture Source", */
  4985. .name = "Input Source",
  4986. .count = 2,
  4987. .info = alc882_mux_enum_info,
  4988. .get = alc882_mux_enum_get,
  4989. .put = alc882_mux_enum_put,
  4990. },
  4991. { } /* end */
  4992. };
  4993. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4994. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4995. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4996. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4997. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4998. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4999. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  5000. {
  5001. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5002. /* The multiple "Capture Source" controls confuse alsamixer
  5003. * So call somewhat different..
  5004. * FIXME: the controls appear in the "playback" view!
  5005. */
  5006. /* .name = "Capture Source", */
  5007. .name = "Input Source",
  5008. .count = 3,
  5009. .info = alc882_mux_enum_info,
  5010. .get = alc882_mux_enum_get,
  5011. .put = alc882_mux_enum_put,
  5012. },
  5013. { } /* end */
  5014. };
  5015. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5016. #define alc882_loopbacks alc880_loopbacks
  5017. #endif
  5018. /* pcm configuration: identiacal with ALC880 */
  5019. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  5020. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  5021. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  5022. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  5023. /*
  5024. * configuration and preset
  5025. */
  5026. static const char *alc882_models[ALC882_MODEL_LAST] = {
  5027. [ALC882_3ST_DIG] = "3stack-dig",
  5028. [ALC882_6ST_DIG] = "6stack-dig",
  5029. [ALC882_ARIMA] = "arima",
  5030. [ALC882_W2JC] = "w2jc",
  5031. [ALC885_MACPRO] = "macpro",
  5032. [ALC885_MBP3] = "mbp3",
  5033. [ALC885_IMAC24] = "imac24",
  5034. [ALC882_AUTO] = "auto",
  5035. };
  5036. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  5037. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  5038. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  5039. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  5040. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  5041. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  5042. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  5043. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  5044. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  5045. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  5046. {}
  5047. };
  5048. static struct alc_config_preset alc882_presets[] = {
  5049. [ALC882_3ST_DIG] = {
  5050. .mixers = { alc882_base_mixer },
  5051. .init_verbs = { alc882_init_verbs },
  5052. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5053. .dac_nids = alc882_dac_nids,
  5054. .dig_out_nid = ALC882_DIGOUT_NID,
  5055. .dig_in_nid = ALC882_DIGIN_NID,
  5056. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5057. .channel_mode = alc882_ch_modes,
  5058. .need_dac_fix = 1,
  5059. .input_mux = &alc882_capture_source,
  5060. },
  5061. [ALC882_6ST_DIG] = {
  5062. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5063. .init_verbs = { alc882_init_verbs },
  5064. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5065. .dac_nids = alc882_dac_nids,
  5066. .dig_out_nid = ALC882_DIGOUT_NID,
  5067. .dig_in_nid = ALC882_DIGIN_NID,
  5068. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5069. .channel_mode = alc882_sixstack_modes,
  5070. .input_mux = &alc882_capture_source,
  5071. },
  5072. [ALC882_ARIMA] = {
  5073. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  5074. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  5075. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5076. .dac_nids = alc882_dac_nids,
  5077. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  5078. .channel_mode = alc882_sixstack_modes,
  5079. .input_mux = &alc882_capture_source,
  5080. },
  5081. [ALC882_W2JC] = {
  5082. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  5083. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  5084. alc880_gpio1_init_verbs },
  5085. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5086. .dac_nids = alc882_dac_nids,
  5087. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  5088. .channel_mode = alc880_threestack_modes,
  5089. .need_dac_fix = 1,
  5090. .input_mux = &alc882_capture_source,
  5091. .dig_out_nid = ALC882_DIGOUT_NID,
  5092. },
  5093. [ALC885_MBP3] = {
  5094. .mixers = { alc885_mbp3_mixer, alc882_chmode_mixer },
  5095. .init_verbs = { alc885_mbp3_init_verbs,
  5096. alc880_gpio1_init_verbs },
  5097. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5098. .dac_nids = alc882_dac_nids,
  5099. .channel_mode = alc885_mbp_6ch_modes,
  5100. .num_channel_mode = ARRAY_SIZE(alc885_mbp_6ch_modes),
  5101. .input_mux = &alc882_capture_source,
  5102. .dig_out_nid = ALC882_DIGOUT_NID,
  5103. .dig_in_nid = ALC882_DIGIN_NID,
  5104. .unsol_event = alc885_mbp3_unsol_event,
  5105. .init_hook = alc885_mbp3_automute,
  5106. },
  5107. [ALC885_MACPRO] = {
  5108. .mixers = { alc882_macpro_mixer },
  5109. .init_verbs = { alc882_macpro_init_verbs },
  5110. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5111. .dac_nids = alc882_dac_nids,
  5112. .dig_out_nid = ALC882_DIGOUT_NID,
  5113. .dig_in_nid = ALC882_DIGIN_NID,
  5114. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5115. .channel_mode = alc882_ch_modes,
  5116. .input_mux = &alc882_capture_source,
  5117. .init_hook = alc885_macpro_init_hook,
  5118. },
  5119. [ALC885_IMAC24] = {
  5120. .mixers = { alc885_imac24_mixer },
  5121. .init_verbs = { alc885_imac24_init_verbs },
  5122. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5123. .dac_nids = alc882_dac_nids,
  5124. .dig_out_nid = ALC882_DIGOUT_NID,
  5125. .dig_in_nid = ALC882_DIGIN_NID,
  5126. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  5127. .channel_mode = alc882_ch_modes,
  5128. .input_mux = &alc882_capture_source,
  5129. .unsol_event = alc885_imac24_unsol_event,
  5130. .init_hook = alc885_imac24_init_hook,
  5131. },
  5132. [ALC882_TARGA] = {
  5133. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  5134. alc882_capture_mixer },
  5135. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  5136. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5137. .dac_nids = alc882_dac_nids,
  5138. .dig_out_nid = ALC882_DIGOUT_NID,
  5139. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5140. .adc_nids = alc882_adc_nids,
  5141. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5142. .channel_mode = alc882_3ST_6ch_modes,
  5143. .need_dac_fix = 1,
  5144. .input_mux = &alc882_capture_source,
  5145. .unsol_event = alc882_targa_unsol_event,
  5146. .init_hook = alc882_targa_automute,
  5147. },
  5148. [ALC882_ASUS_A7J] = {
  5149. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  5150. alc882_capture_mixer },
  5151. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  5152. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  5153. .dac_nids = alc882_dac_nids,
  5154. .dig_out_nid = ALC882_DIGOUT_NID,
  5155. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  5156. .adc_nids = alc882_adc_nids,
  5157. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  5158. .channel_mode = alc882_3ST_6ch_modes,
  5159. .need_dac_fix = 1,
  5160. .input_mux = &alc882_capture_source,
  5161. },
  5162. };
  5163. /*
  5164. * Pin config fixes
  5165. */
  5166. enum {
  5167. PINFIX_ABIT_AW9D_MAX
  5168. };
  5169. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  5170. { 0x15, 0x01080104 }, /* side */
  5171. { 0x16, 0x01011012 }, /* rear */
  5172. { 0x17, 0x01016011 }, /* clfe */
  5173. { }
  5174. };
  5175. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5176. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5177. };
  5178. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5179. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5180. {}
  5181. };
  5182. /*
  5183. * BIOS auto configuration
  5184. */
  5185. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5186. hda_nid_t nid, int pin_type,
  5187. int dac_idx)
  5188. {
  5189. /* set as output */
  5190. struct alc_spec *spec = codec->spec;
  5191. int idx;
  5192. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5193. idx = 4;
  5194. else
  5195. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5196. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5197. pin_type);
  5198. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5199. AMP_OUT_UNMUTE);
  5200. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5201. }
  5202. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5203. {
  5204. struct alc_spec *spec = codec->spec;
  5205. int i;
  5206. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5207. for (i = 0; i <= HDA_SIDE; i++) {
  5208. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5209. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5210. if (nid)
  5211. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5212. i);
  5213. }
  5214. }
  5215. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5216. {
  5217. struct alc_spec *spec = codec->spec;
  5218. hda_nid_t pin;
  5219. pin = spec->autocfg.hp_pins[0];
  5220. if (pin) /* connect to front */
  5221. /* use dac 0 */
  5222. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5223. }
  5224. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5225. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5226. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5227. {
  5228. struct alc_spec *spec = codec->spec;
  5229. int i;
  5230. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5231. hda_nid_t nid = spec->autocfg.input_pins[i];
  5232. if (alc882_is_input_pin(nid)) {
  5233. snd_hda_codec_write(codec, nid, 0,
  5234. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5235. i <= AUTO_PIN_FRONT_MIC ?
  5236. PIN_VREF80 : PIN_IN);
  5237. if (nid != ALC882_PIN_CD_NID)
  5238. snd_hda_codec_write(codec, nid, 0,
  5239. AC_VERB_SET_AMP_GAIN_MUTE,
  5240. AMP_OUT_MUTE);
  5241. }
  5242. }
  5243. }
  5244. /* add mic boosts if needed */
  5245. static int alc_auto_add_mic_boost(struct hda_codec *codec)
  5246. {
  5247. struct alc_spec *spec = codec->spec;
  5248. int err;
  5249. hda_nid_t nid;
  5250. nid = spec->autocfg.input_pins[AUTO_PIN_MIC];
  5251. if (nid) {
  5252. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5253. "Mic Boost",
  5254. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5255. if (err < 0)
  5256. return err;
  5257. }
  5258. nid = spec->autocfg.input_pins[AUTO_PIN_FRONT_MIC];
  5259. if (nid) {
  5260. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  5261. "Front Mic Boost",
  5262. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  5263. if (err < 0)
  5264. return err;
  5265. }
  5266. return 0;
  5267. }
  5268. /* almost identical with ALC880 parser... */
  5269. static int alc882_parse_auto_config(struct hda_codec *codec)
  5270. {
  5271. struct alc_spec *spec = codec->spec;
  5272. int err = alc880_parse_auto_config(codec);
  5273. if (err < 0)
  5274. return err;
  5275. else if (!err)
  5276. return 0; /* no config found */
  5277. err = alc_auto_add_mic_boost(codec);
  5278. if (err < 0)
  5279. return err;
  5280. /* hack - override the init verbs */
  5281. spec->init_verbs[0] = alc882_auto_init_verbs;
  5282. return 1; /* config found */
  5283. }
  5284. /* additional initialization for auto-configuration model */
  5285. static void alc882_auto_init(struct hda_codec *codec)
  5286. {
  5287. alc882_auto_init_multi_out(codec);
  5288. alc882_auto_init_hp_out(codec);
  5289. alc882_auto_init_analog_input(codec);
  5290. }
  5291. static int patch_alc882(struct hda_codec *codec)
  5292. {
  5293. struct alc_spec *spec;
  5294. int err, board_config;
  5295. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5296. if (spec == NULL)
  5297. return -ENOMEM;
  5298. codec->spec = spec;
  5299. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5300. alc882_models,
  5301. alc882_cfg_tbl);
  5302. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5303. /* Pick up systems that don't supply PCI SSID */
  5304. switch (codec->subsystem_id) {
  5305. case 0x106b0c00: /* Mac Pro */
  5306. board_config = ALC885_MACPRO;
  5307. break;
  5308. case 0x106b1000: /* iMac 24 */
  5309. board_config = ALC885_IMAC24;
  5310. break;
  5311. case 0x106b2c00: /* Macbook Pro rev3 */
  5312. board_config = ALC885_MBP3;
  5313. break;
  5314. default:
  5315. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5316. "trying auto-probe from BIOS...\n");
  5317. board_config = ALC882_AUTO;
  5318. }
  5319. }
  5320. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5321. if (board_config == ALC882_AUTO) {
  5322. /* automatic parse from the BIOS config */
  5323. err = alc882_parse_auto_config(codec);
  5324. if (err < 0) {
  5325. alc_free(codec);
  5326. return err;
  5327. } else if (!err) {
  5328. printk(KERN_INFO
  5329. "hda_codec: Cannot set up configuration "
  5330. "from BIOS. Using base mode...\n");
  5331. board_config = ALC882_3ST_DIG;
  5332. }
  5333. }
  5334. if (board_config != ALC882_AUTO)
  5335. setup_preset(spec, &alc882_presets[board_config]);
  5336. spec->stream_name_analog = "ALC882 Analog";
  5337. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5338. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5339. spec->stream_name_digital = "ALC882 Digital";
  5340. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5341. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5342. if (!spec->adc_nids && spec->input_mux) {
  5343. /* check whether NID 0x07 is valid */
  5344. unsigned int wcap = get_wcaps(codec, 0x07);
  5345. /* get type */
  5346. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5347. if (wcap != AC_WID_AUD_IN) {
  5348. spec->adc_nids = alc882_adc_nids_alt;
  5349. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5350. spec->mixers[spec->num_mixers] =
  5351. alc882_capture_alt_mixer;
  5352. spec->num_mixers++;
  5353. } else {
  5354. spec->adc_nids = alc882_adc_nids;
  5355. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5356. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5357. spec->num_mixers++;
  5358. }
  5359. }
  5360. codec->patch_ops = alc_patch_ops;
  5361. if (board_config == ALC882_AUTO)
  5362. spec->init_hook = alc882_auto_init;
  5363. #ifdef CONFIG_SND_HDA_POWER_SAVE
  5364. if (!spec->loopback.amplist)
  5365. spec->loopback.amplist = alc882_loopbacks;
  5366. #endif
  5367. return 0;
  5368. }
  5369. /*
  5370. * ALC883 support
  5371. *
  5372. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5373. * configuration. Each pin widget can choose any input DACs and a mixer.
  5374. * Each ADC is connected from a mixer of all inputs. This makes possible
  5375. * 6-channel independent captures.
  5376. *
  5377. * In addition, an independent DAC for the multi-playback (not used in this
  5378. * driver yet).
  5379. */
  5380. #define ALC883_DIGOUT_NID 0x06
  5381. #define ALC883_DIGIN_NID 0x0a
  5382. static hda_nid_t alc883_dac_nids[4] = {
  5383. /* front, rear, clfe, rear_surr */
  5384. 0x02, 0x04, 0x03, 0x05
  5385. };
  5386. static hda_nid_t alc883_adc_nids[2] = {
  5387. /* ADC1-2 */
  5388. 0x08, 0x09,
  5389. };
  5390. /* input MUX */
  5391. /* FIXME: should be a matrix-type input source selection */
  5392. static struct hda_input_mux alc883_capture_source = {
  5393. .num_items = 4,
  5394. .items = {
  5395. { "Mic", 0x0 },
  5396. { "Front Mic", 0x1 },
  5397. { "Line", 0x2 },
  5398. { "CD", 0x4 },
  5399. },
  5400. };
  5401. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5402. .num_items = 2,
  5403. .items = {
  5404. { "Mic", 0x1 },
  5405. { "Line", 0x2 },
  5406. },
  5407. };
  5408. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5409. .num_items = 4,
  5410. .items = {
  5411. { "Mic", 0x0 },
  5412. { "iMic", 0x1 },
  5413. { "Line", 0x2 },
  5414. { "CD", 0x4 },
  5415. },
  5416. };
  5417. #define alc883_mux_enum_info alc_mux_enum_info
  5418. #define alc883_mux_enum_get alc_mux_enum_get
  5419. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5420. struct snd_ctl_elem_value *ucontrol)
  5421. {
  5422. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5423. struct alc_spec *spec = codec->spec;
  5424. const struct hda_input_mux *imux = spec->input_mux;
  5425. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5426. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5427. hda_nid_t nid = capture_mixers[adc_idx];
  5428. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5429. unsigned int i, idx;
  5430. idx = ucontrol->value.enumerated.item[0];
  5431. if (idx >= imux->num_items)
  5432. idx = imux->num_items - 1;
  5433. if (*cur_val == idx)
  5434. return 0;
  5435. for (i = 0; i < imux->num_items; i++) {
  5436. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  5437. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  5438. imux->items[i].index,
  5439. HDA_AMP_MUTE, v);
  5440. }
  5441. *cur_val = idx;
  5442. return 1;
  5443. }
  5444. /*
  5445. * 2ch mode
  5446. */
  5447. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5448. { 2, NULL }
  5449. };
  5450. /*
  5451. * 2ch mode
  5452. */
  5453. static struct hda_verb alc883_3ST_ch2_init[] = {
  5454. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5455. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5456. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5457. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5458. { } /* end */
  5459. };
  5460. /*
  5461. * 6ch mode
  5462. */
  5463. static struct hda_verb alc883_3ST_ch6_init[] = {
  5464. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5465. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5466. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5467. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5468. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5469. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5470. { } /* end */
  5471. };
  5472. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5473. { 2, alc883_3ST_ch2_init },
  5474. { 6, alc883_3ST_ch6_init },
  5475. };
  5476. /*
  5477. * 6ch mode
  5478. */
  5479. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5480. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5481. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5482. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5483. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5484. { } /* end */
  5485. };
  5486. /*
  5487. * 8ch mode
  5488. */
  5489. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5490. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5491. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5492. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5493. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5494. { } /* end */
  5495. };
  5496. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5497. { 6, alc883_sixstack_ch6_init },
  5498. { 8, alc883_sixstack_ch8_init },
  5499. };
  5500. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5501. /* eanable EAPD on medion laptop */
  5502. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5503. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5504. { }
  5505. };
  5506. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5507. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5508. */
  5509. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5510. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5511. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5512. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5513. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5514. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5515. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5516. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5517. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5518. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5519. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5520. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5521. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5522. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5523. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5524. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5525. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5526. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5527. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5528. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5529. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5530. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5531. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5532. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5533. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5534. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5535. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5536. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5537. {
  5538. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5539. /* .name = "Capture Source", */
  5540. .name = "Input Source",
  5541. .count = 2,
  5542. .info = alc883_mux_enum_info,
  5543. .get = alc883_mux_enum_get,
  5544. .put = alc883_mux_enum_put,
  5545. },
  5546. { } /* end */
  5547. };
  5548. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5549. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5550. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5551. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5552. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5553. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5554. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5555. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5556. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5557. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5558. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5559. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5560. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5561. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5562. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5563. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5564. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5565. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5566. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5567. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5568. {
  5569. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5570. /* .name = "Capture Source", */
  5571. .name = "Input Source",
  5572. .count = 2,
  5573. .info = alc883_mux_enum_info,
  5574. .get = alc883_mux_enum_get,
  5575. .put = alc883_mux_enum_put,
  5576. },
  5577. { } /* end */
  5578. };
  5579. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5580. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5581. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5582. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5583. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5584. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5585. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5586. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5587. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5588. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5589. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5590. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5591. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5592. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5593. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5594. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5595. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5596. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5597. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5598. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5599. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5600. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5601. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5602. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5603. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5604. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5605. {
  5606. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5607. /* .name = "Capture Source", */
  5608. .name = "Input Source",
  5609. .count = 2,
  5610. .info = alc883_mux_enum_info,
  5611. .get = alc883_mux_enum_get,
  5612. .put = alc883_mux_enum_put,
  5613. },
  5614. { } /* end */
  5615. };
  5616. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5617. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5618. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5619. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5620. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5621. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5622. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5623. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5624. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5625. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5626. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5627. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5628. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5629. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5630. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5631. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5632. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5633. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5634. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5635. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5636. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5637. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5638. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5639. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5640. {
  5641. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5642. /* .name = "Capture Source", */
  5643. .name = "Input Source",
  5644. .count = 1,
  5645. .info = alc883_mux_enum_info,
  5646. .get = alc883_mux_enum_get,
  5647. .put = alc883_mux_enum_put,
  5648. },
  5649. { } /* end */
  5650. };
  5651. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5652. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5653. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5654. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5655. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5656. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5657. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5658. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5659. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5660. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5661. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5662. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5663. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5664. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5665. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5666. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5667. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5668. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5669. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5670. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5671. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5672. {
  5673. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5674. /* .name = "Capture Source", */
  5675. .name = "Input Source",
  5676. .count = 2,
  5677. .info = alc883_mux_enum_info,
  5678. .get = alc883_mux_enum_get,
  5679. .put = alc883_mux_enum_put,
  5680. },
  5681. { } /* end */
  5682. };
  5683. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5684. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5685. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5686. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5687. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5688. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5689. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5690. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5691. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5692. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5693. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5694. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5695. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5696. {
  5697. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5698. /* .name = "Capture Source", */
  5699. .name = "Input Source",
  5700. .count = 2,
  5701. .info = alc883_mux_enum_info,
  5702. .get = alc883_mux_enum_get,
  5703. .put = alc883_mux_enum_put,
  5704. },
  5705. { } /* end */
  5706. };
  5707. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5708. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5709. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5710. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5711. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5712. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5713. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5714. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5715. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5716. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5717. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5718. {
  5719. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5720. /* .name = "Capture Source", */
  5721. .name = "Input Source",
  5722. .count = 1,
  5723. .info = alc883_mux_enum_info,
  5724. .get = alc883_mux_enum_get,
  5725. .put = alc883_mux_enum_put,
  5726. },
  5727. { } /* end */
  5728. };
  5729. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5730. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5731. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5732. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5733. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5734. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5735. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5736. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5737. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5738. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5739. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5740. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5741. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5742. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5743. {
  5744. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5745. /* .name = "Capture Source", */
  5746. .name = "Input Source",
  5747. .count = 2,
  5748. .info = alc883_mux_enum_info,
  5749. .get = alc883_mux_enum_get,
  5750. .put = alc883_mux_enum_put,
  5751. },
  5752. { } /* end */
  5753. };
  5754. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5755. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5756. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5757. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5758. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5759. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5760. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5761. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5762. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5763. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5764. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5765. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5766. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5767. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5768. {
  5769. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5770. /* .name = "Capture Source", */
  5771. .name = "Input Source",
  5772. .count = 2,
  5773. .info = alc883_mux_enum_info,
  5774. .get = alc883_mux_enum_get,
  5775. .put = alc883_mux_enum_put,
  5776. },
  5777. { } /* end */
  5778. };
  5779. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5780. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5781. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5782. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5783. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5784. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5785. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5786. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5787. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5788. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5789. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5790. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5791. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5792. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5793. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5794. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5795. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5796. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5797. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5798. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5799. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5800. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5801. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5802. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5803. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5804. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5805. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5806. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5807. {
  5808. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5809. /* .name = "Capture Source", */
  5810. .name = "Input Source",
  5811. .count = 2,
  5812. .info = alc883_mux_enum_info,
  5813. .get = alc883_mux_enum_get,
  5814. .put = alc883_mux_enum_put,
  5815. },
  5816. { } /* end */
  5817. };
  5818. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  5819. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5820. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5821. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5822. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5823. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5824. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5825. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5826. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5827. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5828. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5829. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5830. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5831. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5832. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5833. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5834. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5835. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5836. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5837. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5838. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5839. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5840. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5841. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5842. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5843. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5844. {
  5845. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5846. /* .name = "Capture Source", */
  5847. .name = "Input Source",
  5848. .count = 2,
  5849. .info = alc883_mux_enum_info,
  5850. .get = alc883_mux_enum_get,
  5851. .put = alc883_mux_enum_put,
  5852. },
  5853. { } /* end */
  5854. };
  5855. static struct snd_kcontrol_new alc883_acer_aspire_mixer[] = {
  5856. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5857. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5858. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5859. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5860. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5861. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5862. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5863. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5864. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5865. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5866. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5867. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5868. {
  5869. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5870. /* .name = "Capture Source", */
  5871. .name = "Input Source",
  5872. .count = 2,
  5873. .info = alc883_mux_enum_info,
  5874. .get = alc883_mux_enum_get,
  5875. .put = alc883_mux_enum_put,
  5876. },
  5877. { } /* end */
  5878. };
  5879. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5880. {
  5881. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5882. .name = "Channel Mode",
  5883. .info = alc_ch_mode_info,
  5884. .get = alc_ch_mode_get,
  5885. .put = alc_ch_mode_put,
  5886. },
  5887. { } /* end */
  5888. };
  5889. static struct hda_verb alc883_init_verbs[] = {
  5890. /* ADC1: mute amp left and right */
  5891. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5892. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5893. /* ADC2: mute amp left and right */
  5894. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5895. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5896. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5897. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5898. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5899. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5900. /* Rear mixer */
  5901. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5902. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5903. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5904. /* CLFE mixer */
  5905. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5906. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5907. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5908. /* Side mixer */
  5909. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5910. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5911. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5912. /* mute analog input loopbacks */
  5913. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5914. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5915. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  5916. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  5917. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  5918. /* Front Pin: output 0 (0x0c) */
  5919. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5920. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5921. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5922. /* Rear Pin: output 1 (0x0d) */
  5923. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5924. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5925. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5926. /* CLFE Pin: output 2 (0x0e) */
  5927. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5928. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5929. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5930. /* Side Pin: output 3 (0x0f) */
  5931. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5932. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5933. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5934. /* Mic (rear) pin: input vref at 80% */
  5935. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5936. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5937. /* Front Mic pin: input vref at 80% */
  5938. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5939. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5940. /* Line In pin: input */
  5941. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5942. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5943. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5944. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5945. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5946. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5947. /* CD pin widget for input */
  5948. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5949. /* FIXME: use matrix-type input source selection */
  5950. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5951. /* Input mixer2 */
  5952. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5953. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5954. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5955. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5956. /* Input mixer3 */
  5957. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5958. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5959. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5960. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5961. { }
  5962. };
  5963. static struct hda_verb alc883_tagra_verbs[] = {
  5964. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5965. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5966. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5967. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5968. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5969. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5970. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5971. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5972. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5973. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5974. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5975. { } /* end */
  5976. };
  5977. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5978. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5979. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5980. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5981. { } /* end */
  5982. };
  5983. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5984. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5985. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5986. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5987. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5988. { } /* end */
  5989. };
  5990. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5991. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5992. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5993. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5994. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5995. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5996. { } /* end */
  5997. };
  5998. static struct hda_verb alc883_haier_w66_verbs[] = {
  5999. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6000. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6001. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6002. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6003. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6004. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6005. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6006. { } /* end */
  6007. };
  6008. static struct hda_verb alc888_6st_hp_verbs[] = {
  6009. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6010. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  6011. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  6012. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  6013. { }
  6014. };
  6015. static struct hda_verb alc888_3st_hp_verbs[] = {
  6016. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  6017. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  6018. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  6019. { }
  6020. };
  6021. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  6022. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  6023. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6024. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  6025. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  6026. { }
  6027. };
  6028. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  6029. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6030. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6031. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6032. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6033. { }
  6034. };
  6035. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  6036. { 2, alc888_3st_hp_2ch_init },
  6037. { 6, alc888_3st_hp_6ch_init },
  6038. };
  6039. /* toggle front-jack and RCA according to the hp-jack state */
  6040. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  6041. {
  6042. unsigned int present;
  6043. present = snd_hda_codec_read(codec, 0x1b, 0,
  6044. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6045. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6046. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6047. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6048. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6049. }
  6050. /* toggle RCA according to the front-jack state */
  6051. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  6052. {
  6053. unsigned int present;
  6054. present = snd_hda_codec_read(codec, 0x14, 0,
  6055. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6056. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6057. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6058. }
  6059. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  6060. unsigned int res)
  6061. {
  6062. if ((res >> 26) == ALC880_HP_EVENT)
  6063. alc888_lenovo_ms7195_front_automute(codec);
  6064. if ((res >> 26) == ALC880_FRONT_EVENT)
  6065. alc888_lenovo_ms7195_rca_automute(codec);
  6066. }
  6067. static struct hda_verb alc883_medion_md2_verbs[] = {
  6068. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6069. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6070. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6071. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6072. { } /* end */
  6073. };
  6074. /* toggle speaker-output according to the hp-jack state */
  6075. static void alc883_medion_md2_automute(struct hda_codec *codec)
  6076. {
  6077. unsigned int present;
  6078. present = snd_hda_codec_read(codec, 0x14, 0,
  6079. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6080. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6081. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6082. }
  6083. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  6084. unsigned int res)
  6085. {
  6086. if ((res >> 26) == ALC880_HP_EVENT)
  6087. alc883_medion_md2_automute(codec);
  6088. }
  6089. /* toggle speaker-output according to the hp-jack state */
  6090. static void alc883_tagra_automute(struct hda_codec *codec)
  6091. {
  6092. unsigned int present;
  6093. unsigned char bits;
  6094. present = snd_hda_codec_read(codec, 0x14, 0,
  6095. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6096. bits = present ? HDA_AMP_MUTE : 0;
  6097. snd_hda_codec_amp_stereo(codec, 0x1b, HDA_OUTPUT, 0,
  6098. HDA_AMP_MUTE, bits);
  6099. snd_hda_codec_write_cache(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  6100. present ? 1 : 3);
  6101. }
  6102. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  6103. {
  6104. if ((res >> 26) == ALC880_HP_EVENT)
  6105. alc883_tagra_automute(codec);
  6106. }
  6107. static void alc883_haier_w66_automute(struct hda_codec *codec)
  6108. {
  6109. unsigned int present;
  6110. unsigned char bits;
  6111. present = snd_hda_codec_read(codec, 0x1b, 0,
  6112. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6113. bits = present ? 0x80 : 0;
  6114. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6115. 0x80, bits);
  6116. }
  6117. static void alc883_haier_w66_unsol_event(struct hda_codec *codec,
  6118. unsigned int res)
  6119. {
  6120. if ((res >> 26) == ALC880_HP_EVENT)
  6121. alc883_haier_w66_automute(codec);
  6122. }
  6123. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  6124. {
  6125. unsigned int present;
  6126. unsigned char bits;
  6127. present = snd_hda_codec_read(codec, 0x14, 0,
  6128. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6129. bits = present ? HDA_AMP_MUTE : 0;
  6130. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6131. HDA_AMP_MUTE, bits);
  6132. }
  6133. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  6134. {
  6135. unsigned int present;
  6136. unsigned char bits;
  6137. present = snd_hda_codec_read(codec, 0x1b, 0,
  6138. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6139. bits = present ? HDA_AMP_MUTE : 0;
  6140. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6141. HDA_AMP_MUTE, bits);
  6142. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6143. HDA_AMP_MUTE, bits);
  6144. }
  6145. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  6146. unsigned int res)
  6147. {
  6148. if ((res >> 26) == ALC880_HP_EVENT)
  6149. alc883_lenovo_101e_all_automute(codec);
  6150. if ((res >> 26) == ALC880_FRONT_EVENT)
  6151. alc883_lenovo_101e_ispeaker_automute(codec);
  6152. }
  6153. /* toggle speaker-output according to the hp-jack state */
  6154. static void alc883_acer_aspire_automute(struct hda_codec *codec)
  6155. {
  6156. unsigned int present;
  6157. present = snd_hda_codec_read(codec, 0x14, 0,
  6158. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  6159. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  6160. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6161. snd_hda_codec_amp_stereo(codec, 0x16, HDA_OUTPUT, 0,
  6162. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  6163. }
  6164. static void alc883_acer_aspire_unsol_event(struct hda_codec *codec,
  6165. unsigned int res)
  6166. {
  6167. if ((res >> 26) == ALC880_HP_EVENT)
  6168. alc883_acer_aspire_automute(codec);
  6169. }
  6170. static struct hda_verb alc883_acer_eapd_verbs[] = {
  6171. /* HP Pin: output 0 (0x0c) */
  6172. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6173. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  6174. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6175. /* Front Pin: output 0 (0x0c) */
  6176. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6177. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6178. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  6179. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00},
  6180. /* eanable EAPD on medion laptop */
  6181. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6182. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6183. /* enable unsolicited event */
  6184. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  6185. { }
  6186. };
  6187. /*
  6188. * generic initialization of ADC, input mixers and output mixers
  6189. */
  6190. static struct hda_verb alc883_auto_init_verbs[] = {
  6191. /*
  6192. * Unmute ADC0-2 and set the default input to mic-in
  6193. */
  6194. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6195. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6196. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6197. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6198. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6199. * mixer widget
  6200. * Note: PASD motherboards uses the Line In 2 as the input for
  6201. * front panel mic (mic 2)
  6202. */
  6203. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6204. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6205. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6206. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6207. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6208. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6209. /*
  6210. * Set up output mixers (0x0c - 0x0f)
  6211. */
  6212. /* set vol=0 to output mixers */
  6213. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6214. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6215. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6216. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6217. /* set up input amps for analog loopback */
  6218. /* Amp Indices: DAC = 0, mixer = 1 */
  6219. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6220. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6221. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6222. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6223. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6224. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6225. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6226. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6227. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6228. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6229. /* FIXME: use matrix-type input source selection */
  6230. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6231. /* Input mixer1 */
  6232. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6233. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6234. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6235. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6236. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6237. /* Input mixer2 */
  6238. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6239. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6240. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6241. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  6242. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6243. { }
  6244. };
  6245. /* capture mixer elements */
  6246. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  6247. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  6248. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  6249. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  6250. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  6251. {
  6252. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6253. /* The multiple "Capture Source" controls confuse alsamixer
  6254. * So call somewhat different..
  6255. * FIXME: the controls appear in the "playback" view!
  6256. */
  6257. /* .name = "Capture Source", */
  6258. .name = "Input Source",
  6259. .count = 2,
  6260. .info = alc882_mux_enum_info,
  6261. .get = alc882_mux_enum_get,
  6262. .put = alc882_mux_enum_put,
  6263. },
  6264. { } /* end */
  6265. };
  6266. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6267. #define alc883_loopbacks alc880_loopbacks
  6268. #endif
  6269. /* pcm configuration: identiacal with ALC880 */
  6270. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  6271. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  6272. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  6273. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  6274. /*
  6275. * configuration and preset
  6276. */
  6277. static const char *alc883_models[ALC883_MODEL_LAST] = {
  6278. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6279. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6280. [ALC883_3ST_6ch] = "3stack-6ch",
  6281. [ALC883_6ST_DIG] = "6stack-dig",
  6282. [ALC883_TARGA_DIG] = "targa-dig",
  6283. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6284. [ALC883_ACER] = "acer",
  6285. [ALC883_ACER_ASPIRE] = "acer-aspire",
  6286. [ALC883_MEDION] = "medion",
  6287. [ALC883_MEDION_MD2] = "medion-md2",
  6288. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6289. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6290. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6291. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6292. [ALC883_HAIER_W66] = "haier-w66",
  6293. [ALC888_6ST_HP] = "6stack-hp",
  6294. [ALC888_3ST_HP] = "3stack-hp",
  6295. [ALC883_AUTO] = "auto",
  6296. };
  6297. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6298. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6299. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6300. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6301. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6302. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6303. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6304. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6305. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6306. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6307. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6308. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6309. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6310. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6311. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6312. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6313. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6314. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6315. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6316. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6317. SND_PCI_QUIRK(0x1462, 0x3fdf, "MSI", ALC883_TARGA_DIG),
  6318. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6319. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6320. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6321. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6322. SND_PCI_QUIRK(0x1025, 0x006c, "Acer Aspire 9810", ALC883_ACER_ASPIRE),
  6323. SND_PCI_QUIRK(0x1025, 0x0110, "Acer Aspire", ALC883_ACER_ASPIRE),
  6324. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6325. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6326. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6327. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6328. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6329. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6330. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6331. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6332. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6333. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6334. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6335. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6336. SND_PCI_QUIRK(0x1991, 0x5625, "Haier W66", ALC883_HAIER_W66),
  6337. SND_PCI_QUIRK(0x17aa, 0x3bfc, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6338. {}
  6339. };
  6340. static struct alc_config_preset alc883_presets[] = {
  6341. [ALC883_3ST_2ch_DIG] = {
  6342. .mixers = { alc883_3ST_2ch_mixer },
  6343. .init_verbs = { alc883_init_verbs },
  6344. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6345. .dac_nids = alc883_dac_nids,
  6346. .dig_out_nid = ALC883_DIGOUT_NID,
  6347. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6348. .adc_nids = alc883_adc_nids,
  6349. .dig_in_nid = ALC883_DIGIN_NID,
  6350. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6351. .channel_mode = alc883_3ST_2ch_modes,
  6352. .input_mux = &alc883_capture_source,
  6353. },
  6354. [ALC883_3ST_6ch_DIG] = {
  6355. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6356. .init_verbs = { alc883_init_verbs },
  6357. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6358. .dac_nids = alc883_dac_nids,
  6359. .dig_out_nid = ALC883_DIGOUT_NID,
  6360. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6361. .adc_nids = alc883_adc_nids,
  6362. .dig_in_nid = ALC883_DIGIN_NID,
  6363. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6364. .channel_mode = alc883_3ST_6ch_modes,
  6365. .need_dac_fix = 1,
  6366. .input_mux = &alc883_capture_source,
  6367. },
  6368. [ALC883_3ST_6ch] = {
  6369. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6370. .init_verbs = { alc883_init_verbs },
  6371. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6372. .dac_nids = alc883_dac_nids,
  6373. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6374. .adc_nids = alc883_adc_nids,
  6375. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6376. .channel_mode = alc883_3ST_6ch_modes,
  6377. .need_dac_fix = 1,
  6378. .input_mux = &alc883_capture_source,
  6379. },
  6380. [ALC883_6ST_DIG] = {
  6381. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6382. .init_verbs = { alc883_init_verbs },
  6383. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6384. .dac_nids = alc883_dac_nids,
  6385. .dig_out_nid = ALC883_DIGOUT_NID,
  6386. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6387. .adc_nids = alc883_adc_nids,
  6388. .dig_in_nid = ALC883_DIGIN_NID,
  6389. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6390. .channel_mode = alc883_sixstack_modes,
  6391. .input_mux = &alc883_capture_source,
  6392. },
  6393. [ALC883_TARGA_DIG] = {
  6394. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6395. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6396. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6397. .dac_nids = alc883_dac_nids,
  6398. .dig_out_nid = ALC883_DIGOUT_NID,
  6399. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6400. .adc_nids = alc883_adc_nids,
  6401. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6402. .channel_mode = alc883_3ST_6ch_modes,
  6403. .need_dac_fix = 1,
  6404. .input_mux = &alc883_capture_source,
  6405. .unsol_event = alc883_tagra_unsol_event,
  6406. .init_hook = alc883_tagra_automute,
  6407. },
  6408. [ALC883_TARGA_2ch_DIG] = {
  6409. .mixers = { alc883_tagra_2ch_mixer},
  6410. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6411. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6412. .dac_nids = alc883_dac_nids,
  6413. .dig_out_nid = ALC883_DIGOUT_NID,
  6414. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6415. .adc_nids = alc883_adc_nids,
  6416. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6417. .channel_mode = alc883_3ST_2ch_modes,
  6418. .input_mux = &alc883_capture_source,
  6419. .unsol_event = alc883_tagra_unsol_event,
  6420. .init_hook = alc883_tagra_automute,
  6421. },
  6422. [ALC883_ACER] = {
  6423. .mixers = { alc883_base_mixer },
  6424. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6425. * and the headphone jack. Turn this on and rely on the
  6426. * standard mute methods whenever the user wants to turn
  6427. * these outputs off.
  6428. */
  6429. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6430. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6431. .dac_nids = alc883_dac_nids,
  6432. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6433. .adc_nids = alc883_adc_nids,
  6434. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6435. .channel_mode = alc883_3ST_2ch_modes,
  6436. .input_mux = &alc883_capture_source,
  6437. },
  6438. [ALC883_ACER_ASPIRE] = {
  6439. .mixers = { alc883_acer_aspire_mixer },
  6440. .init_verbs = { alc883_init_verbs, alc883_acer_eapd_verbs },
  6441. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6442. .dac_nids = alc883_dac_nids,
  6443. .dig_out_nid = ALC883_DIGOUT_NID,
  6444. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6445. .adc_nids = alc883_adc_nids,
  6446. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6447. .channel_mode = alc883_3ST_2ch_modes,
  6448. .input_mux = &alc883_capture_source,
  6449. .unsol_event = alc883_acer_aspire_unsol_event,
  6450. .init_hook = alc883_acer_aspire_automute,
  6451. },
  6452. [ALC883_MEDION] = {
  6453. .mixers = { alc883_fivestack_mixer,
  6454. alc883_chmode_mixer },
  6455. .init_verbs = { alc883_init_verbs,
  6456. alc883_medion_eapd_verbs },
  6457. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6458. .dac_nids = alc883_dac_nids,
  6459. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6460. .adc_nids = alc883_adc_nids,
  6461. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6462. .channel_mode = alc883_sixstack_modes,
  6463. .input_mux = &alc883_capture_source,
  6464. },
  6465. [ALC883_MEDION_MD2] = {
  6466. .mixers = { alc883_medion_md2_mixer},
  6467. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6468. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6469. .dac_nids = alc883_dac_nids,
  6470. .dig_out_nid = ALC883_DIGOUT_NID,
  6471. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6472. .adc_nids = alc883_adc_nids,
  6473. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6474. .channel_mode = alc883_3ST_2ch_modes,
  6475. .input_mux = &alc883_capture_source,
  6476. .unsol_event = alc883_medion_md2_unsol_event,
  6477. .init_hook = alc883_medion_md2_automute,
  6478. },
  6479. [ALC883_LAPTOP_EAPD] = {
  6480. .mixers = { alc883_base_mixer },
  6481. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6482. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6483. .dac_nids = alc883_dac_nids,
  6484. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6485. .adc_nids = alc883_adc_nids,
  6486. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6487. .channel_mode = alc883_3ST_2ch_modes,
  6488. .input_mux = &alc883_capture_source,
  6489. },
  6490. [ALC883_LENOVO_101E_2ch] = {
  6491. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6492. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6493. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6494. .dac_nids = alc883_dac_nids,
  6495. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6496. .adc_nids = alc883_adc_nids,
  6497. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6498. .channel_mode = alc883_3ST_2ch_modes,
  6499. .input_mux = &alc883_lenovo_101e_capture_source,
  6500. .unsol_event = alc883_lenovo_101e_unsol_event,
  6501. .init_hook = alc883_lenovo_101e_all_automute,
  6502. },
  6503. [ALC883_LENOVO_NB0763] = {
  6504. .mixers = { alc883_lenovo_nb0763_mixer },
  6505. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6506. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6507. .dac_nids = alc883_dac_nids,
  6508. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6509. .adc_nids = alc883_adc_nids,
  6510. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6511. .channel_mode = alc883_3ST_2ch_modes,
  6512. .need_dac_fix = 1,
  6513. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6514. .unsol_event = alc883_medion_md2_unsol_event,
  6515. .init_hook = alc883_medion_md2_automute,
  6516. },
  6517. [ALC888_LENOVO_MS7195_DIG] = {
  6518. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6519. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6520. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6521. .dac_nids = alc883_dac_nids,
  6522. .dig_out_nid = ALC883_DIGOUT_NID,
  6523. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6524. .adc_nids = alc883_adc_nids,
  6525. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6526. .channel_mode = alc883_3ST_6ch_modes,
  6527. .need_dac_fix = 1,
  6528. .input_mux = &alc883_capture_source,
  6529. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6530. .init_hook = alc888_lenovo_ms7195_front_automute,
  6531. },
  6532. [ALC883_HAIER_W66] = {
  6533. .mixers = { alc883_tagra_2ch_mixer},
  6534. .init_verbs = { alc883_init_verbs, alc883_haier_w66_verbs},
  6535. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6536. .dac_nids = alc883_dac_nids,
  6537. .dig_out_nid = ALC883_DIGOUT_NID,
  6538. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6539. .adc_nids = alc883_adc_nids,
  6540. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6541. .channel_mode = alc883_3ST_2ch_modes,
  6542. .input_mux = &alc883_capture_source,
  6543. .unsol_event = alc883_haier_w66_unsol_event,
  6544. .init_hook = alc883_haier_w66_automute,
  6545. },
  6546. [ALC888_6ST_HP] = {
  6547. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6548. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6549. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6550. .dac_nids = alc883_dac_nids,
  6551. .dig_out_nid = ALC883_DIGOUT_NID,
  6552. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6553. .adc_nids = alc883_adc_nids,
  6554. .dig_in_nid = ALC883_DIGIN_NID,
  6555. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6556. .channel_mode = alc883_sixstack_modes,
  6557. .input_mux = &alc883_capture_source,
  6558. },
  6559. [ALC888_3ST_HP] = {
  6560. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6561. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6562. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6563. .dac_nids = alc883_dac_nids,
  6564. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6565. .adc_nids = alc883_adc_nids,
  6566. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6567. .channel_mode = alc888_3st_hp_modes,
  6568. .need_dac_fix = 1,
  6569. .input_mux = &alc883_capture_source,
  6570. },
  6571. };
  6572. /*
  6573. * BIOS auto configuration
  6574. */
  6575. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6576. hda_nid_t nid, int pin_type,
  6577. int dac_idx)
  6578. {
  6579. /* set as output */
  6580. struct alc_spec *spec = codec->spec;
  6581. int idx;
  6582. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6583. idx = 4;
  6584. else
  6585. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6586. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6587. pin_type);
  6588. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6589. AMP_OUT_UNMUTE);
  6590. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6591. }
  6592. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6593. {
  6594. struct alc_spec *spec = codec->spec;
  6595. int i;
  6596. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6597. for (i = 0; i <= HDA_SIDE; i++) {
  6598. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6599. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6600. if (nid)
  6601. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6602. i);
  6603. }
  6604. }
  6605. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6606. {
  6607. struct alc_spec *spec = codec->spec;
  6608. hda_nid_t pin;
  6609. pin = spec->autocfg.hp_pins[0];
  6610. if (pin) /* connect to front */
  6611. /* use dac 0 */
  6612. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6613. }
  6614. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6615. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6616. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6617. {
  6618. struct alc_spec *spec = codec->spec;
  6619. int i;
  6620. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6621. hda_nid_t nid = spec->autocfg.input_pins[i];
  6622. if (alc883_is_input_pin(nid)) {
  6623. snd_hda_codec_write(codec, nid, 0,
  6624. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6625. (i <= AUTO_PIN_FRONT_MIC ?
  6626. PIN_VREF80 : PIN_IN));
  6627. if (nid != ALC883_PIN_CD_NID)
  6628. snd_hda_codec_write(codec, nid, 0,
  6629. AC_VERB_SET_AMP_GAIN_MUTE,
  6630. AMP_OUT_MUTE);
  6631. }
  6632. }
  6633. }
  6634. /* almost identical with ALC880 parser... */
  6635. static int alc883_parse_auto_config(struct hda_codec *codec)
  6636. {
  6637. struct alc_spec *spec = codec->spec;
  6638. int err = alc880_parse_auto_config(codec);
  6639. if (err < 0)
  6640. return err;
  6641. else if (!err)
  6642. return 0; /* no config found */
  6643. err = alc_auto_add_mic_boost(codec);
  6644. if (err < 0)
  6645. return err;
  6646. /* hack - override the init verbs */
  6647. spec->init_verbs[0] = alc883_auto_init_verbs;
  6648. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6649. spec->num_mixers++;
  6650. return 1; /* config found */
  6651. }
  6652. /* additional initialization for auto-configuration model */
  6653. static void alc883_auto_init(struct hda_codec *codec)
  6654. {
  6655. alc883_auto_init_multi_out(codec);
  6656. alc883_auto_init_hp_out(codec);
  6657. alc883_auto_init_analog_input(codec);
  6658. }
  6659. static int patch_alc883(struct hda_codec *codec)
  6660. {
  6661. struct alc_spec *spec;
  6662. int err, board_config;
  6663. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6664. if (spec == NULL)
  6665. return -ENOMEM;
  6666. codec->spec = spec;
  6667. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6668. alc883_models,
  6669. alc883_cfg_tbl);
  6670. if (board_config < 0) {
  6671. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6672. "trying auto-probe from BIOS...\n");
  6673. board_config = ALC883_AUTO;
  6674. }
  6675. if (board_config == ALC883_AUTO) {
  6676. /* automatic parse from the BIOS config */
  6677. err = alc883_parse_auto_config(codec);
  6678. if (err < 0) {
  6679. alc_free(codec);
  6680. return err;
  6681. } else if (!err) {
  6682. printk(KERN_INFO
  6683. "hda_codec: Cannot set up configuration "
  6684. "from BIOS. Using base mode...\n");
  6685. board_config = ALC883_3ST_2ch_DIG;
  6686. }
  6687. }
  6688. if (board_config != ALC883_AUTO)
  6689. setup_preset(spec, &alc883_presets[board_config]);
  6690. spec->stream_name_analog = "ALC883 Analog";
  6691. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6692. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6693. spec->stream_name_digital = "ALC883 Digital";
  6694. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6695. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6696. if (!spec->adc_nids && spec->input_mux) {
  6697. spec->adc_nids = alc883_adc_nids;
  6698. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6699. }
  6700. codec->patch_ops = alc_patch_ops;
  6701. if (board_config == ALC883_AUTO)
  6702. spec->init_hook = alc883_auto_init;
  6703. #ifdef CONFIG_SND_HDA_POWER_SAVE
  6704. if (!spec->loopback.amplist)
  6705. spec->loopback.amplist = alc883_loopbacks;
  6706. #endif
  6707. return 0;
  6708. }
  6709. /*
  6710. * ALC262 support
  6711. */
  6712. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6713. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6714. #define alc262_dac_nids alc260_dac_nids
  6715. #define alc262_adc_nids alc882_adc_nids
  6716. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6717. #define alc262_modes alc260_modes
  6718. #define alc262_capture_source alc882_capture_source
  6719. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6720. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6721. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6722. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6723. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6724. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6725. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6726. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6727. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6728. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6729. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6730. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6731. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6732. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6733. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6734. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6735. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6736. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6737. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6738. { } /* end */
  6739. };
  6740. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6741. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6742. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6743. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6744. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6745. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6746. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6747. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6748. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6749. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6750. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6751. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6752. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6753. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6754. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6755. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6756. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6757. { } /* end */
  6758. };
  6759. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6760. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6761. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6762. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6763. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6764. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6765. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6766. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6767. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6768. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6769. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6770. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6771. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6772. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6773. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6774. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6775. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6776. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6777. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6778. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6779. { } /* end */
  6780. };
  6781. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6782. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6783. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6784. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6785. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6786. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6787. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6788. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6789. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6790. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6791. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6792. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6793. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6794. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6795. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6796. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6797. { } /* end */
  6798. };
  6799. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6800. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6801. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6802. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6803. { } /* end */
  6804. };
  6805. /* bind hp and internal speaker mute (with plug check) */
  6806. static int alc262_sony_master_sw_put(struct snd_kcontrol *kcontrol,
  6807. struct snd_ctl_elem_value *ucontrol)
  6808. {
  6809. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6810. long *valp = ucontrol->value.integer.value;
  6811. int change;
  6812. /* change hp mute */
  6813. change = snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6814. HDA_AMP_MUTE,
  6815. valp[0] ? 0 : HDA_AMP_MUTE);
  6816. change |= snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6817. HDA_AMP_MUTE,
  6818. valp[1] ? 0 : HDA_AMP_MUTE);
  6819. if (change) {
  6820. /* change speaker according to HP jack state */
  6821. struct alc_spec *spec = codec->spec;
  6822. unsigned int mute;
  6823. if (spec->jack_present)
  6824. mute = HDA_AMP_MUTE;
  6825. else
  6826. mute = snd_hda_codec_amp_read(codec, 0x15, 0,
  6827. HDA_OUTPUT, 0);
  6828. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6829. HDA_AMP_MUTE, mute);
  6830. }
  6831. return change;
  6832. }
  6833. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6834. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6835. {
  6836. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6837. .name = "Master Playback Switch",
  6838. .info = snd_hda_mixer_amp_switch_info,
  6839. .get = snd_hda_mixer_amp_switch_get,
  6840. .put = alc262_sony_master_sw_put,
  6841. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  6842. },
  6843. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6844. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6845. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6846. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6847. { } /* end */
  6848. };
  6849. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6850. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6851. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6852. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6853. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6854. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6855. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6856. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6857. { } /* end */
  6858. };
  6859. #define alc262_capture_mixer alc882_capture_mixer
  6860. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6861. /*
  6862. * generic initialization of ADC, input mixers and output mixers
  6863. */
  6864. static struct hda_verb alc262_init_verbs[] = {
  6865. /*
  6866. * Unmute ADC0-2 and set the default input to mic-in
  6867. */
  6868. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6869. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6870. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6871. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6872. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6873. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6874. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6875. * mixer widget
  6876. * Note: PASD motherboards uses the Line In 2 as the input for
  6877. * front panel mic (mic 2)
  6878. */
  6879. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6880. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  6881. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  6882. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  6883. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  6884. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  6885. /*
  6886. * Set up output mixers (0x0c - 0x0e)
  6887. */
  6888. /* set vol=0 to output mixers */
  6889. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6890. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6891. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6892. /* set up input amps for analog loopback */
  6893. /* Amp Indices: DAC = 0, mixer = 1 */
  6894. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6895. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6896. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6897. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6898. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6899. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6900. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6901. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6902. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6903. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6904. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6905. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6906. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6907. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6908. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6909. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6910. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6911. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6912. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6913. /* FIXME: use matrix-type input source selection */
  6914. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6915. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6916. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6917. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6918. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6919. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6920. /* Input mixer2 */
  6921. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6922. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6923. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6924. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6925. /* Input mixer3 */
  6926. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6927. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6928. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6929. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6930. { }
  6931. };
  6932. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6933. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6934. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6935. {}
  6936. };
  6937. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6938. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6939. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6940. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6941. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6942. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6943. {}
  6944. };
  6945. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6946. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6947. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6948. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6949. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6950. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6951. };
  6952. /* mute/unmute internal speaker according to the hp jack and mute state */
  6953. static void alc262_hippo_automute(struct hda_codec *codec)
  6954. {
  6955. struct alc_spec *spec = codec->spec;
  6956. unsigned int mute;
  6957. unsigned int present;
  6958. /* need to execute and sync at first */
  6959. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6960. present = snd_hda_codec_read(codec, 0x15, 0,
  6961. AC_VERB_GET_PIN_SENSE, 0);
  6962. spec->jack_present = (present & 0x80000000) != 0;
  6963. if (spec->jack_present) {
  6964. /* mute internal speaker */
  6965. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6966. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6967. } else {
  6968. /* unmute internal speaker if necessary */
  6969. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6970. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6971. HDA_AMP_MUTE, mute);
  6972. }
  6973. }
  6974. /* unsolicited event for HP jack sensing */
  6975. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6976. unsigned int res)
  6977. {
  6978. if ((res >> 26) != ALC880_HP_EVENT)
  6979. return;
  6980. alc262_hippo_automute(codec);
  6981. }
  6982. static void alc262_hippo1_automute(struct hda_codec *codec)
  6983. {
  6984. unsigned int mute;
  6985. unsigned int present;
  6986. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6987. present = snd_hda_codec_read(codec, 0x1b, 0,
  6988. AC_VERB_GET_PIN_SENSE, 0);
  6989. present = (present & 0x80000000) != 0;
  6990. if (present) {
  6991. /* mute internal speaker */
  6992. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6993. HDA_AMP_MUTE, HDA_AMP_MUTE);
  6994. } else {
  6995. /* unmute internal speaker if necessary */
  6996. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6997. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  6998. HDA_AMP_MUTE, mute);
  6999. }
  7000. }
  7001. /* unsolicited event for HP jack sensing */
  7002. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  7003. unsigned int res)
  7004. {
  7005. if ((res >> 26) != ALC880_HP_EVENT)
  7006. return;
  7007. alc262_hippo1_automute(codec);
  7008. }
  7009. /*
  7010. * fujitsu model
  7011. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  7012. */
  7013. #define ALC_HP_EVENT 0x37
  7014. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  7015. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  7016. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7017. {}
  7018. };
  7019. static struct hda_input_mux alc262_fujitsu_capture_source = {
  7020. .num_items = 2,
  7021. .items = {
  7022. { "Mic", 0x0 },
  7023. { "CD", 0x4 },
  7024. },
  7025. };
  7026. static struct hda_input_mux alc262_HP_capture_source = {
  7027. .num_items = 5,
  7028. .items = {
  7029. { "Mic", 0x0 },
  7030. { "Front Mic", 0x1 },
  7031. { "Line", 0x2 },
  7032. { "CD", 0x4 },
  7033. { "AUX IN", 0x6 },
  7034. },
  7035. };
  7036. static struct hda_input_mux alc262_HP_D7000_capture_source = {
  7037. .num_items = 4,
  7038. .items = {
  7039. { "Mic", 0x0 },
  7040. { "Front Mic", 0x2 },
  7041. { "Line", 0x1 },
  7042. { "CD", 0x4 },
  7043. },
  7044. };
  7045. /* mute/unmute internal speaker according to the hp jack and mute state */
  7046. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  7047. {
  7048. struct alc_spec *spec = codec->spec;
  7049. unsigned int mute;
  7050. if (force || !spec->sense_updated) {
  7051. unsigned int present;
  7052. /* need to execute and sync at first */
  7053. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  7054. present = snd_hda_codec_read(codec, 0x14, 0,
  7055. AC_VERB_GET_PIN_SENSE, 0);
  7056. spec->jack_present = (present & 0x80000000) != 0;
  7057. spec->sense_updated = 1;
  7058. }
  7059. if (spec->jack_present) {
  7060. /* mute internal speaker */
  7061. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7062. HDA_AMP_MUTE, HDA_AMP_MUTE);
  7063. } else {
  7064. /* unmute internal speaker if necessary */
  7065. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7066. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7067. HDA_AMP_MUTE, mute);
  7068. }
  7069. }
  7070. /* unsolicited event for HP jack sensing */
  7071. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  7072. unsigned int res)
  7073. {
  7074. if ((res >> 26) != ALC_HP_EVENT)
  7075. return;
  7076. alc262_fujitsu_automute(codec, 1);
  7077. }
  7078. /* bind volumes of both NID 0x0c and 0x0d */
  7079. static struct hda_bind_ctls alc262_fujitsu_bind_master_vol = {
  7080. .ops = &snd_hda_bind_vol,
  7081. .values = {
  7082. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  7083. HDA_COMPOSE_AMP_VAL(0x0d, 3, 0, HDA_OUTPUT),
  7084. 0
  7085. },
  7086. };
  7087. /* bind hp and internal speaker mute (with plug check) */
  7088. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  7089. struct snd_ctl_elem_value *ucontrol)
  7090. {
  7091. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7092. long *valp = ucontrol->value.integer.value;
  7093. int change;
  7094. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7095. HDA_AMP_MUTE,
  7096. valp[0] ? 0 : HDA_AMP_MUTE);
  7097. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7098. HDA_AMP_MUTE,
  7099. valp[1] ? 0 : HDA_AMP_MUTE);
  7100. if (change)
  7101. alc262_fujitsu_automute(codec, 0);
  7102. return change;
  7103. }
  7104. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  7105. HDA_BIND_VOL("Master Playback Volume", &alc262_fujitsu_bind_master_vol),
  7106. {
  7107. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7108. .name = "Master Playback Switch",
  7109. .info = snd_hda_mixer_amp_switch_info,
  7110. .get = snd_hda_mixer_amp_switch_get,
  7111. .put = alc262_fujitsu_master_sw_put,
  7112. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7113. },
  7114. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  7115. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  7116. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7117. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  7118. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  7119. { } /* end */
  7120. };
  7121. /* additional init verbs for Benq laptops */
  7122. static struct hda_verb alc262_EAPD_verbs[] = {
  7123. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7124. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  7125. {}
  7126. };
  7127. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  7128. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7129. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7130. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  7131. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  7132. {}
  7133. };
  7134. /* add playback controls from the parsed DAC table */
  7135. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  7136. const struct auto_pin_cfg *cfg)
  7137. {
  7138. hda_nid_t nid;
  7139. int err;
  7140. spec->multiout.num_dacs = 1; /* only use one dac */
  7141. spec->multiout.dac_nids = spec->private_dac_nids;
  7142. spec->multiout.dac_nids[0] = 2;
  7143. nid = cfg->line_out_pins[0];
  7144. if (nid) {
  7145. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7146. "Front Playback Volume",
  7147. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  7148. if (err < 0)
  7149. return err;
  7150. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7151. "Front Playback Switch",
  7152. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  7153. if (err < 0)
  7154. return err;
  7155. }
  7156. nid = cfg->speaker_pins[0];
  7157. if (nid) {
  7158. if (nid == 0x16) {
  7159. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7160. "Speaker Playback Volume",
  7161. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7162. HDA_OUTPUT));
  7163. if (err < 0)
  7164. return err;
  7165. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7166. "Speaker Playback Switch",
  7167. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7168. HDA_OUTPUT));
  7169. if (err < 0)
  7170. return err;
  7171. } else {
  7172. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7173. "Speaker Playback Switch",
  7174. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7175. HDA_OUTPUT));
  7176. if (err < 0)
  7177. return err;
  7178. }
  7179. }
  7180. nid = cfg->hp_pins[0];
  7181. if (nid) {
  7182. /* spec->multiout.hp_nid = 2; */
  7183. if (nid == 0x16) {
  7184. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7185. "Headphone Playback Volume",
  7186. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  7187. HDA_OUTPUT));
  7188. if (err < 0)
  7189. return err;
  7190. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7191. "Headphone Playback Switch",
  7192. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  7193. HDA_OUTPUT));
  7194. if (err < 0)
  7195. return err;
  7196. } else {
  7197. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7198. "Headphone Playback Switch",
  7199. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  7200. HDA_OUTPUT));
  7201. if (err < 0)
  7202. return err;
  7203. }
  7204. }
  7205. return 0;
  7206. }
  7207. /* identical with ALC880 */
  7208. #define alc262_auto_create_analog_input_ctls \
  7209. alc880_auto_create_analog_input_ctls
  7210. /*
  7211. * generic initialization of ADC, input mixers and output mixers
  7212. */
  7213. static struct hda_verb alc262_volume_init_verbs[] = {
  7214. /*
  7215. * Unmute ADC0-2 and set the default input to mic-in
  7216. */
  7217. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7218. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7219. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7220. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7221. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7222. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7223. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7224. * mixer widget
  7225. * Note: PASD motherboards uses the Line In 2 as the input for
  7226. * front panel mic (mic 2)
  7227. */
  7228. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7229. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7230. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7231. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7232. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7233. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7234. /*
  7235. * Set up output mixers (0x0c - 0x0f)
  7236. */
  7237. /* set vol=0 to output mixers */
  7238. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7239. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7240. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7241. /* set up input amps for analog loopback */
  7242. /* Amp Indices: DAC = 0, mixer = 1 */
  7243. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7244. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7245. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7246. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7247. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7248. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7249. /* FIXME: use matrix-type input source selection */
  7250. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7251. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7252. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7253. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7254. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7255. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7256. /* Input mixer2 */
  7257. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7258. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7259. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7260. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7261. /* Input mixer3 */
  7262. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7263. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  7264. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  7265. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  7266. { }
  7267. };
  7268. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  7269. /*
  7270. * Unmute ADC0-2 and set the default input to mic-in
  7271. */
  7272. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7273. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7274. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7275. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7276. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7277. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7278. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7279. * mixer widget
  7280. * Note: PASD motherboards uses the Line In 2 as the input for
  7281. * front panel mic (mic 2)
  7282. */
  7283. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7284. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7285. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7286. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7287. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7288. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7289. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7290. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7291. /*
  7292. * Set up output mixers (0x0c - 0x0e)
  7293. */
  7294. /* set vol=0 to output mixers */
  7295. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7296. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7297. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7298. /* set up input amps for analog loopback */
  7299. /* Amp Indices: DAC = 0, mixer = 1 */
  7300. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7301. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7302. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7303. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7304. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7305. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7306. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7307. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7308. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  7309. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7310. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7311. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7312. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  7313. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7314. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7315. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7316. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7317. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7318. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7319. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7320. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7321. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7322. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7323. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7324. /* FIXME: use matrix-type input source selection */
  7325. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7326. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7327. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7328. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7329. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7330. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7331. /* Input mixer2 */
  7332. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7333. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7334. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7335. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7336. /* Input mixer3 */
  7337. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7338. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7339. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7340. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7341. { }
  7342. };
  7343. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7344. /*
  7345. * Unmute ADC0-2 and set the default input to mic-in
  7346. */
  7347. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7348. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7349. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7350. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7351. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7352. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7353. /* Mute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7354. * mixer widget
  7355. * Note: PASD motherboards uses the Line In 2 as the input for front
  7356. * panel mic (mic 2)
  7357. */
  7358. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7359. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  7360. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  7361. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  7362. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  7363. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  7364. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  7365. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)},
  7366. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)},
  7367. /*
  7368. * Set up output mixers (0x0c - 0x0e)
  7369. */
  7370. /* set vol=0 to output mixers */
  7371. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7372. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7373. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7374. /* set up input amps for analog loopback */
  7375. /* Amp Indices: DAC = 0, mixer = 1 */
  7376. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7377. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7378. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7379. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7380. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7381. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7382. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7383. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7384. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7385. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7386. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7387. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7388. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7389. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7390. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7391. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7392. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7393. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7394. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7395. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7396. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7397. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7398. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7399. /* FIXME: use matrix-type input source selection */
  7400. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7401. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7402. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7403. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7404. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7405. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7406. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7407. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7408. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7409. /* Input mixer2 */
  7410. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7411. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7412. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7413. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7414. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7415. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7416. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7417. /* Input mixer3 */
  7418. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7419. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7420. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7421. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7422. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7423. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7424. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7425. { }
  7426. };
  7427. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7428. #define alc262_loopbacks alc880_loopbacks
  7429. #endif
  7430. /* pcm configuration: identiacal with ALC880 */
  7431. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7432. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7433. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7434. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7435. /*
  7436. * BIOS auto configuration
  7437. */
  7438. static int alc262_parse_auto_config(struct hda_codec *codec)
  7439. {
  7440. struct alc_spec *spec = codec->spec;
  7441. int err;
  7442. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7443. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7444. alc262_ignore);
  7445. if (err < 0)
  7446. return err;
  7447. if (!spec->autocfg.line_outs)
  7448. return 0; /* can't find valid BIOS pin config */
  7449. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7450. if (err < 0)
  7451. return err;
  7452. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7453. if (err < 0)
  7454. return err;
  7455. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7456. if (spec->autocfg.dig_out_pin)
  7457. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7458. if (spec->autocfg.dig_in_pin)
  7459. spec->dig_in_nid = ALC262_DIGIN_NID;
  7460. if (spec->kctl_alloc)
  7461. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7462. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7463. spec->num_mux_defs = 1;
  7464. spec->input_mux = &spec->private_imux;
  7465. err = alc_auto_add_mic_boost(codec);
  7466. if (err < 0)
  7467. return err;
  7468. return 1;
  7469. }
  7470. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7471. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7472. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7473. /* init callback for auto-configuration model -- overriding the default init */
  7474. static void alc262_auto_init(struct hda_codec *codec)
  7475. {
  7476. alc262_auto_init_multi_out(codec);
  7477. alc262_auto_init_hp_out(codec);
  7478. alc262_auto_init_analog_input(codec);
  7479. }
  7480. /*
  7481. * configuration and preset
  7482. */
  7483. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7484. [ALC262_BASIC] = "basic",
  7485. [ALC262_HIPPO] = "hippo",
  7486. [ALC262_HIPPO_1] = "hippo_1",
  7487. [ALC262_FUJITSU] = "fujitsu",
  7488. [ALC262_HP_BPC] = "hp-bpc",
  7489. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7490. [ALC262_BENQ_ED8] = "benq",
  7491. [ALC262_BENQ_T31] = "benq-t31",
  7492. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7493. [ALC262_AUTO] = "auto",
  7494. };
  7495. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7496. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7497. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7498. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7499. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7500. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7501. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7502. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7503. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7504. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7505. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7506. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7507. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7508. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7509. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7510. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7511. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7512. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7513. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7514. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7515. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7516. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7517. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7518. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7519. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7520. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7521. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7522. {}
  7523. };
  7524. static struct alc_config_preset alc262_presets[] = {
  7525. [ALC262_BASIC] = {
  7526. .mixers = { alc262_base_mixer },
  7527. .init_verbs = { alc262_init_verbs },
  7528. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7529. .dac_nids = alc262_dac_nids,
  7530. .hp_nid = 0x03,
  7531. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7532. .channel_mode = alc262_modes,
  7533. .input_mux = &alc262_capture_source,
  7534. },
  7535. [ALC262_HIPPO] = {
  7536. .mixers = { alc262_base_mixer },
  7537. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7538. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7539. .dac_nids = alc262_dac_nids,
  7540. .hp_nid = 0x03,
  7541. .dig_out_nid = ALC262_DIGOUT_NID,
  7542. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7543. .channel_mode = alc262_modes,
  7544. .input_mux = &alc262_capture_source,
  7545. .unsol_event = alc262_hippo_unsol_event,
  7546. .init_hook = alc262_hippo_automute,
  7547. },
  7548. [ALC262_HIPPO_1] = {
  7549. .mixers = { alc262_hippo1_mixer },
  7550. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7551. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7552. .dac_nids = alc262_dac_nids,
  7553. .hp_nid = 0x02,
  7554. .dig_out_nid = ALC262_DIGOUT_NID,
  7555. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7556. .channel_mode = alc262_modes,
  7557. .input_mux = &alc262_capture_source,
  7558. .unsol_event = alc262_hippo1_unsol_event,
  7559. .init_hook = alc262_hippo1_automute,
  7560. },
  7561. [ALC262_FUJITSU] = {
  7562. .mixers = { alc262_fujitsu_mixer },
  7563. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7564. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7565. .dac_nids = alc262_dac_nids,
  7566. .hp_nid = 0x03,
  7567. .dig_out_nid = ALC262_DIGOUT_NID,
  7568. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7569. .channel_mode = alc262_modes,
  7570. .input_mux = &alc262_fujitsu_capture_source,
  7571. .unsol_event = alc262_fujitsu_unsol_event,
  7572. },
  7573. [ALC262_HP_BPC] = {
  7574. .mixers = { alc262_HP_BPC_mixer },
  7575. .init_verbs = { alc262_HP_BPC_init_verbs },
  7576. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7577. .dac_nids = alc262_dac_nids,
  7578. .hp_nid = 0x03,
  7579. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7580. .channel_mode = alc262_modes,
  7581. .input_mux = &alc262_HP_capture_source,
  7582. },
  7583. [ALC262_HP_BPC_D7000_WF] = {
  7584. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7585. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7586. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7587. .dac_nids = alc262_dac_nids,
  7588. .hp_nid = 0x03,
  7589. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7590. .channel_mode = alc262_modes,
  7591. .input_mux = &alc262_HP_D7000_capture_source,
  7592. },
  7593. [ALC262_HP_BPC_D7000_WL] = {
  7594. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7595. alc262_HP_BPC_WildWest_option_mixer },
  7596. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7597. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7598. .dac_nids = alc262_dac_nids,
  7599. .hp_nid = 0x03,
  7600. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7601. .channel_mode = alc262_modes,
  7602. .input_mux = &alc262_HP_D7000_capture_source,
  7603. },
  7604. [ALC262_BENQ_ED8] = {
  7605. .mixers = { alc262_base_mixer },
  7606. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7607. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7608. .dac_nids = alc262_dac_nids,
  7609. .hp_nid = 0x03,
  7610. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7611. .channel_mode = alc262_modes,
  7612. .input_mux = &alc262_capture_source,
  7613. },
  7614. [ALC262_SONY_ASSAMD] = {
  7615. .mixers = { alc262_sony_mixer },
  7616. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7617. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7618. .dac_nids = alc262_dac_nids,
  7619. .hp_nid = 0x02,
  7620. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7621. .channel_mode = alc262_modes,
  7622. .input_mux = &alc262_capture_source,
  7623. .unsol_event = alc262_hippo_unsol_event,
  7624. .init_hook = alc262_hippo_automute,
  7625. },
  7626. [ALC262_BENQ_T31] = {
  7627. .mixers = { alc262_benq_t31_mixer },
  7628. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7629. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7630. .dac_nids = alc262_dac_nids,
  7631. .hp_nid = 0x03,
  7632. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7633. .channel_mode = alc262_modes,
  7634. .input_mux = &alc262_capture_source,
  7635. .unsol_event = alc262_hippo_unsol_event,
  7636. .init_hook = alc262_hippo_automute,
  7637. },
  7638. };
  7639. static int patch_alc262(struct hda_codec *codec)
  7640. {
  7641. struct alc_spec *spec;
  7642. int board_config;
  7643. int err;
  7644. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7645. if (spec == NULL)
  7646. return -ENOMEM;
  7647. codec->spec = spec;
  7648. #if 0
  7649. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7650. * under-run
  7651. */
  7652. {
  7653. int tmp;
  7654. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7655. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7656. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7657. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7658. }
  7659. #endif
  7660. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7661. alc262_models,
  7662. alc262_cfg_tbl);
  7663. if (board_config < 0) {
  7664. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7665. "trying auto-probe from BIOS...\n");
  7666. board_config = ALC262_AUTO;
  7667. }
  7668. if (board_config == ALC262_AUTO) {
  7669. /* automatic parse from the BIOS config */
  7670. err = alc262_parse_auto_config(codec);
  7671. if (err < 0) {
  7672. alc_free(codec);
  7673. return err;
  7674. } else if (!err) {
  7675. printk(KERN_INFO
  7676. "hda_codec: Cannot set up configuration "
  7677. "from BIOS. Using base mode...\n");
  7678. board_config = ALC262_BASIC;
  7679. }
  7680. }
  7681. if (board_config != ALC262_AUTO)
  7682. setup_preset(spec, &alc262_presets[board_config]);
  7683. spec->stream_name_analog = "ALC262 Analog";
  7684. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7685. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7686. spec->stream_name_digital = "ALC262 Digital";
  7687. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7688. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7689. if (!spec->adc_nids && spec->input_mux) {
  7690. /* check whether NID 0x07 is valid */
  7691. unsigned int wcap = get_wcaps(codec, 0x07);
  7692. /* get type */
  7693. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7694. if (wcap != AC_WID_AUD_IN) {
  7695. spec->adc_nids = alc262_adc_nids_alt;
  7696. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7697. spec->mixers[spec->num_mixers] =
  7698. alc262_capture_alt_mixer;
  7699. spec->num_mixers++;
  7700. } else {
  7701. spec->adc_nids = alc262_adc_nids;
  7702. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7703. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7704. spec->num_mixers++;
  7705. }
  7706. }
  7707. codec->patch_ops = alc_patch_ops;
  7708. if (board_config == ALC262_AUTO)
  7709. spec->init_hook = alc262_auto_init;
  7710. #ifdef CONFIG_SND_HDA_POWER_SAVE
  7711. if (!spec->loopback.amplist)
  7712. spec->loopback.amplist = alc262_loopbacks;
  7713. #endif
  7714. return 0;
  7715. }
  7716. /*
  7717. * ALC268 channel source setting (2 channel)
  7718. */
  7719. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7720. #define alc268_modes alc260_modes
  7721. static hda_nid_t alc268_dac_nids[2] = {
  7722. /* front, hp */
  7723. 0x02, 0x03
  7724. };
  7725. static hda_nid_t alc268_adc_nids[2] = {
  7726. /* ADC0-1 */
  7727. 0x08, 0x07
  7728. };
  7729. static hda_nid_t alc268_adc_nids_alt[1] = {
  7730. /* ADC0 */
  7731. 0x08
  7732. };
  7733. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7734. /* output mixer control */
  7735. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7736. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7737. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7738. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7739. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7740. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  7741. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7742. { }
  7743. };
  7744. static struct hda_verb alc268_eapd_verbs[] = {
  7745. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7746. {0x15, AC_VERB_SET_EAPD_BTLENABLE, 2},
  7747. { }
  7748. };
  7749. /* Toshiba specific */
  7750. #define alc268_toshiba_automute alc262_hippo_automute
  7751. static struct hda_verb alc268_toshiba_verbs[] = {
  7752. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7753. { } /* end */
  7754. };
  7755. /* Acer specific */
  7756. /* bind volumes of both NID 0x02 and 0x03 */
  7757. static struct hda_bind_ctls alc268_acer_bind_master_vol = {
  7758. .ops = &snd_hda_bind_vol,
  7759. .values = {
  7760. HDA_COMPOSE_AMP_VAL(0x02, 3, 0, HDA_OUTPUT),
  7761. HDA_COMPOSE_AMP_VAL(0x03, 3, 0, HDA_OUTPUT),
  7762. 0
  7763. },
  7764. };
  7765. /* mute/unmute internal speaker according to the hp jack and mute state */
  7766. static void alc268_acer_automute(struct hda_codec *codec, int force)
  7767. {
  7768. struct alc_spec *spec = codec->spec;
  7769. unsigned int mute;
  7770. if (force || !spec->sense_updated) {
  7771. unsigned int present;
  7772. present = snd_hda_codec_read(codec, 0x14, 0,
  7773. AC_VERB_GET_PIN_SENSE, 0);
  7774. spec->jack_present = (present & 0x80000000) != 0;
  7775. spec->sense_updated = 1;
  7776. }
  7777. if (spec->jack_present)
  7778. mute = HDA_AMP_MUTE; /* mute internal speaker */
  7779. else /* unmute internal speaker if necessary */
  7780. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  7781. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  7782. HDA_AMP_MUTE, mute);
  7783. }
  7784. /* bind hp and internal speaker mute (with plug check) */
  7785. static int alc268_acer_master_sw_put(struct snd_kcontrol *kcontrol,
  7786. struct snd_ctl_elem_value *ucontrol)
  7787. {
  7788. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7789. long *valp = ucontrol->value.integer.value;
  7790. int change;
  7791. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  7792. HDA_AMP_MUTE,
  7793. valp[0] ? 0 : HDA_AMP_MUTE);
  7794. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  7795. HDA_AMP_MUTE,
  7796. valp[1] ? 0 : HDA_AMP_MUTE);
  7797. if (change)
  7798. alc268_acer_automute(codec, 0);
  7799. return change;
  7800. }
  7801. static struct snd_kcontrol_new alc268_acer_mixer[] = {
  7802. /* output mixer control */
  7803. HDA_BIND_VOL("Master Playback Volume", &alc268_acer_bind_master_vol),
  7804. {
  7805. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7806. .name = "Master Playback Switch",
  7807. .info = snd_hda_mixer_amp_switch_info,
  7808. .get = snd_hda_mixer_amp_switch_get,
  7809. .put = alc268_acer_master_sw_put,
  7810. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  7811. },
  7812. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  7813. HDA_CODEC_VOLUME("Internal Mic Boost", 0x19, 0, HDA_INPUT),
  7814. HDA_CODEC_VOLUME("Line In Boost", 0x1a, 0, HDA_INPUT),
  7815. { }
  7816. };
  7817. static struct hda_verb alc268_acer_verbs[] = {
  7818. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  7819. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  7820. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  7821. { }
  7822. };
  7823. /* unsolicited event for HP jack sensing */
  7824. static void alc268_toshiba_unsol_event(struct hda_codec *codec,
  7825. unsigned int res)
  7826. {
  7827. if ((res >> 26) != ALC880_HP_EVENT)
  7828. return;
  7829. alc268_toshiba_automute(codec);
  7830. }
  7831. static void alc268_acer_unsol_event(struct hda_codec *codec,
  7832. unsigned int res)
  7833. {
  7834. if ((res >> 26) != ALC880_HP_EVENT)
  7835. return;
  7836. alc268_acer_automute(codec, 1);
  7837. }
  7838. static void alc268_acer_init_hook(struct hda_codec *codec)
  7839. {
  7840. alc268_acer_automute(codec, 1);
  7841. }
  7842. /*
  7843. * generic initialization of ADC, input mixers and output mixers
  7844. */
  7845. static struct hda_verb alc268_base_init_verbs[] = {
  7846. /* Unmute DAC0-1 and set vol = 0 */
  7847. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7848. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7849. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7850. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7851. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7852. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7853. /*
  7854. * Set up output mixers (0x0c - 0x0e)
  7855. */
  7856. /* set vol=0 to output mixers */
  7857. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7858. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7859. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7860. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7861. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7862. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7863. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7864. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7865. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7866. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7867. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7868. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7869. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7870. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7871. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7872. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7873. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7874. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7875. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7876. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7877. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7878. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7879. /* FIXME: use matrix-type input source selection */
  7880. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7881. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7882. /* Input mixer2 */
  7883. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7884. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7885. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7886. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7887. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7888. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7889. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7890. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7891. { }
  7892. };
  7893. /*
  7894. * generic initialization of ADC, input mixers and output mixers
  7895. */
  7896. static struct hda_verb alc268_volume_init_verbs[] = {
  7897. /* set output DAC */
  7898. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7899. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7900. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7901. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7902. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7903. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7904. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7905. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7906. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7907. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7908. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7909. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7910. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7911. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7912. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7913. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7914. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7915. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7916. /* set PCBEEP vol = 0 */
  7917. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7918. { }
  7919. };
  7920. #define alc268_mux_enum_info alc_mux_enum_info
  7921. #define alc268_mux_enum_get alc_mux_enum_get
  7922. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7923. struct snd_ctl_elem_value *ucontrol)
  7924. {
  7925. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7926. struct alc_spec *spec = codec->spec;
  7927. const struct hda_input_mux *imux = spec->input_mux;
  7928. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7929. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7930. hda_nid_t nid = capture_mixers[adc_idx];
  7931. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7932. unsigned int i, idx;
  7933. idx = ucontrol->value.enumerated.item[0];
  7934. if (idx >= imux->num_items)
  7935. idx = imux->num_items - 1;
  7936. if (*cur_val == idx)
  7937. return 0;
  7938. for (i = 0; i < imux->num_items; i++) {
  7939. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  7940. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  7941. imux->items[i].index,
  7942. HDA_AMP_MUTE, v);
  7943. snd_hda_codec_write_cache(codec, nid, 0,
  7944. AC_VERB_SET_CONNECT_SEL,
  7945. idx );
  7946. }
  7947. *cur_val = idx;
  7948. return 1;
  7949. }
  7950. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7951. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7952. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7953. {
  7954. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7955. /* The multiple "Capture Source" controls confuse alsamixer
  7956. * So call somewhat different..
  7957. * FIXME: the controls appear in the "playback" view!
  7958. */
  7959. /* .name = "Capture Source", */
  7960. .name = "Input Source",
  7961. .count = 1,
  7962. .info = alc268_mux_enum_info,
  7963. .get = alc268_mux_enum_get,
  7964. .put = alc268_mux_enum_put,
  7965. },
  7966. { } /* end */
  7967. };
  7968. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7969. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7970. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7971. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7972. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7973. {
  7974. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7975. /* The multiple "Capture Source" controls confuse alsamixer
  7976. * So call somewhat different..
  7977. * FIXME: the controls appear in the "playback" view!
  7978. */
  7979. /* .name = "Capture Source", */
  7980. .name = "Input Source",
  7981. .count = 2,
  7982. .info = alc268_mux_enum_info,
  7983. .get = alc268_mux_enum_get,
  7984. .put = alc268_mux_enum_put,
  7985. },
  7986. { } /* end */
  7987. };
  7988. static struct hda_input_mux alc268_capture_source = {
  7989. .num_items = 4,
  7990. .items = {
  7991. { "Mic", 0x0 },
  7992. { "Front Mic", 0x1 },
  7993. { "Line", 0x2 },
  7994. { "CD", 0x3 },
  7995. },
  7996. };
  7997. /* create input playback/capture controls for the given pin */
  7998. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7999. const char *ctlname, int idx)
  8000. {
  8001. char name[32];
  8002. int err;
  8003. sprintf(name, "%s Playback Volume", ctlname);
  8004. if (nid == 0x14) {
  8005. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8006. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  8007. HDA_OUTPUT));
  8008. if (err < 0)
  8009. return err;
  8010. } else if (nid == 0x15) {
  8011. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  8012. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  8013. HDA_OUTPUT));
  8014. if (err < 0)
  8015. return err;
  8016. } else
  8017. return -1;
  8018. sprintf(name, "%s Playback Switch", ctlname);
  8019. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  8020. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  8021. if (err < 0)
  8022. return err;
  8023. return 0;
  8024. }
  8025. /* add playback controls from the parsed DAC table */
  8026. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  8027. const struct auto_pin_cfg *cfg)
  8028. {
  8029. hda_nid_t nid;
  8030. int err;
  8031. spec->multiout.num_dacs = 2; /* only use one dac */
  8032. spec->multiout.dac_nids = spec->private_dac_nids;
  8033. spec->multiout.dac_nids[0] = 2;
  8034. spec->multiout.dac_nids[1] = 3;
  8035. nid = cfg->line_out_pins[0];
  8036. if (nid)
  8037. alc268_new_analog_output(spec, nid, "Front", 0);
  8038. nid = cfg->speaker_pins[0];
  8039. if (nid == 0x1d) {
  8040. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  8041. "Speaker Playback Volume",
  8042. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  8043. if (err < 0)
  8044. return err;
  8045. }
  8046. nid = cfg->hp_pins[0];
  8047. if (nid)
  8048. alc268_new_analog_output(spec, nid, "Headphone", 0);
  8049. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  8050. if (nid == 0x16) {
  8051. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8052. "Mono Playback Switch",
  8053. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  8054. if (err < 0)
  8055. return err;
  8056. }
  8057. return 0;
  8058. }
  8059. /* create playback/capture controls for input pins */
  8060. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  8061. const struct auto_pin_cfg *cfg)
  8062. {
  8063. struct hda_input_mux *imux = &spec->private_imux;
  8064. int i, idx1;
  8065. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8066. switch(cfg->input_pins[i]) {
  8067. case 0x18:
  8068. idx1 = 0; /* Mic 1 */
  8069. break;
  8070. case 0x19:
  8071. idx1 = 1; /* Mic 2 */
  8072. break;
  8073. case 0x1a:
  8074. idx1 = 2; /* Line In */
  8075. break;
  8076. case 0x1c:
  8077. idx1 = 3; /* CD */
  8078. break;
  8079. default:
  8080. continue;
  8081. }
  8082. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8083. imux->items[imux->num_items].index = idx1;
  8084. imux->num_items++;
  8085. }
  8086. return 0;
  8087. }
  8088. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  8089. {
  8090. struct alc_spec *spec = codec->spec;
  8091. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  8092. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  8093. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  8094. unsigned int dac_vol1, dac_vol2;
  8095. if (speaker_nid) {
  8096. snd_hda_codec_write(codec, speaker_nid, 0,
  8097. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  8098. snd_hda_codec_write(codec, 0x0f, 0,
  8099. AC_VERB_SET_AMP_GAIN_MUTE,
  8100. AMP_IN_UNMUTE(1));
  8101. snd_hda_codec_write(codec, 0x10, 0,
  8102. AC_VERB_SET_AMP_GAIN_MUTE,
  8103. AMP_IN_UNMUTE(1));
  8104. } else {
  8105. snd_hda_codec_write(codec, 0x0f, 0,
  8106. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8107. snd_hda_codec_write(codec, 0x10, 0,
  8108. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  8109. }
  8110. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  8111. if (line_nid == 0x14)
  8112. dac_vol2 = AMP_OUT_ZERO;
  8113. else if (line_nid == 0x15)
  8114. dac_vol1 = AMP_OUT_ZERO;
  8115. if (hp_nid == 0x14)
  8116. dac_vol2 = AMP_OUT_ZERO;
  8117. else if (hp_nid == 0x15)
  8118. dac_vol1 = AMP_OUT_ZERO;
  8119. if (line_nid != 0x16 || hp_nid != 0x16 ||
  8120. spec->autocfg.line_out_pins[1] != 0x16 ||
  8121. spec->autocfg.line_out_pins[2] != 0x16)
  8122. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  8123. snd_hda_codec_write(codec, 0x02, 0,
  8124. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  8125. snd_hda_codec_write(codec, 0x03, 0,
  8126. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  8127. }
  8128. /* pcm configuration: identiacal with ALC880 */
  8129. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  8130. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  8131. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  8132. /*
  8133. * BIOS auto configuration
  8134. */
  8135. static int alc268_parse_auto_config(struct hda_codec *codec)
  8136. {
  8137. struct alc_spec *spec = codec->spec;
  8138. int err;
  8139. static hda_nid_t alc268_ignore[] = { 0 };
  8140. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8141. alc268_ignore);
  8142. if (err < 0)
  8143. return err;
  8144. if (!spec->autocfg.line_outs)
  8145. return 0; /* can't find valid BIOS pin config */
  8146. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8147. if (err < 0)
  8148. return err;
  8149. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8150. if (err < 0)
  8151. return err;
  8152. spec->multiout.max_channels = 2;
  8153. /* digital only support output */
  8154. if (spec->autocfg.dig_out_pin)
  8155. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  8156. if (spec->kctl_alloc)
  8157. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8158. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  8159. spec->num_mux_defs = 1;
  8160. spec->input_mux = &spec->private_imux;
  8161. err = alc_auto_add_mic_boost(codec);
  8162. if (err < 0)
  8163. return err;
  8164. return 1;
  8165. }
  8166. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  8167. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  8168. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  8169. /* init callback for auto-configuration model -- overriding the default init */
  8170. static void alc268_auto_init(struct hda_codec *codec)
  8171. {
  8172. alc268_auto_init_multi_out(codec);
  8173. alc268_auto_init_hp_out(codec);
  8174. alc268_auto_init_mono_speaker_out(codec);
  8175. alc268_auto_init_analog_input(codec);
  8176. }
  8177. /*
  8178. * configuration and preset
  8179. */
  8180. static const char *alc268_models[ALC268_MODEL_LAST] = {
  8181. [ALC268_3ST] = "3stack",
  8182. [ALC268_TOSHIBA] = "toshiba",
  8183. [ALC268_ACER] = "acer",
  8184. [ALC268_AUTO] = "auto",
  8185. };
  8186. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  8187. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  8188. SND_PCI_QUIRK(0x1179, 0xff10, "TOSHIBA A205", ALC268_TOSHIBA),
  8189. SND_PCI_QUIRK(0x103c, 0x30cc, "TOSHIBA", ALC268_TOSHIBA),
  8190. SND_PCI_QUIRK(0x1025, 0x0126, "Acer", ALC268_ACER),
  8191. SND_PCI_QUIRK(0x1025, 0x0130, "Acer Extensa 5210", ALC268_ACER),
  8192. {}
  8193. };
  8194. static struct alc_config_preset alc268_presets[] = {
  8195. [ALC268_3ST] = {
  8196. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8197. .init_verbs = { alc268_base_init_verbs },
  8198. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8199. .dac_nids = alc268_dac_nids,
  8200. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8201. .adc_nids = alc268_adc_nids_alt,
  8202. .hp_nid = 0x03,
  8203. .dig_out_nid = ALC268_DIGOUT_NID,
  8204. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8205. .channel_mode = alc268_modes,
  8206. .input_mux = &alc268_capture_source,
  8207. },
  8208. [ALC268_TOSHIBA] = {
  8209. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  8210. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8211. alc268_toshiba_verbs },
  8212. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8213. .dac_nids = alc268_dac_nids,
  8214. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8215. .adc_nids = alc268_adc_nids_alt,
  8216. .hp_nid = 0x03,
  8217. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8218. .channel_mode = alc268_modes,
  8219. .input_mux = &alc268_capture_source,
  8220. .input_mux = &alc268_capture_source,
  8221. .unsol_event = alc268_toshiba_unsol_event,
  8222. .init_hook = alc268_toshiba_automute,
  8223. },
  8224. [ALC268_ACER] = {
  8225. .mixers = { alc268_acer_mixer, alc268_capture_alt_mixer },
  8226. .init_verbs = { alc268_base_init_verbs, alc268_eapd_verbs,
  8227. alc268_acer_verbs },
  8228. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  8229. .dac_nids = alc268_dac_nids,
  8230. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  8231. .adc_nids = alc268_adc_nids_alt,
  8232. .hp_nid = 0x02,
  8233. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  8234. .channel_mode = alc268_modes,
  8235. .input_mux = &alc268_capture_source,
  8236. .unsol_event = alc268_acer_unsol_event,
  8237. .init_hook = alc268_acer_init_hook,
  8238. },
  8239. };
  8240. static int patch_alc268(struct hda_codec *codec)
  8241. {
  8242. struct alc_spec *spec;
  8243. int board_config;
  8244. int err;
  8245. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  8246. if (spec == NULL)
  8247. return -ENOMEM;
  8248. codec->spec = spec;
  8249. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  8250. alc268_models,
  8251. alc268_cfg_tbl);
  8252. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  8253. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  8254. "trying auto-probe from BIOS...\n");
  8255. board_config = ALC268_AUTO;
  8256. }
  8257. if (board_config == ALC268_AUTO) {
  8258. /* automatic parse from the BIOS config */
  8259. err = alc268_parse_auto_config(codec);
  8260. if (err < 0) {
  8261. alc_free(codec);
  8262. return err;
  8263. } else if (!err) {
  8264. printk(KERN_INFO
  8265. "hda_codec: Cannot set up configuration "
  8266. "from BIOS. Using base mode...\n");
  8267. board_config = ALC268_3ST;
  8268. }
  8269. }
  8270. if (board_config != ALC268_AUTO)
  8271. setup_preset(spec, &alc268_presets[board_config]);
  8272. spec->stream_name_analog = "ALC268 Analog";
  8273. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  8274. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  8275. spec->stream_name_digital = "ALC268 Digital";
  8276. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  8277. if (board_config == ALC268_AUTO) {
  8278. if (!spec->adc_nids && spec->input_mux) {
  8279. /* check whether NID 0x07 is valid */
  8280. unsigned int wcap = get_wcaps(codec, 0x07);
  8281. /* get type */
  8282. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  8283. if (wcap != AC_WID_AUD_IN) {
  8284. spec->adc_nids = alc268_adc_nids_alt;
  8285. spec->num_adc_nids =
  8286. ARRAY_SIZE(alc268_adc_nids_alt);
  8287. spec->mixers[spec->num_mixers] =
  8288. alc268_capture_alt_mixer;
  8289. spec->num_mixers++;
  8290. } else {
  8291. spec->adc_nids = alc268_adc_nids;
  8292. spec->num_adc_nids =
  8293. ARRAY_SIZE(alc268_adc_nids);
  8294. spec->mixers[spec->num_mixers] =
  8295. alc268_capture_mixer;
  8296. spec->num_mixers++;
  8297. }
  8298. }
  8299. }
  8300. codec->patch_ops = alc_patch_ops;
  8301. if (board_config == ALC268_AUTO)
  8302. spec->init_hook = alc268_auto_init;
  8303. return 0;
  8304. }
  8305. /*
  8306. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  8307. */
  8308. /*
  8309. * set the path ways for 2 channel output
  8310. * need to set the codec line out and mic 1 pin widgets to inputs
  8311. */
  8312. static struct hda_verb alc861_threestack_ch2_init[] = {
  8313. /* set pin widget 1Ah (line in) for input */
  8314. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8315. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8316. * the vref
  8317. */
  8318. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8319. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8320. #if 0
  8321. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8322. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8323. #endif
  8324. { } /* end */
  8325. };
  8326. /*
  8327. * 6ch mode
  8328. * need to set the codec line out and mic 1 pin widgets to outputs
  8329. */
  8330. static struct hda_verb alc861_threestack_ch6_init[] = {
  8331. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8332. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8333. /* set pin widget 18h (mic1) for output (CLFE)*/
  8334. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8335. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8336. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8337. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8338. #if 0
  8339. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8340. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8341. #endif
  8342. { } /* end */
  8343. };
  8344. static struct hda_channel_mode alc861_threestack_modes[2] = {
  8345. { 2, alc861_threestack_ch2_init },
  8346. { 6, alc861_threestack_ch6_init },
  8347. };
  8348. /* Set mic1 as input and unmute the mixer */
  8349. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  8350. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8351. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8352. { } /* end */
  8353. };
  8354. /* Set mic1 as output and mute mixer */
  8355. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  8356. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8357. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8358. { } /* end */
  8359. };
  8360. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  8361. { 2, alc861_uniwill_m31_ch2_init },
  8362. { 4, alc861_uniwill_m31_ch4_init },
  8363. };
  8364. /* Set mic1 and line-in as input and unmute the mixer */
  8365. static struct hda_verb alc861_asus_ch2_init[] = {
  8366. /* set pin widget 1Ah (line in) for input */
  8367. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8368. /* set pin widget 18h (mic1/2) for input, for mic also enable
  8369. * the vref
  8370. */
  8371. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8372. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  8373. #if 0
  8374. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  8375. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  8376. #endif
  8377. { } /* end */
  8378. };
  8379. /* Set mic1 nad line-in as output and mute mixer */
  8380. static struct hda_verb alc861_asus_ch6_init[] = {
  8381. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  8382. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8383. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8384. /* set pin widget 18h (mic1) for output (CLFE)*/
  8385. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8386. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  8387. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8388. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8389. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  8390. #if 0
  8391. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  8392. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  8393. #endif
  8394. { } /* end */
  8395. };
  8396. static struct hda_channel_mode alc861_asus_modes[2] = {
  8397. { 2, alc861_asus_ch2_init },
  8398. { 6, alc861_asus_ch6_init },
  8399. };
  8400. /* patch-ALC861 */
  8401. static struct snd_kcontrol_new alc861_base_mixer[] = {
  8402. /* output mixer control */
  8403. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8404. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8405. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8406. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8407. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8408. /*Input mixer control */
  8409. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8410. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8411. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8412. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8413. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8414. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8415. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8416. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8417. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8418. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8419. /* Capture mixer control */
  8420. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8421. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8422. {
  8423. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8424. .name = "Capture Source",
  8425. .count = 1,
  8426. .info = alc_mux_enum_info,
  8427. .get = alc_mux_enum_get,
  8428. .put = alc_mux_enum_put,
  8429. },
  8430. { } /* end */
  8431. };
  8432. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  8433. /* output mixer control */
  8434. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8435. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8436. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8437. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8438. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8439. /* Input mixer control */
  8440. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8441. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8442. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8443. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8444. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8445. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8446. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8447. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8448. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8449. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8450. /* Capture mixer control */
  8451. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8452. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8453. {
  8454. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8455. .name = "Capture Source",
  8456. .count = 1,
  8457. .info = alc_mux_enum_info,
  8458. .get = alc_mux_enum_get,
  8459. .put = alc_mux_enum_put,
  8460. },
  8461. {
  8462. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8463. .name = "Channel Mode",
  8464. .info = alc_ch_mode_info,
  8465. .get = alc_ch_mode_get,
  8466. .put = alc_ch_mode_put,
  8467. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  8468. },
  8469. { } /* end */
  8470. };
  8471. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8472. /* output mixer control */
  8473. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8474. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8475. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8476. /*Capture mixer control */
  8477. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8478. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8479. {
  8480. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8481. .name = "Capture Source",
  8482. .count = 1,
  8483. .info = alc_mux_enum_info,
  8484. .get = alc_mux_enum_get,
  8485. .put = alc_mux_enum_put,
  8486. },
  8487. { } /* end */
  8488. };
  8489. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8490. /* output mixer control */
  8491. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8492. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8493. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8494. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8495. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8496. /* Input mixer control */
  8497. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8498. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8499. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8500. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8501. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8502. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8503. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8504. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8505. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8506. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8507. /* Capture mixer control */
  8508. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8509. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8510. {
  8511. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8512. .name = "Capture Source",
  8513. .count = 1,
  8514. .info = alc_mux_enum_info,
  8515. .get = alc_mux_enum_get,
  8516. .put = alc_mux_enum_put,
  8517. },
  8518. {
  8519. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8520. .name = "Channel Mode",
  8521. .info = alc_ch_mode_info,
  8522. .get = alc_ch_mode_get,
  8523. .put = alc_ch_mode_put,
  8524. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8525. },
  8526. { } /* end */
  8527. };
  8528. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8529. /* output mixer control */
  8530. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8531. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8532. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8533. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8534. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8535. /* Input mixer control */
  8536. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8537. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8538. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8539. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8540. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8541. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8542. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8543. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8544. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8545. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8546. /* Capture mixer control */
  8547. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8548. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8549. {
  8550. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8551. .name = "Capture Source",
  8552. .count = 1,
  8553. .info = alc_mux_enum_info,
  8554. .get = alc_mux_enum_get,
  8555. .put = alc_mux_enum_put,
  8556. },
  8557. {
  8558. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8559. .name = "Channel Mode",
  8560. .info = alc_ch_mode_info,
  8561. .get = alc_ch_mode_get,
  8562. .put = alc_ch_mode_put,
  8563. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8564. },
  8565. { }
  8566. };
  8567. /* additional mixer */
  8568. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8569. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8570. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8571. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8572. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8573. { }
  8574. };
  8575. /*
  8576. * generic initialization of ADC, input mixers and output mixers
  8577. */
  8578. static struct hda_verb alc861_base_init_verbs[] = {
  8579. /*
  8580. * Unmute ADC0 and set the default input to mic-in
  8581. */
  8582. /* port-A for surround (rear panel) */
  8583. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8584. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8585. /* port-B for mic-in (rear panel) with vref */
  8586. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8587. /* port-C for line-in (rear panel) */
  8588. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8589. /* port-D for Front */
  8590. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8591. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8592. /* port-E for HP out (front panel) */
  8593. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8594. /* route front PCM to HP */
  8595. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8596. /* port-F for mic-in (front panel) with vref */
  8597. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8598. /* port-G for CLFE (rear panel) */
  8599. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8600. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8601. /* port-H for side (rear panel) */
  8602. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8603. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8604. /* CD-in */
  8605. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8606. /* route front mic to ADC1*/
  8607. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8608. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8609. /* Unmute DAC0~3 & spdif out*/
  8610. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8611. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8612. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8613. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8614. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8615. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8616. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8617. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8618. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8619. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8620. /* Unmute Stereo Mixer 15 */
  8621. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8622. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8623. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8624. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8625. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8626. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8627. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8628. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8629. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8630. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8631. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8632. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8633. /* hp used DAC 3 (Front) */
  8634. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8635. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8636. { }
  8637. };
  8638. static struct hda_verb alc861_threestack_init_verbs[] = {
  8639. /*
  8640. * Unmute ADC0 and set the default input to mic-in
  8641. */
  8642. /* port-A for surround (rear panel) */
  8643. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8644. /* port-B for mic-in (rear panel) with vref */
  8645. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8646. /* port-C for line-in (rear panel) */
  8647. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8648. /* port-D for Front */
  8649. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8650. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8651. /* port-E for HP out (front panel) */
  8652. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8653. /* route front PCM to HP */
  8654. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8655. /* port-F for mic-in (front panel) with vref */
  8656. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8657. /* port-G for CLFE (rear panel) */
  8658. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8659. /* port-H for side (rear panel) */
  8660. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8661. /* CD-in */
  8662. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8663. /* route front mic to ADC1*/
  8664. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8665. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8666. /* Unmute DAC0~3 & spdif out*/
  8667. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8668. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8669. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8670. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8671. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8672. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8673. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8674. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8675. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8676. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8677. /* Unmute Stereo Mixer 15 */
  8678. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8679. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8680. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8681. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8682. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8683. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8684. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8685. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8686. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8687. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8688. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8689. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8690. /* hp used DAC 3 (Front) */
  8691. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8692. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8693. { }
  8694. };
  8695. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8696. /*
  8697. * Unmute ADC0 and set the default input to mic-in
  8698. */
  8699. /* port-A for surround (rear panel) */
  8700. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8701. /* port-B for mic-in (rear panel) with vref */
  8702. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8703. /* port-C for line-in (rear panel) */
  8704. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8705. /* port-D for Front */
  8706. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8707. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8708. /* port-E for HP out (front panel) */
  8709. /* this has to be set to VREF80 */
  8710. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8711. /* route front PCM to HP */
  8712. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8713. /* port-F for mic-in (front panel) with vref */
  8714. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8715. /* port-G for CLFE (rear panel) */
  8716. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8717. /* port-H for side (rear panel) */
  8718. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8719. /* CD-in */
  8720. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8721. /* route front mic to ADC1*/
  8722. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8723. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8724. /* Unmute DAC0~3 & spdif out*/
  8725. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8726. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8727. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8728. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8729. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8730. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8731. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8732. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8733. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8734. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8735. /* Unmute Stereo Mixer 15 */
  8736. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8737. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8738. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8739. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8740. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8741. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8742. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8743. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8744. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8745. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8746. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8747. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8748. /* hp used DAC 3 (Front) */
  8749. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8750. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8751. { }
  8752. };
  8753. static struct hda_verb alc861_asus_init_verbs[] = {
  8754. /*
  8755. * Unmute ADC0 and set the default input to mic-in
  8756. */
  8757. /* port-A for surround (rear panel)
  8758. * according to codec#0 this is the HP jack
  8759. */
  8760. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8761. /* route front PCM to HP */
  8762. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8763. /* port-B for mic-in (rear panel) with vref */
  8764. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8765. /* port-C for line-in (rear panel) */
  8766. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8767. /* port-D for Front */
  8768. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8769. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8770. /* port-E for HP out (front panel) */
  8771. /* this has to be set to VREF80 */
  8772. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8773. /* route front PCM to HP */
  8774. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8775. /* port-F for mic-in (front panel) with vref */
  8776. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8777. /* port-G for CLFE (rear panel) */
  8778. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8779. /* port-H for side (rear panel) */
  8780. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8781. /* CD-in */
  8782. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8783. /* route front mic to ADC1*/
  8784. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8785. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8786. /* Unmute DAC0~3 & spdif out*/
  8787. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8788. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8789. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8790. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8791. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8792. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8793. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8794. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8795. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8796. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8797. /* Unmute Stereo Mixer 15 */
  8798. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8799. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8800. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8801. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8802. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8803. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8804. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8805. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8806. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8807. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8808. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8809. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8810. /* hp used DAC 3 (Front) */
  8811. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8812. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8813. { }
  8814. };
  8815. /* additional init verbs for ASUS laptops */
  8816. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8817. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8818. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8819. { }
  8820. };
  8821. /*
  8822. * generic initialization of ADC, input mixers and output mixers
  8823. */
  8824. static struct hda_verb alc861_auto_init_verbs[] = {
  8825. /*
  8826. * Unmute ADC0 and set the default input to mic-in
  8827. */
  8828. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8829. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8830. /* Unmute DAC0~3 & spdif out*/
  8831. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8832. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8833. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8834. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8835. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8836. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8837. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8838. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8839. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8840. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8841. /* Unmute Stereo Mixer 15 */
  8842. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8843. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8844. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8845. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8846. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8847. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8848. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8849. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8850. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8851. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8852. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8853. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8854. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8855. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8856. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8857. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8858. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8859. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8860. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8861. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8862. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8863. { }
  8864. };
  8865. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8866. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8867. { }
  8868. };
  8869. /* toggle speaker-output according to the hp-jack state */
  8870. static void alc861_toshiba_automute(struct hda_codec *codec)
  8871. {
  8872. unsigned int present;
  8873. present = snd_hda_codec_read(codec, 0x0f, 0,
  8874. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8875. snd_hda_codec_amp_stereo(codec, 0x16, HDA_INPUT, 0,
  8876. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  8877. snd_hda_codec_amp_stereo(codec, 0x1a, HDA_INPUT, 3,
  8878. HDA_AMP_MUTE, present ? 0 : HDA_AMP_MUTE);
  8879. }
  8880. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8881. unsigned int res)
  8882. {
  8883. if ((res >> 26) == ALC880_HP_EVENT)
  8884. alc861_toshiba_automute(codec);
  8885. }
  8886. /* pcm configuration: identiacal with ALC880 */
  8887. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8888. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8889. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8890. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8891. #define ALC861_DIGOUT_NID 0x07
  8892. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8893. { 8, NULL }
  8894. };
  8895. static hda_nid_t alc861_dac_nids[4] = {
  8896. /* front, surround, clfe, side */
  8897. 0x03, 0x06, 0x05, 0x04
  8898. };
  8899. static hda_nid_t alc660_dac_nids[3] = {
  8900. /* front, clfe, surround */
  8901. 0x03, 0x05, 0x06
  8902. };
  8903. static hda_nid_t alc861_adc_nids[1] = {
  8904. /* ADC0-2 */
  8905. 0x08,
  8906. };
  8907. static struct hda_input_mux alc861_capture_source = {
  8908. .num_items = 5,
  8909. .items = {
  8910. { "Mic", 0x0 },
  8911. { "Front Mic", 0x3 },
  8912. { "Line", 0x1 },
  8913. { "CD", 0x4 },
  8914. { "Mixer", 0x5 },
  8915. },
  8916. };
  8917. /* fill in the dac_nids table from the parsed pin configuration */
  8918. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8919. const struct auto_pin_cfg *cfg)
  8920. {
  8921. int i;
  8922. hda_nid_t nid;
  8923. spec->multiout.dac_nids = spec->private_dac_nids;
  8924. for (i = 0; i < cfg->line_outs; i++) {
  8925. nid = cfg->line_out_pins[i];
  8926. if (nid) {
  8927. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8928. continue;
  8929. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8930. }
  8931. }
  8932. spec->multiout.num_dacs = cfg->line_outs;
  8933. return 0;
  8934. }
  8935. /* add playback controls from the parsed DAC table */
  8936. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8937. const struct auto_pin_cfg *cfg)
  8938. {
  8939. char name[32];
  8940. static const char *chname[4] = {
  8941. "Front", "Surround", NULL /*CLFE*/, "Side"
  8942. };
  8943. hda_nid_t nid;
  8944. int i, idx, err;
  8945. for (i = 0; i < cfg->line_outs; i++) {
  8946. nid = spec->multiout.dac_nids[i];
  8947. if (!nid)
  8948. continue;
  8949. if (nid == 0x05) {
  8950. /* Center/LFE */
  8951. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8952. "Center Playback Switch",
  8953. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8954. HDA_OUTPUT));
  8955. if (err < 0)
  8956. return err;
  8957. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8958. "LFE Playback Switch",
  8959. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8960. HDA_OUTPUT));
  8961. if (err < 0)
  8962. return err;
  8963. } else {
  8964. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8965. idx++)
  8966. if (nid == alc861_dac_nids[idx])
  8967. break;
  8968. sprintf(name, "%s Playback Switch", chname[idx]);
  8969. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8970. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8971. HDA_OUTPUT));
  8972. if (err < 0)
  8973. return err;
  8974. }
  8975. }
  8976. return 0;
  8977. }
  8978. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8979. {
  8980. int err;
  8981. hda_nid_t nid;
  8982. if (!pin)
  8983. return 0;
  8984. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8985. nid = 0x03;
  8986. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8987. "Headphone Playback Switch",
  8988. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8989. if (err < 0)
  8990. return err;
  8991. spec->multiout.hp_nid = nid;
  8992. }
  8993. return 0;
  8994. }
  8995. /* create playback/capture controls for input pins */
  8996. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8997. const struct auto_pin_cfg *cfg)
  8998. {
  8999. struct hda_input_mux *imux = &spec->private_imux;
  9000. int i, err, idx, idx1;
  9001. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9002. switch (cfg->input_pins[i]) {
  9003. case 0x0c:
  9004. idx1 = 1;
  9005. idx = 2; /* Line In */
  9006. break;
  9007. case 0x0f:
  9008. idx1 = 2;
  9009. idx = 2; /* Line In */
  9010. break;
  9011. case 0x0d:
  9012. idx1 = 0;
  9013. idx = 1; /* Mic In */
  9014. break;
  9015. case 0x10:
  9016. idx1 = 3;
  9017. idx = 1; /* Mic In */
  9018. break;
  9019. case 0x11:
  9020. idx1 = 4;
  9021. idx = 0; /* CD */
  9022. break;
  9023. default:
  9024. continue;
  9025. }
  9026. err = new_analog_input(spec, cfg->input_pins[i],
  9027. auto_pin_cfg_labels[i], idx, 0x15);
  9028. if (err < 0)
  9029. return err;
  9030. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  9031. imux->items[imux->num_items].index = idx1;
  9032. imux->num_items++;
  9033. }
  9034. return 0;
  9035. }
  9036. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  9037. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  9038. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  9039. {
  9040. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9041. /* The multiple "Capture Source" controls confuse alsamixer
  9042. * So call somewhat different..
  9043. *FIXME: the controls appear in the "playback" view!
  9044. */
  9045. /* .name = "Capture Source", */
  9046. .name = "Input Source",
  9047. .count = 1,
  9048. .info = alc_mux_enum_info,
  9049. .get = alc_mux_enum_get,
  9050. .put = alc_mux_enum_put,
  9051. },
  9052. { } /* end */
  9053. };
  9054. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  9055. hda_nid_t nid,
  9056. int pin_type, int dac_idx)
  9057. {
  9058. /* set as output */
  9059. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  9060. pin_type);
  9061. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9062. AMP_OUT_UNMUTE);
  9063. }
  9064. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  9065. {
  9066. struct alc_spec *spec = codec->spec;
  9067. int i;
  9068. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  9069. for (i = 0; i < spec->autocfg.line_outs; i++) {
  9070. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9071. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9072. if (nid)
  9073. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  9074. spec->multiout.dac_nids[i]);
  9075. }
  9076. }
  9077. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  9078. {
  9079. struct alc_spec *spec = codec->spec;
  9080. hda_nid_t pin;
  9081. pin = spec->autocfg.hp_pins[0];
  9082. if (pin) /* connect to front */
  9083. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  9084. spec->multiout.dac_nids[0]);
  9085. }
  9086. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  9087. {
  9088. struct alc_spec *spec = codec->spec;
  9089. int i;
  9090. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9091. hda_nid_t nid = spec->autocfg.input_pins[i];
  9092. if (nid >= 0x0c && nid <= 0x11) {
  9093. snd_hda_codec_write(codec, nid, 0,
  9094. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9095. i <= AUTO_PIN_FRONT_MIC ?
  9096. PIN_VREF80 : PIN_IN);
  9097. }
  9098. }
  9099. }
  9100. /* parse the BIOS configuration and set up the alc_spec */
  9101. /* return 1 if successful, 0 if the proper config is not found,
  9102. * or a negative error code
  9103. */
  9104. static int alc861_parse_auto_config(struct hda_codec *codec)
  9105. {
  9106. struct alc_spec *spec = codec->spec;
  9107. int err;
  9108. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  9109. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9110. alc861_ignore);
  9111. if (err < 0)
  9112. return err;
  9113. if (!spec->autocfg.line_outs)
  9114. return 0; /* can't find valid BIOS pin config */
  9115. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  9116. if (err < 0)
  9117. return err;
  9118. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9119. if (err < 0)
  9120. return err;
  9121. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  9122. if (err < 0)
  9123. return err;
  9124. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9125. if (err < 0)
  9126. return err;
  9127. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9128. if (spec->autocfg.dig_out_pin)
  9129. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  9130. if (spec->kctl_alloc)
  9131. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9132. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  9133. spec->num_mux_defs = 1;
  9134. spec->input_mux = &spec->private_imux;
  9135. spec->adc_nids = alc861_adc_nids;
  9136. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  9137. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  9138. spec->num_mixers++;
  9139. return 1;
  9140. }
  9141. /* additional initialization for auto-configuration model */
  9142. static void alc861_auto_init(struct hda_codec *codec)
  9143. {
  9144. alc861_auto_init_multi_out(codec);
  9145. alc861_auto_init_hp_out(codec);
  9146. alc861_auto_init_analog_input(codec);
  9147. }
  9148. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9149. static struct hda_amp_list alc861_loopbacks[] = {
  9150. { 0x15, HDA_INPUT, 0 },
  9151. { 0x15, HDA_INPUT, 1 },
  9152. { 0x15, HDA_INPUT, 2 },
  9153. { 0x15, HDA_INPUT, 3 },
  9154. { } /* end */
  9155. };
  9156. #endif
  9157. /*
  9158. * configuration and preset
  9159. */
  9160. static const char *alc861_models[ALC861_MODEL_LAST] = {
  9161. [ALC861_3ST] = "3stack",
  9162. [ALC660_3ST] = "3stack-660",
  9163. [ALC861_3ST_DIG] = "3stack-dig",
  9164. [ALC861_6ST_DIG] = "6stack-dig",
  9165. [ALC861_UNIWILL_M31] = "uniwill-m31",
  9166. [ALC861_TOSHIBA] = "toshiba",
  9167. [ALC861_ASUS] = "asus",
  9168. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  9169. [ALC861_AUTO] = "auto",
  9170. };
  9171. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  9172. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  9173. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9174. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  9175. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  9176. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  9177. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  9178. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  9179. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  9180. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  9181. * Any other models that need this preset?
  9182. */
  9183. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  9184. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  9185. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  9186. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  9187. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  9188. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  9189. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  9190. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  9191. {}
  9192. };
  9193. static struct alc_config_preset alc861_presets[] = {
  9194. [ALC861_3ST] = {
  9195. .mixers = { alc861_3ST_mixer },
  9196. .init_verbs = { alc861_threestack_init_verbs },
  9197. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9198. .dac_nids = alc861_dac_nids,
  9199. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9200. .channel_mode = alc861_threestack_modes,
  9201. .need_dac_fix = 1,
  9202. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9203. .adc_nids = alc861_adc_nids,
  9204. .input_mux = &alc861_capture_source,
  9205. },
  9206. [ALC861_3ST_DIG] = {
  9207. .mixers = { alc861_base_mixer },
  9208. .init_verbs = { alc861_threestack_init_verbs },
  9209. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9210. .dac_nids = alc861_dac_nids,
  9211. .dig_out_nid = ALC861_DIGOUT_NID,
  9212. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9213. .channel_mode = alc861_threestack_modes,
  9214. .need_dac_fix = 1,
  9215. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9216. .adc_nids = alc861_adc_nids,
  9217. .input_mux = &alc861_capture_source,
  9218. },
  9219. [ALC861_6ST_DIG] = {
  9220. .mixers = { alc861_base_mixer },
  9221. .init_verbs = { alc861_base_init_verbs },
  9222. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9223. .dac_nids = alc861_dac_nids,
  9224. .dig_out_nid = ALC861_DIGOUT_NID,
  9225. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  9226. .channel_mode = alc861_8ch_modes,
  9227. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9228. .adc_nids = alc861_adc_nids,
  9229. .input_mux = &alc861_capture_source,
  9230. },
  9231. [ALC660_3ST] = {
  9232. .mixers = { alc861_3ST_mixer },
  9233. .init_verbs = { alc861_threestack_init_verbs },
  9234. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  9235. .dac_nids = alc660_dac_nids,
  9236. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  9237. .channel_mode = alc861_threestack_modes,
  9238. .need_dac_fix = 1,
  9239. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9240. .adc_nids = alc861_adc_nids,
  9241. .input_mux = &alc861_capture_source,
  9242. },
  9243. [ALC861_UNIWILL_M31] = {
  9244. .mixers = { alc861_uniwill_m31_mixer },
  9245. .init_verbs = { alc861_uniwill_m31_init_verbs },
  9246. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9247. .dac_nids = alc861_dac_nids,
  9248. .dig_out_nid = ALC861_DIGOUT_NID,
  9249. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  9250. .channel_mode = alc861_uniwill_m31_modes,
  9251. .need_dac_fix = 1,
  9252. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9253. .adc_nids = alc861_adc_nids,
  9254. .input_mux = &alc861_capture_source,
  9255. },
  9256. [ALC861_TOSHIBA] = {
  9257. .mixers = { alc861_toshiba_mixer },
  9258. .init_verbs = { alc861_base_init_verbs,
  9259. alc861_toshiba_init_verbs },
  9260. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9261. .dac_nids = alc861_dac_nids,
  9262. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9263. .channel_mode = alc883_3ST_2ch_modes,
  9264. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9265. .adc_nids = alc861_adc_nids,
  9266. .input_mux = &alc861_capture_source,
  9267. .unsol_event = alc861_toshiba_unsol_event,
  9268. .init_hook = alc861_toshiba_automute,
  9269. },
  9270. [ALC861_ASUS] = {
  9271. .mixers = { alc861_asus_mixer },
  9272. .init_verbs = { alc861_asus_init_verbs },
  9273. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9274. .dac_nids = alc861_dac_nids,
  9275. .dig_out_nid = ALC861_DIGOUT_NID,
  9276. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  9277. .channel_mode = alc861_asus_modes,
  9278. .need_dac_fix = 1,
  9279. .hp_nid = 0x06,
  9280. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9281. .adc_nids = alc861_adc_nids,
  9282. .input_mux = &alc861_capture_source,
  9283. },
  9284. [ALC861_ASUS_LAPTOP] = {
  9285. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  9286. .init_verbs = { alc861_asus_init_verbs,
  9287. alc861_asus_laptop_init_verbs },
  9288. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  9289. .dac_nids = alc861_dac_nids,
  9290. .dig_out_nid = ALC861_DIGOUT_NID,
  9291. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  9292. .channel_mode = alc883_3ST_2ch_modes,
  9293. .need_dac_fix = 1,
  9294. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  9295. .adc_nids = alc861_adc_nids,
  9296. .input_mux = &alc861_capture_source,
  9297. },
  9298. };
  9299. static int patch_alc861(struct hda_codec *codec)
  9300. {
  9301. struct alc_spec *spec;
  9302. int board_config;
  9303. int err;
  9304. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9305. if (spec == NULL)
  9306. return -ENOMEM;
  9307. codec->spec = spec;
  9308. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  9309. alc861_models,
  9310. alc861_cfg_tbl);
  9311. if (board_config < 0) {
  9312. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  9313. "trying auto-probe from BIOS...\n");
  9314. board_config = ALC861_AUTO;
  9315. }
  9316. if (board_config == ALC861_AUTO) {
  9317. /* automatic parse from the BIOS config */
  9318. err = alc861_parse_auto_config(codec);
  9319. if (err < 0) {
  9320. alc_free(codec);
  9321. return err;
  9322. } else if (!err) {
  9323. printk(KERN_INFO
  9324. "hda_codec: Cannot set up configuration "
  9325. "from BIOS. Using base mode...\n");
  9326. board_config = ALC861_3ST_DIG;
  9327. }
  9328. }
  9329. if (board_config != ALC861_AUTO)
  9330. setup_preset(spec, &alc861_presets[board_config]);
  9331. spec->stream_name_analog = "ALC861 Analog";
  9332. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  9333. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  9334. spec->stream_name_digital = "ALC861 Digital";
  9335. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  9336. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  9337. codec->patch_ops = alc_patch_ops;
  9338. if (board_config == ALC861_AUTO)
  9339. spec->init_hook = alc861_auto_init;
  9340. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9341. if (!spec->loopback.amplist)
  9342. spec->loopback.amplist = alc861_loopbacks;
  9343. #endif
  9344. return 0;
  9345. }
  9346. /*
  9347. * ALC861-VD support
  9348. *
  9349. * Based on ALC882
  9350. *
  9351. * In addition, an independent DAC
  9352. */
  9353. #define ALC861VD_DIGOUT_NID 0x06
  9354. static hda_nid_t alc861vd_dac_nids[4] = {
  9355. /* front, surr, clfe, side surr */
  9356. 0x02, 0x03, 0x04, 0x05
  9357. };
  9358. /* dac_nids for ALC660vd are in a different order - according to
  9359. * Realtek's driver.
  9360. * This should probably tesult in a different mixer for 6stack models
  9361. * of ALC660vd codecs, but for now there is only 3stack mixer
  9362. * - and it is the same as in 861vd.
  9363. * adc_nids in ALC660vd are (is) the same as in 861vd
  9364. */
  9365. static hda_nid_t alc660vd_dac_nids[3] = {
  9366. /* front, rear, clfe, rear_surr */
  9367. 0x02, 0x04, 0x03
  9368. };
  9369. static hda_nid_t alc861vd_adc_nids[1] = {
  9370. /* ADC0 */
  9371. 0x09,
  9372. };
  9373. /* input MUX */
  9374. /* FIXME: should be a matrix-type input source selection */
  9375. static struct hda_input_mux alc861vd_capture_source = {
  9376. .num_items = 4,
  9377. .items = {
  9378. { "Mic", 0x0 },
  9379. { "Front Mic", 0x1 },
  9380. { "Line", 0x2 },
  9381. { "CD", 0x4 },
  9382. },
  9383. };
  9384. static struct hda_input_mux alc861vd_dallas_capture_source = {
  9385. .num_items = 3,
  9386. .items = {
  9387. { "Front Mic", 0x0 },
  9388. { "ATAPI Mic", 0x1 },
  9389. { "Line In", 0x5 },
  9390. },
  9391. };
  9392. static struct hda_input_mux alc861vd_hp_capture_source = {
  9393. .num_items = 2,
  9394. .items = {
  9395. { "Front Mic", 0x0 },
  9396. { "ATAPI Mic", 0x1 },
  9397. },
  9398. };
  9399. #define alc861vd_mux_enum_info alc_mux_enum_info
  9400. #define alc861vd_mux_enum_get alc_mux_enum_get
  9401. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  9402. struct snd_ctl_elem_value *ucontrol)
  9403. {
  9404. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9405. struct alc_spec *spec = codec->spec;
  9406. const struct hda_input_mux *imux = spec->input_mux;
  9407. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9408. static hda_nid_t capture_mixers[1] = { 0x22 };
  9409. hda_nid_t nid = capture_mixers[adc_idx];
  9410. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9411. unsigned int i, idx;
  9412. idx = ucontrol->value.enumerated.item[0];
  9413. if (idx >= imux->num_items)
  9414. idx = imux->num_items - 1;
  9415. if (*cur_val == idx)
  9416. return 0;
  9417. for (i = 0; i < imux->num_items; i++) {
  9418. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  9419. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  9420. imux->items[i].index,
  9421. HDA_AMP_MUTE, v);
  9422. }
  9423. *cur_val = idx;
  9424. return 1;
  9425. }
  9426. /*
  9427. * 2ch mode
  9428. */
  9429. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  9430. { 2, NULL }
  9431. };
  9432. /*
  9433. * 6ch mode
  9434. */
  9435. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  9436. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9437. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9438. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9439. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9440. { } /* end */
  9441. };
  9442. /*
  9443. * 8ch mode
  9444. */
  9445. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  9446. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9447. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9448. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9449. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9450. { } /* end */
  9451. };
  9452. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  9453. { 6, alc861vd_6stack_ch6_init },
  9454. { 8, alc861vd_6stack_ch8_init },
  9455. };
  9456. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  9457. {
  9458. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9459. .name = "Channel Mode",
  9460. .info = alc_ch_mode_info,
  9461. .get = alc_ch_mode_get,
  9462. .put = alc_ch_mode_put,
  9463. },
  9464. { } /* end */
  9465. };
  9466. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  9467. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9468. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9469. {
  9470. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9471. /* The multiple "Capture Source" controls confuse alsamixer
  9472. * So call somewhat different..
  9473. *FIXME: the controls appear in the "playback" view!
  9474. */
  9475. /* .name = "Capture Source", */
  9476. .name = "Input Source",
  9477. .count = 1,
  9478. .info = alc861vd_mux_enum_info,
  9479. .get = alc861vd_mux_enum_get,
  9480. .put = alc861vd_mux_enum_put,
  9481. },
  9482. { } /* end */
  9483. };
  9484. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9485. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9486. */
  9487. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9488. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9489. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9490. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9491. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9492. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9493. HDA_OUTPUT),
  9494. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9495. HDA_OUTPUT),
  9496. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9497. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9498. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9499. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9500. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9501. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9502. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9503. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9504. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9505. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9506. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9507. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9508. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9509. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9510. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9511. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9512. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9513. { } /* end */
  9514. };
  9515. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9516. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9517. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9518. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9519. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9520. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9521. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9522. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9523. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9524. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9525. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9526. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9527. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9528. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9529. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9530. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9531. { } /* end */
  9532. };
  9533. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9534. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9535. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9536. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9537. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9538. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9539. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9540. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9541. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9542. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9543. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9544. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9545. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9546. { } /* end */
  9547. };
  9548. /* Pin assignment: Front=0x14, HP = 0x15,
  9549. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9550. */
  9551. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9552. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9553. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9554. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9555. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9556. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9557. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9558. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9559. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9560. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9561. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9562. { } /* end */
  9563. };
  9564. /* Pin assignment: Speaker=0x14, Line-out = 0x15,
  9565. * Front Mic=0x18, ATAPI Mic = 0x19,
  9566. */
  9567. static struct snd_kcontrol_new alc861vd_hp_mixer[] = {
  9568. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9569. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9570. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9571. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9572. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9573. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9574. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9575. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9576. { } /* end */
  9577. };
  9578. /*
  9579. * generic initialization of ADC, input mixers and output mixers
  9580. */
  9581. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9582. /*
  9583. * Unmute ADC0 and set the default input to mic-in
  9584. */
  9585. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9586. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9587. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9588. * the analog-loopback mixer widget
  9589. */
  9590. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9591. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9592. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9593. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9594. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9595. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9596. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9597. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9598. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9599. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9600. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9601. /*
  9602. * Set up output mixers (0x02 - 0x05)
  9603. */
  9604. /* set vol=0 to output mixers */
  9605. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9606. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9607. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9608. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9609. /* set up input amps for analog loopback */
  9610. /* Amp Indices: DAC = 0, mixer = 1 */
  9611. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9612. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9613. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9614. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9615. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9616. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9617. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9618. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9619. { }
  9620. };
  9621. /*
  9622. * 3-stack pin configuration:
  9623. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9624. */
  9625. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9626. /*
  9627. * Set pin mode and muting
  9628. */
  9629. /* set front pin widgets 0x14 for output */
  9630. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9631. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9632. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9633. /* Mic (rear) pin: input vref at 80% */
  9634. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9635. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9636. /* Front Mic pin: input vref at 80% */
  9637. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9638. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9639. /* Line In pin: input */
  9640. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9641. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9642. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9643. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9644. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9645. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9646. /* CD pin widget for input */
  9647. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9648. { }
  9649. };
  9650. /*
  9651. * 6-stack pin configuration:
  9652. */
  9653. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9654. /*
  9655. * Set pin mode and muting
  9656. */
  9657. /* set front pin widgets 0x14 for output */
  9658. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9659. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9660. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9661. /* Rear Pin: output 1 (0x0d) */
  9662. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9663. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9664. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9665. /* CLFE Pin: output 2 (0x0e) */
  9666. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9667. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9668. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9669. /* Side Pin: output 3 (0x0f) */
  9670. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9671. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9672. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9673. /* Mic (rear) pin: input vref at 80% */
  9674. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9675. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9676. /* Front Mic pin: input vref at 80% */
  9677. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9678. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9679. /* Line In pin: input */
  9680. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9681. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9682. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9683. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9684. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9685. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9686. /* CD pin widget for input */
  9687. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9688. { }
  9689. };
  9690. static struct hda_verb alc861vd_eapd_verbs[] = {
  9691. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9692. { }
  9693. };
  9694. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9695. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9696. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9697. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9698. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9699. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9700. {}
  9701. };
  9702. /* toggle speaker-output according to the hp-jack state */
  9703. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9704. {
  9705. unsigned int present;
  9706. unsigned char bits;
  9707. present = snd_hda_codec_read(codec, 0x1b, 0,
  9708. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9709. bits = present ? HDA_AMP_MUTE : 0;
  9710. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9711. HDA_AMP_MUTE, bits);
  9712. }
  9713. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9714. {
  9715. unsigned int present;
  9716. unsigned char bits;
  9717. present = snd_hda_codec_read(codec, 0x18, 0,
  9718. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9719. bits = present ? HDA_AMP_MUTE : 0;
  9720. snd_hda_codec_amp_stereo(codec, 0x0b, HDA_INPUT, 1,
  9721. HDA_AMP_MUTE, bits);
  9722. }
  9723. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9724. {
  9725. alc861vd_lenovo_hp_automute(codec);
  9726. alc861vd_lenovo_mic_automute(codec);
  9727. }
  9728. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9729. unsigned int res)
  9730. {
  9731. switch (res >> 26) {
  9732. case ALC880_HP_EVENT:
  9733. alc861vd_lenovo_hp_automute(codec);
  9734. break;
  9735. case ALC880_MIC_EVENT:
  9736. alc861vd_lenovo_mic_automute(codec);
  9737. break;
  9738. }
  9739. }
  9740. static struct hda_verb alc861vd_dallas_verbs[] = {
  9741. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9742. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9743. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9744. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9745. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9746. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9747. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9748. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9749. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9750. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9751. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9752. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9753. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9754. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9755. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9756. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9757. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9758. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9759. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9760. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9761. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9762. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9763. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9764. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9765. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9766. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9767. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9768. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9769. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9770. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9771. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9772. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9773. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9774. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9775. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9776. { } /* end */
  9777. };
  9778. /* toggle speaker-output according to the hp-jack state */
  9779. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9780. {
  9781. unsigned int present;
  9782. present = snd_hda_codec_read(codec, 0x15, 0,
  9783. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9784. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  9785. HDA_AMP_MUTE, present ? HDA_AMP_MUTE : 0);
  9786. }
  9787. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9788. {
  9789. if ((res >> 26) == ALC880_HP_EVENT)
  9790. alc861vd_dallas_automute(codec);
  9791. }
  9792. #ifdef CONFIG_SND_HDA_POWER_SAVE
  9793. #define alc861vd_loopbacks alc880_loopbacks
  9794. #endif
  9795. /* pcm configuration: identiacal with ALC880 */
  9796. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9797. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9798. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9799. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9800. /*
  9801. * configuration and preset
  9802. */
  9803. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9804. [ALC660VD_3ST] = "3stack-660",
  9805. [ALC660VD_3ST_DIG] = "3stack-660-digout",
  9806. [ALC861VD_3ST] = "3stack",
  9807. [ALC861VD_3ST_DIG] = "3stack-digout",
  9808. [ALC861VD_6ST_DIG] = "6stack-digout",
  9809. [ALC861VD_LENOVO] = "lenovo",
  9810. [ALC861VD_DALLAS] = "dallas",
  9811. [ALC861VD_HP] = "hp",
  9812. [ALC861VD_AUTO] = "auto",
  9813. };
  9814. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9815. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9816. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9817. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9818. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9819. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9820. /*SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),*/ /*lenovo*/
  9821. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9822. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9823. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9824. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9825. SND_PCI_QUIRK(0x1179, 0xff03, "Toshiba P205", ALC861VD_LENOVO),
  9826. SND_PCI_QUIRK(0x1565, 0x820d, "Biostar NF61S SE", ALC861VD_6ST_DIG),
  9827. SND_PCI_QUIRK(0x1849, 0x0862, "ASRock K8NF6G-VSTA", ALC861VD_6ST_DIG),
  9828. SND_PCI_QUIRK(0x103c, 0x30bf, "HP TX1000", ALC861VD_HP),
  9829. {}
  9830. };
  9831. static struct alc_config_preset alc861vd_presets[] = {
  9832. [ALC660VD_3ST] = {
  9833. .mixers = { alc861vd_3st_mixer },
  9834. .init_verbs = { alc861vd_volume_init_verbs,
  9835. alc861vd_3stack_init_verbs },
  9836. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9837. .dac_nids = alc660vd_dac_nids,
  9838. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9839. .adc_nids = alc861vd_adc_nids,
  9840. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9841. .channel_mode = alc861vd_3stack_2ch_modes,
  9842. .input_mux = &alc861vd_capture_source,
  9843. },
  9844. [ALC660VD_3ST_DIG] = {
  9845. .mixers = { alc861vd_3st_mixer },
  9846. .init_verbs = { alc861vd_volume_init_verbs,
  9847. alc861vd_3stack_init_verbs },
  9848. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9849. .dac_nids = alc660vd_dac_nids,
  9850. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9851. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9852. .adc_nids = alc861vd_adc_nids,
  9853. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9854. .channel_mode = alc861vd_3stack_2ch_modes,
  9855. .input_mux = &alc861vd_capture_source,
  9856. },
  9857. [ALC861VD_3ST] = {
  9858. .mixers = { alc861vd_3st_mixer },
  9859. .init_verbs = { alc861vd_volume_init_verbs,
  9860. alc861vd_3stack_init_verbs },
  9861. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9862. .dac_nids = alc861vd_dac_nids,
  9863. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9864. .channel_mode = alc861vd_3stack_2ch_modes,
  9865. .input_mux = &alc861vd_capture_source,
  9866. },
  9867. [ALC861VD_3ST_DIG] = {
  9868. .mixers = { alc861vd_3st_mixer },
  9869. .init_verbs = { alc861vd_volume_init_verbs,
  9870. alc861vd_3stack_init_verbs },
  9871. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9872. .dac_nids = alc861vd_dac_nids,
  9873. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9874. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9875. .channel_mode = alc861vd_3stack_2ch_modes,
  9876. .input_mux = &alc861vd_capture_source,
  9877. },
  9878. [ALC861VD_6ST_DIG] = {
  9879. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9880. .init_verbs = { alc861vd_volume_init_verbs,
  9881. alc861vd_6stack_init_verbs },
  9882. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9883. .dac_nids = alc861vd_dac_nids,
  9884. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9885. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9886. .channel_mode = alc861vd_6stack_modes,
  9887. .input_mux = &alc861vd_capture_source,
  9888. },
  9889. [ALC861VD_LENOVO] = {
  9890. .mixers = { alc861vd_lenovo_mixer },
  9891. .init_verbs = { alc861vd_volume_init_verbs,
  9892. alc861vd_3stack_init_verbs,
  9893. alc861vd_eapd_verbs,
  9894. alc861vd_lenovo_unsol_verbs },
  9895. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9896. .dac_nids = alc660vd_dac_nids,
  9897. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9898. .adc_nids = alc861vd_adc_nids,
  9899. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9900. .channel_mode = alc861vd_3stack_2ch_modes,
  9901. .input_mux = &alc861vd_capture_source,
  9902. .unsol_event = alc861vd_lenovo_unsol_event,
  9903. .init_hook = alc861vd_lenovo_automute,
  9904. },
  9905. [ALC861VD_DALLAS] = {
  9906. .mixers = { alc861vd_dallas_mixer },
  9907. .init_verbs = { alc861vd_dallas_verbs },
  9908. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9909. .dac_nids = alc861vd_dac_nids,
  9910. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9911. .adc_nids = alc861vd_adc_nids,
  9912. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9913. .channel_mode = alc861vd_3stack_2ch_modes,
  9914. .input_mux = &alc861vd_dallas_capture_source,
  9915. .unsol_event = alc861vd_dallas_unsol_event,
  9916. .init_hook = alc861vd_dallas_automute,
  9917. },
  9918. [ALC861VD_HP] = {
  9919. .mixers = { alc861vd_hp_mixer },
  9920. .init_verbs = { alc861vd_dallas_verbs, alc861vd_eapd_verbs },
  9921. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9922. .dac_nids = alc861vd_dac_nids,
  9923. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9924. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9925. .adc_nids = alc861vd_adc_nids,
  9926. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9927. .channel_mode = alc861vd_3stack_2ch_modes,
  9928. .input_mux = &alc861vd_hp_capture_source,
  9929. .unsol_event = alc861vd_dallas_unsol_event,
  9930. .init_hook = alc861vd_dallas_automute,
  9931. },
  9932. };
  9933. /*
  9934. * BIOS auto configuration
  9935. */
  9936. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9937. hda_nid_t nid, int pin_type, int dac_idx)
  9938. {
  9939. /* set as output */
  9940. snd_hda_codec_write(codec, nid, 0,
  9941. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9942. snd_hda_codec_write(codec, nid, 0,
  9943. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9944. }
  9945. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9946. {
  9947. struct alc_spec *spec = codec->spec;
  9948. int i;
  9949. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9950. for (i = 0; i <= HDA_SIDE; i++) {
  9951. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9952. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9953. if (nid)
  9954. alc861vd_auto_set_output_and_unmute(codec, nid,
  9955. pin_type, i);
  9956. }
  9957. }
  9958. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9959. {
  9960. struct alc_spec *spec = codec->spec;
  9961. hda_nid_t pin;
  9962. pin = spec->autocfg.hp_pins[0];
  9963. if (pin) /* connect to front and use dac 0 */
  9964. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9965. }
  9966. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9967. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9968. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9969. {
  9970. struct alc_spec *spec = codec->spec;
  9971. int i;
  9972. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9973. hda_nid_t nid = spec->autocfg.input_pins[i];
  9974. if (alc861vd_is_input_pin(nid)) {
  9975. snd_hda_codec_write(codec, nid, 0,
  9976. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9977. i <= AUTO_PIN_FRONT_MIC ?
  9978. PIN_VREF80 : PIN_IN);
  9979. if (nid != ALC861VD_PIN_CD_NID)
  9980. snd_hda_codec_write(codec, nid, 0,
  9981. AC_VERB_SET_AMP_GAIN_MUTE,
  9982. AMP_OUT_MUTE);
  9983. }
  9984. }
  9985. }
  9986. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9987. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9988. /* add playback controls from the parsed DAC table */
  9989. /* Based on ALC880 version. But ALC861VD has separate,
  9990. * different NIDs for mute/unmute switch and volume control */
  9991. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9992. const struct auto_pin_cfg *cfg)
  9993. {
  9994. char name[32];
  9995. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9996. hda_nid_t nid_v, nid_s;
  9997. int i, err;
  9998. for (i = 0; i < cfg->line_outs; i++) {
  9999. if (!spec->multiout.dac_nids[i])
  10000. continue;
  10001. nid_v = alc861vd_idx_to_mixer_vol(
  10002. alc880_dac_to_idx(
  10003. spec->multiout.dac_nids[i]));
  10004. nid_s = alc861vd_idx_to_mixer_switch(
  10005. alc880_dac_to_idx(
  10006. spec->multiout.dac_nids[i]));
  10007. if (i == 2) {
  10008. /* Center/LFE */
  10009. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10010. "Center Playback Volume",
  10011. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  10012. HDA_OUTPUT));
  10013. if (err < 0)
  10014. return err;
  10015. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10016. "LFE Playback Volume",
  10017. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  10018. HDA_OUTPUT));
  10019. if (err < 0)
  10020. return err;
  10021. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10022. "Center Playback Switch",
  10023. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  10024. HDA_INPUT));
  10025. if (err < 0)
  10026. return err;
  10027. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10028. "LFE Playback Switch",
  10029. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  10030. HDA_INPUT));
  10031. if (err < 0)
  10032. return err;
  10033. } else {
  10034. sprintf(name, "%s Playback Volume", chname[i]);
  10035. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10036. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  10037. HDA_OUTPUT));
  10038. if (err < 0)
  10039. return err;
  10040. sprintf(name, "%s Playback Switch", chname[i]);
  10041. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10042. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  10043. HDA_INPUT));
  10044. if (err < 0)
  10045. return err;
  10046. }
  10047. }
  10048. return 0;
  10049. }
  10050. /* add playback controls for speaker and HP outputs */
  10051. /* Based on ALC880 version. But ALC861VD has separate,
  10052. * different NIDs for mute/unmute switch and volume control */
  10053. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  10054. hda_nid_t pin, const char *pfx)
  10055. {
  10056. hda_nid_t nid_v, nid_s;
  10057. int err;
  10058. char name[32];
  10059. if (!pin)
  10060. return 0;
  10061. if (alc880_is_fixed_pin(pin)) {
  10062. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10063. /* specify the DAC as the extra output */
  10064. if (!spec->multiout.hp_nid)
  10065. spec->multiout.hp_nid = nid_v;
  10066. else
  10067. spec->multiout.extra_out_nid[0] = nid_v;
  10068. /* control HP volume/switch on the output mixer amp */
  10069. nid_v = alc861vd_idx_to_mixer_vol(
  10070. alc880_fixed_pin_idx(pin));
  10071. nid_s = alc861vd_idx_to_mixer_switch(
  10072. alc880_fixed_pin_idx(pin));
  10073. sprintf(name, "%s Playback Volume", pfx);
  10074. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10075. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  10076. if (err < 0)
  10077. return err;
  10078. sprintf(name, "%s Playback Switch", pfx);
  10079. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10080. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  10081. if (err < 0)
  10082. return err;
  10083. } else if (alc880_is_multi_pin(pin)) {
  10084. /* set manual connection */
  10085. /* we have only a switch on HP-out PIN */
  10086. sprintf(name, "%s Playback Switch", pfx);
  10087. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10088. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10089. if (err < 0)
  10090. return err;
  10091. }
  10092. return 0;
  10093. }
  10094. /* parse the BIOS configuration and set up the alc_spec
  10095. * return 1 if successful, 0 if the proper config is not found,
  10096. * or a negative error code
  10097. * Based on ALC880 version - had to change it to override
  10098. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  10099. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  10100. {
  10101. struct alc_spec *spec = codec->spec;
  10102. int err;
  10103. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  10104. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10105. alc861vd_ignore);
  10106. if (err < 0)
  10107. return err;
  10108. if (!spec->autocfg.line_outs)
  10109. return 0; /* can't find valid BIOS pin config */
  10110. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10111. if (err < 0)
  10112. return err;
  10113. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10114. if (err < 0)
  10115. return err;
  10116. err = alc861vd_auto_create_extra_out(spec,
  10117. spec->autocfg.speaker_pins[0],
  10118. "Speaker");
  10119. if (err < 0)
  10120. return err;
  10121. err = alc861vd_auto_create_extra_out(spec,
  10122. spec->autocfg.hp_pins[0],
  10123. "Headphone");
  10124. if (err < 0)
  10125. return err;
  10126. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10127. if (err < 0)
  10128. return err;
  10129. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10130. if (spec->autocfg.dig_out_pin)
  10131. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  10132. if (spec->kctl_alloc)
  10133. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10134. spec->init_verbs[spec->num_init_verbs++]
  10135. = alc861vd_volume_init_verbs;
  10136. spec->num_mux_defs = 1;
  10137. spec->input_mux = &spec->private_imux;
  10138. err = alc_auto_add_mic_boost(codec);
  10139. if (err < 0)
  10140. return err;
  10141. return 1;
  10142. }
  10143. /* additional initialization for auto-configuration model */
  10144. static void alc861vd_auto_init(struct hda_codec *codec)
  10145. {
  10146. alc861vd_auto_init_multi_out(codec);
  10147. alc861vd_auto_init_hp_out(codec);
  10148. alc861vd_auto_init_analog_input(codec);
  10149. }
  10150. static int patch_alc861vd(struct hda_codec *codec)
  10151. {
  10152. struct alc_spec *spec;
  10153. int err, board_config;
  10154. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10155. if (spec == NULL)
  10156. return -ENOMEM;
  10157. codec->spec = spec;
  10158. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  10159. alc861vd_models,
  10160. alc861vd_cfg_tbl);
  10161. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  10162. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  10163. "ALC861VD, trying auto-probe from BIOS...\n");
  10164. board_config = ALC861VD_AUTO;
  10165. }
  10166. if (board_config == ALC861VD_AUTO) {
  10167. /* automatic parse from the BIOS config */
  10168. err = alc861vd_parse_auto_config(codec);
  10169. if (err < 0) {
  10170. alc_free(codec);
  10171. return err;
  10172. } else if (!err) {
  10173. printk(KERN_INFO
  10174. "hda_codec: Cannot set up configuration "
  10175. "from BIOS. Using base mode...\n");
  10176. board_config = ALC861VD_3ST;
  10177. }
  10178. }
  10179. if (board_config != ALC861VD_AUTO)
  10180. setup_preset(spec, &alc861vd_presets[board_config]);
  10181. spec->stream_name_analog = "ALC861VD Analog";
  10182. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  10183. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  10184. spec->stream_name_digital = "ALC861VD Digital";
  10185. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  10186. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  10187. spec->adc_nids = alc861vd_adc_nids;
  10188. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  10189. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  10190. spec->num_mixers++;
  10191. codec->patch_ops = alc_patch_ops;
  10192. if (board_config == ALC861VD_AUTO)
  10193. spec->init_hook = alc861vd_auto_init;
  10194. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10195. if (!spec->loopback.amplist)
  10196. spec->loopback.amplist = alc861vd_loopbacks;
  10197. #endif
  10198. return 0;
  10199. }
  10200. /*
  10201. * ALC662 support
  10202. *
  10203. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  10204. * configuration. Each pin widget can choose any input DACs and a mixer.
  10205. * Each ADC is connected from a mixer of all inputs. This makes possible
  10206. * 6-channel independent captures.
  10207. *
  10208. * In addition, an independent DAC for the multi-playback (not used in this
  10209. * driver yet).
  10210. */
  10211. #define ALC662_DIGOUT_NID 0x06
  10212. #define ALC662_DIGIN_NID 0x0a
  10213. static hda_nid_t alc662_dac_nids[4] = {
  10214. /* front, rear, clfe, rear_surr */
  10215. 0x02, 0x03, 0x04
  10216. };
  10217. static hda_nid_t alc662_adc_nids[1] = {
  10218. /* ADC1-2 */
  10219. 0x09,
  10220. };
  10221. /* input MUX */
  10222. /* FIXME: should be a matrix-type input source selection */
  10223. static struct hda_input_mux alc662_capture_source = {
  10224. .num_items = 4,
  10225. .items = {
  10226. { "Mic", 0x0 },
  10227. { "Front Mic", 0x1 },
  10228. { "Line", 0x2 },
  10229. { "CD", 0x4 },
  10230. },
  10231. };
  10232. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  10233. .num_items = 2,
  10234. .items = {
  10235. { "Mic", 0x1 },
  10236. { "Line", 0x2 },
  10237. },
  10238. };
  10239. #define alc662_mux_enum_info alc_mux_enum_info
  10240. #define alc662_mux_enum_get alc_mux_enum_get
  10241. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  10242. struct snd_ctl_elem_value *ucontrol)
  10243. {
  10244. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  10245. struct alc_spec *spec = codec->spec;
  10246. const struct hda_input_mux *imux = spec->input_mux;
  10247. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  10248. static hda_nid_t capture_mixers[2] = { 0x23, 0x22 };
  10249. hda_nid_t nid = capture_mixers[adc_idx];
  10250. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  10251. unsigned int i, idx;
  10252. idx = ucontrol->value.enumerated.item[0];
  10253. if (idx >= imux->num_items)
  10254. idx = imux->num_items - 1;
  10255. if (*cur_val == idx)
  10256. return 0;
  10257. for (i = 0; i < imux->num_items; i++) {
  10258. unsigned int v = (i == idx) ? 0 : HDA_AMP_MUTE;
  10259. snd_hda_codec_amp_stereo(codec, nid, HDA_INPUT,
  10260. imux->items[i].index,
  10261. HDA_AMP_MUTE, v);
  10262. }
  10263. *cur_val = idx;
  10264. return 1;
  10265. }
  10266. /*
  10267. * 2ch mode
  10268. */
  10269. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  10270. { 2, NULL }
  10271. };
  10272. /*
  10273. * 2ch mode
  10274. */
  10275. static struct hda_verb alc662_3ST_ch2_init[] = {
  10276. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  10277. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10278. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  10279. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  10280. { } /* end */
  10281. };
  10282. /*
  10283. * 6ch mode
  10284. */
  10285. static struct hda_verb alc662_3ST_ch6_init[] = {
  10286. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10287. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10288. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  10289. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10290. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  10291. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  10292. { } /* end */
  10293. };
  10294. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  10295. { 2, alc662_3ST_ch2_init },
  10296. { 6, alc662_3ST_ch6_init },
  10297. };
  10298. /*
  10299. * 2ch mode
  10300. */
  10301. static struct hda_verb alc662_sixstack_ch6_init[] = {
  10302. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10303. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  10304. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10305. { } /* end */
  10306. };
  10307. /*
  10308. * 6ch mode
  10309. */
  10310. static struct hda_verb alc662_sixstack_ch8_init[] = {
  10311. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10312. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10313. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  10314. { } /* end */
  10315. };
  10316. static struct hda_channel_mode alc662_5stack_modes[2] = {
  10317. { 2, alc662_sixstack_ch6_init },
  10318. { 6, alc662_sixstack_ch8_init },
  10319. };
  10320. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  10321. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  10322. */
  10323. static struct snd_kcontrol_new alc662_base_mixer[] = {
  10324. /* output mixer control */
  10325. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  10326. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  10327. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  10328. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  10329. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10330. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10331. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10332. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10333. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10334. /*Input mixer control */
  10335. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  10336. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  10337. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  10338. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  10339. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  10340. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  10341. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  10342. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  10343. /* Capture mixer control */
  10344. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10345. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10346. {
  10347. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10348. .name = "Capture Source",
  10349. .count = 1,
  10350. .info = alc_mux_enum_info,
  10351. .get = alc_mux_enum_get,
  10352. .put = alc_mux_enum_put,
  10353. },
  10354. { } /* end */
  10355. };
  10356. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  10357. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10358. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10359. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10360. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10361. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10362. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10363. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10364. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10365. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10366. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10367. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10368. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10369. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10370. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10371. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10372. {
  10373. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10374. /* .name = "Capture Source", */
  10375. .name = "Input Source",
  10376. .count = 1,
  10377. .info = alc662_mux_enum_info,
  10378. .get = alc662_mux_enum_get,
  10379. .put = alc662_mux_enum_put,
  10380. },
  10381. { } /* end */
  10382. };
  10383. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  10384. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10385. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10386. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10387. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  10388. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  10389. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  10390. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  10391. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  10392. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10393. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  10394. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  10395. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10396. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10397. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  10398. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  10399. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10400. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10401. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  10402. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  10403. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10404. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10405. {
  10406. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10407. /* .name = "Capture Source", */
  10408. .name = "Input Source",
  10409. .count = 1,
  10410. .info = alc662_mux_enum_info,
  10411. .get = alc662_mux_enum_get,
  10412. .put = alc662_mux_enum_put,
  10413. },
  10414. { } /* end */
  10415. };
  10416. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  10417. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  10418. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  10419. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  10420. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  10421. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  10422. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  10423. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  10424. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  10425. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  10426. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10427. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10428. {
  10429. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10430. /* .name = "Capture Source", */
  10431. .name = "Input Source",
  10432. .count = 1,
  10433. .info = alc662_mux_enum_info,
  10434. .get = alc662_mux_enum_get,
  10435. .put = alc662_mux_enum_put,
  10436. },
  10437. { } /* end */
  10438. };
  10439. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  10440. {
  10441. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10442. .name = "Channel Mode",
  10443. .info = alc_ch_mode_info,
  10444. .get = alc_ch_mode_get,
  10445. .put = alc_ch_mode_put,
  10446. },
  10447. { } /* end */
  10448. };
  10449. static struct hda_verb alc662_init_verbs[] = {
  10450. /* ADC: mute amp left and right */
  10451. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10452. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10453. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  10454. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10455. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10456. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10457. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10458. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10459. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10460. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10461. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10462. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10463. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10464. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10465. /* Front Pin: output 0 (0x0c) */
  10466. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10467. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10468. /* Rear Pin: output 1 (0x0d) */
  10469. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10470. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10471. /* CLFE Pin: output 2 (0x0e) */
  10472. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  10473. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10474. /* Mic (rear) pin: input vref at 80% */
  10475. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10476. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10477. /* Front Mic pin: input vref at 80% */
  10478. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  10479. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10480. /* Line In pin: input */
  10481. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10482. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  10483. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  10484. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  10485. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  10486. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  10487. /* CD pin widget for input */
  10488. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  10489. /* FIXME: use matrix-type input source selection */
  10490. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10491. /* Input mixer */
  10492. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10493. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10494. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10495. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10496. { }
  10497. };
  10498. static struct hda_verb alc662_sue_init_verbs[] = {
  10499. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  10500. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  10501. {}
  10502. };
  10503. /*
  10504. * generic initialization of ADC, input mixers and output mixers
  10505. */
  10506. static struct hda_verb alc662_auto_init_verbs[] = {
  10507. /*
  10508. * Unmute ADC and set the default input to mic-in
  10509. */
  10510. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  10511. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10512. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  10513. * mixer widget
  10514. * Note: PASD motherboards uses the Line In 2 as the input for front
  10515. * panel mic (mic 2)
  10516. */
  10517. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10518. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  10519. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  10520. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  10521. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  10522. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  10523. /*
  10524. * Set up output mixers (0x0c - 0x0f)
  10525. */
  10526. /* set vol=0 to output mixers */
  10527. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10528. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10529. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10530. /* set up input amps for analog loopback */
  10531. /* Amp Indices: DAC = 0, mixer = 1 */
  10532. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10533. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10534. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10535. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10536. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10537. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10538. /* FIXME: use matrix-type input source selection */
  10539. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10540. /* Input mixer */
  10541. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10542. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10543. { }
  10544. };
  10545. /* capture mixer elements */
  10546. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10547. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10548. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10549. {
  10550. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10551. /* The multiple "Capture Source" controls confuse alsamixer
  10552. * So call somewhat different..
  10553. * FIXME: the controls appear in the "playback" view!
  10554. */
  10555. /* .name = "Capture Source", */
  10556. .name = "Input Source",
  10557. .count = 1,
  10558. .info = alc882_mux_enum_info,
  10559. .get = alc882_mux_enum_get,
  10560. .put = alc882_mux_enum_put,
  10561. },
  10562. { } /* end */
  10563. };
  10564. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10565. {
  10566. unsigned int present;
  10567. unsigned char bits;
  10568. present = snd_hda_codec_read(codec, 0x14, 0,
  10569. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10570. bits = present ? HDA_AMP_MUTE : 0;
  10571. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10572. HDA_AMP_MUTE, bits);
  10573. }
  10574. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10575. {
  10576. unsigned int present;
  10577. unsigned char bits;
  10578. present = snd_hda_codec_read(codec, 0x1b, 0,
  10579. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10580. bits = present ? HDA_AMP_MUTE : 0;
  10581. snd_hda_codec_amp_stereo(codec, 0x15, HDA_OUTPUT, 0,
  10582. HDA_AMP_MUTE, bits);
  10583. snd_hda_codec_amp_stereo(codec, 0x14, HDA_OUTPUT, 0,
  10584. HDA_AMP_MUTE, bits);
  10585. }
  10586. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10587. unsigned int res)
  10588. {
  10589. if ((res >> 26) == ALC880_HP_EVENT)
  10590. alc662_lenovo_101e_all_automute(codec);
  10591. if ((res >> 26) == ALC880_FRONT_EVENT)
  10592. alc662_lenovo_101e_ispeaker_automute(codec);
  10593. }
  10594. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10595. #define alc662_loopbacks alc880_loopbacks
  10596. #endif
  10597. /* pcm configuration: identiacal with ALC880 */
  10598. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10599. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10600. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10601. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10602. /*
  10603. * configuration and preset
  10604. */
  10605. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10606. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10607. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10608. [ALC662_3ST_6ch] = "3stack-6ch",
  10609. [ALC662_5ST_DIG] = "6stack-dig",
  10610. [ALC662_LENOVO_101E] = "lenovo-101e",
  10611. [ALC662_AUTO] = "auto",
  10612. };
  10613. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10614. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10615. {}
  10616. };
  10617. static struct alc_config_preset alc662_presets[] = {
  10618. [ALC662_3ST_2ch_DIG] = {
  10619. .mixers = { alc662_3ST_2ch_mixer },
  10620. .init_verbs = { alc662_init_verbs },
  10621. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10622. .dac_nids = alc662_dac_nids,
  10623. .dig_out_nid = ALC662_DIGOUT_NID,
  10624. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10625. .adc_nids = alc662_adc_nids,
  10626. .dig_in_nid = ALC662_DIGIN_NID,
  10627. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10628. .channel_mode = alc662_3ST_2ch_modes,
  10629. .input_mux = &alc662_capture_source,
  10630. },
  10631. [ALC662_3ST_6ch_DIG] = {
  10632. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10633. .init_verbs = { alc662_init_verbs },
  10634. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10635. .dac_nids = alc662_dac_nids,
  10636. .dig_out_nid = ALC662_DIGOUT_NID,
  10637. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10638. .adc_nids = alc662_adc_nids,
  10639. .dig_in_nid = ALC662_DIGIN_NID,
  10640. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10641. .channel_mode = alc662_3ST_6ch_modes,
  10642. .need_dac_fix = 1,
  10643. .input_mux = &alc662_capture_source,
  10644. },
  10645. [ALC662_3ST_6ch] = {
  10646. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10647. .init_verbs = { alc662_init_verbs },
  10648. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10649. .dac_nids = alc662_dac_nids,
  10650. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10651. .adc_nids = alc662_adc_nids,
  10652. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10653. .channel_mode = alc662_3ST_6ch_modes,
  10654. .need_dac_fix = 1,
  10655. .input_mux = &alc662_capture_source,
  10656. },
  10657. [ALC662_5ST_DIG] = {
  10658. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10659. .init_verbs = { alc662_init_verbs },
  10660. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10661. .dac_nids = alc662_dac_nids,
  10662. .dig_out_nid = ALC662_DIGOUT_NID,
  10663. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10664. .adc_nids = alc662_adc_nids,
  10665. .dig_in_nid = ALC662_DIGIN_NID,
  10666. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10667. .channel_mode = alc662_5stack_modes,
  10668. .input_mux = &alc662_capture_source,
  10669. },
  10670. [ALC662_LENOVO_101E] = {
  10671. .mixers = { alc662_lenovo_101e_mixer },
  10672. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10673. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10674. .dac_nids = alc662_dac_nids,
  10675. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10676. .adc_nids = alc662_adc_nids,
  10677. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10678. .channel_mode = alc662_3ST_2ch_modes,
  10679. .input_mux = &alc662_lenovo_101e_capture_source,
  10680. .unsol_event = alc662_lenovo_101e_unsol_event,
  10681. .init_hook = alc662_lenovo_101e_all_automute,
  10682. },
  10683. };
  10684. /*
  10685. * BIOS auto configuration
  10686. */
  10687. /* add playback controls from the parsed DAC table */
  10688. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10689. const struct auto_pin_cfg *cfg)
  10690. {
  10691. char name[32];
  10692. static const char *chname[4] = {
  10693. "Front", "Surround", NULL /*CLFE*/, "Side"
  10694. };
  10695. hda_nid_t nid;
  10696. int i, err;
  10697. for (i = 0; i < cfg->line_outs; i++) {
  10698. if (!spec->multiout.dac_nids[i])
  10699. continue;
  10700. nid = alc880_idx_to_mixer(i);
  10701. if (i == 2) {
  10702. /* Center/LFE */
  10703. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10704. "Center Playback Volume",
  10705. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10706. HDA_OUTPUT));
  10707. if (err < 0)
  10708. return err;
  10709. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10710. "LFE Playback Volume",
  10711. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10712. HDA_OUTPUT));
  10713. if (err < 0)
  10714. return err;
  10715. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10716. "Center Playback Switch",
  10717. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10718. HDA_INPUT));
  10719. if (err < 0)
  10720. return err;
  10721. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10722. "LFE Playback Switch",
  10723. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10724. HDA_INPUT));
  10725. if (err < 0)
  10726. return err;
  10727. } else {
  10728. sprintf(name, "%s Playback Volume", chname[i]);
  10729. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10730. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10731. HDA_OUTPUT));
  10732. if (err < 0)
  10733. return err;
  10734. sprintf(name, "%s Playback Switch", chname[i]);
  10735. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10736. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10737. HDA_INPUT));
  10738. if (err < 0)
  10739. return err;
  10740. }
  10741. }
  10742. return 0;
  10743. }
  10744. /* add playback controls for speaker and HP outputs */
  10745. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10746. const char *pfx)
  10747. {
  10748. hda_nid_t nid;
  10749. int err;
  10750. char name[32];
  10751. if (!pin)
  10752. return 0;
  10753. if (alc880_is_fixed_pin(pin)) {
  10754. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10755. /* printk("DAC nid=%x\n",nid); */
  10756. /* specify the DAC as the extra output */
  10757. if (!spec->multiout.hp_nid)
  10758. spec->multiout.hp_nid = nid;
  10759. else
  10760. spec->multiout.extra_out_nid[0] = nid;
  10761. /* control HP volume/switch on the output mixer amp */
  10762. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10763. sprintf(name, "%s Playback Volume", pfx);
  10764. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10765. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10766. if (err < 0)
  10767. return err;
  10768. sprintf(name, "%s Playback Switch", pfx);
  10769. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10770. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10771. if (err < 0)
  10772. return err;
  10773. } else if (alc880_is_multi_pin(pin)) {
  10774. /* set manual connection */
  10775. /* we have only a switch on HP-out PIN */
  10776. sprintf(name, "%s Playback Switch", pfx);
  10777. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10778. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10779. if (err < 0)
  10780. return err;
  10781. }
  10782. return 0;
  10783. }
  10784. /* create playback/capture controls for input pins */
  10785. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10786. const struct auto_pin_cfg *cfg)
  10787. {
  10788. struct hda_input_mux *imux = &spec->private_imux;
  10789. int i, err, idx;
  10790. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10791. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10792. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10793. err = new_analog_input(spec, cfg->input_pins[i],
  10794. auto_pin_cfg_labels[i],
  10795. idx, 0x0b);
  10796. if (err < 0)
  10797. return err;
  10798. imux->items[imux->num_items].label =
  10799. auto_pin_cfg_labels[i];
  10800. imux->items[imux->num_items].index =
  10801. alc880_input_pin_idx(cfg->input_pins[i]);
  10802. imux->num_items++;
  10803. }
  10804. }
  10805. return 0;
  10806. }
  10807. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10808. hda_nid_t nid, int pin_type,
  10809. int dac_idx)
  10810. {
  10811. /* set as output */
  10812. snd_hda_codec_write(codec, nid, 0,
  10813. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10814. snd_hda_codec_write(codec, nid, 0,
  10815. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10816. /* need the manual connection? */
  10817. if (alc880_is_multi_pin(nid)) {
  10818. struct alc_spec *spec = codec->spec;
  10819. int idx = alc880_multi_pin_idx(nid);
  10820. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10821. AC_VERB_SET_CONNECT_SEL,
  10822. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10823. }
  10824. }
  10825. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10826. {
  10827. struct alc_spec *spec = codec->spec;
  10828. int i;
  10829. for (i = 0; i <= HDA_SIDE; i++) {
  10830. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10831. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10832. if (nid)
  10833. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10834. i);
  10835. }
  10836. }
  10837. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10838. {
  10839. struct alc_spec *spec = codec->spec;
  10840. hda_nid_t pin;
  10841. pin = spec->autocfg.hp_pins[0];
  10842. if (pin) /* connect to front */
  10843. /* use dac 0 */
  10844. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10845. }
  10846. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10847. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10848. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10849. {
  10850. struct alc_spec *spec = codec->spec;
  10851. int i;
  10852. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10853. hda_nid_t nid = spec->autocfg.input_pins[i];
  10854. if (alc662_is_input_pin(nid)) {
  10855. snd_hda_codec_write(codec, nid, 0,
  10856. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10857. (i <= AUTO_PIN_FRONT_MIC ?
  10858. PIN_VREF80 : PIN_IN));
  10859. if (nid != ALC662_PIN_CD_NID)
  10860. snd_hda_codec_write(codec, nid, 0,
  10861. AC_VERB_SET_AMP_GAIN_MUTE,
  10862. AMP_OUT_MUTE);
  10863. }
  10864. }
  10865. }
  10866. static int alc662_parse_auto_config(struct hda_codec *codec)
  10867. {
  10868. struct alc_spec *spec = codec->spec;
  10869. int err;
  10870. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10871. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10872. alc662_ignore);
  10873. if (err < 0)
  10874. return err;
  10875. if (!spec->autocfg.line_outs)
  10876. return 0; /* can't find valid BIOS pin config */
  10877. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10878. if (err < 0)
  10879. return err;
  10880. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10881. if (err < 0)
  10882. return err;
  10883. err = alc662_auto_create_extra_out(spec,
  10884. spec->autocfg.speaker_pins[0],
  10885. "Speaker");
  10886. if (err < 0)
  10887. return err;
  10888. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10889. "Headphone");
  10890. if (err < 0)
  10891. return err;
  10892. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10893. if (err < 0)
  10894. return err;
  10895. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10896. if (spec->autocfg.dig_out_pin)
  10897. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10898. if (spec->kctl_alloc)
  10899. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10900. spec->num_mux_defs = 1;
  10901. spec->input_mux = &spec->private_imux;
  10902. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10903. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10904. spec->num_mixers++;
  10905. return 1;
  10906. }
  10907. /* additional initialization for auto-configuration model */
  10908. static void alc662_auto_init(struct hda_codec *codec)
  10909. {
  10910. alc662_auto_init_multi_out(codec);
  10911. alc662_auto_init_hp_out(codec);
  10912. alc662_auto_init_analog_input(codec);
  10913. }
  10914. static int patch_alc662(struct hda_codec *codec)
  10915. {
  10916. struct alc_spec *spec;
  10917. int err, board_config;
  10918. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10919. if (!spec)
  10920. return -ENOMEM;
  10921. codec->spec = spec;
  10922. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10923. alc662_models,
  10924. alc662_cfg_tbl);
  10925. if (board_config < 0) {
  10926. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10927. "trying auto-probe from BIOS...\n");
  10928. board_config = ALC662_AUTO;
  10929. }
  10930. if (board_config == ALC662_AUTO) {
  10931. /* automatic parse from the BIOS config */
  10932. err = alc662_parse_auto_config(codec);
  10933. if (err < 0) {
  10934. alc_free(codec);
  10935. return err;
  10936. } else if (!err) {
  10937. printk(KERN_INFO
  10938. "hda_codec: Cannot set up configuration "
  10939. "from BIOS. Using base mode...\n");
  10940. board_config = ALC662_3ST_2ch_DIG;
  10941. }
  10942. }
  10943. if (board_config != ALC662_AUTO)
  10944. setup_preset(spec, &alc662_presets[board_config]);
  10945. spec->stream_name_analog = "ALC662 Analog";
  10946. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10947. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10948. spec->stream_name_digital = "ALC662 Digital";
  10949. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10950. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10951. if (!spec->adc_nids && spec->input_mux) {
  10952. spec->adc_nids = alc662_adc_nids;
  10953. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10954. }
  10955. codec->patch_ops = alc_patch_ops;
  10956. if (board_config == ALC662_AUTO)
  10957. spec->init_hook = alc662_auto_init;
  10958. #ifdef CONFIG_SND_HDA_POWER_SAVE
  10959. if (!spec->loopback.amplist)
  10960. spec->loopback.amplist = alc662_loopbacks;
  10961. #endif
  10962. return 0;
  10963. }
  10964. /*
  10965. * patch entries
  10966. */
  10967. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10968. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10969. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10970. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10971. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10972. .patch = patch_alc861 },
  10973. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10974. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10975. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10976. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10977. .patch = patch_alc883 },
  10978. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10979. .patch = patch_alc662 },
  10980. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10981. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10982. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10983. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10984. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10985. {} /* terminator */
  10986. };