patch_realtek.c 385 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * HD audio interface patch for ALC 260/880/882 codecs
  5. *
  6. * Copyright (c) 2004 Kailang Yang <kailang@realtek.com.tw>
  7. * PeiSen Hou <pshou@realtek.com.tw>
  8. * Takashi Iwai <tiwai@suse.de>
  9. * Jonathan Woithe <jwoithe@physics.adelaide.edu.au>
  10. *
  11. * This driver is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version.
  15. *
  16. * This driver is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software
  23. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  24. */
  25. #include <sound/driver.h>
  26. #include <linux/init.h>
  27. #include <linux/delay.h>
  28. #include <linux/slab.h>
  29. #include <linux/pci.h>
  30. #include <sound/core.h>
  31. #include "hda_codec.h"
  32. #include "hda_local.h"
  33. #define ALC880_FRONT_EVENT 0x01
  34. #define ALC880_DCVOL_EVENT 0x02
  35. #define ALC880_HP_EVENT 0x04
  36. #define ALC880_MIC_EVENT 0x08
  37. /* ALC880 board config type */
  38. enum {
  39. ALC880_3ST,
  40. ALC880_3ST_DIG,
  41. ALC880_5ST,
  42. ALC880_5ST_DIG,
  43. ALC880_W810,
  44. ALC880_Z71V,
  45. ALC880_6ST,
  46. ALC880_6ST_DIG,
  47. ALC880_F1734,
  48. ALC880_ASUS,
  49. ALC880_ASUS_DIG,
  50. ALC880_ASUS_W1V,
  51. ALC880_ASUS_DIG2,
  52. ALC880_FUJITSU,
  53. ALC880_UNIWILL_DIG,
  54. ALC880_UNIWILL,
  55. ALC880_UNIWILL_P53,
  56. ALC880_CLEVO,
  57. ALC880_TCL_S700,
  58. ALC880_LG,
  59. ALC880_LG_LW,
  60. #ifdef CONFIG_SND_DEBUG
  61. ALC880_TEST,
  62. #endif
  63. ALC880_AUTO,
  64. ALC880_MODEL_LAST /* last tag */
  65. };
  66. /* ALC260 models */
  67. enum {
  68. ALC260_BASIC,
  69. ALC260_HP,
  70. ALC260_HP_3013,
  71. ALC260_FUJITSU_S702X,
  72. ALC260_ACER,
  73. ALC260_WILL,
  74. ALC260_REPLACER_672V,
  75. #ifdef CONFIG_SND_DEBUG
  76. ALC260_TEST,
  77. #endif
  78. ALC260_AUTO,
  79. ALC260_MODEL_LAST /* last tag */
  80. };
  81. /* ALC262 models */
  82. enum {
  83. ALC262_BASIC,
  84. ALC262_HIPPO,
  85. ALC262_HIPPO_1,
  86. ALC262_FUJITSU,
  87. ALC262_HP_BPC,
  88. ALC262_HP_BPC_D7000_WL,
  89. ALC262_HP_BPC_D7000_WF,
  90. ALC262_BENQ_ED8,
  91. ALC262_SONY_ASSAMD,
  92. ALC262_BENQ_T31,
  93. ALC262_AUTO,
  94. ALC262_MODEL_LAST /* last tag */
  95. };
  96. /* ALC268 models */
  97. enum {
  98. ALC268_3ST,
  99. ALC268_AUTO,
  100. ALC268_MODEL_LAST /* last tag */
  101. };
  102. /* ALC861 models */
  103. enum {
  104. ALC861_3ST,
  105. ALC660_3ST,
  106. ALC861_3ST_DIG,
  107. ALC861_6ST_DIG,
  108. ALC861_UNIWILL_M31,
  109. ALC861_TOSHIBA,
  110. ALC861_ASUS,
  111. ALC861_ASUS_LAPTOP,
  112. ALC861_AUTO,
  113. ALC861_MODEL_LAST,
  114. };
  115. /* ALC861-VD models */
  116. enum {
  117. ALC660VD_3ST,
  118. ALC660VD_3ST_DIG,
  119. ALC861VD_3ST,
  120. ALC861VD_3ST_DIG,
  121. ALC861VD_6ST_DIG,
  122. ALC861VD_LENOVO,
  123. ALC861VD_DALLAS,
  124. ALC861VD_AUTO,
  125. ALC861VD_MODEL_LAST,
  126. };
  127. /* ALC662 models */
  128. enum {
  129. ALC662_3ST_2ch_DIG,
  130. ALC662_3ST_6ch_DIG,
  131. ALC662_3ST_6ch,
  132. ALC662_5ST_DIG,
  133. ALC662_LENOVO_101E,
  134. ALC662_AUTO,
  135. ALC662_MODEL_LAST,
  136. };
  137. /* ALC882 models */
  138. enum {
  139. ALC882_3ST_DIG,
  140. ALC882_6ST_DIG,
  141. ALC882_ARIMA,
  142. ALC882_W2JC,
  143. ALC882_TARGA,
  144. ALC882_ASUS_A7J,
  145. ALC885_MACPRO,
  146. ALC885_IMAC24,
  147. ALC882_AUTO,
  148. ALC882_MODEL_LAST,
  149. };
  150. /* ALC883 models */
  151. enum {
  152. ALC883_3ST_2ch_DIG,
  153. ALC883_3ST_6ch_DIG,
  154. ALC883_3ST_6ch,
  155. ALC883_6ST_DIG,
  156. ALC883_TARGA_DIG,
  157. ALC883_TARGA_2ch_DIG,
  158. ALC883_ACER,
  159. ALC883_MEDION,
  160. ALC883_MEDION_MD2,
  161. ALC883_LAPTOP_EAPD,
  162. ALC883_LENOVO_101E_2ch,
  163. ALC883_LENOVO_NB0763,
  164. ALC888_LENOVO_MS7195_DIG,
  165. ALC888_6ST_HP,
  166. ALC888_3ST_HP,
  167. ALC883_AUTO,
  168. ALC883_MODEL_LAST,
  169. };
  170. /* for GPIO Poll */
  171. #define GPIO_MASK 0x03
  172. struct alc_spec {
  173. /* codec parameterization */
  174. struct snd_kcontrol_new *mixers[5]; /* mixer arrays */
  175. unsigned int num_mixers;
  176. const struct hda_verb *init_verbs[5]; /* initialization verbs
  177. * don't forget NULL
  178. * termination!
  179. */
  180. unsigned int num_init_verbs;
  181. char *stream_name_analog; /* analog PCM stream */
  182. struct hda_pcm_stream *stream_analog_playback;
  183. struct hda_pcm_stream *stream_analog_capture;
  184. char *stream_name_digital; /* digital PCM stream */
  185. struct hda_pcm_stream *stream_digital_playback;
  186. struct hda_pcm_stream *stream_digital_capture;
  187. /* playback */
  188. struct hda_multi_out multiout; /* playback set-up
  189. * max_channels, dacs must be set
  190. * dig_out_nid and hp_nid are optional
  191. */
  192. /* capture */
  193. unsigned int num_adc_nids;
  194. hda_nid_t *adc_nids;
  195. hda_nid_t dig_in_nid; /* digital-in NID; optional */
  196. /* capture source */
  197. unsigned int num_mux_defs;
  198. const struct hda_input_mux *input_mux;
  199. unsigned int cur_mux[3];
  200. /* channel model */
  201. const struct hda_channel_mode *channel_mode;
  202. int num_channel_mode;
  203. int need_dac_fix;
  204. /* PCM information */
  205. struct hda_pcm pcm_rec[3]; /* used in alc_build_pcms() */
  206. /* dynamic controls, init_verbs and input_mux */
  207. struct auto_pin_cfg autocfg;
  208. unsigned int num_kctl_alloc, num_kctl_used;
  209. struct snd_kcontrol_new *kctl_alloc;
  210. struct hda_input_mux private_imux;
  211. hda_nid_t private_dac_nids[5];
  212. /* hooks */
  213. void (*init_hook)(struct hda_codec *codec);
  214. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  215. /* for pin sensing */
  216. unsigned int sense_updated: 1;
  217. unsigned int jack_present: 1;
  218. };
  219. /*
  220. * configuration template - to be copied to the spec instance
  221. */
  222. struct alc_config_preset {
  223. struct snd_kcontrol_new *mixers[5]; /* should be identical size
  224. * with spec
  225. */
  226. const struct hda_verb *init_verbs[5];
  227. unsigned int num_dacs;
  228. hda_nid_t *dac_nids;
  229. hda_nid_t dig_out_nid; /* optional */
  230. hda_nid_t hp_nid; /* optional */
  231. unsigned int num_adc_nids;
  232. hda_nid_t *adc_nids;
  233. hda_nid_t dig_in_nid;
  234. unsigned int num_channel_mode;
  235. const struct hda_channel_mode *channel_mode;
  236. int need_dac_fix;
  237. unsigned int num_mux_defs;
  238. const struct hda_input_mux *input_mux;
  239. void (*unsol_event)(struct hda_codec *, unsigned int);
  240. void (*init_hook)(struct hda_codec *);
  241. };
  242. /*
  243. * input MUX handling
  244. */
  245. static int alc_mux_enum_info(struct snd_kcontrol *kcontrol,
  246. struct snd_ctl_elem_info *uinfo)
  247. {
  248. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  249. struct alc_spec *spec = codec->spec;
  250. unsigned int mux_idx = snd_ctl_get_ioffidx(kcontrol, &uinfo->id);
  251. if (mux_idx >= spec->num_mux_defs)
  252. mux_idx = 0;
  253. return snd_hda_input_mux_info(&spec->input_mux[mux_idx], uinfo);
  254. }
  255. static int alc_mux_enum_get(struct snd_kcontrol *kcontrol,
  256. struct snd_ctl_elem_value *ucontrol)
  257. {
  258. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  259. struct alc_spec *spec = codec->spec;
  260. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  261. ucontrol->value.enumerated.item[0] = spec->cur_mux[adc_idx];
  262. return 0;
  263. }
  264. static int alc_mux_enum_put(struct snd_kcontrol *kcontrol,
  265. struct snd_ctl_elem_value *ucontrol)
  266. {
  267. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  268. struct alc_spec *spec = codec->spec;
  269. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  270. unsigned int mux_idx = adc_idx >= spec->num_mux_defs ? 0 : adc_idx;
  271. return snd_hda_input_mux_put(codec, &spec->input_mux[mux_idx], ucontrol,
  272. spec->adc_nids[adc_idx],
  273. &spec->cur_mux[adc_idx]);
  274. }
  275. /*
  276. * channel mode setting
  277. */
  278. static int alc_ch_mode_info(struct snd_kcontrol *kcontrol,
  279. struct snd_ctl_elem_info *uinfo)
  280. {
  281. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  282. struct alc_spec *spec = codec->spec;
  283. return snd_hda_ch_mode_info(codec, uinfo, spec->channel_mode,
  284. spec->num_channel_mode);
  285. }
  286. static int alc_ch_mode_get(struct snd_kcontrol *kcontrol,
  287. struct snd_ctl_elem_value *ucontrol)
  288. {
  289. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  290. struct alc_spec *spec = codec->spec;
  291. return snd_hda_ch_mode_get(codec, ucontrol, spec->channel_mode,
  292. spec->num_channel_mode,
  293. spec->multiout.max_channels);
  294. }
  295. static int alc_ch_mode_put(struct snd_kcontrol *kcontrol,
  296. struct snd_ctl_elem_value *ucontrol)
  297. {
  298. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  299. struct alc_spec *spec = codec->spec;
  300. int err = snd_hda_ch_mode_put(codec, ucontrol, spec->channel_mode,
  301. spec->num_channel_mode,
  302. &spec->multiout.max_channels);
  303. if (err >= 0 && spec->need_dac_fix)
  304. spec->multiout.num_dacs = spec->multiout.max_channels / 2;
  305. return err;
  306. }
  307. /*
  308. * Control the mode of pin widget settings via the mixer. "pc" is used
  309. * instead of "%" to avoid consequences of accidently treating the % as
  310. * being part of a format specifier. Maximum allowed length of a value is
  311. * 63 characters plus NULL terminator.
  312. *
  313. * Note: some retasking pin complexes seem to ignore requests for input
  314. * states other than HiZ (eg: PIN_VREFxx) and revert to HiZ if any of these
  315. * are requested. Therefore order this list so that this behaviour will not
  316. * cause problems when mixer clients move through the enum sequentially.
  317. * NIDs 0x0f and 0x10 have been observed to have this behaviour as of
  318. * March 2006.
  319. */
  320. static char *alc_pin_mode_names[] = {
  321. "Mic 50pc bias", "Mic 80pc bias",
  322. "Line in", "Line out", "Headphone out",
  323. };
  324. static unsigned char alc_pin_mode_values[] = {
  325. PIN_VREF50, PIN_VREF80, PIN_IN, PIN_OUT, PIN_HP,
  326. };
  327. /* The control can present all 5 options, or it can limit the options based
  328. * in the pin being assumed to be exclusively an input or an output pin. In
  329. * addition, "input" pins may or may not process the mic bias option
  330. * depending on actual widget capability (NIDs 0x0f and 0x10 don't seem to
  331. * accept requests for bias as of chip versions up to March 2006) and/or
  332. * wiring in the computer.
  333. */
  334. #define ALC_PIN_DIR_IN 0x00
  335. #define ALC_PIN_DIR_OUT 0x01
  336. #define ALC_PIN_DIR_INOUT 0x02
  337. #define ALC_PIN_DIR_IN_NOMICBIAS 0x03
  338. #define ALC_PIN_DIR_INOUT_NOMICBIAS 0x04
  339. /* Info about the pin modes supported by the different pin direction modes.
  340. * For each direction the minimum and maximum values are given.
  341. */
  342. static signed char alc_pin_mode_dir_info[5][2] = {
  343. { 0, 2 }, /* ALC_PIN_DIR_IN */
  344. { 3, 4 }, /* ALC_PIN_DIR_OUT */
  345. { 0, 4 }, /* ALC_PIN_DIR_INOUT */
  346. { 2, 2 }, /* ALC_PIN_DIR_IN_NOMICBIAS */
  347. { 2, 4 }, /* ALC_PIN_DIR_INOUT_NOMICBIAS */
  348. };
  349. #define alc_pin_mode_min(_dir) (alc_pin_mode_dir_info[_dir][0])
  350. #define alc_pin_mode_max(_dir) (alc_pin_mode_dir_info[_dir][1])
  351. #define alc_pin_mode_n_items(_dir) \
  352. (alc_pin_mode_max(_dir)-alc_pin_mode_min(_dir)+1)
  353. static int alc_pin_mode_info(struct snd_kcontrol *kcontrol,
  354. struct snd_ctl_elem_info *uinfo)
  355. {
  356. unsigned int item_num = uinfo->value.enumerated.item;
  357. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  358. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  359. uinfo->count = 1;
  360. uinfo->value.enumerated.items = alc_pin_mode_n_items(dir);
  361. if (item_num<alc_pin_mode_min(dir) || item_num>alc_pin_mode_max(dir))
  362. item_num = alc_pin_mode_min(dir);
  363. strcpy(uinfo->value.enumerated.name, alc_pin_mode_names[item_num]);
  364. return 0;
  365. }
  366. static int alc_pin_mode_get(struct snd_kcontrol *kcontrol,
  367. struct snd_ctl_elem_value *ucontrol)
  368. {
  369. unsigned int i;
  370. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  371. hda_nid_t nid = kcontrol->private_value & 0xffff;
  372. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  373. long *valp = ucontrol->value.integer.value;
  374. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  375. AC_VERB_GET_PIN_WIDGET_CONTROL,
  376. 0x00);
  377. /* Find enumerated value for current pinctl setting */
  378. i = alc_pin_mode_min(dir);
  379. while (alc_pin_mode_values[i] != pinctl && i <= alc_pin_mode_max(dir))
  380. i++;
  381. *valp = i <= alc_pin_mode_max(dir) ? i: alc_pin_mode_min(dir);
  382. return 0;
  383. }
  384. static int alc_pin_mode_put(struct snd_kcontrol *kcontrol,
  385. struct snd_ctl_elem_value *ucontrol)
  386. {
  387. signed int change;
  388. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  389. hda_nid_t nid = kcontrol->private_value & 0xffff;
  390. unsigned char dir = (kcontrol->private_value >> 16) & 0xff;
  391. long val = *ucontrol->value.integer.value;
  392. unsigned int pinctl = snd_hda_codec_read(codec, nid, 0,
  393. AC_VERB_GET_PIN_WIDGET_CONTROL,
  394. 0x00);
  395. if (val < alc_pin_mode_min(dir) || val > alc_pin_mode_max(dir))
  396. val = alc_pin_mode_min(dir);
  397. change = pinctl != alc_pin_mode_values[val];
  398. if (change) {
  399. /* Set pin mode to that requested */
  400. snd_hda_codec_write(codec,nid,0,AC_VERB_SET_PIN_WIDGET_CONTROL,
  401. alc_pin_mode_values[val]);
  402. /* Also enable the retasking pin's input/output as required
  403. * for the requested pin mode. Enum values of 2 or less are
  404. * input modes.
  405. *
  406. * Dynamically switching the input/output buffers probably
  407. * reduces noise slightly (particularly on input) so we'll
  408. * do it. However, having both input and output buffers
  409. * enabled simultaneously doesn't seem to be problematic if
  410. * this turns out to be necessary in the future.
  411. */
  412. if (val <= 2) {
  413. snd_hda_codec_write(codec, nid, 0,
  414. AC_VERB_SET_AMP_GAIN_MUTE,
  415. AMP_OUT_MUTE);
  416. snd_hda_codec_write(codec, nid, 0,
  417. AC_VERB_SET_AMP_GAIN_MUTE,
  418. AMP_IN_UNMUTE(0));
  419. } else {
  420. snd_hda_codec_write(codec, nid, 0,
  421. AC_VERB_SET_AMP_GAIN_MUTE,
  422. AMP_IN_MUTE(0));
  423. snd_hda_codec_write(codec, nid, 0,
  424. AC_VERB_SET_AMP_GAIN_MUTE,
  425. AMP_OUT_UNMUTE);
  426. }
  427. }
  428. return change;
  429. }
  430. #define ALC_PIN_MODE(xname, nid, dir) \
  431. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  432. .info = alc_pin_mode_info, \
  433. .get = alc_pin_mode_get, \
  434. .put = alc_pin_mode_put, \
  435. .private_value = nid | (dir<<16) }
  436. /* A switch control for ALC260 GPIO pins. Multiple GPIOs can be ganged
  437. * together using a mask with more than one bit set. This control is
  438. * currently used only by the ALC260 test model. At this stage they are not
  439. * needed for any "production" models.
  440. */
  441. #ifdef CONFIG_SND_DEBUG
  442. #define alc_gpio_data_info snd_ctl_boolean_mono_info
  443. static int alc_gpio_data_get(struct snd_kcontrol *kcontrol,
  444. struct snd_ctl_elem_value *ucontrol)
  445. {
  446. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  447. hda_nid_t nid = kcontrol->private_value & 0xffff;
  448. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  449. long *valp = ucontrol->value.integer.value;
  450. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  451. AC_VERB_GET_GPIO_DATA, 0x00);
  452. *valp = (val & mask) != 0;
  453. return 0;
  454. }
  455. static int alc_gpio_data_put(struct snd_kcontrol *kcontrol,
  456. struct snd_ctl_elem_value *ucontrol)
  457. {
  458. signed int change;
  459. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  460. hda_nid_t nid = kcontrol->private_value & 0xffff;
  461. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  462. long val = *ucontrol->value.integer.value;
  463. unsigned int gpio_data = snd_hda_codec_read(codec, nid, 0,
  464. AC_VERB_GET_GPIO_DATA,
  465. 0x00);
  466. /* Set/unset the masked GPIO bit(s) as needed */
  467. change = (val == 0 ? 0 : mask) != (gpio_data & mask);
  468. if (val == 0)
  469. gpio_data &= ~mask;
  470. else
  471. gpio_data |= mask;
  472. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_GPIO_DATA, gpio_data);
  473. return change;
  474. }
  475. #define ALC_GPIO_DATA_SWITCH(xname, nid, mask) \
  476. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  477. .info = alc_gpio_data_info, \
  478. .get = alc_gpio_data_get, \
  479. .put = alc_gpio_data_put, \
  480. .private_value = nid | (mask<<16) }
  481. #endif /* CONFIG_SND_DEBUG */
  482. /* A switch control to allow the enabling of the digital IO pins on the
  483. * ALC260. This is incredibly simplistic; the intention of this control is
  484. * to provide something in the test model allowing digital outputs to be
  485. * identified if present. If models are found which can utilise these
  486. * outputs a more complete mixer control can be devised for those models if
  487. * necessary.
  488. */
  489. #ifdef CONFIG_SND_DEBUG
  490. #define alc_spdif_ctrl_info snd_ctl_boolean_mono_info
  491. static int alc_spdif_ctrl_get(struct snd_kcontrol *kcontrol,
  492. struct snd_ctl_elem_value *ucontrol)
  493. {
  494. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  495. hda_nid_t nid = kcontrol->private_value & 0xffff;
  496. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  497. long *valp = ucontrol->value.integer.value;
  498. unsigned int val = snd_hda_codec_read(codec, nid, 0,
  499. AC_VERB_GET_DIGI_CONVERT, 0x00);
  500. *valp = (val & mask) != 0;
  501. return 0;
  502. }
  503. static int alc_spdif_ctrl_put(struct snd_kcontrol *kcontrol,
  504. struct snd_ctl_elem_value *ucontrol)
  505. {
  506. signed int change;
  507. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  508. hda_nid_t nid = kcontrol->private_value & 0xffff;
  509. unsigned char mask = (kcontrol->private_value >> 16) & 0xff;
  510. long val = *ucontrol->value.integer.value;
  511. unsigned int ctrl_data = snd_hda_codec_read(codec, nid, 0,
  512. AC_VERB_GET_DIGI_CONVERT,
  513. 0x00);
  514. /* Set/unset the masked control bit(s) as needed */
  515. change = (val == 0 ? 0 : mask) != (ctrl_data & mask);
  516. if (val==0)
  517. ctrl_data &= ~mask;
  518. else
  519. ctrl_data |= mask;
  520. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_DIGI_CONVERT_1,
  521. ctrl_data);
  522. return change;
  523. }
  524. #define ALC_SPDIF_CTRL_SWITCH(xname, nid, mask) \
  525. { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = 0, \
  526. .info = alc_spdif_ctrl_info, \
  527. .get = alc_spdif_ctrl_get, \
  528. .put = alc_spdif_ctrl_put, \
  529. .private_value = nid | (mask<<16) }
  530. #endif /* CONFIG_SND_DEBUG */
  531. /*
  532. * set up from the preset table
  533. */
  534. static void setup_preset(struct alc_spec *spec,
  535. const struct alc_config_preset *preset)
  536. {
  537. int i;
  538. for (i = 0; i < ARRAY_SIZE(preset->mixers) && preset->mixers[i]; i++)
  539. spec->mixers[spec->num_mixers++] = preset->mixers[i];
  540. for (i = 0; i < ARRAY_SIZE(preset->init_verbs) && preset->init_verbs[i];
  541. i++)
  542. spec->init_verbs[spec->num_init_verbs++] =
  543. preset->init_verbs[i];
  544. spec->channel_mode = preset->channel_mode;
  545. spec->num_channel_mode = preset->num_channel_mode;
  546. spec->need_dac_fix = preset->need_dac_fix;
  547. spec->multiout.max_channels = spec->channel_mode[0].channels;
  548. spec->multiout.num_dacs = preset->num_dacs;
  549. spec->multiout.dac_nids = preset->dac_nids;
  550. spec->multiout.dig_out_nid = preset->dig_out_nid;
  551. spec->multiout.hp_nid = preset->hp_nid;
  552. spec->num_mux_defs = preset->num_mux_defs;
  553. if (!spec->num_mux_defs)
  554. spec->num_mux_defs = 1;
  555. spec->input_mux = preset->input_mux;
  556. spec->num_adc_nids = preset->num_adc_nids;
  557. spec->adc_nids = preset->adc_nids;
  558. spec->dig_in_nid = preset->dig_in_nid;
  559. spec->unsol_event = preset->unsol_event;
  560. spec->init_hook = preset->init_hook;
  561. }
  562. /* Enable GPIO mask and set output */
  563. static struct hda_verb alc_gpio1_init_verbs[] = {
  564. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  565. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  566. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  567. { }
  568. };
  569. static struct hda_verb alc_gpio2_init_verbs[] = {
  570. {0x01, AC_VERB_SET_GPIO_MASK, 0x02},
  571. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x02},
  572. {0x01, AC_VERB_SET_GPIO_DATA, 0x02},
  573. { }
  574. };
  575. static struct hda_verb alc_gpio3_init_verbs[] = {
  576. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  577. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  578. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  579. { }
  580. };
  581. /* 32-bit subsystem ID for BIOS loading in HD Audio codec.
  582. * 31 ~ 16 : Manufacture ID
  583. * 15 ~ 8 : SKU ID
  584. * 7 ~ 0 : Assembly ID
  585. * port-A --> pin 39/41, port-E --> pin 14/15, port-D --> pin 35/36
  586. */
  587. static void alc_subsystem_id(struct hda_codec *codec,
  588. unsigned int porta, unsigned int porte,
  589. unsigned int portd)
  590. {
  591. unsigned int ass, tmp;
  592. ass = codec->subsystem_id;
  593. if (!(ass & 1))
  594. return;
  595. /* Override */
  596. tmp = (ass & 0x38) >> 3; /* external Amp control */
  597. switch (tmp) {
  598. case 1:
  599. snd_hda_sequence_write(codec, alc_gpio1_init_verbs);
  600. break;
  601. case 3:
  602. snd_hda_sequence_write(codec, alc_gpio2_init_verbs);
  603. break;
  604. case 7:
  605. snd_hda_sequence_write(codec, alc_gpio3_init_verbs);
  606. break;
  607. case 5:
  608. switch (codec->vendor_id) {
  609. case 0x10ec0862:
  610. case 0x10ec0660:
  611. case 0x10ec0662:
  612. case 0x10ec0267:
  613. case 0x10ec0268:
  614. snd_hda_codec_write(codec, 0x14, 0,
  615. AC_VERB_SET_EAPD_BTLENABLE, 2);
  616. snd_hda_codec_write(codec, 0x15, 0,
  617. AC_VERB_SET_EAPD_BTLENABLE, 2);
  618. return;
  619. }
  620. case 6:
  621. if (ass & 4) { /* bit 2 : 0 = Desktop, 1 = Laptop */
  622. hda_nid_t port = 0;
  623. tmp = (ass & 0x1800) >> 11;
  624. switch (tmp) {
  625. case 0: port = porta; break;
  626. case 1: port = porte; break;
  627. case 2: port = portd; break;
  628. }
  629. if (port)
  630. snd_hda_codec_write(codec, port, 0,
  631. AC_VERB_SET_EAPD_BTLENABLE,
  632. 2);
  633. }
  634. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  635. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF,
  636. (tmp == 5 ? 0x3040 : 0x3050));
  637. break;
  638. }
  639. }
  640. /*
  641. * Fix-up pin default configurations
  642. */
  643. struct alc_pincfg {
  644. hda_nid_t nid;
  645. u32 val;
  646. };
  647. static void alc_fix_pincfg(struct hda_codec *codec,
  648. const struct snd_pci_quirk *quirk,
  649. const struct alc_pincfg **pinfix)
  650. {
  651. const struct alc_pincfg *cfg;
  652. quirk = snd_pci_quirk_lookup(codec->bus->pci, quirk);
  653. if (!quirk)
  654. return;
  655. cfg = pinfix[quirk->value];
  656. for (; cfg->nid; cfg++) {
  657. int i;
  658. u32 val = cfg->val;
  659. for (i = 0; i < 4; i++) {
  660. snd_hda_codec_write(codec, cfg->nid, 0,
  661. AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 + i,
  662. val & 0xff);
  663. val >>= 8;
  664. }
  665. }
  666. }
  667. /*
  668. * ALC880 3-stack model
  669. *
  670. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0e)
  671. * Pin assignment: Front = 0x14, Line-In/Surr = 0x1a, Mic/CLFE = 0x18,
  672. * F-Mic = 0x1b, HP = 0x19
  673. */
  674. static hda_nid_t alc880_dac_nids[4] = {
  675. /* front, rear, clfe, rear_surr */
  676. 0x02, 0x05, 0x04, 0x03
  677. };
  678. static hda_nid_t alc880_adc_nids[3] = {
  679. /* ADC0-2 */
  680. 0x07, 0x08, 0x09,
  681. };
  682. /* The datasheet says the node 0x07 is connected from inputs,
  683. * but it shows zero connection in the real implementation on some devices.
  684. * Note: this is a 915GAV bug, fixed on 915GLV
  685. */
  686. static hda_nid_t alc880_adc_nids_alt[2] = {
  687. /* ADC1-2 */
  688. 0x08, 0x09,
  689. };
  690. #define ALC880_DIGOUT_NID 0x06
  691. #define ALC880_DIGIN_NID 0x0a
  692. static struct hda_input_mux alc880_capture_source = {
  693. .num_items = 4,
  694. .items = {
  695. { "Mic", 0x0 },
  696. { "Front Mic", 0x3 },
  697. { "Line", 0x2 },
  698. { "CD", 0x4 },
  699. },
  700. };
  701. /* channel source setting (2/6 channel selection for 3-stack) */
  702. /* 2ch mode */
  703. static struct hda_verb alc880_threestack_ch2_init[] = {
  704. /* set line-in to input, mute it */
  705. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  706. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  707. /* set mic-in to input vref 80%, mute it */
  708. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  709. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  710. { } /* end */
  711. };
  712. /* 6ch mode */
  713. static struct hda_verb alc880_threestack_ch6_init[] = {
  714. /* set line-in to output, unmute it */
  715. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  716. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  717. /* set mic-in to output, unmute it */
  718. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  719. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  720. { } /* end */
  721. };
  722. static struct hda_channel_mode alc880_threestack_modes[2] = {
  723. { 2, alc880_threestack_ch2_init },
  724. { 6, alc880_threestack_ch6_init },
  725. };
  726. static struct snd_kcontrol_new alc880_three_stack_mixer[] = {
  727. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  728. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  729. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  730. HDA_BIND_MUTE("Surround Playback Switch", 0x0f, 2, HDA_INPUT),
  731. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  732. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  733. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  734. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  735. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  736. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  737. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  738. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  739. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  740. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  741. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x3, HDA_INPUT),
  742. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x3, HDA_INPUT),
  743. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  744. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  745. HDA_CODEC_MUTE("Headphone Playback Switch", 0x19, 0x0, HDA_OUTPUT),
  746. {
  747. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  748. .name = "Channel Mode",
  749. .info = alc_ch_mode_info,
  750. .get = alc_ch_mode_get,
  751. .put = alc_ch_mode_put,
  752. },
  753. { } /* end */
  754. };
  755. /* capture mixer elements */
  756. static struct snd_kcontrol_new alc880_capture_mixer[] = {
  757. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  758. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  759. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  760. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  761. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  762. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  763. {
  764. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  765. /* The multiple "Capture Source" controls confuse alsamixer
  766. * So call somewhat different..
  767. * FIXME: the controls appear in the "playback" view!
  768. */
  769. /* .name = "Capture Source", */
  770. .name = "Input Source",
  771. .count = 3,
  772. .info = alc_mux_enum_info,
  773. .get = alc_mux_enum_get,
  774. .put = alc_mux_enum_put,
  775. },
  776. { } /* end */
  777. };
  778. /* capture mixer elements (in case NID 0x07 not available) */
  779. static struct snd_kcontrol_new alc880_capture_alt_mixer[] = {
  780. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  781. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  782. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  783. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  784. {
  785. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  786. /* The multiple "Capture Source" controls confuse alsamixer
  787. * So call somewhat different..
  788. * FIXME: the controls appear in the "playback" view!
  789. */
  790. /* .name = "Capture Source", */
  791. .name = "Input Source",
  792. .count = 2,
  793. .info = alc_mux_enum_info,
  794. .get = alc_mux_enum_get,
  795. .put = alc_mux_enum_put,
  796. },
  797. { } /* end */
  798. };
  799. /*
  800. * ALC880 5-stack model
  801. *
  802. * DAC: Front = 0x02 (0x0c), Surr = 0x05 (0x0f), CLFE = 0x04 (0x0d),
  803. * Side = 0x02 (0xd)
  804. * Pin assignment: Front = 0x14, Surr = 0x17, CLFE = 0x16
  805. * Line-In/Side = 0x1a, Mic = 0x18, F-Mic = 0x1b, HP = 0x19
  806. */
  807. /* additional mixers to alc880_three_stack_mixer */
  808. static struct snd_kcontrol_new alc880_five_stack_mixer[] = {
  809. HDA_CODEC_VOLUME("Side Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  810. HDA_BIND_MUTE("Side Playback Switch", 0x0d, 2, HDA_INPUT),
  811. { } /* end */
  812. };
  813. /* channel source setting (6/8 channel selection for 5-stack) */
  814. /* 6ch mode */
  815. static struct hda_verb alc880_fivestack_ch6_init[] = {
  816. /* set line-in to input, mute it */
  817. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  818. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  819. { } /* end */
  820. };
  821. /* 8ch mode */
  822. static struct hda_verb alc880_fivestack_ch8_init[] = {
  823. /* set line-in to output, unmute it */
  824. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  825. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  826. { } /* end */
  827. };
  828. static struct hda_channel_mode alc880_fivestack_modes[2] = {
  829. { 6, alc880_fivestack_ch6_init },
  830. { 8, alc880_fivestack_ch8_init },
  831. };
  832. /*
  833. * ALC880 6-stack model
  834. *
  835. * DAC: Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e),
  836. * Side = 0x05 (0x0f)
  837. * Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, Side = 0x17,
  838. * Mic = 0x18, F-Mic = 0x19, Line = 0x1a, HP = 0x1b
  839. */
  840. static hda_nid_t alc880_6st_dac_nids[4] = {
  841. /* front, rear, clfe, rear_surr */
  842. 0x02, 0x03, 0x04, 0x05
  843. };
  844. static struct hda_input_mux alc880_6stack_capture_source = {
  845. .num_items = 4,
  846. .items = {
  847. { "Mic", 0x0 },
  848. { "Front Mic", 0x1 },
  849. { "Line", 0x2 },
  850. { "CD", 0x4 },
  851. },
  852. };
  853. /* fixed 8-channels */
  854. static struct hda_channel_mode alc880_sixstack_modes[1] = {
  855. { 8, NULL },
  856. };
  857. static struct snd_kcontrol_new alc880_six_stack_mixer[] = {
  858. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  859. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  860. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  861. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  862. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  863. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  864. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  865. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  866. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  867. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  868. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  869. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  870. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  871. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  872. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  873. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  874. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  875. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  876. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  877. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  878. {
  879. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  880. .name = "Channel Mode",
  881. .info = alc_ch_mode_info,
  882. .get = alc_ch_mode_get,
  883. .put = alc_ch_mode_put,
  884. },
  885. { } /* end */
  886. };
  887. /*
  888. * ALC880 W810 model
  889. *
  890. * W810 has rear IO for:
  891. * Front (DAC 02)
  892. * Surround (DAC 03)
  893. * Center/LFE (DAC 04)
  894. * Digital out (06)
  895. *
  896. * The system also has a pair of internal speakers, and a headphone jack.
  897. * These are both connected to Line2 on the codec, hence to DAC 02.
  898. *
  899. * There is a variable resistor to control the speaker or headphone
  900. * volume. This is a hardware-only device without a software API.
  901. *
  902. * Plugging headphones in will disable the internal speakers. This is
  903. * implemented in hardware, not via the driver using jack sense. In
  904. * a similar fashion, plugging into the rear socket marked "front" will
  905. * disable both the speakers and headphones.
  906. *
  907. * For input, there's a microphone jack, and an "audio in" jack.
  908. * These may not do anything useful with this driver yet, because I
  909. * haven't setup any initialization verbs for these yet...
  910. */
  911. static hda_nid_t alc880_w810_dac_nids[3] = {
  912. /* front, rear/surround, clfe */
  913. 0x02, 0x03, 0x04
  914. };
  915. /* fixed 6 channels */
  916. static struct hda_channel_mode alc880_w810_modes[1] = {
  917. { 6, NULL }
  918. };
  919. /* Pin assignment: Front = 0x14, Surr = 0x15, CLFE = 0x16, HP = 0x1b */
  920. static struct snd_kcontrol_new alc880_w810_base_mixer[] = {
  921. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  922. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  923. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  924. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  925. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  926. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  927. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  928. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  929. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  930. { } /* end */
  931. };
  932. /*
  933. * Z710V model
  934. *
  935. * DAC: Front = 0x02 (0x0c), HP = 0x03 (0x0d)
  936. * Pin assignment: Front = 0x14, HP = 0x15, Mic = 0x18, Mic2 = 0x19(?),
  937. * Line = 0x1a
  938. */
  939. static hda_nid_t alc880_z71v_dac_nids[1] = {
  940. 0x02
  941. };
  942. #define ALC880_Z71V_HP_DAC 0x03
  943. /* fixed 2 channels */
  944. static struct hda_channel_mode alc880_2_jack_modes[1] = {
  945. { 2, NULL }
  946. };
  947. static struct snd_kcontrol_new alc880_z71v_mixer[] = {
  948. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  949. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  950. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  951. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  952. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  953. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  954. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  955. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  956. { } /* end */
  957. };
  958. /* FIXME! */
  959. /*
  960. * ALC880 F1734 model
  961. *
  962. * DAC: HP = 0x02 (0x0c), Front = 0x03 (0x0d)
  963. * Pin assignment: HP = 0x14, Front = 0x15, Mic = 0x18
  964. */
  965. static hda_nid_t alc880_f1734_dac_nids[1] = {
  966. 0x03
  967. };
  968. #define ALC880_F1734_HP_DAC 0x02
  969. static struct snd_kcontrol_new alc880_f1734_mixer[] = {
  970. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  971. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  972. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  973. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  974. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  975. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  976. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  977. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  978. { } /* end */
  979. };
  980. /* FIXME! */
  981. /*
  982. * ALC880 ASUS model
  983. *
  984. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  985. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  986. * Mic = 0x18, Line = 0x1a
  987. */
  988. #define alc880_asus_dac_nids alc880_w810_dac_nids /* identical with w810 */
  989. #define alc880_asus_modes alc880_threestack_modes /* 2/6 channel mode */
  990. static struct snd_kcontrol_new alc880_asus_mixer[] = {
  991. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  992. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  993. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  994. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  995. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  996. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  997. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  998. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  999. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1000. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1001. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1002. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1003. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1004. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1005. {
  1006. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1007. .name = "Channel Mode",
  1008. .info = alc_ch_mode_info,
  1009. .get = alc_ch_mode_get,
  1010. .put = alc_ch_mode_put,
  1011. },
  1012. { } /* end */
  1013. };
  1014. /* FIXME! */
  1015. /*
  1016. * ALC880 ASUS W1V model
  1017. *
  1018. * DAC: HP/Front = 0x02 (0x0c), Surr = 0x03 (0x0d), CLFE = 0x04 (0x0e)
  1019. * Pin assignment: HP/Front = 0x14, Surr = 0x15, CLFE = 0x16,
  1020. * Mic = 0x18, Line = 0x1a, Line2 = 0x1b
  1021. */
  1022. /* additional mixers to alc880_asus_mixer */
  1023. static struct snd_kcontrol_new alc880_asus_w1v_mixer[] = {
  1024. HDA_CODEC_VOLUME("Line2 Playback Volume", 0x0b, 0x03, HDA_INPUT),
  1025. HDA_CODEC_MUTE("Line2 Playback Switch", 0x0b, 0x03, HDA_INPUT),
  1026. { } /* end */
  1027. };
  1028. /* additional mixers to alc880_asus_mixer */
  1029. static struct snd_kcontrol_new alc880_pcbeep_mixer[] = {
  1030. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1031. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1032. { } /* end */
  1033. };
  1034. /* TCL S700 */
  1035. static struct snd_kcontrol_new alc880_tcl_s700_mixer[] = {
  1036. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1037. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  1038. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  1039. HDA_CODEC_VOLUME("CD Playback Volume", 0x0B, 0x04, HDA_INPUT),
  1040. HDA_CODEC_MUTE("CD Playback Switch", 0x0B, 0x04, HDA_INPUT),
  1041. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0B, 0x0, HDA_INPUT),
  1042. HDA_CODEC_MUTE("Mic Playback Switch", 0x0B, 0x0, HDA_INPUT),
  1043. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  1044. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  1045. {
  1046. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1047. /* The multiple "Capture Source" controls confuse alsamixer
  1048. * So call somewhat different..
  1049. * FIXME: the controls appear in the "playback" view!
  1050. */
  1051. /* .name = "Capture Source", */
  1052. .name = "Input Source",
  1053. .count = 1,
  1054. .info = alc_mux_enum_info,
  1055. .get = alc_mux_enum_get,
  1056. .put = alc_mux_enum_put,
  1057. },
  1058. { } /* end */
  1059. };
  1060. /* Uniwill */
  1061. static struct snd_kcontrol_new alc880_uniwill_mixer[] = {
  1062. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1063. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1064. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1065. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1066. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  1067. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  1068. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  1069. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  1070. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1071. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1072. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  1073. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  1074. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1075. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1076. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1077. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1078. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  1079. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  1080. {
  1081. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1082. .name = "Channel Mode",
  1083. .info = alc_ch_mode_info,
  1084. .get = alc_ch_mode_get,
  1085. .put = alc_ch_mode_put,
  1086. },
  1087. { } /* end */
  1088. };
  1089. static struct snd_kcontrol_new alc880_fujitsu_mixer[] = {
  1090. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1091. HDA_BIND_MUTE("Headphone Playback Switch", 0x0c, 2, HDA_INPUT),
  1092. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1093. HDA_BIND_MUTE("Speaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1094. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  1095. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  1096. HDA_CODEC_VOLUME("Ext Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1097. HDA_CODEC_MUTE("Ext Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1098. HDA_CODEC_VOLUME("Int Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1099. HDA_CODEC_MUTE("Int Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1100. { } /* end */
  1101. };
  1102. static struct snd_kcontrol_new alc880_uniwill_p53_mixer[] = {
  1103. HDA_CODEC_VOLUME("HPhone Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1104. HDA_BIND_MUTE("HPhone Playback Switch", 0x0c, 2, HDA_INPUT),
  1105. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  1106. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  1107. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  1108. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  1109. { } /* end */
  1110. };
  1111. /*
  1112. * build control elements
  1113. */
  1114. static int alc_build_controls(struct hda_codec *codec)
  1115. {
  1116. struct alc_spec *spec = codec->spec;
  1117. int err;
  1118. int i;
  1119. for (i = 0; i < spec->num_mixers; i++) {
  1120. err = snd_hda_add_new_ctls(codec, spec->mixers[i]);
  1121. if (err < 0)
  1122. return err;
  1123. }
  1124. if (spec->multiout.dig_out_nid) {
  1125. err = snd_hda_create_spdif_out_ctls(codec,
  1126. spec->multiout.dig_out_nid);
  1127. if (err < 0)
  1128. return err;
  1129. }
  1130. if (spec->dig_in_nid) {
  1131. err = snd_hda_create_spdif_in_ctls(codec, spec->dig_in_nid);
  1132. if (err < 0)
  1133. return err;
  1134. }
  1135. return 0;
  1136. }
  1137. /*
  1138. * initialize the codec volumes, etc
  1139. */
  1140. /*
  1141. * generic initialization of ADC, input mixers and output mixers
  1142. */
  1143. static struct hda_verb alc880_volume_init_verbs[] = {
  1144. /*
  1145. * Unmute ADC0-2 and set the default input to mic-in
  1146. */
  1147. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  1148. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1149. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  1150. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1151. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  1152. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1153. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  1154. * mixer widget
  1155. * Note: PASD motherboards uses the Line In 2 as the input for front
  1156. * panel mic (mic 2)
  1157. */
  1158. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  1159. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  1160. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1161. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  1162. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  1163. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  1164. /*
  1165. * Set up output mixers (0x0c - 0x0f)
  1166. */
  1167. /* set vol=0 to output mixers */
  1168. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1169. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1170. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1171. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  1172. /* set up input amps for analog loopback */
  1173. /* Amp Indices: DAC = 0, mixer = 1 */
  1174. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1175. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1176. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1177. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1178. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1179. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1180. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  1181. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  1182. { }
  1183. };
  1184. /*
  1185. * 3-stack pin configuration:
  1186. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  1187. */
  1188. static struct hda_verb alc880_pin_3stack_init_verbs[] = {
  1189. /*
  1190. * preset connection lists of input pins
  1191. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1192. */
  1193. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  1194. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1195. {0x12, AC_VERB_SET_CONNECT_SEL, 0x03}, /* line/surround */
  1196. /*
  1197. * Set pin mode and muting
  1198. */
  1199. /* set front pin widgets 0x14 for output */
  1200. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1201. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1202. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1203. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1204. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1205. /* Mic2 (as headphone out) for HP output */
  1206. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1207. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1208. /* Line In pin widget for input */
  1209. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1210. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1211. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1212. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1213. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1214. /* CD pin widget for input */
  1215. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1216. { }
  1217. };
  1218. /*
  1219. * 5-stack pin configuration:
  1220. * front = 0x14, surround = 0x17, clfe = 0x16, mic = 0x18, HP = 0x19,
  1221. * line-in/side = 0x1a, f-mic = 0x1b
  1222. */
  1223. static struct hda_verb alc880_pin_5stack_init_verbs[] = {
  1224. /*
  1225. * preset connection lists of input pins
  1226. * 0 = front, 1 = rear_surr, 2 = CLFE, 3 = surround
  1227. */
  1228. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1229. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/side */
  1230. /*
  1231. * Set pin mode and muting
  1232. */
  1233. /* set pin widgets 0x14-0x17 for output */
  1234. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1235. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1236. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1237. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1238. /* unmute pins for output (no gain on this amp) */
  1239. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1240. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1241. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1242. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1243. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1244. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1245. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1246. /* Mic2 (as headphone out) for HP output */
  1247. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1248. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1249. /* Line In pin widget for input */
  1250. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1251. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1252. /* Line2 (as front mic) pin widget for input and vref at 80% */
  1253. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1254. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1255. /* CD pin widget for input */
  1256. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1257. { }
  1258. };
  1259. /*
  1260. * W810 pin configuration:
  1261. * front = 0x14, surround = 0x15, clfe = 0x16, HP = 0x1b
  1262. */
  1263. static struct hda_verb alc880_pin_w810_init_verbs[] = {
  1264. /* hphone/speaker input selector: front DAC */
  1265. {0x13, AC_VERB_SET_CONNECT_SEL, 0x0},
  1266. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1267. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1268. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1269. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1270. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1271. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1272. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1273. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1274. { }
  1275. };
  1276. /*
  1277. * Z71V pin configuration:
  1278. * Speaker-out = 0x14, HP = 0x15, Mic = 0x18, Line-in = 0x1a, Mic2 = 0x1b (?)
  1279. */
  1280. static struct hda_verb alc880_pin_z71v_init_verbs[] = {
  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_HP},
  1284. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1285. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1286. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1287. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1288. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1289. { }
  1290. };
  1291. /*
  1292. * 6-stack pin configuration:
  1293. * front = 0x14, surr = 0x15, clfe = 0x16, side = 0x17, mic = 0x18,
  1294. * f-mic = 0x19, line = 0x1a, HP = 0x1b
  1295. */
  1296. static struct hda_verb alc880_pin_6stack_init_verbs[] = {
  1297. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1298. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1299. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1300. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1301. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1302. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1303. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1304. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1305. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1306. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1307. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1308. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1309. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1310. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1311. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1312. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1313. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1314. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1315. { }
  1316. };
  1317. /*
  1318. * Uniwill pin configuration:
  1319. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x18, internal mic = 0x19,
  1320. * line = 0x1a
  1321. */
  1322. static struct hda_verb alc880_uniwill_init_verbs[] = {
  1323. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1324. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1325. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1326. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1327. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1328. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1329. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1330. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1331. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1332. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1333. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1334. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1335. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1336. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1337. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1338. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1339. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1340. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1341. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1342. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1343. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1344. /* {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP}, */
  1345. /* {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE}, */
  1346. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1347. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1348. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  1349. { }
  1350. };
  1351. /*
  1352. * Uniwill P53
  1353. * HP = 0x14, InternalSpeaker = 0x15, mic = 0x19,
  1354. */
  1355. static struct hda_verb alc880_uniwill_p53_init_verbs[] = {
  1356. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  1357. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1358. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1359. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1360. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1361. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1362. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1363. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1364. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1365. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1366. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1367. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  1368. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  1369. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1370. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1371. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1372. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1373. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1374. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1375. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  1376. {0x21, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_DCVOL_EVENT},
  1377. { }
  1378. };
  1379. static struct hda_verb alc880_beep_init_verbs[] = {
  1380. { 0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5) },
  1381. { }
  1382. };
  1383. /* toggle speaker-output according to the hp-jack state */
  1384. static void alc880_uniwill_hp_automute(struct hda_codec *codec)
  1385. {
  1386. unsigned int present;
  1387. unsigned char bits;
  1388. present = snd_hda_codec_read(codec, 0x14, 0,
  1389. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1390. bits = present ? 0x80 : 0;
  1391. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  1392. 0x80, bits);
  1393. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  1394. 0x80, bits);
  1395. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_OUTPUT, 0,
  1396. 0x80, bits);
  1397. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_OUTPUT, 0,
  1398. 0x80, bits);
  1399. }
  1400. /* auto-toggle front mic */
  1401. static void alc880_uniwill_mic_automute(struct hda_codec *codec)
  1402. {
  1403. unsigned int present;
  1404. unsigned char bits;
  1405. present = snd_hda_codec_read(codec, 0x18, 0,
  1406. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1407. bits = present ? 0x80 : 0;
  1408. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  1409. 0x80, bits);
  1410. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  1411. 0x80, bits);
  1412. }
  1413. static void alc880_uniwill_automute(struct hda_codec *codec)
  1414. {
  1415. alc880_uniwill_hp_automute(codec);
  1416. alc880_uniwill_mic_automute(codec);
  1417. }
  1418. static void alc880_uniwill_unsol_event(struct hda_codec *codec,
  1419. unsigned int res)
  1420. {
  1421. /* Looks like the unsol event is incompatible with the standard
  1422. * definition. 4bit tag is placed at 28 bit!
  1423. */
  1424. switch (res >> 28) {
  1425. case ALC880_HP_EVENT:
  1426. alc880_uniwill_hp_automute(codec);
  1427. break;
  1428. case ALC880_MIC_EVENT:
  1429. alc880_uniwill_mic_automute(codec);
  1430. break;
  1431. }
  1432. }
  1433. static void alc880_uniwill_p53_hp_automute(struct hda_codec *codec)
  1434. {
  1435. unsigned int present;
  1436. unsigned char bits;
  1437. present = snd_hda_codec_read(codec, 0x14, 0,
  1438. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1439. bits = present ? 0x80 : 0;
  1440. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_INPUT, 0,
  1441. 0x80, bits);
  1442. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_INPUT, 0,
  1443. 0x80, bits);
  1444. }
  1445. static void alc880_uniwill_p53_dcvol_automute(struct hda_codec *codec)
  1446. {
  1447. unsigned int present;
  1448. present = snd_hda_codec_read(codec, 0x21, 0,
  1449. AC_VERB_GET_VOLUME_KNOB_CONTROL, 0) & 0x7f;
  1450. snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  1451. 0x7f, present);
  1452. snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  1453. 0x7f, present);
  1454. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  1455. 0x7f, present);
  1456. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  1457. 0x7f, present);
  1458. }
  1459. static void alc880_uniwill_p53_unsol_event(struct hda_codec *codec,
  1460. unsigned int res)
  1461. {
  1462. /* Looks like the unsol event is incompatible with the standard
  1463. * definition. 4bit tag is placed at 28 bit!
  1464. */
  1465. if ((res >> 28) == ALC880_HP_EVENT)
  1466. alc880_uniwill_p53_hp_automute(codec);
  1467. if ((res >> 28) == ALC880_DCVOL_EVENT)
  1468. alc880_uniwill_p53_dcvol_automute(codec);
  1469. }
  1470. /* FIXME! */
  1471. /*
  1472. * F1734 pin configuration:
  1473. * HP = 0x14, speaker-out = 0x15, mic = 0x18
  1474. */
  1475. static struct hda_verb alc880_pin_f1734_init_verbs[] = {
  1476. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1477. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1478. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1479. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1480. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1481. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1482. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1483. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1484. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1485. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1486. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1487. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1488. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1489. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1490. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1491. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1492. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1493. { }
  1494. };
  1495. /* FIXME! */
  1496. /*
  1497. * ASUS pin configuration:
  1498. * HP/front = 0x14, surr = 0x15, clfe = 0x16, mic = 0x18, line = 0x1a
  1499. */
  1500. static struct hda_verb alc880_pin_asus_init_verbs[] = {
  1501. {0x10, AC_VERB_SET_CONNECT_SEL, 0x02},
  1502. {0x11, AC_VERB_SET_CONNECT_SEL, 0x00},
  1503. {0x12, AC_VERB_SET_CONNECT_SEL, 0x01},
  1504. {0x13, AC_VERB_SET_CONNECT_SEL, 0x00},
  1505. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1506. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1507. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1508. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1509. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1510. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1511. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1512. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1513. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1514. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1515. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1516. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1517. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1518. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  1519. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1520. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1521. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1522. { }
  1523. };
  1524. /* Enable GPIO mask and set output */
  1525. #define alc880_gpio1_init_verbs alc_gpio1_init_verbs
  1526. #define alc880_gpio2_init_verbs alc_gpio2_init_verbs
  1527. /* Clevo m520g init */
  1528. static struct hda_verb alc880_pin_clevo_init_verbs[] = {
  1529. /* headphone output */
  1530. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1531. /* line-out */
  1532. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1533. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1534. /* Line-in */
  1535. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1536. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1537. /* CD */
  1538. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1539. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1540. /* Mic1 (rear panel) */
  1541. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1542. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1543. /* Mic2 (front panel) */
  1544. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1545. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1546. /* headphone */
  1547. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1548. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1549. /* change to EAPD mode */
  1550. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1551. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1552. { }
  1553. };
  1554. static struct hda_verb alc880_pin_tcl_S700_init_verbs[] = {
  1555. /* change to EAPD mode */
  1556. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1557. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  1558. /* Headphone output */
  1559. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1560. /* Front output*/
  1561. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  1562. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  1563. /* Line In pin widget for input */
  1564. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1565. /* CD pin widget for input */
  1566. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1567. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  1568. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1569. /* change to EAPD mode */
  1570. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  1571. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  1572. { }
  1573. };
  1574. /*
  1575. * LG m1 express dual
  1576. *
  1577. * Pin assignment:
  1578. * Rear Line-In/Out (blue): 0x14
  1579. * Build-in Mic-In: 0x15
  1580. * Speaker-out: 0x17
  1581. * HP-Out (green): 0x1b
  1582. * Mic-In/Out (red): 0x19
  1583. * SPDIF-Out: 0x1e
  1584. */
  1585. /* To make 5.1 output working (green=Front, blue=Surr, red=CLFE) */
  1586. static hda_nid_t alc880_lg_dac_nids[3] = {
  1587. 0x05, 0x02, 0x03
  1588. };
  1589. /* seems analog CD is not working */
  1590. static struct hda_input_mux alc880_lg_capture_source = {
  1591. .num_items = 3,
  1592. .items = {
  1593. { "Mic", 0x1 },
  1594. { "Line", 0x5 },
  1595. { "Internal Mic", 0x6 },
  1596. },
  1597. };
  1598. /* 2,4,6 channel modes */
  1599. static struct hda_verb alc880_lg_ch2_init[] = {
  1600. /* set line-in and mic-in to input */
  1601. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  1602. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1603. { }
  1604. };
  1605. static struct hda_verb alc880_lg_ch4_init[] = {
  1606. /* set line-in to out and mic-in to input */
  1607. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1608. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  1609. { }
  1610. };
  1611. static struct hda_verb alc880_lg_ch6_init[] = {
  1612. /* set line-in and mic-in to output */
  1613. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1614. { 0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP },
  1615. { }
  1616. };
  1617. static struct hda_channel_mode alc880_lg_ch_modes[3] = {
  1618. { 2, alc880_lg_ch2_init },
  1619. { 4, alc880_lg_ch4_init },
  1620. { 6, alc880_lg_ch6_init },
  1621. };
  1622. static struct snd_kcontrol_new alc880_lg_mixer[] = {
  1623. /* FIXME: it's not really "master" but front channels */
  1624. HDA_CODEC_VOLUME("Master Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  1625. HDA_BIND_MUTE("Master Playback Switch", 0x0f, 2, HDA_INPUT),
  1626. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  1627. HDA_BIND_MUTE("Surround Playback Switch", 0x0c, 2, HDA_INPUT),
  1628. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  1629. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  1630. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  1631. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  1632. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  1633. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  1634. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x06, HDA_INPUT),
  1635. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x06, HDA_INPUT),
  1636. HDA_CODEC_VOLUME("Internal Mic Playback Volume", 0x0b, 0x07, HDA_INPUT),
  1637. HDA_CODEC_MUTE("Internal Mic Playback Switch", 0x0b, 0x07, HDA_INPUT),
  1638. {
  1639. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  1640. .name = "Channel Mode",
  1641. .info = alc_ch_mode_info,
  1642. .get = alc_ch_mode_get,
  1643. .put = alc_ch_mode_put,
  1644. },
  1645. { } /* end */
  1646. };
  1647. static struct hda_verb alc880_lg_init_verbs[] = {
  1648. /* set capture source to mic-in */
  1649. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1650. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1651. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  1652. /* mute all amp mixer inputs */
  1653. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  1654. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  1655. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  1656. /* line-in to input */
  1657. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  1658. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1659. /* built-in mic */
  1660. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1661. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1662. /* speaker-out */
  1663. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1664. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1665. /* mic-in to input */
  1666. {0x11, AC_VERB_SET_CONNECT_SEL, 0x01},
  1667. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  1668. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1669. /* HP-out */
  1670. {0x13, AC_VERB_SET_CONNECT_SEL, 0x03},
  1671. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  1672. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  1673. /* jack sense */
  1674. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | 0x1},
  1675. { }
  1676. };
  1677. /* toggle speaker-output according to the hp-jack state */
  1678. static void alc880_lg_automute(struct hda_codec *codec)
  1679. {
  1680. unsigned int present;
  1681. unsigned char bits;
  1682. present = snd_hda_codec_read(codec, 0x1b, 0,
  1683. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  1684. bits = present ? 0x80 : 0;
  1685. snd_hda_codec_amp_update(codec, 0x17, 0, HDA_OUTPUT, 0,
  1686. 0x80, bits);
  1687. snd_hda_codec_amp_update(codec, 0x17, 1, HDA_OUTPUT, 0,
  1688. 0x80, 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_UNMUTE(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 ? 0x80 : 0;
  1775. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  1776. 0x80, bits);
  1777. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  1778. 0x80, bits);
  1779. }
  1780. static void alc880_lg_lw_unsol_event(struct hda_codec *codec, unsigned int res)
  1781. {
  1782. /* Looks like the unsol event is incompatible with the standard
  1783. * definition. 4bit tag is placed at 28 bit!
  1784. */
  1785. if ((res >> 28) == 0x01)
  1786. alc880_lg_lw_automute(codec);
  1787. }
  1788. /*
  1789. * Common callbacks
  1790. */
  1791. static int alc_init(struct hda_codec *codec)
  1792. {
  1793. struct alc_spec *spec = codec->spec;
  1794. unsigned int i;
  1795. for (i = 0; i < spec->num_init_verbs; i++)
  1796. snd_hda_sequence_write(codec, spec->init_verbs[i]);
  1797. if (spec->init_hook)
  1798. spec->init_hook(codec);
  1799. return 0;
  1800. }
  1801. static void alc_unsol_event(struct hda_codec *codec, unsigned int res)
  1802. {
  1803. struct alc_spec *spec = codec->spec;
  1804. if (spec->unsol_event)
  1805. spec->unsol_event(codec, res);
  1806. }
  1807. #ifdef CONFIG_PM
  1808. /*
  1809. * resume
  1810. */
  1811. static int alc_resume(struct hda_codec *codec)
  1812. {
  1813. struct alc_spec *spec = codec->spec;
  1814. int i;
  1815. alc_init(codec);
  1816. for (i = 0; i < spec->num_mixers; i++)
  1817. snd_hda_resume_ctls(codec, spec->mixers[i]);
  1818. if (spec->multiout.dig_out_nid)
  1819. snd_hda_resume_spdif_out(codec);
  1820. if (spec->dig_in_nid)
  1821. snd_hda_resume_spdif_in(codec);
  1822. return 0;
  1823. }
  1824. #endif
  1825. /*
  1826. * Analog playback callbacks
  1827. */
  1828. static int alc880_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1829. struct hda_codec *codec,
  1830. struct snd_pcm_substream *substream)
  1831. {
  1832. struct alc_spec *spec = codec->spec;
  1833. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream);
  1834. }
  1835. static int alc880_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1836. struct hda_codec *codec,
  1837. unsigned int stream_tag,
  1838. unsigned int format,
  1839. struct snd_pcm_substream *substream)
  1840. {
  1841. struct alc_spec *spec = codec->spec;
  1842. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  1843. stream_tag, format, substream);
  1844. }
  1845. static int alc880_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1846. struct hda_codec *codec,
  1847. struct snd_pcm_substream *substream)
  1848. {
  1849. struct alc_spec *spec = codec->spec;
  1850. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  1851. }
  1852. /*
  1853. * Digital out
  1854. */
  1855. static int alc880_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  1856. struct hda_codec *codec,
  1857. struct snd_pcm_substream *substream)
  1858. {
  1859. struct alc_spec *spec = codec->spec;
  1860. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1861. }
  1862. static int alc880_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1863. struct hda_codec *codec,
  1864. unsigned int stream_tag,
  1865. unsigned int format,
  1866. struct snd_pcm_substream *substream)
  1867. {
  1868. struct alc_spec *spec = codec->spec;
  1869. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1870. stream_tag, format, substream);
  1871. }
  1872. static int alc880_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1873. struct hda_codec *codec,
  1874. struct snd_pcm_substream *substream)
  1875. {
  1876. struct alc_spec *spec = codec->spec;
  1877. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1878. }
  1879. /*
  1880. * Analog capture
  1881. */
  1882. static int alc880_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  1883. struct hda_codec *codec,
  1884. unsigned int stream_tag,
  1885. unsigned int format,
  1886. struct snd_pcm_substream *substream)
  1887. {
  1888. struct alc_spec *spec = codec->spec;
  1889. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1890. stream_tag, 0, format);
  1891. return 0;
  1892. }
  1893. static int alc880_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  1894. struct hda_codec *codec,
  1895. struct snd_pcm_substream *substream)
  1896. {
  1897. struct alc_spec *spec = codec->spec;
  1898. snd_hda_codec_setup_stream(codec, spec->adc_nids[substream->number],
  1899. 0, 0, 0);
  1900. return 0;
  1901. }
  1902. /*
  1903. */
  1904. static struct hda_pcm_stream alc880_pcm_analog_playback = {
  1905. .substreams = 1,
  1906. .channels_min = 2,
  1907. .channels_max = 8,
  1908. /* NID is set in alc_build_pcms */
  1909. .ops = {
  1910. .open = alc880_playback_pcm_open,
  1911. .prepare = alc880_playback_pcm_prepare,
  1912. .cleanup = alc880_playback_pcm_cleanup
  1913. },
  1914. };
  1915. static struct hda_pcm_stream alc880_pcm_analog_capture = {
  1916. .substreams = 2,
  1917. .channels_min = 2,
  1918. .channels_max = 2,
  1919. /* NID is set in alc_build_pcms */
  1920. .ops = {
  1921. .prepare = alc880_capture_pcm_prepare,
  1922. .cleanup = alc880_capture_pcm_cleanup
  1923. },
  1924. };
  1925. static struct hda_pcm_stream alc880_pcm_digital_playback = {
  1926. .substreams = 1,
  1927. .channels_min = 2,
  1928. .channels_max = 2,
  1929. /* NID is set in alc_build_pcms */
  1930. .ops = {
  1931. .open = alc880_dig_playback_pcm_open,
  1932. .close = alc880_dig_playback_pcm_close,
  1933. .prepare = alc880_dig_playback_pcm_prepare
  1934. },
  1935. };
  1936. static struct hda_pcm_stream alc880_pcm_digital_capture = {
  1937. .substreams = 1,
  1938. .channels_min = 2,
  1939. .channels_max = 2,
  1940. /* NID is set in alc_build_pcms */
  1941. };
  1942. /* Used by alc_build_pcms to flag that a PCM has no playback stream */
  1943. static struct hda_pcm_stream alc_pcm_null_playback = {
  1944. .substreams = 0,
  1945. .channels_min = 0,
  1946. .channels_max = 0,
  1947. };
  1948. static int alc_build_pcms(struct hda_codec *codec)
  1949. {
  1950. struct alc_spec *spec = codec->spec;
  1951. struct hda_pcm *info = spec->pcm_rec;
  1952. int i;
  1953. codec->num_pcms = 1;
  1954. codec->pcm_info = info;
  1955. info->name = spec->stream_name_analog;
  1956. if (spec->stream_analog_playback) {
  1957. snd_assert(spec->multiout.dac_nids, return -EINVAL);
  1958. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_analog_playback);
  1959. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dac_nids[0];
  1960. }
  1961. if (spec->stream_analog_capture) {
  1962. snd_assert(spec->adc_nids, return -EINVAL);
  1963. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  1964. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[0];
  1965. }
  1966. if (spec->channel_mode) {
  1967. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = 0;
  1968. for (i = 0; i < spec->num_channel_mode; i++) {
  1969. if (spec->channel_mode[i].channels > info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max) {
  1970. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max = spec->channel_mode[i].channels;
  1971. }
  1972. }
  1973. }
  1974. /* SPDIF for stream index #1 */
  1975. if (spec->multiout.dig_out_nid || spec->dig_in_nid) {
  1976. codec->num_pcms = 2;
  1977. info = spec->pcm_rec + 1;
  1978. info->name = spec->stream_name_digital;
  1979. if (spec->multiout.dig_out_nid &&
  1980. spec->stream_digital_playback) {
  1981. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = *(spec->stream_digital_playback);
  1982. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->multiout.dig_out_nid;
  1983. }
  1984. if (spec->dig_in_nid &&
  1985. spec->stream_digital_capture) {
  1986. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_digital_capture);
  1987. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in_nid;
  1988. }
  1989. }
  1990. /* If the use of more than one ADC is requested for the current
  1991. * model, configure a second analog capture-only PCM.
  1992. */
  1993. /* Additional Analaog capture for index #2 */
  1994. if (spec->num_adc_nids > 1 && spec->stream_analog_capture &&
  1995. spec->adc_nids) {
  1996. codec->num_pcms = 3;
  1997. info = spec->pcm_rec + 2;
  1998. info->name = spec->stream_name_analog;
  1999. /* No playback stream for second PCM */
  2000. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = alc_pcm_null_playback;
  2001. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = 0;
  2002. if (spec->stream_analog_capture) {
  2003. info->stream[SNDRV_PCM_STREAM_CAPTURE] = *(spec->stream_analog_capture);
  2004. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->adc_nids[1];
  2005. }
  2006. }
  2007. return 0;
  2008. }
  2009. static void alc_free(struct hda_codec *codec)
  2010. {
  2011. struct alc_spec *spec = codec->spec;
  2012. unsigned int i;
  2013. if (!spec)
  2014. return;
  2015. if (spec->kctl_alloc) {
  2016. for (i = 0; i < spec->num_kctl_used; i++)
  2017. kfree(spec->kctl_alloc[i].name);
  2018. kfree(spec->kctl_alloc);
  2019. }
  2020. kfree(spec);
  2021. }
  2022. /*
  2023. */
  2024. static struct hda_codec_ops alc_patch_ops = {
  2025. .build_controls = alc_build_controls,
  2026. .build_pcms = alc_build_pcms,
  2027. .init = alc_init,
  2028. .free = alc_free,
  2029. .unsol_event = alc_unsol_event,
  2030. #ifdef CONFIG_PM
  2031. .resume = alc_resume,
  2032. #endif
  2033. };
  2034. /*
  2035. * Test configuration for debugging
  2036. *
  2037. * Almost all inputs/outputs are enabled. I/O pins can be configured via
  2038. * enum controls.
  2039. */
  2040. #ifdef CONFIG_SND_DEBUG
  2041. static hda_nid_t alc880_test_dac_nids[4] = {
  2042. 0x02, 0x03, 0x04, 0x05
  2043. };
  2044. static struct hda_input_mux alc880_test_capture_source = {
  2045. .num_items = 7,
  2046. .items = {
  2047. { "In-1", 0x0 },
  2048. { "In-2", 0x1 },
  2049. { "In-3", 0x2 },
  2050. { "In-4", 0x3 },
  2051. { "CD", 0x4 },
  2052. { "Front", 0x5 },
  2053. { "Surround", 0x6 },
  2054. },
  2055. };
  2056. static struct hda_channel_mode alc880_test_modes[4] = {
  2057. { 2, NULL },
  2058. { 4, NULL },
  2059. { 6, NULL },
  2060. { 8, NULL },
  2061. };
  2062. static int alc_test_pin_ctl_info(struct snd_kcontrol *kcontrol,
  2063. struct snd_ctl_elem_info *uinfo)
  2064. {
  2065. static char *texts[] = {
  2066. "N/A", "Line Out", "HP Out",
  2067. "In Hi-Z", "In 50%", "In Grd", "In 80%", "In 100%"
  2068. };
  2069. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2070. uinfo->count = 1;
  2071. uinfo->value.enumerated.items = 8;
  2072. if (uinfo->value.enumerated.item >= 8)
  2073. uinfo->value.enumerated.item = 7;
  2074. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2075. return 0;
  2076. }
  2077. static int alc_test_pin_ctl_get(struct snd_kcontrol *kcontrol,
  2078. struct snd_ctl_elem_value *ucontrol)
  2079. {
  2080. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2081. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2082. unsigned int pin_ctl, item = 0;
  2083. pin_ctl = snd_hda_codec_read(codec, nid, 0,
  2084. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2085. if (pin_ctl & AC_PINCTL_OUT_EN) {
  2086. if (pin_ctl & AC_PINCTL_HP_EN)
  2087. item = 2;
  2088. else
  2089. item = 1;
  2090. } else if (pin_ctl & AC_PINCTL_IN_EN) {
  2091. switch (pin_ctl & AC_PINCTL_VREFEN) {
  2092. case AC_PINCTL_VREF_HIZ: item = 3; break;
  2093. case AC_PINCTL_VREF_50: item = 4; break;
  2094. case AC_PINCTL_VREF_GRD: item = 5; break;
  2095. case AC_PINCTL_VREF_80: item = 6; break;
  2096. case AC_PINCTL_VREF_100: item = 7; break;
  2097. }
  2098. }
  2099. ucontrol->value.enumerated.item[0] = item;
  2100. return 0;
  2101. }
  2102. static int alc_test_pin_ctl_put(struct snd_kcontrol *kcontrol,
  2103. struct snd_ctl_elem_value *ucontrol)
  2104. {
  2105. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2106. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2107. static unsigned int ctls[] = {
  2108. 0, AC_PINCTL_OUT_EN, AC_PINCTL_OUT_EN | AC_PINCTL_HP_EN,
  2109. AC_PINCTL_IN_EN | AC_PINCTL_VREF_HIZ,
  2110. AC_PINCTL_IN_EN | AC_PINCTL_VREF_50,
  2111. AC_PINCTL_IN_EN | AC_PINCTL_VREF_GRD,
  2112. AC_PINCTL_IN_EN | AC_PINCTL_VREF_80,
  2113. AC_PINCTL_IN_EN | AC_PINCTL_VREF_100,
  2114. };
  2115. unsigned int old_ctl, new_ctl;
  2116. old_ctl = snd_hda_codec_read(codec, nid, 0,
  2117. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  2118. new_ctl = ctls[ucontrol->value.enumerated.item[0]];
  2119. if (old_ctl != new_ctl) {
  2120. snd_hda_codec_write(codec, nid, 0,
  2121. AC_VERB_SET_PIN_WIDGET_CONTROL, new_ctl);
  2122. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2123. (ucontrol->value.enumerated.item[0] >= 3 ?
  2124. 0xb080 : 0xb000));
  2125. return 1;
  2126. }
  2127. return 0;
  2128. }
  2129. static int alc_test_pin_src_info(struct snd_kcontrol *kcontrol,
  2130. struct snd_ctl_elem_info *uinfo)
  2131. {
  2132. static char *texts[] = {
  2133. "Front", "Surround", "CLFE", "Side"
  2134. };
  2135. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  2136. uinfo->count = 1;
  2137. uinfo->value.enumerated.items = 4;
  2138. if (uinfo->value.enumerated.item >= 4)
  2139. uinfo->value.enumerated.item = 3;
  2140. strcpy(uinfo->value.enumerated.name, texts[uinfo->value.enumerated.item]);
  2141. return 0;
  2142. }
  2143. static int alc_test_pin_src_get(struct snd_kcontrol *kcontrol,
  2144. struct snd_ctl_elem_value *ucontrol)
  2145. {
  2146. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2147. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2148. unsigned int sel;
  2149. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0);
  2150. ucontrol->value.enumerated.item[0] = sel & 3;
  2151. return 0;
  2152. }
  2153. static int alc_test_pin_src_put(struct snd_kcontrol *kcontrol,
  2154. struct snd_ctl_elem_value *ucontrol)
  2155. {
  2156. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  2157. hda_nid_t nid = (hda_nid_t)kcontrol->private_value;
  2158. unsigned int sel;
  2159. sel = snd_hda_codec_read(codec, nid, 0, AC_VERB_GET_CONNECT_SEL, 0) & 3;
  2160. if (ucontrol->value.enumerated.item[0] != sel) {
  2161. sel = ucontrol->value.enumerated.item[0] & 3;
  2162. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, sel);
  2163. return 1;
  2164. }
  2165. return 0;
  2166. }
  2167. #define PIN_CTL_TEST(xname,nid) { \
  2168. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2169. .name = xname, \
  2170. .info = alc_test_pin_ctl_info, \
  2171. .get = alc_test_pin_ctl_get, \
  2172. .put = alc_test_pin_ctl_put, \
  2173. .private_value = nid \
  2174. }
  2175. #define PIN_SRC_TEST(xname,nid) { \
  2176. .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
  2177. .name = xname, \
  2178. .info = alc_test_pin_src_info, \
  2179. .get = alc_test_pin_src_get, \
  2180. .put = alc_test_pin_src_put, \
  2181. .private_value = nid \
  2182. }
  2183. static struct snd_kcontrol_new alc880_test_mixer[] = {
  2184. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  2185. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  2186. HDA_CODEC_VOLUME("CLFE Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  2187. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  2188. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  2189. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  2190. HDA_BIND_MUTE("CLFE Playback Switch", 0x0e, 2, HDA_INPUT),
  2191. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  2192. PIN_CTL_TEST("Front Pin Mode", 0x14),
  2193. PIN_CTL_TEST("Surround Pin Mode", 0x15),
  2194. PIN_CTL_TEST("CLFE Pin Mode", 0x16),
  2195. PIN_CTL_TEST("Side Pin Mode", 0x17),
  2196. PIN_CTL_TEST("In-1 Pin Mode", 0x18),
  2197. PIN_CTL_TEST("In-2 Pin Mode", 0x19),
  2198. PIN_CTL_TEST("In-3 Pin Mode", 0x1a),
  2199. PIN_CTL_TEST("In-4 Pin Mode", 0x1b),
  2200. PIN_SRC_TEST("In-1 Pin Source", 0x18),
  2201. PIN_SRC_TEST("In-2 Pin Source", 0x19),
  2202. PIN_SRC_TEST("In-3 Pin Source", 0x1a),
  2203. PIN_SRC_TEST("In-4 Pin Source", 0x1b),
  2204. HDA_CODEC_VOLUME("In-1 Playback Volume", 0x0b, 0x0, HDA_INPUT),
  2205. HDA_CODEC_MUTE("In-1 Playback Switch", 0x0b, 0x0, HDA_INPUT),
  2206. HDA_CODEC_VOLUME("In-2 Playback Volume", 0x0b, 0x1, HDA_INPUT),
  2207. HDA_CODEC_MUTE("In-2 Playback Switch", 0x0b, 0x1, HDA_INPUT),
  2208. HDA_CODEC_VOLUME("In-3 Playback Volume", 0x0b, 0x2, HDA_INPUT),
  2209. HDA_CODEC_MUTE("In-3 Playback Switch", 0x0b, 0x2, HDA_INPUT),
  2210. HDA_CODEC_VOLUME("In-4 Playback Volume", 0x0b, 0x3, HDA_INPUT),
  2211. HDA_CODEC_MUTE("In-4 Playback Switch", 0x0b, 0x3, HDA_INPUT),
  2212. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x4, HDA_INPUT),
  2213. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x4, HDA_INPUT),
  2214. {
  2215. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  2216. .name = "Channel Mode",
  2217. .info = alc_ch_mode_info,
  2218. .get = alc_ch_mode_get,
  2219. .put = alc_ch_mode_put,
  2220. },
  2221. { } /* end */
  2222. };
  2223. static struct hda_verb alc880_test_init_verbs[] = {
  2224. /* Unmute inputs of 0x0c - 0x0f */
  2225. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2226. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2227. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2228. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2229. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2230. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2231. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  2232. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  2233. /* Vol output for 0x0c-0x0f */
  2234. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2235. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2236. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2237. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  2238. /* Set output pins 0x14-0x17 */
  2239. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2240. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2241. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2242. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  2243. /* Unmute output pins 0x14-0x17 */
  2244. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2245. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2246. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2247. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  2248. /* Set input pins 0x18-0x1c */
  2249. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2250. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  2251. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2252. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2253. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  2254. /* Mute input pins 0x18-0x1b */
  2255. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2256. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2257. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2258. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  2259. /* ADC set up */
  2260. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2261. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  2262. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2263. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  2264. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2265. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  2266. /* Analog input/passthru */
  2267. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  2268. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  2269. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  2270. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  2271. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  2272. { }
  2273. };
  2274. #endif
  2275. /*
  2276. */
  2277. static const char *alc880_models[ALC880_MODEL_LAST] = {
  2278. [ALC880_3ST] = "3stack",
  2279. [ALC880_TCL_S700] = "tcl",
  2280. [ALC880_3ST_DIG] = "3stack-digout",
  2281. [ALC880_CLEVO] = "clevo",
  2282. [ALC880_5ST] = "5stack",
  2283. [ALC880_5ST_DIG] = "5stack-digout",
  2284. [ALC880_W810] = "w810",
  2285. [ALC880_Z71V] = "z71v",
  2286. [ALC880_6ST] = "6stack",
  2287. [ALC880_6ST_DIG] = "6stack-digout",
  2288. [ALC880_ASUS] = "asus",
  2289. [ALC880_ASUS_W1V] = "asus-w1v",
  2290. [ALC880_ASUS_DIG] = "asus-dig",
  2291. [ALC880_ASUS_DIG2] = "asus-dig2",
  2292. [ALC880_UNIWILL_DIG] = "uniwill",
  2293. [ALC880_UNIWILL_P53] = "uniwill-p53",
  2294. [ALC880_FUJITSU] = "fujitsu",
  2295. [ALC880_F1734] = "F1734",
  2296. [ALC880_LG] = "lg",
  2297. [ALC880_LG_LW] = "lg-lw",
  2298. #ifdef CONFIG_SND_DEBUG
  2299. [ALC880_TEST] = "test",
  2300. #endif
  2301. [ALC880_AUTO] = "auto",
  2302. };
  2303. static struct snd_pci_quirk alc880_cfg_tbl[] = {
  2304. /* Broken BIOS configuration */
  2305. SND_PCI_QUIRK(0x2668, 0x8086, NULL, ALC880_6ST_DIG),
  2306. SND_PCI_QUIRK(0x8086, 0x2668, NULL, ALC880_6ST_DIG),
  2307. SND_PCI_QUIRK(0x1019, 0xa880, "ECS", ALC880_5ST_DIG),
  2308. SND_PCI_QUIRK(0x1019, 0xa884, "Acer APFV", ALC880_6ST),
  2309. SND_PCI_QUIRK(0x1019, 0x0f69, "Coeus G610P", ALC880_W810),
  2310. SND_PCI_QUIRK(0x1025, 0x0070, "ULI", ALC880_3ST_DIG),
  2311. SND_PCI_QUIRK(0x1025, 0x0077, "ULI", ALC880_6ST_DIG),
  2312. SND_PCI_QUIRK(0x1025, 0x0078, "ULI", ALC880_6ST_DIG),
  2313. SND_PCI_QUIRK(0x1025, 0x0087, "ULI", ALC880_6ST_DIG),
  2314. SND_PCI_QUIRK(0x1025, 0xe309, "ULI", ALC880_3ST_DIG),
  2315. SND_PCI_QUIRK(0x1025, 0xe310, "ULI", ALC880_3ST),
  2316. SND_PCI_QUIRK(0x1039, 0x1234, NULL, ALC880_6ST_DIG),
  2317. SND_PCI_QUIRK(0x103c, 0x2a09, "HP", ALC880_5ST),
  2318. SND_PCI_QUIRK(0x1043, 0x10b3, "ASUS W1V", ALC880_ASUS_W1V),
  2319. SND_PCI_QUIRK(0x1043, 0x10c2, "ASUS W6A", ALC880_ASUS_DIG),
  2320. SND_PCI_QUIRK(0x1043, 0x10c3, "ASUS Wxx", ALC880_ASUS_DIG),
  2321. SND_PCI_QUIRK(0x1043, 0x1113, "ASUS", ALC880_ASUS_DIG),
  2322. SND_PCI_QUIRK(0x1043, 0x1123, "ASUS", ALC880_ASUS_DIG),
  2323. SND_PCI_QUIRK(0x1043, 0x1173, "ASUS", ALC880_ASUS_DIG),
  2324. SND_PCI_QUIRK(0x1043, 0x1964, "ASUS Z71V", ALC880_Z71V),
  2325. /* SND_PCI_QUIRK(0x1043, 0x1964, "ASUS", ALC880_ASUS_DIG), */
  2326. SND_PCI_QUIRK(0x1043, 0x1973, "ASUS", ALC880_ASUS_DIG),
  2327. SND_PCI_QUIRK(0x1043, 0x19b3, "ASUS", ALC880_ASUS_DIG),
  2328. SND_PCI_QUIRK(0x1043, 0x814e, "ASUS", ALC880_ASUS),
  2329. SND_PCI_QUIRK(0x1043, 0x8181, "ASUS P4GPL", ALC880_ASUS_DIG),
  2330. SND_PCI_QUIRK(0x1043, 0x8196, "ASUS P5GD1", ALC880_6ST),
  2331. SND_PCI_QUIRK(0x1043, 0x81b4, "ASUS", ALC880_6ST),
  2332. SND_PCI_QUIRK(0x1043, 0, "ASUS", ALC880_ASUS),
  2333. SND_PCI_QUIRK(0x104d, 0x81d6, "Sony", ALC880_3ST),
  2334. SND_PCI_QUIRK(0x104d, 0x81a0, "Sony", ALC880_3ST),
  2335. SND_PCI_QUIRK(0x107b, 0x3033, "Gateway", ALC880_5ST),
  2336. SND_PCI_QUIRK(0x107b, 0x4039, "Gateway", ALC880_5ST),
  2337. SND_PCI_QUIRK(0x107b, 0x3032, "Gateway", ALC880_5ST),
  2338. SND_PCI_QUIRK(0x1558, 0x0520, "Clevo m520G", ALC880_CLEVO),
  2339. SND_PCI_QUIRK(0x1558, 0x0660, "Clevo m655n", ALC880_CLEVO),
  2340. SND_PCI_QUIRK(0x1565, 0x8202, "Biostar", ALC880_5ST_DIG),
  2341. SND_PCI_QUIRK(0x161f, 0x203d, "W810", ALC880_W810),
  2342. SND_PCI_QUIRK(0x1695, 0x400d, "EPoX", ALC880_5ST_DIG),
  2343. SND_PCI_QUIRK(0x19db, 0x4188, "TCL S700", ALC880_TCL_S700),
  2344. SND_PCI_QUIRK(0xa0a0, 0x0560, "AOpen i915GMm-HFS", ALC880_5ST_DIG),
  2345. SND_PCI_QUIRK(0xe803, 0x1019, NULL, ALC880_6ST_DIG),
  2346. SND_PCI_QUIRK(0x1297, 0xc790, "Shuttle ST20G5", ALC880_6ST_DIG),
  2347. SND_PCI_QUIRK(0x1458, 0xa102, "Gigabyte K8", ALC880_6ST_DIG),
  2348. SND_PCI_QUIRK(0x1462, 0x1150, "MSI", ALC880_6ST_DIG),
  2349. SND_PCI_QUIRK(0x1509, 0x925d, "FIC P4M", ALC880_6ST_DIG),
  2350. SND_PCI_QUIRK(0x1558, 0x5401, "ASUS", ALC880_ASUS_DIG2),
  2351. SND_PCI_QUIRK(0x1584, 0x9050, "Uniwill", ALC880_UNIWILL_DIG),
  2352. SND_PCI_QUIRK(0x1584, 0x9070, "Uniwill", ALC880_UNIWILL),
  2353. SND_PCI_QUIRK(0x1584, 0x9077, "Uniwill P53", ALC880_UNIWILL_P53),
  2354. SND_PCI_QUIRK(0x1584, 0x9054, "Uniwlll", ALC880_F1734),
  2355. SND_PCI_QUIRK(0x1695, 0x4012, "EPox EP-5LDA", ALC880_5ST_DIG),
  2356. SND_PCI_QUIRK(0x1734, 0x10ac, "FSC", ALC880_UNIWILL),
  2357. SND_PCI_QUIRK(0x1734, 0x107c, "FSC F1734", ALC880_F1734),
  2358. SND_PCI_QUIRK(0x1734, 0x10b0, "Fujitsu", ALC880_FUJITSU),
  2359. SND_PCI_QUIRK(0x1854, 0x003b, "LG", ALC880_LG),
  2360. SND_PCI_QUIRK(0x1854, 0x0068, "LG w1", ALC880_LG),
  2361. SND_PCI_QUIRK(0x1854, 0x0018, "LG LW20", ALC880_LG_LW),
  2362. SND_PCI_QUIRK(0x1854, 0x0077, "LG LW25", ALC880_LG_LW),
  2363. SND_PCI_QUIRK(0x8086, 0xe308, "Intel mobo", ALC880_3ST_DIG),
  2364. SND_PCI_QUIRK(0x8086, 0xe305, "Intel mobo", ALC880_3ST_DIG),
  2365. SND_PCI_QUIRK(0x8086, 0xd402, "Intel mobo", ALC880_3ST_DIG),
  2366. SND_PCI_QUIRK(0x8086, 0xd400, "Intel mobo", ALC880_5ST_DIG),
  2367. SND_PCI_QUIRK(0x8086, 0xd401, "Intel mobo", ALC880_5ST_DIG),
  2368. SND_PCI_QUIRK(0x8086, 0xe224, "Intel mobo", ALC880_5ST_DIG),
  2369. SND_PCI_QUIRK(0x8086, 0xe400, "Intel mobo", ALC880_5ST_DIG),
  2370. SND_PCI_QUIRK(0x8086, 0xe401, "Intel mobo", ALC880_5ST_DIG),
  2371. SND_PCI_QUIRK(0x8086, 0xe402, "Intel mobo", ALC880_5ST_DIG),
  2372. SND_PCI_QUIRK(0x8086, 0xa100, "Intel mobo", ALC880_5ST_DIG),
  2373. SND_PCI_QUIRK(0x8086, 0, "Intel mobo", ALC880_3ST),
  2374. {}
  2375. };
  2376. /*
  2377. * ALC880 codec presets
  2378. */
  2379. static struct alc_config_preset alc880_presets[] = {
  2380. [ALC880_3ST] = {
  2381. .mixers = { alc880_three_stack_mixer },
  2382. .init_verbs = { alc880_volume_init_verbs,
  2383. alc880_pin_3stack_init_verbs },
  2384. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2385. .dac_nids = alc880_dac_nids,
  2386. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2387. .channel_mode = alc880_threestack_modes,
  2388. .need_dac_fix = 1,
  2389. .input_mux = &alc880_capture_source,
  2390. },
  2391. [ALC880_3ST_DIG] = {
  2392. .mixers = { alc880_three_stack_mixer },
  2393. .init_verbs = { alc880_volume_init_verbs,
  2394. alc880_pin_3stack_init_verbs },
  2395. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2396. .dac_nids = alc880_dac_nids,
  2397. .dig_out_nid = ALC880_DIGOUT_NID,
  2398. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2399. .channel_mode = alc880_threestack_modes,
  2400. .need_dac_fix = 1,
  2401. .input_mux = &alc880_capture_source,
  2402. },
  2403. [ALC880_TCL_S700] = {
  2404. .mixers = { alc880_tcl_s700_mixer },
  2405. .init_verbs = { alc880_volume_init_verbs,
  2406. alc880_pin_tcl_S700_init_verbs,
  2407. alc880_gpio2_init_verbs },
  2408. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2409. .dac_nids = alc880_dac_nids,
  2410. .hp_nid = 0x03,
  2411. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2412. .channel_mode = alc880_2_jack_modes,
  2413. .input_mux = &alc880_capture_source,
  2414. },
  2415. [ALC880_5ST] = {
  2416. .mixers = { alc880_three_stack_mixer,
  2417. alc880_five_stack_mixer},
  2418. .init_verbs = { alc880_volume_init_verbs,
  2419. alc880_pin_5stack_init_verbs },
  2420. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2421. .dac_nids = alc880_dac_nids,
  2422. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2423. .channel_mode = alc880_fivestack_modes,
  2424. .input_mux = &alc880_capture_source,
  2425. },
  2426. [ALC880_5ST_DIG] = {
  2427. .mixers = { alc880_three_stack_mixer,
  2428. alc880_five_stack_mixer },
  2429. .init_verbs = { alc880_volume_init_verbs,
  2430. alc880_pin_5stack_init_verbs },
  2431. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2432. .dac_nids = alc880_dac_nids,
  2433. .dig_out_nid = ALC880_DIGOUT_NID,
  2434. .num_channel_mode = ARRAY_SIZE(alc880_fivestack_modes),
  2435. .channel_mode = alc880_fivestack_modes,
  2436. .input_mux = &alc880_capture_source,
  2437. },
  2438. [ALC880_6ST] = {
  2439. .mixers = { alc880_six_stack_mixer },
  2440. .init_verbs = { alc880_volume_init_verbs,
  2441. alc880_pin_6stack_init_verbs },
  2442. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2443. .dac_nids = alc880_6st_dac_nids,
  2444. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2445. .channel_mode = alc880_sixstack_modes,
  2446. .input_mux = &alc880_6stack_capture_source,
  2447. },
  2448. [ALC880_6ST_DIG] = {
  2449. .mixers = { alc880_six_stack_mixer },
  2450. .init_verbs = { alc880_volume_init_verbs,
  2451. alc880_pin_6stack_init_verbs },
  2452. .num_dacs = ARRAY_SIZE(alc880_6st_dac_nids),
  2453. .dac_nids = alc880_6st_dac_nids,
  2454. .dig_out_nid = ALC880_DIGOUT_NID,
  2455. .num_channel_mode = ARRAY_SIZE(alc880_sixstack_modes),
  2456. .channel_mode = alc880_sixstack_modes,
  2457. .input_mux = &alc880_6stack_capture_source,
  2458. },
  2459. [ALC880_W810] = {
  2460. .mixers = { alc880_w810_base_mixer },
  2461. .init_verbs = { alc880_volume_init_verbs,
  2462. alc880_pin_w810_init_verbs,
  2463. alc880_gpio2_init_verbs },
  2464. .num_dacs = ARRAY_SIZE(alc880_w810_dac_nids),
  2465. .dac_nids = alc880_w810_dac_nids,
  2466. .dig_out_nid = ALC880_DIGOUT_NID,
  2467. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2468. .channel_mode = alc880_w810_modes,
  2469. .input_mux = &alc880_capture_source,
  2470. },
  2471. [ALC880_Z71V] = {
  2472. .mixers = { alc880_z71v_mixer },
  2473. .init_verbs = { alc880_volume_init_verbs,
  2474. alc880_pin_z71v_init_verbs },
  2475. .num_dacs = ARRAY_SIZE(alc880_z71v_dac_nids),
  2476. .dac_nids = alc880_z71v_dac_nids,
  2477. .dig_out_nid = ALC880_DIGOUT_NID,
  2478. .hp_nid = 0x03,
  2479. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2480. .channel_mode = alc880_2_jack_modes,
  2481. .input_mux = &alc880_capture_source,
  2482. },
  2483. [ALC880_F1734] = {
  2484. .mixers = { alc880_f1734_mixer },
  2485. .init_verbs = { alc880_volume_init_verbs,
  2486. alc880_pin_f1734_init_verbs },
  2487. .num_dacs = ARRAY_SIZE(alc880_f1734_dac_nids),
  2488. .dac_nids = alc880_f1734_dac_nids,
  2489. .hp_nid = 0x02,
  2490. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2491. .channel_mode = alc880_2_jack_modes,
  2492. .input_mux = &alc880_capture_source,
  2493. },
  2494. [ALC880_ASUS] = {
  2495. .mixers = { alc880_asus_mixer },
  2496. .init_verbs = { alc880_volume_init_verbs,
  2497. alc880_pin_asus_init_verbs,
  2498. alc880_gpio1_init_verbs },
  2499. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2500. .dac_nids = alc880_asus_dac_nids,
  2501. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2502. .channel_mode = alc880_asus_modes,
  2503. .need_dac_fix = 1,
  2504. .input_mux = &alc880_capture_source,
  2505. },
  2506. [ALC880_ASUS_DIG] = {
  2507. .mixers = { alc880_asus_mixer },
  2508. .init_verbs = { alc880_volume_init_verbs,
  2509. alc880_pin_asus_init_verbs,
  2510. alc880_gpio1_init_verbs },
  2511. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2512. .dac_nids = alc880_asus_dac_nids,
  2513. .dig_out_nid = ALC880_DIGOUT_NID,
  2514. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2515. .channel_mode = alc880_asus_modes,
  2516. .need_dac_fix = 1,
  2517. .input_mux = &alc880_capture_source,
  2518. },
  2519. [ALC880_ASUS_DIG2] = {
  2520. .mixers = { alc880_asus_mixer },
  2521. .init_verbs = { alc880_volume_init_verbs,
  2522. alc880_pin_asus_init_verbs,
  2523. alc880_gpio2_init_verbs }, /* use GPIO2 */
  2524. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2525. .dac_nids = alc880_asus_dac_nids,
  2526. .dig_out_nid = ALC880_DIGOUT_NID,
  2527. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2528. .channel_mode = alc880_asus_modes,
  2529. .need_dac_fix = 1,
  2530. .input_mux = &alc880_capture_source,
  2531. },
  2532. [ALC880_ASUS_W1V] = {
  2533. .mixers = { alc880_asus_mixer, alc880_asus_w1v_mixer },
  2534. .init_verbs = { alc880_volume_init_verbs,
  2535. alc880_pin_asus_init_verbs,
  2536. alc880_gpio1_init_verbs },
  2537. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2538. .dac_nids = alc880_asus_dac_nids,
  2539. .dig_out_nid = ALC880_DIGOUT_NID,
  2540. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2541. .channel_mode = alc880_asus_modes,
  2542. .need_dac_fix = 1,
  2543. .input_mux = &alc880_capture_source,
  2544. },
  2545. [ALC880_UNIWILL_DIG] = {
  2546. .mixers = { alc880_asus_mixer, alc880_pcbeep_mixer },
  2547. .init_verbs = { alc880_volume_init_verbs,
  2548. alc880_pin_asus_init_verbs },
  2549. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2550. .dac_nids = alc880_asus_dac_nids,
  2551. .dig_out_nid = ALC880_DIGOUT_NID,
  2552. .num_channel_mode = ARRAY_SIZE(alc880_asus_modes),
  2553. .channel_mode = alc880_asus_modes,
  2554. .need_dac_fix = 1,
  2555. .input_mux = &alc880_capture_source,
  2556. },
  2557. [ALC880_UNIWILL] = {
  2558. .mixers = { alc880_uniwill_mixer },
  2559. .init_verbs = { alc880_volume_init_verbs,
  2560. alc880_uniwill_init_verbs },
  2561. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2562. .dac_nids = alc880_asus_dac_nids,
  2563. .dig_out_nid = ALC880_DIGOUT_NID,
  2564. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2565. .channel_mode = alc880_threestack_modes,
  2566. .need_dac_fix = 1,
  2567. .input_mux = &alc880_capture_source,
  2568. .unsol_event = alc880_uniwill_unsol_event,
  2569. .init_hook = alc880_uniwill_automute,
  2570. },
  2571. [ALC880_UNIWILL_P53] = {
  2572. .mixers = { alc880_uniwill_p53_mixer },
  2573. .init_verbs = { alc880_volume_init_verbs,
  2574. alc880_uniwill_p53_init_verbs },
  2575. .num_dacs = ARRAY_SIZE(alc880_asus_dac_nids),
  2576. .dac_nids = alc880_asus_dac_nids,
  2577. .num_channel_mode = ARRAY_SIZE(alc880_w810_modes),
  2578. .channel_mode = alc880_threestack_modes,
  2579. .input_mux = &alc880_capture_source,
  2580. .unsol_event = alc880_uniwill_p53_unsol_event,
  2581. .init_hook = alc880_uniwill_p53_hp_automute,
  2582. },
  2583. [ALC880_FUJITSU] = {
  2584. .mixers = { alc880_fujitsu_mixer,
  2585. alc880_pcbeep_mixer, },
  2586. .init_verbs = { alc880_volume_init_verbs,
  2587. alc880_uniwill_p53_init_verbs,
  2588. alc880_beep_init_verbs },
  2589. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2590. .dac_nids = alc880_dac_nids,
  2591. .num_channel_mode = ARRAY_SIZE(alc880_2_jack_modes),
  2592. .channel_mode = alc880_2_jack_modes,
  2593. .input_mux = &alc880_capture_source,
  2594. .unsol_event = alc880_uniwill_p53_unsol_event,
  2595. .init_hook = alc880_uniwill_p53_hp_automute,
  2596. },
  2597. [ALC880_CLEVO] = {
  2598. .mixers = { alc880_three_stack_mixer },
  2599. .init_verbs = { alc880_volume_init_verbs,
  2600. alc880_pin_clevo_init_verbs },
  2601. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2602. .dac_nids = alc880_dac_nids,
  2603. .hp_nid = 0x03,
  2604. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  2605. .channel_mode = alc880_threestack_modes,
  2606. .need_dac_fix = 1,
  2607. .input_mux = &alc880_capture_source,
  2608. },
  2609. [ALC880_LG] = {
  2610. .mixers = { alc880_lg_mixer },
  2611. .init_verbs = { alc880_volume_init_verbs,
  2612. alc880_lg_init_verbs },
  2613. .num_dacs = ARRAY_SIZE(alc880_lg_dac_nids),
  2614. .dac_nids = alc880_lg_dac_nids,
  2615. .dig_out_nid = ALC880_DIGOUT_NID,
  2616. .num_channel_mode = ARRAY_SIZE(alc880_lg_ch_modes),
  2617. .channel_mode = alc880_lg_ch_modes,
  2618. .need_dac_fix = 1,
  2619. .input_mux = &alc880_lg_capture_source,
  2620. .unsol_event = alc880_lg_unsol_event,
  2621. .init_hook = alc880_lg_automute,
  2622. },
  2623. [ALC880_LG_LW] = {
  2624. .mixers = { alc880_lg_lw_mixer },
  2625. .init_verbs = { alc880_volume_init_verbs,
  2626. alc880_lg_lw_init_verbs },
  2627. .num_dacs = ARRAY_SIZE(alc880_dac_nids),
  2628. .dac_nids = alc880_dac_nids,
  2629. .dig_out_nid = ALC880_DIGOUT_NID,
  2630. .num_channel_mode = ARRAY_SIZE(alc880_lg_lw_modes),
  2631. .channel_mode = alc880_lg_lw_modes,
  2632. .input_mux = &alc880_lg_lw_capture_source,
  2633. .unsol_event = alc880_lg_lw_unsol_event,
  2634. .init_hook = alc880_lg_lw_automute,
  2635. },
  2636. #ifdef CONFIG_SND_DEBUG
  2637. [ALC880_TEST] = {
  2638. .mixers = { alc880_test_mixer },
  2639. .init_verbs = { alc880_test_init_verbs },
  2640. .num_dacs = ARRAY_SIZE(alc880_test_dac_nids),
  2641. .dac_nids = alc880_test_dac_nids,
  2642. .dig_out_nid = ALC880_DIGOUT_NID,
  2643. .num_channel_mode = ARRAY_SIZE(alc880_test_modes),
  2644. .channel_mode = alc880_test_modes,
  2645. .input_mux = &alc880_test_capture_source,
  2646. },
  2647. #endif
  2648. };
  2649. /*
  2650. * Automatic parse of I/O pins from the BIOS configuration
  2651. */
  2652. #define NUM_CONTROL_ALLOC 32
  2653. #define NUM_VERB_ALLOC 32
  2654. enum {
  2655. ALC_CTL_WIDGET_VOL,
  2656. ALC_CTL_WIDGET_MUTE,
  2657. ALC_CTL_BIND_MUTE,
  2658. };
  2659. static struct snd_kcontrol_new alc880_control_templates[] = {
  2660. HDA_CODEC_VOLUME(NULL, 0, 0, 0),
  2661. HDA_CODEC_MUTE(NULL, 0, 0, 0),
  2662. HDA_BIND_MUTE(NULL, 0, 0, 0),
  2663. };
  2664. /* add dynamic controls */
  2665. static int add_control(struct alc_spec *spec, int type, const char *name,
  2666. unsigned long val)
  2667. {
  2668. struct snd_kcontrol_new *knew;
  2669. if (spec->num_kctl_used >= spec->num_kctl_alloc) {
  2670. int num = spec->num_kctl_alloc + NUM_CONTROL_ALLOC;
  2671. /* array + terminator */
  2672. knew = kcalloc(num + 1, sizeof(*knew), GFP_KERNEL);
  2673. if (!knew)
  2674. return -ENOMEM;
  2675. if (spec->kctl_alloc) {
  2676. memcpy(knew, spec->kctl_alloc,
  2677. sizeof(*knew) * spec->num_kctl_alloc);
  2678. kfree(spec->kctl_alloc);
  2679. }
  2680. spec->kctl_alloc = knew;
  2681. spec->num_kctl_alloc = num;
  2682. }
  2683. knew = &spec->kctl_alloc[spec->num_kctl_used];
  2684. *knew = alc880_control_templates[type];
  2685. knew->name = kstrdup(name, GFP_KERNEL);
  2686. if (!knew->name)
  2687. return -ENOMEM;
  2688. knew->private_value = val;
  2689. spec->num_kctl_used++;
  2690. return 0;
  2691. }
  2692. #define alc880_is_fixed_pin(nid) ((nid) >= 0x14 && (nid) <= 0x17)
  2693. #define alc880_fixed_pin_idx(nid) ((nid) - 0x14)
  2694. #define alc880_is_multi_pin(nid) ((nid) >= 0x18)
  2695. #define alc880_multi_pin_idx(nid) ((nid) - 0x18)
  2696. #define alc880_is_input_pin(nid) ((nid) >= 0x18)
  2697. #define alc880_input_pin_idx(nid) ((nid) - 0x18)
  2698. #define alc880_idx_to_dac(nid) ((nid) + 0x02)
  2699. #define alc880_dac_to_idx(nid) ((nid) - 0x02)
  2700. #define alc880_idx_to_mixer(nid) ((nid) + 0x0c)
  2701. #define alc880_idx_to_selector(nid) ((nid) + 0x10)
  2702. #define ALC880_PIN_CD_NID 0x1c
  2703. /* fill in the dac_nids table from the parsed pin configuration */
  2704. static int alc880_auto_fill_dac_nids(struct alc_spec *spec,
  2705. const struct auto_pin_cfg *cfg)
  2706. {
  2707. hda_nid_t nid;
  2708. int assigned[4];
  2709. int i, j;
  2710. memset(assigned, 0, sizeof(assigned));
  2711. spec->multiout.dac_nids = spec->private_dac_nids;
  2712. /* check the pins hardwired to audio widget */
  2713. for (i = 0; i < cfg->line_outs; i++) {
  2714. nid = cfg->line_out_pins[i];
  2715. if (alc880_is_fixed_pin(nid)) {
  2716. int idx = alc880_fixed_pin_idx(nid);
  2717. spec->multiout.dac_nids[i] = alc880_idx_to_dac(idx);
  2718. assigned[idx] = 1;
  2719. }
  2720. }
  2721. /* left pins can be connect to any audio widget */
  2722. for (i = 0; i < cfg->line_outs; i++) {
  2723. nid = cfg->line_out_pins[i];
  2724. if (alc880_is_fixed_pin(nid))
  2725. continue;
  2726. /* search for an empty channel */
  2727. for (j = 0; j < cfg->line_outs; j++) {
  2728. if (!assigned[j]) {
  2729. spec->multiout.dac_nids[i] =
  2730. alc880_idx_to_dac(j);
  2731. assigned[j] = 1;
  2732. break;
  2733. }
  2734. }
  2735. }
  2736. spec->multiout.num_dacs = cfg->line_outs;
  2737. return 0;
  2738. }
  2739. /* add playback controls from the parsed DAC table */
  2740. static int alc880_auto_create_multi_out_ctls(struct alc_spec *spec,
  2741. const struct auto_pin_cfg *cfg)
  2742. {
  2743. char name[32];
  2744. static const char *chname[4] = {
  2745. "Front", "Surround", NULL /*CLFE*/, "Side"
  2746. };
  2747. hda_nid_t nid;
  2748. int i, err;
  2749. for (i = 0; i < cfg->line_outs; i++) {
  2750. if (!spec->multiout.dac_nids[i])
  2751. continue;
  2752. nid = alc880_idx_to_mixer(alc880_dac_to_idx(spec->multiout.dac_nids[i]));
  2753. if (i == 2) {
  2754. /* Center/LFE */
  2755. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2756. "Center Playback Volume",
  2757. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  2758. HDA_OUTPUT));
  2759. if (err < 0)
  2760. return err;
  2761. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  2762. "LFE Playback Volume",
  2763. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  2764. HDA_OUTPUT));
  2765. if (err < 0)
  2766. return err;
  2767. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2768. "Center Playback Switch",
  2769. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  2770. HDA_INPUT));
  2771. if (err < 0)
  2772. return err;
  2773. err = add_control(spec, ALC_CTL_BIND_MUTE,
  2774. "LFE Playback Switch",
  2775. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  2776. HDA_INPUT));
  2777. if (err < 0)
  2778. return err;
  2779. } else {
  2780. sprintf(name, "%s Playback Volume", chname[i]);
  2781. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2782. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  2783. HDA_OUTPUT));
  2784. if (err < 0)
  2785. return err;
  2786. sprintf(name, "%s Playback Switch", chname[i]);
  2787. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2788. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  2789. HDA_INPUT));
  2790. if (err < 0)
  2791. return err;
  2792. }
  2793. }
  2794. return 0;
  2795. }
  2796. /* add playback controls for speaker and HP outputs */
  2797. static int alc880_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  2798. const char *pfx)
  2799. {
  2800. hda_nid_t nid;
  2801. int err;
  2802. char name[32];
  2803. if (!pin)
  2804. return 0;
  2805. if (alc880_is_fixed_pin(pin)) {
  2806. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  2807. /* specify the DAC as the extra output */
  2808. if (!spec->multiout.hp_nid)
  2809. spec->multiout.hp_nid = nid;
  2810. else
  2811. spec->multiout.extra_out_nid[0] = nid;
  2812. /* control HP volume/switch on the output mixer amp */
  2813. nid = alc880_idx_to_mixer(alc880_fixed_pin_idx(pin));
  2814. sprintf(name, "%s Playback Volume", pfx);
  2815. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2816. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  2817. if (err < 0)
  2818. return err;
  2819. sprintf(name, "%s Playback Switch", pfx);
  2820. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  2821. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  2822. if (err < 0)
  2823. return err;
  2824. } else if (alc880_is_multi_pin(pin)) {
  2825. /* set manual connection */
  2826. /* we have only a switch on HP-out PIN */
  2827. sprintf(name, "%s Playback Switch", pfx);
  2828. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2829. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  2830. if (err < 0)
  2831. return err;
  2832. }
  2833. return 0;
  2834. }
  2835. /* create input playback/capture controls for the given pin */
  2836. static int new_analog_input(struct alc_spec *spec, hda_nid_t pin,
  2837. const char *ctlname,
  2838. int idx, hda_nid_t mix_nid)
  2839. {
  2840. char name[32];
  2841. int err;
  2842. sprintf(name, "%s Playback Volume", ctlname);
  2843. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  2844. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2845. if (err < 0)
  2846. return err;
  2847. sprintf(name, "%s Playback Switch", ctlname);
  2848. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  2849. HDA_COMPOSE_AMP_VAL(mix_nid, 3, idx, HDA_INPUT));
  2850. if (err < 0)
  2851. return err;
  2852. return 0;
  2853. }
  2854. /* create playback/capture controls for input pins */
  2855. static int alc880_auto_create_analog_input_ctls(struct alc_spec *spec,
  2856. const struct auto_pin_cfg *cfg)
  2857. {
  2858. struct hda_input_mux *imux = &spec->private_imux;
  2859. int i, err, idx;
  2860. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2861. if (alc880_is_input_pin(cfg->input_pins[i])) {
  2862. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  2863. err = new_analog_input(spec, cfg->input_pins[i],
  2864. auto_pin_cfg_labels[i],
  2865. idx, 0x0b);
  2866. if (err < 0)
  2867. return err;
  2868. imux->items[imux->num_items].label =
  2869. auto_pin_cfg_labels[i];
  2870. imux->items[imux->num_items].index =
  2871. alc880_input_pin_idx(cfg->input_pins[i]);
  2872. imux->num_items++;
  2873. }
  2874. }
  2875. return 0;
  2876. }
  2877. static void alc880_auto_set_output_and_unmute(struct hda_codec *codec,
  2878. hda_nid_t nid, int pin_type,
  2879. int dac_idx)
  2880. {
  2881. /* set as output */
  2882. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  2883. pin_type);
  2884. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  2885. AMP_OUT_UNMUTE);
  2886. /* need the manual connection? */
  2887. if (alc880_is_multi_pin(nid)) {
  2888. struct alc_spec *spec = codec->spec;
  2889. int idx = alc880_multi_pin_idx(nid);
  2890. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  2891. AC_VERB_SET_CONNECT_SEL,
  2892. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  2893. }
  2894. }
  2895. static int get_pin_type(int line_out_type)
  2896. {
  2897. if (line_out_type == AUTO_PIN_HP_OUT)
  2898. return PIN_HP;
  2899. else
  2900. return PIN_OUT;
  2901. }
  2902. static void alc880_auto_init_multi_out(struct hda_codec *codec)
  2903. {
  2904. struct alc_spec *spec = codec->spec;
  2905. int i;
  2906. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  2907. for (i = 0; i < spec->autocfg.line_outs; i++) {
  2908. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  2909. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  2910. alc880_auto_set_output_and_unmute(codec, nid, pin_type, i);
  2911. }
  2912. }
  2913. static void alc880_auto_init_extra_out(struct hda_codec *codec)
  2914. {
  2915. struct alc_spec *spec = codec->spec;
  2916. hda_nid_t pin;
  2917. pin = spec->autocfg.speaker_pins[0];
  2918. if (pin) /* connect to front */
  2919. alc880_auto_set_output_and_unmute(codec, pin, PIN_OUT, 0);
  2920. pin = spec->autocfg.hp_pins[0];
  2921. if (pin) /* connect to front */
  2922. alc880_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  2923. }
  2924. static void alc880_auto_init_analog_input(struct hda_codec *codec)
  2925. {
  2926. struct alc_spec *spec = codec->spec;
  2927. int i;
  2928. for (i = 0; i < AUTO_PIN_LAST; i++) {
  2929. hda_nid_t nid = spec->autocfg.input_pins[i];
  2930. if (alc880_is_input_pin(nid)) {
  2931. snd_hda_codec_write(codec, nid, 0,
  2932. AC_VERB_SET_PIN_WIDGET_CONTROL,
  2933. i <= AUTO_PIN_FRONT_MIC ?
  2934. PIN_VREF80 : PIN_IN);
  2935. if (nid != ALC880_PIN_CD_NID)
  2936. snd_hda_codec_write(codec, nid, 0,
  2937. AC_VERB_SET_AMP_GAIN_MUTE,
  2938. AMP_OUT_MUTE);
  2939. }
  2940. }
  2941. }
  2942. /* parse the BIOS configuration and set up the alc_spec */
  2943. /* return 1 if successful, 0 if the proper config is not found,
  2944. * or a negative error code
  2945. */
  2946. static int alc880_parse_auto_config(struct hda_codec *codec)
  2947. {
  2948. struct alc_spec *spec = codec->spec;
  2949. int err;
  2950. static hda_nid_t alc880_ignore[] = { 0x1d, 0 };
  2951. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  2952. alc880_ignore);
  2953. if (err < 0)
  2954. return err;
  2955. if (!spec->autocfg.line_outs)
  2956. return 0; /* can't find valid BIOS pin config */
  2957. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  2958. if (err < 0)
  2959. return err;
  2960. err = alc880_auto_create_multi_out_ctls(spec, &spec->autocfg);
  2961. if (err < 0)
  2962. return err;
  2963. err = alc880_auto_create_extra_out(spec,
  2964. spec->autocfg.speaker_pins[0],
  2965. "Speaker");
  2966. if (err < 0)
  2967. return err;
  2968. err = alc880_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  2969. "Headphone");
  2970. if (err < 0)
  2971. return err;
  2972. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  2973. if (err < 0)
  2974. return err;
  2975. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  2976. if (spec->autocfg.dig_out_pin)
  2977. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  2978. if (spec->autocfg.dig_in_pin)
  2979. spec->dig_in_nid = ALC880_DIGIN_NID;
  2980. if (spec->kctl_alloc)
  2981. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  2982. spec->init_verbs[spec->num_init_verbs++] = alc880_volume_init_verbs;
  2983. spec->num_mux_defs = 1;
  2984. spec->input_mux = &spec->private_imux;
  2985. return 1;
  2986. }
  2987. /* additional initialization for auto-configuration model */
  2988. static void alc880_auto_init(struct hda_codec *codec)
  2989. {
  2990. alc880_auto_init_multi_out(codec);
  2991. alc880_auto_init_extra_out(codec);
  2992. alc880_auto_init_analog_input(codec);
  2993. }
  2994. /*
  2995. * OK, here we have finally the patch for ALC880
  2996. */
  2997. static int patch_alc880(struct hda_codec *codec)
  2998. {
  2999. struct alc_spec *spec;
  3000. int board_config;
  3001. int err;
  3002. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  3003. if (spec == NULL)
  3004. return -ENOMEM;
  3005. codec->spec = spec;
  3006. board_config = snd_hda_check_board_config(codec, ALC880_MODEL_LAST,
  3007. alc880_models,
  3008. alc880_cfg_tbl);
  3009. if (board_config < 0) {
  3010. printk(KERN_INFO "hda_codec: Unknown model for ALC880, "
  3011. "trying auto-probe from BIOS...\n");
  3012. board_config = ALC880_AUTO;
  3013. }
  3014. if (board_config == ALC880_AUTO) {
  3015. /* automatic parse from the BIOS config */
  3016. err = alc880_parse_auto_config(codec);
  3017. if (err < 0) {
  3018. alc_free(codec);
  3019. return err;
  3020. } else if (!err) {
  3021. printk(KERN_INFO
  3022. "hda_codec: Cannot set up configuration "
  3023. "from BIOS. Using 3-stack mode...\n");
  3024. board_config = ALC880_3ST;
  3025. }
  3026. }
  3027. if (board_config != ALC880_AUTO)
  3028. setup_preset(spec, &alc880_presets[board_config]);
  3029. spec->stream_name_analog = "ALC880 Analog";
  3030. spec->stream_analog_playback = &alc880_pcm_analog_playback;
  3031. spec->stream_analog_capture = &alc880_pcm_analog_capture;
  3032. spec->stream_name_digital = "ALC880 Digital";
  3033. spec->stream_digital_playback = &alc880_pcm_digital_playback;
  3034. spec->stream_digital_capture = &alc880_pcm_digital_capture;
  3035. if (!spec->adc_nids && spec->input_mux) {
  3036. /* check whether NID 0x07 is valid */
  3037. unsigned int wcap = get_wcaps(codec, alc880_adc_nids[0]);
  3038. /* get type */
  3039. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  3040. if (wcap != AC_WID_AUD_IN) {
  3041. spec->adc_nids = alc880_adc_nids_alt;
  3042. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids_alt);
  3043. spec->mixers[spec->num_mixers] =
  3044. alc880_capture_alt_mixer;
  3045. spec->num_mixers++;
  3046. } else {
  3047. spec->adc_nids = alc880_adc_nids;
  3048. spec->num_adc_nids = ARRAY_SIZE(alc880_adc_nids);
  3049. spec->mixers[spec->num_mixers] = alc880_capture_mixer;
  3050. spec->num_mixers++;
  3051. }
  3052. }
  3053. codec->patch_ops = alc_patch_ops;
  3054. if (board_config == ALC880_AUTO)
  3055. spec->init_hook = alc880_auto_init;
  3056. return 0;
  3057. }
  3058. /*
  3059. * ALC260 support
  3060. */
  3061. static hda_nid_t alc260_dac_nids[1] = {
  3062. /* front */
  3063. 0x02,
  3064. };
  3065. static hda_nid_t alc260_adc_nids[1] = {
  3066. /* ADC0 */
  3067. 0x04,
  3068. };
  3069. static hda_nid_t alc260_adc_nids_alt[1] = {
  3070. /* ADC1 */
  3071. 0x05,
  3072. };
  3073. static hda_nid_t alc260_hp_adc_nids[2] = {
  3074. /* ADC1, 0 */
  3075. 0x05, 0x04
  3076. };
  3077. /* NIDs used when simultaneous access to both ADCs makes sense. Note that
  3078. * alc260_capture_mixer assumes ADC0 (nid 0x04) is the first ADC.
  3079. */
  3080. static hda_nid_t alc260_dual_adc_nids[2] = {
  3081. /* ADC0, ADC1 */
  3082. 0x04, 0x05
  3083. };
  3084. #define ALC260_DIGOUT_NID 0x03
  3085. #define ALC260_DIGIN_NID 0x06
  3086. static struct hda_input_mux alc260_capture_source = {
  3087. .num_items = 4,
  3088. .items = {
  3089. { "Mic", 0x0 },
  3090. { "Front Mic", 0x1 },
  3091. { "Line", 0x2 },
  3092. { "CD", 0x4 },
  3093. },
  3094. };
  3095. /* On Fujitsu S702x laptops capture only makes sense from Mic/LineIn jack,
  3096. * headphone jack and the internal CD lines since these are the only pins at
  3097. * which audio can appear. For flexibility, also allow the option of
  3098. * recording the mixer output on the second ADC (ADC0 doesn't have a
  3099. * connection to the mixer output).
  3100. */
  3101. static struct hda_input_mux alc260_fujitsu_capture_sources[2] = {
  3102. {
  3103. .num_items = 3,
  3104. .items = {
  3105. { "Mic/Line", 0x0 },
  3106. { "CD", 0x4 },
  3107. { "Headphone", 0x2 },
  3108. },
  3109. },
  3110. {
  3111. .num_items = 4,
  3112. .items = {
  3113. { "Mic/Line", 0x0 },
  3114. { "CD", 0x4 },
  3115. { "Headphone", 0x2 },
  3116. { "Mixer", 0x5 },
  3117. },
  3118. },
  3119. };
  3120. /* Acer TravelMate(/Extensa/Aspire) notebooks have similar configuration to
  3121. * the Fujitsu S702x, but jacks are marked differently.
  3122. */
  3123. static struct hda_input_mux alc260_acer_capture_sources[2] = {
  3124. {
  3125. .num_items = 4,
  3126. .items = {
  3127. { "Mic", 0x0 },
  3128. { "Line", 0x2 },
  3129. { "CD", 0x4 },
  3130. { "Headphone", 0x5 },
  3131. },
  3132. },
  3133. {
  3134. .num_items = 5,
  3135. .items = {
  3136. { "Mic", 0x0 },
  3137. { "Line", 0x2 },
  3138. { "CD", 0x4 },
  3139. { "Headphone", 0x6 },
  3140. { "Mixer", 0x5 },
  3141. },
  3142. },
  3143. };
  3144. /*
  3145. * This is just place-holder, so there's something for alc_build_pcms to look
  3146. * at when it calculates the maximum number of channels. ALC260 has no mixer
  3147. * element which allows changing the channel mode, so the verb list is
  3148. * never used.
  3149. */
  3150. static struct hda_channel_mode alc260_modes[1] = {
  3151. { 2, NULL },
  3152. };
  3153. /* Mixer combinations
  3154. *
  3155. * basic: base_output + input + pc_beep + capture
  3156. * HP: base_output + input + capture_alt
  3157. * HP_3013: hp_3013 + input + capture
  3158. * fujitsu: fujitsu + capture
  3159. * acer: acer + capture
  3160. */
  3161. static struct snd_kcontrol_new alc260_base_output_mixer[] = {
  3162. HDA_CODEC_VOLUME("Front Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3163. HDA_BIND_MUTE("Front Playback Switch", 0x08, 2, HDA_INPUT),
  3164. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3165. HDA_BIND_MUTE("Headphone Playback Switch", 0x09, 2, HDA_INPUT),
  3166. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3167. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3168. { } /* end */
  3169. };
  3170. static struct snd_kcontrol_new alc260_input_mixer[] = {
  3171. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3172. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3173. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3174. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3175. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3176. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3177. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x07, 0x01, HDA_INPUT),
  3178. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x07, 0x01, HDA_INPUT),
  3179. { } /* end */
  3180. };
  3181. static struct snd_kcontrol_new alc260_pc_beep_mixer[] = {
  3182. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x07, 0x05, HDA_INPUT),
  3183. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x07, 0x05, HDA_INPUT),
  3184. { } /* end */
  3185. };
  3186. static struct snd_kcontrol_new alc260_hp_3013_mixer[] = {
  3187. HDA_CODEC_VOLUME("Front Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3188. HDA_CODEC_MUTE("Front Playback Switch", 0x10, 0x0, HDA_OUTPUT),
  3189. HDA_CODEC_VOLUME("Aux-In Playback Volume", 0x07, 0x06, HDA_INPUT),
  3190. HDA_CODEC_MUTE("Aux-In Playback Switch", 0x07, 0x06, HDA_INPUT),
  3191. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3192. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  3193. HDA_CODEC_VOLUME_MONO("iSpeaker Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3194. HDA_CODEC_MUTE_MONO("iSpeaker Playback Switch", 0x11, 1, 0x0, HDA_OUTPUT),
  3195. { } /* end */
  3196. };
  3197. /* Fujitsu S702x series laptops. ALC260 pin usage: Mic/Line jack = 0x12,
  3198. * HP jack = 0x14, CD audio = 0x16, internal speaker = 0x10.
  3199. */
  3200. static struct snd_kcontrol_new alc260_fujitsu_mixer[] = {
  3201. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3202. HDA_BIND_MUTE("Headphone Playback Switch", 0x08, 2, HDA_INPUT),
  3203. ALC_PIN_MODE("Headphone Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3204. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3205. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3206. HDA_CODEC_VOLUME("Mic/Line Playback Volume", 0x07, 0x0, HDA_INPUT),
  3207. HDA_CODEC_MUTE("Mic/Line Playback Switch", 0x07, 0x0, HDA_INPUT),
  3208. ALC_PIN_MODE("Mic/Line Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3209. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3210. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3211. HDA_CODEC_VOLUME("Internal Speaker Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3212. HDA_BIND_MUTE("Internal Speaker Playback Switch", 0x09, 2, HDA_INPUT),
  3213. { } /* end */
  3214. };
  3215. /* Mixer for Acer TravelMate(/Extensa/Aspire) notebooks. Note that current
  3216. * versions of the ALC260 don't act on requests to enable mic bias from NID
  3217. * 0x0f (used to drive the headphone jack in these laptops). The ALC260
  3218. * datasheet doesn't mention this restriction. At this stage it's not clear
  3219. * whether this behaviour is intentional or is a hardware bug in chip
  3220. * revisions available in early 2006. Therefore for now allow the
  3221. * "Headphone Jack Mode" control to span all choices, but if it turns out
  3222. * that the lack of mic bias for this NID is intentional we could change the
  3223. * mode from ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3224. *
  3225. * In addition, Acer TravelMate(/Extensa/Aspire) notebooks in early 2006
  3226. * don't appear to make the mic bias available from the "line" jack, even
  3227. * though the NID used for this jack (0x14) can supply it. The theory is
  3228. * that perhaps Acer have included blocking capacitors between the ALC260
  3229. * and the output jack. If this turns out to be the case for all such
  3230. * models the "Line Jack Mode" mode could be changed from ALC_PIN_DIR_INOUT
  3231. * to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3232. *
  3233. * The C20x Tablet series have a mono internal speaker which is controlled
  3234. * via the chip's Mono sum widget and pin complex, so include the necessary
  3235. * controls for such models. On models without a "mono speaker" the control
  3236. * won't do anything.
  3237. */
  3238. static struct snd_kcontrol_new alc260_acer_mixer[] = {
  3239. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3240. HDA_BIND_MUTE("Master Playback Switch", 0x08, 2, HDA_INPUT),
  3241. ALC_PIN_MODE("Headphone Jack Mode", 0x0f, ALC_PIN_DIR_INOUT),
  3242. HDA_CODEC_VOLUME_MONO("Mono Speaker Playback Volume", 0x0a, 1, 0x0,
  3243. HDA_OUTPUT),
  3244. HDA_BIND_MUTE_MONO("Mono Speaker Playback Switch", 0x0a, 1, 2,
  3245. HDA_INPUT),
  3246. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3247. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3248. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3249. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3250. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3251. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3252. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3253. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3254. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3255. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3256. { } /* end */
  3257. };
  3258. /* Packard bell V7900 ALC260 pin usage: HP = 0x0f, Mic jack = 0x12,
  3259. * Line In jack = 0x14, CD audio = 0x16, pc beep = 0x17.
  3260. */
  3261. static struct snd_kcontrol_new alc260_will_mixer[] = {
  3262. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3263. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3264. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3265. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3266. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3267. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3268. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3269. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3270. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3271. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3272. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3273. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3274. { } /* end */
  3275. };
  3276. /* Replacer 672V ALC260 pin usage: Mic jack = 0x12,
  3277. * Line In jack = 0x14, ATAPI Mic = 0x13, speaker = 0x0f.
  3278. */
  3279. static struct snd_kcontrol_new alc260_replacer_672v_mixer[] = {
  3280. HDA_CODEC_VOLUME("Master Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3281. HDA_BIND_MUTE("Master Playback Switch", 0x08, 0x2, HDA_INPUT),
  3282. HDA_CODEC_VOLUME("Mic Playback Volume", 0x07, 0x0, HDA_INPUT),
  3283. HDA_CODEC_MUTE("Mic Playback Switch", 0x07, 0x0, HDA_INPUT),
  3284. ALC_PIN_MODE("Mic Jack Mode", 0x12, ALC_PIN_DIR_IN),
  3285. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x07, 0x1, HDA_INPUT),
  3286. HDA_CODEC_MUTE("ATATI Mic Playback Switch", 0x07, 0x1, HDA_INPUT),
  3287. HDA_CODEC_VOLUME("Line Playback Volume", 0x07, 0x02, HDA_INPUT),
  3288. HDA_CODEC_MUTE("Line Playback Switch", 0x07, 0x02, HDA_INPUT),
  3289. ALC_PIN_MODE("Line Jack Mode", 0x14, ALC_PIN_DIR_INOUT),
  3290. { } /* end */
  3291. };
  3292. /* capture mixer elements */
  3293. static struct snd_kcontrol_new alc260_capture_mixer[] = {
  3294. HDA_CODEC_VOLUME("Capture Volume", 0x04, 0x0, HDA_INPUT),
  3295. HDA_CODEC_MUTE("Capture Switch", 0x04, 0x0, HDA_INPUT),
  3296. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x05, 0x0, HDA_INPUT),
  3297. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x05, 0x0, HDA_INPUT),
  3298. {
  3299. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3300. /* The multiple "Capture Source" controls confuse alsamixer
  3301. * So call somewhat different..
  3302. * FIXME: the controls appear in the "playback" view!
  3303. */
  3304. /* .name = "Capture Source", */
  3305. .name = "Input Source",
  3306. .count = 2,
  3307. .info = alc_mux_enum_info,
  3308. .get = alc_mux_enum_get,
  3309. .put = alc_mux_enum_put,
  3310. },
  3311. { } /* end */
  3312. };
  3313. static struct snd_kcontrol_new alc260_capture_alt_mixer[] = {
  3314. HDA_CODEC_VOLUME("Capture Volume", 0x05, 0x0, HDA_INPUT),
  3315. HDA_CODEC_MUTE("Capture Switch", 0x05, 0x0, HDA_INPUT),
  3316. {
  3317. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  3318. /* The multiple "Capture Source" controls confuse alsamixer
  3319. * So call somewhat different..
  3320. * FIXME: the controls appear in the "playback" view!
  3321. */
  3322. /* .name = "Capture Source", */
  3323. .name = "Input Source",
  3324. .count = 1,
  3325. .info = alc_mux_enum_info,
  3326. .get = alc_mux_enum_get,
  3327. .put = alc_mux_enum_put,
  3328. },
  3329. { } /* end */
  3330. };
  3331. /*
  3332. * initialization verbs
  3333. */
  3334. static struct hda_verb alc260_init_verbs[] = {
  3335. /* Line In pin widget for input */
  3336. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3337. /* CD pin widget for input */
  3338. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3339. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3340. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3341. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3342. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  3343. /* LINE-2 is used for line-out in rear */
  3344. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3345. /* select line-out */
  3346. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  3347. /* LINE-OUT pin */
  3348. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3349. /* enable HP */
  3350. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3351. /* enable Mono */
  3352. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3353. /* mute capture amp left and right */
  3354. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3355. /* set connection select to line in (default select for this ADC) */
  3356. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3357. /* mute capture amp left and right */
  3358. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3359. /* set connection select to line in (default select for this ADC) */
  3360. {0x05, AC_VERB_SET_CONNECT_SEL, 0x02},
  3361. /* set vol=0 Line-Out mixer amp left and right */
  3362. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3363. /* unmute pin widget amp left and right (no gain on this amp) */
  3364. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3365. /* set vol=0 HP mixer amp left and right */
  3366. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3367. /* unmute pin widget amp left and right (no gain on this amp) */
  3368. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3369. /* set vol=0 Mono mixer amp left and right */
  3370. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3371. /* unmute pin widget amp left and right (no gain on this amp) */
  3372. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3373. /* unmute LINE-2 out pin */
  3374. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3375. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3376. * Line In 2 = 0x03
  3377. */
  3378. /* mute CD */
  3379. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  3380. /* mute Line In */
  3381. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  3382. /* mute Mic */
  3383. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3384. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3385. /* mute Front out path */
  3386. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3387. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3388. /* mute Headphone out path */
  3389. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3390. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3391. /* mute Mono out path */
  3392. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3393. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3394. { }
  3395. };
  3396. #if 0 /* should be identical with alc260_init_verbs? */
  3397. static struct hda_verb alc260_hp_init_verbs[] = {
  3398. /* Headphone and output */
  3399. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3400. /* mono output */
  3401. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3402. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3403. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3404. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3405. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3406. /* Line In pin widget for input */
  3407. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3408. /* Line-2 pin widget for output */
  3409. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3410. /* CD pin widget for input */
  3411. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3412. /* unmute amp left and right */
  3413. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3414. /* set connection select to line in (default select for this ADC) */
  3415. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3416. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3417. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3418. /* mute pin widget amp left and right (no gain on this amp) */
  3419. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3420. /* unmute HP mixer amp left and right (volume = 0) */
  3421. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3422. /* mute pin widget amp left and right (no gain on this amp) */
  3423. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3424. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3425. * Line In 2 = 0x03
  3426. */
  3427. /* unmute CD */
  3428. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3429. /* unmute Line In */
  3430. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3431. /* unmute Mic */
  3432. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3433. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3434. /* Unmute Front out path */
  3435. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3436. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3437. /* Unmute Headphone out path */
  3438. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3439. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3440. /* Unmute Mono out path */
  3441. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3442. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3443. { }
  3444. };
  3445. #endif
  3446. static struct hda_verb alc260_hp_3013_init_verbs[] = {
  3447. /* Line out and output */
  3448. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3449. /* mono output */
  3450. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  3451. /* Mic1 (rear panel) pin widget for input and vref at 80% */
  3452. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3453. /* Mic2 (front panel) pin widget for input and vref at 80% */
  3454. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  3455. /* Line In pin widget for input */
  3456. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3457. /* Headphone pin widget for output */
  3458. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  3459. /* CD pin widget for input */
  3460. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  3461. /* unmute amp left and right */
  3462. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000},
  3463. /* set connection select to line in (default select for this ADC) */
  3464. {0x04, AC_VERB_SET_CONNECT_SEL, 0x02},
  3465. /* unmute Line-Out mixer amp left and right (volume = 0) */
  3466. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3467. /* mute pin widget amp left and right (no gain on this amp) */
  3468. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3469. /* unmute HP mixer amp left and right (volume = 0) */
  3470. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, 0xb000},
  3471. /* mute pin widget amp left and right (no gain on this amp) */
  3472. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  3473. /* Amp Indexes: CD = 0x04, Line In 1 = 0x02, Mic 1 = 0x00 &
  3474. * Line In 2 = 0x03
  3475. */
  3476. /* unmute CD */
  3477. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  3478. /* unmute Line In */
  3479. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  3480. /* unmute Mic */
  3481. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3482. /* Amp Indexes: DAC = 0x01 & mixer = 0x00 */
  3483. /* Unmute Front out path */
  3484. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3485. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3486. /* Unmute Headphone out path */
  3487. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3488. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3489. /* Unmute Mono out path */
  3490. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  3491. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  3492. { }
  3493. };
  3494. /* Initialisation sequence for ALC260 as configured in Fujitsu S702x
  3495. * laptops. ALC260 pin usage: Mic/Line jack = 0x12, HP jack = 0x14, CD
  3496. * audio = 0x16, internal speaker = 0x10.
  3497. */
  3498. static struct hda_verb alc260_fujitsu_init_verbs[] = {
  3499. /* Disable all GPIOs */
  3500. {0x01, AC_VERB_SET_GPIO_MASK, 0},
  3501. /* Internal speaker is connected to headphone pin */
  3502. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3503. /* Headphone/Line-out jack connects to Line1 pin; make it an output */
  3504. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3505. /* Mic/Line-in jack is connected to mic1 pin, so make it an input */
  3506. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3507. /* Ensure all other unused pins are disabled and muted. */
  3508. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3509. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3510. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3511. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3512. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3513. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3514. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3515. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3516. /* Disable digital (SPDIF) pins */
  3517. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3518. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3519. /* Ensure Line1 pin widget takes its input from the OUT1 sum bus
  3520. * when acting as an output.
  3521. */
  3522. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3523. /* Start with output sum widgets muted and their output gains at min */
  3524. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3525. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3526. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3527. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3528. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3529. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3530. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3531. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3532. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3533. /* Unmute HP pin widget amp left and right (no equiv mixer ctrl) */
  3534. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3535. /* Unmute Line1 pin widget output buffer since it starts as an output.
  3536. * If the pin mode is changed by the user the pin mode control will
  3537. * take care of enabling the pin's input/output buffers as needed.
  3538. * Therefore there's no need to enable the input buffer at this
  3539. * stage.
  3540. */
  3541. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3542. /* Unmute input buffer of pin widget used for Line-in (no equiv
  3543. * mixer ctrl)
  3544. */
  3545. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3546. /* Mute capture amp left and right */
  3547. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3548. /* Set ADC connection select to match default mixer setting - line
  3549. * in (on mic1 pin)
  3550. */
  3551. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3552. /* Do the same for the second ADC: mute capture input amp and
  3553. * set ADC connection to line in (on mic1 pin)
  3554. */
  3555. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3556. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3557. /* Mute all inputs to mixer widget (even unconnected ones) */
  3558. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3559. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3560. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3561. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3562. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3563. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3564. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3565. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3566. { }
  3567. };
  3568. /* Initialisation sequence for ALC260 as configured in Acer TravelMate and
  3569. * similar laptops (adapted from Fujitsu init verbs).
  3570. */
  3571. static struct hda_verb alc260_acer_init_verbs[] = {
  3572. /* On TravelMate laptops, GPIO 0 enables the internal speaker and
  3573. * the headphone jack. Turn this on and rely on the standard mute
  3574. * methods whenever the user wants to turn these outputs off.
  3575. */
  3576. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3577. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3578. {0x01, AC_VERB_SET_GPIO_DATA, 0x01},
  3579. /* Internal speaker/Headphone jack is connected to Line-out pin */
  3580. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3581. /* Internal microphone/Mic jack is connected to Mic1 pin */
  3582. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  3583. /* Line In jack is connected to Line1 pin */
  3584. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  3585. /* Some Acers (eg: C20x Tablets) use Mono pin for internal speaker */
  3586. {0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3587. /* Ensure all other unused pins are disabled and muted. */
  3588. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3589. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3590. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3591. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3592. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0},
  3593. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3594. /* Disable digital (SPDIF) pins */
  3595. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3596. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3597. /* Ensure Mic1 and Line1 pin widgets take input from the OUT1 sum
  3598. * bus when acting as outputs.
  3599. */
  3600. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3601. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3602. /* Start with output sum widgets muted and their output gains at min */
  3603. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3604. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3605. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3606. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3607. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3608. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3609. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3610. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3611. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3612. /* Unmute Line-out pin widget amp left and right
  3613. * (no equiv mixer ctrl)
  3614. */
  3615. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3616. /* Unmute mono pin widget amp output (no equiv mixer ctrl) */
  3617. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3618. /* Unmute Mic1 and Line1 pin widget input buffers since they start as
  3619. * inputs. If the pin mode is changed by the user the pin mode control
  3620. * will take care of enabling the pin's input/output buffers as needed.
  3621. * Therefore there's no need to enable the input buffer at this
  3622. * stage.
  3623. */
  3624. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3625. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  3626. /* Mute capture amp left and right */
  3627. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3628. /* Set ADC connection select to match default mixer setting - mic
  3629. * (on mic1 pin)
  3630. */
  3631. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3632. /* Do similar with the second ADC: mute capture input amp and
  3633. * set ADC connection to mic to match ALSA's default state.
  3634. */
  3635. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3636. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3637. /* Mute all inputs to mixer widget (even unconnected ones) */
  3638. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3639. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3640. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3641. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3642. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3643. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3644. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3645. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3646. { }
  3647. };
  3648. static struct hda_verb alc260_will_verbs[] = {
  3649. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  3650. {0x0b, AC_VERB_SET_CONNECT_SEL, 0x00},
  3651. {0x0d, AC_VERB_SET_CONNECT_SEL, 0x00},
  3652. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3653. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3654. {0x1a, AC_VERB_SET_PROC_COEF, 0x3040},
  3655. {}
  3656. };
  3657. static struct hda_verb alc260_replacer_672v_verbs[] = {
  3658. {0x0f, AC_VERB_SET_EAPD_BTLENABLE, 0x02},
  3659. {0x1a, AC_VERB_SET_COEF_INDEX, 0x07},
  3660. {0x1a, AC_VERB_SET_PROC_COEF, 0x3050},
  3661. {0x01, AC_VERB_SET_GPIO_MASK, 0x01},
  3662. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x01},
  3663. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3664. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  3665. {}
  3666. };
  3667. /* toggle speaker-output according to the hp-jack state */
  3668. static void alc260_replacer_672v_automute(struct hda_codec *codec)
  3669. {
  3670. unsigned int present;
  3671. /* speaker --> GPIO Data 0, hp or spdif --> GPIO data 1 */
  3672. present = snd_hda_codec_read(codec, 0x0f, 0,
  3673. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  3674. if (present) {
  3675. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 1);
  3676. snd_hda_codec_write(codec, 0x0f, 0,
  3677. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  3678. } else {
  3679. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA, 0);
  3680. snd_hda_codec_write(codec, 0x0f, 0,
  3681. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  3682. }
  3683. }
  3684. static void alc260_replacer_672v_unsol_event(struct hda_codec *codec,
  3685. unsigned int res)
  3686. {
  3687. if ((res >> 26) == ALC880_HP_EVENT)
  3688. alc260_replacer_672v_automute(codec);
  3689. }
  3690. /* Test configuration for debugging, modelled after the ALC880 test
  3691. * configuration.
  3692. */
  3693. #ifdef CONFIG_SND_DEBUG
  3694. static hda_nid_t alc260_test_dac_nids[1] = {
  3695. 0x02,
  3696. };
  3697. static hda_nid_t alc260_test_adc_nids[2] = {
  3698. 0x04, 0x05,
  3699. };
  3700. /* For testing the ALC260, each input MUX needs its own definition since
  3701. * the signal assignments are different. This assumes that the first ADC
  3702. * is NID 0x04.
  3703. */
  3704. static struct hda_input_mux alc260_test_capture_sources[2] = {
  3705. {
  3706. .num_items = 7,
  3707. .items = {
  3708. { "MIC1 pin", 0x0 },
  3709. { "MIC2 pin", 0x1 },
  3710. { "LINE1 pin", 0x2 },
  3711. { "LINE2 pin", 0x3 },
  3712. { "CD pin", 0x4 },
  3713. { "LINE-OUT pin", 0x5 },
  3714. { "HP-OUT pin", 0x6 },
  3715. },
  3716. },
  3717. {
  3718. .num_items = 8,
  3719. .items = {
  3720. { "MIC1 pin", 0x0 },
  3721. { "MIC2 pin", 0x1 },
  3722. { "LINE1 pin", 0x2 },
  3723. { "LINE2 pin", 0x3 },
  3724. { "CD pin", 0x4 },
  3725. { "Mixer", 0x5 },
  3726. { "LINE-OUT pin", 0x6 },
  3727. { "HP-OUT pin", 0x7 },
  3728. },
  3729. },
  3730. };
  3731. static struct snd_kcontrol_new alc260_test_mixer[] = {
  3732. /* Output driver widgets */
  3733. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0a, 1, 0x0, HDA_OUTPUT),
  3734. HDA_BIND_MUTE_MONO("Mono Playback Switch", 0x0a, 1, 2, HDA_INPUT),
  3735. HDA_CODEC_VOLUME("LOUT2 Playback Volume", 0x09, 0x0, HDA_OUTPUT),
  3736. HDA_BIND_MUTE("LOUT2 Playback Switch", 0x09, 2, HDA_INPUT),
  3737. HDA_CODEC_VOLUME("LOUT1 Playback Volume", 0x08, 0x0, HDA_OUTPUT),
  3738. HDA_BIND_MUTE("LOUT1 Playback Switch", 0x08, 2, HDA_INPUT),
  3739. /* Modes for retasking pin widgets
  3740. * Note: the ALC260 doesn't seem to act on requests to enable mic
  3741. * bias from NIDs 0x0f and 0x10. The ALC260 datasheet doesn't
  3742. * mention this restriction. At this stage it's not clear whether
  3743. * this behaviour is intentional or is a hardware bug in chip
  3744. * revisions available at least up until early 2006. Therefore for
  3745. * now allow the "HP-OUT" and "LINE-OUT" Mode controls to span all
  3746. * choices, but if it turns out that the lack of mic bias for these
  3747. * NIDs is intentional we could change their modes from
  3748. * ALC_PIN_DIR_INOUT to ALC_PIN_DIR_INOUT_NOMICBIAS.
  3749. */
  3750. ALC_PIN_MODE("HP-OUT pin mode", 0x10, ALC_PIN_DIR_INOUT),
  3751. ALC_PIN_MODE("LINE-OUT pin mode", 0x0f, ALC_PIN_DIR_INOUT),
  3752. ALC_PIN_MODE("LINE2 pin mode", 0x15, ALC_PIN_DIR_INOUT),
  3753. ALC_PIN_MODE("LINE1 pin mode", 0x14, ALC_PIN_DIR_INOUT),
  3754. ALC_PIN_MODE("MIC2 pin mode", 0x13, ALC_PIN_DIR_INOUT),
  3755. ALC_PIN_MODE("MIC1 pin mode", 0x12, ALC_PIN_DIR_INOUT),
  3756. /* Loopback mixer controls */
  3757. HDA_CODEC_VOLUME("MIC1 Playback Volume", 0x07, 0x00, HDA_INPUT),
  3758. HDA_CODEC_MUTE("MIC1 Playback Switch", 0x07, 0x00, HDA_INPUT),
  3759. HDA_CODEC_VOLUME("MIC2 Playback Volume", 0x07, 0x01, HDA_INPUT),
  3760. HDA_CODEC_MUTE("MIC2 Playback Switch", 0x07, 0x01, HDA_INPUT),
  3761. HDA_CODEC_VOLUME("LINE1 Playback Volume", 0x07, 0x02, HDA_INPUT),
  3762. HDA_CODEC_MUTE("LINE1 Playback Switch", 0x07, 0x02, HDA_INPUT),
  3763. HDA_CODEC_VOLUME("LINE2 Playback Volume", 0x07, 0x03, HDA_INPUT),
  3764. HDA_CODEC_MUTE("LINE2 Playback Switch", 0x07, 0x03, HDA_INPUT),
  3765. HDA_CODEC_VOLUME("CD Playback Volume", 0x07, 0x04, HDA_INPUT),
  3766. HDA_CODEC_MUTE("CD Playback Switch", 0x07, 0x04, HDA_INPUT),
  3767. HDA_CODEC_VOLUME("Beep Playback Volume", 0x07, 0x05, HDA_INPUT),
  3768. HDA_CODEC_MUTE("Beep Playback Switch", 0x07, 0x05, HDA_INPUT),
  3769. HDA_CODEC_VOLUME("LINE-OUT loopback Playback Volume", 0x07, 0x06, HDA_INPUT),
  3770. HDA_CODEC_MUTE("LINE-OUT loopback Playback Switch", 0x07, 0x06, HDA_INPUT),
  3771. HDA_CODEC_VOLUME("HP-OUT loopback Playback Volume", 0x07, 0x7, HDA_INPUT),
  3772. HDA_CODEC_MUTE("HP-OUT loopback Playback Switch", 0x07, 0x7, HDA_INPUT),
  3773. /* Controls for GPIO pins, assuming they are configured as outputs */
  3774. ALC_GPIO_DATA_SWITCH("GPIO pin 0", 0x01, 0x01),
  3775. ALC_GPIO_DATA_SWITCH("GPIO pin 1", 0x01, 0x02),
  3776. ALC_GPIO_DATA_SWITCH("GPIO pin 2", 0x01, 0x04),
  3777. ALC_GPIO_DATA_SWITCH("GPIO pin 3", 0x01, 0x08),
  3778. /* Switches to allow the digital IO pins to be enabled. The datasheet
  3779. * is ambigious as to which NID is which; testing on laptops which
  3780. * make this output available should provide clarification.
  3781. */
  3782. ALC_SPDIF_CTRL_SWITCH("SPDIF Playback Switch", 0x03, 0x01),
  3783. ALC_SPDIF_CTRL_SWITCH("SPDIF Capture Switch", 0x06, 0x01),
  3784. { } /* end */
  3785. };
  3786. static struct hda_verb alc260_test_init_verbs[] = {
  3787. /* Enable all GPIOs as outputs with an initial value of 0 */
  3788. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x0f},
  3789. {0x01, AC_VERB_SET_GPIO_DATA, 0x00},
  3790. {0x01, AC_VERB_SET_GPIO_MASK, 0x0f},
  3791. /* Enable retasking pins as output, initially without power amp */
  3792. {0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3793. {0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3794. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3795. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3796. {0x13, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3797. {0x12, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  3798. /* Disable digital (SPDIF) pins initially, but users can enable
  3799. * them via a mixer switch. In the case of SPDIF-out, this initverb
  3800. * payload also sets the generation to 0, output to be in "consumer"
  3801. * PCM format, copyright asserted, no pre-emphasis and no validity
  3802. * control.
  3803. */
  3804. {0x03, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3805. {0x06, AC_VERB_SET_DIGI_CONVERT_1, 0},
  3806. /* Ensure mic1, mic2, line1 and line2 pin widgets take input from the
  3807. * OUT1 sum bus when acting as an output.
  3808. */
  3809. {0x0b, AC_VERB_SET_CONNECT_SEL, 0},
  3810. {0x0c, AC_VERB_SET_CONNECT_SEL, 0},
  3811. {0x0d, AC_VERB_SET_CONNECT_SEL, 0},
  3812. {0x0e, AC_VERB_SET_CONNECT_SEL, 0},
  3813. /* Start with output sum widgets muted and their output gains at min */
  3814. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3815. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3816. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3817. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3818. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3819. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3820. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3821. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  3822. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  3823. /* Unmute retasking pin widget output buffers since the default
  3824. * state appears to be output. As the pin mode is changed by the
  3825. * user the pin mode control will take care of enabling the pin's
  3826. * input/output buffers as needed.
  3827. */
  3828. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3829. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3830. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3831. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3832. {0x13, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3833. {0x12, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3834. /* Also unmute the mono-out pin widget */
  3835. {0x11, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  3836. /* Mute capture amp left and right */
  3837. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3838. /* Set ADC connection select to match default mixer setting (mic1
  3839. * pin)
  3840. */
  3841. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  3842. /* Do the same for the second ADC: mute capture input amp and
  3843. * set ADC connection to mic1 pin
  3844. */
  3845. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  3846. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  3847. /* Mute all inputs to mixer widget (even unconnected ones) */
  3848. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)}, /* mic1 pin */
  3849. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)}, /* mic2 pin */
  3850. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)}, /* line1 pin */
  3851. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)}, /* line2 pin */
  3852. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)}, /* CD pin */
  3853. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)}, /* Beep-gen pin */
  3854. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(6)}, /* Line-out pin */
  3855. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(7)}, /* HP-pin pin */
  3856. { }
  3857. };
  3858. #endif
  3859. static struct hda_pcm_stream alc260_pcm_analog_playback = {
  3860. .substreams = 1,
  3861. .channels_min = 2,
  3862. .channels_max = 2,
  3863. };
  3864. static struct hda_pcm_stream alc260_pcm_analog_capture = {
  3865. .substreams = 1,
  3866. .channels_min = 2,
  3867. .channels_max = 2,
  3868. };
  3869. #define alc260_pcm_digital_playback alc880_pcm_digital_playback
  3870. #define alc260_pcm_digital_capture alc880_pcm_digital_capture
  3871. /*
  3872. * for BIOS auto-configuration
  3873. */
  3874. static int alc260_add_playback_controls(struct alc_spec *spec, hda_nid_t nid,
  3875. const char *pfx)
  3876. {
  3877. hda_nid_t nid_vol;
  3878. unsigned long vol_val, sw_val;
  3879. char name[32];
  3880. int err;
  3881. if (nid >= 0x0f && nid < 0x11) {
  3882. nid_vol = nid - 0x7;
  3883. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3884. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3885. } else if (nid == 0x11) {
  3886. nid_vol = nid - 0x7;
  3887. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 2, 0, HDA_OUTPUT);
  3888. sw_val = HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_OUTPUT);
  3889. } else if (nid >= 0x12 && nid <= 0x15) {
  3890. nid_vol = 0x08;
  3891. vol_val = HDA_COMPOSE_AMP_VAL(nid_vol, 3, 0, HDA_OUTPUT);
  3892. sw_val = HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT);
  3893. } else
  3894. return 0; /* N/A */
  3895. snprintf(name, sizeof(name), "%s Playback Volume", pfx);
  3896. err = add_control(spec, ALC_CTL_WIDGET_VOL, name, vol_val);
  3897. if (err < 0)
  3898. return err;
  3899. snprintf(name, sizeof(name), "%s Playback Switch", pfx);
  3900. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name, sw_val);
  3901. if (err < 0)
  3902. return err;
  3903. return 1;
  3904. }
  3905. /* add playback controls from the parsed DAC table */
  3906. static int alc260_auto_create_multi_out_ctls(struct alc_spec *spec,
  3907. const struct auto_pin_cfg *cfg)
  3908. {
  3909. hda_nid_t nid;
  3910. int err;
  3911. spec->multiout.num_dacs = 1;
  3912. spec->multiout.dac_nids = spec->private_dac_nids;
  3913. spec->multiout.dac_nids[0] = 0x02;
  3914. nid = cfg->line_out_pins[0];
  3915. if (nid) {
  3916. err = alc260_add_playback_controls(spec, nid, "Front");
  3917. if (err < 0)
  3918. return err;
  3919. }
  3920. nid = cfg->speaker_pins[0];
  3921. if (nid) {
  3922. err = alc260_add_playback_controls(spec, nid, "Speaker");
  3923. if (err < 0)
  3924. return err;
  3925. }
  3926. nid = cfg->hp_pins[0];
  3927. if (nid) {
  3928. err = alc260_add_playback_controls(spec, nid, "Headphone");
  3929. if (err < 0)
  3930. return err;
  3931. }
  3932. return 0;
  3933. }
  3934. /* create playback/capture controls for input pins */
  3935. static int alc260_auto_create_analog_input_ctls(struct alc_spec *spec,
  3936. const struct auto_pin_cfg *cfg)
  3937. {
  3938. struct hda_input_mux *imux = &spec->private_imux;
  3939. int i, err, idx;
  3940. for (i = 0; i < AUTO_PIN_LAST; i++) {
  3941. if (cfg->input_pins[i] >= 0x12) {
  3942. idx = cfg->input_pins[i] - 0x12;
  3943. err = new_analog_input(spec, cfg->input_pins[i],
  3944. auto_pin_cfg_labels[i], idx,
  3945. 0x07);
  3946. if (err < 0)
  3947. return err;
  3948. imux->items[imux->num_items].label =
  3949. auto_pin_cfg_labels[i];
  3950. imux->items[imux->num_items].index = idx;
  3951. imux->num_items++;
  3952. }
  3953. if (cfg->input_pins[i] >= 0x0f && cfg->input_pins[i] <= 0x10){
  3954. idx = cfg->input_pins[i] - 0x09;
  3955. err = new_analog_input(spec, cfg->input_pins[i],
  3956. auto_pin_cfg_labels[i], idx,
  3957. 0x07);
  3958. if (err < 0)
  3959. return err;
  3960. imux->items[imux->num_items].label =
  3961. auto_pin_cfg_labels[i];
  3962. imux->items[imux->num_items].index = idx;
  3963. imux->num_items++;
  3964. }
  3965. }
  3966. return 0;
  3967. }
  3968. static void alc260_auto_set_output_and_unmute(struct hda_codec *codec,
  3969. hda_nid_t nid, int pin_type,
  3970. int sel_idx)
  3971. {
  3972. /* set as output */
  3973. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  3974. pin_type);
  3975. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  3976. AMP_OUT_UNMUTE);
  3977. /* need the manual connection? */
  3978. if (nid >= 0x12) {
  3979. int idx = nid - 0x12;
  3980. snd_hda_codec_write(codec, idx + 0x0b, 0,
  3981. AC_VERB_SET_CONNECT_SEL, sel_idx);
  3982. }
  3983. }
  3984. static void alc260_auto_init_multi_out(struct hda_codec *codec)
  3985. {
  3986. struct alc_spec *spec = codec->spec;
  3987. hda_nid_t nid;
  3988. alc_subsystem_id(codec, 0x10, 0x15, 0x0f);
  3989. nid = spec->autocfg.line_out_pins[0];
  3990. if (nid) {
  3991. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  3992. alc260_auto_set_output_and_unmute(codec, nid, pin_type, 0);
  3993. }
  3994. nid = spec->autocfg.speaker_pins[0];
  3995. if (nid)
  3996. alc260_auto_set_output_and_unmute(codec, nid, PIN_OUT, 0);
  3997. nid = spec->autocfg.hp_pins[0];
  3998. if (nid)
  3999. alc260_auto_set_output_and_unmute(codec, nid, PIN_HP, 0);
  4000. }
  4001. #define ALC260_PIN_CD_NID 0x16
  4002. static void alc260_auto_init_analog_input(struct hda_codec *codec)
  4003. {
  4004. struct alc_spec *spec = codec->spec;
  4005. int i;
  4006. for (i = 0; i < AUTO_PIN_LAST; i++) {
  4007. hda_nid_t nid = spec->autocfg.input_pins[i];
  4008. if (nid >= 0x12) {
  4009. snd_hda_codec_write(codec, nid, 0,
  4010. AC_VERB_SET_PIN_WIDGET_CONTROL,
  4011. i <= AUTO_PIN_FRONT_MIC ?
  4012. PIN_VREF80 : PIN_IN);
  4013. if (nid != ALC260_PIN_CD_NID)
  4014. snd_hda_codec_write(codec, nid, 0,
  4015. AC_VERB_SET_AMP_GAIN_MUTE,
  4016. AMP_OUT_MUTE);
  4017. }
  4018. }
  4019. }
  4020. /*
  4021. * generic initialization of ADC, input mixers and output mixers
  4022. */
  4023. static struct hda_verb alc260_volume_init_verbs[] = {
  4024. /*
  4025. * Unmute ADC0-1 and set the default input to mic-in
  4026. */
  4027. {0x04, AC_VERB_SET_CONNECT_SEL, 0x00},
  4028. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4029. {0x05, AC_VERB_SET_CONNECT_SEL, 0x00},
  4030. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4031. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4032. * mixer widget
  4033. * Note: PASD motherboards uses the Line In 2 as the input for
  4034. * front panel mic (mic 2)
  4035. */
  4036. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4037. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4038. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4039. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4040. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4041. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4042. /*
  4043. * Set up output mixers (0x08 - 0x0a)
  4044. */
  4045. /* set vol=0 to output mixers */
  4046. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4047. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4048. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4049. /* set up input amps for analog loopback */
  4050. /* Amp Indices: DAC = 0, mixer = 1 */
  4051. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4052. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4053. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4054. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4055. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4056. {0x0a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4057. { }
  4058. };
  4059. static int alc260_parse_auto_config(struct hda_codec *codec)
  4060. {
  4061. struct alc_spec *spec = codec->spec;
  4062. unsigned int wcap;
  4063. int err;
  4064. static hda_nid_t alc260_ignore[] = { 0x17, 0 };
  4065. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  4066. alc260_ignore);
  4067. if (err < 0)
  4068. return err;
  4069. err = alc260_auto_create_multi_out_ctls(spec, &spec->autocfg);
  4070. if (err < 0)
  4071. return err;
  4072. if (!spec->kctl_alloc)
  4073. return 0; /* can't find valid BIOS pin config */
  4074. err = alc260_auto_create_analog_input_ctls(spec, &spec->autocfg);
  4075. if (err < 0)
  4076. return err;
  4077. spec->multiout.max_channels = 2;
  4078. if (spec->autocfg.dig_out_pin)
  4079. spec->multiout.dig_out_nid = ALC260_DIGOUT_NID;
  4080. if (spec->kctl_alloc)
  4081. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  4082. spec->init_verbs[spec->num_init_verbs++] = alc260_volume_init_verbs;
  4083. spec->num_mux_defs = 1;
  4084. spec->input_mux = &spec->private_imux;
  4085. /* check whether NID 0x04 is valid */
  4086. wcap = get_wcaps(codec, 0x04);
  4087. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT; /* get type */
  4088. if (wcap != AC_WID_AUD_IN) {
  4089. spec->adc_nids = alc260_adc_nids_alt;
  4090. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids_alt);
  4091. spec->mixers[spec->num_mixers] = alc260_capture_alt_mixer;
  4092. } else {
  4093. spec->adc_nids = alc260_adc_nids;
  4094. spec->num_adc_nids = ARRAY_SIZE(alc260_adc_nids);
  4095. spec->mixers[spec->num_mixers] = alc260_capture_mixer;
  4096. }
  4097. spec->num_mixers++;
  4098. return 1;
  4099. }
  4100. /* additional initialization for auto-configuration model */
  4101. static void alc260_auto_init(struct hda_codec *codec)
  4102. {
  4103. alc260_auto_init_multi_out(codec);
  4104. alc260_auto_init_analog_input(codec);
  4105. }
  4106. /*
  4107. * ALC260 configurations
  4108. */
  4109. static const char *alc260_models[ALC260_MODEL_LAST] = {
  4110. [ALC260_BASIC] = "basic",
  4111. [ALC260_HP] = "hp",
  4112. [ALC260_HP_3013] = "hp-3013",
  4113. [ALC260_FUJITSU_S702X] = "fujitsu",
  4114. [ALC260_ACER] = "acer",
  4115. [ALC260_WILL] = "will",
  4116. [ALC260_REPLACER_672V] = "replacer",
  4117. #ifdef CONFIG_SND_DEBUG
  4118. [ALC260_TEST] = "test",
  4119. #endif
  4120. [ALC260_AUTO] = "auto",
  4121. };
  4122. static struct snd_pci_quirk alc260_cfg_tbl[] = {
  4123. SND_PCI_QUIRK(0x1025, 0x007b, "Acer C20x", ALC260_ACER),
  4124. SND_PCI_QUIRK(0x1025, 0x008f, "Acer", ALC260_ACER),
  4125. SND_PCI_QUIRK(0x103c, 0x2808, "HP d5700", ALC260_HP_3013),
  4126. SND_PCI_QUIRK(0x103c, 0x280a, "HP d5750", ALC260_HP_3013),
  4127. SND_PCI_QUIRK(0x103c, 0x3010, "HP", ALC260_HP_3013),
  4128. SND_PCI_QUIRK(0x103c, 0x3011, "HP", ALC260_HP),
  4129. SND_PCI_QUIRK(0x103c, 0x3012, "HP", ALC260_HP_3013),
  4130. SND_PCI_QUIRK(0x103c, 0x3013, "HP", ALC260_HP_3013),
  4131. SND_PCI_QUIRK(0x103c, 0x3014, "HP", ALC260_HP),
  4132. SND_PCI_QUIRK(0x103c, 0x3015, "HP", ALC260_HP),
  4133. SND_PCI_QUIRK(0x103c, 0x3016, "HP", ALC260_HP),
  4134. SND_PCI_QUIRK(0x104d, 0x81bb, "Sony VAIO", ALC260_BASIC),
  4135. SND_PCI_QUIRK(0x104d, 0x81cc, "Sony VAIO", ALC260_BASIC),
  4136. SND_PCI_QUIRK(0x104d, 0x81cd, "Sony VAIO", ALC260_BASIC),
  4137. SND_PCI_QUIRK(0x10cf, 0x1326, "Fujitsu S702X", ALC260_FUJITSU_S702X),
  4138. SND_PCI_QUIRK(0x152d, 0x0729, "CTL U553W", ALC260_BASIC),
  4139. SND_PCI_QUIRK(0x1631, 0xc017, "PB V7900", ALC260_WILL),
  4140. SND_PCI_QUIRK(0x161f, 0x2057, "Replacer 672V", ALC260_REPLACER_672V),
  4141. {}
  4142. };
  4143. static struct alc_config_preset alc260_presets[] = {
  4144. [ALC260_BASIC] = {
  4145. .mixers = { alc260_base_output_mixer,
  4146. alc260_input_mixer,
  4147. alc260_pc_beep_mixer,
  4148. alc260_capture_mixer },
  4149. .init_verbs = { alc260_init_verbs },
  4150. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4151. .dac_nids = alc260_dac_nids,
  4152. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4153. .adc_nids = alc260_adc_nids,
  4154. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4155. .channel_mode = alc260_modes,
  4156. .input_mux = &alc260_capture_source,
  4157. },
  4158. [ALC260_HP] = {
  4159. .mixers = { alc260_base_output_mixer,
  4160. alc260_input_mixer,
  4161. alc260_capture_alt_mixer },
  4162. .init_verbs = { alc260_init_verbs },
  4163. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4164. .dac_nids = alc260_dac_nids,
  4165. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4166. .adc_nids = alc260_hp_adc_nids,
  4167. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4168. .channel_mode = alc260_modes,
  4169. .input_mux = &alc260_capture_source,
  4170. },
  4171. [ALC260_HP_3013] = {
  4172. .mixers = { alc260_hp_3013_mixer,
  4173. alc260_input_mixer,
  4174. alc260_capture_alt_mixer },
  4175. .init_verbs = { alc260_hp_3013_init_verbs },
  4176. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4177. .dac_nids = alc260_dac_nids,
  4178. .num_adc_nids = ARRAY_SIZE(alc260_hp_adc_nids),
  4179. .adc_nids = alc260_hp_adc_nids,
  4180. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4181. .channel_mode = alc260_modes,
  4182. .input_mux = &alc260_capture_source,
  4183. },
  4184. [ALC260_FUJITSU_S702X] = {
  4185. .mixers = { alc260_fujitsu_mixer,
  4186. alc260_capture_mixer },
  4187. .init_verbs = { alc260_fujitsu_init_verbs },
  4188. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4189. .dac_nids = alc260_dac_nids,
  4190. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4191. .adc_nids = alc260_dual_adc_nids,
  4192. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4193. .channel_mode = alc260_modes,
  4194. .num_mux_defs = ARRAY_SIZE(alc260_fujitsu_capture_sources),
  4195. .input_mux = alc260_fujitsu_capture_sources,
  4196. },
  4197. [ALC260_ACER] = {
  4198. .mixers = { alc260_acer_mixer,
  4199. alc260_capture_mixer },
  4200. .init_verbs = { alc260_acer_init_verbs },
  4201. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4202. .dac_nids = alc260_dac_nids,
  4203. .num_adc_nids = ARRAY_SIZE(alc260_dual_adc_nids),
  4204. .adc_nids = alc260_dual_adc_nids,
  4205. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4206. .channel_mode = alc260_modes,
  4207. .num_mux_defs = ARRAY_SIZE(alc260_acer_capture_sources),
  4208. .input_mux = alc260_acer_capture_sources,
  4209. },
  4210. [ALC260_WILL] = {
  4211. .mixers = { alc260_will_mixer,
  4212. alc260_capture_mixer },
  4213. .init_verbs = { alc260_init_verbs, alc260_will_verbs },
  4214. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4215. .dac_nids = alc260_dac_nids,
  4216. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4217. .adc_nids = alc260_adc_nids,
  4218. .dig_out_nid = ALC260_DIGOUT_NID,
  4219. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4220. .channel_mode = alc260_modes,
  4221. .input_mux = &alc260_capture_source,
  4222. },
  4223. [ALC260_REPLACER_672V] = {
  4224. .mixers = { alc260_replacer_672v_mixer,
  4225. alc260_capture_mixer },
  4226. .init_verbs = { alc260_init_verbs, alc260_replacer_672v_verbs },
  4227. .num_dacs = ARRAY_SIZE(alc260_dac_nids),
  4228. .dac_nids = alc260_dac_nids,
  4229. .num_adc_nids = ARRAY_SIZE(alc260_adc_nids),
  4230. .adc_nids = alc260_adc_nids,
  4231. .dig_out_nid = ALC260_DIGOUT_NID,
  4232. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4233. .channel_mode = alc260_modes,
  4234. .input_mux = &alc260_capture_source,
  4235. .unsol_event = alc260_replacer_672v_unsol_event,
  4236. .init_hook = alc260_replacer_672v_automute,
  4237. },
  4238. #ifdef CONFIG_SND_DEBUG
  4239. [ALC260_TEST] = {
  4240. .mixers = { alc260_test_mixer,
  4241. alc260_capture_mixer },
  4242. .init_verbs = { alc260_test_init_verbs },
  4243. .num_dacs = ARRAY_SIZE(alc260_test_dac_nids),
  4244. .dac_nids = alc260_test_dac_nids,
  4245. .num_adc_nids = ARRAY_SIZE(alc260_test_adc_nids),
  4246. .adc_nids = alc260_test_adc_nids,
  4247. .num_channel_mode = ARRAY_SIZE(alc260_modes),
  4248. .channel_mode = alc260_modes,
  4249. .num_mux_defs = ARRAY_SIZE(alc260_test_capture_sources),
  4250. .input_mux = alc260_test_capture_sources,
  4251. },
  4252. #endif
  4253. };
  4254. static int patch_alc260(struct hda_codec *codec)
  4255. {
  4256. struct alc_spec *spec;
  4257. int err, board_config;
  4258. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  4259. if (spec == NULL)
  4260. return -ENOMEM;
  4261. codec->spec = spec;
  4262. board_config = snd_hda_check_board_config(codec, ALC260_MODEL_LAST,
  4263. alc260_models,
  4264. alc260_cfg_tbl);
  4265. if (board_config < 0) {
  4266. snd_printd(KERN_INFO "hda_codec: Unknown model for ALC260, "
  4267. "trying auto-probe from BIOS...\n");
  4268. board_config = ALC260_AUTO;
  4269. }
  4270. if (board_config == ALC260_AUTO) {
  4271. /* automatic parse from the BIOS config */
  4272. err = alc260_parse_auto_config(codec);
  4273. if (err < 0) {
  4274. alc_free(codec);
  4275. return err;
  4276. } else if (!err) {
  4277. printk(KERN_INFO
  4278. "hda_codec: Cannot set up configuration "
  4279. "from BIOS. Using base mode...\n");
  4280. board_config = ALC260_BASIC;
  4281. }
  4282. }
  4283. if (board_config != ALC260_AUTO)
  4284. setup_preset(spec, &alc260_presets[board_config]);
  4285. spec->stream_name_analog = "ALC260 Analog";
  4286. spec->stream_analog_playback = &alc260_pcm_analog_playback;
  4287. spec->stream_analog_capture = &alc260_pcm_analog_capture;
  4288. spec->stream_name_digital = "ALC260 Digital";
  4289. spec->stream_digital_playback = &alc260_pcm_digital_playback;
  4290. spec->stream_digital_capture = &alc260_pcm_digital_capture;
  4291. codec->patch_ops = alc_patch_ops;
  4292. if (board_config == ALC260_AUTO)
  4293. spec->init_hook = alc260_auto_init;
  4294. return 0;
  4295. }
  4296. /*
  4297. * ALC882 support
  4298. *
  4299. * ALC882 is almost identical with ALC880 but has cleaner and more flexible
  4300. * configuration. Each pin widget can choose any input DACs and a mixer.
  4301. * Each ADC is connected from a mixer of all inputs. This makes possible
  4302. * 6-channel independent captures.
  4303. *
  4304. * In addition, an independent DAC for the multi-playback (not used in this
  4305. * driver yet).
  4306. */
  4307. #define ALC882_DIGOUT_NID 0x06
  4308. #define ALC882_DIGIN_NID 0x0a
  4309. static struct hda_channel_mode alc882_ch_modes[1] = {
  4310. { 8, NULL }
  4311. };
  4312. static hda_nid_t alc882_dac_nids[4] = {
  4313. /* front, rear, clfe, rear_surr */
  4314. 0x02, 0x03, 0x04, 0x05
  4315. };
  4316. /* identical with ALC880 */
  4317. #define alc882_adc_nids alc880_adc_nids
  4318. #define alc882_adc_nids_alt alc880_adc_nids_alt
  4319. /* input MUX */
  4320. /* FIXME: should be a matrix-type input source selection */
  4321. static struct hda_input_mux alc882_capture_source = {
  4322. .num_items = 4,
  4323. .items = {
  4324. { "Mic", 0x0 },
  4325. { "Front Mic", 0x1 },
  4326. { "Line", 0x2 },
  4327. { "CD", 0x4 },
  4328. },
  4329. };
  4330. #define alc882_mux_enum_info alc_mux_enum_info
  4331. #define alc882_mux_enum_get alc_mux_enum_get
  4332. static int alc882_mux_enum_put(struct snd_kcontrol *kcontrol,
  4333. struct snd_ctl_elem_value *ucontrol)
  4334. {
  4335. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  4336. struct alc_spec *spec = codec->spec;
  4337. const struct hda_input_mux *imux = spec->input_mux;
  4338. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  4339. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  4340. hda_nid_t nid = capture_mixers[adc_idx];
  4341. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  4342. unsigned int i, idx;
  4343. idx = ucontrol->value.enumerated.item[0];
  4344. if (idx >= imux->num_items)
  4345. idx = imux->num_items - 1;
  4346. if (*cur_val == idx && !codec->in_resume)
  4347. return 0;
  4348. for (i = 0; i < imux->num_items; i++) {
  4349. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  4350. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  4351. v | (imux->items[i].index << 8));
  4352. }
  4353. *cur_val = idx;
  4354. return 1;
  4355. }
  4356. /*
  4357. * 2ch mode
  4358. */
  4359. static struct hda_verb alc882_3ST_ch2_init[] = {
  4360. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  4361. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4362. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  4363. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  4364. { } /* end */
  4365. };
  4366. /*
  4367. * 6ch mode
  4368. */
  4369. static struct hda_verb alc882_3ST_ch6_init[] = {
  4370. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4371. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4372. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  4373. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4374. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  4375. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  4376. { } /* end */
  4377. };
  4378. static struct hda_channel_mode alc882_3ST_6ch_modes[2] = {
  4379. { 2, alc882_3ST_ch2_init },
  4380. { 6, alc882_3ST_ch6_init },
  4381. };
  4382. /*
  4383. * 6ch mode
  4384. */
  4385. static struct hda_verb alc882_sixstack_ch6_init[] = {
  4386. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  4387. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4388. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4389. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4390. { } /* end */
  4391. };
  4392. /*
  4393. * 8ch mode
  4394. */
  4395. static struct hda_verb alc882_sixstack_ch8_init[] = {
  4396. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4397. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4398. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4399. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  4400. { } /* end */
  4401. };
  4402. static struct hda_channel_mode alc882_sixstack_modes[2] = {
  4403. { 6, alc882_sixstack_ch6_init },
  4404. { 8, alc882_sixstack_ch8_init },
  4405. };
  4406. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  4407. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  4408. */
  4409. static struct snd_kcontrol_new alc882_base_mixer[] = {
  4410. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4411. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4412. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  4413. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  4414. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  4415. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  4416. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  4417. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  4418. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  4419. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  4420. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4421. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4422. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4423. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4424. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4425. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4426. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4427. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4428. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4429. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  4430. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4431. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4432. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4433. { } /* end */
  4434. };
  4435. static struct snd_kcontrol_new alc882_w2jc_mixer[] = {
  4436. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4437. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4438. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4439. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4440. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4441. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4442. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4443. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  4444. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4445. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  4446. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  4447. { } /* end */
  4448. };
  4449. static struct snd_kcontrol_new alc882_targa_mixer[] = {
  4450. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4451. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4452. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  4453. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4454. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4455. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4456. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4457. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4458. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4459. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  4460. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  4461. { } /* end */
  4462. };
  4463. /* Pin assignment: Front=0x14, HP = 0x15, Front = 0x16, ???
  4464. * Front Mic=0x18, Line In = 0x1a, Line In = 0x1b, CD = 0x1c
  4465. */
  4466. static struct snd_kcontrol_new alc882_asus_a7j_mixer[] = {
  4467. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4468. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  4469. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  4470. HDA_CODEC_MUTE("Mobile Front Playback Switch", 0x16, 0x0, HDA_OUTPUT),
  4471. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  4472. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  4473. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4474. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4475. HDA_CODEC_VOLUME("Mobile Line Playback Volume", 0x0b, 0x03, HDA_INPUT),
  4476. HDA_CODEC_MUTE("Mobile Line Playback Switch", 0x0b, 0x03, HDA_INPUT),
  4477. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  4478. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  4479. { } /* end */
  4480. };
  4481. static struct snd_kcontrol_new alc882_chmode_mixer[] = {
  4482. {
  4483. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4484. .name = "Channel Mode",
  4485. .info = alc_ch_mode_info,
  4486. .get = alc_ch_mode_get,
  4487. .put = alc_ch_mode_put,
  4488. },
  4489. { } /* end */
  4490. };
  4491. static struct hda_verb alc882_init_verbs[] = {
  4492. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4493. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4494. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4495. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4496. /* Rear mixer */
  4497. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4498. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4499. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4500. /* CLFE mixer */
  4501. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4502. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4503. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4504. /* Side mixer */
  4505. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4506. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4507. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4508. /* Front Pin: output 0 (0x0c) */
  4509. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4510. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4511. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4512. /* Rear Pin: output 1 (0x0d) */
  4513. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4514. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4515. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  4516. /* CLFE Pin: output 2 (0x0e) */
  4517. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4518. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4519. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  4520. /* Side Pin: output 3 (0x0f) */
  4521. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4522. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4523. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  4524. /* Mic (rear) pin: input vref at 80% */
  4525. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4526. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4527. /* Front Mic pin: input vref at 80% */
  4528. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4529. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4530. /* Line In pin: input */
  4531. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4532. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4533. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  4534. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4535. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4536. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  4537. /* CD pin widget for input */
  4538. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  4539. /* FIXME: use matrix-type input source selection */
  4540. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4541. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4542. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4543. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4544. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4545. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4546. /* Input mixer2 */
  4547. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4548. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4549. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4550. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4551. /* Input mixer3 */
  4552. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4553. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4554. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4555. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4556. /* ADC1: mute amp left and right */
  4557. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4558. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4559. /* ADC2: mute amp left and right */
  4560. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4561. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4562. /* ADC3: mute amp left and right */
  4563. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4564. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4565. { }
  4566. };
  4567. static struct hda_verb alc882_eapd_verbs[] = {
  4568. /* change to EAPD mode */
  4569. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  4570. {0x20, AC_VERB_SET_PROC_COEF, 0x3060},
  4571. { }
  4572. };
  4573. /* Mac Pro test */
  4574. static struct snd_kcontrol_new alc882_macpro_mixer[] = {
  4575. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  4576. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  4577. HDA_CODEC_MUTE("Headphone Playback Switch", 0x18, 0x0, HDA_OUTPUT),
  4578. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  4579. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  4580. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x02, HDA_INPUT),
  4581. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x02, HDA_INPUT),
  4582. { } /* end */
  4583. };
  4584. static struct hda_verb alc882_macpro_init_verbs[] = {
  4585. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  4586. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4587. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4588. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  4589. /* Front Pin: output 0 (0x0c) */
  4590. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4591. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4592. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  4593. /* Front Mic pin: input vref at 80% */
  4594. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4595. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4596. /* Speaker: output */
  4597. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4598. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4599. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x04},
  4600. /* Headphone output (output 0 - 0x0c) */
  4601. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4602. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4603. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4604. /* FIXME: use matrix-type input source selection */
  4605. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4606. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4607. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4608. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4609. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4610. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4611. /* Input mixer2 */
  4612. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4613. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4614. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4615. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4616. /* Input mixer3 */
  4617. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4618. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  4619. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  4620. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  4621. /* ADC1: mute amp left and right */
  4622. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4623. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4624. /* ADC2: mute amp left and right */
  4625. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4626. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4627. /* ADC3: mute amp left and right */
  4628. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  4629. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4630. { }
  4631. };
  4632. /* iMac 24 mixer. */
  4633. static struct snd_kcontrol_new alc885_imac24_mixer[] = {
  4634. HDA_CODEC_VOLUME("Master Playback Volume", 0x0c, 0x00, HDA_OUTPUT),
  4635. HDA_CODEC_MUTE("Master Playback Switch", 0x0c, 0x00, HDA_INPUT),
  4636. { } /* end */
  4637. };
  4638. /* iMac 24 init verbs. */
  4639. static struct hda_verb alc885_imac24_init_verbs[] = {
  4640. /* Internal speakers: output 0 (0x0c) */
  4641. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4642. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4643. {0x18, AC_VERB_SET_CONNECT_SEL, 0x00},
  4644. /* Internal speakers: output 0 (0x0c) */
  4645. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4646. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4647. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x00},
  4648. /* Headphone: output 0 (0x0c) */
  4649. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4650. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  4651. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  4652. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4653. /* Front Mic: input vref at 80% */
  4654. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  4655. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  4656. { }
  4657. };
  4658. /* Toggle speaker-output according to the hp-jack state */
  4659. static void alc885_imac24_automute(struct hda_codec *codec)
  4660. {
  4661. unsigned int present;
  4662. present = snd_hda_codec_read(codec, 0x14, 0,
  4663. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4664. snd_hda_codec_amp_update(codec, 0x18, 0, HDA_OUTPUT, 0,
  4665. 0x80, present ? 0x80 : 0);
  4666. snd_hda_codec_amp_update(codec, 0x18, 1, HDA_OUTPUT, 0,
  4667. 0x80, present ? 0x80 : 0);
  4668. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_OUTPUT, 0,
  4669. 0x80, present ? 0x80 : 0);
  4670. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_OUTPUT, 0,
  4671. 0x80, present ? 0x80 : 0);
  4672. }
  4673. /* Processes unsolicited events. */
  4674. static void alc885_imac24_unsol_event(struct hda_codec *codec,
  4675. unsigned int res)
  4676. {
  4677. /* Headphone insertion or removal. */
  4678. if ((res >> 26) == ALC880_HP_EVENT)
  4679. alc885_imac24_automute(codec);
  4680. }
  4681. static struct hda_verb alc882_targa_verbs[] = {
  4682. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4683. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4684. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4685. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4686. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4687. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4688. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4689. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  4690. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  4691. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  4692. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  4693. { } /* end */
  4694. };
  4695. /* toggle speaker-output according to the hp-jack state */
  4696. static void alc882_targa_automute(struct hda_codec *codec)
  4697. {
  4698. unsigned int present;
  4699. present = snd_hda_codec_read(codec, 0x14, 0,
  4700. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  4701. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  4702. 0x80, present ? 0x80 : 0);
  4703. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  4704. 0x80, present ? 0x80 : 0);
  4705. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA, present ? 1 : 3);
  4706. }
  4707. static void alc882_targa_unsol_event(struct hda_codec *codec, unsigned int res)
  4708. {
  4709. /* Looks like the unsol event is incompatible with the standard
  4710. * definition. 4bit tag is placed at 26 bit!
  4711. */
  4712. if (((res >> 26) == ALC880_HP_EVENT)) {
  4713. alc882_targa_automute(codec);
  4714. }
  4715. }
  4716. static struct hda_verb alc882_asus_a7j_verbs[] = {
  4717. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4718. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4719. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  4720. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4721. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  4722. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4723. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4724. {0x16, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front */
  4725. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  4726. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  4727. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  4728. { } /* end */
  4729. };
  4730. static void alc882_gpio_mute(struct hda_codec *codec, int pin, int muted)
  4731. {
  4732. unsigned int gpiostate, gpiomask, gpiodir;
  4733. gpiostate = snd_hda_codec_read(codec, codec->afg, 0,
  4734. AC_VERB_GET_GPIO_DATA, 0);
  4735. if (!muted)
  4736. gpiostate |= (1 << pin);
  4737. else
  4738. gpiostate &= ~(1 << pin);
  4739. gpiomask = snd_hda_codec_read(codec, codec->afg, 0,
  4740. AC_VERB_GET_GPIO_MASK, 0);
  4741. gpiomask |= (1 << pin);
  4742. gpiodir = snd_hda_codec_read(codec, codec->afg, 0,
  4743. AC_VERB_GET_GPIO_DIRECTION, 0);
  4744. gpiodir |= (1 << pin);
  4745. snd_hda_codec_write(codec, codec->afg, 0,
  4746. AC_VERB_SET_GPIO_MASK, gpiomask);
  4747. snd_hda_codec_write(codec, codec->afg, 0,
  4748. AC_VERB_SET_GPIO_DIRECTION, gpiodir);
  4749. msleep(1);
  4750. snd_hda_codec_write(codec, codec->afg, 0,
  4751. AC_VERB_SET_GPIO_DATA, gpiostate);
  4752. }
  4753. /*
  4754. * generic initialization of ADC, input mixers and output mixers
  4755. */
  4756. static struct hda_verb alc882_auto_init_verbs[] = {
  4757. /*
  4758. * Unmute ADC0-2 and set the default input to mic-in
  4759. */
  4760. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  4761. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4762. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  4763. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4764. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  4765. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4766. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  4767. * mixer widget
  4768. * Note: PASD motherboards uses the Line In 2 as the input for
  4769. * front panel mic (mic 2)
  4770. */
  4771. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  4772. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4773. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4774. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  4775. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  4776. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  4777. /*
  4778. * Set up output mixers (0x0c - 0x0f)
  4779. */
  4780. /* set vol=0 to output mixers */
  4781. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4782. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4783. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4784. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  4785. /* set up input amps for analog loopback */
  4786. /* Amp Indices: DAC = 0, mixer = 1 */
  4787. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4788. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4789. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4790. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4791. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4792. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4793. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4794. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4795. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  4796. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  4797. /* FIXME: use matrix-type input source selection */
  4798. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  4799. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  4800. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4801. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4802. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4803. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4804. /* Input mixer2 */
  4805. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4806. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4807. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4808. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4809. /* Input mixer3 */
  4810. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  4811. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  4812. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  4813. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  4814. { }
  4815. };
  4816. /* capture mixer elements */
  4817. static struct snd_kcontrol_new alc882_capture_alt_mixer[] = {
  4818. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  4819. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  4820. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  4821. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  4822. {
  4823. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4824. /* The multiple "Capture Source" controls confuse alsamixer
  4825. * So call somewhat different..
  4826. * FIXME: the controls appear in the "playback" view!
  4827. */
  4828. /* .name = "Capture Source", */
  4829. .name = "Input Source",
  4830. .count = 2,
  4831. .info = alc882_mux_enum_info,
  4832. .get = alc882_mux_enum_get,
  4833. .put = alc882_mux_enum_put,
  4834. },
  4835. { } /* end */
  4836. };
  4837. static struct snd_kcontrol_new alc882_capture_mixer[] = {
  4838. HDA_CODEC_VOLUME("Capture Volume", 0x07, 0x0, HDA_INPUT),
  4839. HDA_CODEC_MUTE("Capture Switch", 0x07, 0x0, HDA_INPUT),
  4840. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x08, 0x0, HDA_INPUT),
  4841. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x08, 0x0, HDA_INPUT),
  4842. HDA_CODEC_VOLUME_IDX("Capture Volume", 2, 0x09, 0x0, HDA_INPUT),
  4843. HDA_CODEC_MUTE_IDX("Capture Switch", 2, 0x09, 0x0, HDA_INPUT),
  4844. {
  4845. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  4846. /* The multiple "Capture Source" controls confuse alsamixer
  4847. * So call somewhat different..
  4848. * FIXME: the controls appear in the "playback" view!
  4849. */
  4850. /* .name = "Capture Source", */
  4851. .name = "Input Source",
  4852. .count = 3,
  4853. .info = alc882_mux_enum_info,
  4854. .get = alc882_mux_enum_get,
  4855. .put = alc882_mux_enum_put,
  4856. },
  4857. { } /* end */
  4858. };
  4859. /* pcm configuration: identiacal with ALC880 */
  4860. #define alc882_pcm_analog_playback alc880_pcm_analog_playback
  4861. #define alc882_pcm_analog_capture alc880_pcm_analog_capture
  4862. #define alc882_pcm_digital_playback alc880_pcm_digital_playback
  4863. #define alc882_pcm_digital_capture alc880_pcm_digital_capture
  4864. /*
  4865. * configuration and preset
  4866. */
  4867. static const char *alc882_models[ALC882_MODEL_LAST] = {
  4868. [ALC882_3ST_DIG] = "3stack-dig",
  4869. [ALC882_6ST_DIG] = "6stack-dig",
  4870. [ALC882_ARIMA] = "arima",
  4871. [ALC882_W2JC] = "w2jc",
  4872. [ALC885_MACPRO] = "macpro",
  4873. [ALC885_IMAC24] = "imac24",
  4874. [ALC882_AUTO] = "auto",
  4875. };
  4876. static struct snd_pci_quirk alc882_cfg_tbl[] = {
  4877. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC882_6ST_DIG),
  4878. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC882_6ST_DIG),
  4879. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC882_6ST_DIG),
  4880. SND_PCI_QUIRK(0x1462, 0x28fb, "Targa T8", ALC882_TARGA), /* MSI-1049 T8 */
  4881. SND_PCI_QUIRK(0x161f, 0x2054, "Arima W820", ALC882_ARIMA),
  4882. SND_PCI_QUIRK(0x1043, 0x060d, "Asus A7J", ALC882_ASUS_A7J),
  4883. SND_PCI_QUIRK(0x1043, 0x817f, "Asus P5LD2", ALC882_6ST_DIG),
  4884. SND_PCI_QUIRK(0x1043, 0x81d8, "Asus P5WD", ALC882_6ST_DIG),
  4885. SND_PCI_QUIRK(0x1043, 0x1971, "Asus W2JC", ALC882_W2JC),
  4886. {}
  4887. };
  4888. static struct alc_config_preset alc882_presets[] = {
  4889. [ALC882_3ST_DIG] = {
  4890. .mixers = { alc882_base_mixer },
  4891. .init_verbs = { alc882_init_verbs },
  4892. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4893. .dac_nids = alc882_dac_nids,
  4894. .dig_out_nid = ALC882_DIGOUT_NID,
  4895. .dig_in_nid = ALC882_DIGIN_NID,
  4896. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4897. .channel_mode = alc882_ch_modes,
  4898. .need_dac_fix = 1,
  4899. .input_mux = &alc882_capture_source,
  4900. },
  4901. [ALC882_6ST_DIG] = {
  4902. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4903. .init_verbs = { alc882_init_verbs },
  4904. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4905. .dac_nids = alc882_dac_nids,
  4906. .dig_out_nid = ALC882_DIGOUT_NID,
  4907. .dig_in_nid = ALC882_DIGIN_NID,
  4908. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4909. .channel_mode = alc882_sixstack_modes,
  4910. .input_mux = &alc882_capture_source,
  4911. },
  4912. [ALC882_ARIMA] = {
  4913. .mixers = { alc882_base_mixer, alc882_chmode_mixer },
  4914. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs },
  4915. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4916. .dac_nids = alc882_dac_nids,
  4917. .num_channel_mode = ARRAY_SIZE(alc882_sixstack_modes),
  4918. .channel_mode = alc882_sixstack_modes,
  4919. .input_mux = &alc882_capture_source,
  4920. },
  4921. [ALC882_W2JC] = {
  4922. .mixers = { alc882_w2jc_mixer, alc882_chmode_mixer },
  4923. .init_verbs = { alc882_init_verbs, alc882_eapd_verbs,
  4924. alc880_gpio1_init_verbs },
  4925. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4926. .dac_nids = alc882_dac_nids,
  4927. .num_channel_mode = ARRAY_SIZE(alc880_threestack_modes),
  4928. .channel_mode = alc880_threestack_modes,
  4929. .need_dac_fix = 1,
  4930. .input_mux = &alc882_capture_source,
  4931. .dig_out_nid = ALC882_DIGOUT_NID,
  4932. },
  4933. [ALC885_MACPRO] = {
  4934. .mixers = { alc882_macpro_mixer },
  4935. .init_verbs = { alc882_macpro_init_verbs },
  4936. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4937. .dac_nids = alc882_dac_nids,
  4938. .dig_out_nid = ALC882_DIGOUT_NID,
  4939. .dig_in_nid = ALC882_DIGIN_NID,
  4940. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4941. .channel_mode = alc882_ch_modes,
  4942. .input_mux = &alc882_capture_source,
  4943. },
  4944. [ALC885_IMAC24] = {
  4945. .mixers = { alc885_imac24_mixer },
  4946. .init_verbs = { alc885_imac24_init_verbs },
  4947. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4948. .dac_nids = alc882_dac_nids,
  4949. .dig_out_nid = ALC882_DIGOUT_NID,
  4950. .dig_in_nid = ALC882_DIGIN_NID,
  4951. .num_channel_mode = ARRAY_SIZE(alc882_ch_modes),
  4952. .channel_mode = alc882_ch_modes,
  4953. .input_mux = &alc882_capture_source,
  4954. .unsol_event = alc885_imac24_unsol_event,
  4955. .init_hook = alc885_imac24_automute,
  4956. },
  4957. [ALC882_TARGA] = {
  4958. .mixers = { alc882_targa_mixer, alc882_chmode_mixer,
  4959. alc882_capture_mixer },
  4960. .init_verbs = { alc882_init_verbs, alc882_targa_verbs},
  4961. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4962. .dac_nids = alc882_dac_nids,
  4963. .dig_out_nid = ALC882_DIGOUT_NID,
  4964. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4965. .adc_nids = alc882_adc_nids,
  4966. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4967. .channel_mode = alc882_3ST_6ch_modes,
  4968. .need_dac_fix = 1,
  4969. .input_mux = &alc882_capture_source,
  4970. .unsol_event = alc882_targa_unsol_event,
  4971. .init_hook = alc882_targa_automute,
  4972. },
  4973. [ALC882_ASUS_A7J] = {
  4974. .mixers = { alc882_asus_a7j_mixer, alc882_chmode_mixer,
  4975. alc882_capture_mixer },
  4976. .init_verbs = { alc882_init_verbs, alc882_asus_a7j_verbs},
  4977. .num_dacs = ARRAY_SIZE(alc882_dac_nids),
  4978. .dac_nids = alc882_dac_nids,
  4979. .dig_out_nid = ALC882_DIGOUT_NID,
  4980. .num_adc_nids = ARRAY_SIZE(alc882_adc_nids),
  4981. .adc_nids = alc882_adc_nids,
  4982. .num_channel_mode = ARRAY_SIZE(alc882_3ST_6ch_modes),
  4983. .channel_mode = alc882_3ST_6ch_modes,
  4984. .need_dac_fix = 1,
  4985. .input_mux = &alc882_capture_source,
  4986. },
  4987. };
  4988. /*
  4989. * Pin config fixes
  4990. */
  4991. enum {
  4992. PINFIX_ABIT_AW9D_MAX
  4993. };
  4994. static struct alc_pincfg alc882_abit_aw9d_pinfix[] = {
  4995. { 0x15, 0x01080104 }, /* side */
  4996. { 0x16, 0x01011012 }, /* rear */
  4997. { 0x17, 0x01016011 }, /* clfe */
  4998. { }
  4999. };
  5000. static const struct alc_pincfg *alc882_pin_fixes[] = {
  5001. [PINFIX_ABIT_AW9D_MAX] = alc882_abit_aw9d_pinfix,
  5002. };
  5003. static struct snd_pci_quirk alc882_pinfix_tbl[] = {
  5004. SND_PCI_QUIRK(0x147b, 0x107a, "Abit AW9D-MAX", PINFIX_ABIT_AW9D_MAX),
  5005. {}
  5006. };
  5007. /*
  5008. * BIOS auto configuration
  5009. */
  5010. static void alc882_auto_set_output_and_unmute(struct hda_codec *codec,
  5011. hda_nid_t nid, int pin_type,
  5012. int dac_idx)
  5013. {
  5014. /* set as output */
  5015. struct alc_spec *spec = codec->spec;
  5016. int idx;
  5017. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  5018. idx = 4;
  5019. else
  5020. idx = spec->multiout.dac_nids[dac_idx] - 2;
  5021. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  5022. pin_type);
  5023. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5024. AMP_OUT_UNMUTE);
  5025. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  5026. }
  5027. static void alc882_auto_init_multi_out(struct hda_codec *codec)
  5028. {
  5029. struct alc_spec *spec = codec->spec;
  5030. int i;
  5031. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  5032. for (i = 0; i <= HDA_SIDE; i++) {
  5033. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  5034. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  5035. if (nid)
  5036. alc882_auto_set_output_and_unmute(codec, nid, pin_type,
  5037. i);
  5038. }
  5039. }
  5040. static void alc882_auto_init_hp_out(struct hda_codec *codec)
  5041. {
  5042. struct alc_spec *spec = codec->spec;
  5043. hda_nid_t pin;
  5044. pin = spec->autocfg.hp_pins[0];
  5045. if (pin) /* connect to front */
  5046. /* use dac 0 */
  5047. alc882_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  5048. }
  5049. #define alc882_is_input_pin(nid) alc880_is_input_pin(nid)
  5050. #define ALC882_PIN_CD_NID ALC880_PIN_CD_NID
  5051. static void alc882_auto_init_analog_input(struct hda_codec *codec)
  5052. {
  5053. struct alc_spec *spec = codec->spec;
  5054. int i;
  5055. for (i = 0; i < AUTO_PIN_LAST; i++) {
  5056. hda_nid_t nid = spec->autocfg.input_pins[i];
  5057. if (alc882_is_input_pin(nid)) {
  5058. snd_hda_codec_write(codec, nid, 0,
  5059. AC_VERB_SET_PIN_WIDGET_CONTROL,
  5060. i <= AUTO_PIN_FRONT_MIC ?
  5061. PIN_VREF80 : PIN_IN);
  5062. if (nid != ALC882_PIN_CD_NID)
  5063. snd_hda_codec_write(codec, nid, 0,
  5064. AC_VERB_SET_AMP_GAIN_MUTE,
  5065. AMP_OUT_MUTE);
  5066. }
  5067. }
  5068. }
  5069. /* almost identical with ALC880 parser... */
  5070. static int alc882_parse_auto_config(struct hda_codec *codec)
  5071. {
  5072. struct alc_spec *spec = codec->spec;
  5073. int err = alc880_parse_auto_config(codec);
  5074. if (err < 0)
  5075. return err;
  5076. else if (err > 0)
  5077. /* hack - override the init verbs */
  5078. spec->init_verbs[0] = alc882_auto_init_verbs;
  5079. return err;
  5080. }
  5081. /* additional initialization for auto-configuration model */
  5082. static void alc882_auto_init(struct hda_codec *codec)
  5083. {
  5084. alc882_auto_init_multi_out(codec);
  5085. alc882_auto_init_hp_out(codec);
  5086. alc882_auto_init_analog_input(codec);
  5087. }
  5088. static int patch_alc882(struct hda_codec *codec)
  5089. {
  5090. struct alc_spec *spec;
  5091. int err, board_config;
  5092. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  5093. if (spec == NULL)
  5094. return -ENOMEM;
  5095. codec->spec = spec;
  5096. board_config = snd_hda_check_board_config(codec, ALC882_MODEL_LAST,
  5097. alc882_models,
  5098. alc882_cfg_tbl);
  5099. if (board_config < 0 || board_config >= ALC882_MODEL_LAST) {
  5100. /* Pick up systems that don't supply PCI SSID */
  5101. switch (codec->subsystem_id) {
  5102. case 0x106b0c00: /* Mac Pro */
  5103. board_config = ALC885_MACPRO;
  5104. break;
  5105. case 0x106b1000: /* iMac 24 */
  5106. board_config = ALC885_IMAC24;
  5107. break;
  5108. default:
  5109. printk(KERN_INFO "hda_codec: Unknown model for ALC882, "
  5110. "trying auto-probe from BIOS...\n");
  5111. board_config = ALC882_AUTO;
  5112. }
  5113. }
  5114. alc_fix_pincfg(codec, alc882_pinfix_tbl, alc882_pin_fixes);
  5115. if (board_config == ALC882_AUTO) {
  5116. /* automatic parse from the BIOS config */
  5117. err = alc882_parse_auto_config(codec);
  5118. if (err < 0) {
  5119. alc_free(codec);
  5120. return err;
  5121. } else if (!err) {
  5122. printk(KERN_INFO
  5123. "hda_codec: Cannot set up configuration "
  5124. "from BIOS. Using base mode...\n");
  5125. board_config = ALC882_3ST_DIG;
  5126. }
  5127. }
  5128. if (board_config != ALC882_AUTO)
  5129. setup_preset(spec, &alc882_presets[board_config]);
  5130. if (board_config == ALC885_MACPRO || board_config == ALC885_IMAC24) {
  5131. alc882_gpio_mute(codec, 0, 0);
  5132. alc882_gpio_mute(codec, 1, 0);
  5133. }
  5134. spec->stream_name_analog = "ALC882 Analog";
  5135. spec->stream_analog_playback = &alc882_pcm_analog_playback;
  5136. spec->stream_analog_capture = &alc882_pcm_analog_capture;
  5137. spec->stream_name_digital = "ALC882 Digital";
  5138. spec->stream_digital_playback = &alc882_pcm_digital_playback;
  5139. spec->stream_digital_capture = &alc882_pcm_digital_capture;
  5140. if (!spec->adc_nids && spec->input_mux) {
  5141. /* check whether NID 0x07 is valid */
  5142. unsigned int wcap = get_wcaps(codec, 0x07);
  5143. /* get type */
  5144. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  5145. if (wcap != AC_WID_AUD_IN) {
  5146. spec->adc_nids = alc882_adc_nids_alt;
  5147. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids_alt);
  5148. spec->mixers[spec->num_mixers] =
  5149. alc882_capture_alt_mixer;
  5150. spec->num_mixers++;
  5151. } else {
  5152. spec->adc_nids = alc882_adc_nids;
  5153. spec->num_adc_nids = ARRAY_SIZE(alc882_adc_nids);
  5154. spec->mixers[spec->num_mixers] = alc882_capture_mixer;
  5155. spec->num_mixers++;
  5156. }
  5157. }
  5158. codec->patch_ops = alc_patch_ops;
  5159. if (board_config == ALC882_AUTO)
  5160. spec->init_hook = alc882_auto_init;
  5161. return 0;
  5162. }
  5163. /*
  5164. * ALC883 support
  5165. *
  5166. * ALC883 is almost identical with ALC880 but has cleaner and more flexible
  5167. * configuration. Each pin widget can choose any input DACs and a mixer.
  5168. * Each ADC is connected from a mixer of all inputs. This makes possible
  5169. * 6-channel independent captures.
  5170. *
  5171. * In addition, an independent DAC for the multi-playback (not used in this
  5172. * driver yet).
  5173. */
  5174. #define ALC883_DIGOUT_NID 0x06
  5175. #define ALC883_DIGIN_NID 0x0a
  5176. static hda_nid_t alc883_dac_nids[4] = {
  5177. /* front, rear, clfe, rear_surr */
  5178. 0x02, 0x04, 0x03, 0x05
  5179. };
  5180. static hda_nid_t alc883_adc_nids[2] = {
  5181. /* ADC1-2 */
  5182. 0x08, 0x09,
  5183. };
  5184. /* input MUX */
  5185. /* FIXME: should be a matrix-type input source selection */
  5186. static struct hda_input_mux alc883_capture_source = {
  5187. .num_items = 4,
  5188. .items = {
  5189. { "Mic", 0x0 },
  5190. { "Front Mic", 0x1 },
  5191. { "Line", 0x2 },
  5192. { "CD", 0x4 },
  5193. },
  5194. };
  5195. static struct hda_input_mux alc883_lenovo_101e_capture_source = {
  5196. .num_items = 2,
  5197. .items = {
  5198. { "Mic", 0x1 },
  5199. { "Line", 0x2 },
  5200. },
  5201. };
  5202. static struct hda_input_mux alc883_lenovo_nb0763_capture_source = {
  5203. .num_items = 4,
  5204. .items = {
  5205. { "Mic", 0x0 },
  5206. { "iMic", 0x1 },
  5207. { "Line", 0x2 },
  5208. { "CD", 0x4 },
  5209. },
  5210. };
  5211. #define alc883_mux_enum_info alc_mux_enum_info
  5212. #define alc883_mux_enum_get alc_mux_enum_get
  5213. static int alc883_mux_enum_put(struct snd_kcontrol *kcontrol,
  5214. struct snd_ctl_elem_value *ucontrol)
  5215. {
  5216. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  5217. struct alc_spec *spec = codec->spec;
  5218. const struct hda_input_mux *imux = spec->input_mux;
  5219. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  5220. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  5221. hda_nid_t nid = capture_mixers[adc_idx];
  5222. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  5223. unsigned int i, idx;
  5224. idx = ucontrol->value.enumerated.item[0];
  5225. if (idx >= imux->num_items)
  5226. idx = imux->num_items - 1;
  5227. if (*cur_val == idx && !codec->in_resume)
  5228. return 0;
  5229. for (i = 0; i < imux->num_items; i++) {
  5230. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  5231. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  5232. v | (imux->items[i].index << 8));
  5233. }
  5234. *cur_val = idx;
  5235. return 1;
  5236. }
  5237. /*
  5238. * 2ch mode
  5239. */
  5240. static struct hda_channel_mode alc883_3ST_2ch_modes[1] = {
  5241. { 2, NULL }
  5242. };
  5243. /*
  5244. * 2ch mode
  5245. */
  5246. static struct hda_verb alc883_3ST_ch2_init[] = {
  5247. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5248. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5249. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5250. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5251. { } /* end */
  5252. };
  5253. /*
  5254. * 6ch mode
  5255. */
  5256. static struct hda_verb alc883_3ST_ch6_init[] = {
  5257. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5258. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5259. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  5260. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5261. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5262. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  5263. { } /* end */
  5264. };
  5265. static struct hda_channel_mode alc883_3ST_6ch_modes[2] = {
  5266. { 2, alc883_3ST_ch2_init },
  5267. { 6, alc883_3ST_ch6_init },
  5268. };
  5269. /*
  5270. * 6ch mode
  5271. */
  5272. static struct hda_verb alc883_sixstack_ch6_init[] = {
  5273. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  5274. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5275. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5276. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5277. { } /* end */
  5278. };
  5279. /*
  5280. * 8ch mode
  5281. */
  5282. static struct hda_verb alc883_sixstack_ch8_init[] = {
  5283. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5284. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5285. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5286. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5287. { } /* end */
  5288. };
  5289. static struct hda_channel_mode alc883_sixstack_modes[2] = {
  5290. { 6, alc883_sixstack_ch6_init },
  5291. { 8, alc883_sixstack_ch8_init },
  5292. };
  5293. static struct hda_verb alc883_medion_eapd_verbs[] = {
  5294. /* eanable EAPD on medion laptop */
  5295. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  5296. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  5297. { }
  5298. };
  5299. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  5300. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  5301. */
  5302. static struct snd_kcontrol_new alc883_base_mixer[] = {
  5303. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5304. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5305. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5306. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5307. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5308. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5309. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5310. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5311. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5312. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5313. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5314. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5315. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5316. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5317. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5318. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5319. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5320. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5321. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5322. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5323. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5324. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5325. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5326. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5327. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5328. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5329. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5330. {
  5331. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5332. /* .name = "Capture Source", */
  5333. .name = "Input Source",
  5334. .count = 2,
  5335. .info = alc883_mux_enum_info,
  5336. .get = alc883_mux_enum_get,
  5337. .put = alc883_mux_enum_put,
  5338. },
  5339. { } /* end */
  5340. };
  5341. static struct snd_kcontrol_new alc883_3ST_2ch_mixer[] = {
  5342. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5343. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5344. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5345. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5346. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5347. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5348. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5349. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5350. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5351. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5352. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5353. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5354. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5355. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5356. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5357. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5358. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5359. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5360. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5361. {
  5362. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5363. /* .name = "Capture Source", */
  5364. .name = "Input Source",
  5365. .count = 2,
  5366. .info = alc883_mux_enum_info,
  5367. .get = alc883_mux_enum_get,
  5368. .put = alc883_mux_enum_put,
  5369. },
  5370. { } /* end */
  5371. };
  5372. static struct snd_kcontrol_new alc883_3ST_6ch_mixer[] = {
  5373. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5374. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5375. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5376. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5377. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5378. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5379. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5380. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5381. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5382. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5383. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5384. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5385. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5386. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5387. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5388. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5389. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5390. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5391. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5392. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5393. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5394. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5395. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5396. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5397. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5398. {
  5399. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5400. /* .name = "Capture Source", */
  5401. .name = "Input Source",
  5402. .count = 2,
  5403. .info = alc883_mux_enum_info,
  5404. .get = alc883_mux_enum_get,
  5405. .put = alc883_mux_enum_put,
  5406. },
  5407. { } /* end */
  5408. };
  5409. static struct snd_kcontrol_new alc883_fivestack_mixer[] = {
  5410. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5411. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5412. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5413. HDA_CODEC_MUTE("Surround Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5414. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5415. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5416. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x16, 1, 0x0, HDA_OUTPUT),
  5417. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  5418. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5419. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5420. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5421. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5422. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5423. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5424. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5425. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5426. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5427. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5428. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5429. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5430. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5431. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5432. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5433. {
  5434. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5435. /* .name = "Capture Source", */
  5436. .name = "Input Source",
  5437. .count = 1,
  5438. .info = alc883_mux_enum_info,
  5439. .get = alc883_mux_enum_get,
  5440. .put = alc883_mux_enum_put,
  5441. },
  5442. { } /* end */
  5443. };
  5444. static struct snd_kcontrol_new alc883_tagra_mixer[] = {
  5445. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5446. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5447. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5448. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5449. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  5450. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0e, 1, 0x0, HDA_OUTPUT),
  5451. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  5452. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  5453. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  5454. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5455. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5456. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5457. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5458. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5459. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5460. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5461. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5462. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5463. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5464. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5465. {
  5466. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5467. /* .name = "Capture Source", */
  5468. .name = "Input Source",
  5469. .count = 2,
  5470. .info = alc883_mux_enum_info,
  5471. .get = alc883_mux_enum_get,
  5472. .put = alc883_mux_enum_put,
  5473. },
  5474. { } /* end */
  5475. };
  5476. static struct snd_kcontrol_new alc883_tagra_2ch_mixer[] = {
  5477. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5478. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5479. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5480. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5481. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5482. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5483. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5484. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5485. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5486. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5487. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5488. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5489. {
  5490. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5491. /* .name = "Capture Source", */
  5492. .name = "Input Source",
  5493. .count = 2,
  5494. .info = alc883_mux_enum_info,
  5495. .get = alc883_mux_enum_get,
  5496. .put = alc883_mux_enum_put,
  5497. },
  5498. { } /* end */
  5499. };
  5500. static struct snd_kcontrol_new alc883_lenovo_101e_2ch_mixer[] = {
  5501. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5502. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5503. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  5504. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x0d, 2, HDA_INPUT),
  5505. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5506. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5507. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5508. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5509. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5510. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5511. {
  5512. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5513. /* .name = "Capture Source", */
  5514. .name = "Input Source",
  5515. .count = 1,
  5516. .info = alc883_mux_enum_info,
  5517. .get = alc883_mux_enum_get,
  5518. .put = alc883_mux_enum_put,
  5519. },
  5520. { } /* end */
  5521. };
  5522. static struct snd_kcontrol_new alc883_lenovo_nb0763_mixer[] = {
  5523. HDA_CODEC_VOLUME("Speaker Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5524. HDA_BIND_MUTE("Speaker Playback Switch", 0x0c, 2, HDA_INPUT),
  5525. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5526. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5527. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5528. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5529. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5530. HDA_CODEC_VOLUME("iMic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5531. HDA_CODEC_MUTE("iMic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5532. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5533. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5534. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5535. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5536. {
  5537. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5538. /* .name = "Capture Source", */
  5539. .name = "Input Source",
  5540. .count = 2,
  5541. .info = alc883_mux_enum_info,
  5542. .get = alc883_mux_enum_get,
  5543. .put = alc883_mux_enum_put,
  5544. },
  5545. { } /* end */
  5546. };
  5547. static struct snd_kcontrol_new alc883_medion_md2_mixer[] = {
  5548. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5549. HDA_CODEC_MUTE("Headphone Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  5550. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  5551. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5552. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5553. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5554. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5555. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5556. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5557. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5558. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5559. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5560. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5561. {
  5562. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5563. /* .name = "Capture Source", */
  5564. .name = "Input Source",
  5565. .count = 2,
  5566. .info = alc883_mux_enum_info,
  5567. .get = alc883_mux_enum_get,
  5568. .put = alc883_mux_enum_put,
  5569. },
  5570. { } /* end */
  5571. };
  5572. static struct snd_kcontrol_new alc888_6st_hp_mixer[] = {
  5573. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5574. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5575. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5576. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5577. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5578. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5579. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5580. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5581. HDA_CODEC_VOLUME("Side Playback Volume", 0x0f, 0x0, HDA_OUTPUT),
  5582. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  5583. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5584. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5585. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5586. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5587. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5588. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5589. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5590. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5591. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5592. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5593. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5594. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5595. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5596. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5597. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5598. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5599. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5600. {
  5601. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5602. /* .name = "Capture Source", */
  5603. .name = "Input Source",
  5604. .count = 2,
  5605. .info = alc883_mux_enum_info,
  5606. .get = alc883_mux_enum_get,
  5607. .put = alc883_mux_enum_put,
  5608. },
  5609. { } /* end */
  5610. };
  5611. static struct snd_kcontrol_new alc888_3st_hp_mixer[] = {
  5612. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  5613. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  5614. HDA_CODEC_VOLUME("Surround Playback Volume", 0x0e, 0x0, HDA_OUTPUT),
  5615. HDA_BIND_MUTE("Surround Playback Switch", 0x0e, 2, HDA_INPUT),
  5616. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x0d, 1, 0x0, HDA_OUTPUT),
  5617. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x0d, 2, 0x0, HDA_OUTPUT),
  5618. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0d, 1, 2, HDA_INPUT),
  5619. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0d, 2, 2, HDA_INPUT),
  5620. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  5621. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  5622. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  5623. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  5624. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  5625. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  5626. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  5627. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  5628. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  5629. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  5630. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  5631. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  5632. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  5633. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5634. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5635. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5636. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5637. {
  5638. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5639. /* .name = "Capture Source", */
  5640. .name = "Input Source",
  5641. .count = 2,
  5642. .info = alc883_mux_enum_info,
  5643. .get = alc883_mux_enum_get,
  5644. .put = alc883_mux_enum_put,
  5645. },
  5646. { } /* end */
  5647. };
  5648. static struct snd_kcontrol_new alc883_chmode_mixer[] = {
  5649. {
  5650. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5651. .name = "Channel Mode",
  5652. .info = alc_ch_mode_info,
  5653. .get = alc_ch_mode_get,
  5654. .put = alc_ch_mode_put,
  5655. },
  5656. { } /* end */
  5657. };
  5658. static struct hda_verb alc883_init_verbs[] = {
  5659. /* ADC1: mute amp left and right */
  5660. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5661. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5662. /* ADC2: mute amp left and right */
  5663. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5664. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5665. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  5666. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5667. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5668. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5669. /* Rear mixer */
  5670. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5671. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5672. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5673. /* CLFE mixer */
  5674. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5675. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5676. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5677. /* Side mixer */
  5678. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5679. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  5680. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  5681. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5682. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5683. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5684. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5685. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5686. /* Front Pin: output 0 (0x0c) */
  5687. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5688. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5689. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  5690. /* Rear Pin: output 1 (0x0d) */
  5691. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5692. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5693. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  5694. /* CLFE Pin: output 2 (0x0e) */
  5695. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5696. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5697. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  5698. /* Side Pin: output 3 (0x0f) */
  5699. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5700. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5701. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  5702. /* Mic (rear) pin: input vref at 80% */
  5703. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5704. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5705. /* Front Mic pin: input vref at 80% */
  5706. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  5707. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5708. /* Line In pin: input */
  5709. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5710. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  5711. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  5712. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5713. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  5714. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  5715. /* CD pin widget for input */
  5716. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  5717. /* FIXME: use matrix-type input source selection */
  5718. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5719. /* Input mixer2 */
  5720. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5721. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5722. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5723. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5724. /* Input mixer3 */
  5725. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5726. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5727. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5728. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5729. { }
  5730. };
  5731. static struct hda_verb alc883_tagra_verbs[] = {
  5732. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5733. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5734. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5735. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  5736. {0x18, AC_VERB_SET_CONNECT_SEL, 0x02}, /* mic/clfe */
  5737. {0x1a, AC_VERB_SET_CONNECT_SEL, 0x01}, /* line/surround */
  5738. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00}, /* HP */
  5739. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5740. {0x01, AC_VERB_SET_GPIO_MASK, 0x03},
  5741. {0x01, AC_VERB_SET_GPIO_DIRECTION, 0x03},
  5742. {0x01, AC_VERB_SET_GPIO_DATA, 0x03},
  5743. { } /* end */
  5744. };
  5745. static struct hda_verb alc883_lenovo_101e_verbs[] = {
  5746. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5747. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT|AC_USRSP_EN},
  5748. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT|AC_USRSP_EN},
  5749. { } /* end */
  5750. };
  5751. static struct hda_verb alc883_lenovo_nb0763_verbs[] = {
  5752. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5753. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5754. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5755. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5756. { } /* end */
  5757. };
  5758. static struct hda_verb alc888_lenovo_ms7195_verbs[] = {
  5759. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5760. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5761. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  5762. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_FRONT_EVENT | AC_USRSP_EN},
  5763. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5764. { } /* end */
  5765. };
  5766. static struct hda_verb alc888_6st_hp_verbs[] = {
  5767. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5768. {0x15, AC_VERB_SET_CONNECT_SEL, 0x02}, /* Rear : output 2 (0x0e) */
  5769. {0x16, AC_VERB_SET_CONNECT_SEL, 0x01}, /* CLFE : output 1 (0x0d) */
  5770. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03}, /* Side : output 3 (0x0f) */
  5771. { }
  5772. };
  5773. static struct hda_verb alc888_3st_hp_verbs[] = {
  5774. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00}, /* Front: output 0 (0x0c) */
  5775. {0x18, AC_VERB_SET_CONNECT_SEL, 0x01}, /* Rear : output 1 (0x0d) */
  5776. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02}, /* CLFE : output 2 (0x0e) */
  5777. { }
  5778. };
  5779. static struct hda_verb alc888_3st_hp_2ch_init[] = {
  5780. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  5781. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5782. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  5783. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  5784. { }
  5785. };
  5786. static struct hda_verb alc888_3st_hp_6ch_init[] = {
  5787. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5788. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5789. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  5790. { 0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  5791. { }
  5792. };
  5793. static struct hda_channel_mode alc888_3st_hp_modes[2] = {
  5794. { 2, alc888_3st_hp_2ch_init },
  5795. { 6, alc888_3st_hp_6ch_init },
  5796. };
  5797. /* toggle front-jack and RCA according to the hp-jack state */
  5798. static void alc888_lenovo_ms7195_front_automute(struct hda_codec *codec)
  5799. {
  5800. unsigned int present;
  5801. present = snd_hda_codec_read(codec, 0x1b, 0,
  5802. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5803. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5804. 0x80, present ? 0x80 : 0);
  5805. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5806. 0x80, present ? 0x80 : 0);
  5807. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5808. 0x80, present ? 0x80 : 0);
  5809. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5810. 0x80, present ? 0x80 : 0);
  5811. }
  5812. /* toggle RCA according to the front-jack state */
  5813. static void alc888_lenovo_ms7195_rca_automute(struct hda_codec *codec)
  5814. {
  5815. unsigned int present;
  5816. present = snd_hda_codec_read(codec, 0x14, 0,
  5817. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5818. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5819. 0x80, present ? 0x80 : 0);
  5820. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5821. 0x80, present ? 0x80 : 0);
  5822. }
  5823. static void alc883_lenovo_ms7195_unsol_event(struct hda_codec *codec,
  5824. unsigned int res)
  5825. {
  5826. if ((res >> 26) == ALC880_HP_EVENT)
  5827. alc888_lenovo_ms7195_front_automute(codec);
  5828. if ((res >> 26) == ALC880_FRONT_EVENT)
  5829. alc888_lenovo_ms7195_rca_automute(codec);
  5830. }
  5831. static struct hda_verb alc883_medion_md2_verbs[] = {
  5832. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5833. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5834. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  5835. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, ALC880_HP_EVENT | AC_USRSP_EN},
  5836. { } /* end */
  5837. };
  5838. /* toggle speaker-output according to the hp-jack state */
  5839. static void alc883_medion_md2_automute(struct hda_codec *codec)
  5840. {
  5841. unsigned int present;
  5842. present = snd_hda_codec_read(codec, 0x14, 0,
  5843. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5844. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5845. 0x80, present ? 0x80 : 0);
  5846. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5847. 0x80, present ? 0x80 : 0);
  5848. }
  5849. static void alc883_medion_md2_unsol_event(struct hda_codec *codec,
  5850. unsigned int res)
  5851. {
  5852. if ((res >> 26) == ALC880_HP_EVENT)
  5853. alc883_medion_md2_automute(codec);
  5854. }
  5855. /* toggle speaker-output according to the hp-jack state */
  5856. static void alc883_tagra_automute(struct hda_codec *codec)
  5857. {
  5858. unsigned int present;
  5859. unsigned char bits;
  5860. present = snd_hda_codec_read(codec, 0x14, 0,
  5861. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5862. bits = present ? 0x80 : 0;
  5863. snd_hda_codec_amp_update(codec, 0x1b, 0, HDA_OUTPUT, 0,
  5864. 0x80, bits);
  5865. snd_hda_codec_amp_update(codec, 0x1b, 1, HDA_OUTPUT, 0,
  5866. 0x80, bits);
  5867. snd_hda_codec_write(codec, 1, 0, AC_VERB_SET_GPIO_DATA,
  5868. present ? 1 : 3);
  5869. }
  5870. static void alc883_tagra_unsol_event(struct hda_codec *codec, unsigned int res)
  5871. {
  5872. if ((res >> 26) == ALC880_HP_EVENT)
  5873. alc883_tagra_automute(codec);
  5874. }
  5875. static void alc883_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  5876. {
  5877. unsigned int present;
  5878. unsigned char bits;
  5879. present = snd_hda_codec_read(codec, 0x14, 0,
  5880. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5881. bits = present ? 0x80 : 0;
  5882. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5883. 0x80, bits);
  5884. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5885. 0x80, bits);
  5886. }
  5887. static void alc883_lenovo_101e_all_automute(struct hda_codec *codec)
  5888. {
  5889. unsigned int present;
  5890. unsigned char bits;
  5891. present = snd_hda_codec_read(codec, 0x1b, 0,
  5892. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  5893. bits = present ? 0x80 : 0;
  5894. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  5895. 0x80, bits);
  5896. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  5897. 0x80, bits);
  5898. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  5899. 0x80, bits);
  5900. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  5901. 0x80, bits);
  5902. }
  5903. static void alc883_lenovo_101e_unsol_event(struct hda_codec *codec,
  5904. unsigned int res)
  5905. {
  5906. if ((res >> 26) == ALC880_HP_EVENT)
  5907. alc883_lenovo_101e_all_automute(codec);
  5908. if ((res >> 26) == ALC880_FRONT_EVENT)
  5909. alc883_lenovo_101e_ispeaker_automute(codec);
  5910. }
  5911. /*
  5912. * generic initialization of ADC, input mixers and output mixers
  5913. */
  5914. static struct hda_verb alc883_auto_init_verbs[] = {
  5915. /*
  5916. * Unmute ADC0-2 and set the default input to mic-in
  5917. */
  5918. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  5919. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5920. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  5921. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5922. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  5923. * mixer widget
  5924. * Note: PASD motherboards uses the Line In 2 as the input for
  5925. * front panel mic (mic 2)
  5926. */
  5927. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  5928. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5929. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5930. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5931. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  5932. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5933. /*
  5934. * Set up output mixers (0x0c - 0x0f)
  5935. */
  5936. /* set vol=0 to output mixers */
  5937. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5938. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5939. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5940. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  5941. /* set up input amps for analog loopback */
  5942. /* Amp Indices: DAC = 0, mixer = 1 */
  5943. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5944. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5945. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5946. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5947. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5948. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5949. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5950. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5951. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5952. {0x26, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5953. /* FIXME: use matrix-type input source selection */
  5954. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  5955. /* Input mixer1 */
  5956. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5957. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5958. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5959. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5960. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5961. /* Input mixer2 */
  5962. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  5963. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  5964. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  5965. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)}, */
  5966. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  5967. { }
  5968. };
  5969. /* capture mixer elements */
  5970. static struct snd_kcontrol_new alc883_capture_mixer[] = {
  5971. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  5972. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  5973. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x09, 0x0, HDA_INPUT),
  5974. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x09, 0x0, HDA_INPUT),
  5975. {
  5976. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  5977. /* The multiple "Capture Source" controls confuse alsamixer
  5978. * So call somewhat different..
  5979. * FIXME: the controls appear in the "playback" view!
  5980. */
  5981. /* .name = "Capture Source", */
  5982. .name = "Input Source",
  5983. .count = 2,
  5984. .info = alc882_mux_enum_info,
  5985. .get = alc882_mux_enum_get,
  5986. .put = alc882_mux_enum_put,
  5987. },
  5988. { } /* end */
  5989. };
  5990. /* pcm configuration: identiacal with ALC880 */
  5991. #define alc883_pcm_analog_playback alc880_pcm_analog_playback
  5992. #define alc883_pcm_analog_capture alc880_pcm_analog_capture
  5993. #define alc883_pcm_digital_playback alc880_pcm_digital_playback
  5994. #define alc883_pcm_digital_capture alc880_pcm_digital_capture
  5995. /*
  5996. * configuration and preset
  5997. */
  5998. static const char *alc883_models[ALC883_MODEL_LAST] = {
  5999. [ALC883_3ST_2ch_DIG] = "3stack-dig",
  6000. [ALC883_3ST_6ch_DIG] = "3stack-6ch-dig",
  6001. [ALC883_3ST_6ch] = "3stack-6ch",
  6002. [ALC883_6ST_DIG] = "6stack-dig",
  6003. [ALC883_TARGA_DIG] = "targa-dig",
  6004. [ALC883_TARGA_2ch_DIG] = "targa-2ch-dig",
  6005. [ALC883_ACER] = "acer",
  6006. [ALC883_MEDION] = "medion",
  6007. [ALC883_MEDION_MD2] = "medion-md2",
  6008. [ALC883_LAPTOP_EAPD] = "laptop-eapd",
  6009. [ALC883_LENOVO_101E_2ch] = "lenovo-101e",
  6010. [ALC883_LENOVO_NB0763] = "lenovo-nb0763",
  6011. [ALC888_LENOVO_MS7195_DIG] = "lenovo-ms7195-dig",
  6012. [ALC888_6ST_HP] = "6stack-hp",
  6013. [ALC888_3ST_HP] = "3stack-hp",
  6014. [ALC883_AUTO] = "auto",
  6015. };
  6016. static struct snd_pci_quirk alc883_cfg_tbl[] = {
  6017. SND_PCI_QUIRK(0x1019, 0x6668, "ECS", ALC883_3ST_6ch_DIG),
  6018. SND_PCI_QUIRK(0x103c, 0x2a3d, "HP Pavillion", ALC883_6ST_DIG),
  6019. SND_PCI_QUIRK(0x108e, 0x534d, NULL, ALC883_3ST_6ch),
  6020. SND_PCI_QUIRK(0x1558, 0, "Clevo laptop", ALC883_LAPTOP_EAPD),
  6021. SND_PCI_QUIRK(0x105b, 0x6668, "Foxconn", ALC883_6ST_DIG),
  6022. SND_PCI_QUIRK(0x1458, 0xa002, "MSI", ALC883_6ST_DIG),
  6023. SND_PCI_QUIRK(0x1462, 0x6668, "MSI", ALC883_6ST_DIG),
  6024. SND_PCI_QUIRK(0x1462, 0x7187, "MSI", ALC883_6ST_DIG),
  6025. SND_PCI_QUIRK(0x1462, 0x7250, "MSI", ALC883_6ST_DIG),
  6026. SND_PCI_QUIRK(0x1462, 0x7280, "MSI", ALC883_6ST_DIG),
  6027. SND_PCI_QUIRK(0x1462, 0x7327, "MSI", ALC883_6ST_DIG),
  6028. SND_PCI_QUIRK(0x1462, 0x0349, "MSI", ALC883_TARGA_2ch_DIG),
  6029. SND_PCI_QUIRK(0x1462, 0x0579, "MSI", ALC883_TARGA_2ch_DIG),
  6030. SND_PCI_QUIRK(0x1462, 0x3729, "MSI S420", ALC883_TARGA_DIG),
  6031. SND_PCI_QUIRK(0x1462, 0x3ef9, "MSI", ALC883_TARGA_DIG),
  6032. SND_PCI_QUIRK(0x1462, 0x3b7f, "MSI", ALC883_TARGA_2ch_DIG),
  6033. SND_PCI_QUIRK(0x1462, 0x3fcc, "MSI", ALC883_TARGA_DIG),
  6034. SND_PCI_QUIRK(0x1462, 0x3fc1, "MSI", ALC883_TARGA_DIG),
  6035. SND_PCI_QUIRK(0x1462, 0x3fc3, "MSI", ALC883_TARGA_DIG),
  6036. SND_PCI_QUIRK(0x1462, 0x4314, "MSI", ALC883_TARGA_DIG),
  6037. SND_PCI_QUIRK(0x1462, 0x4319, "MSI", ALC883_TARGA_DIG),
  6038. SND_PCI_QUIRK(0x1462, 0x4324, "MSI", ALC883_TARGA_DIG),
  6039. SND_PCI_QUIRK(0x1462, 0xa422, "MSI", ALC883_TARGA_2ch_DIG),
  6040. SND_PCI_QUIRK(0x1025, 0, "Acer laptop", ALC883_ACER),
  6041. SND_PCI_QUIRK(0x15d9, 0x8780, "Supermicro PDSBA", ALC883_3ST_6ch),
  6042. SND_PCI_QUIRK(0x161f, 0x2054, "Medion laptop", ALC883_MEDION),
  6043. SND_PCI_QUIRK(0x1071, 0x8258, "Evesham Voyaeger", ALC883_LAPTOP_EAPD),
  6044. SND_PCI_QUIRK(0x8086, 0xd601, "D102GGC", ALC883_3ST_6ch),
  6045. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo 101e", ALC883_LENOVO_101E_2ch),
  6046. SND_PCI_QUIRK(0x17aa, 0x3bfd, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6047. SND_PCI_QUIRK(0x17aa, 0x2085, "Lenovo NB0763", ALC883_LENOVO_NB0763),
  6048. SND_PCI_QUIRK(0x103c, 0x2a61, "HP Nettle", ALC888_6ST_HP),
  6049. SND_PCI_QUIRK(0x103c, 0x2a60, "HP Lucknow", ALC888_3ST_HP),
  6050. SND_PCI_QUIRK(0x103c, 0x2a4f, "HP Samba", ALC888_3ST_HP),
  6051. SND_PCI_QUIRK(0x17c0, 0x4071, "MEDION MD2", ALC883_MEDION_MD2),
  6052. {}
  6053. };
  6054. static struct alc_config_preset alc883_presets[] = {
  6055. [ALC883_3ST_2ch_DIG] = {
  6056. .mixers = { alc883_3ST_2ch_mixer },
  6057. .init_verbs = { alc883_init_verbs },
  6058. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6059. .dac_nids = alc883_dac_nids,
  6060. .dig_out_nid = ALC883_DIGOUT_NID,
  6061. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6062. .adc_nids = alc883_adc_nids,
  6063. .dig_in_nid = ALC883_DIGIN_NID,
  6064. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6065. .channel_mode = alc883_3ST_2ch_modes,
  6066. .input_mux = &alc883_capture_source,
  6067. },
  6068. [ALC883_3ST_6ch_DIG] = {
  6069. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6070. .init_verbs = { alc883_init_verbs },
  6071. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6072. .dac_nids = alc883_dac_nids,
  6073. .dig_out_nid = ALC883_DIGOUT_NID,
  6074. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6075. .adc_nids = alc883_adc_nids,
  6076. .dig_in_nid = ALC883_DIGIN_NID,
  6077. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6078. .channel_mode = alc883_3ST_6ch_modes,
  6079. .need_dac_fix = 1,
  6080. .input_mux = &alc883_capture_source,
  6081. },
  6082. [ALC883_3ST_6ch] = {
  6083. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6084. .init_verbs = { alc883_init_verbs },
  6085. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6086. .dac_nids = alc883_dac_nids,
  6087. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6088. .adc_nids = alc883_adc_nids,
  6089. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6090. .channel_mode = alc883_3ST_6ch_modes,
  6091. .need_dac_fix = 1,
  6092. .input_mux = &alc883_capture_source,
  6093. },
  6094. [ALC883_6ST_DIG] = {
  6095. .mixers = { alc883_base_mixer, alc883_chmode_mixer },
  6096. .init_verbs = { alc883_init_verbs },
  6097. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6098. .dac_nids = alc883_dac_nids,
  6099. .dig_out_nid = ALC883_DIGOUT_NID,
  6100. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6101. .adc_nids = alc883_adc_nids,
  6102. .dig_in_nid = ALC883_DIGIN_NID,
  6103. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6104. .channel_mode = alc883_sixstack_modes,
  6105. .input_mux = &alc883_capture_source,
  6106. },
  6107. [ALC883_TARGA_DIG] = {
  6108. .mixers = { alc883_tagra_mixer, alc883_chmode_mixer },
  6109. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6110. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6111. .dac_nids = alc883_dac_nids,
  6112. .dig_out_nid = ALC883_DIGOUT_NID,
  6113. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6114. .adc_nids = alc883_adc_nids,
  6115. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6116. .channel_mode = alc883_3ST_6ch_modes,
  6117. .need_dac_fix = 1,
  6118. .input_mux = &alc883_capture_source,
  6119. .unsol_event = alc883_tagra_unsol_event,
  6120. .init_hook = alc883_tagra_automute,
  6121. },
  6122. [ALC883_TARGA_2ch_DIG] = {
  6123. .mixers = { alc883_tagra_2ch_mixer},
  6124. .init_verbs = { alc883_init_verbs, alc883_tagra_verbs},
  6125. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6126. .dac_nids = alc883_dac_nids,
  6127. .dig_out_nid = ALC883_DIGOUT_NID,
  6128. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6129. .adc_nids = alc883_adc_nids,
  6130. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6131. .channel_mode = alc883_3ST_2ch_modes,
  6132. .input_mux = &alc883_capture_source,
  6133. .unsol_event = alc883_tagra_unsol_event,
  6134. .init_hook = alc883_tagra_automute,
  6135. },
  6136. [ALC883_ACER] = {
  6137. .mixers = { alc883_base_mixer,
  6138. alc883_chmode_mixer },
  6139. /* On TravelMate laptops, GPIO 0 enables the internal speaker
  6140. * and the headphone jack. Turn this on and rely on the
  6141. * standard mute methods whenever the user wants to turn
  6142. * these outputs off.
  6143. */
  6144. .init_verbs = { alc883_init_verbs, alc880_gpio1_init_verbs },
  6145. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6146. .dac_nids = alc883_dac_nids,
  6147. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6148. .adc_nids = alc883_adc_nids,
  6149. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6150. .channel_mode = alc883_3ST_2ch_modes,
  6151. .input_mux = &alc883_capture_source,
  6152. },
  6153. [ALC883_MEDION] = {
  6154. .mixers = { alc883_fivestack_mixer,
  6155. alc883_chmode_mixer },
  6156. .init_verbs = { alc883_init_verbs,
  6157. alc883_medion_eapd_verbs },
  6158. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6159. .dac_nids = alc883_dac_nids,
  6160. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6161. .adc_nids = alc883_adc_nids,
  6162. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6163. .channel_mode = alc883_sixstack_modes,
  6164. .input_mux = &alc883_capture_source,
  6165. },
  6166. [ALC883_MEDION_MD2] = {
  6167. .mixers = { alc883_medion_md2_mixer},
  6168. .init_verbs = { alc883_init_verbs, alc883_medion_md2_verbs},
  6169. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6170. .dac_nids = alc883_dac_nids,
  6171. .dig_out_nid = ALC883_DIGOUT_NID,
  6172. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6173. .adc_nids = alc883_adc_nids,
  6174. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6175. .channel_mode = alc883_3ST_2ch_modes,
  6176. .input_mux = &alc883_capture_source,
  6177. .unsol_event = alc883_medion_md2_unsol_event,
  6178. .init_hook = alc883_medion_md2_automute,
  6179. },
  6180. [ALC883_LAPTOP_EAPD] = {
  6181. .mixers = { alc883_base_mixer,
  6182. alc883_chmode_mixer },
  6183. .init_verbs = { alc883_init_verbs, alc882_eapd_verbs },
  6184. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6185. .dac_nids = alc883_dac_nids,
  6186. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6187. .adc_nids = alc883_adc_nids,
  6188. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6189. .channel_mode = alc883_3ST_2ch_modes,
  6190. .input_mux = &alc883_capture_source,
  6191. },
  6192. [ALC883_LENOVO_101E_2ch] = {
  6193. .mixers = { alc883_lenovo_101e_2ch_mixer},
  6194. .init_verbs = { alc883_init_verbs, alc883_lenovo_101e_verbs},
  6195. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6196. .dac_nids = alc883_dac_nids,
  6197. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6198. .adc_nids = alc883_adc_nids,
  6199. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6200. .channel_mode = alc883_3ST_2ch_modes,
  6201. .input_mux = &alc883_lenovo_101e_capture_source,
  6202. .unsol_event = alc883_lenovo_101e_unsol_event,
  6203. .init_hook = alc883_lenovo_101e_all_automute,
  6204. },
  6205. [ALC883_LENOVO_NB0763] = {
  6206. .mixers = { alc883_lenovo_nb0763_mixer },
  6207. .init_verbs = { alc883_init_verbs, alc883_lenovo_nb0763_verbs},
  6208. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6209. .dac_nids = alc883_dac_nids,
  6210. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6211. .adc_nids = alc883_adc_nids,
  6212. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  6213. .channel_mode = alc883_3ST_2ch_modes,
  6214. .need_dac_fix = 1,
  6215. .input_mux = &alc883_lenovo_nb0763_capture_source,
  6216. .unsol_event = alc883_medion_md2_unsol_event,
  6217. .init_hook = alc883_medion_md2_automute,
  6218. },
  6219. [ALC888_LENOVO_MS7195_DIG] = {
  6220. .mixers = { alc883_3ST_6ch_mixer, alc883_chmode_mixer },
  6221. .init_verbs = { alc883_init_verbs, alc888_lenovo_ms7195_verbs},
  6222. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6223. .dac_nids = alc883_dac_nids,
  6224. .dig_out_nid = ALC883_DIGOUT_NID,
  6225. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6226. .adc_nids = alc883_adc_nids,
  6227. .num_channel_mode = ARRAY_SIZE(alc883_3ST_6ch_modes),
  6228. .channel_mode = alc883_3ST_6ch_modes,
  6229. .need_dac_fix = 1,
  6230. .input_mux = &alc883_capture_source,
  6231. .unsol_event = alc883_lenovo_ms7195_unsol_event,
  6232. .init_hook = alc888_lenovo_ms7195_front_automute,
  6233. },
  6234. [ALC888_6ST_HP] = {
  6235. .mixers = { alc888_6st_hp_mixer, alc883_chmode_mixer },
  6236. .init_verbs = { alc883_init_verbs, alc888_6st_hp_verbs },
  6237. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6238. .dac_nids = alc883_dac_nids,
  6239. .dig_out_nid = ALC883_DIGOUT_NID,
  6240. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6241. .adc_nids = alc883_adc_nids,
  6242. .dig_in_nid = ALC883_DIGIN_NID,
  6243. .num_channel_mode = ARRAY_SIZE(alc883_sixstack_modes),
  6244. .channel_mode = alc883_sixstack_modes,
  6245. .input_mux = &alc883_capture_source,
  6246. },
  6247. [ALC888_3ST_HP] = {
  6248. .mixers = { alc888_3st_hp_mixer, alc883_chmode_mixer },
  6249. .init_verbs = { alc883_init_verbs, alc888_3st_hp_verbs },
  6250. .num_dacs = ARRAY_SIZE(alc883_dac_nids),
  6251. .dac_nids = alc883_dac_nids,
  6252. .num_adc_nids = ARRAY_SIZE(alc883_adc_nids),
  6253. .adc_nids = alc883_adc_nids,
  6254. .num_channel_mode = ARRAY_SIZE(alc888_3st_hp_modes),
  6255. .channel_mode = alc888_3st_hp_modes,
  6256. .need_dac_fix = 1,
  6257. .input_mux = &alc883_capture_source,
  6258. },
  6259. };
  6260. /*
  6261. * BIOS auto configuration
  6262. */
  6263. static void alc883_auto_set_output_and_unmute(struct hda_codec *codec,
  6264. hda_nid_t nid, int pin_type,
  6265. int dac_idx)
  6266. {
  6267. /* set as output */
  6268. struct alc_spec *spec = codec->spec;
  6269. int idx;
  6270. if (spec->multiout.dac_nids[dac_idx] == 0x25)
  6271. idx = 4;
  6272. else
  6273. idx = spec->multiout.dac_nids[dac_idx] - 2;
  6274. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  6275. pin_type);
  6276. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  6277. AMP_OUT_UNMUTE);
  6278. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL, idx);
  6279. }
  6280. static void alc883_auto_init_multi_out(struct hda_codec *codec)
  6281. {
  6282. struct alc_spec *spec = codec->spec;
  6283. int i;
  6284. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  6285. for (i = 0; i <= HDA_SIDE; i++) {
  6286. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  6287. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  6288. if (nid)
  6289. alc883_auto_set_output_and_unmute(codec, nid, pin_type,
  6290. i);
  6291. }
  6292. }
  6293. static void alc883_auto_init_hp_out(struct hda_codec *codec)
  6294. {
  6295. struct alc_spec *spec = codec->spec;
  6296. hda_nid_t pin;
  6297. pin = spec->autocfg.hp_pins[0];
  6298. if (pin) /* connect to front */
  6299. /* use dac 0 */
  6300. alc883_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  6301. }
  6302. #define alc883_is_input_pin(nid) alc880_is_input_pin(nid)
  6303. #define ALC883_PIN_CD_NID ALC880_PIN_CD_NID
  6304. static void alc883_auto_init_analog_input(struct hda_codec *codec)
  6305. {
  6306. struct alc_spec *spec = codec->spec;
  6307. int i;
  6308. for (i = 0; i < AUTO_PIN_LAST; i++) {
  6309. hda_nid_t nid = spec->autocfg.input_pins[i];
  6310. if (alc883_is_input_pin(nid)) {
  6311. snd_hda_codec_write(codec, nid, 0,
  6312. AC_VERB_SET_PIN_WIDGET_CONTROL,
  6313. (i <= AUTO_PIN_FRONT_MIC ?
  6314. PIN_VREF80 : PIN_IN));
  6315. if (nid != ALC883_PIN_CD_NID)
  6316. snd_hda_codec_write(codec, nid, 0,
  6317. AC_VERB_SET_AMP_GAIN_MUTE,
  6318. AMP_OUT_MUTE);
  6319. }
  6320. }
  6321. }
  6322. /* almost identical with ALC880 parser... */
  6323. static int alc883_parse_auto_config(struct hda_codec *codec)
  6324. {
  6325. struct alc_spec *spec = codec->spec;
  6326. int err = alc880_parse_auto_config(codec);
  6327. if (err < 0)
  6328. return err;
  6329. else if (err > 0)
  6330. /* hack - override the init verbs */
  6331. spec->init_verbs[0] = alc883_auto_init_verbs;
  6332. spec->mixers[spec->num_mixers] = alc883_capture_mixer;
  6333. spec->num_mixers++;
  6334. return err;
  6335. }
  6336. /* additional initialization for auto-configuration model */
  6337. static void alc883_auto_init(struct hda_codec *codec)
  6338. {
  6339. alc883_auto_init_multi_out(codec);
  6340. alc883_auto_init_hp_out(codec);
  6341. alc883_auto_init_analog_input(codec);
  6342. }
  6343. static int patch_alc883(struct hda_codec *codec)
  6344. {
  6345. struct alc_spec *spec;
  6346. int err, board_config;
  6347. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  6348. if (spec == NULL)
  6349. return -ENOMEM;
  6350. codec->spec = spec;
  6351. board_config = snd_hda_check_board_config(codec, ALC883_MODEL_LAST,
  6352. alc883_models,
  6353. alc883_cfg_tbl);
  6354. if (board_config < 0) {
  6355. printk(KERN_INFO "hda_codec: Unknown model for ALC883, "
  6356. "trying auto-probe from BIOS...\n");
  6357. board_config = ALC883_AUTO;
  6358. }
  6359. if (board_config == ALC883_AUTO) {
  6360. /* automatic parse from the BIOS config */
  6361. err = alc883_parse_auto_config(codec);
  6362. if (err < 0) {
  6363. alc_free(codec);
  6364. return err;
  6365. } else if (!err) {
  6366. printk(KERN_INFO
  6367. "hda_codec: Cannot set up configuration "
  6368. "from BIOS. Using base mode...\n");
  6369. board_config = ALC883_3ST_2ch_DIG;
  6370. }
  6371. }
  6372. if (board_config != ALC883_AUTO)
  6373. setup_preset(spec, &alc883_presets[board_config]);
  6374. spec->stream_name_analog = "ALC883 Analog";
  6375. spec->stream_analog_playback = &alc883_pcm_analog_playback;
  6376. spec->stream_analog_capture = &alc883_pcm_analog_capture;
  6377. spec->stream_name_digital = "ALC883 Digital";
  6378. spec->stream_digital_playback = &alc883_pcm_digital_playback;
  6379. spec->stream_digital_capture = &alc883_pcm_digital_capture;
  6380. if (!spec->adc_nids && spec->input_mux) {
  6381. spec->adc_nids = alc883_adc_nids;
  6382. spec->num_adc_nids = ARRAY_SIZE(alc883_adc_nids);
  6383. }
  6384. codec->patch_ops = alc_patch_ops;
  6385. if (board_config == ALC883_AUTO)
  6386. spec->init_hook = alc883_auto_init;
  6387. return 0;
  6388. }
  6389. /*
  6390. * ALC262 support
  6391. */
  6392. #define ALC262_DIGOUT_NID ALC880_DIGOUT_NID
  6393. #define ALC262_DIGIN_NID ALC880_DIGIN_NID
  6394. #define alc262_dac_nids alc260_dac_nids
  6395. #define alc262_adc_nids alc882_adc_nids
  6396. #define alc262_adc_nids_alt alc882_adc_nids_alt
  6397. #define alc262_modes alc260_modes
  6398. #define alc262_capture_source alc882_capture_source
  6399. static struct snd_kcontrol_new alc262_base_mixer[] = {
  6400. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6401. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6402. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6403. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6404. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6405. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6406. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6407. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6408. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6409. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6410. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6411. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6412. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6413. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6414. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),
  6415. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6416. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6417. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6418. { } /* end */
  6419. };
  6420. static struct snd_kcontrol_new alc262_hippo1_mixer[] = {
  6421. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6422. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6423. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6424. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6425. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6426. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6427. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6428. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6429. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6430. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6431. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6432. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6433. /* HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6434. HDA_CODEC_MUTE("PC Beelp Playback Switch", 0x0b, 0x05, HDA_INPUT), */
  6435. /*HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0D, 0x0, HDA_OUTPUT),*/
  6436. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6437. { } /* end */
  6438. };
  6439. static struct snd_kcontrol_new alc262_HP_BPC_mixer[] = {
  6440. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6441. HDA_CODEC_MUTE("Front Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6442. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6443. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6444. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6445. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6446. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6447. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6448. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6449. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6450. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  6451. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6452. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6453. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6454. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6455. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6456. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6457. HDA_CODEC_VOLUME("AUX IN Playback Volume", 0x0b, 0x06, HDA_INPUT),
  6458. HDA_CODEC_MUTE("AUX IN Playback Switch", 0x0b, 0x06, HDA_INPUT),
  6459. { } /* end */
  6460. };
  6461. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_mixer[] = {
  6462. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6463. HDA_CODEC_MUTE("Front Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  6464. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x0d, 0x0, HDA_OUTPUT),
  6465. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6466. HDA_CODEC_VOLUME_MONO("Mono Playback Volume", 0x0e, 2, 0x0, HDA_OUTPUT),
  6467. HDA_CODEC_MUTE_MONO("Mono Playback Switch", 0x16, 2, 0x0, HDA_OUTPUT),
  6468. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x02, HDA_INPUT),
  6469. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x02, HDA_INPUT),
  6470. HDA_CODEC_VOLUME("Front Mic Boost", 0x1a, 0, HDA_INPUT),
  6471. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6472. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6473. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6474. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6475. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x0b, 0x05, HDA_INPUT),
  6476. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x0b, 0x05, HDA_INPUT),
  6477. { } /* end */
  6478. };
  6479. static struct snd_kcontrol_new alc262_HP_BPC_WildWest_option_mixer[] = {
  6480. HDA_CODEC_VOLUME("Rear Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6481. HDA_CODEC_MUTE("Rear Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6482. HDA_CODEC_VOLUME("Rear Mic Boost", 0x18, 0, HDA_INPUT),
  6483. { } /* end */
  6484. };
  6485. static int alc262_sony_sw_put(struct snd_kcontrol *kcontrol,
  6486. struct snd_ctl_elem_value *ucontrol)
  6487. {
  6488. unsigned long private_save = kcontrol->private_value;
  6489. int change;
  6490. kcontrol->private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT);
  6491. change = snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
  6492. kcontrol->private_value = private_save;
  6493. change |= snd_hda_mixer_amp_switch_put(kcontrol, ucontrol);
  6494. return change;
  6495. }
  6496. static struct snd_kcontrol_new alc262_sony_mixer[] = {
  6497. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6498. {
  6499. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6500. .name = "Front Playback Switch",
  6501. .info = snd_hda_mixer_amp_switch_info,
  6502. .get = snd_hda_mixer_amp_switch_get,
  6503. .put = alc262_sony_sw_put,
  6504. .private_value = HDA_COMPOSE_AMP_VAL(0x15, 3, 0, HDA_OUTPUT),
  6505. },
  6506. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6507. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6508. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6509. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6510. { } /* end */
  6511. };
  6512. static struct snd_kcontrol_new alc262_benq_t31_mixer[] = {
  6513. HDA_CODEC_VOLUME("Front Playback Volume", 0x0c, 0x0, HDA_OUTPUT),
  6514. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  6515. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  6516. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6517. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6518. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x01, HDA_INPUT),
  6519. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x01, HDA_INPUT),
  6520. { } /* end */
  6521. };
  6522. #define alc262_capture_mixer alc882_capture_mixer
  6523. #define alc262_capture_alt_mixer alc882_capture_alt_mixer
  6524. /*
  6525. * generic initialization of ADC, input mixers and output mixers
  6526. */
  6527. static struct hda_verb alc262_init_verbs[] = {
  6528. /*
  6529. * Unmute ADC0-2 and set the default input to mic-in
  6530. */
  6531. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6532. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6533. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6534. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6535. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6536. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6537. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6538. * mixer widget
  6539. * Note: PASD motherboards uses the Line In 2 as the input for
  6540. * front panel mic (mic 2)
  6541. */
  6542. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6543. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6544. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6545. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6546. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6547. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6548. /*
  6549. * Set up output mixers (0x0c - 0x0e)
  6550. */
  6551. /* set vol=0 to output mixers */
  6552. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6553. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6554. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6555. /* set up input amps for analog loopback */
  6556. /* Amp Indices: DAC = 0, mixer = 1 */
  6557. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6558. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6559. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6560. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6561. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6562. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6563. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6564. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6565. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  6566. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6567. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6568. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6569. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6570. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6571. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6572. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6573. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6574. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  6575. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  6576. /* FIXME: use matrix-type input source selection */
  6577. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6578. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6579. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6580. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6581. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6582. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6583. /* Input mixer2 */
  6584. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6585. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6586. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6587. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6588. /* Input mixer3 */
  6589. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6590. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6591. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6592. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6593. { }
  6594. };
  6595. static struct hda_verb alc262_hippo_unsol_verbs[] = {
  6596. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6597. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6598. {}
  6599. };
  6600. static struct hda_verb alc262_hippo1_unsol_verbs[] = {
  6601. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6602. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6603. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, 0x0000},
  6604. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6605. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6606. {}
  6607. };
  6608. static struct hda_verb alc262_sony_unsol_verbs[] = {
  6609. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6610. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6611. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24}, // Front Mic
  6612. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  6613. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6614. };
  6615. /* mute/unmute internal speaker according to the hp jack and mute state */
  6616. static void alc262_hippo_automute(struct hda_codec *codec)
  6617. {
  6618. struct alc_spec *spec = codec->spec;
  6619. unsigned int mute;
  6620. unsigned int present;
  6621. /* need to execute and sync at first */
  6622. snd_hda_codec_read(codec, 0x15, 0, AC_VERB_SET_PIN_SENSE, 0);
  6623. present = snd_hda_codec_read(codec, 0x15, 0,
  6624. AC_VERB_GET_PIN_SENSE, 0);
  6625. spec->jack_present = (present & 0x80000000) != 0;
  6626. if (spec->jack_present) {
  6627. /* mute internal speaker */
  6628. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6629. 0x80, 0x80);
  6630. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6631. 0x80, 0x80);
  6632. } else {
  6633. /* unmute internal speaker if necessary */
  6634. mute = snd_hda_codec_amp_read(codec, 0x15, 0, HDA_OUTPUT, 0);
  6635. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6636. 0x80, mute & 0x80);
  6637. mute = snd_hda_codec_amp_read(codec, 0x15, 1, HDA_OUTPUT, 0);
  6638. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6639. 0x80, mute & 0x80);
  6640. }
  6641. }
  6642. /* unsolicited event for HP jack sensing */
  6643. static void alc262_hippo_unsol_event(struct hda_codec *codec,
  6644. unsigned int res)
  6645. {
  6646. if ((res >> 26) != ALC880_HP_EVENT)
  6647. return;
  6648. alc262_hippo_automute(codec);
  6649. }
  6650. static void alc262_hippo1_automute(struct hda_codec *codec)
  6651. {
  6652. unsigned int mute;
  6653. unsigned int present;
  6654. snd_hda_codec_read(codec, 0x1b, 0, AC_VERB_SET_PIN_SENSE, 0);
  6655. present = snd_hda_codec_read(codec, 0x1b, 0,
  6656. AC_VERB_GET_PIN_SENSE, 0);
  6657. present = (present & 0x80000000) != 0;
  6658. if (present) {
  6659. /* mute internal speaker */
  6660. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6661. 0x80, 0x80);
  6662. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6663. 0x80, 0x80);
  6664. } else {
  6665. /* unmute internal speaker if necessary */
  6666. mute = snd_hda_codec_amp_read(codec, 0x1b, 0, HDA_OUTPUT, 0);
  6667. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6668. 0x80, mute & 0x80);
  6669. mute = snd_hda_codec_amp_read(codec, 0x1b, 1, HDA_OUTPUT, 0);
  6670. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6671. 0x80, mute & 0x80);
  6672. }
  6673. }
  6674. /* unsolicited event for HP jack sensing */
  6675. static void alc262_hippo1_unsol_event(struct hda_codec *codec,
  6676. unsigned int res)
  6677. {
  6678. if ((res >> 26) != ALC880_HP_EVENT)
  6679. return;
  6680. alc262_hippo1_automute(codec);
  6681. }
  6682. /*
  6683. * fujitsu model
  6684. * 0x14 = headphone/spdif-out, 0x15 = internal speaker
  6685. */
  6686. #define ALC_HP_EVENT 0x37
  6687. static struct hda_verb alc262_fujitsu_unsol_verbs[] = {
  6688. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC_HP_EVENT},
  6689. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  6690. {}
  6691. };
  6692. static struct hda_input_mux alc262_fujitsu_capture_source = {
  6693. .num_items = 2,
  6694. .items = {
  6695. { "Mic", 0x0 },
  6696. { "CD", 0x4 },
  6697. },
  6698. };
  6699. static struct hda_input_mux alc262_HP_capture_source = {
  6700. .num_items = 5,
  6701. .items = {
  6702. { "Mic", 0x0 },
  6703. { "Front Mic", 0x3 },
  6704. { "Line", 0x2 },
  6705. { "CD", 0x4 },
  6706. { "AUX IN", 0x6 },
  6707. },
  6708. };
  6709. /* mute/unmute internal speaker according to the hp jack and mute state */
  6710. static void alc262_fujitsu_automute(struct hda_codec *codec, int force)
  6711. {
  6712. struct alc_spec *spec = codec->spec;
  6713. unsigned int mute;
  6714. if (force || !spec->sense_updated) {
  6715. unsigned int present;
  6716. /* need to execute and sync at first */
  6717. snd_hda_codec_read(codec, 0x14, 0, AC_VERB_SET_PIN_SENSE, 0);
  6718. present = snd_hda_codec_read(codec, 0x14, 0,
  6719. AC_VERB_GET_PIN_SENSE, 0);
  6720. spec->jack_present = (present & 0x80000000) != 0;
  6721. spec->sense_updated = 1;
  6722. }
  6723. if (spec->jack_present) {
  6724. /* mute internal speaker */
  6725. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6726. 0x80, 0x80);
  6727. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6728. 0x80, 0x80);
  6729. } else {
  6730. /* unmute internal speaker if necessary */
  6731. mute = snd_hda_codec_amp_read(codec, 0x14, 0, HDA_OUTPUT, 0);
  6732. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  6733. 0x80, mute & 0x80);
  6734. mute = snd_hda_codec_amp_read(codec, 0x14, 1, HDA_OUTPUT, 0);
  6735. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  6736. 0x80, mute & 0x80);
  6737. }
  6738. }
  6739. /* unsolicited event for HP jack sensing */
  6740. static void alc262_fujitsu_unsol_event(struct hda_codec *codec,
  6741. unsigned int res)
  6742. {
  6743. if ((res >> 26) != ALC_HP_EVENT)
  6744. return;
  6745. alc262_fujitsu_automute(codec, 1);
  6746. }
  6747. /* bind volumes of both NID 0x0c and 0x0d */
  6748. static int alc262_fujitsu_master_vol_put(struct snd_kcontrol *kcontrol,
  6749. struct snd_ctl_elem_value *ucontrol)
  6750. {
  6751. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6752. long *valp = ucontrol->value.integer.value;
  6753. int change;
  6754. change = snd_hda_codec_amp_update(codec, 0x0c, 0, HDA_OUTPUT, 0,
  6755. 0x7f, valp[0] & 0x7f);
  6756. change |= snd_hda_codec_amp_update(codec, 0x0c, 1, HDA_OUTPUT, 0,
  6757. 0x7f, valp[1] & 0x7f);
  6758. snd_hda_codec_amp_update(codec, 0x0d, 0, HDA_OUTPUT, 0,
  6759. 0x7f, valp[0] & 0x7f);
  6760. snd_hda_codec_amp_update(codec, 0x0d, 1, HDA_OUTPUT, 0,
  6761. 0x7f, valp[1] & 0x7f);
  6762. return change;
  6763. }
  6764. /* bind hp and internal speaker mute (with plug check) */
  6765. static int alc262_fujitsu_master_sw_put(struct snd_kcontrol *kcontrol,
  6766. struct snd_ctl_elem_value *ucontrol)
  6767. {
  6768. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  6769. long *valp = ucontrol->value.integer.value;
  6770. int change;
  6771. change = snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  6772. 0x80, valp[0] ? 0 : 0x80);
  6773. change |= snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  6774. 0x80, valp[1] ? 0 : 0x80);
  6775. if (change || codec->in_resume)
  6776. alc262_fujitsu_automute(codec, codec->in_resume);
  6777. return change;
  6778. }
  6779. static struct snd_kcontrol_new alc262_fujitsu_mixer[] = {
  6780. {
  6781. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6782. .name = "Master Playback Volume",
  6783. .info = snd_hda_mixer_amp_volume_info,
  6784. .get = snd_hda_mixer_amp_volume_get,
  6785. .put = alc262_fujitsu_master_vol_put,
  6786. .tlv = { .c = snd_hda_mixer_amp_tlv },
  6787. .private_value = HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT),
  6788. },
  6789. {
  6790. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  6791. .name = "Master Playback Switch",
  6792. .info = snd_hda_mixer_amp_switch_info,
  6793. .get = snd_hda_mixer_amp_switch_get,
  6794. .put = alc262_fujitsu_master_sw_put,
  6795. .private_value = HDA_COMPOSE_AMP_VAL(0x14, 3, 0, HDA_OUTPUT),
  6796. },
  6797. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  6798. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  6799. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  6800. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  6801. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  6802. { } /* end */
  6803. };
  6804. /* additional init verbs for Benq laptops */
  6805. static struct hda_verb alc262_EAPD_verbs[] = {
  6806. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6807. {0x20, AC_VERB_SET_PROC_COEF, 0x3070},
  6808. {}
  6809. };
  6810. static struct hda_verb alc262_benq_t31_EAPD_verbs[] = {
  6811. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6812. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6813. {0x20, AC_VERB_SET_COEF_INDEX, 0x07},
  6814. {0x20, AC_VERB_SET_PROC_COEF, 0x3050},
  6815. {}
  6816. };
  6817. /* add playback controls from the parsed DAC table */
  6818. static int alc262_auto_create_multi_out_ctls(struct alc_spec *spec,
  6819. const struct auto_pin_cfg *cfg)
  6820. {
  6821. hda_nid_t nid;
  6822. int err;
  6823. spec->multiout.num_dacs = 1; /* only use one dac */
  6824. spec->multiout.dac_nids = spec->private_dac_nids;
  6825. spec->multiout.dac_nids[0] = 2;
  6826. nid = cfg->line_out_pins[0];
  6827. if (nid) {
  6828. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6829. "Front Playback Volume",
  6830. HDA_COMPOSE_AMP_VAL(0x0c, 3, 0, HDA_OUTPUT));
  6831. if (err < 0)
  6832. return err;
  6833. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6834. "Front Playback Switch",
  6835. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  6836. if (err < 0)
  6837. return err;
  6838. }
  6839. nid = cfg->speaker_pins[0];
  6840. if (nid) {
  6841. if (nid == 0x16) {
  6842. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6843. "Speaker Playback Volume",
  6844. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6845. HDA_OUTPUT));
  6846. if (err < 0)
  6847. return err;
  6848. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6849. "Speaker Playback Switch",
  6850. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6851. HDA_OUTPUT));
  6852. if (err < 0)
  6853. return err;
  6854. } else {
  6855. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6856. "Speaker Playback Switch",
  6857. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6858. HDA_OUTPUT));
  6859. if (err < 0)
  6860. return err;
  6861. }
  6862. }
  6863. nid = cfg->hp_pins[0];
  6864. if (nid) {
  6865. /* spec->multiout.hp_nid = 2; */
  6866. if (nid == 0x16) {
  6867. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  6868. "Headphone Playback Volume",
  6869. HDA_COMPOSE_AMP_VAL(0x0e, 2, 0,
  6870. HDA_OUTPUT));
  6871. if (err < 0)
  6872. return err;
  6873. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6874. "Headphone Playback Switch",
  6875. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  6876. HDA_OUTPUT));
  6877. if (err < 0)
  6878. return err;
  6879. } else {
  6880. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  6881. "Headphone Playback Switch",
  6882. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  6883. HDA_OUTPUT));
  6884. if (err < 0)
  6885. return err;
  6886. }
  6887. }
  6888. return 0;
  6889. }
  6890. /* identical with ALC880 */
  6891. #define alc262_auto_create_analog_input_ctls \
  6892. alc880_auto_create_analog_input_ctls
  6893. /*
  6894. * generic initialization of ADC, input mixers and output mixers
  6895. */
  6896. static struct hda_verb alc262_volume_init_verbs[] = {
  6897. /*
  6898. * Unmute ADC0-2 and set the default input to mic-in
  6899. */
  6900. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6901. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6902. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6903. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6904. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6905. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6906. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6907. * mixer widget
  6908. * Note: PASD motherboards uses the Line In 2 as the input for
  6909. * front panel mic (mic 2)
  6910. */
  6911. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6912. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6913. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6914. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6915. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6916. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6917. /*
  6918. * Set up output mixers (0x0c - 0x0f)
  6919. */
  6920. /* set vol=0 to output mixers */
  6921. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6922. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6923. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6924. /* set up input amps for analog loopback */
  6925. /* Amp Indices: DAC = 0, mixer = 1 */
  6926. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6927. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6928. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6929. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6930. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6931. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6932. /* FIXME: use matrix-type input source selection */
  6933. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  6934. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  6935. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6936. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6937. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6938. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6939. /* Input mixer2 */
  6940. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6941. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6942. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6943. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6944. /* Input mixer3 */
  6945. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  6946. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x03 << 8))},
  6947. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8))},
  6948. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x04 << 8))},
  6949. { }
  6950. };
  6951. static struct hda_verb alc262_HP_BPC_init_verbs[] = {
  6952. /*
  6953. * Unmute ADC0-2 and set the default input to mic-in
  6954. */
  6955. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  6956. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6957. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  6958. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6959. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  6960. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6961. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  6962. * mixer widget
  6963. * Note: PASD motherboards uses the Line In 2 as the input for
  6964. * front panel mic (mic 2)
  6965. */
  6966. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  6967. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6968. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6969. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  6970. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  6971. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  6972. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  6973. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  6974. /*
  6975. * Set up output mixers (0x0c - 0x0e)
  6976. */
  6977. /* set vol=0 to output mixers */
  6978. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6979. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6980. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  6981. /* set up input amps for analog loopback */
  6982. /* Amp Indices: DAC = 0, mixer = 1 */
  6983. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6984. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6985. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6986. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6987. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  6988. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  6989. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  6990. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6991. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  6992. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6993. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  6994. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  6995. {0x15, AC_VERB_SET_CONNECT_SEL, 0x00},
  6996. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  6997. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6998. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  6999. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7000. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7001. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7002. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7003. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7004. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7005. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7006. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7007. /* FIXME: use matrix-type input source selection */
  7008. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7009. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7010. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7011. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7012. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7013. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7014. /* Input mixer2 */
  7015. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7016. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7017. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7018. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7019. /* Input mixer3 */
  7020. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7021. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7022. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7023. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7024. { }
  7025. };
  7026. static struct hda_verb alc262_HP_BPC_WildWest_init_verbs[] = {
  7027. /*
  7028. * Unmute ADC0-2 and set the default input to mic-in
  7029. */
  7030. {0x07, AC_VERB_SET_CONNECT_SEL, 0x00},
  7031. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7032. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  7033. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7034. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  7035. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7036. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  7037. * mixer widget
  7038. * Note: PASD motherboards uses the Line In 2 as the input for front
  7039. * panel mic (mic 2)
  7040. */
  7041. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  7042. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7043. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7044. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  7045. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  7046. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  7047. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(5)},
  7048. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(6)},
  7049. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(7)},
  7050. /*
  7051. * Set up output mixers (0x0c - 0x0e)
  7052. */
  7053. /* set vol=0 to output mixers */
  7054. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7055. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7056. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7057. /* set up input amps for analog loopback */
  7058. /* Amp Indices: DAC = 0, mixer = 1 */
  7059. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7060. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7061. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7062. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7063. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7064. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7065. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP }, /* HP */
  7066. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Mono */
  7067. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* rear MIC */
  7068. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* Line in */
  7069. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 }, /* Front MIC */
  7070. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT }, /* Line out */
  7071. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN }, /* CD in */
  7072. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7073. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  7074. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  7075. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  7076. /* {0x14, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 }, */
  7077. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7078. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7079. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, 0x7023 },
  7080. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7081. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, 0x7000 },
  7082. /* FIXME: use matrix-type input source selection */
  7083. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  7084. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7085. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))}, /*rear MIC*/
  7086. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))}, /*Line in*/
  7087. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))}, /*F MIC*/
  7088. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))}, /*Front*/
  7089. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))}, /*CD*/
  7090. /* {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7091. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))}, /*HP*/
  7092. /* Input mixer2 */
  7093. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7094. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7095. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7096. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7097. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7098. /* {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7099. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7100. /* Input mixer3 */
  7101. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7102. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7103. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7104. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7105. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x04 << 8))},
  7106. /* {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x06 << 8))}, */
  7107. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x07 << 8))},
  7108. { }
  7109. };
  7110. /* pcm configuration: identiacal with ALC880 */
  7111. #define alc262_pcm_analog_playback alc880_pcm_analog_playback
  7112. #define alc262_pcm_analog_capture alc880_pcm_analog_capture
  7113. #define alc262_pcm_digital_playback alc880_pcm_digital_playback
  7114. #define alc262_pcm_digital_capture alc880_pcm_digital_capture
  7115. /*
  7116. * BIOS auto configuration
  7117. */
  7118. static int alc262_parse_auto_config(struct hda_codec *codec)
  7119. {
  7120. struct alc_spec *spec = codec->spec;
  7121. int err;
  7122. static hda_nid_t alc262_ignore[] = { 0x1d, 0 };
  7123. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7124. alc262_ignore);
  7125. if (err < 0)
  7126. return err;
  7127. if (!spec->autocfg.line_outs)
  7128. return 0; /* can't find valid BIOS pin config */
  7129. err = alc262_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7130. if (err < 0)
  7131. return err;
  7132. err = alc262_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7133. if (err < 0)
  7134. return err;
  7135. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  7136. if (spec->autocfg.dig_out_pin)
  7137. spec->multiout.dig_out_nid = ALC262_DIGOUT_NID;
  7138. if (spec->autocfg.dig_in_pin)
  7139. spec->dig_in_nid = ALC262_DIGIN_NID;
  7140. if (spec->kctl_alloc)
  7141. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7142. spec->init_verbs[spec->num_init_verbs++] = alc262_volume_init_verbs;
  7143. spec->num_mux_defs = 1;
  7144. spec->input_mux = &spec->private_imux;
  7145. return 1;
  7146. }
  7147. #define alc262_auto_init_multi_out alc882_auto_init_multi_out
  7148. #define alc262_auto_init_hp_out alc882_auto_init_hp_out
  7149. #define alc262_auto_init_analog_input alc882_auto_init_analog_input
  7150. /* init callback for auto-configuration model -- overriding the default init */
  7151. static void alc262_auto_init(struct hda_codec *codec)
  7152. {
  7153. alc262_auto_init_multi_out(codec);
  7154. alc262_auto_init_hp_out(codec);
  7155. alc262_auto_init_analog_input(codec);
  7156. }
  7157. /*
  7158. * configuration and preset
  7159. */
  7160. static const char *alc262_models[ALC262_MODEL_LAST] = {
  7161. [ALC262_BASIC] = "basic",
  7162. [ALC262_HIPPO] = "hippo",
  7163. [ALC262_HIPPO_1] = "hippo_1",
  7164. [ALC262_FUJITSU] = "fujitsu",
  7165. [ALC262_HP_BPC] = "hp-bpc",
  7166. [ALC262_HP_BPC_D7000_WL]= "hp-bpc-d7000",
  7167. [ALC262_BENQ_ED8] = "benq",
  7168. [ALC262_BENQ_T31] = "benq-t31",
  7169. [ALC262_SONY_ASSAMD] = "sony-assamd",
  7170. [ALC262_AUTO] = "auto",
  7171. };
  7172. static struct snd_pci_quirk alc262_cfg_tbl[] = {
  7173. SND_PCI_QUIRK(0x1002, 0x437b, "Hippo", ALC262_HIPPO),
  7174. SND_PCI_QUIRK(0x103c, 0x12fe, "HP xw9400", ALC262_HP_BPC),
  7175. SND_PCI_QUIRK(0x103c, 0x280c, "HP xw4400", ALC262_HP_BPC),
  7176. SND_PCI_QUIRK(0x103c, 0x12ff, "HP xw4550", ALC262_HP_BPC),
  7177. SND_PCI_QUIRK(0x103c, 0x1308, "HP xw4600", ALC262_HP_BPC),
  7178. SND_PCI_QUIRK(0x103c, 0x3014, "HP xw6400", ALC262_HP_BPC),
  7179. SND_PCI_QUIRK(0x103c, 0x1307, "HP xw6600", ALC262_HP_BPC),
  7180. SND_PCI_QUIRK(0x103c, 0x3015, "HP xw8400", ALC262_HP_BPC),
  7181. SND_PCI_QUIRK(0x103c, 0x1306, "HP xw8600", ALC262_HP_BPC),
  7182. SND_PCI_QUIRK(0x103c, 0x2800, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7183. SND_PCI_QUIRK(0x103c, 0x2802, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7184. SND_PCI_QUIRK(0x103c, 0x2804, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7185. SND_PCI_QUIRK(0x103c, 0x2806, "HP D7000", ALC262_HP_BPC_D7000_WL),
  7186. SND_PCI_QUIRK(0x103c, 0x2801, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7187. SND_PCI_QUIRK(0x103c, 0x2803, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7188. SND_PCI_QUIRK(0x103c, 0x2805, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7189. SND_PCI_QUIRK(0x103c, 0x2807, "HP D7000", ALC262_HP_BPC_D7000_WF),
  7190. SND_PCI_QUIRK(0x104d, 0x8203, "Sony UX-90", ALC262_HIPPO),
  7191. SND_PCI_QUIRK(0x10cf, 0x1397, "Fujitsu", ALC262_FUJITSU),
  7192. SND_PCI_QUIRK(0x17ff, 0x058f, "Benq Hippo", ALC262_HIPPO_1),
  7193. SND_PCI_QUIRK(0x17ff, 0x0560, "Benq ED8", ALC262_BENQ_ED8),
  7194. SND_PCI_QUIRK(0x17ff, 0x058d, "Benq T31-16", ALC262_BENQ_T31),
  7195. SND_PCI_QUIRK(0x104d, 0x820f, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7196. SND_PCI_QUIRK(0x104d, 0x9015, "Sony 0x9015", ALC262_SONY_ASSAMD),
  7197. SND_PCI_QUIRK(0x104d, 0x900e, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7198. SND_PCI_QUIRK(0x104d, 0x1f00, "Sony ASSAMD", ALC262_SONY_ASSAMD),
  7199. {}
  7200. };
  7201. static struct alc_config_preset alc262_presets[] = {
  7202. [ALC262_BASIC] = {
  7203. .mixers = { alc262_base_mixer },
  7204. .init_verbs = { alc262_init_verbs },
  7205. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7206. .dac_nids = alc262_dac_nids,
  7207. .hp_nid = 0x03,
  7208. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7209. .channel_mode = alc262_modes,
  7210. .input_mux = &alc262_capture_source,
  7211. },
  7212. [ALC262_HIPPO] = {
  7213. .mixers = { alc262_base_mixer },
  7214. .init_verbs = { alc262_init_verbs, alc262_hippo_unsol_verbs},
  7215. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7216. .dac_nids = alc262_dac_nids,
  7217. .hp_nid = 0x03,
  7218. .dig_out_nid = ALC262_DIGOUT_NID,
  7219. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7220. .channel_mode = alc262_modes,
  7221. .input_mux = &alc262_capture_source,
  7222. .unsol_event = alc262_hippo_unsol_event,
  7223. .init_hook = alc262_hippo_automute,
  7224. },
  7225. [ALC262_HIPPO_1] = {
  7226. .mixers = { alc262_hippo1_mixer },
  7227. .init_verbs = { alc262_init_verbs, alc262_hippo1_unsol_verbs},
  7228. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7229. .dac_nids = alc262_dac_nids,
  7230. .hp_nid = 0x02,
  7231. .dig_out_nid = ALC262_DIGOUT_NID,
  7232. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7233. .channel_mode = alc262_modes,
  7234. .input_mux = &alc262_capture_source,
  7235. .unsol_event = alc262_hippo1_unsol_event,
  7236. .init_hook = alc262_hippo1_automute,
  7237. },
  7238. [ALC262_FUJITSU] = {
  7239. .mixers = { alc262_fujitsu_mixer },
  7240. .init_verbs = { alc262_init_verbs, alc262_fujitsu_unsol_verbs },
  7241. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7242. .dac_nids = alc262_dac_nids,
  7243. .hp_nid = 0x03,
  7244. .dig_out_nid = ALC262_DIGOUT_NID,
  7245. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7246. .channel_mode = alc262_modes,
  7247. .input_mux = &alc262_fujitsu_capture_source,
  7248. .unsol_event = alc262_fujitsu_unsol_event,
  7249. },
  7250. [ALC262_HP_BPC] = {
  7251. .mixers = { alc262_HP_BPC_mixer },
  7252. .init_verbs = { alc262_HP_BPC_init_verbs },
  7253. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7254. .dac_nids = alc262_dac_nids,
  7255. .hp_nid = 0x03,
  7256. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7257. .channel_mode = alc262_modes,
  7258. .input_mux = &alc262_HP_capture_source,
  7259. },
  7260. [ALC262_HP_BPC_D7000_WF] = {
  7261. .mixers = { alc262_HP_BPC_WildWest_mixer },
  7262. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7263. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7264. .dac_nids = alc262_dac_nids,
  7265. .hp_nid = 0x03,
  7266. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7267. .channel_mode = alc262_modes,
  7268. .input_mux = &alc262_HP_capture_source,
  7269. },
  7270. [ALC262_HP_BPC_D7000_WL] = {
  7271. .mixers = { alc262_HP_BPC_WildWest_mixer,
  7272. alc262_HP_BPC_WildWest_option_mixer },
  7273. .init_verbs = { alc262_HP_BPC_WildWest_init_verbs },
  7274. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7275. .dac_nids = alc262_dac_nids,
  7276. .hp_nid = 0x03,
  7277. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7278. .channel_mode = alc262_modes,
  7279. .input_mux = &alc262_HP_capture_source,
  7280. },
  7281. [ALC262_BENQ_ED8] = {
  7282. .mixers = { alc262_base_mixer },
  7283. .init_verbs = { alc262_init_verbs, alc262_EAPD_verbs },
  7284. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7285. .dac_nids = alc262_dac_nids,
  7286. .hp_nid = 0x03,
  7287. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7288. .channel_mode = alc262_modes,
  7289. .input_mux = &alc262_capture_source,
  7290. },
  7291. [ALC262_SONY_ASSAMD] = {
  7292. .mixers = { alc262_sony_mixer },
  7293. .init_verbs = { alc262_init_verbs, alc262_sony_unsol_verbs},
  7294. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7295. .dac_nids = alc262_dac_nids,
  7296. .hp_nid = 0x02,
  7297. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7298. .channel_mode = alc262_modes,
  7299. .input_mux = &alc262_capture_source,
  7300. .unsol_event = alc262_hippo_unsol_event,
  7301. .init_hook = alc262_hippo_automute,
  7302. },
  7303. [ALC262_BENQ_T31] = {
  7304. .mixers = { alc262_benq_t31_mixer },
  7305. .init_verbs = { alc262_init_verbs, alc262_benq_t31_EAPD_verbs, alc262_hippo_unsol_verbs },
  7306. .num_dacs = ARRAY_SIZE(alc262_dac_nids),
  7307. .dac_nids = alc262_dac_nids,
  7308. .hp_nid = 0x03,
  7309. .num_channel_mode = ARRAY_SIZE(alc262_modes),
  7310. .channel_mode = alc262_modes,
  7311. .input_mux = &alc262_capture_source,
  7312. .unsol_event = alc262_hippo_unsol_event,
  7313. .init_hook = alc262_hippo_automute,
  7314. },
  7315. };
  7316. static int patch_alc262(struct hda_codec *codec)
  7317. {
  7318. struct alc_spec *spec;
  7319. int board_config;
  7320. int err;
  7321. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  7322. if (spec == NULL)
  7323. return -ENOMEM;
  7324. codec->spec = spec;
  7325. #if 0
  7326. /* pshou 07/11/05 set a zero PCM sample to DAC when FIFO is
  7327. * under-run
  7328. */
  7329. {
  7330. int tmp;
  7331. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7332. tmp = snd_hda_codec_read(codec, 0x20, 0, AC_VERB_GET_PROC_COEF, 0);
  7333. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_COEF_INDEX, 7);
  7334. snd_hda_codec_write(codec, 0x1a, 0, AC_VERB_SET_PROC_COEF, tmp | 0x80);
  7335. }
  7336. #endif
  7337. board_config = snd_hda_check_board_config(codec, ALC262_MODEL_LAST,
  7338. alc262_models,
  7339. alc262_cfg_tbl);
  7340. if (board_config < 0) {
  7341. printk(KERN_INFO "hda_codec: Unknown model for ALC262, "
  7342. "trying auto-probe from BIOS...\n");
  7343. board_config = ALC262_AUTO;
  7344. }
  7345. if (board_config == ALC262_AUTO) {
  7346. /* automatic parse from the BIOS config */
  7347. err = alc262_parse_auto_config(codec);
  7348. if (err < 0) {
  7349. alc_free(codec);
  7350. return err;
  7351. } else if (!err) {
  7352. printk(KERN_INFO
  7353. "hda_codec: Cannot set up configuration "
  7354. "from BIOS. Using base mode...\n");
  7355. board_config = ALC262_BASIC;
  7356. }
  7357. }
  7358. if (board_config != ALC262_AUTO)
  7359. setup_preset(spec, &alc262_presets[board_config]);
  7360. spec->stream_name_analog = "ALC262 Analog";
  7361. spec->stream_analog_playback = &alc262_pcm_analog_playback;
  7362. spec->stream_analog_capture = &alc262_pcm_analog_capture;
  7363. spec->stream_name_digital = "ALC262 Digital";
  7364. spec->stream_digital_playback = &alc262_pcm_digital_playback;
  7365. spec->stream_digital_capture = &alc262_pcm_digital_capture;
  7366. if (!spec->adc_nids && spec->input_mux) {
  7367. /* check whether NID 0x07 is valid */
  7368. unsigned int wcap = get_wcaps(codec, 0x07);
  7369. /* get type */
  7370. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7371. if (wcap != AC_WID_AUD_IN) {
  7372. spec->adc_nids = alc262_adc_nids_alt;
  7373. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids_alt);
  7374. spec->mixers[spec->num_mixers] =
  7375. alc262_capture_alt_mixer;
  7376. spec->num_mixers++;
  7377. } else {
  7378. spec->adc_nids = alc262_adc_nids;
  7379. spec->num_adc_nids = ARRAY_SIZE(alc262_adc_nids);
  7380. spec->mixers[spec->num_mixers] = alc262_capture_mixer;
  7381. spec->num_mixers++;
  7382. }
  7383. }
  7384. codec->patch_ops = alc_patch_ops;
  7385. if (board_config == ALC262_AUTO)
  7386. spec->init_hook = alc262_auto_init;
  7387. return 0;
  7388. }
  7389. /*
  7390. * ALC268 channel source setting (2 channel)
  7391. */
  7392. #define ALC268_DIGOUT_NID ALC880_DIGOUT_NID
  7393. #define alc268_modes alc260_modes
  7394. static hda_nid_t alc268_dac_nids[2] = {
  7395. /* front, hp */
  7396. 0x02, 0x03
  7397. };
  7398. static hda_nid_t alc268_adc_nids[2] = {
  7399. /* ADC0-1 */
  7400. 0x08, 0x07
  7401. };
  7402. static hda_nid_t alc268_adc_nids_alt[1] = {
  7403. /* ADC0 */
  7404. 0x08
  7405. };
  7406. static struct snd_kcontrol_new alc268_base_mixer[] = {
  7407. /* output mixer control */
  7408. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  7409. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  7410. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  7411. HDA_CODEC_MUTE("Headphone Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  7412. { }
  7413. };
  7414. /*
  7415. * generic initialization of ADC, input mixers and output mixers
  7416. */
  7417. static struct hda_verb alc268_base_init_verbs[] = {
  7418. /* Unmute DAC0-1 and set vol = 0 */
  7419. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7420. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7421. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7422. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7423. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7424. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7425. /*
  7426. * Set up output mixers (0x0c - 0x0e)
  7427. */
  7428. /* set vol=0 to output mixers */
  7429. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7430. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7431. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7432. {0x0e, AC_VERB_SET_CONNECT_SEL, 0x00},
  7433. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7434. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7435. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7436. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0},
  7437. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40},
  7438. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7439. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7440. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7441. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7442. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7443. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7444. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7445. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7446. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7447. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7448. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7449. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7450. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7451. /* FIXME: use matrix-type input source selection */
  7452. /* Mixer elements: 0x18, 19, 1a, 1c, 14, 15, 0b */
  7453. /* Input mixer1: unmute Mic, F-Mic, Line, CD inputs */
  7454. /* Input mixer2 */
  7455. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7456. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7457. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7458. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7459. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x00 << 8))},
  7460. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8))},
  7461. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8))},
  7462. {0x24, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x03 << 8))},
  7463. { }
  7464. };
  7465. /*
  7466. * generic initialization of ADC, input mixers and output mixers
  7467. */
  7468. static struct hda_verb alc268_volume_init_verbs[] = {
  7469. /* set output DAC */
  7470. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7471. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7472. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7473. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7474. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7475. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24},
  7476. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7477. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7478. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20},
  7479. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  7480. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7481. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  7482. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7483. {0x10, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  7484. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7485. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7486. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7487. {0x1c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  7488. /* set PCBEEP vol = 0 */
  7489. {0x1d, AC_VERB_SET_AMP_GAIN_MUTE, (0xb000 | (0x00 << 8))},
  7490. { }
  7491. };
  7492. #define alc268_mux_enum_info alc_mux_enum_info
  7493. #define alc268_mux_enum_get alc_mux_enum_get
  7494. static int alc268_mux_enum_put(struct snd_kcontrol *kcontrol,
  7495. struct snd_ctl_elem_value *ucontrol)
  7496. {
  7497. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  7498. struct alc_spec *spec = codec->spec;
  7499. const struct hda_input_mux *imux = spec->input_mux;
  7500. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  7501. static hda_nid_t capture_mixers[3] = { 0x23, 0x24 };
  7502. hda_nid_t nid = capture_mixers[adc_idx];
  7503. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  7504. unsigned int i, idx;
  7505. idx = ucontrol->value.enumerated.item[0];
  7506. if (idx >= imux->num_items)
  7507. idx = imux->num_items - 1;
  7508. if (*cur_val == idx && !codec->in_resume)
  7509. return 0;
  7510. for (i = 0; i < imux->num_items; i++) {
  7511. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  7512. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  7513. v | (imux->items[i].index << 8));
  7514. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_CONNECT_SEL,
  7515. idx );
  7516. }
  7517. *cur_val = idx;
  7518. return 1;
  7519. }
  7520. static struct snd_kcontrol_new alc268_capture_alt_mixer[] = {
  7521. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7522. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7523. {
  7524. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7525. /* The multiple "Capture Source" controls confuse alsamixer
  7526. * So call somewhat different..
  7527. * FIXME: the controls appear in the "playback" view!
  7528. */
  7529. /* .name = "Capture Source", */
  7530. .name = "Input Source",
  7531. .count = 1,
  7532. .info = alc268_mux_enum_info,
  7533. .get = alc268_mux_enum_get,
  7534. .put = alc268_mux_enum_put,
  7535. },
  7536. { } /* end */
  7537. };
  7538. static struct snd_kcontrol_new alc268_capture_mixer[] = {
  7539. HDA_CODEC_VOLUME("Capture Volume", 0x23, 0x0, HDA_OUTPUT),
  7540. HDA_CODEC_MUTE("Capture Switch", 0x23, 0x0, HDA_OUTPUT),
  7541. HDA_CODEC_VOLUME_IDX("Capture Volume", 1, 0x24, 0x0, HDA_OUTPUT),
  7542. HDA_CODEC_MUTE_IDX("Capture Switch", 1, 0x24, 0x0, HDA_OUTPUT),
  7543. {
  7544. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7545. /* The multiple "Capture Source" controls confuse alsamixer
  7546. * So call somewhat different..
  7547. * FIXME: the controls appear in the "playback" view!
  7548. */
  7549. /* .name = "Capture Source", */
  7550. .name = "Input Source",
  7551. .count = 2,
  7552. .info = alc268_mux_enum_info,
  7553. .get = alc268_mux_enum_get,
  7554. .put = alc268_mux_enum_put,
  7555. },
  7556. { } /* end */
  7557. };
  7558. static struct hda_input_mux alc268_capture_source = {
  7559. .num_items = 4,
  7560. .items = {
  7561. { "Mic", 0x0 },
  7562. { "Front Mic", 0x1 },
  7563. { "Line", 0x2 },
  7564. { "CD", 0x3 },
  7565. },
  7566. };
  7567. /* create input playback/capture controls for the given pin */
  7568. static int alc268_new_analog_output(struct alc_spec *spec, hda_nid_t nid,
  7569. const char *ctlname, int idx)
  7570. {
  7571. char name[32];
  7572. int err;
  7573. sprintf(name, "%s Playback Volume", ctlname);
  7574. if (nid == 0x14) {
  7575. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7576. HDA_COMPOSE_AMP_VAL(0x02, 3, idx,
  7577. HDA_OUTPUT));
  7578. if (err < 0)
  7579. return err;
  7580. } else if (nid == 0x15) {
  7581. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  7582. HDA_COMPOSE_AMP_VAL(0x03, 3, idx,
  7583. HDA_OUTPUT));
  7584. if (err < 0)
  7585. return err;
  7586. } else
  7587. return -1;
  7588. sprintf(name, "%s Playback Switch", ctlname);
  7589. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  7590. HDA_COMPOSE_AMP_VAL(nid, 3, idx, HDA_OUTPUT));
  7591. if (err < 0)
  7592. return err;
  7593. return 0;
  7594. }
  7595. /* add playback controls from the parsed DAC table */
  7596. static int alc268_auto_create_multi_out_ctls(struct alc_spec *spec,
  7597. const struct auto_pin_cfg *cfg)
  7598. {
  7599. hda_nid_t nid;
  7600. int err;
  7601. spec->multiout.num_dacs = 2; /* only use one dac */
  7602. spec->multiout.dac_nids = spec->private_dac_nids;
  7603. spec->multiout.dac_nids[0] = 2;
  7604. spec->multiout.dac_nids[1] = 3;
  7605. nid = cfg->line_out_pins[0];
  7606. if (nid)
  7607. alc268_new_analog_output(spec, nid, "Front", 0);
  7608. nid = cfg->speaker_pins[0];
  7609. if (nid == 0x1d) {
  7610. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  7611. "Speaker Playback Volume",
  7612. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_INPUT));
  7613. if (err < 0)
  7614. return err;
  7615. }
  7616. nid = cfg->hp_pins[0];
  7617. if (nid)
  7618. alc268_new_analog_output(spec, nid, "Headphone", 0);
  7619. nid = cfg->line_out_pins[1] | cfg->line_out_pins[2];
  7620. if (nid == 0x16) {
  7621. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  7622. "Mono Playback Switch",
  7623. HDA_COMPOSE_AMP_VAL(nid, 2, 0, HDA_INPUT));
  7624. if (err < 0)
  7625. return err;
  7626. }
  7627. return 0;
  7628. }
  7629. /* create playback/capture controls for input pins */
  7630. static int alc268_auto_create_analog_input_ctls(struct alc_spec *spec,
  7631. const struct auto_pin_cfg *cfg)
  7632. {
  7633. struct hda_input_mux *imux = &spec->private_imux;
  7634. int i, idx1;
  7635. for (i = 0; i < AUTO_PIN_LAST; i++) {
  7636. switch(cfg->input_pins[i]) {
  7637. case 0x18:
  7638. idx1 = 0; /* Mic 1 */
  7639. break;
  7640. case 0x19:
  7641. idx1 = 1; /* Mic 2 */
  7642. break;
  7643. case 0x1a:
  7644. idx1 = 2; /* Line In */
  7645. break;
  7646. case 0x1c:
  7647. idx1 = 3; /* CD */
  7648. break;
  7649. default:
  7650. continue;
  7651. }
  7652. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  7653. imux->items[imux->num_items].index = idx1;
  7654. imux->num_items++;
  7655. }
  7656. return 0;
  7657. }
  7658. static void alc268_auto_init_mono_speaker_out(struct hda_codec *codec)
  7659. {
  7660. struct alc_spec *spec = codec->spec;
  7661. hda_nid_t speaker_nid = spec->autocfg.speaker_pins[0];
  7662. hda_nid_t hp_nid = spec->autocfg.hp_pins[0];
  7663. hda_nid_t line_nid = spec->autocfg.line_out_pins[0];
  7664. unsigned int dac_vol1, dac_vol2;
  7665. if (speaker_nid) {
  7666. snd_hda_codec_write(codec, speaker_nid, 0,
  7667. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  7668. snd_hda_codec_write(codec, 0x0f, 0,
  7669. AC_VERB_SET_AMP_GAIN_MUTE,
  7670. AMP_IN_UNMUTE(1));
  7671. snd_hda_codec_write(codec, 0x10, 0,
  7672. AC_VERB_SET_AMP_GAIN_MUTE,
  7673. AMP_IN_UNMUTE(1));
  7674. } else {
  7675. snd_hda_codec_write(codec, 0x0f, 0,
  7676. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7677. snd_hda_codec_write(codec, 0x10, 0,
  7678. AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1));
  7679. }
  7680. dac_vol1 = dac_vol2 = 0xb000 | 0x40; /* set max volume */
  7681. if (line_nid == 0x14)
  7682. dac_vol2 = AMP_OUT_ZERO;
  7683. else if (line_nid == 0x15)
  7684. dac_vol1 = AMP_OUT_ZERO;
  7685. if (hp_nid == 0x14)
  7686. dac_vol2 = AMP_OUT_ZERO;
  7687. else if (hp_nid == 0x15)
  7688. dac_vol1 = AMP_OUT_ZERO;
  7689. if (line_nid != 0x16 || hp_nid != 0x16 ||
  7690. spec->autocfg.line_out_pins[1] != 0x16 ||
  7691. spec->autocfg.line_out_pins[2] != 0x16)
  7692. dac_vol1 = dac_vol2 = AMP_OUT_ZERO;
  7693. snd_hda_codec_write(codec, 0x02, 0,
  7694. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol1);
  7695. snd_hda_codec_write(codec, 0x03, 0,
  7696. AC_VERB_SET_AMP_GAIN_MUTE, dac_vol2);
  7697. }
  7698. /* pcm configuration: identiacal with ALC880 */
  7699. #define alc268_pcm_analog_playback alc880_pcm_analog_playback
  7700. #define alc268_pcm_analog_capture alc880_pcm_analog_capture
  7701. #define alc268_pcm_digital_playback alc880_pcm_digital_playback
  7702. /*
  7703. * BIOS auto configuration
  7704. */
  7705. static int alc268_parse_auto_config(struct hda_codec *codec)
  7706. {
  7707. struct alc_spec *spec = codec->spec;
  7708. int err;
  7709. static hda_nid_t alc268_ignore[] = { 0 };
  7710. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  7711. alc268_ignore);
  7712. if (err < 0)
  7713. return err;
  7714. if (!spec->autocfg.line_outs)
  7715. return 0; /* can't find valid BIOS pin config */
  7716. err = alc268_auto_create_multi_out_ctls(spec, &spec->autocfg);
  7717. if (err < 0)
  7718. return err;
  7719. err = alc268_auto_create_analog_input_ctls(spec, &spec->autocfg);
  7720. if (err < 0)
  7721. return err;
  7722. spec->multiout.max_channels = 2;
  7723. /* digital only support output */
  7724. if (spec->autocfg.dig_out_pin)
  7725. spec->multiout.dig_out_nid = ALC268_DIGOUT_NID;
  7726. if (spec->kctl_alloc)
  7727. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  7728. spec->init_verbs[spec->num_init_verbs++] = alc268_volume_init_verbs;
  7729. spec->num_mux_defs = 1;
  7730. spec->input_mux = &spec->private_imux;
  7731. return 1;
  7732. }
  7733. #define alc268_auto_init_multi_out alc882_auto_init_multi_out
  7734. #define alc268_auto_init_hp_out alc882_auto_init_hp_out
  7735. #define alc268_auto_init_analog_input alc882_auto_init_analog_input
  7736. /* init callback for auto-configuration model -- overriding the default init */
  7737. static void alc268_auto_init(struct hda_codec *codec)
  7738. {
  7739. alc268_auto_init_multi_out(codec);
  7740. alc268_auto_init_hp_out(codec);
  7741. alc268_auto_init_mono_speaker_out(codec);
  7742. alc268_auto_init_analog_input(codec);
  7743. }
  7744. /*
  7745. * configuration and preset
  7746. */
  7747. static const char *alc268_models[ALC268_MODEL_LAST] = {
  7748. [ALC268_3ST] = "3stack",
  7749. [ALC268_AUTO] = "auto",
  7750. };
  7751. static struct snd_pci_quirk alc268_cfg_tbl[] = {
  7752. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC268_3ST),
  7753. {}
  7754. };
  7755. static struct alc_config_preset alc268_presets[] = {
  7756. [ALC268_3ST] = {
  7757. .mixers = { alc268_base_mixer, alc268_capture_alt_mixer },
  7758. .init_verbs = { alc268_base_init_verbs },
  7759. .num_dacs = ARRAY_SIZE(alc268_dac_nids),
  7760. .dac_nids = alc268_dac_nids,
  7761. .num_adc_nids = ARRAY_SIZE(alc268_adc_nids_alt),
  7762. .adc_nids = alc268_adc_nids_alt,
  7763. .hp_nid = 0x03,
  7764. .dig_out_nid = ALC268_DIGOUT_NID,
  7765. .num_channel_mode = ARRAY_SIZE(alc268_modes),
  7766. .channel_mode = alc268_modes,
  7767. .input_mux = &alc268_capture_source,
  7768. },
  7769. };
  7770. static int patch_alc268(struct hda_codec *codec)
  7771. {
  7772. struct alc_spec *spec;
  7773. int board_config;
  7774. int err;
  7775. spec = kcalloc(1, sizeof(*spec), GFP_KERNEL);
  7776. if (spec == NULL)
  7777. return -ENOMEM;
  7778. codec->spec = spec;
  7779. board_config = snd_hda_check_board_config(codec, ALC268_MODEL_LAST,
  7780. alc268_models,
  7781. alc268_cfg_tbl);
  7782. if (board_config < 0 || board_config >= ALC268_MODEL_LAST) {
  7783. printk(KERN_INFO "hda_codec: Unknown model for ALC268, "
  7784. "trying auto-probe from BIOS...\n");
  7785. board_config = ALC268_AUTO;
  7786. }
  7787. if (board_config == ALC268_AUTO) {
  7788. /* automatic parse from the BIOS config */
  7789. err = alc268_parse_auto_config(codec);
  7790. if (err < 0) {
  7791. alc_free(codec);
  7792. return err;
  7793. } else if (!err) {
  7794. printk(KERN_INFO
  7795. "hda_codec: Cannot set up configuration "
  7796. "from BIOS. Using base mode...\n");
  7797. board_config = ALC268_3ST;
  7798. }
  7799. }
  7800. if (board_config != ALC268_AUTO)
  7801. setup_preset(spec, &alc268_presets[board_config]);
  7802. spec->stream_name_analog = "ALC268 Analog";
  7803. spec->stream_analog_playback = &alc268_pcm_analog_playback;
  7804. spec->stream_analog_capture = &alc268_pcm_analog_capture;
  7805. spec->stream_name_digital = "ALC268 Digital";
  7806. spec->stream_digital_playback = &alc268_pcm_digital_playback;
  7807. if (board_config == ALC268_AUTO) {
  7808. if (!spec->adc_nids && spec->input_mux) {
  7809. /* check whether NID 0x07 is valid */
  7810. unsigned int wcap = get_wcaps(codec, 0x07);
  7811. /* get type */
  7812. wcap = (wcap & AC_WCAP_TYPE) >> AC_WCAP_TYPE_SHIFT;
  7813. if (wcap != AC_WID_AUD_IN) {
  7814. spec->adc_nids = alc268_adc_nids_alt;
  7815. spec->num_adc_nids =
  7816. ARRAY_SIZE(alc268_adc_nids_alt);
  7817. spec->mixers[spec->num_mixers] =
  7818. alc268_capture_alt_mixer;
  7819. spec->num_mixers++;
  7820. } else {
  7821. spec->adc_nids = alc268_adc_nids;
  7822. spec->num_adc_nids =
  7823. ARRAY_SIZE(alc268_adc_nids);
  7824. spec->mixers[spec->num_mixers] =
  7825. alc268_capture_mixer;
  7826. spec->num_mixers++;
  7827. }
  7828. }
  7829. }
  7830. codec->patch_ops = alc_patch_ops;
  7831. if (board_config == ALC268_AUTO)
  7832. spec->init_hook = alc268_auto_init;
  7833. return 0;
  7834. }
  7835. /*
  7836. * ALC861 channel source setting (2/6 channel selection for 3-stack)
  7837. */
  7838. /*
  7839. * set the path ways for 2 channel output
  7840. * need to set the codec line out and mic 1 pin widgets to inputs
  7841. */
  7842. static struct hda_verb alc861_threestack_ch2_init[] = {
  7843. /* set pin widget 1Ah (line in) for input */
  7844. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7845. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7846. * the vref
  7847. */
  7848. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7849. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7850. #if 0
  7851. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7852. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7853. #endif
  7854. { } /* end */
  7855. };
  7856. /*
  7857. * 6ch mode
  7858. * need to set the codec line out and mic 1 pin widgets to outputs
  7859. */
  7860. static struct hda_verb alc861_threestack_ch6_init[] = {
  7861. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7862. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7863. /* set pin widget 18h (mic1) for output (CLFE)*/
  7864. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7865. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7866. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7867. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7868. #if 0
  7869. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7870. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7871. #endif
  7872. { } /* end */
  7873. };
  7874. static struct hda_channel_mode alc861_threestack_modes[2] = {
  7875. { 2, alc861_threestack_ch2_init },
  7876. { 6, alc861_threestack_ch6_init },
  7877. };
  7878. /* Set mic1 as input and unmute the mixer */
  7879. static struct hda_verb alc861_uniwill_m31_ch2_init[] = {
  7880. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7881. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7882. { } /* end */
  7883. };
  7884. /* Set mic1 as output and mute mixer */
  7885. static struct hda_verb alc861_uniwill_m31_ch4_init[] = {
  7886. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7887. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7888. { } /* end */
  7889. };
  7890. static struct hda_channel_mode alc861_uniwill_m31_modes[2] = {
  7891. { 2, alc861_uniwill_m31_ch2_init },
  7892. { 4, alc861_uniwill_m31_ch4_init },
  7893. };
  7894. /* Set mic1 and line-in as input and unmute the mixer */
  7895. static struct hda_verb alc861_asus_ch2_init[] = {
  7896. /* set pin widget 1Ah (line in) for input */
  7897. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  7898. /* set pin widget 18h (mic1/2) for input, for mic also enable
  7899. * the vref
  7900. */
  7901. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  7902. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c },
  7903. #if 0
  7904. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x01 << 8)) }, /*mic*/
  7905. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7000 | (0x02 << 8)) }, /*line-in*/
  7906. #endif
  7907. { } /* end */
  7908. };
  7909. /* Set mic1 nad line-in as output and mute mixer */
  7910. static struct hda_verb alc861_asus_ch6_init[] = {
  7911. /* set pin widget 1Ah (line in) for output (Back Surround)*/
  7912. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7913. /* { 0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7914. /* set pin widget 18h (mic1) for output (CLFE)*/
  7915. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  7916. /* { 0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE }, */
  7917. { 0x0c, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7918. { 0x0d, AC_VERB_SET_CONNECT_SEL, 0x00 },
  7919. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb080 },
  7920. #if 0
  7921. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x01 << 8)) }, /*mic*/
  7922. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, (0x7080 | (0x02 << 8)) }, /*line in*/
  7923. #endif
  7924. { } /* end */
  7925. };
  7926. static struct hda_channel_mode alc861_asus_modes[2] = {
  7927. { 2, alc861_asus_ch2_init },
  7928. { 6, alc861_asus_ch6_init },
  7929. };
  7930. /* patch-ALC861 */
  7931. static struct snd_kcontrol_new alc861_base_mixer[] = {
  7932. /* output mixer control */
  7933. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7934. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7935. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7936. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7937. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  7938. /*Input mixer control */
  7939. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7940. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7941. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7942. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7943. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7944. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7945. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7946. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7947. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7948. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7949. /* Capture mixer control */
  7950. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7951. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7952. {
  7953. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7954. .name = "Capture Source",
  7955. .count = 1,
  7956. .info = alc_mux_enum_info,
  7957. .get = alc_mux_enum_get,
  7958. .put = alc_mux_enum_put,
  7959. },
  7960. { } /* end */
  7961. };
  7962. static struct snd_kcontrol_new alc861_3ST_mixer[] = {
  7963. /* output mixer control */
  7964. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  7965. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  7966. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  7967. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  7968. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  7969. /* Input mixer control */
  7970. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  7971. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  7972. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  7973. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  7974. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  7975. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  7976. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  7977. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  7978. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  7979. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  7980. /* Capture mixer control */
  7981. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  7982. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  7983. {
  7984. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7985. .name = "Capture Source",
  7986. .count = 1,
  7987. .info = alc_mux_enum_info,
  7988. .get = alc_mux_enum_get,
  7989. .put = alc_mux_enum_put,
  7990. },
  7991. {
  7992. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  7993. .name = "Channel Mode",
  7994. .info = alc_ch_mode_info,
  7995. .get = alc_ch_mode_get,
  7996. .put = alc_ch_mode_put,
  7997. .private_value = ARRAY_SIZE(alc861_threestack_modes),
  7998. },
  7999. { } /* end */
  8000. };
  8001. static struct snd_kcontrol_new alc861_toshiba_mixer[] = {
  8002. /* output mixer control */
  8003. HDA_CODEC_MUTE("Master Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8004. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8005. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8006. /*Capture mixer control */
  8007. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8008. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8009. {
  8010. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8011. .name = "Capture Source",
  8012. .count = 1,
  8013. .info = alc_mux_enum_info,
  8014. .get = alc_mux_enum_get,
  8015. .put = alc_mux_enum_put,
  8016. },
  8017. { } /* end */
  8018. };
  8019. static struct snd_kcontrol_new alc861_uniwill_m31_mixer[] = {
  8020. /* output mixer control */
  8021. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8022. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8023. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8024. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8025. /*HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT), */
  8026. /* Input mixer control */
  8027. /* HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8028. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT), */
  8029. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8030. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8031. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8032. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8033. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8034. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8035. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8036. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_INPUT),
  8037. /* Capture mixer control */
  8038. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8039. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8040. {
  8041. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8042. .name = "Capture Source",
  8043. .count = 1,
  8044. .info = alc_mux_enum_info,
  8045. .get = alc_mux_enum_get,
  8046. .put = alc_mux_enum_put,
  8047. },
  8048. {
  8049. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8050. .name = "Channel Mode",
  8051. .info = alc_ch_mode_info,
  8052. .get = alc_ch_mode_get,
  8053. .put = alc_ch_mode_put,
  8054. .private_value = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8055. },
  8056. { } /* end */
  8057. };
  8058. static struct snd_kcontrol_new alc861_asus_mixer[] = {
  8059. /* output mixer control */
  8060. HDA_CODEC_MUTE("Front Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  8061. HDA_CODEC_MUTE("Surround Playback Switch", 0x06, 0x0, HDA_OUTPUT),
  8062. HDA_CODEC_MUTE_MONO("Center Playback Switch", 0x05, 1, 0x0, HDA_OUTPUT),
  8063. HDA_CODEC_MUTE_MONO("LFE Playback Switch", 0x05, 2, 0x0, HDA_OUTPUT),
  8064. HDA_CODEC_MUTE("Side Playback Switch", 0x04, 0x0, HDA_OUTPUT),
  8065. /* Input mixer control */
  8066. HDA_CODEC_VOLUME("Input Playback Volume", 0x15, 0x0, HDA_OUTPUT),
  8067. HDA_CODEC_MUTE("Input Playback Switch", 0x15, 0x0, HDA_OUTPUT),
  8068. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8069. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8070. HDA_CODEC_VOLUME("Line Playback Volume", 0x15, 0x02, HDA_INPUT),
  8071. HDA_CODEC_MUTE("Line Playback Switch", 0x15, 0x02, HDA_INPUT),
  8072. HDA_CODEC_VOLUME("Mic Playback Volume", 0x15, 0x01, HDA_INPUT),
  8073. HDA_CODEC_MUTE("Mic Playback Switch", 0x15, 0x01, HDA_INPUT),
  8074. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x10, 0x01, HDA_OUTPUT),
  8075. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1a, 0x03, HDA_OUTPUT),
  8076. /* Capture mixer control */
  8077. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8078. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8079. {
  8080. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8081. .name = "Capture Source",
  8082. .count = 1,
  8083. .info = alc_mux_enum_info,
  8084. .get = alc_mux_enum_get,
  8085. .put = alc_mux_enum_put,
  8086. },
  8087. {
  8088. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8089. .name = "Channel Mode",
  8090. .info = alc_ch_mode_info,
  8091. .get = alc_ch_mode_get,
  8092. .put = alc_ch_mode_put,
  8093. .private_value = ARRAY_SIZE(alc861_asus_modes),
  8094. },
  8095. { }
  8096. };
  8097. /* additional mixer */
  8098. static struct snd_kcontrol_new alc861_asus_laptop_mixer[] = {
  8099. HDA_CODEC_VOLUME("CD Playback Volume", 0x15, 0x0, HDA_INPUT),
  8100. HDA_CODEC_MUTE("CD Playback Switch", 0x15, 0x0, HDA_INPUT),
  8101. HDA_CODEC_VOLUME("PC Beep Playback Volume", 0x23, 0x0, HDA_OUTPUT),
  8102. HDA_CODEC_MUTE("PC Beep Playback Switch", 0x23, 0x0, HDA_OUTPUT),
  8103. { }
  8104. };
  8105. /*
  8106. * generic initialization of ADC, input mixers and output mixers
  8107. */
  8108. static struct hda_verb alc861_base_init_verbs[] = {
  8109. /*
  8110. * Unmute ADC0 and set the default input to mic-in
  8111. */
  8112. /* port-A for surround (rear panel) */
  8113. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8114. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8115. /* port-B for mic-in (rear panel) with vref */
  8116. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8117. /* port-C for line-in (rear panel) */
  8118. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8119. /* port-D for Front */
  8120. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8121. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8122. /* port-E for HP out (front panel) */
  8123. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8124. /* route front PCM to HP */
  8125. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8126. /* port-F for mic-in (front panel) with vref */
  8127. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8128. /* port-G for CLFE (rear panel) */
  8129. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8130. { 0x1f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8131. /* port-H for side (rear panel) */
  8132. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8133. { 0x20, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8134. /* CD-in */
  8135. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8136. /* route front mic to ADC1*/
  8137. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8138. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8139. /* Unmute DAC0~3 & spdif out*/
  8140. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8141. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8142. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8143. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8144. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8145. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8146. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8147. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8148. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8149. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8150. /* Unmute Stereo Mixer 15 */
  8151. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8152. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8153. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8154. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8155. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8156. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8157. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8158. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8159. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8160. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8161. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8162. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8163. /* hp used DAC 3 (Front) */
  8164. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8165. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8166. { }
  8167. };
  8168. static struct hda_verb alc861_threestack_init_verbs[] = {
  8169. /*
  8170. * Unmute ADC0 and set the default input to mic-in
  8171. */
  8172. /* port-A for surround (rear panel) */
  8173. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8174. /* port-B for mic-in (rear panel) with vref */
  8175. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8176. /* port-C for line-in (rear panel) */
  8177. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8178. /* port-D for Front */
  8179. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8180. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8181. /* port-E for HP out (front panel) */
  8182. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 },
  8183. /* route front PCM to HP */
  8184. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8185. /* port-F for mic-in (front panel) with vref */
  8186. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8187. /* port-G for CLFE (rear panel) */
  8188. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8189. /* port-H for side (rear panel) */
  8190. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8191. /* CD-in */
  8192. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8193. /* route front mic to ADC1*/
  8194. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8195. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8196. /* Unmute DAC0~3 & spdif out*/
  8197. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8198. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8199. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8200. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8201. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8202. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8203. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8204. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8205. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8206. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8207. /* Unmute Stereo Mixer 15 */
  8208. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8209. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8210. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8211. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8212. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8213. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8214. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8215. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8216. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8217. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8218. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8219. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8220. /* hp used DAC 3 (Front) */
  8221. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8222. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8223. { }
  8224. };
  8225. static struct hda_verb alc861_uniwill_m31_init_verbs[] = {
  8226. /*
  8227. * Unmute ADC0 and set the default input to mic-in
  8228. */
  8229. /* port-A for surround (rear panel) */
  8230. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8231. /* port-B for mic-in (rear panel) with vref */
  8232. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8233. /* port-C for line-in (rear panel) */
  8234. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8235. /* port-D for Front */
  8236. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8237. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8238. /* port-E for HP out (front panel) */
  8239. /* this has to be set to VREF80 */
  8240. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8241. /* route front PCM to HP */
  8242. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8243. /* port-F for mic-in (front panel) with vref */
  8244. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8245. /* port-G for CLFE (rear panel) */
  8246. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8247. /* port-H for side (rear panel) */
  8248. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8249. /* CD-in */
  8250. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8251. /* route front mic to ADC1*/
  8252. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8253. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8254. /* Unmute DAC0~3 & spdif out*/
  8255. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8256. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8257. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8258. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8259. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8260. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8261. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8262. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8263. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8264. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8265. /* Unmute Stereo Mixer 15 */
  8266. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8267. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8268. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8269. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8270. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8271. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8272. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8273. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8274. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8275. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8276. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8277. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8278. /* hp used DAC 3 (Front) */
  8279. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8280. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8281. { }
  8282. };
  8283. static struct hda_verb alc861_asus_init_verbs[] = {
  8284. /*
  8285. * Unmute ADC0 and set the default input to mic-in
  8286. */
  8287. /* port-A for surround (rear panel)
  8288. * according to codec#0 this is the HP jack
  8289. */
  8290. { 0x0e, AC_VERB_SET_PIN_WIDGET_CONTROL, 0xc0 }, /* was 0x00 */
  8291. /* route front PCM to HP */
  8292. { 0x0e, AC_VERB_SET_CONNECT_SEL, 0x01 },
  8293. /* port-B for mic-in (rear panel) with vref */
  8294. { 0x0d, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8295. /* port-C for line-in (rear panel) */
  8296. { 0x0c, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8297. /* port-D for Front */
  8298. { 0x0b, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8299. { 0x0b, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8300. /* port-E for HP out (front panel) */
  8301. /* this has to be set to VREF80 */
  8302. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8303. /* route front PCM to HP */
  8304. { 0x0f, AC_VERB_SET_CONNECT_SEL, 0x00 },
  8305. /* port-F for mic-in (front panel) with vref */
  8306. { 0x10, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x24 },
  8307. /* port-G for CLFE (rear panel) */
  8308. { 0x1f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8309. /* port-H for side (rear panel) */
  8310. { 0x20, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x40 },
  8311. /* CD-in */
  8312. { 0x11, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x20 },
  8313. /* route front mic to ADC1*/
  8314. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00},
  8315. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8316. /* Unmute DAC0~3 & spdif out*/
  8317. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8318. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8319. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8320. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8321. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8322. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8323. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8324. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8325. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8326. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8327. /* Unmute Stereo Mixer 15 */
  8328. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8329. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8330. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8331. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c}, /* Output 0~12 step */
  8332. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8333. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8334. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8335. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8336. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8337. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8338. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8339. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8340. /* hp used DAC 3 (Front) */
  8341. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8342. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8343. { }
  8344. };
  8345. /* additional init verbs for ASUS laptops */
  8346. static struct hda_verb alc861_asus_laptop_init_verbs[] = {
  8347. { 0x0f, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x45 }, /* HP-out */
  8348. { 0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2) }, /* mute line-in */
  8349. { }
  8350. };
  8351. /*
  8352. * generic initialization of ADC, input mixers and output mixers
  8353. */
  8354. static struct hda_verb alc861_auto_init_verbs[] = {
  8355. /*
  8356. * Unmute ADC0 and set the default input to mic-in
  8357. */
  8358. /* {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, */
  8359. {0x08, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8360. /* Unmute DAC0~3 & spdif out*/
  8361. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8362. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8363. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8364. {0x06, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  8365. {0x07, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  8366. /* Unmute Mixer 14 (mic) 1c (Line in)*/
  8367. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8368. {0x014, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8369. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8370. {0x01c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8371. /* Unmute Stereo Mixer 15 */
  8372. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8373. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8374. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8375. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, 0xb00c},
  8376. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8377. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8378. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8379. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8380. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8381. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8382. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  8383. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  8384. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8385. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8386. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8387. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8388. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  8389. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  8390. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  8391. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  8392. {0x08, AC_VERB_SET_CONNECT_SEL, 0x00}, /* set Mic 1 */
  8393. { }
  8394. };
  8395. static struct hda_verb alc861_toshiba_init_verbs[] = {
  8396. {0x0f, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  8397. { }
  8398. };
  8399. /* toggle speaker-output according to the hp-jack state */
  8400. static void alc861_toshiba_automute(struct hda_codec *codec)
  8401. {
  8402. unsigned int present;
  8403. present = snd_hda_codec_read(codec, 0x0f, 0,
  8404. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  8405. snd_hda_codec_amp_update(codec, 0x16, 0, HDA_INPUT, 0,
  8406. 0x80, present ? 0x80 : 0);
  8407. snd_hda_codec_amp_update(codec, 0x16, 1, HDA_INPUT, 0,
  8408. 0x80, present ? 0x80 : 0);
  8409. snd_hda_codec_amp_update(codec, 0x1a, 0, HDA_INPUT, 3,
  8410. 0x80, present ? 0 : 0x80);
  8411. snd_hda_codec_amp_update(codec, 0x1a, 1, HDA_INPUT, 3,
  8412. 0x80, present ? 0 : 0x80);
  8413. }
  8414. static void alc861_toshiba_unsol_event(struct hda_codec *codec,
  8415. unsigned int res)
  8416. {
  8417. if ((res >> 26) == ALC880_HP_EVENT)
  8418. alc861_toshiba_automute(codec);
  8419. }
  8420. /* pcm configuration: identiacal with ALC880 */
  8421. #define alc861_pcm_analog_playback alc880_pcm_analog_playback
  8422. #define alc861_pcm_analog_capture alc880_pcm_analog_capture
  8423. #define alc861_pcm_digital_playback alc880_pcm_digital_playback
  8424. #define alc861_pcm_digital_capture alc880_pcm_digital_capture
  8425. #define ALC861_DIGOUT_NID 0x07
  8426. static struct hda_channel_mode alc861_8ch_modes[1] = {
  8427. { 8, NULL }
  8428. };
  8429. static hda_nid_t alc861_dac_nids[4] = {
  8430. /* front, surround, clfe, side */
  8431. 0x03, 0x06, 0x05, 0x04
  8432. };
  8433. static hda_nid_t alc660_dac_nids[3] = {
  8434. /* front, clfe, surround */
  8435. 0x03, 0x05, 0x06
  8436. };
  8437. static hda_nid_t alc861_adc_nids[1] = {
  8438. /* ADC0-2 */
  8439. 0x08,
  8440. };
  8441. static struct hda_input_mux alc861_capture_source = {
  8442. .num_items = 5,
  8443. .items = {
  8444. { "Mic", 0x0 },
  8445. { "Front Mic", 0x3 },
  8446. { "Line", 0x1 },
  8447. { "CD", 0x4 },
  8448. { "Mixer", 0x5 },
  8449. },
  8450. };
  8451. /* fill in the dac_nids table from the parsed pin configuration */
  8452. static int alc861_auto_fill_dac_nids(struct alc_spec *spec,
  8453. const struct auto_pin_cfg *cfg)
  8454. {
  8455. int i;
  8456. hda_nid_t nid;
  8457. spec->multiout.dac_nids = spec->private_dac_nids;
  8458. for (i = 0; i < cfg->line_outs; i++) {
  8459. nid = cfg->line_out_pins[i];
  8460. if (nid) {
  8461. if (i >= ARRAY_SIZE(alc861_dac_nids))
  8462. continue;
  8463. spec->multiout.dac_nids[i] = alc861_dac_nids[i];
  8464. }
  8465. }
  8466. spec->multiout.num_dacs = cfg->line_outs;
  8467. return 0;
  8468. }
  8469. /* add playback controls from the parsed DAC table */
  8470. static int alc861_auto_create_multi_out_ctls(struct alc_spec *spec,
  8471. const struct auto_pin_cfg *cfg)
  8472. {
  8473. char name[32];
  8474. static const char *chname[4] = {
  8475. "Front", "Surround", NULL /*CLFE*/, "Side"
  8476. };
  8477. hda_nid_t nid;
  8478. int i, idx, err;
  8479. for (i = 0; i < cfg->line_outs; i++) {
  8480. nid = spec->multiout.dac_nids[i];
  8481. if (!nid)
  8482. continue;
  8483. if (nid == 0x05) {
  8484. /* Center/LFE */
  8485. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8486. "Center Playback Switch",
  8487. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  8488. HDA_OUTPUT));
  8489. if (err < 0)
  8490. return err;
  8491. err = add_control(spec, ALC_CTL_BIND_MUTE,
  8492. "LFE Playback Switch",
  8493. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  8494. HDA_OUTPUT));
  8495. if (err < 0)
  8496. return err;
  8497. } else {
  8498. for (idx = 0; idx < ARRAY_SIZE(alc861_dac_nids) - 1;
  8499. idx++)
  8500. if (nid == alc861_dac_nids[idx])
  8501. break;
  8502. sprintf(name, "%s Playback Switch", chname[idx]);
  8503. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  8504. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  8505. HDA_OUTPUT));
  8506. if (err < 0)
  8507. return err;
  8508. }
  8509. }
  8510. return 0;
  8511. }
  8512. static int alc861_auto_create_hp_ctls(struct alc_spec *spec, hda_nid_t pin)
  8513. {
  8514. int err;
  8515. hda_nid_t nid;
  8516. if (!pin)
  8517. return 0;
  8518. if ((pin >= 0x0b && pin <= 0x10) || pin == 0x1f || pin == 0x20) {
  8519. nid = 0x03;
  8520. err = add_control(spec, ALC_CTL_WIDGET_MUTE,
  8521. "Headphone Playback Switch",
  8522. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  8523. if (err < 0)
  8524. return err;
  8525. spec->multiout.hp_nid = nid;
  8526. }
  8527. return 0;
  8528. }
  8529. /* create playback/capture controls for input pins */
  8530. static int alc861_auto_create_analog_input_ctls(struct alc_spec *spec,
  8531. const struct auto_pin_cfg *cfg)
  8532. {
  8533. struct hda_input_mux *imux = &spec->private_imux;
  8534. int i, err, idx, idx1;
  8535. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8536. switch (cfg->input_pins[i]) {
  8537. case 0x0c:
  8538. idx1 = 1;
  8539. idx = 2; /* Line In */
  8540. break;
  8541. case 0x0f:
  8542. idx1 = 2;
  8543. idx = 2; /* Line In */
  8544. break;
  8545. case 0x0d:
  8546. idx1 = 0;
  8547. idx = 1; /* Mic In */
  8548. break;
  8549. case 0x10:
  8550. idx1 = 3;
  8551. idx = 1; /* Mic In */
  8552. break;
  8553. case 0x11:
  8554. idx1 = 4;
  8555. idx = 0; /* CD */
  8556. break;
  8557. default:
  8558. continue;
  8559. }
  8560. err = new_analog_input(spec, cfg->input_pins[i],
  8561. auto_pin_cfg_labels[i], idx, 0x15);
  8562. if (err < 0)
  8563. return err;
  8564. imux->items[imux->num_items].label = auto_pin_cfg_labels[i];
  8565. imux->items[imux->num_items].index = idx1;
  8566. imux->num_items++;
  8567. }
  8568. return 0;
  8569. }
  8570. static struct snd_kcontrol_new alc861_capture_mixer[] = {
  8571. HDA_CODEC_VOLUME("Capture Volume", 0x08, 0x0, HDA_INPUT),
  8572. HDA_CODEC_MUTE("Capture Switch", 0x08, 0x0, HDA_INPUT),
  8573. {
  8574. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8575. /* The multiple "Capture Source" controls confuse alsamixer
  8576. * So call somewhat different..
  8577. *FIXME: the controls appear in the "playback" view!
  8578. */
  8579. /* .name = "Capture Source", */
  8580. .name = "Input Source",
  8581. .count = 1,
  8582. .info = alc_mux_enum_info,
  8583. .get = alc_mux_enum_get,
  8584. .put = alc_mux_enum_put,
  8585. },
  8586. { } /* end */
  8587. };
  8588. static void alc861_auto_set_output_and_unmute(struct hda_codec *codec,
  8589. hda_nid_t nid,
  8590. int pin_type, int dac_idx)
  8591. {
  8592. /* set as output */
  8593. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_PIN_WIDGET_CONTROL,
  8594. pin_type);
  8595. snd_hda_codec_write(codec, dac_idx, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8596. AMP_OUT_UNMUTE);
  8597. }
  8598. static void alc861_auto_init_multi_out(struct hda_codec *codec)
  8599. {
  8600. struct alc_spec *spec = codec->spec;
  8601. int i;
  8602. alc_subsystem_id(codec, 0x0e, 0x0f, 0x0b);
  8603. for (i = 0; i < spec->autocfg.line_outs; i++) {
  8604. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  8605. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  8606. if (nid)
  8607. alc861_auto_set_output_and_unmute(codec, nid, pin_type,
  8608. spec->multiout.dac_nids[i]);
  8609. }
  8610. }
  8611. static void alc861_auto_init_hp_out(struct hda_codec *codec)
  8612. {
  8613. struct alc_spec *spec = codec->spec;
  8614. hda_nid_t pin;
  8615. pin = spec->autocfg.hp_pins[0];
  8616. if (pin) /* connect to front */
  8617. alc861_auto_set_output_and_unmute(codec, pin, PIN_HP,
  8618. spec->multiout.dac_nids[0]);
  8619. }
  8620. static void alc861_auto_init_analog_input(struct hda_codec *codec)
  8621. {
  8622. struct alc_spec *spec = codec->spec;
  8623. int i;
  8624. for (i = 0; i < AUTO_PIN_LAST; i++) {
  8625. hda_nid_t nid = spec->autocfg.input_pins[i];
  8626. if (nid >= 0x0c && nid <= 0x11) {
  8627. snd_hda_codec_write(codec, nid, 0,
  8628. AC_VERB_SET_PIN_WIDGET_CONTROL,
  8629. i <= AUTO_PIN_FRONT_MIC ?
  8630. PIN_VREF80 : PIN_IN);
  8631. }
  8632. }
  8633. }
  8634. /* parse the BIOS configuration and set up the alc_spec */
  8635. /* return 1 if successful, 0 if the proper config is not found,
  8636. * or a negative error code
  8637. */
  8638. static int alc861_parse_auto_config(struct hda_codec *codec)
  8639. {
  8640. struct alc_spec *spec = codec->spec;
  8641. int err;
  8642. static hda_nid_t alc861_ignore[] = { 0x1d, 0 };
  8643. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  8644. alc861_ignore);
  8645. if (err < 0)
  8646. return err;
  8647. if (!spec->autocfg.line_outs)
  8648. return 0; /* can't find valid BIOS pin config */
  8649. err = alc861_auto_fill_dac_nids(spec, &spec->autocfg);
  8650. if (err < 0)
  8651. return err;
  8652. err = alc861_auto_create_multi_out_ctls(spec, &spec->autocfg);
  8653. if (err < 0)
  8654. return err;
  8655. err = alc861_auto_create_hp_ctls(spec, spec->autocfg.hp_pins[0]);
  8656. if (err < 0)
  8657. return err;
  8658. err = alc861_auto_create_analog_input_ctls(spec, &spec->autocfg);
  8659. if (err < 0)
  8660. return err;
  8661. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  8662. if (spec->autocfg.dig_out_pin)
  8663. spec->multiout.dig_out_nid = ALC861_DIGOUT_NID;
  8664. if (spec->kctl_alloc)
  8665. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  8666. spec->init_verbs[spec->num_init_verbs++] = alc861_auto_init_verbs;
  8667. spec->num_mux_defs = 1;
  8668. spec->input_mux = &spec->private_imux;
  8669. spec->adc_nids = alc861_adc_nids;
  8670. spec->num_adc_nids = ARRAY_SIZE(alc861_adc_nids);
  8671. spec->mixers[spec->num_mixers] = alc861_capture_mixer;
  8672. spec->num_mixers++;
  8673. return 1;
  8674. }
  8675. /* additional initialization for auto-configuration model */
  8676. static void alc861_auto_init(struct hda_codec *codec)
  8677. {
  8678. alc861_auto_init_multi_out(codec);
  8679. alc861_auto_init_hp_out(codec);
  8680. alc861_auto_init_analog_input(codec);
  8681. }
  8682. /*
  8683. * configuration and preset
  8684. */
  8685. static const char *alc861_models[ALC861_MODEL_LAST] = {
  8686. [ALC861_3ST] = "3stack",
  8687. [ALC660_3ST] = "3stack-660",
  8688. [ALC861_3ST_DIG] = "3stack-dig",
  8689. [ALC861_6ST_DIG] = "6stack-dig",
  8690. [ALC861_UNIWILL_M31] = "uniwill-m31",
  8691. [ALC861_TOSHIBA] = "toshiba",
  8692. [ALC861_ASUS] = "asus",
  8693. [ALC861_ASUS_LAPTOP] = "asus-laptop",
  8694. [ALC861_AUTO] = "auto",
  8695. };
  8696. static struct snd_pci_quirk alc861_cfg_tbl[] = {
  8697. SND_PCI_QUIRK(0x1043, 0x1205, "ASUS W7J", ALC861_3ST),
  8698. SND_PCI_QUIRK(0x1043, 0x1335, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8699. SND_PCI_QUIRK(0x1043, 0x1338, "ASUS F2/3", ALC861_ASUS_LAPTOP),
  8700. SND_PCI_QUIRK(0x1043, 0x13d7, "ASUS A9rp", ALC861_ASUS_LAPTOP),
  8701. SND_PCI_QUIRK(0x1584, 0x9075, "Airis Praxis N1212", ALC861_ASUS_LAPTOP),
  8702. SND_PCI_QUIRK(0x1043, 0x1393, "ASUS", ALC861_ASUS),
  8703. SND_PCI_QUIRK(0x1043, 0x81cb, "ASUS P1-AH2", ALC861_3ST_DIG),
  8704. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba", ALC861_TOSHIBA),
  8705. /* FIXME: the entry below breaks Toshiba A100 (model=auto works!)
  8706. * Any other models that need this preset?
  8707. */
  8708. /* SND_PCI_QUIRK(0x1179, 0xff10, "Toshiba", ALC861_TOSHIBA), */
  8709. SND_PCI_QUIRK(0x1584, 0x9072, "Uniwill m31", ALC861_UNIWILL_M31),
  8710. SND_PCI_QUIRK(0x1584, 0x9075, "Uniwill", ALC861_UNIWILL_M31),
  8711. SND_PCI_QUIRK(0x1584, 0x2b01, "Uniwill X40AIx", ALC861_UNIWILL_M31),
  8712. SND_PCI_QUIRK(0x1849, 0x0660, "Asrock 939SLI32", ALC660_3ST),
  8713. SND_PCI_QUIRK(0x8086, 0xd600, "Intel", ALC861_3ST),
  8714. SND_PCI_QUIRK(0x1462, 0x7254, "HP dx2200 (MSI MS-7254)", ALC861_3ST),
  8715. SND_PCI_QUIRK(0x1462, 0x7297, "HP dx2250 (MSI MS-7297)", ALC861_3ST),
  8716. {}
  8717. };
  8718. static struct alc_config_preset alc861_presets[] = {
  8719. [ALC861_3ST] = {
  8720. .mixers = { alc861_3ST_mixer },
  8721. .init_verbs = { alc861_threestack_init_verbs },
  8722. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8723. .dac_nids = alc861_dac_nids,
  8724. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8725. .channel_mode = alc861_threestack_modes,
  8726. .need_dac_fix = 1,
  8727. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8728. .adc_nids = alc861_adc_nids,
  8729. .input_mux = &alc861_capture_source,
  8730. },
  8731. [ALC861_3ST_DIG] = {
  8732. .mixers = { alc861_base_mixer },
  8733. .init_verbs = { alc861_threestack_init_verbs },
  8734. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8735. .dac_nids = alc861_dac_nids,
  8736. .dig_out_nid = ALC861_DIGOUT_NID,
  8737. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8738. .channel_mode = alc861_threestack_modes,
  8739. .need_dac_fix = 1,
  8740. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8741. .adc_nids = alc861_adc_nids,
  8742. .input_mux = &alc861_capture_source,
  8743. },
  8744. [ALC861_6ST_DIG] = {
  8745. .mixers = { alc861_base_mixer },
  8746. .init_verbs = { alc861_base_init_verbs },
  8747. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8748. .dac_nids = alc861_dac_nids,
  8749. .dig_out_nid = ALC861_DIGOUT_NID,
  8750. .num_channel_mode = ARRAY_SIZE(alc861_8ch_modes),
  8751. .channel_mode = alc861_8ch_modes,
  8752. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8753. .adc_nids = alc861_adc_nids,
  8754. .input_mux = &alc861_capture_source,
  8755. },
  8756. [ALC660_3ST] = {
  8757. .mixers = { alc861_3ST_mixer },
  8758. .init_verbs = { alc861_threestack_init_verbs },
  8759. .num_dacs = ARRAY_SIZE(alc660_dac_nids),
  8760. .dac_nids = alc660_dac_nids,
  8761. .num_channel_mode = ARRAY_SIZE(alc861_threestack_modes),
  8762. .channel_mode = alc861_threestack_modes,
  8763. .need_dac_fix = 1,
  8764. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8765. .adc_nids = alc861_adc_nids,
  8766. .input_mux = &alc861_capture_source,
  8767. },
  8768. [ALC861_UNIWILL_M31] = {
  8769. .mixers = { alc861_uniwill_m31_mixer },
  8770. .init_verbs = { alc861_uniwill_m31_init_verbs },
  8771. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8772. .dac_nids = alc861_dac_nids,
  8773. .dig_out_nid = ALC861_DIGOUT_NID,
  8774. .num_channel_mode = ARRAY_SIZE(alc861_uniwill_m31_modes),
  8775. .channel_mode = alc861_uniwill_m31_modes,
  8776. .need_dac_fix = 1,
  8777. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8778. .adc_nids = alc861_adc_nids,
  8779. .input_mux = &alc861_capture_source,
  8780. },
  8781. [ALC861_TOSHIBA] = {
  8782. .mixers = { alc861_toshiba_mixer },
  8783. .init_verbs = { alc861_base_init_verbs,
  8784. alc861_toshiba_init_verbs },
  8785. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8786. .dac_nids = alc861_dac_nids,
  8787. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8788. .channel_mode = alc883_3ST_2ch_modes,
  8789. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8790. .adc_nids = alc861_adc_nids,
  8791. .input_mux = &alc861_capture_source,
  8792. .unsol_event = alc861_toshiba_unsol_event,
  8793. .init_hook = alc861_toshiba_automute,
  8794. },
  8795. [ALC861_ASUS] = {
  8796. .mixers = { alc861_asus_mixer },
  8797. .init_verbs = { alc861_asus_init_verbs },
  8798. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8799. .dac_nids = alc861_dac_nids,
  8800. .dig_out_nid = ALC861_DIGOUT_NID,
  8801. .num_channel_mode = ARRAY_SIZE(alc861_asus_modes),
  8802. .channel_mode = alc861_asus_modes,
  8803. .need_dac_fix = 1,
  8804. .hp_nid = 0x06,
  8805. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8806. .adc_nids = alc861_adc_nids,
  8807. .input_mux = &alc861_capture_source,
  8808. },
  8809. [ALC861_ASUS_LAPTOP] = {
  8810. .mixers = { alc861_toshiba_mixer, alc861_asus_laptop_mixer },
  8811. .init_verbs = { alc861_asus_init_verbs,
  8812. alc861_asus_laptop_init_verbs },
  8813. .num_dacs = ARRAY_SIZE(alc861_dac_nids),
  8814. .dac_nids = alc861_dac_nids,
  8815. .dig_out_nid = ALC861_DIGOUT_NID,
  8816. .num_channel_mode = ARRAY_SIZE(alc883_3ST_2ch_modes),
  8817. .channel_mode = alc883_3ST_2ch_modes,
  8818. .need_dac_fix = 1,
  8819. .num_adc_nids = ARRAY_SIZE(alc861_adc_nids),
  8820. .adc_nids = alc861_adc_nids,
  8821. .input_mux = &alc861_capture_source,
  8822. },
  8823. };
  8824. static int patch_alc861(struct hda_codec *codec)
  8825. {
  8826. struct alc_spec *spec;
  8827. int board_config;
  8828. int err;
  8829. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  8830. if (spec == NULL)
  8831. return -ENOMEM;
  8832. codec->spec = spec;
  8833. board_config = snd_hda_check_board_config(codec, ALC861_MODEL_LAST,
  8834. alc861_models,
  8835. alc861_cfg_tbl);
  8836. if (board_config < 0) {
  8837. printk(KERN_INFO "hda_codec: Unknown model for ALC861, "
  8838. "trying auto-probe from BIOS...\n");
  8839. board_config = ALC861_AUTO;
  8840. }
  8841. if (board_config == ALC861_AUTO) {
  8842. /* automatic parse from the BIOS config */
  8843. err = alc861_parse_auto_config(codec);
  8844. if (err < 0) {
  8845. alc_free(codec);
  8846. return err;
  8847. } else if (!err) {
  8848. printk(KERN_INFO
  8849. "hda_codec: Cannot set up configuration "
  8850. "from BIOS. Using base mode...\n");
  8851. board_config = ALC861_3ST_DIG;
  8852. }
  8853. }
  8854. if (board_config != ALC861_AUTO)
  8855. setup_preset(spec, &alc861_presets[board_config]);
  8856. spec->stream_name_analog = "ALC861 Analog";
  8857. spec->stream_analog_playback = &alc861_pcm_analog_playback;
  8858. spec->stream_analog_capture = &alc861_pcm_analog_capture;
  8859. spec->stream_name_digital = "ALC861 Digital";
  8860. spec->stream_digital_playback = &alc861_pcm_digital_playback;
  8861. spec->stream_digital_capture = &alc861_pcm_digital_capture;
  8862. codec->patch_ops = alc_patch_ops;
  8863. if (board_config == ALC861_AUTO)
  8864. spec->init_hook = alc861_auto_init;
  8865. return 0;
  8866. }
  8867. /*
  8868. * ALC861-VD support
  8869. *
  8870. * Based on ALC882
  8871. *
  8872. * In addition, an independent DAC
  8873. */
  8874. #define ALC861VD_DIGOUT_NID 0x06
  8875. static hda_nid_t alc861vd_dac_nids[4] = {
  8876. /* front, surr, clfe, side surr */
  8877. 0x02, 0x03, 0x04, 0x05
  8878. };
  8879. /* dac_nids for ALC660vd are in a different order - according to
  8880. * Realtek's driver.
  8881. * This should probably tesult in a different mixer for 6stack models
  8882. * of ALC660vd codecs, but for now there is only 3stack mixer
  8883. * - and it is the same as in 861vd.
  8884. * adc_nids in ALC660vd are (is) the same as in 861vd
  8885. */
  8886. static hda_nid_t alc660vd_dac_nids[3] = {
  8887. /* front, rear, clfe, rear_surr */
  8888. 0x02, 0x04, 0x03
  8889. };
  8890. static hda_nid_t alc861vd_adc_nids[1] = {
  8891. /* ADC0 */
  8892. 0x09,
  8893. };
  8894. /* input MUX */
  8895. /* FIXME: should be a matrix-type input source selection */
  8896. static struct hda_input_mux alc861vd_capture_source = {
  8897. .num_items = 4,
  8898. .items = {
  8899. { "Mic", 0x0 },
  8900. { "Front Mic", 0x1 },
  8901. { "Line", 0x2 },
  8902. { "CD", 0x4 },
  8903. },
  8904. };
  8905. static struct hda_input_mux alc861vd_dallas_capture_source = {
  8906. .num_items = 3,
  8907. .items = {
  8908. { "Front Mic", 0x0 },
  8909. { "ATAPI Mic", 0x1 },
  8910. { "Line In", 0x5 },
  8911. },
  8912. };
  8913. #define alc861vd_mux_enum_info alc_mux_enum_info
  8914. #define alc861vd_mux_enum_get alc_mux_enum_get
  8915. static int alc861vd_mux_enum_put(struct snd_kcontrol *kcontrol,
  8916. struct snd_ctl_elem_value *ucontrol)
  8917. {
  8918. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  8919. struct alc_spec *spec = codec->spec;
  8920. const struct hda_input_mux *imux = spec->input_mux;
  8921. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  8922. static hda_nid_t capture_mixers[1] = { 0x22 };
  8923. hda_nid_t nid = capture_mixers[adc_idx];
  8924. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  8925. unsigned int i, idx;
  8926. idx = ucontrol->value.enumerated.item[0];
  8927. if (idx >= imux->num_items)
  8928. idx = imux->num_items - 1;
  8929. if (*cur_val == idx && !codec->in_resume)
  8930. return 0;
  8931. for (i = 0; i < imux->num_items; i++) {
  8932. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  8933. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  8934. v | (imux->items[i].index << 8));
  8935. }
  8936. *cur_val = idx;
  8937. return 1;
  8938. }
  8939. /*
  8940. * 2ch mode
  8941. */
  8942. static struct hda_channel_mode alc861vd_3stack_2ch_modes[1] = {
  8943. { 2, NULL }
  8944. };
  8945. /*
  8946. * 6ch mode
  8947. */
  8948. static struct hda_verb alc861vd_6stack_ch6_init[] = {
  8949. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  8950. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8951. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8952. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8953. { } /* end */
  8954. };
  8955. /*
  8956. * 8ch mode
  8957. */
  8958. static struct hda_verb alc861vd_6stack_ch8_init[] = {
  8959. { 0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8960. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8961. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8962. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  8963. { } /* end */
  8964. };
  8965. static struct hda_channel_mode alc861vd_6stack_modes[2] = {
  8966. { 6, alc861vd_6stack_ch6_init },
  8967. { 8, alc861vd_6stack_ch8_init },
  8968. };
  8969. static struct snd_kcontrol_new alc861vd_chmode_mixer[] = {
  8970. {
  8971. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8972. .name = "Channel Mode",
  8973. .info = alc_ch_mode_info,
  8974. .get = alc_ch_mode_get,
  8975. .put = alc_ch_mode_put,
  8976. },
  8977. { } /* end */
  8978. };
  8979. static struct snd_kcontrol_new alc861vd_capture_mixer[] = {
  8980. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  8981. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  8982. {
  8983. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  8984. /* The multiple "Capture Source" controls confuse alsamixer
  8985. * So call somewhat different..
  8986. *FIXME: the controls appear in the "playback" view!
  8987. */
  8988. /* .name = "Capture Source", */
  8989. .name = "Input Source",
  8990. .count = 1,
  8991. .info = alc861vd_mux_enum_info,
  8992. .get = alc861vd_mux_enum_get,
  8993. .put = alc861vd_mux_enum_put,
  8994. },
  8995. { } /* end */
  8996. };
  8997. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  8998. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  8999. */
  9000. static struct snd_kcontrol_new alc861vd_6st_mixer[] = {
  9001. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9002. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9003. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9004. HDA_BIND_MUTE("Surround Playback Switch", 0x0d, 2, HDA_INPUT),
  9005. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0,
  9006. HDA_OUTPUT),
  9007. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0,
  9008. HDA_OUTPUT),
  9009. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x0e, 1, 2, HDA_INPUT),
  9010. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x0e, 2, 2, HDA_INPUT),
  9011. HDA_CODEC_VOLUME("Side Playback Volume", 0x05, 0x0, HDA_OUTPUT),
  9012. HDA_BIND_MUTE("Side Playback Switch", 0x0f, 2, HDA_INPUT),
  9013. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9014. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9015. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9016. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9017. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9018. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9019. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9020. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9021. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9022. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9023. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9024. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9025. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9026. { } /* end */
  9027. };
  9028. static struct snd_kcontrol_new alc861vd_3st_mixer[] = {
  9029. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9030. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9031. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9032. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9033. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9034. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9035. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9036. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9037. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9038. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9039. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9040. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9041. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9042. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9043. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9044. { } /* end */
  9045. };
  9046. static struct snd_kcontrol_new alc861vd_lenovo_mixer[] = {
  9047. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9048. /*HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),*/
  9049. HDA_CODEC_MUTE("Front Playback Switch", 0x14, 0x0, HDA_OUTPUT),
  9050. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9051. HDA_CODEC_VOLUME("Mic Boost", 0x18, 0, HDA_INPUT),
  9052. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9053. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9054. HDA_CODEC_VOLUME("Front Mic Boost", 0x19, 0, HDA_INPUT),
  9055. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9056. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9057. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9058. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9059. { } /* end */
  9060. };
  9061. /* Pin assignment: Front=0x14, HP = 0x15,
  9062. * Front Mic=0x18, ATAPI Mic = 0x19, Line In = 0x1d
  9063. */
  9064. static struct snd_kcontrol_new alc861vd_dallas_mixer[] = {
  9065. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9066. HDA_BIND_MUTE("Front Playback Switch", 0x0c, 2, HDA_INPUT),
  9067. HDA_CODEC_VOLUME("Headphone Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9068. HDA_BIND_MUTE("Headphone Playback Switch", 0x0d, 2, HDA_INPUT),
  9069. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9070. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9071. HDA_CODEC_VOLUME("ATAPI Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9072. HDA_CODEC_MUTE("ATAPI Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9073. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9074. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9075. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9076. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9077. {
  9078. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9079. /* .name = "Capture Source", */
  9080. .name = "Input Source",
  9081. .count = 1,
  9082. .info = alc882_mux_enum_info,
  9083. .get = alc882_mux_enum_get,
  9084. .put = alc882_mux_enum_put,
  9085. },
  9086. { } /* end */
  9087. };
  9088. /*
  9089. * generic initialization of ADC, input mixers and output mixers
  9090. */
  9091. static struct hda_verb alc861vd_volume_init_verbs[] = {
  9092. /*
  9093. * Unmute ADC0 and set the default input to mic-in
  9094. */
  9095. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9096. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9097. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of
  9098. * the analog-loopback mixer widget
  9099. */
  9100. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  9101. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9102. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9103. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9104. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9105. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9106. /* Capture mixer: unmute Mic, F-Mic, Line, CD inputs */
  9107. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9108. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9109. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9110. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9111. /*
  9112. * Set up output mixers (0x02 - 0x05)
  9113. */
  9114. /* set vol=0 to output mixers */
  9115. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9116. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9117. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9118. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9119. /* set up input amps for analog loopback */
  9120. /* Amp Indices: DAC = 0, mixer = 1 */
  9121. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9122. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9123. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9124. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9125. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9126. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9127. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9128. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9129. { }
  9130. };
  9131. /*
  9132. * 3-stack pin configuration:
  9133. * front = 0x14, mic/clfe = 0x18, HP = 0x19, line/surr = 0x1a, f-mic = 0x1b
  9134. */
  9135. static struct hda_verb alc861vd_3stack_init_verbs[] = {
  9136. /*
  9137. * Set pin mode and muting
  9138. */
  9139. /* set front pin widgets 0x14 for output */
  9140. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9141. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9142. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9143. /* Mic (rear) pin: input vref at 80% */
  9144. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9145. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9146. /* Front Mic pin: input vref at 80% */
  9147. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9148. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9149. /* Line In pin: input */
  9150. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9151. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9152. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9153. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9154. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9155. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9156. /* CD pin widget for input */
  9157. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9158. { }
  9159. };
  9160. /*
  9161. * 6-stack pin configuration:
  9162. */
  9163. static struct hda_verb alc861vd_6stack_init_verbs[] = {
  9164. /*
  9165. * Set pin mode and muting
  9166. */
  9167. /* set front pin widgets 0x14 for output */
  9168. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9169. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9170. {0x14, AC_VERB_SET_CONNECT_SEL, 0x00},
  9171. /* Rear Pin: output 1 (0x0d) */
  9172. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9173. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9174. {0x15, AC_VERB_SET_CONNECT_SEL, 0x01},
  9175. /* CLFE Pin: output 2 (0x0e) */
  9176. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9177. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9178. {0x16, AC_VERB_SET_CONNECT_SEL, 0x02},
  9179. /* Side Pin: output 3 (0x0f) */
  9180. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9181. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9182. {0x17, AC_VERB_SET_CONNECT_SEL, 0x03},
  9183. /* Mic (rear) pin: input vref at 80% */
  9184. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9185. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9186. /* Front Mic pin: input vref at 80% */
  9187. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9188. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9189. /* Line In pin: input */
  9190. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9191. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9192. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9193. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9194. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9195. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9196. /* CD pin widget for input */
  9197. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9198. { }
  9199. };
  9200. static struct hda_verb alc861vd_eapd_verbs[] = {
  9201. {0x14, AC_VERB_SET_EAPD_BTLENABLE, 2},
  9202. { }
  9203. };
  9204. static struct hda_verb alc861vd_lenovo_unsol_verbs[] = {
  9205. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9206. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9207. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(5)},
  9208. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9209. {0x18, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_MIC_EVENT},
  9210. {}
  9211. };
  9212. /* toggle speaker-output according to the hp-jack state */
  9213. static void alc861vd_lenovo_hp_automute(struct hda_codec *codec)
  9214. {
  9215. unsigned int present;
  9216. unsigned char bits;
  9217. present = snd_hda_codec_read(codec, 0x1b, 0,
  9218. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9219. bits = present ? 0x80 : 0;
  9220. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9221. 0x80, bits);
  9222. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9223. 0x80, bits);
  9224. }
  9225. static void alc861vd_lenovo_mic_automute(struct hda_codec *codec)
  9226. {
  9227. unsigned int present;
  9228. unsigned char bits;
  9229. present = snd_hda_codec_read(codec, 0x18, 0,
  9230. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9231. bits = present ? 0x80 : 0;
  9232. snd_hda_codec_amp_update(codec, 0x0b, 0, HDA_INPUT, 1,
  9233. 0x80, bits);
  9234. snd_hda_codec_amp_update(codec, 0x0b, 1, HDA_INPUT, 1,
  9235. 0x80, bits);
  9236. }
  9237. static void alc861vd_lenovo_automute(struct hda_codec *codec)
  9238. {
  9239. alc861vd_lenovo_hp_automute(codec);
  9240. alc861vd_lenovo_mic_automute(codec);
  9241. }
  9242. static void alc861vd_lenovo_unsol_event(struct hda_codec *codec,
  9243. unsigned int res)
  9244. {
  9245. switch (res >> 26) {
  9246. case ALC880_HP_EVENT:
  9247. alc861vd_lenovo_hp_automute(codec);
  9248. break;
  9249. case ALC880_MIC_EVENT:
  9250. alc861vd_lenovo_mic_automute(codec);
  9251. break;
  9252. }
  9253. }
  9254. static struct hda_verb alc861vd_dallas_verbs[] = {
  9255. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9256. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9257. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9258. {0x05, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  9259. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9260. {0x0c, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9261. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9262. {0x0d, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9263. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9264. {0x0e, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9265. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9266. {0x0f, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(1)},
  9267. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9268. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9269. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9270. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9271. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9272. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9273. {0x17, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9274. {0x17, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9275. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9276. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9277. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF50},
  9278. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9279. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9280. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9281. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9282. {0x1d, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9283. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9284. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(3)},
  9285. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(2)},
  9286. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(4)},
  9287. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9288. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9289. {0x15, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN | ALC880_HP_EVENT},
  9290. { } /* end */
  9291. };
  9292. /* toggle speaker-output according to the hp-jack state */
  9293. static void alc861vd_dallas_automute(struct hda_codec *codec)
  9294. {
  9295. unsigned int present;
  9296. present = snd_hda_codec_read(codec, 0x15, 0,
  9297. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  9298. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  9299. 0x80, present ? 0x80 : 0);
  9300. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  9301. 0x80, present ? 0x80 : 0);
  9302. }
  9303. static void alc861vd_dallas_unsol_event(struct hda_codec *codec, unsigned int res)
  9304. {
  9305. if ((res >> 26) == ALC880_HP_EVENT)
  9306. alc861vd_dallas_automute(codec);
  9307. }
  9308. /* pcm configuration: identiacal with ALC880 */
  9309. #define alc861vd_pcm_analog_playback alc880_pcm_analog_playback
  9310. #define alc861vd_pcm_analog_capture alc880_pcm_analog_capture
  9311. #define alc861vd_pcm_digital_playback alc880_pcm_digital_playback
  9312. #define alc861vd_pcm_digital_capture alc880_pcm_digital_capture
  9313. /*
  9314. * configuration and preset
  9315. */
  9316. static const char *alc861vd_models[ALC861VD_MODEL_LAST] = {
  9317. [ALC660VD_3ST] = "3stack-660",
  9318. [ALC660VD_3ST_DIG]= "3stack-660-digout",
  9319. [ALC861VD_3ST] = "3stack",
  9320. [ALC861VD_3ST_DIG] = "3stack-digout",
  9321. [ALC861VD_6ST_DIG] = "6stack-digout",
  9322. [ALC861VD_LENOVO] = "lenovo",
  9323. [ALC861VD_DALLAS] = "dallas",
  9324. [ALC861VD_AUTO] = "auto",
  9325. };
  9326. static struct snd_pci_quirk alc861vd_cfg_tbl[] = {
  9327. SND_PCI_QUIRK(0x1043, 0x12e2, "Asus z35m", ALC660VD_3ST),
  9328. SND_PCI_QUIRK(0x1043, 0x1339, "Asus G1", ALC660VD_3ST),
  9329. SND_PCI_QUIRK(0x1043, 0x81e7, "ASUS", ALC660VD_3ST_DIG),
  9330. SND_PCI_QUIRK(0x10de, 0x03f0, "Realtek ALC660 demo", ALC660VD_3ST),
  9331. SND_PCI_QUIRK(0x1019, 0xa88d, "Realtek ALC660 demo", ALC660VD_3ST),
  9332. SND_PCI_QUIRK(0x1179, 0xff00, "DALLAS", ALC861VD_DALLAS),
  9333. SND_PCI_QUIRK(0x1179, 0xff01, "DALLAS", ALC861VD_DALLAS),
  9334. SND_PCI_QUIRK(0x17aa, 0x3802, "Lenovo 3000 C200", ALC861VD_LENOVO),
  9335. SND_PCI_QUIRK(0x17aa, 0x2066, "Lenovo", ALC861VD_LENOVO),
  9336. SND_PCI_QUIRK(0x1179, 0xff00, "Toshiba A135", ALC861VD_LENOVO),
  9337. {}
  9338. };
  9339. static struct alc_config_preset alc861vd_presets[] = {
  9340. [ALC660VD_3ST] = {
  9341. .mixers = { alc861vd_3st_mixer },
  9342. .init_verbs = { alc861vd_volume_init_verbs,
  9343. alc861vd_3stack_init_verbs },
  9344. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9345. .dac_nids = alc660vd_dac_nids,
  9346. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9347. .adc_nids = alc861vd_adc_nids,
  9348. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9349. .channel_mode = alc861vd_3stack_2ch_modes,
  9350. .input_mux = &alc861vd_capture_source,
  9351. },
  9352. [ALC660VD_3ST_DIG] = {
  9353. .mixers = { alc861vd_3st_mixer },
  9354. .init_verbs = { alc861vd_volume_init_verbs,
  9355. alc861vd_3stack_init_verbs },
  9356. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9357. .dac_nids = alc660vd_dac_nids,
  9358. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9359. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9360. .adc_nids = alc861vd_adc_nids,
  9361. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9362. .channel_mode = alc861vd_3stack_2ch_modes,
  9363. .input_mux = &alc861vd_capture_source,
  9364. },
  9365. [ALC861VD_3ST] = {
  9366. .mixers = { alc861vd_3st_mixer },
  9367. .init_verbs = { alc861vd_volume_init_verbs,
  9368. alc861vd_3stack_init_verbs },
  9369. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9370. .dac_nids = alc861vd_dac_nids,
  9371. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9372. .channel_mode = alc861vd_3stack_2ch_modes,
  9373. .input_mux = &alc861vd_capture_source,
  9374. },
  9375. [ALC861VD_3ST_DIG] = {
  9376. .mixers = { alc861vd_3st_mixer },
  9377. .init_verbs = { alc861vd_volume_init_verbs,
  9378. alc861vd_3stack_init_verbs },
  9379. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9380. .dac_nids = alc861vd_dac_nids,
  9381. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9382. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9383. .channel_mode = alc861vd_3stack_2ch_modes,
  9384. .input_mux = &alc861vd_capture_source,
  9385. },
  9386. [ALC861VD_6ST_DIG] = {
  9387. .mixers = { alc861vd_6st_mixer, alc861vd_chmode_mixer },
  9388. .init_verbs = { alc861vd_volume_init_verbs,
  9389. alc861vd_6stack_init_verbs },
  9390. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9391. .dac_nids = alc861vd_dac_nids,
  9392. .dig_out_nid = ALC861VD_DIGOUT_NID,
  9393. .num_channel_mode = ARRAY_SIZE(alc861vd_6stack_modes),
  9394. .channel_mode = alc861vd_6stack_modes,
  9395. .input_mux = &alc861vd_capture_source,
  9396. },
  9397. [ALC861VD_LENOVO] = {
  9398. .mixers = { alc861vd_lenovo_mixer },
  9399. .init_verbs = { alc861vd_volume_init_verbs,
  9400. alc861vd_3stack_init_verbs,
  9401. alc861vd_eapd_verbs,
  9402. alc861vd_lenovo_unsol_verbs },
  9403. .num_dacs = ARRAY_SIZE(alc660vd_dac_nids),
  9404. .dac_nids = alc660vd_dac_nids,
  9405. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9406. .adc_nids = alc861vd_adc_nids,
  9407. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9408. .channel_mode = alc861vd_3stack_2ch_modes,
  9409. .input_mux = &alc861vd_capture_source,
  9410. .unsol_event = alc861vd_lenovo_unsol_event,
  9411. .init_hook = alc861vd_lenovo_automute,
  9412. },
  9413. [ALC861VD_DALLAS] = {
  9414. .mixers = { alc861vd_dallas_mixer },
  9415. .init_verbs = { alc861vd_dallas_verbs },
  9416. .num_dacs = ARRAY_SIZE(alc861vd_dac_nids),
  9417. .dac_nids = alc861vd_dac_nids,
  9418. .num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids),
  9419. .adc_nids = alc861vd_adc_nids,
  9420. .num_channel_mode = ARRAY_SIZE(alc861vd_3stack_2ch_modes),
  9421. .channel_mode = alc861vd_3stack_2ch_modes,
  9422. .input_mux = &alc861vd_dallas_capture_source,
  9423. .unsol_event = alc861vd_dallas_unsol_event,
  9424. .init_hook = alc861vd_dallas_automute,
  9425. },
  9426. };
  9427. /*
  9428. * BIOS auto configuration
  9429. */
  9430. static void alc861vd_auto_set_output_and_unmute(struct hda_codec *codec,
  9431. hda_nid_t nid, int pin_type, int dac_idx)
  9432. {
  9433. /* set as output */
  9434. snd_hda_codec_write(codec, nid, 0,
  9435. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  9436. snd_hda_codec_write(codec, nid, 0,
  9437. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  9438. }
  9439. static void alc861vd_auto_init_multi_out(struct hda_codec *codec)
  9440. {
  9441. struct alc_spec *spec = codec->spec;
  9442. int i;
  9443. alc_subsystem_id(codec, 0x15, 0x1b, 0x14);
  9444. for (i = 0; i <= HDA_SIDE; i++) {
  9445. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  9446. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  9447. if (nid)
  9448. alc861vd_auto_set_output_and_unmute(codec, nid,
  9449. pin_type, i);
  9450. }
  9451. }
  9452. static void alc861vd_auto_init_hp_out(struct hda_codec *codec)
  9453. {
  9454. struct alc_spec *spec = codec->spec;
  9455. hda_nid_t pin;
  9456. pin = spec->autocfg.hp_pins[0];
  9457. if (pin) /* connect to front and use dac 0 */
  9458. alc861vd_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  9459. }
  9460. #define alc861vd_is_input_pin(nid) alc880_is_input_pin(nid)
  9461. #define ALC861VD_PIN_CD_NID ALC880_PIN_CD_NID
  9462. static void alc861vd_auto_init_analog_input(struct hda_codec *codec)
  9463. {
  9464. struct alc_spec *spec = codec->spec;
  9465. int i;
  9466. for (i = 0; i < AUTO_PIN_LAST; i++) {
  9467. hda_nid_t nid = spec->autocfg.input_pins[i];
  9468. if (alc861vd_is_input_pin(nid)) {
  9469. snd_hda_codec_write(codec, nid, 0,
  9470. AC_VERB_SET_PIN_WIDGET_CONTROL,
  9471. i <= AUTO_PIN_FRONT_MIC ?
  9472. PIN_VREF80 : PIN_IN);
  9473. if (nid != ALC861VD_PIN_CD_NID)
  9474. snd_hda_codec_write(codec, nid, 0,
  9475. AC_VERB_SET_AMP_GAIN_MUTE,
  9476. AMP_OUT_MUTE);
  9477. }
  9478. }
  9479. }
  9480. #define alc861vd_idx_to_mixer_vol(nid) ((nid) + 0x02)
  9481. #define alc861vd_idx_to_mixer_switch(nid) ((nid) + 0x0c)
  9482. /* add playback controls from the parsed DAC table */
  9483. /* Based on ALC880 version. But ALC861VD has separate,
  9484. * different NIDs for mute/unmute switch and volume control */
  9485. static int alc861vd_auto_create_multi_out_ctls(struct alc_spec *spec,
  9486. const struct auto_pin_cfg *cfg)
  9487. {
  9488. char name[32];
  9489. static const char *chname[4] = {"Front", "Surround", "CLFE", "Side"};
  9490. hda_nid_t nid_v, nid_s;
  9491. int i, err;
  9492. for (i = 0; i < cfg->line_outs; i++) {
  9493. if (!spec->multiout.dac_nids[i])
  9494. continue;
  9495. nid_v = alc861vd_idx_to_mixer_vol(
  9496. alc880_dac_to_idx(
  9497. spec->multiout.dac_nids[i]));
  9498. nid_s = alc861vd_idx_to_mixer_switch(
  9499. alc880_dac_to_idx(
  9500. spec->multiout.dac_nids[i]));
  9501. if (i == 2) {
  9502. /* Center/LFE */
  9503. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9504. "Center Playback Volume",
  9505. HDA_COMPOSE_AMP_VAL(nid_v, 1, 0,
  9506. HDA_OUTPUT));
  9507. if (err < 0)
  9508. return err;
  9509. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  9510. "LFE Playback Volume",
  9511. HDA_COMPOSE_AMP_VAL(nid_v, 2, 0,
  9512. HDA_OUTPUT));
  9513. if (err < 0)
  9514. return err;
  9515. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9516. "Center Playback Switch",
  9517. HDA_COMPOSE_AMP_VAL(nid_s, 1, 2,
  9518. HDA_INPUT));
  9519. if (err < 0)
  9520. return err;
  9521. err = add_control(spec, ALC_CTL_BIND_MUTE,
  9522. "LFE Playback Switch",
  9523. HDA_COMPOSE_AMP_VAL(nid_s, 2, 2,
  9524. HDA_INPUT));
  9525. if (err < 0)
  9526. return err;
  9527. } else {
  9528. sprintf(name, "%s Playback Volume", chname[i]);
  9529. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9530. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0,
  9531. HDA_OUTPUT));
  9532. if (err < 0)
  9533. return err;
  9534. sprintf(name, "%s Playback Switch", chname[i]);
  9535. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9536. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2,
  9537. HDA_INPUT));
  9538. if (err < 0)
  9539. return err;
  9540. }
  9541. }
  9542. return 0;
  9543. }
  9544. /* add playback controls for speaker and HP outputs */
  9545. /* Based on ALC880 version. But ALC861VD has separate,
  9546. * different NIDs for mute/unmute switch and volume control */
  9547. static int alc861vd_auto_create_extra_out(struct alc_spec *spec,
  9548. hda_nid_t pin, const char *pfx)
  9549. {
  9550. hda_nid_t nid_v, nid_s;
  9551. int err;
  9552. char name[32];
  9553. if (!pin)
  9554. return 0;
  9555. if (alc880_is_fixed_pin(pin)) {
  9556. nid_v = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  9557. /* specify the DAC as the extra output */
  9558. if (!spec->multiout.hp_nid)
  9559. spec->multiout.hp_nid = nid_v;
  9560. else
  9561. spec->multiout.extra_out_nid[0] = nid_v;
  9562. /* control HP volume/switch on the output mixer amp */
  9563. nid_v = alc861vd_idx_to_mixer_vol(
  9564. alc880_fixed_pin_idx(pin));
  9565. nid_s = alc861vd_idx_to_mixer_switch(
  9566. alc880_fixed_pin_idx(pin));
  9567. sprintf(name, "%s Playback Volume", pfx);
  9568. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  9569. HDA_COMPOSE_AMP_VAL(nid_v, 3, 0, HDA_OUTPUT));
  9570. if (err < 0)
  9571. return err;
  9572. sprintf(name, "%s Playback Switch", pfx);
  9573. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  9574. HDA_COMPOSE_AMP_VAL(nid_s, 3, 2, HDA_INPUT));
  9575. if (err < 0)
  9576. return err;
  9577. } else if (alc880_is_multi_pin(pin)) {
  9578. /* set manual connection */
  9579. /* we have only a switch on HP-out PIN */
  9580. sprintf(name, "%s Playback Switch", pfx);
  9581. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  9582. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  9583. if (err < 0)
  9584. return err;
  9585. }
  9586. return 0;
  9587. }
  9588. /* parse the BIOS configuration and set up the alc_spec
  9589. * return 1 if successful, 0 if the proper config is not found,
  9590. * or a negative error code
  9591. * Based on ALC880 version - had to change it to override
  9592. * alc880_auto_create_extra_out and alc880_auto_create_multi_out_ctls */
  9593. static int alc861vd_parse_auto_config(struct hda_codec *codec)
  9594. {
  9595. struct alc_spec *spec = codec->spec;
  9596. int err;
  9597. static hda_nid_t alc861vd_ignore[] = { 0x1d, 0 };
  9598. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  9599. alc861vd_ignore);
  9600. if (err < 0)
  9601. return err;
  9602. if (!spec->autocfg.line_outs)
  9603. return 0; /* can't find valid BIOS pin config */
  9604. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  9605. if (err < 0)
  9606. return err;
  9607. err = alc861vd_auto_create_multi_out_ctls(spec, &spec->autocfg);
  9608. if (err < 0)
  9609. return err;
  9610. err = alc861vd_auto_create_extra_out(spec,
  9611. spec->autocfg.speaker_pins[0],
  9612. "Speaker");
  9613. if (err < 0)
  9614. return err;
  9615. err = alc861vd_auto_create_extra_out(spec,
  9616. spec->autocfg.hp_pins[0],
  9617. "Headphone");
  9618. if (err < 0)
  9619. return err;
  9620. err = alc880_auto_create_analog_input_ctls(spec, &spec->autocfg);
  9621. if (err < 0)
  9622. return err;
  9623. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  9624. if (spec->autocfg.dig_out_pin)
  9625. spec->multiout.dig_out_nid = ALC861VD_DIGOUT_NID;
  9626. if (spec->kctl_alloc)
  9627. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  9628. spec->init_verbs[spec->num_init_verbs++]
  9629. = alc861vd_volume_init_verbs;
  9630. spec->num_mux_defs = 1;
  9631. spec->input_mux = &spec->private_imux;
  9632. return 1;
  9633. }
  9634. /* additional initialization for auto-configuration model */
  9635. static void alc861vd_auto_init(struct hda_codec *codec)
  9636. {
  9637. alc861vd_auto_init_multi_out(codec);
  9638. alc861vd_auto_init_hp_out(codec);
  9639. alc861vd_auto_init_analog_input(codec);
  9640. }
  9641. static int patch_alc861vd(struct hda_codec *codec)
  9642. {
  9643. struct alc_spec *spec;
  9644. int err, board_config;
  9645. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  9646. if (spec == NULL)
  9647. return -ENOMEM;
  9648. codec->spec = spec;
  9649. board_config = snd_hda_check_board_config(codec, ALC861VD_MODEL_LAST,
  9650. alc861vd_models,
  9651. alc861vd_cfg_tbl);
  9652. if (board_config < 0 || board_config >= ALC861VD_MODEL_LAST) {
  9653. printk(KERN_INFO "hda_codec: Unknown model for ALC660VD/"
  9654. "ALC861VD, trying auto-probe from BIOS...\n");
  9655. board_config = ALC861VD_AUTO;
  9656. }
  9657. if (board_config == ALC861VD_AUTO) {
  9658. /* automatic parse from the BIOS config */
  9659. err = alc861vd_parse_auto_config(codec);
  9660. if (err < 0) {
  9661. alc_free(codec);
  9662. return err;
  9663. } else if (!err) {
  9664. printk(KERN_INFO
  9665. "hda_codec: Cannot set up configuration "
  9666. "from BIOS. Using base mode...\n");
  9667. board_config = ALC861VD_3ST;
  9668. }
  9669. }
  9670. if (board_config != ALC861VD_AUTO)
  9671. setup_preset(spec, &alc861vd_presets[board_config]);
  9672. spec->stream_name_analog = "ALC861VD Analog";
  9673. spec->stream_analog_playback = &alc861vd_pcm_analog_playback;
  9674. spec->stream_analog_capture = &alc861vd_pcm_analog_capture;
  9675. spec->stream_name_digital = "ALC861VD Digital";
  9676. spec->stream_digital_playback = &alc861vd_pcm_digital_playback;
  9677. spec->stream_digital_capture = &alc861vd_pcm_digital_capture;
  9678. spec->adc_nids = alc861vd_adc_nids;
  9679. spec->num_adc_nids = ARRAY_SIZE(alc861vd_adc_nids);
  9680. spec->mixers[spec->num_mixers] = alc861vd_capture_mixer;
  9681. spec->num_mixers++;
  9682. codec->patch_ops = alc_patch_ops;
  9683. if (board_config == ALC861VD_AUTO)
  9684. spec->init_hook = alc861vd_auto_init;
  9685. return 0;
  9686. }
  9687. /*
  9688. * ALC662 support
  9689. *
  9690. * ALC662 is almost identical with ALC880 but has cleaner and more flexible
  9691. * configuration. Each pin widget can choose any input DACs and a mixer.
  9692. * Each ADC is connected from a mixer of all inputs. This makes possible
  9693. * 6-channel independent captures.
  9694. *
  9695. * In addition, an independent DAC for the multi-playback (not used in this
  9696. * driver yet).
  9697. */
  9698. #define ALC662_DIGOUT_NID 0x06
  9699. #define ALC662_DIGIN_NID 0x0a
  9700. static hda_nid_t alc662_dac_nids[4] = {
  9701. /* front, rear, clfe, rear_surr */
  9702. 0x02, 0x03, 0x04
  9703. };
  9704. static hda_nid_t alc662_adc_nids[1] = {
  9705. /* ADC1-2 */
  9706. 0x09,
  9707. };
  9708. /* input MUX */
  9709. /* FIXME: should be a matrix-type input source selection */
  9710. static struct hda_input_mux alc662_capture_source = {
  9711. .num_items = 4,
  9712. .items = {
  9713. { "Mic", 0x0 },
  9714. { "Front Mic", 0x1 },
  9715. { "Line", 0x2 },
  9716. { "CD", 0x4 },
  9717. },
  9718. };
  9719. static struct hda_input_mux alc662_lenovo_101e_capture_source = {
  9720. .num_items = 2,
  9721. .items = {
  9722. { "Mic", 0x1 },
  9723. { "Line", 0x2 },
  9724. },
  9725. };
  9726. #define alc662_mux_enum_info alc_mux_enum_info
  9727. #define alc662_mux_enum_get alc_mux_enum_get
  9728. static int alc662_mux_enum_put(struct snd_kcontrol *kcontrol,
  9729. struct snd_ctl_elem_value *ucontrol)
  9730. {
  9731. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  9732. struct alc_spec *spec = codec->spec;
  9733. const struct hda_input_mux *imux = spec->input_mux;
  9734. unsigned int adc_idx = snd_ctl_get_ioffidx(kcontrol, &ucontrol->id);
  9735. static hda_nid_t capture_mixers[3] = { 0x24, 0x23, 0x22 };
  9736. hda_nid_t nid = capture_mixers[adc_idx];
  9737. unsigned int *cur_val = &spec->cur_mux[adc_idx];
  9738. unsigned int i, idx;
  9739. idx = ucontrol->value.enumerated.item[0];
  9740. if (idx >= imux->num_items)
  9741. idx = imux->num_items - 1;
  9742. if (*cur_val == idx && !codec->in_resume)
  9743. return 0;
  9744. for (i = 0; i < imux->num_items; i++) {
  9745. unsigned int v = (i == idx) ? 0x7000 : 0x7080;
  9746. snd_hda_codec_write(codec, nid, 0, AC_VERB_SET_AMP_GAIN_MUTE,
  9747. v | (imux->items[i].index << 8));
  9748. }
  9749. *cur_val = idx;
  9750. return 1;
  9751. }
  9752. /*
  9753. * 2ch mode
  9754. */
  9755. static struct hda_channel_mode alc662_3ST_2ch_modes[1] = {
  9756. { 2, NULL }
  9757. };
  9758. /*
  9759. * 2ch mode
  9760. */
  9761. static struct hda_verb alc662_3ST_ch2_init[] = {
  9762. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80 },
  9763. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9764. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN },
  9765. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE },
  9766. { } /* end */
  9767. };
  9768. /*
  9769. * 6ch mode
  9770. */
  9771. static struct hda_verb alc662_3ST_ch6_init[] = {
  9772. { 0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9773. { 0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9774. { 0x18, AC_VERB_SET_CONNECT_SEL, 0x02 },
  9775. { 0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9776. { 0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE },
  9777. { 0x1a, AC_VERB_SET_CONNECT_SEL, 0x01 },
  9778. { } /* end */
  9779. };
  9780. static struct hda_channel_mode alc662_3ST_6ch_modes[2] = {
  9781. { 2, alc662_3ST_ch2_init },
  9782. { 6, alc662_3ST_ch6_init },
  9783. };
  9784. /*
  9785. * 2ch mode
  9786. */
  9787. static struct hda_verb alc662_sixstack_ch6_init[] = {
  9788. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9789. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, 0x00 },
  9790. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9791. { } /* end */
  9792. };
  9793. /*
  9794. * 6ch mode
  9795. */
  9796. static struct hda_verb alc662_sixstack_ch8_init[] = {
  9797. { 0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9798. { 0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9799. { 0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  9800. { } /* end */
  9801. };
  9802. static struct hda_channel_mode alc662_5stack_modes[2] = {
  9803. { 2, alc662_sixstack_ch6_init },
  9804. { 6, alc662_sixstack_ch8_init },
  9805. };
  9806. /* Pin assignment: Front=0x14, Rear=0x15, CLFE=0x16, Side=0x17
  9807. * Mic=0x18, Front Mic=0x19, Line-In=0x1a, HP=0x1b
  9808. */
  9809. static struct snd_kcontrol_new alc662_base_mixer[] = {
  9810. /* output mixer control */
  9811. HDA_CODEC_VOLUME("Front Playback Volume", 0x2, 0x0, HDA_OUTPUT),
  9812. HDA_CODEC_MUTE("Front Playback Switch", 0x02, 0x0, HDA_OUTPUT),
  9813. HDA_CODEC_VOLUME("Surround Playback Volume", 0x3, 0x0, HDA_OUTPUT),
  9814. HDA_CODEC_MUTE("Surround Playback Switch", 0x03, 0x0, HDA_OUTPUT),
  9815. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9816. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9817. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9818. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9819. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9820. /*Input mixer control */
  9821. HDA_CODEC_VOLUME("CD Playback Volume", 0xb, 0x4, HDA_INPUT),
  9822. HDA_CODEC_MUTE("CD Playback Switch", 0xb, 0x4, HDA_INPUT),
  9823. HDA_CODEC_VOLUME("Line Playback Volume", 0xb, 0x02, HDA_INPUT),
  9824. HDA_CODEC_MUTE("Line Playback Switch", 0xb, 0x02, HDA_INPUT),
  9825. HDA_CODEC_VOLUME("Mic Playback Volume", 0xb, 0x0, HDA_INPUT),
  9826. HDA_CODEC_MUTE("Mic Playback Switch", 0xb, 0x0, HDA_INPUT),
  9827. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0xb, 0x01, HDA_INPUT),
  9828. HDA_CODEC_MUTE("Front Mic Playback Switch", 0xb, 0x01, HDA_INPUT),
  9829. /* Capture mixer control */
  9830. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9831. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9832. {
  9833. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9834. .name = "Capture Source",
  9835. .count = 1,
  9836. .info = alc_mux_enum_info,
  9837. .get = alc_mux_enum_get,
  9838. .put = alc_mux_enum_put,
  9839. },
  9840. { } /* end */
  9841. };
  9842. static struct snd_kcontrol_new alc662_3ST_2ch_mixer[] = {
  9843. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9844. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9845. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9846. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9847. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9848. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9849. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9850. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9851. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9852. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9853. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9854. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9855. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9856. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9857. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9858. {
  9859. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9860. /* .name = "Capture Source", */
  9861. .name = "Input Source",
  9862. .count = 1,
  9863. .info = alc662_mux_enum_info,
  9864. .get = alc662_mux_enum_get,
  9865. .put = alc662_mux_enum_put,
  9866. },
  9867. { } /* end */
  9868. };
  9869. static struct snd_kcontrol_new alc662_3ST_6ch_mixer[] = {
  9870. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9871. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9872. HDA_CODEC_VOLUME("Surround Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9873. HDA_BIND_MUTE("Surround Playback Switch", 0x03, 2, HDA_INPUT),
  9874. HDA_CODEC_VOLUME_MONO("Center Playback Volume", 0x04, 1, 0x0, HDA_OUTPUT),
  9875. HDA_CODEC_VOLUME_MONO("LFE Playback Volume", 0x04, 2, 0x0, HDA_OUTPUT),
  9876. HDA_BIND_MUTE_MONO("Center Playback Switch", 0x04, 1, 2, HDA_INPUT),
  9877. HDA_BIND_MUTE_MONO("LFE Playback Switch", 0x04, 2, 2, HDA_INPUT),
  9878. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9879. HDA_CODEC_VOLUME("CD Playback Volume", 0x0b, 0x04, HDA_INPUT),
  9880. HDA_CODEC_MUTE("CD Playback Switch", 0x0b, 0x04, HDA_INPUT),
  9881. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9882. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9883. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x0, HDA_INPUT),
  9884. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x0, HDA_INPUT),
  9885. HDA_CODEC_VOLUME("Front Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9886. HDA_CODEC_MUTE("Front Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9887. HDA_CODEC_VOLUME("PC Speaker Playback Volume", 0x0b, 0x05, HDA_INPUT),
  9888. HDA_CODEC_MUTE("PC Speaker Playback Switch", 0x0b, 0x05, HDA_INPUT),
  9889. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9890. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9891. {
  9892. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9893. /* .name = "Capture Source", */
  9894. .name = "Input Source",
  9895. .count = 1,
  9896. .info = alc662_mux_enum_info,
  9897. .get = alc662_mux_enum_get,
  9898. .put = alc662_mux_enum_put,
  9899. },
  9900. { } /* end */
  9901. };
  9902. static struct snd_kcontrol_new alc662_lenovo_101e_mixer[] = {
  9903. HDA_CODEC_VOLUME("Front Playback Volume", 0x02, 0x0, HDA_OUTPUT),
  9904. HDA_BIND_MUTE("Front Playback Switch", 0x02, 2, HDA_INPUT),
  9905. HDA_CODEC_VOLUME("iSpeaker Playback Volume", 0x03, 0x0, HDA_OUTPUT),
  9906. HDA_BIND_MUTE("iSpeaker Playback Switch", 0x03, 2, HDA_INPUT),
  9907. HDA_CODEC_MUTE("Headphone Playback Switch", 0x1b, 0x0, HDA_OUTPUT),
  9908. HDA_CODEC_VOLUME("Line Playback Volume", 0x0b, 0x02, HDA_INPUT),
  9909. HDA_CODEC_MUTE("Line Playback Switch", 0x0b, 0x02, HDA_INPUT),
  9910. HDA_CODEC_VOLUME("Mic Playback Volume", 0x0b, 0x1, HDA_INPUT),
  9911. HDA_CODEC_MUTE("Mic Playback Switch", 0x0b, 0x1, HDA_INPUT),
  9912. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  9913. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  9914. {
  9915. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9916. /* .name = "Capture Source", */
  9917. .name = "Input Source",
  9918. .count = 1,
  9919. .info = alc662_mux_enum_info,
  9920. .get = alc662_mux_enum_get,
  9921. .put = alc662_mux_enum_put,
  9922. },
  9923. { } /* end */
  9924. };
  9925. static struct snd_kcontrol_new alc662_chmode_mixer[] = {
  9926. {
  9927. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  9928. .name = "Channel Mode",
  9929. .info = alc_ch_mode_info,
  9930. .get = alc_ch_mode_get,
  9931. .put = alc_ch_mode_put,
  9932. },
  9933. { } /* end */
  9934. };
  9935. static struct hda_verb alc662_init_verbs[] = {
  9936. /* ADC: mute amp left and right */
  9937. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_MUTE(0)},
  9938. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9939. /* Front mixer: unmute input/output amp left and right (volume = 0) */
  9940. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9941. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9942. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9943. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  9944. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9945. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9946. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9947. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9948. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9949. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9950. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9951. /* Front Pin: output 0 (0x0c) */
  9952. {0x14, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9953. {0x14, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9954. /* Rear Pin: output 1 (0x0d) */
  9955. {0x15, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9956. {0x15, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9957. /* CLFE Pin: output 2 (0x0e) */
  9958. {0x16, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT},
  9959. {0x16, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9960. /* Mic (rear) pin: input vref at 80% */
  9961. {0x18, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9962. {0x18, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9963. /* Front Mic pin: input vref at 80% */
  9964. {0x19, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_VREF80},
  9965. {0x19, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9966. /* Line In pin: input */
  9967. {0x1a, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9968. {0x1a, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE},
  9969. /* Line-2 In: Headphone output (output 0 - 0x0c) */
  9970. {0x1b, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP},
  9971. {0x1b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE},
  9972. {0x1b, AC_VERB_SET_CONNECT_SEL, 0x00},
  9973. /* CD pin widget for input */
  9974. {0x1c, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_IN},
  9975. /* FIXME: use matrix-type input source selection */
  9976. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  9977. /* Input mixer */
  9978. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9979. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  9980. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  9981. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  9982. { }
  9983. };
  9984. static struct hda_verb alc662_sue_init_verbs[] = {
  9985. {0x14, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_FRONT_EVENT},
  9986. {0x1b, AC_VERB_SET_UNSOLICITED_ENABLE, AC_USRSP_EN|ALC880_HP_EVENT},
  9987. {}
  9988. };
  9989. /*
  9990. * generic initialization of ADC, input mixers and output mixers
  9991. */
  9992. static struct hda_verb alc662_auto_init_verbs[] = {
  9993. /*
  9994. * Unmute ADC and set the default input to mic-in
  9995. */
  9996. {0x09, AC_VERB_SET_CONNECT_SEL, 0x00},
  9997. {0x09, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  9998. /* Unmute input amps (CD, Line In, Mic 1 & Mic 2) of the analog-loopback
  9999. * mixer widget
  10000. * Note: PASD motherboards uses the Line In 2 as the input for front
  10001. * panel mic (mic 2)
  10002. */
  10003. /* Amp Indices: Mic1 = 0, Mic2 = 1, Line1 = 2, Line2 = 3, CD = 4 */
  10004. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10005. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10006. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10007. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},
  10008. {0x0b, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10009. /*
  10010. * Set up output mixers (0x0c - 0x0f)
  10011. */
  10012. /* set vol=0 to output mixers */
  10013. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10014. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10015. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_ZERO},
  10016. /* set up input amps for analog loopback */
  10017. /* Amp Indices: DAC = 0, mixer = 1 */
  10018. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10019. {0x02, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10020. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10021. {0x03, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10022. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10023. {0x04, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10024. /* FIXME: use matrix-type input source selection */
  10025. /* Mixer elements: 0x18, 19, 1a, 1b, 1c, 1d, 14, 15, 16, 17, 0b */
  10026. /* Input mixer */
  10027. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(0)},
  10028. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(1)},
  10029. {0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(2)},
  10030. /*{0x22, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(3)},*/
  10031. {0x23, AC_VERB_SET_AMP_GAIN_MUTE, AMP_IN_UNMUTE(4)},
  10032. { }
  10033. };
  10034. /* capture mixer elements */
  10035. static struct snd_kcontrol_new alc662_capture_mixer[] = {
  10036. HDA_CODEC_VOLUME("Capture Volume", 0x09, 0x0, HDA_INPUT),
  10037. HDA_CODEC_MUTE("Capture Switch", 0x09, 0x0, HDA_INPUT),
  10038. {
  10039. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  10040. /* The multiple "Capture Source" controls confuse alsamixer
  10041. * So call somewhat different..
  10042. * FIXME: the controls appear in the "playback" view!
  10043. */
  10044. /* .name = "Capture Source", */
  10045. .name = "Input Source",
  10046. .count = 1,
  10047. .info = alc882_mux_enum_info,
  10048. .get = alc882_mux_enum_get,
  10049. .put = alc882_mux_enum_put,
  10050. },
  10051. { } /* end */
  10052. };
  10053. static void alc662_lenovo_101e_ispeaker_automute(struct hda_codec *codec)
  10054. {
  10055. unsigned int present;
  10056. unsigned char bits;
  10057. present = snd_hda_codec_read(codec, 0x14, 0,
  10058. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10059. bits = present ? 0x80 : 0;
  10060. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  10061. 0x80, bits);
  10062. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  10063. 0x80, bits);
  10064. }
  10065. static void alc662_lenovo_101e_all_automute(struct hda_codec *codec)
  10066. {
  10067. unsigned int present;
  10068. unsigned char bits;
  10069. present = snd_hda_codec_read(codec, 0x1b, 0,
  10070. AC_VERB_GET_PIN_SENSE, 0) & 0x80000000;
  10071. bits = present ? 0x80 : 0;
  10072. snd_hda_codec_amp_update(codec, 0x15, 0, HDA_OUTPUT, 0,
  10073. 0x80, bits);
  10074. snd_hda_codec_amp_update(codec, 0x15, 1, HDA_OUTPUT, 0,
  10075. 0x80, bits);
  10076. snd_hda_codec_amp_update(codec, 0x14, 0, HDA_OUTPUT, 0,
  10077. 0x80, bits);
  10078. snd_hda_codec_amp_update(codec, 0x14, 1, HDA_OUTPUT, 0,
  10079. 0x80, bits);
  10080. }
  10081. static void alc662_lenovo_101e_unsol_event(struct hda_codec *codec,
  10082. unsigned int res)
  10083. {
  10084. if ((res >> 26) == ALC880_HP_EVENT)
  10085. alc662_lenovo_101e_all_automute(codec);
  10086. if ((res >> 26) == ALC880_FRONT_EVENT)
  10087. alc662_lenovo_101e_ispeaker_automute(codec);
  10088. }
  10089. /* pcm configuration: identiacal with ALC880 */
  10090. #define alc662_pcm_analog_playback alc880_pcm_analog_playback
  10091. #define alc662_pcm_analog_capture alc880_pcm_analog_capture
  10092. #define alc662_pcm_digital_playback alc880_pcm_digital_playback
  10093. #define alc662_pcm_digital_capture alc880_pcm_digital_capture
  10094. /*
  10095. * configuration and preset
  10096. */
  10097. static const char *alc662_models[ALC662_MODEL_LAST] = {
  10098. [ALC662_3ST_2ch_DIG] = "3stack-dig",
  10099. [ALC662_3ST_6ch_DIG] = "3stack-6ch-dig",
  10100. [ALC662_3ST_6ch] = "3stack-6ch",
  10101. [ALC662_5ST_DIG] = "6stack-dig",
  10102. [ALC662_LENOVO_101E] = "lenovo-101e",
  10103. [ALC662_AUTO] = "auto",
  10104. };
  10105. static struct snd_pci_quirk alc662_cfg_tbl[] = {
  10106. SND_PCI_QUIRK(0x17aa, 0x101e, "Lenovo", ALC662_LENOVO_101E),
  10107. {}
  10108. };
  10109. static struct alc_config_preset alc662_presets[] = {
  10110. [ALC662_3ST_2ch_DIG] = {
  10111. .mixers = { alc662_3ST_2ch_mixer },
  10112. .init_verbs = { alc662_init_verbs },
  10113. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10114. .dac_nids = alc662_dac_nids,
  10115. .dig_out_nid = ALC662_DIGOUT_NID,
  10116. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10117. .adc_nids = alc662_adc_nids,
  10118. .dig_in_nid = ALC662_DIGIN_NID,
  10119. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10120. .channel_mode = alc662_3ST_2ch_modes,
  10121. .input_mux = &alc662_capture_source,
  10122. },
  10123. [ALC662_3ST_6ch_DIG] = {
  10124. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10125. .init_verbs = { alc662_init_verbs },
  10126. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10127. .dac_nids = alc662_dac_nids,
  10128. .dig_out_nid = ALC662_DIGOUT_NID,
  10129. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10130. .adc_nids = alc662_adc_nids,
  10131. .dig_in_nid = ALC662_DIGIN_NID,
  10132. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10133. .channel_mode = alc662_3ST_6ch_modes,
  10134. .need_dac_fix = 1,
  10135. .input_mux = &alc662_capture_source,
  10136. },
  10137. [ALC662_3ST_6ch] = {
  10138. .mixers = { alc662_3ST_6ch_mixer, alc662_chmode_mixer },
  10139. .init_verbs = { alc662_init_verbs },
  10140. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10141. .dac_nids = alc662_dac_nids,
  10142. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10143. .adc_nids = alc662_adc_nids,
  10144. .num_channel_mode = ARRAY_SIZE(alc662_3ST_6ch_modes),
  10145. .channel_mode = alc662_3ST_6ch_modes,
  10146. .need_dac_fix = 1,
  10147. .input_mux = &alc662_capture_source,
  10148. },
  10149. [ALC662_5ST_DIG] = {
  10150. .mixers = { alc662_base_mixer, alc662_chmode_mixer },
  10151. .init_verbs = { alc662_init_verbs },
  10152. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10153. .dac_nids = alc662_dac_nids,
  10154. .dig_out_nid = ALC662_DIGOUT_NID,
  10155. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10156. .adc_nids = alc662_adc_nids,
  10157. .dig_in_nid = ALC662_DIGIN_NID,
  10158. .num_channel_mode = ARRAY_SIZE(alc662_5stack_modes),
  10159. .channel_mode = alc662_5stack_modes,
  10160. .input_mux = &alc662_capture_source,
  10161. },
  10162. [ALC662_LENOVO_101E] = {
  10163. .mixers = { alc662_lenovo_101e_mixer },
  10164. .init_verbs = { alc662_init_verbs, alc662_sue_init_verbs },
  10165. .num_dacs = ARRAY_SIZE(alc662_dac_nids),
  10166. .dac_nids = alc662_dac_nids,
  10167. .num_adc_nids = ARRAY_SIZE(alc662_adc_nids),
  10168. .adc_nids = alc662_adc_nids,
  10169. .num_channel_mode = ARRAY_SIZE(alc662_3ST_2ch_modes),
  10170. .channel_mode = alc662_3ST_2ch_modes,
  10171. .input_mux = &alc662_lenovo_101e_capture_source,
  10172. .unsol_event = alc662_lenovo_101e_unsol_event,
  10173. .init_hook = alc662_lenovo_101e_all_automute,
  10174. },
  10175. };
  10176. /*
  10177. * BIOS auto configuration
  10178. */
  10179. /* add playback controls from the parsed DAC table */
  10180. static int alc662_auto_create_multi_out_ctls(struct alc_spec *spec,
  10181. const struct auto_pin_cfg *cfg)
  10182. {
  10183. char name[32];
  10184. static const char *chname[4] = {
  10185. "Front", "Surround", NULL /*CLFE*/, "Side"
  10186. };
  10187. hda_nid_t nid;
  10188. int i, err;
  10189. for (i = 0; i < cfg->line_outs; i++) {
  10190. if (!spec->multiout.dac_nids[i])
  10191. continue;
  10192. nid = alc880_idx_to_mixer(i);
  10193. if (i == 2) {
  10194. /* Center/LFE */
  10195. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10196. "Center Playback Volume",
  10197. HDA_COMPOSE_AMP_VAL(nid, 1, 0,
  10198. HDA_OUTPUT));
  10199. if (err < 0)
  10200. return err;
  10201. err = add_control(spec, ALC_CTL_WIDGET_VOL,
  10202. "LFE Playback Volume",
  10203. HDA_COMPOSE_AMP_VAL(nid, 2, 0,
  10204. HDA_OUTPUT));
  10205. if (err < 0)
  10206. return err;
  10207. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10208. "Center Playback Switch",
  10209. HDA_COMPOSE_AMP_VAL(nid, 1, 2,
  10210. HDA_INPUT));
  10211. if (err < 0)
  10212. return err;
  10213. err = add_control(spec, ALC_CTL_BIND_MUTE,
  10214. "LFE Playback Switch",
  10215. HDA_COMPOSE_AMP_VAL(nid, 2, 2,
  10216. HDA_INPUT));
  10217. if (err < 0)
  10218. return err;
  10219. } else {
  10220. sprintf(name, "%s Playback Volume", chname[i]);
  10221. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10222. HDA_COMPOSE_AMP_VAL(nid, 3, 0,
  10223. HDA_OUTPUT));
  10224. if (err < 0)
  10225. return err;
  10226. sprintf(name, "%s Playback Switch", chname[i]);
  10227. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10228. HDA_COMPOSE_AMP_VAL(nid, 3, 2,
  10229. HDA_INPUT));
  10230. if (err < 0)
  10231. return err;
  10232. }
  10233. }
  10234. return 0;
  10235. }
  10236. /* add playback controls for speaker and HP outputs */
  10237. static int alc662_auto_create_extra_out(struct alc_spec *spec, hda_nid_t pin,
  10238. const char *pfx)
  10239. {
  10240. hda_nid_t nid;
  10241. int err;
  10242. char name[32];
  10243. if (!pin)
  10244. return 0;
  10245. if (alc880_is_fixed_pin(pin)) {
  10246. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10247. /* printk("DAC nid=%x\n",nid); */
  10248. /* specify the DAC as the extra output */
  10249. if (!spec->multiout.hp_nid)
  10250. spec->multiout.hp_nid = nid;
  10251. else
  10252. spec->multiout.extra_out_nid[0] = nid;
  10253. /* control HP volume/switch on the output mixer amp */
  10254. nid = alc880_idx_to_dac(alc880_fixed_pin_idx(pin));
  10255. sprintf(name, "%s Playback Volume", pfx);
  10256. err = add_control(spec, ALC_CTL_WIDGET_VOL, name,
  10257. HDA_COMPOSE_AMP_VAL(nid, 3, 0, HDA_OUTPUT));
  10258. if (err < 0)
  10259. return err;
  10260. sprintf(name, "%s Playback Switch", pfx);
  10261. err = add_control(spec, ALC_CTL_BIND_MUTE, name,
  10262. HDA_COMPOSE_AMP_VAL(nid, 3, 2, HDA_INPUT));
  10263. if (err < 0)
  10264. return err;
  10265. } else if (alc880_is_multi_pin(pin)) {
  10266. /* set manual connection */
  10267. /* we have only a switch on HP-out PIN */
  10268. sprintf(name, "%s Playback Switch", pfx);
  10269. err = add_control(spec, ALC_CTL_WIDGET_MUTE, name,
  10270. HDA_COMPOSE_AMP_VAL(pin, 3, 0, HDA_OUTPUT));
  10271. if (err < 0)
  10272. return err;
  10273. }
  10274. return 0;
  10275. }
  10276. /* create playback/capture controls for input pins */
  10277. static int alc662_auto_create_analog_input_ctls(struct alc_spec *spec,
  10278. const struct auto_pin_cfg *cfg)
  10279. {
  10280. struct hda_input_mux *imux = &spec->private_imux;
  10281. int i, err, idx;
  10282. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10283. if (alc880_is_input_pin(cfg->input_pins[i])) {
  10284. idx = alc880_input_pin_idx(cfg->input_pins[i]);
  10285. err = new_analog_input(spec, cfg->input_pins[i],
  10286. auto_pin_cfg_labels[i],
  10287. idx, 0x0b);
  10288. if (err < 0)
  10289. return err;
  10290. imux->items[imux->num_items].label =
  10291. auto_pin_cfg_labels[i];
  10292. imux->items[imux->num_items].index =
  10293. alc880_input_pin_idx(cfg->input_pins[i]);
  10294. imux->num_items++;
  10295. }
  10296. }
  10297. return 0;
  10298. }
  10299. static void alc662_auto_set_output_and_unmute(struct hda_codec *codec,
  10300. hda_nid_t nid, int pin_type,
  10301. int dac_idx)
  10302. {
  10303. /* set as output */
  10304. snd_hda_codec_write(codec, nid, 0,
  10305. AC_VERB_SET_PIN_WIDGET_CONTROL, pin_type);
  10306. snd_hda_codec_write(codec, nid, 0,
  10307. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  10308. /* need the manual connection? */
  10309. if (alc880_is_multi_pin(nid)) {
  10310. struct alc_spec *spec = codec->spec;
  10311. int idx = alc880_multi_pin_idx(nid);
  10312. snd_hda_codec_write(codec, alc880_idx_to_selector(idx), 0,
  10313. AC_VERB_SET_CONNECT_SEL,
  10314. alc880_dac_to_idx(spec->multiout.dac_nids[dac_idx]));
  10315. }
  10316. }
  10317. static void alc662_auto_init_multi_out(struct hda_codec *codec)
  10318. {
  10319. struct alc_spec *spec = codec->spec;
  10320. int i;
  10321. for (i = 0; i <= HDA_SIDE; i++) {
  10322. hda_nid_t nid = spec->autocfg.line_out_pins[i];
  10323. int pin_type = get_pin_type(spec->autocfg.line_out_type);
  10324. if (nid)
  10325. alc662_auto_set_output_and_unmute(codec, nid, pin_type,
  10326. i);
  10327. }
  10328. }
  10329. static void alc662_auto_init_hp_out(struct hda_codec *codec)
  10330. {
  10331. struct alc_spec *spec = codec->spec;
  10332. hda_nid_t pin;
  10333. pin = spec->autocfg.hp_pins[0];
  10334. if (pin) /* connect to front */
  10335. /* use dac 0 */
  10336. alc662_auto_set_output_and_unmute(codec, pin, PIN_HP, 0);
  10337. }
  10338. #define alc662_is_input_pin(nid) alc880_is_input_pin(nid)
  10339. #define ALC662_PIN_CD_NID ALC880_PIN_CD_NID
  10340. static void alc662_auto_init_analog_input(struct hda_codec *codec)
  10341. {
  10342. struct alc_spec *spec = codec->spec;
  10343. int i;
  10344. for (i = 0; i < AUTO_PIN_LAST; i++) {
  10345. hda_nid_t nid = spec->autocfg.input_pins[i];
  10346. if (alc662_is_input_pin(nid)) {
  10347. snd_hda_codec_write(codec, nid, 0,
  10348. AC_VERB_SET_PIN_WIDGET_CONTROL,
  10349. (i <= AUTO_PIN_FRONT_MIC ?
  10350. PIN_VREF80 : PIN_IN));
  10351. if (nid != ALC662_PIN_CD_NID)
  10352. snd_hda_codec_write(codec, nid, 0,
  10353. AC_VERB_SET_AMP_GAIN_MUTE,
  10354. AMP_OUT_MUTE);
  10355. }
  10356. }
  10357. }
  10358. static int alc662_parse_auto_config(struct hda_codec *codec)
  10359. {
  10360. struct alc_spec *spec = codec->spec;
  10361. int err;
  10362. static hda_nid_t alc662_ignore[] = { 0x1d, 0 };
  10363. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg,
  10364. alc662_ignore);
  10365. if (err < 0)
  10366. return err;
  10367. if (!spec->autocfg.line_outs)
  10368. return 0; /* can't find valid BIOS pin config */
  10369. err = alc880_auto_fill_dac_nids(spec, &spec->autocfg);
  10370. if (err < 0)
  10371. return err;
  10372. err = alc662_auto_create_multi_out_ctls(spec, &spec->autocfg);
  10373. if (err < 0)
  10374. return err;
  10375. err = alc662_auto_create_extra_out(spec,
  10376. spec->autocfg.speaker_pins[0],
  10377. "Speaker");
  10378. if (err < 0)
  10379. return err;
  10380. err = alc662_auto_create_extra_out(spec, spec->autocfg.hp_pins[0],
  10381. "Headphone");
  10382. if (err < 0)
  10383. return err;
  10384. err = alc662_auto_create_analog_input_ctls(spec, &spec->autocfg);
  10385. if (err < 0)
  10386. return err;
  10387. spec->multiout.max_channels = spec->multiout.num_dacs * 2;
  10388. if (spec->autocfg.dig_out_pin)
  10389. spec->multiout.dig_out_nid = ALC880_DIGOUT_NID;
  10390. if (spec->kctl_alloc)
  10391. spec->mixers[spec->num_mixers++] = spec->kctl_alloc;
  10392. spec->num_mux_defs = 1;
  10393. spec->input_mux = &spec->private_imux;
  10394. spec->init_verbs[spec->num_init_verbs++] = alc662_auto_init_verbs;
  10395. spec->mixers[spec->num_mixers] = alc662_capture_mixer;
  10396. spec->num_mixers++;
  10397. return 1;
  10398. }
  10399. /* additional initialization for auto-configuration model */
  10400. static void alc662_auto_init(struct hda_codec *codec)
  10401. {
  10402. alc662_auto_init_multi_out(codec);
  10403. alc662_auto_init_hp_out(codec);
  10404. alc662_auto_init_analog_input(codec);
  10405. }
  10406. static int patch_alc662(struct hda_codec *codec)
  10407. {
  10408. struct alc_spec *spec;
  10409. int err, board_config;
  10410. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  10411. if (!spec)
  10412. return -ENOMEM;
  10413. codec->spec = spec;
  10414. board_config = snd_hda_check_board_config(codec, ALC662_MODEL_LAST,
  10415. alc662_models,
  10416. alc662_cfg_tbl);
  10417. if (board_config < 0) {
  10418. printk(KERN_INFO "hda_codec: Unknown model for ALC662, "
  10419. "trying auto-probe from BIOS...\n");
  10420. board_config = ALC662_AUTO;
  10421. }
  10422. if (board_config == ALC662_AUTO) {
  10423. /* automatic parse from the BIOS config */
  10424. err = alc662_parse_auto_config(codec);
  10425. if (err < 0) {
  10426. alc_free(codec);
  10427. return err;
  10428. } else if (!err) {
  10429. printk(KERN_INFO
  10430. "hda_codec: Cannot set up configuration "
  10431. "from BIOS. Using base mode...\n");
  10432. board_config = ALC662_3ST_2ch_DIG;
  10433. }
  10434. }
  10435. if (board_config != ALC662_AUTO)
  10436. setup_preset(spec, &alc662_presets[board_config]);
  10437. spec->stream_name_analog = "ALC662 Analog";
  10438. spec->stream_analog_playback = &alc662_pcm_analog_playback;
  10439. spec->stream_analog_capture = &alc662_pcm_analog_capture;
  10440. spec->stream_name_digital = "ALC662 Digital";
  10441. spec->stream_digital_playback = &alc662_pcm_digital_playback;
  10442. spec->stream_digital_capture = &alc662_pcm_digital_capture;
  10443. if (!spec->adc_nids && spec->input_mux) {
  10444. spec->adc_nids = alc662_adc_nids;
  10445. spec->num_adc_nids = ARRAY_SIZE(alc662_adc_nids);
  10446. }
  10447. codec->patch_ops = alc_patch_ops;
  10448. if (board_config == ALC662_AUTO)
  10449. spec->init_hook = alc662_auto_init;
  10450. return 0;
  10451. }
  10452. /*
  10453. * patch entries
  10454. */
  10455. struct hda_codec_preset snd_hda_preset_realtek[] = {
  10456. { .id = 0x10ec0260, .name = "ALC260", .patch = patch_alc260 },
  10457. { .id = 0x10ec0262, .name = "ALC262", .patch = patch_alc262 },
  10458. { .id = 0x10ec0268, .name = "ALC268", .patch = patch_alc268 },
  10459. { .id = 0x10ec0861, .rev = 0x100340, .name = "ALC660",
  10460. .patch = patch_alc861 },
  10461. { .id = 0x10ec0660, .name = "ALC660-VD", .patch = patch_alc861vd },
  10462. { .id = 0x10ec0861, .name = "ALC861", .patch = patch_alc861 },
  10463. { .id = 0x10ec0862, .name = "ALC861-VD", .patch = patch_alc861vd },
  10464. { .id = 0x10ec0662, .rev = 0x100002, .name = "ALC662 rev2",
  10465. .patch = patch_alc883 },
  10466. { .id = 0x10ec0662, .rev = 0x100101, .name = "ALC662 rev1",
  10467. .patch = patch_alc662 },
  10468. { .id = 0x10ec0880, .name = "ALC880", .patch = patch_alc880 },
  10469. { .id = 0x10ec0882, .name = "ALC882", .patch = patch_alc882 },
  10470. { .id = 0x10ec0883, .name = "ALC883", .patch = patch_alc883 },
  10471. { .id = 0x10ec0885, .name = "ALC885", .patch = patch_alc882 },
  10472. { .id = 0x10ec0888, .name = "ALC888", .patch = patch_alc883 },
  10473. {} /* terminator */
  10474. };